After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 580093 - tcpserversink,src: add 'current-port' property and signal actually used port when port=0 was set
tcpserversink,src: add 'current-port' property and signal actually used port ...
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-base
git master
Other Linux
: Normal enhancement
: 1.0.2
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2009-04-24 09:36 UTC by Luca Ognibene
Modified: 2012-10-19 17:33 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
add getsockname (1.03 KB, patch)
2009-04-24 09:40 UTC, Luca Ognibene
needs-work Details | Review
update "port" property with real port on tcpserver sink AND src when using port 0 (1.88 KB, patch)
2012-03-09 18:26 UTC, Alexandre RELANGE
needs-work Details | Review
update port property with real port number when automatic binding (port=0) is used (2.21 KB, patch)
2012-10-12 07:57 UTC, Alexandre RELANGE
needs-work Details | Review
lock on server_port variable (3.77 KB, patch)
2012-10-12 08:10 UTC, Alexandre RELANGE
needs-work Details | Review
tcpserversink,src: add 'current-port' property (5.88 KB, patch)
2012-10-17 10:34 UTC, Alexandre RELANGE
reviewed Details | Review

Description Luca Ognibene 2009-04-24 09:36:17 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.
Comment 1 Luca Ognibene 2009-04-24 09:40:16 UTC
Created attachment 133245 [details] [review]
add getsockname
Comment 2 Luca Ognibene 2009-09-25 13:05:47 UTC
ping.. i think this can be useful
Comment 3 Sebastian Dröge (slomo) 2009-09-30 17:09:49 UTC
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.
Comment 4 Alexandre RELANGE 2012-03-09 18:26:55 UTC
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...
Comment 5 Alexandre RELANGE 2012-04-03 09:15:13 UTC
up ? nobody interested ?
Comment 6 Tim-Philipp Müller 2012-10-04 10:00:48 UTC
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.
Comment 7 Alexandre RELANGE 2012-10-12 07:57:52 UTC
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
Comment 8 Alexandre RELANGE 2012-10-12 08:10:13 UTC
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 ?
Comment 9 Tim-Philipp Müller 2012-10-12 20:25:56 UTC
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.
Comment 10 Tim-Philipp Müller 2012-10-15 13:21:33 UTC
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).
Comment 11 Alexandre RELANGE 2012-10-17 10:34:58 UTC
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.
Comment 12 Tim-Philipp Müller 2012-10-19 17:32:51 UTC
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