[gst-devel] Troubles with segments, reverse playback and events, possible misunderstanding.

wl2776 wl2776 at gmail.com
Wed May 12 16:55:31 CEST 2010


Briefly, my question is, after setting the pipeline to reverse playback from
a file end and pause, how can I keep current position on the very last frame
but reconfigure it to prepare to play the file again from begin to end with
the forward playback direction?

Now details.
I am developing a video player using playbin2.

One of the desired functionality is "Go End" feature. 
The player should display the very last movie frame and go to pause. Then,
if the play button is pressed again, it should again go to paused state.

My application has the "Play/Pause" button and sets its icon to the "Play"
or "Pause" depending on what the pipeline is doing currently. It also
listens to the EOS message and sets the icon on the "Play/Pause" button to
"Play", and sends the pipeline to the paused state.

I am working with MPEG2 Program Streams, which constitute the majority of
the media. Other media types also present, so I am using the playbin2
element.

I tried to implement "Go End" function using seek events (with
gst_element_seek() and gst_element_seek_simple()), but it didn't work.
The player jumped to the desired position (equal to the stream duration),
but didn't display the latest frame.

Then I have implemented it by making it to reverse playback, like the
following:

gst_element_set_state(GST_ELEMENT(m_player),GST_STATE_PAUSED);
gboolean rb=gst_element_seek(GST_ELEMENT(m_player),-1.0,
 
GST_FORMAT_TIME,(GstSeekFlags)(GST_SEEK_FLAG_FLUSH|GST_SEEK_FLAG_ACCURATE),
  GST_SEEK_TYPE_SET,0,GST_SEEK_TYPE_END,m_stream_duration);


This almost works. The player displays the last frame and goes to the paused
state.
However, if I press the play button, it goes to the playing state, but
doesn't play anything.
I suspect, it still plays the movie in reverse, but the poor implementation
of this functionality in mpeg2 elements simply hangs the pipeline in waiting
for EOS message.

I tried to catch the async-done message, resulted by setting that reverse
playback, and set new segment, but call to gst_element_send_event( <new
segment event> ) returned FALSE.
The following:

gboolean bus_watch(GstBus *bus, GstMessage *msg)
{
    switch (GST_MESSAGE_TYPE (msg)) {
  ....
        case GST_MESSAGE_ASYNC_DONE:{
            GstEvent *evt=gst_event_new_new_segment(TRUE,1.0,
                          GST_FORMAT_TIME,0,m_stream_duration,0);
            rb=gst_element_send_event(m_player,evt);
            GST_DEBUG("async-done: send newsegment returned %d",rb);
            rb=gst_element_seek(m_player,1.0,GST_FORMAT_TIME,
                   
(GstSeekFlags)(GST_SEEK_FLAG_FLUSH|GST_SEEK_FLAG_ACCURATE),
   	     
GST_SEEK_TYPE_SET,m_current_position,GST_SEEK_TYPE_SET,m_stream_duration);
            GST_DEBUG("async-done: seek returned %d",rb);
        }
  ....

    }
}


I set some flags in the player object, they are omitted for brevity. 
But I am sure, these functions are not called on every async-done event,
only on that caused by the call to go_end() function.

Debug output shows that send newsegment returns 0.

So, how can I reconfigure the player to prepare playing the file from begin
to end with the forward playback direction and keep current position on the
very last frame?

Is async-done the correct message, which I should catch for this?

-- 
View this message in context: http://gstreamer-devel.966125.n4.nabble.com/Troubles-with-segments-reverse-playback-and-events-possible-misunderstanding-tp2196173p2196173.html
Sent from the GStreamer-devel mailing list archive at Nabble.com.




More information about the gstreamer-devel mailing list