1

我是 gstreamer 的新手,正在尝试开发一个用于字幕解码的示例插件。

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

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

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

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

在此先感谢,克兰蒂


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");
}

4

1 回答 1

1

在尝试了一些关于 gstreamer 元素的示例后,发现了问题。

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

但是为什么需要这样做-我仍在尝试弄清楚

有时,用于创建管道的名称也会引起问题:最好使用一些唯一的名称而不是 gst_pipeline_new ("管道") 中的管道;

于 2013-03-27T07:19:07.140 回答