How to resume playing after paused using gstreamer?

你。 提交于 2019-11-28 14:33:24
mpr

Do you have queue elements on each branch that comes off the tee? One for the file and one for the decode? You could also try messing around with the "sync" property on the filesink. Maybe set it to true.


Edited by Nawaz.

Since this answer first gave me few directions and almost a very-near-to-the-solution direction, it deserves the bounty I've set for this question. But before that, here is the solution (explanation is in my answer - Nawaz).

gst::element filesink("filesink", "file-sink");
filesink.set("async", gboolean(FALSE));

Hope that helps other as well.

I found the answer myself. I tried to print the status of all the elements as:

void print_status_of_all()
{
    auto it  = gst_bin_iterate_elements(GST_BIN(_pipeline.raw()));
    GValue value = G_VALUE_INIT;
    for(GstIteratorResult r = gst_iterator_next(it, &value); r != GST_ITERATOR_DONE; r = gst_iterator_next(it, &value))
    {
         if ( r == GST_ITERATOR_OK )
         {
             GstElement *e = static_cast<GstElement*>(g_value_peek_pointer(&value));
             GstState  current, pending;
             auto ret = gst_element_get_state(e, &current, &pending, 100000);
             g_print("%s(%s), status = %s, pending = %s\n", G_VALUE_TYPE_NAME(&value), gst_element_get_name(e), gst_element_state_get_name(current), gst_element_state_get_name(pending));
         }
    }
}

And then it helped me figured out that the status of all the elements were changing from PLAYING to PAUSED and PAUSED to PLAYING, without any pending state, except filesink element whose state remains at PLAYING and a pending PAUSED state (which is because it attempts to change it asynchronously) — that eventually led me to the async property of the GstBaseSink which is the base class of filesink. I just set it to FALSE as:

gst::element filesink("filesink", "file-sink");
filesink.set("async", gboolean(FALSE));

That's it. Now pause and resume works great — status of all the elements change to PLAYING to PAUSED and PAUSED to PLAYING, without any pending state!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!