Gstreamer 如何通过GMainLoop访问管道?

Gstreamer 如何通过GMainLoop访问管道?,gstreamer,Gstreamer,我有一个应用程序正在读取一个电影文件,我想在流到达流的末尾时将流重置为其初始位置 gint64 streamPosition, streamLength; GstFormat format = GST_FORMAT_TIME; gst_element_query_position (pipeline, &format, &streamPosition); gst_element_query_duration (pipeline, &format, &stream

我有一个应用程序正在读取一个电影文件,我想在流到达流的末尾时将流重置为其初始位置

gint64 streamPosition, streamLength;
GstFormat format = GST_FORMAT_TIME;

gst_element_query_position (pipeline, &format, &streamPosition);
gst_element_query_duration (pipeline, &format, &streamLength);
if (streamPosition==streamLength)
    stopIt(widget,pipeline);
所以我有了通常的结构,我加了一辆巴士来观看比赛

bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
gst_bus_add_watch (bus, bus_call, loop);
gst_object_unref (bus);
这是一个总线调用函数的片段

static gboolean bus_call (GstBus     *bus,
                      GstMessage *msg,
                      gpointer data)
{
    GMainLoop *loop = (GMainLoop *) data;

    switch (GST_MESSAGE_TYPE (msg))
    {
    case GST_MESSAGE_EOS:
        g_print ("End of stream\n");
            g_main_loop_quit (loop);
        break;
    default:
        break;
    }
    return TRUE;
}
所以现在,当我到达流的末尾时,我只是退出循环。 我可以通过环路访问我的管道吗? 谢谢阅读,如果我想做一些不可能的事,请告诉我


ps:我希望避免将管道设置为全局变量,或者将包含管道和循环的结构传递给bus_调用,因为这感觉是错误的

我的目标是在流结束时自动倒带。用户可以点击播放按钮,再次播放

所以我避开了这个问题,修改了播放按钮的回调函数。 现在,它检测当前流的位置,并将其与流的长度进行比较

gint64 streamPosition, streamLength;
GstFormat format = GST_FORMAT_TIME;

gst_element_query_position (pipeline, &format, &streamPosition);
gst_element_query_duration (pipeline, &format, &streamLength);
if (streamPosition==streamLength)
    stopIt(widget,pipeline);
如果当前流的位置等于流的长度,这意味着我们在流的末端。所以我调用一个函数来倒带流

感觉很不舒服,但这是我目前拥有的“最佳”解决方案

我仍然愿意接受建议