summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--media/filters/frame_processor.cc8
-rw-r--r--media/filters/frame_processor_unittest.cc19
2 files changed, 24 insertions, 3 deletions
diff --git a/media/filters/frame_processor.cc b/media/filters/frame_processor.cc
index 3071439..68f4c61 100644
--- a/media/filters/frame_processor.cc
+++ b/media/filters/frame_processor.cc
@@ -261,13 +261,15 @@ bool FrameProcessor::ProcessFrame(
if (frame->timestamp() != presentation_timestamp && !sequence_mode_)
*new_media_segment = true;
- // |frame| has been partially trimmed or had preroll added.
+ // |frame| has been partially trimmed or had preroll added. Though
+ // |frame|'s duration may have changed, do not update |frame_duration|
+ // here, so |track_buffer|'s last frame duration update uses original
+ // frame duration and reduces spurious discontinuity detection.
decode_timestamp = frame->GetDecodeTimestamp();
presentation_timestamp = frame->timestamp();
- frame_duration = frame->duration();
// The end timestamp of the frame should be unchanged.
- DCHECK(frame_end_timestamp == presentation_timestamp + frame_duration);
+ DCHECK(frame_end_timestamp == presentation_timestamp + frame->duration());
}
if (presentation_timestamp < append_window_start ||
diff --git a/media/filters/frame_processor_unittest.cc b/media/filters/frame_processor_unittest.cc
index b6f5d2f..f4cde5a 100644
--- a/media/filters/frame_processor_unittest.cc
+++ b/media/filters/frame_processor_unittest.cc
@@ -633,6 +633,25 @@ TEST_P(FrameProcessorTest, AllowNegativeFramePTSAndDTSBeforeOffsetAdjustment) {
}
}
+TEST_P(FrameProcessorTest, PartialAppendWindowFilterNoDiscontinuity) {
+ // Tests that spurious discontinuity is not introduced by a partially
+ // trimmed frame.
+ InSequence s;
+ AddTestTracks(HAS_AUDIO);
+ new_media_segment_ = true;
+ if (GetParam())
+ frame_processor_->SetSequenceMode(true);
+ EXPECT_CALL(callbacks_,
+ PossibleDurationIncrease(base::TimeDelta::FromMilliseconds(29)));
+
+ append_window_start_ = base::TimeDelta::FromMilliseconds(7);
+ ProcessFrames("0K 19K", "");
+
+ EXPECT_EQ(base::TimeDelta(), timestamp_offset_);
+ CheckExpectedRangesByTimestamp(audio_.get(), "{ [7,29) }");
+ CheckReadsThenReadStalls(audio_.get(), "7:0 19");
+}
+
INSTANTIATE_TEST_CASE_P(SequenceMode, FrameProcessorTest, Values(true));
INSTANTIATE_TEST_CASE_P(SegmentsMode, FrameProcessorTest, Values(false));