GStreamer - 示例插件

时间:2013-03-27 04:41:57

标签: plugins gstreamer

我是gstreamer的新手,并试图为字幕解码开发一个示例插件。

我已经下载了gStreamer插件模板:基于this信息。

当我从命令行启动插件时,它运行正常。

我写了一个示例应用程序来验证插件。 但是现在,我在将管道状态设置为PLAYING 时遇到了问题。以下是代码段

任何输入都会有很大的帮助。

提前致谢, 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");
}

1 个答案:

答案 0 :(得分:1)

在尝试了几个关于gstreamer元素的例子后,发现了问题。

除了filesrc,filter,fakesink ::如果我也将'decoder'元素添加到管道中,那么我可以将状态更改为PLAYING

但为什么需要这样做 - 我仍然想弄明白

有时,用于创建管道的名称也会导致问题:最好在gst_pipeline_new中使用一些唯一的名称而不是管道(“管道”);