No "pad-added" signal in rtspsrc
Francisco Velázquez
francisv at ifi.uio.no
Mon Mar 2 13:37:32 PST 2015
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 <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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20150302/89aa5e5d/attachment-0002.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: log.log
Type: application/octet-stream
Size: 2514543 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20150302/89aa5e5d/attachment-0001.obj>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20150302/89aa5e5d/attachment-0003.html>
More information about the gstreamer-devel
mailing list