How to connect to UDP broadcast using GStreamer in C

I have a small program that uses the GStreamer library to play videos from local files and videos on web servers using HTTP. How can I connect to UDP broadcast in C using GStreamer ?

For example, what is required to play streaming video in this hypothetical URI? 10.0.11.255:9001

I tried:

 // using playbin2 connect to UDP broadcast g_object_set (data.playbin2, "uri", "udp://10.0.11.255:9001", NULL); 

Then I try to start the stream with the following:

 /* Start playing */ if( gst_element_set_state (data.playbin2, GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE ) { g_printerr ("Unable to set the pipeline to the playing state.\n"); gst_object_unref (data.playbin2); return( -1 ); } 

and I get a message about the status change of the message.

I did a google search and did not find anything useful.

EDIT: after a few more searches, I found out about udpsrc . However, I cannot figure out how to use it in C code.

+4
source share
2 answers

The problem is that the UDP broadcast stream is not forwarded to the virtual machine I am developing on.

Using playbin2 and setting its uri property to udp://0.0.0.0:9001 is all that is required to get playbin2 correctly create the necessary source element.

+1
source

udpsrc is a network source that reads UDP packets from the network. You cannot use it to connect to a remote host, you can only read data from the port.

However, if you have a multicast group installed, you can read from multicast groups by setting the "multicast-group" property to the IP address of the multicast group.

If you use:

 g_object_set (data.udpsrc, "uri", "udp://10.0.11.255:9001", NULL); 

Then this means that you are reading data from the mulitcast group, whose IP address is 10.0.11.255, and not to connect to the host.

0
source

Source: https://habr.com/ru/post/1479439/


All Articles