Reputation: 192
I am a newbie in gstreamer and trying to develop a sample plugin for captions decoding.
I have downloaded the gStreamer Plugin template: based on this information.
When I launched the plugin from command line, it is working fine.
I wrote a sample application to verify the plugin. But now, I am facing a problem in setting pipeline state to PLAYING. Below is the code snippet
Any inputs would be of great help.
Thanks in advance, Kranti
gst_init(NULL, NULL);
loop = g_main_loop_new (NULL, TRUE);
g_print("\n Gstreamer is Initialized and Created the loop ");
pipeline = gst_pipeline_new ("pipeline");
source = gst_element_factory_make ("filesrc", "source");
filter = gst_element_factory_make ("myfilter", "testfilter");
sink = gst_element_factory_make ("fakesink", "sink");
if((NULL != pipeline) && (NULL != source) && (NULL != filter) && (NULL != sink))
{
g_print("\n Successfully created the factory elements ");
g_object_set(G_OBJECT (source), "location", fileName, NULL);
g_print("\n Set the file name \n");
g_object_set(G_OBJECT (filter), "silent", 1, NULL);
g_print("\n Set the silent type \n");
/* we add a message handler */
bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
bus_watch_id = gst_bus_add_watch (bus, bus_call, loop);
gst_object_unref (bus);
g_print("\n Created bus and a monitor to watch it");
gst_bin_add_many(GST_BIN(pipeline), source, filter, sink, NULL);
gst_element_link_many(source, filter, sink);
g_print("\n Added and Linked the factory elements");
g_signal_connect (filter, "pad-added", G_CALLBACK (on_pad_added), filter);
g_print ("Now reading: %s\n", "test.txt");
g_print ("Setting the pipeline state to PLAYING ");
ret = gst_element_set_state (pipeline, GST_STATE_PLAYING);
if(ret == GST_STATE_CHANGE_FAILURE)
{
g_print("\n Failure in setting pipeline state to PLAYING \n");
}
else
{
g_print("\n Successfully set the pipeline state to playing \n");
}
}
else
{
g_print("\n Failure in creating factory elements");
}
Upvotes: 1
Views: 4613
Reputation: 192
After trying with few examples on gstreamer elements, found the problem.
Apart from filesrc, filter, fakesink:: If I add 'decoder' element also to the pipeline, then I am able to change the state to PLAYING
But why is that required - I am still trying to figure it out
And sometimes, the name used to create pipeline is also causing problems: Better to use some unique name rather than pipeline in gst_pipeline_new ("pipeline");
Upvotes: 1