Index: media/filters/frame_processor_unittest.cc |
diff --git a/media/filters/frame_processor_unittest.cc b/media/filters/frame_processor_unittest.cc |
index 6061bfe97689b426f01fe89cf8b036165d40b8cf..6e1415f9e000a0330687b4b26db9a097ff4f0779 100644 |
--- a/media/filters/frame_processor_unittest.cc |
+++ b/media/filters/frame_processor_unittest.cc |
@@ -567,6 +567,84 @@ TEST_P(FrameProcessorTest, AudioVideo_Discontinuity) { |
} |
} |
+TEST_P(FrameProcessorTest, AudioOnly_AppendWindowMaximalContinuousGap) { |
+ // Tests A: P(A0) + append window start=29 + P(A10,A20,A30) -> |
+ // In both sequence and segments mode, with partial append window filtering |
+ // supported: TSO==0,(a0,a20@29,a30) |
+ // Since only frames from original time [10,29) are dropped, including |
+ // partial discard [20,29), the April 1, 2014 spec does not signal |
+ // discontinuity. |
+ InSequence s; |
+ AddTestTracks(HAS_AUDIO); |
+ new_media_segment_ = true; |
+ if (GetParam()) |
+ frame_processor_->SetSequenceMode(true); |
+ |
+ EXPECT_CALL(callbacks_, PossibleDurationIncrease(frame_duration_)); |
+ ProcessFrames("0K", ""); |
+ EXPECT_FALSE(new_media_segment_); |
+ EXPECT_EQ(base::TimeDelta(), timestamp_offset_); |
+ CheckExpectedRangesByTimestamp(audio_.get(), "{ [0,10) }"); |
+ |
+ EXPECT_CALL(callbacks_, PossibleDurationIncrease(frame_duration_ * 4)); |
+ append_window_start_ = base::TimeDelta::FromMilliseconds(29); |
+ ProcessFrames("10K 20K 30K", ""); |
+ EXPECT_FALSE(new_media_segment_); |
+ EXPECT_EQ(base::TimeDelta(), timestamp_offset_); |
+ CheckExpectedRangesByTimestamp(audio_.get(), "{ [0,40) }"); |
+ CheckReadsThenReadStalls(audio_.get(), "0 29:20 30"); |
+} |
+ |
+TEST_P(FrameProcessorTest, AudioOnly_AppendWindowAndMinimalDiscontinuity) { |
+ // Tests A: P(A0,A10) + append window start=40 + P(A20,A30,A40,A50,A60,A70) -> |
+ // |
+ // TODO(wolenetz): Two initial frame appends (versus one) are required to |
+ // prevent SourceBufferStream's inter-buffer distance fudging from merging |
+ // these otherwise discontinuous ranges. See http://crbug.com/351166. |
+ // |
+ // If segments mode: TSO==0,(a0,a10,),seek(40)->(a40,a50,a60,a70) |
+ // If sequence mode: TSO==-20,(a0,a10,a60@40,a70@50) |
+ // |
+ // TODO(wolenetz/acolwell): Compliant sequence mode frame processing with |
+ // append window filtering can result in strange lack of second detection of |
+ // discontinuity after first discontinuity detected. |
+ InSequence s; |
+ AddTestTracks(HAS_AUDIO); |
+ new_media_segment_ = true; |
+ bool using_sequence_mode = GetParam(); |
+ if (using_sequence_mode) |
+ frame_processor_->SetSequenceMode(true); |
+ EXPECT_CALL(callbacks_, PossibleDurationIncrease(frame_duration_ * 2)); |
+ |
+ ProcessFrames("0K 10K", ""); |
+ EXPECT_FALSE(new_media_segment_); |
+ EXPECT_EQ(base::TimeDelta(), timestamp_offset_); |
+ CheckExpectedRangesByTimestamp(audio_.get(), "{ [0,20) }"); |
+ |
+ if (using_sequence_mode) |
+ EXPECT_CALL(callbacks_, PossibleDurationIncrease(frame_duration_ * 6)); |
+ else |
+ EXPECT_CALL(callbacks_, PossibleDurationIncrease(frame_duration_ * 8)); |
+ |
+ append_window_start_ = base::TimeDelta::FromMilliseconds(40); |
+ ProcessFrames("20K 30K 40K 50K 60K 70K", ""); |
+ EXPECT_FALSE(new_media_segment_); |
+ |
+ if (using_sequence_mode) { |
+ EXPECT_EQ(frame_duration_ * -2, timestamp_offset_); |
+ CheckExpectedRangesByTimestamp(audio_.get(), "{ [0,60) }"); |
+ CheckReadsThenReadStalls(audio_.get(), "0 10 40:60 50:70"); |
+ } else { |
+ EXPECT_EQ(base::TimeDelta(), timestamp_offset_); |
+ CheckExpectedRangesByTimestamp(audio_.get(), "{ [0,20) [40,80) }"); |
+ CheckReadsThenReadStalls(audio_.get(), "0 10"); |
+ audio_->AbortReads(); |
+ audio_->Seek(frame_duration_ * 4); |
+ audio_->StartReturningData(); |
+ CheckReadsThenReadStalls(audio_.get(), "40 50 60 70"); |
+ } |
+} |
+ |
INSTANTIATE_TEST_CASE_P(SequenceMode, FrameProcessorTest, Values(true)); |
INSTANTIATE_TEST_CASE_P(SegmentsMode, FrameProcessorTest, Values(false)); |