Implementing a media player using Gstreamer: Mapping the STOPPED state

Mandeep Sandhu mandeepsandhu.chd at gmail.com
Tue Dec 4 03:30:24 PST 2012


Hi All,

I'm implementing a media player on an embedded board. I'm using
Gstreamer for the actual media playback (the chip vendor provides us
with some proprietary plugins for H264/AAC decoding and audio/video
sinks for the specific hardware).

Currently I'm concentrating on just playing MP4/H264/AAC files (other
formats will be supported later when I figure out how to do
auto-detection! :))

My gst pipeline essentially looks like this:

file-source -> qtdemux -> h264dec -> vsink
                        |
                        +-----> aacdec -> asink


So, I have most of the bits worked out, except what state to set on
the pipeline when I'm in the STOPPED state of my player (eg: a user
pressed the STOP button on the player or the stream ended (EOS)).

Initially I thought setting the pipeline to READY state would do it
but that turned out to be wrong. Reading docs on GST_MESSAGE_EOS
revealed that the EOS event is retained in the elements and has to be
flushed explicitly.

I have the state of my player being tracked by state machine, so the
SM transitions to the STOPPED state on either an explicit command (by
the user) or when the EOS message appears on the pipeline's bus.

So I wrote some code to flush the pipeline and then set it to the
PAUSED state (since I don't want playback to start automatically).
Here's what I do when going into the STOPPED state:

gst_element_seek(m_pipeline, 1.0, GST_FORMAT_TIME,
                     GST_SEEK_FLAG_FLUSH, GST_SEEK_TYPE_SET,
                     0, GST_SEEK_TYPE_NONE,  0);
gst_element_set_state (m_pipeline, GST_STATE_PAUSED);

Is this correct way to handle the scenario described or is there a
better/recommended way of going about it?

I basically want the stream playback position to be set to the start
so that a play command will cause it to play the file from the
beginning.

Any pointers appreciated.

Thanks,
-mandeep


More information about the gstreamer-devel mailing list