No "pad-added" signal in rtspsrc

Francisco Velázquez francisco.javier at me.com
Fri Mar 6 06:30:03 PST 2015


Thanks, Sérgio.

Yes, the problem was that I was missing to add rstpsrc to the pipeline. Nothing more than that was needed for the program to work.

Best regards,

Francisco

> On 03 Mar 2015, at 11:39, Sérgio Agostinho <sergio.r.agostinho at gmail.com> wrote:
> 
> Hey, 
> 
> You're not adding the rstpsrc to the pipeline. You need to add the rtspsrc to the pipeline, set the pipeline to play and only then add and link the remainder elements once the rtspsrc source pads are created. If you try to set the pipeline to play with elements unlinked it will fail to transition to play. 
> 
> Cheers, 
> Sérgio 
> 
> 2015-03-02 22:37 GMT+01:00 Francisco Velázquez <francisv at ifi.uio.no <mailto:francisv at ifi.uio.no>>:
> Hello,
> 
> I am trying to create a rtsp client using the rtspsrc element, but I’m failing to have it working. The problem I see is that the “pad-added” signal is never triggered. The code is:
> 
> #include <stdio.h>
> #include <gst/gst.h>
> #include <string.h>
> 
> GST_DEBUG_CATEGORY_STATIC (my_category);
> #define GST_CAT_DEFAULT my_category
> 
> /* Structure to contain all our information, so we can pass it around */
> typedef struct _CustomData{
>   GMainLoop *main_loop;
>   GstElement *pipeline, *rtspsrc, *rtpamrdepay, *amrnbdec, *pulsesink, *rtpvp8depay, *vp8dec, *videoconvert, *ximagesink;
> }CustomData;
> 
> static void new_pad_cb (GstElement *rtspsrc, GstPad* pad, CustomData *data){
>   GST_INFO("New pad in rtspsrc added!");
>   
>   gchar *dynamic_pad_name;
>   
>   dynamic_pad_name = gst_pad_get_name (pad);
>   
>   if(gst_element_link_pads(data->rtspsrc, dynamic_pad_name, data->rtpamrdepay, "sink")){
>     GST_INFO("Pad for audio linked");
>     g_free (dynamic_pad_name);
>     return;
>   }
>   else if(gst_element_link_pads(data->rtspsrc, dynamic_pad_name, data->rtpvp8depay, "sink")){
>     GST_INFO("Pad for video linked");
>     g_free (dynamic_pad_name);
>     return;
>   }
>   g_free (dynamic_pad_name);
> }
> 
> int main (int argc, char *argv[]){
> 
>   /* Initialize our data structure */
>   CustomData data;
>   memset (&data, 0, sizeof (data));
> 
>   gst_init (&argc, &argv);
>   
>   GST_DEBUG_CATEGORY_INIT (my_category, "my_code", 0, "This is the debug category for my code.");
> 
>   /* Generic elements */
>   data.pipeline = gst_pipeline_new("pipeline");
>   data.rtspsrc = gst_element_factory_make("rtspsrc", "rtspsrc");
> 
>   /* listen for newly created pads in rtpbin */
>   g_signal_connect (data.rtspsrc, "pad-added", G_CALLBACK (new_pad_cb), &data);
> 
>   g_object_set(G_OBJECT (data.rtspsrc), "location", "rtsp://127.0.0.1:8554/test <>", NULL);
> 
>   /* Audio elements */
>   data.rtpamrdepay = gst_element_factory_make("rtpamrdepay", "rtpamrdepay");
>   data.amrnbdec = gst_element_factory_make("amrnbdec", "amrnbdec");
>   data.pulsesink = gst_element_factory_make("pulsesink", "pulsesink");
>   
>   /* Video elements */
>   data.rtpvp8depay = gst_element_factory_make("rtpvp8depay", "rtpvp8depay");
>   data.vp8dec = gst_element_factory_make("vp8dec", "vp8dec");
>   data.videoconvert = gst_element_factory_make("videoconvert", "videoconvert");
>   data.ximagesink = gst_element_factory_make("ximagesink", "ximagesink");
>   
>   gst_bin_add_many(GST_BIN(data.pipeline), data.rtpamrdepay, data.amrnbdec, data.pulsesink, data.rtpvp8depay, data.vp8dec, data.videoconvert, data.ximagesink, NULL);
>   
>   /* Linking audio elements */
>   gst_element_link_many(data.rtpamrdepay, data.amrnbdec, data.pulsesink, NULL);
>   
>   /* Linding video elements */
>   gst_element_link_many(data.rtpvp8depay, data.vp8dec, data.videoconvert, data.ximagesink, NULL);
>   
>   gst_element_set_state(data.pipeline, GST_STATE_PLAYING);
>   
>   GST_DEBUG_BIN_TO_DOT_FILE (GST_BIN (data.pipeline), GST_DEBUG_GRAPH_SHOW_ALL ,"rtcp_client");
>   
>   /* Create a GLib Main Loop and set it to run */
>   data.main_loop = g_main_loop_new (NULL, FALSE);
>   g_main_loop_run (data.main_loop);
>   
>   gst_element_set_state (data.pipeline, GST_STATE_NULL);
>   
>   return 0;
> }
> 
>  This pipeline using gst-launch-1.0 works:
> 
> gst-launch-1.0 rtspsrc location=rtsp://127.0.0.1:8554/test <> name=src src. ! rtpamrdepay ! amrnbdec ! autoaudiosink src. ! rtpvp8depay ! vp8dec ! videoconvert ! ximagesink
> 
> This means that my rtsp server is up and running, and producing an appropriate stream for this client.
> 
> Log from rtspsrc and attached logs for *:9.
> 
> $ GST_DEBUG=rtspsrc:9 ./rtsp_client
> 0:00:00.012373298 21227       0xa2ec00 DEBUG                rtspsrc gstrtspsrc.c:8087:gst_rtspsrc_uri_set_uri:<rtspsrc> parsing URI
> 0:00:00.012954043 21227       0xa2ec00 DEBUG                rtspsrc gstrtspsrc.c:8094:gst_rtspsrc_uri_set_uri:<rtspsrc> configuring URI
> 0:00:00.013509915 21227       0xa2ec00 DEBUG                rtspsrc gstrtspsrc.c:8110:gst_rtspsrc_uri_set_uri:<rtspsrc> set uri: rtsp://127.0.0.1:8554/test <>
> 0:00:00.013924933 21227       0xa2ec00 DEBUG                rtspsrc gstrtspsrc.c:8112:gst_rtspsrc_uri_set_uri:<rtspsrc> request uri is: rtsp://127.0.0.1:8554/test <>
> 
> 
> 
> Thanks for any hint on what I'm doing wrong.
> 
> Best regards,
> 
> Francisco
> 
> 
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.freedesktop.org <mailto:gstreamer-devel at lists.freedesktop.org>
> http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel <http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel>
> 
> 
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20150306/13eb1b78/attachment-0001.html>


More information about the gstreamer-devel mailing list