Error on changing pipeline state if UDPSINK source port is set

Sunil sunil.p at globaledgesoft.com
Mon Nov 28 04:23:46 PST 2011


Hi All,

          I am setting the source port of UDPSINK by creating socket and 
binding  port.But while trying to change the state of
pipeline to playing i am getting the following error.But rtp packets are 
flowing in both directions using the port binded to socket.

---------------------------------------------------------------------------------
gst_element_set_state(gst_handle.play_pipeline,
                                       GST_STATE_PLAYING);

Error:Could not get/set settings from/on resource
---------------------------------------------------------------------------------

if i don't set the socket fd the code is working fine but uses a random 
port for sending the rtp packets.

Is there any thing extra i need to do to set the UDPSINK port apart from 
the below code.
----------------------------------------------------------------------------------------------------------------
     /* 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;
         }


      /* create and bind a socket for RTP*/
         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 
(video_caps->remote_addr.rtp_port);
                 rtp_addr.sin_addr.s_addr = INADDR_ANY;

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

         g_object_set(G_OBJECT(udp_rtp_sink),"sockfd",
                                         rtp_sockfd, NULL);

       /* Setting the RTP address for the session */
         g_object_set(G_OBJECT(udp_rtp_sink), "host",
                      video_caps->remote_addr.ip.ipv4, NULL);

         /* Setting the RTP port for the session */
         g_object_set(G_OBJECT(udp_rtp_sink), "port",
                      video_caps->remote_addr.rtp_port, NULL);


-------------------------------------------------------------------------------------------------------------------------------------

Regards,
Sunil


More information about the gstreamer-devel mailing list