GNOME Bugzilla – Bug 580093
tcpserversink,src: add 'current-port' property and signal actually used port when port=0 was set
Last modified: 2012-10-19 17:33:15 UTC
Right now you can pass 0 to tcpserversink as port parameter, OS will select a random free port but you don't know which.. This patch add as a call to getsockname so you can do: * create tcpserversink port=0 * set_state(READY) * ret = element.get_property(port) Without the patch ret is 0. With the patch ret points to the port selected by the OS.
Created attachment 133245 [details] [review] add getsockname
ping.. i think this can be useful
The patch looks good in general but please do g_object_notify(obj, "port") after the port property has changed. Also the same should probably applied to tcpserversrc.
Created attachment 209342 [details] [review] update "port" property with real port on tcpserver sink AND src when using port 0 updated patch fix tcpserver sink and src added object notify after property value update May still be usefull...
up ? nobody interested ?
No, we're still interested, but have been busy working on 1.0. The patch needs updating for 1.0. Some locking would be good too.
Created attachment 226314 [details] [review] update port property with real port number when automatic binding (port=0) is used Thank you very much Tim ! Here is the version updated for the 1.0.x series. The lock will be in a separate patch
Created attachment 226315 [details] [review] lock on server_port variable Well... this is a lock to prevent modification of server_port variable especially during connection process and update of the value when port=0 is used. Although I do not really think this lock is useful since gst_tcp_server_src_start () is run only once each time we start the plugin (should not be run twice in parallel) and if someone try to set the port property during this startup, the behavior is unpredictable anyway. The value must be configured BEFORE the plugin state is changed. Am I wrong ?
No, I think you're right. What I was thinking of is this: - you set the port property to 0 - then you use the element, and a port gets selected automatically, now you store that port in the property variable - now you shut down the element, and start it up again - but now the port is no longer 0 but what was used in the previous run, which may or may not work. A port is no longer selected automatically. - to work around that, you'd have to get the port from the addr in the property getter *if* the property is 0 and addr exists, I think. Not really sure if that's how it's supposed to work tbh.
Ok, so I think the consensus is that what we should do here is to add a new read-only "current-port" property, and then notify on that. The "port" property would still return 0 if set to 0, and current-port would either return 0 or the currently-bound-to port if we are bound. Think you could whip up a new patch for that? (Sorry for the hoops).
Created attachment 226624 [details] [review] tcpserversink,src: add 'current-port' property Here it is ! Add the read only 'current-port' property. Its value is retrieved only in get_property, and notified in init/start and close/stop.
Thanks! I've shuffled things around a little, hope you don't mind. commit 0ea65267702f3731e9fb7838e58de44cfe93f4ca Author: Tim-Philipp Müller <tim.muller@collabora.co.uk> Date: Fri Oct 19 18:29:00 2012 +0100 tcpserver{sink,src}: improve docs and property strings And some minor clean-ups. commit d2f1d827781763a3bf9ce9d88f821152c829138d Author: Alexandre Relange <alexandre.relange@pineasystems.org> Date: Wed Oct 17 12:19:56 2012 +0200 tcpserver{sink,src}: add 'current-port' property and signal actually used port Useful when port=0 (use random available port) was requested. https://bugzilla.gnome.org/show_bug.cgi?id=580093