Setting Source port of udp sink

Sunil sunil.p at
Fri Nov 25 04:09:25 PST 2011

Hi All,

     I am trying to set the source port of udpsink using external socked 
fd.But i am getting error  as "Could not get/set settings from/on resource".
Please find the code for the same below.Request you all to help me fix 
the issue.

      /* create and bind a socket for RTP and RTCP */
         memset(&rtp_addr, 0, sizeof(struct sockaddr_in));
         rtp_sockfd = socket (AF_INET, SOCK_DGRAM, 0);
         if (rtp_sockfd > 0 ) {
                 int res;
                 rtp_addr.sin_family = AF_INET;
                 rtp_addr.sin_port = htons (rtp_port);
                 rtp_addr.sin_addr.s_addr = INADDR_ANY;

                 res = bind(rtp_sockfd, (struct sockaddr*)&rtp_addr, 
                 if (res == 0) {
                         printf("Succesfully bound to local RTP port 
%d.\n", rtp_port);
                 } else {
                         printf("Unable to bind to local RTP port 
%d.\n", rtp_port);
                         rtp_sockfd = -1;

          /* Creating an UDP sink for RTP */
         udp_rtp_sink = gst_element_factory_make("udpsink", "udpsink0");
         if (!udp_rtp_sink) {
                 g_printerr ("udp_rtp_sink element could not be created."
                             " Exiting.\n");
                 return NULL;

        if (rtp_sockfd != -1)
                 g_object_set(G_OBJECT(udp_rtp_sink), "sockfd", 
rtp_sockfd, "port",
                                                 remote_rtp_port,  NULL);

Could not get/set settings from/on resource

Thanks and Regards,

More information about the gstreamer-devel mailing list