Gstreamer async CB

Hello.

I was working with ofGstVideoPlayer recently doing a frame-by-frame process on video files.

doing a player.setFrame() is performing an asynchronous seek in the background. the implementation is using GST_SEEK_FLAG_FLUSH which flushes the pipeline. from gstreamer documentation:
“Flushing seeks will trigger a preroll, which will emit GST_MESSAGE_ASYNC_DONE.”

In order to do frame-by-frame stepping as fast as possible, we need a way to know when GST_MESSAGE_ASYNC_DONE occurs.

looking into ofGstUtils::gstHandleMessage() is reveals GST_MESSAGE_ASYNC_DONE is not handled at all.

i am not quite sure about the side-effects, but suggest to add a on_async_done() callback so that one can react on async_done on higher level.
no idea how well this would fit to other video-player / grabber implementations.

The attached diff does change the following:
ofGstAsyncCB.diff.zip (768 Bytes)

adds a virtual function in class ofGstAppSink

class ofGstAppSink{
public:
    virtual void on_async_done(){};
}

in ofGstUtils::gstHandleMessage() calls on_async_done()

case GST_MESSAGE_ASYNC_DONE:
            if (appsink) appsink->on_async_done();
            ofLogVerbose("ofGstUtils") << "gstHandleMessage(): async done";

in class ofGstVideoPlayer add virtual function on_asnyc_done()

class ofGstVideoPlayer: public ofBaseVideoPlayer, public ofGstAppSink{
    virtual void on_async_done() {};
}

so, if somebody wants to use on_async_done() one can subclass ofGstPlayer and implement on_async_done().

happy to hear any comments about that.

cheers
inx

1 Like