UDP multicast on iOS with WWAN turned on
Dries Langsweirdt
dries.langsweirdt at flowpilots.com
Thu Dec 8 11:54:43 UTC 2016
Hello,
I got this problem solved. I'm leaving this here for future visitors.
Socket code that is working correctly (receiving multicast UDP when
mobile data is turned on) is as follows:
----------
fd = socket(AF_INET, SOCK_DGRAM, 0);
memset(&addr, 0, sizeof(addr));
addr.sin_len = sizeof(addr);
addr.sin_family = AF_INET;
addr.sin_addr.s_addr = INADDR_ANY;
addr.sin_port = ntohs(5004);
bind(fd, (const struct sockaddr *) &addr, sizeof(addr)) == 0;
mreq.gr_interface = if_nametoindex(@"en0");
memset(&mreq.gr_group, 0, sizeof(mreq.gr_group));
a = (struct sockaddr_in *) &mreq.gr_group;
a->sin_len = sizeof(addr);
a->sin_family = AF_INET;
a->sin_addr.s_addr = inet_addr("224.1.1.1");
a->sin_port = 0;
setsockopt(fd, IPPROTO_IP, MCAST_JOIN_GROUP, &mreq, sizeof(mreq)) == 0;
----------
When I compare this with the socket creation code in Glib, I see a few
differences:
- https://github.com/GNOME/glib/blob/master/gio/gsocket.c#L2280 => GlIb
is using the group join operation IP_ADD_SOURCE_MEMBERSHIP, while the
above code uses MCAST_JOIN_GROUP.
- https://github.com/GNOME/glib/blob/master/gio/gsocket.c#L2236 => GLib
is only setting if_nametoindex (iface), but not
mc_req.imr_interface.s_addr = g_htonl (INADDR_ANY), while in the above
code: addr.sin_addr.s_addr = INADDR_ANY; and mreq.gr_interface =
if_nametoindex (iface);
The way I have solved this is by constructing the socket myself, similar
to the example code provided, and to set the socket manually on the
udpsrc element(s):
----------
gsocket_video = g_socket_new_from_fd(fd, &error);
...
pipeline = gst_parse_launch(pipeline_desc, &error);
...
GstElement* srcvideo = gst_bin_get_by_name((GstBin*)pipeline, "srcvideo");
g_object_set (srcvideo, "socket", gsocket_video, NULL);
----------
To answer this question: "Also is switching WWAN on causing a new
interface to appear, or what effects does it have?"
=> There are no new interfaces, the list of real and virtual interfaces
on iOS seem fixed. However, in my situation the WIFI is a LAN (so there
is no internet access). I assume that when mobile data is turned on the
default gateway of the system is changed in order to prefer traffic over
WWAN.
On 07/12/16 11:25, Sebastian Dröge wrote:
> On Wed, 2016-12-07 at 01:17 +0100, Dries Langsweirdt wrote:
>> I would like to know if I'm looking at an application specific problem
>> or a general gstreamer problem, so if someone could confirm or
>> de-confirm this behavior that would be great. Any suggestions as to how
>> to proceed are greatly appreciated.
> This would seem like a GStreamer or GLib problem. Can you compare what
> that other application does with the socket, and what udpsrc does
> different?
>
> Also is switching WWAN on causing a new interface to appear, or what
> effects does it have?
>
>
>
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
--
Met vriendelijke groeten,
Dries Langsweirdt
Partner
Flow Pilots
M +32497729982
E dries.langsweirdt at flowpilots.com
W www.flowpilots.com
/Please be informed that the Flow Pilots offices will be closed from Dec
26th 2016 until Jan 1st. 2017./
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/gstreamer-devel/attachments/20161208/7c32cb93/attachment.html>
More information about the gstreamer-devel
mailing list