Hi folks,<div><br></div><div>While playing a MPTS stream, I'm trying to pause, swap pids, and start playing again.  However, when I attempt to do this, the call to gst_element_set_state(pipeline, GST_STATE_PLAYING) is (usually) not being honored (and a subsequent call to get_state() does not return).  I believe that this is likely due to a prerolling issue, but I am unsure how to resolve it.  The source element is "filesrc," followed by "typefind," but the rest of the elements are custom plugins.  I said "usually" above, because on some occasions, playback will resume after a bit of a delay.</div>

<div><br></div><div><br></div><div>Here's the order of my attempted steps (error checking hidden for simpler readability, and calls in-lined):</div><div><br></div><div><br></div><div><br></div><div>gst_element_set_state(pipeline, GST_STATE_PAUSED);</div>

<div>gst_element_get_state(pipeline, NULL, NULL, GST_CLOCK_TIME_NONE);</div><div><div><br></div><div><div><br></div></div><div>//<begin code called within the demux element></div><div>//flush upstream and downstream.  (I have also tried only flushing down-stream as well, with no change in behavior)</div>

<div><div>GST_OBJECT_LOCK(demux);</div></div><div><div>gst_pad_push_event (GST_PAD(demux->sink_pad), gst_event_new_flush_start ());</div><div>gst_pad_push_event (GST_PAD(demux->aud_src_pad), gst_event_new_flush_start ());</div>

<div>gst_pad_push_event (GST_PAD(demux->vid_src_pad), gst_event_new_flush_start ());</div><div>GST_OBJECT_UNLOCK(demux);</div><div><br></div><div>//internally, this modifies the demux filters  (the audio and video codecs are the same)</div>

<div>reconfigure_filter(demux, demux->filter[FILTER_AUDIO], 0x17dd);</div><div>reconfigure_filter(demux, demux->filter[FILTER_VIDEO], 0x17dc);</div><div><br></div><div>GST_OBJECT_LOCK(demux);</div><div>gst_pad_push_event (GST_PAD(demux->sink_pad), gst_event_new_flush_stop ());</div>

<div>gst_pad_push_event (GST_PAD(demux->aud_src_pad), gst_event_new_flush_stop ());</div><div>gst_pad_push_event (GST_PAD(demux->vid_src_pad), gst_event_new_flush_stop ());</div><div>GST_OBJECT_UNLOCK(demux);</div>
<div>
<br></div><div>//internally, this sets the pcr pid</div><div>demux_ts_set_pcr_pid(demux, 0x17dc));</div><div><br></div><div>//internally, set the demux into the playing state</div><div>demux_set_state(smd_element->dev_handle, ISMD_DEV_STATE_PLAY))</div>

<div><br></div></div><div>//</end code called within the demux element></div><div><br></div><div><br></div><div>gst_element_set_state(pipeline, GST_STATE_PLAYING);</div><div>gst_element_get_state(pipeline, NULL, NULL, GST_CLOCK_TIME_NONE);</div>

<div><br></div><div><br></div></div><div><br></div><div><br></div><div><br></div><div>As I mentioned, that "get_state()" call never returns and I never see the GST_STATE_PLAYING event in ANY of the custom elements (all of the elements are custom except for 'filesrc' and 'typefind')</div>

<div><br></div><div><br></div><div>For reference, the pipeline looks like this:</div><div><br></div><div><font face="courier new, monospace">filesrc->typefind->demux->|->vdec->vproc->vsink</font></div><div>

<font face="courier new, monospace">                          |->asink (an audio decoder and sink element)</font></div><div><br></div><div><br></div><div><br></div><div>So what's going on?  This does not appear to be a problem with the internals of the custom elements, but rather an issue with not making the gstreamer framework happy.</div>

<div><br></div><div>If I turn on lots and lots of debug prints, I will sometimes see an INFO print from the filesrc element saying "wrong-state" , but I also do not see this print reliably.</div><div><br></div>
<div>
here's the print:</div><div><div>0:00:00.906761967  2292  0x8187428 INFO                 basesrc gstbasesrc.c:2519:gst_base_src_loop:<source> pausing after gst_pad_push() = wrong-state</div></div><div><br></div>

<div>I have also tried adding a 2-second delay between each of the above calls, to try and narrow down any race conditions, and that *reliably* makes it not play.  Which is good that it's reliable, but I haven't been able to figure out yet why it isn't working.</div>

<div><br></div><div><br></div><div>Ideas on where to investigate are appreciated, as well as general advice regarding flushing the pipeline from within a pipeline element.</div><div><br></div><div>Thanks,</div><div>Eric</div>

<div><br></div><div><br></div><div><br></div><div><br></div>