Reputation: 679
I am trying learning how to use dynamic pads in gstreamer. So I tried to add pad-added signal so I can get a message once an element is created. However, I didn't get any message.
Here is the code:
#include <gst/gst.h>
static void
cb_new_pad (GstElement *element,
GstPad *pad,
gpointer data)
{
gchar *name;
name = gst_pad_get_name (pad);
g_print ("A new pad %s was created\n", name);
g_free (name);
/* here, you would setup a new pad link for the newly created pad */
}
int
main (int argc,
char *argv[])
{
GstElement *pipeline, *source, *demux;
GMainLoop *loop;
/* init */
gst_init (&argc, &argv);
/* create elements */
pipeline = gst_pipeline_new ("my_pipeline");
source = gst_element_factory_make ("filesrc", "source");
g_object_set (source, "location", argv[1], NULL);
demux = gst_element_factory_make ("oggdemux", "demuxer");
/* put together a pipeline */
gst_bin_add_many (GST_BIN (pipeline), source, demux, NULL);
gst_element_link_pads (source, "src", demux, "sink");
/* listen for newly created pads */
g_signal_connect (demux, "pad-added", G_CALLBACK (cb_new_pad), NULL);
/* start the pipeline */
gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING);
loop = g_main_loop_new (NULL, FALSE);
g_main_loop_run (loop);
}
So what is the problem ? (By the way I am using gstreamer 1.2.1
Upvotes: 1
Views: 2304
Reputation: 1244
Your code worked fine for me.
Your demuxer probably could not demultiplex the stream, check the input file that you are providing. It is probably not a valid ogg file.
On a related note, do add debugging code to your program i.e. listen to the bus for messages. It helps a lot when something doesn't work.
The basic tutorial 3 of the gstreamer sdk is a perfect example for what you're trying to do.
Upvotes: 1