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 743008 - udpsink: Can't set manually created GSocket: Invalid address family (got 10)
udpsink: Can't set manually created GSocket: Invalid address family (got 10)
Status: RESOLVED NOTABUG
Product: GStreamer
Classification: Platform
Component: gst-plugins-good
1.4.4
Other Mac OS
: Normal normal
: git master
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2015-01-16 07:05 UTC by Antonis
Modified: 2015-10-14 12:38 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
GStreamer Tutorials, with some changes in Tutorial 2 so that issue is reptroducible (1.22 MB, application/zip)
2015-01-30 18:25 UTC, Antonis
Details
app.c (2.92 KB, text/plain)
2015-10-14 12:29 UTC, Sebastian Dröge (slomo)
Details

Description Antonis 2015-01-16 07:05:41 UTC
When I setup and start the pipeline I get:

'Could not get/set settings from/on resource' from the bus

Code:

----------------
...
// create UDP sink
udpsink = gst_element_factory_make ("udpsink", "sink");
assert (udpsink != NULL);
g_object_set (G_OBJECT (udpsink), "socket", gsocket, NULL);

// add and link gstreamer elements and then start the pipeline
...
----------------

Notice that once I remove the g_object_set() or I use it to set another property (like 'async' for instance) everything works fine. Could it be that 'socket' property has any issues specifically in iOS? Keep in mind that the exact same code works fine in Linux.

Moreover, I tried setting the sockfd property but it doesn't seem to exist anymore.

Any ideas what might be wrong?

Thanks

P.S. Notice that I'm using the official iOS bundle of GStreamer (i.e. GStreamer.framework) downloaded from http://gstreamer.freedesktop.org/data/pkg/ios/1.4.4/ and have tried to follow the conventions of the sample code at http://cgit.freedesktop.org/~slomo/gst-sdk-tutorials/tree/gst-sdk/tutorials/xcode%20iOS
Comment 1 Sebastian Dröge (slomo) 2015-01-16 10:15:37 UTC
How do you create the socket? You can find some code that does this here: http://cgit.freedesktop.org/gstreamer/gst-rtsp-server/tree/gst/rtsp-server/rtsp-stream.c#n1009
Comment 2 Antonis 2015-01-16 10:32:11 UTC
The socket is already created + bound at an earlier point in code using standard socket(2) and bind(2) calls, so in order to convert it to a gsocket I use the following before setting it in the udpsink property:

GSocket * gsocket = g_socket_new_from_fd(self->sm_rtp_sockfd, &err);
assert (gsocket != NULL);


Which works fine in Linux
Comment 3 Sebastian Dröge (slomo) 2015-01-16 10:33:49 UTC
Are you binding the socket before you set it on udpsink?
Comment 4 Sebastian Dröge (slomo) 2015-01-16 10:35:19 UTC
Ah you said that you bind it, sorry.

Can you get a debug log with gst_debug_set_threshold_from_string("2,*udp*:6", TRUE)? Call that before you start your pipeline.
Comment 5 Antonis 2015-01-18 10:06:08 UTC
Debug log says 'Invalid address family (got 30)':

0:00:05.845535000 [335m  196[00m 0x183dfaa0 [37mDEBUG  [00m [00m        multiudpsink gstmultiudpsink.c:758:gst_multiudpsink_set_property:<sink>[00m setting socket to 0x183f4148
0:00:05.846648000 [335m  196[00m 0x183dfaa0 [37mDEBUG  [00m [00m        multiudpsink gstmultiudpsink.c:975:gst_multiudpsink_start:<sink>[00m using configured socket
0:00:05.846699000 [335m  196[00m 0x183dfaa0 [37mDEBUG  [00m [00m        multiudpsink gstmultiudpsink.c:1115:gst_multiudpsink_start:<sink>[00m have UDP buffer of 9216 bytes
0:00:05.846792000 [335m  196[00m 0x183dfaa0 [37mDEBUG  [00m [00m        multiudpsink gstmultiudpsink.c:913:gst_multiudpsink_configure_client:<sink>[00m configuring client 0x17b445c0
0:00:05.846921000 [335m  196[00m 0x183dfaa0 [33;01mWARN   [00m [00m        multiudpsink gstmultiudpsink.c:956:gst_multiudpsink_configure_client:<sink>[00m error: Invalid address family (got 30)

For some reason udpsink seems to not like the address family, which is AF_INET in my case. And to be more exact the socket call I use (before creating a gsocket from my socket), is:

    sockfd = socket (AF_INET, SOCK_DGRAM, 0);

Any idea why that might cause issues?

Best regards,
Antonis
Comment 6 Sebastian Dröge (slomo) 2015-01-19 14:47:44 UTC
30 should be AF_INET6, 2 would be AF_INET. That's quite interesting.

If you run

> struct sockaddr_storage address;
> guint addrlen = sizeof address;
> getsockname(fd, (struct sockaddr *) &address, &addrlen);

what is the value of address.ss_family? AF_INET or AF_INET6?

Also if you want to use IPv6 sockets, check if setting it as the socket-v6 property makes any difference.
Comment 7 Antonis 2015-01-19 19:53:13 UTC
I tried that piece of code and I get 2, which is AF_INET as expected. 

And if I use socket-v6 the error message changes to:

(<unknown>:579): GLib-GIO-CRITICAL **: g_socket_get_family: assertion 'G_IS_SOCKET (socket)' failed

Any ideas?

Also, by the looks of the original message:

'Invalid address family (got 30)'

it seems as if gstreamer 'thinks' that I used 20 instead of 2, right?
Comment 8 Sebastian Dröge (slomo) 2015-01-19 20:10:17 UTC
What does g_socket_get_family() return on your newly created GSocket? AF_INET or AF_INET6 (aka G_SOCKET_FAMILY_IPV4 and G_SOCKET_FAMILY_IPV6)? Also are G_SOCKET_FAMILY_IPV4 and AF_INET the same value for you?

The problem here seems to be that GIO does something wrong when you create the GSocket from the fd.
Comment 9 Antonis 2015-01-19 22:08:04 UTC
Thanks a lot for the prompt reply. Here you go:

- g_socket_get_family returns G_SOCKET_FAMILY_IPV4 = 2.
- Yes both G_SOCKET_FAMILY_IPV4 and AF_INET are 2.

Any other hints?

Best regards
Comment 10 Sebastian Dröge (slomo) 2015-01-20 08:17:26 UTC
Weird, because inside multisocketsink g_socket_get_family() will have to return 30 to end up in that error path.

The next step would be to check what changes with the socket until the error, by calling g_socket_get_family() on it after the error too, and also checking with a debugger inside multisocketsink if it maybe has a different socket at that point (and where it comes from).
Comment 11 Antonis 2015-01-28 22:51:23 UTC
Did some more troubleshooting. Here are some interesting notes:

>> Note #1: Tried to simplify the scenario and removed the conversion from fd -> gsocket (i.e. avoid g_socket_new_from_fd). Instead, I use gsockets all the way:

----
GSocket *gsocket = NULL;
GSocketAddress *rtp_sockaddr = NULL;
GInetAddress *inetaddr = NULL;

gsocket = g_socket_new (G_SOCKET_FAMILY_IPV4, G_SOCKET_TYPE_DATAGRAM, G_SOCKET_PROTOCOL_UDP, NULL);
inetaddr = g_inet_address_new_any (G_SOCKET_FAMILY_IPV4);
rtp_sockaddr = g_inet_socket_address_new (inetaddr, 16384);
g_socket_bind (gsocket, rtp_sockaddr, FALSE, NULL);

g_object_set (G_OBJECT (self->sm_udpsink), "socket", gsocket, NULL);
----

Again, I get the exact same problem; this means that the problem is not with the conversion. 

>> Note #2: Instead of setting the socket property of the udpsink of my pipeline, I did that for the udpsrc (the rest of the code remains the same):

----
...
g_object_set (G_OBJECT (self->sm_udpsrc), "socket", gsocket, NULL);
----

In this scenario, I got no issues! Which is pretty strange. I mean this means that the address family issue occurs for the udpsink but not for the udpsrc.

>> Note #3: I even tried using specifically the IP the iPhone gets from my router using rtp_sockaddr = g_inet_socket_address_new_from_string("10.0.0.10", 16384), but again the same problems.

Any ideas are most welcome

Thanks a lot in advance,
Antonis

P.S. Here's my pipeline in case you are interested:

autoaudiosrc ! capsfilter caps=audio/x-raw,rate=44100 ! audioconvert ! audioresample ! queue ! mulawenc ! rtppcmupay ! udpsink name=udp-sink udpsrc name=udp-src caps=\"application/x-rtp,media=audio,clock-rate=8000,encoding-name=PCMU\" ! rtppcmudepay ! mulawdec ! audioconvert ! audioresample ! autoaudiosink
Comment 12 Sebastian Dröge (slomo) 2015-01-30 09:31:18 UTC
Thanks for debugging all this, I'll try to find some time to look further into this soon.

If you can, could you also provide a sample application here that reproduces the bug?

From your description this sounds like the socket somehow gets broken, maybe by the sink.
Comment 13 Antonis 2015-01-30 18:25:26 UTC
Created attachment 295817 [details]
GStreamer Tutorials, with some changes in Tutorial 2 so that issue is reptroducible

I managed to tweak 'Tutorial 2' from your GStreamer tutorials and now it is reproducible. I replaced the tutorial's pipeline with mine and little after gst_parse_launch() I try to set the udpsink 'socket' property to a gsocket I had previously initialized + bounded.

Just run it and hit play.

I'm attaching the whole project as a zip.

Thanks,
Antonis
Comment 14 Antonis 2015-05-13 12:56:32 UTC
Hello again, 

Did you by any chance had a look at that?

Thanks
Comment 15 Sebastian Dröge (slomo) 2015-05-13 13:09:56 UTC
No, I didn't have any time to look at this yet, sorry
Comment 16 Sebastian Dröge (slomo) 2015-10-14 12:29:11 UTC
Created attachment 313258 [details]
app.c

Can be reproduced with the attached on Linux too
Comment 17 Sebastian Dröge (slomo) 2015-10-14 12:38:32 UTC
The problem here is that localhost is used, which then resolves to an IPv6 address. But your socket is for IPv4.

Setting the host property on udpsink to 127.0.0.1 makes it work here. Or just using an IPv6 socket should also work.