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 604870 - [udpsink] Can't set TTL socket option
[udpsink] Can't set TTL socket option
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-good
0.10.17
Other Windows
: Normal normal
: 0.10.22
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2009-12-18 00:02 UTC by Andoni Morales
Modified: 2012-10-12 07:42 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
0001-multiudpsink-swallow-errors-trying-to-call-getsockna.patch (887 bytes, patch)
2010-03-10 19:26 UTC, Andoni Morales
rejected Details | Review
0001-multiudpsink-avoid-getting-the-socket-family-using-g.patch (5.14 KB, patch)
2010-03-10 21:31 UTC, Andoni Morales
accepted-commit_now Details | Review
Fixes for udp on windows vista / 7 (20.55 KB, patch)
2010-03-12 00:52 UTC, Richard Spiers
none Details | Review
0001-udpsink-errors-setting-the-ttl-option-on-windows-are (1.06 KB, patch)
2012-10-11 16:11 UTC, Andoni Morales
committed Details | Review

Description Andoni Morales 2009-12-18 00:02:28 UTC
Running the following pipeline on windows with gstupd from gst-plugins-bad exits with an error:

$ export GST_DEBUG=*udp*:5 && gst-launch-0.10.exe videotestsrc ! videoscale ! theoraenc ! queue ! udpsink  host=127.0.0.1 po
rt=12343
0:00:00.390625000  3600   00392A98 DEBUG           multiudpsink gstmultiudpsink.c:816:gst_multiudpsink_add_internal:<GstUDPSink@00B244C8> adding client on host localhost, port 4951
0:00:00.390625000  3600   00392A98 DEBUG           multiudpsink gstmultiudpsink.c:850:gst_multiudpsink_add_internal:<GstUDPSink@00B244C8> added client on host localhost, port 4951
0:00:00.390625000  3600   00392A98 DEBUG           multiudpsink gstmultiudpsink.c:904:gst_multiudpsink_remove:<udpsink0> remove client with host localhost, port 4951
0:00:00.390625000  3600   00392A98 DEBUG           multiudpsink gstmultiudpsink.c:816:gst_multiudpsink_add_internal:<udpsink0> adding client on host 127.0.0.1, port 4951
0:00:00.390625000  3600   00392A98 DEBUG           multiudpsink gstmultiudpsink.c:850:gst_multiudpsink_add_internal:<udpsink0> added client on host 127.0.0.1, port 4951
0:00:00.390625000  3600   00392A98 DEBUG           multiudpsink gstmultiudpsink.c:904:gst_multiudpsink_remove:<udpsink0> remove client with host 127.0.0.1, port 4951
0:00:00.390625000  3600   00392A98 DEBUG           multiudpsink gstmultiudpsink.c:816:gst_multiudpsink_add_internal:<udpsink0> adding client on host 127.0.0.1, port 12343
0:00:00.390625000  3600   00392A98 DEBUG           multiudpsink gstmultiudpsink.c:850:gst_multiudpsink_add_internal:<udpsink0> added client on host 127.0.0.1, port 12343
Setting pipeline to PAUSED ...
0:00:00.515625000  3600   00392A98 WARN            multiudpsink gstmultiudpsink.c:790:gst_multiudpsink_init_send:<udpsink0> error: Could not set TTL socket option (0): No error
ERROR: Pipeline doesn't want to pause.
ERROR: from element /GstPipeline:pipeline0/GstUDPSink:udpsink0: Could not get/set settings from/on resource.
Additional debug info:
..\..\..\Source\gst-plugins-good\gst\udp\gstmultiudpsink.c(790): gst_multiudpsink_init_send (): /GstPipeline:pipeline0/GstUDPSink:udpsink0:
Could not set TTL socket option (0): No error
Setting pipeline to NULL ...
Freeing pipeline ...

The udpsink element is working fine for gst-plugins-good-0.10.15

To reproduce the error you can use GStreamer WinBuild 0.10.5
Comment 1 Andoni Morales 2009-12-18 00:03:59 UTC
I ment gst-plugins-good 0.10.17, instead of gst-plugins-bad.
Comment 2 Andoni Morales 2009-12-18 00:15:53 UTC
This commit seems to be the cause:
http://cgit.freedesktop.org/gstreamer/gst-plugins-good/commit/?id=e2518fedbe8f6eb9cf1cf456381a5e350e2c4001
Comment 4 Michael Smith 2009-12-20 22:39:56 UTC
I don't have a windows system on which I can test this - however, I rewrote the error reporting recently so that on windows, it should give you the correct error in the debug output - instead of just "No error".

If you can re-test with that, maybe it'll provide enough hints for us to figure out the correct _fix_ for this.
Comment 5 Andoni Morales 2009-12-21 01:17:26 UTC
(In reply to comment #4)
> I don't have a windows system on which I can test this - however, I rewrote the
> error reporting recently so that on windows, it should give you the correct
> error in the debug output - instead of just "No error".
I saw your commits, but there is another bug there:
https://bugzilla.gnome.org/show_bug.cgi?id=604872
Can you review it, please?
I was getting only an error code and the message was: "(null)" (maybe because I wasn't setting the len parameter in the right way.
I haven't my windows machine right now either, so I can't test it untill tomorrow.
Comment 6 Michael Smith 2009-12-21 01:27:28 UTC
Thanks for pointing out that bug - pushed a fix.

Just telling me what the error code is might be enough to be helpful, even if the message still isn't reported properly.
Comment 7 Andoni Morales 2009-12-23 21:44:55 UTC
Using your fix for g_convert() setting lenght=-1 I get:
Could not set TTL socket option (0): S

While setting lenght=sizeof(buf) I get:
Could not set TTL socket option (1113): (null)

Should I reopen #604872?
Comment 8 Sjoerd Op 't Land 2010-03-06 13:11:24 UTC
To whom it may concern: the same error occurs on Mac OS 10.5.8, gst-plugins-good 0.10.18:

gst-launch audiotestsrc ! udpsink

Gives:

gstmultiudpsink.c(846): gst_multiudpsink_init_send (): /GstPipeline:pipeline0/GstUDPSink:udpsink0:
Could not set TTL socket option (22): Invalid argument
Comment 9 Sjoerd Op 't Land 2010-03-06 17:22:29 UTC
Tried to localise where this error is thrown in my case: from gstudpnetutils.c in the last if branch of gst_udp_set_ttl (addr.ss_family = AF_INET6, is_multicast = false). Apparently setting IPV6_UNICAST_HOPS goes alright, but trying to set IP_TTL to the same value (ttl = 64) gives this error (22).
Comment 10 Richard Spiers 2010-03-09 13:46:08 UTC
Hi all

I tried using the latest release of the winbuilds (after getting the above ttl error). The pipeline seemed to run (whereas before it stopped), but no traffic appears on in my network dump.

I then downloaded the latest svn, built the gstudp project, and tried with those plugins - i get the same thing, no network traffic appears.

I tried with several different pipelines. The below log is generated by:

videotestsrc ! videoscale ! theoraenc ! queue ! udpsink  host=10.10.10.1 port=12343

I used wireshark to look for any traffic heading to 10.10.10.1, and nothing appeared.

Does the UDP sink currently work in any version on windows ? Is this something wrong with my setup?

0:00:00.079005000  4320   004F8CB0 DEBUG           multiudpsink gstmultiudpsink.c:767:gst_multiudpsink_add_internal:<GstUDPSink@01D23138> adding client on host localhost, port 4951
0:00:00.086005000  4320   004F8CB0 DEBUG           multiudpsink gstmultiudpsink.c:801:gst_multiudpsink_add_internal:<GstUDPSink@01D23138> added client on host localhost, port 4951
0:00:00.086005000  4320   004F8CB0 DEBUG           multiudpsink gstmultiudpsink.c:855:gst_multiudpsink_remove:<udpsink0> remove client with host localhost, port 4951
0:00:00.086005000  4320   004F8CB0 DEBUG           multiudpsink gstmultiudpsink.c:767:gst_multiudpsink_add_internal:<udpsink0> adding client on host 10.10.10.1, port 4951
0:00:00.086005000  4320   004F8CB0 DEBUG           multiudpsink gstmultiudpsink.c:801:gst_multiudpsink_add_internal:<udpsink0> added client on host 10.10.10.1, port 4951
0:00:00.086005000  4320   004F8CB0 DEBUG           multiudpsink gstmultiudpsink.c:855:gst_multiudpsink_remove:<udpsink0> remove client with host 10.10.10.1, port 4951
0:00:00.086005000  4320   004F8CB0 DEBUG           multiudpsink gstmultiudpsink.c:767:gst_multiudpsink_add_internal:<udpsink0> adding client on host 10.10.10.1, port 12343
0:00:00.086005000  4320   004F8CB0 DEBUG           multiudpsink gstmultiudpsink.c:801:gst_multiudpsink_add_internal:<udpsink0> added client on host 10.10.10.1, port 12343
Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...
Pipeline is PREROLLED ...
Setting pipeline to PLAYING ...
0:00:00.126008000  4320   01CEDE20 LOG             multiudpsink gstmultiudpsink.c:392:gst_multiudpsink_render:<udpsink0> about to send 42 bytes
New clock: GstSystemClock
0:00:00.126008000  4320   01CEDE20 LOG             multiudpsink gstmultiudpsink.c:399:gst_multiudpsink_render:<udpsink0> sending 42 bytes to client 01D0D2E0
0:00:00.126008000  4320   01CEDE20 WARN            multiudpsink gstmultiudpsink.c:417:gst_multiudpsink_render:<udpsink0> client 01D0D2E0 gave error 0 (No error)
0:00:00.126008000  4320   01CEDE20 LOG             multiudpsink gstmultiudpsink.c:432:gst_multiudpsink_render:<udpsink0> sent 42 bytes to 0 (of 1) clients
0:00:00.126008000  4320   01CEDE20 LOG             multiudpsink gstmultiudpsink.c:392:gst_multiudpsink_render:<udpsink0> about to send 58 bytes
0:00:00.126008000  4320   01CEDE20 LOG             multiudpsink gstmultiudpsink.c:399:gst_multiudpsink_render:<udpsink0> sending 58 bytes to client 01D0D2E0
0:00:00.127008000  4320   01CEDE20 WARN            multiudpsink gstmultiudpsink.c:417:gst_multiudpsink_render:<udpsink0> client 01D0D2E0 gave error 0 (No error)
Comment 11 Andoni Morales 2010-03-09 14:09:18 UTC
The Gstreamer WinBuilds release works b/c I reverted the sources to the parent of the commits introducing the regression.
As you see in the log it works (sending 42 bytes to
client 01D0D2E0
). You can also try with:
server -> videotestsrc ! udpsink host=locahost port=1234 clients=locahost:3000
client -> udpsrc uri=udp://locahost:1234 port=3000 ! fakesink dump=true
Comment 12 Richard Spiers 2010-03-09 16:18:27 UTC
I am a bit confused as why I see 

"sent 42 bytes to 0 (of 1) clients"

etc in the logs then. Shouldn't that be "sent x bytes to 1 (of 1) clients" if it was working?  I must be doing something stupid, but cannot get a local server / client going, as well as never seeing anything on the wire between two different machines when testing remotely.

Any suggestions ?
Comment 13 Andoni Morales 2010-03-09 21:20:28 UTC
I didn't realized that it was using multiudpsink, which doesn't work (#602312)
Comment 14 Richard Spiers 2010-03-09 21:38:03 UTC
I didn't know about the other bug - will take this discussion there instead.

Thanks
Comment 15 Andoni Morales 2010-03-10 01:53:58 UTC
On Windows the error is thrown in getsockname() (gstudpnetutils.c:168), with errorcode=10022.
Apparently this method can't be called on unbound sockets. See also http://bugs.python.org/issue1049.
Comment 16 Andoni Morales 2010-03-10 19:26:46 UTC
Created attachment 155777 [details] [review]
0001-multiudpsink-swallow-errors-trying-to-call-getsockna.patch

There is a better way to do it but this patch fixes partially the bug.
Comment 17 Michael Smith 2010-03-10 19:34:30 UTC
Comment on attachment 155777 [details] [review]
0001-multiudpsink-swallow-errors-trying-to-call-getsockna.patch

This is a pretty nasty hack.

We only use the result of getsockname() to figure out the type of socket - better patch would be to pass that (or pass the whole struct sockaddr *) to this function, and adjust all the callers appropriately.
Comment 18 Andoni Morales 2010-03-10 20:05:19 UTC
Pretty ugly hack indeed :)
Maybe something like:
gst_udp_set_ttl (int sockfd, int ttl, gboolean is_multicast, gboolen is_ipv6)
Comment 19 Michael Smith 2010-03-10 20:17:56 UTC
I wouldn't use a boolean - either pass the ss_family member, or the struct sockaddr *. Probably the ss_family is a good choice.
Comment 20 Andoni Morales 2010-03-10 21:31:42 UTC
Created attachment 155786 [details] [review]
0001-multiudpsink-avoid-getting-the-socket-family-using-g.patch

The ss_family is get when the socket is created and then passed to set_ttl() and set_loop() instead of retrieving it from socketgetname()
Comment 21 Michael Smith 2010-03-10 21:34:11 UTC
Comment on attachment 155786 [details] [review]
0001-multiudpsink-avoid-getting-the-socket-family-using-g.patch

This one looks fine to me. Do you have commit access?
Comment 22 Andoni Morales 2010-03-11 08:39:04 UTC
I don't, can do you it for me?
And thanks for helping me with the patch :)
Comment 23 Richard Spiers 2010-03-12 00:52:07 UTC
Created attachment 155909 [details] [review]
Fixes for udp on windows vista / 7

Hi all

I have attached a patch that applies to current git from the patch above and from https://bugzilla.gnome.org/show_bug.cgi?id=534243

I now have working udp traffic on my windows 7 machine.

It needs to be tested on linux and windows XP to make sure I didn't break anything when re-arranging / merging patches based off old code.

I would appreciate it if someone could review how the ss_family is assigned to the sink in the gst_multiudpsink_init_send function, to make sure i didn't miss a case / how it should be handled. The rest of the code is pretty much as is from the other patches.
Comment 24 Andoni Morales 2010-04-07 23:40:37 UTC
The patch has already been commited:

http://cgit.freedesktop.org/gstreamer/gst-plugins-good/commit/?id=7f980d28aa23c64dce423c0c0f994b2d136fc7fe
Comment 25 Levente Farkas 2010-04-09 13:01:05 UTC
we still got this error:
0:00:00.890625000   128   00382978 INFO     GST_ELEMENT_FACTORY
gstelementfactory.c:403:gst_element_factory_create: creating element
"udpsink"
0:00:00.890625000   128   00382978 INFO        GST_ELEMENT_PADS
gstelement.c:727:gst_element_add_pad:<GstBaseSink@00BA3A18> adding pad
'sink'
0:00:00.890625000   128   00382978 INFO              GST_STATES
gstelement.c:2211:gst_element_continue_state:<udpsink1> committing
state from NULL to READY, pending PLAYING, next PAUSED
0:00:00.890625000   128   00382978 INFO              GST_STATES
gstelement.c:2220:gst_element_continue_state:<udpsink1> continue state
change READY to PAUSED, final PLAYING
Sockfd is 1792, ss_family is 23, ttl is 64, is_multicast is 0
0:00:00.890625000   128   00382978 WARN            multiudpsink
gstmultiudpsink.c:906:gst_multiudpsink_configure_client:<udpsink1>
error: Could not set TTL socket option (10022): A
0:00:00.890625000   128   00382978 INFO        GST_ERROR_SYSTEM
gstelement.c:1763:gst_element_message_full:<udpsink1> posting message:
Could
not get/set settings from/on resource.
0:00:00.890625000   128   00382978 INFO        GST_ERROR_SYSTEM
gstelement.c:1786:gst_element_message_full:<udpsink1> posted error
message: Could not get/set settings from/on resource.
0:00:00.890625000   128   00382978 INFO              GST_STATES
gstelement.c:2555:gst_element_change_state:<udpsink1> have FAILURE
change_state return
0:00:00.890625000   128   00382978 INFO              GST_STATES
gstelement.c:2132:gst_element_abort_state:<udpsink1> aborting state
from READY to PLAYING
Comment 26 Andoni Morales 2010-04-09 14:09:41 UTC
Works for me on XP and Vista and for other users too #534243
You should test with this installer: http://ossbuild.googlecode.com/files/GStreamer-WinBuilds-GPL-x86-RC01.msi
Comment 27 Levente Farkas 2010-04-09 14:56:07 UTC
we already test that installer:-(
but may be that installer do not contains that fix...
but the same gst-lunch working on linux:-(
Comment 28 stephane.raux 2012-07-31 17:41:15 UTC
The issue still exists on Windows. The following pipeline fails because the TTL option could not be set (Windows error code 10022 WSAEINVAL, i.e. "An invalid argument was supplied"):
gst-launch-0.10 --gst-debug=*udp*:5 filesrc location=<some_small_file> ! udpsink port=5000

Output is:
******************
0:00:00.385077000  4984   08C4F500 DEBUG           multiudpsink gstmultiudpsink.c:1061:gst_multiudpsink_add_internal:<GstUDPSink@029109E8> adding client on host localhost, port 4951
0:00:00.389078000  4984   08C4F500 DEBUG           multiudpsink gstmultiudpsink.c:1089:gst_multiudpsink_add_internal:<GstUDPSink@029109E8> add client with host localhost, port 4951
0:00:00.389078000  4984   08C4F500 DEBUG           multiudpsink gstmultiudpsink.c:1099:gst_multiudpsink_add_internal:<GstUDPSink@029109E8> added client on host localhost, port 4951
0:00:00.389078000  4984   08C4F500 DEBUG           multiudpsink gstmultiudpsink.c:1141:gst_multiudpsink_remove:<udpsink0> found 1 clients with host localhost, port 4951
0:00:00.389578000  4984   08C4F500 DEBUG           multiudpsink gstmultiudpsink.c:1145:gst_multiudpsink_remove:<udpsink0> remove client with host localhost, port 4951
0:00:00.389578000  4984   08C4F500 DEBUG           multiudpsink gstmultiudpsink.c:1061:gst_multiudpsink_add_internal:<udpsink0> adding client on host localhost, port 5000
0:00:00.389578000  4984   08C4F500 DEBUG           multiudpsink gstmultiudpsink.c:1089:gst_multiudpsink_add_internal:<udpsink0> add client with host localhost, port 5000
0:00:00.390078000  4984   08C4F500 DEBUG           multiudpsink gstmultiudpsink.c:1099:gst_multiudpsink_add_internal:<udpsink0> added client on host localhost, port 5000
Setting pipeline to PAUSED ...
0:00:00.390078000  4984   08C4F500 DEBUG           multiudpsink gstmultiudpsink.c:936:gst_multiudpsink_init_send:<udpsink0> creating sockets
0:00:00.390078000  4984   08C4F500 DEBUG           multiudpsink gstmultiudpsink.c:945:gst_multiudpsink_init_send:<udpsink0> have socket
0:00:00.390078000  4984   08C4F500 DEBUG           multiudpsink gstmultiudpsink.c:988:gst_multiudpsink_init_send:<udpsink0> could not get udp buffer size
0:00:00.390578000  4984   08C4F500 DEBUG           multiudpsink gstmultiudpsink.c:868:gst_multiudpsink_configure_client:<udpsink0> configuring client 08E3C0B0
0:00:00.390578000  4984   08C4F500 DEBUG           multiudpsink gstmultiudpsink.c:885:gst_multiudpsink_configure_client:<udpsink0> setting unicast ttl to 64
0:00:00.390578000  4984   08C4F500 WARN            multiudpsink gstmultiudpsink.c:908:gst_multiudpsink_configure_client:<udpsink0> error: Could not set TTL socket option (10022): A
ERROR: Pipeline doesn't want to pause.
ERROR: from element /GstPipeline:pipeline0/GstUDPSink:udpsink0: Could not get/set settings from/on resource.
Additional debug info:
gstmultiudpsink.c(908): gst_multiudpsink_configure_client (): /GstPipeline:pipeline0/GstUDPSink:udpsink0:
Could not set TTL socket option (10022): A
Setting pipeline to NULL ...
Freeing pipeline ...
******************

gstreamer version is 0.10.36, issue reproduced on Win Vista and Win 7.

In gstmultiudpsink.c at line 886, failure to set the TTL seems to be considered as fatal, but it shouldn't on Windows. From the MSDN documentation, IP_TTL support is not required and may not be supported.
Comment 29 stephane.raux 2012-07-31 18:04:39 UTC
In addition to the fact that a failure to set the TTL on Windows should not be considered fatal, the WSAEINVAL error code may indicate another bug as setsockopt is supposed to return WSAEINVAL only when "The level parameter is not valid, or the information in the buffer pointed to by the optval parameter is not valid". The level is IPPROTO_IP which seems correct and IP_TTL expects a pointer to DWORD which should be ok as the code passes an int*.
Comment 30 Andoni Morales 2012-10-11 16:11:28 UTC
Created attachment 226274 [details] [review]
0001-udpsink-errors-setting-the-ttl-option-on-windows-are

Treat errors setting TTL as non fatals on windows