[gst-devel] What happens to the current segment after seek in the playbin2?

wl2776 wl2776 at gmail.com
Fri Jun 25 12:39:17 CEST 2010


I have the following code, which queries the current segment, issues a seek
and queries the current segment again.

m_player is the playbin2, it has loaded the MPEG2-PS file, and it was turned
to the reverse playback before this code.

GstQuery *query=gst_query_new_segment(GST_FORMAT_TIME);
gst_element_query(GST_ELEMENT(m_player),query);

gdouble rate;
GstFormat fmt;
gint64 start=-1,stop=-1;
gst_query_parse_segment(query,&rate,&fmt,&start,&stop);
GST_DEBUG("segment before seek: rate %f fmt %d start %"G_GINT64_FORMAT
                          " stop %"G_GINT64_FORMAT", direction
%d",rate,fmt,start,stop,m_direction);
gst_query_unref(query);

GST_DEBUG("current_position = %"G_GINT64_FORMAT, m_current_position);
if(!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("seek failed");

query=gst_query_new_segment(GST_FORMAT_TIME);
gst_element_query(GST_ELEMENT(m_player),query);
gst_query_parse_segment(query,&rate,&fmt,&start,&stop);
GST_DEBUG("segment after seek: rate %f fmt %d start %"G_GINT64_FORMAT
                         " stop %"G_GINT64_FORMAT", direction
%d",rate,fmt,start,stop,m_direction);
gst_query_unref(query);


The relevant code of the bus-watch:
case GST_MESSAGE_ASYNC_DONE:{
    GST_DEBUG("message %s(%d) from %s",GST_MESSAGE_TYPE_NAME(msg),
                                     
GST_MESSAGE_TYPE(msg),GST_MESSAGE_SRC_NAME(msg));
    GstFormat fmt=GST_FORMAT_TIME;

    gst_element_query_position(m_player,&fmt,&m_current_position);
    GST_DEBUG("current player position
%dms",GST_TIME_AS_MSECONDS(m_current_position));

    GstQuery *query=gst_query_new_segment(GST_FORMAT_TIME);
    gst_element_query(GST_ELEMENT(m_player),query);
    gdouble rate;
    gint64 start=-1,stop=-1;
    gst_query_parse_segment(query,&rate,&fmt,&start,&stop);
    GST_DEBUG("current segment: rate %lf fmt %d start %"G_GINT64_FORMAT
                           " stop %"G_GINT64_FORMAT" direction
%d",rate,fmt,start,stop,m_direction);
    gst_query_unref(query);
}
break;


I observe the following debug output (few first columns are omitted for
brevity)

DEBUG                 player gst_player.cpp:800:gst_player::play: segment
before seek: rate -1.000000 fmt 3 start 0 stop 450054800000, direction -1
DEBUG                 player gst_player.cpp:804:gst_player::play:
current_position = 450054800000
DEBUG                 player gst_player.cpp:815:gst_player::play: segment
after seek: rate 1.000000 fmt 3 start 0 stop -1, direction -1
DEBUG                 player gst_player.cpp:345:gst_player::bus_watch:
message async-done(2097152) from playbin0
DEBUG                 player gst_player.cpp:349:gst_player::bus_watch:
current player position 450054ms
0:01:22.658857000  2652   040051E8 DEBUG                 player
gst_player.cpp:356:gst_player::bus_watch: current segment: rate 1.000000 fmt
3 start 0 stop -1 direction 1


I've read in the documentation, that the current playing segment is
configured with the seek.
Why doesn't the playback direction change after the seek?

And again, I observe the jump in frames. 
The m_player was paused and stepping frames backwards before the code above
was called.
However, when the m_player is put to playing, it plays from the frame where
it was paused or even some frames after it. 
The impression is like the framestepping was in both directions. Frames
stepped back were shown, but the beginning of the playing segment was
shifted to the end of file by the same amount of frames.
-- 
View this message in context: http://gstreamer-devel.966125.n4.nabble.com/What-happens-to-the-current-segment-after-seek-in-the-playbin2-tp2268270p2268270.html
Sent from the GStreamer-devel mailing list archive at Nabble.com.




More information about the gstreamer-devel mailing list