UDP and custom GSockets

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

UDP and custom GSockets

debruyn
Good day,

So I have been sitting with an issue for a while. The system I am developing uses UDP elements (UDPSink and UDPSrc) to send an rtsp stream over a network. Now the issue is I only have ONE port that I can use on the UDPSrc side(Client side). I have multiple UDPSinks, from differant hosts. I need to differentiate between the incoming pipes that are set up by the hosts. Multicasting the addreses does work but it is not a valid solution as the client will be on a webserver somewhere in the world. As multicast address will most likely then be dropped on route to the client web server.

So I want to implement my own sockets on the UDP elements, as i think this is the only solution. on the hosts I have set up my UDPSinks as follows (Using C++ 11):
 
       GSocket * socketUDP = g_socket_new(G_SOCKET_FAMILY_IPV4, G_SOCKET_TYPE_DATAGRAM, G_SOCKET_PROTOCOL_UDP, NULL);

        g_object_set (G_OBJECT (gstSink), "socket", socketUDP, NULL);

/*Set the sink elements' properties*/   g_object_set(gstSink,"host",moProfileInstance->getMediaLocation(),"port",moProfileInstance->getHostPort(miCamNumber),
                        "bind-address",moProfileInstance->getSrcIP(miCamNumber),"bind-port",moProfileInstance->getSrcPort(miCamNumber), NULL);

Now how can I access that same socket on the client side with UDPSrc, The idea is that i want to use the Source IP and Source Port addresses of the incoming connection. Please any help would be much appreciated

regards,
debruyn
Reply | Threaded
Open this post in threaded view
|

Re: UDP and custom GSockets

Sebastian Dröge-3
On Di, 2016-04-19 at 23:09 -0700, debruyn wrote:


> Now how can I access that same socket on the client side with UDPSrc, The
> idea is that i want to use the Source IP and Source Port addresses of the
> incoming connection. Please any help would be much appreciated

UDP is not connection based. However you will get the source IP and
port for every buffer coming out of udpsrc in the GstNetAddressMeta.

--
Sebastian Dröge, Centricular Ltd · http://www.centricular.com

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

signature.asc (968 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: UDP and custom GSockets

debruyn
Hi Sebastian,

Thanks for helping, So i can get n source address from creating like a buffer probe on the udpsrc? Do you know where i can find an example of buffer probes? Was only successfull yesterday to create event probes.

Also I am trying to create my own socket to give to UDPSrc. Will this work if i link the source IP address and port, that i set on the UDPSink? This is my code snippet to link the address (Note the pipeline has been linked and created before this):

GSocketAddress *bind_addr;
        GInetAddress *bind_iaddr;
        GSocketFamily family;
        guint16 port = 50001;
        GError *err = NULL;

        bind_iaddr = g_inet_address_new_from_string ("10.15.1.140");
        bind_addr = g_inet_socket_address_new (bind_iaddr, port);

        g_object_unref (bind_iaddr);

        family = g_socket_address_get_family (G_SOCKET_ADDRESS (bind_addr));

        GSocket * socketUDP = g_socket_new(family, G_SOCKET_TYPE_DATAGRAM, G_SOCKET_PROTOCOL_UDP, &err);
        if(socketUDP == NULL)
        {
                debug("Could not create socket: %s", err->message);
                g_object_unref (bind_addr);
        }
        else
        {
                g_socket_bind (socketUDP, bind_addr, TRUE, &err);
                if(err != NULL)
                {
                        debug("Failed to bind socket: %s", err->message);
                        g_object_unref (bind_addr);
                }
                else
                {
                        g_object_set (G_OBJECT (gstSource), "socket", socketUDP, NULL);
                }
        }

        g_object_set(gstSource,"port",moProfileInstance->getHostPort(),"caps",gst_caps_new_simple ("application/x-rtp",NULL),NULL);

The Error I am getting says the following => Failed to bind socket: Error binding to address: Cannot assign requested address.
What worries me is that i get the same error when trying to set the address property of udpsrc ,in  the commandline (using gst-launch-1.0) using any other address other than multicast addresses.

Thanks for the help I really appreciate it.
Reply | Threaded
Open this post in threaded view
|

Re: UDP and custom GSockets

Sebastian Dröge-3
On Mi, 2016-04-20 at 02:02 -0700, debruyn wrote:
> update: It defnintly can only bind multicast addresses, is there no
> way to bind normal address to UDP Src?

You can bind your own socket to a non-multicast address and pass it to
udpsrc, or you can set the address property (which is the same as the
misnamed multicast-group property) to the address you want it to bind
to.

--
Sebastian Dröge, Centricular Ltd · http://www.centricular.com


_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

signature.asc (968 bytes) Download Attachment