Asynchronous state change
Carlos Rafael Giani
dv at pseudoterminal.org
Thu Feb 19 03:06:41 PST 2015
On 2015-02-19 11:40, Alicia Romero wrote:
> Hi List,
> I want to change the state of a pipeline and wait till the pipeline
> has the wanted state.
> Is there a way to know when the pipeline has change to the state we
> set before?
>
> Thank!!
>
>
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
You need to watch out in the bus watch or sync handler for the
GST_MESSAGE_STATE_CHANGED message. This is the recommended way to do this.
Note that you will get statechange messages from ALL elements, which is
probably not what you want. GST_MESSAGE_SRC(msg) tells you what element
sent the msg message. I use this to check if the message was sent by the
pipeline element. If so, I handle it, otherwise I ignore it. For
debugging purposes, I also call GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS() in
the statechange message handler code.
Also keep in mind that the READY->NULL state change is not announced
anywhere, since the bus is put in a flushing state then.
In the READY->NULL change , I think you can safely assume the change
happened after the set_state call. I have never seen this state change
happen asynchronously. However, when I used a sync handler instead of a
bus watch, I sometimes got statechange messages even after calling
gst_element_set_state(pipeline, GST_STATE_NULL). I added a check to
circumvent this strange issue; if the pending state change
gst_message_parse_state_changed() gives me is set to GST_STATE_NULL
(note: not the same as GST_STATE_VOID_PENDING), I ignore the
statechange. This trick is not necessary if you are using a bus watch.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20150219/b034b462/attachment.html>
More information about the gstreamer-devel
mailing list