<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">On 2015-02-19 11:40, Alicia Romero
wrote:<br>
</div>
<blockquote
cite="mid:CAKjtJDXdYiOcetTGW97dVSZuSf1hSgps48puc5OysfB_+M-RPQ@mail.gmail.com"
type="cite">
<div dir="ltr">
<div>
<div>
<div>Hi List,<br>
</div>
I want to change the state of a pipeline and wait till the
pipeline has the wanted state. <br>
</div>
Is there a way to know when the pipeline has change to the
state we set before?<br>
<br>
</div>
Thank!!<br>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
gstreamer-devel mailing list
<a class="moz-txt-link-abbreviated" href="mailto:gstreamer-devel@lists.freedesktop.org">gstreamer-devel@lists.freedesktop.org</a>
<a class="moz-txt-link-freetext" href="http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel">http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel</a>
</pre>
</blockquote>
<br>
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.<br>
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.<br>
<br>
Also keep in mind that the READY->NULL state change is not
announced anywhere, since the bus is put in a flushing state then.<br>
<br>
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.<br>
</body>
</html>