Commit aa7ec20e authored by acolwell@chromium.org's avatar acolwell@chromium.org

Fix crashes caused when SourceBuffer.remove() is called starting at the presentation duration.

BUG=381302
TEST=ChunkDemuxerTest.Remove_StartAtDuration

Review URL: https://codereview.chromium.org/312403002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@275405 0039d316-1c4b-4281-b951-d872f2087c98
parent 544246e4
......@@ -1322,6 +1322,16 @@ void ChunkDemuxer::Remove(const std::string& id, TimeDelta start,
DCHECK(!id.empty());
CHECK(IsValidId(id));
DCHECK(start >= base::TimeDelta()) << start.InSecondsF();
DCHECK(start < end) << "start " << start.InSecondsF()
<< " end " << end.InSecondsF();
DCHECK(duration_ != kNoTimestamp());
DCHECK(start <= duration_) << "start " << start.InSecondsF()
<< " duration " << duration_.InSecondsF();
if (start == duration_)
return;
source_state_map_[id]->Remove(start, end, duration_);
}
......
......@@ -3030,17 +3030,6 @@ TEST_P(ChunkDemuxerTest, GCDuringSeek) {
CheckExpectedRanges(kSourceId, "{ [500,592) [792,815) }");
}
TEST_P(ChunkDemuxerTest, RemoveBeforeInitSegment) {
EXPECT_CALL(*this, DemuxerOpened());
demuxer_->Initialize(
&host_, CreateInitDoneCB(kNoTimestamp(), PIPELINE_OK), true);
EXPECT_EQ(ChunkDemuxer::kOk, AddId(kSourceId, HAS_AUDIO | HAS_VIDEO));
demuxer_->Remove(kSourceId, base::TimeDelta::FromMilliseconds(0),
base::TimeDelta::FromMilliseconds(1));
}
TEST_P(ChunkDemuxerTest, AppendWindow_Video) {
ASSERT_TRUE(InitDemuxer(HAS_VIDEO));
DemuxerStream* stream = demuxer_->GetStream(DemuxerStream::VIDEO);
......@@ -3269,6 +3258,33 @@ TEST_P(ChunkDemuxerTest, Remove_AudioVideoText) {
CheckExpectedBuffers(text_stream, "1 101 201");
}
TEST_P(ChunkDemuxerTest, Remove_StartAtDuration) {
ASSERT_TRUE(InitDemuxer(HAS_AUDIO));
DemuxerStream* audio_stream = demuxer_->GetStream(DemuxerStream::AUDIO);
// Set the duration to something small so that the append that
// follows updates the duration to reflect the end of the appended data.
EXPECT_CALL(host_, SetDuration(
base::TimeDelta::FromMilliseconds(1)));
demuxer_->SetDuration(0.001);
EXPECT_CALL(host_, SetDuration(
base::TimeDelta::FromMilliseconds(160)));
AppendSingleStreamCluster(kSourceId, kAudioTrackNum,
"0K 20K 40K 60K 80K 100K 120K 140K");
CheckExpectedRanges(kSourceId, "{ [0,160) }");
CheckExpectedBuffers(audio_stream, "0 20 40 60 80 100 120 140");
demuxer_->Remove(kSourceId,
base::TimeDelta::FromSecondsD(demuxer_->GetDuration()),
kInfiniteDuration());
Seek(base::TimeDelta());
CheckExpectedRanges(kSourceId, "{ [0,160) }");
CheckExpectedBuffers(audio_stream, "0 20 40 60 80 100 120 140");
}
// Verifies that a Seek() will complete without text cues for
// the seek point and will return cues after the seek position
// when they are eventually appended.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment