diff --git a/src/MediaPlayer.cpp b/src/MediaPlayer.cpp index c8e9133..0cd7b52 100644 --- a/src/MediaPlayer.cpp +++ b/src/MediaPlayer.cpp @@ -1495,6 +1495,9 @@ bool MediaPlayer::fill_frame(GstBuffer *buf, FrameStatus status) // set the start position (i.e. pts of first frame we got) if (timeline_.first() == GST_CLOCK_TIME_NONE) { timeline_.setFirst(buf->pts); + // add a gap to show that before + if (buf->pts > 0 && !timeline_.gapAt( buf->pts )) + timeline_.addGap(0, buf->pts); } } // full but invalid frame : will be deleted next iteration diff --git a/src/Timeline.cpp b/src/Timeline.cpp index a6698e6..bf1786c 100644 --- a/src/Timeline.cpp +++ b/src/Timeline.cpp @@ -101,6 +101,7 @@ void Timeline::setStep(GstClockTime dt) void Timeline::setTiming(TimeInterval interval, GstClockTime step) { timing_ = interval; + first_ = GST_CLOCK_TIME_NONE; if (step != GST_CLOCK_TIME_NONE) step_ = step; } @@ -113,6 +114,9 @@ GstClockTime Timeline::next(GstClockTime time) const if (getGapAt(time, gap) && gap.is_valid()) next_time = gap.end; + if ( first_ != GST_CLOCK_TIME_NONE && next_time < first_ ) + next_time = first_; + return next_time; } @@ -123,6 +127,9 @@ GstClockTime Timeline::previous(GstClockTime time) const if (getGapAt(time, gap) && gap.is_valid()) prev_time = gap.begin; + if ( first_ != GST_CLOCK_TIME_NONE && prev_time < first_ ) + prev_time = first_; + return prev_time; }