summaryrefslogtreecommitdiffstats
path: root/media/filters
diff options
context:
space:
mode:
authordamienv@chromium.org <damienv@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-09 05:52:35 +0000
committerdamienv@chromium.org <damienv@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-09 05:52:35 +0000
commit5655d80f8720212cf6901fcb1e62e0d5abb79e53 (patch)
tree0a6451497f6214dc78afe8f98d6f34b56da260ee /media/filters
parentd82834280800eaa091b2020199de1236ff2a126b (diff)
downloadchromium_src-5655d80f8720212cf6901fcb1e62e0d5abb79e53.zip
chromium_src-5655d80f8720212cf6901fcb1e62e0d5abb79e53.tar.gz
chromium_src-5655d80f8720212cf6901fcb1e62e0d5abb79e53.tar.bz2
Invoke the seek callback during abort if needed.
BUG=392281 TEST=ChunkDemuxerTest.SeekCompleteDuringAbort Review URL: https://codereview.chromium.org/374203003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@281965 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/filters')
-rw-r--r--media/filters/chunk_demuxer.cc7
-rw-r--r--media/filters/chunk_demuxer_unittest.cc39
2 files changed, 46 insertions, 0 deletions
diff --git a/media/filters/chunk_demuxer.cc b/media/filters/chunk_demuxer.cc
index b83199c..657859a 100644
--- a/media/filters/chunk_demuxer.cc
+++ b/media/filters/chunk_demuxer.cc
@@ -1304,9 +1304,16 @@ void ChunkDemuxer::Abort(const std::string& id,
base::AutoLock auto_lock(lock_);
DCHECK(!id.empty());
CHECK(IsValidId(id));
+ bool old_waiting_for_data = IsSeekWaitingForData_Locked();
source_state_map_[id]->Abort(append_window_start,
append_window_end,
timestamp_offset);
+ // Abort can possibly emit some buffers.
+ // Need to check whether seeking can be completed.
+ if (old_waiting_for_data && !IsSeekWaitingForData_Locked() &&
+ !seek_cb_.is_null()) {
+ base::ResetAndReturn(&seek_cb_).Run(PIPELINE_OK);
+ }
}
void ChunkDemuxer::Remove(const std::string& id, TimeDelta start,
diff --git a/media/filters/chunk_demuxer_unittest.cc b/media/filters/chunk_demuxer_unittest.cc
index ea65ce3..0bb3ecc 100644
--- a/media/filters/chunk_demuxer_unittest.cc
+++ b/media/filters/chunk_demuxer_unittest.cc
@@ -3022,6 +3022,45 @@ TEST_F(ChunkDemuxerTest, EmitBuffersDuringAbort) {
EXPECT_EQ(range_after_abort.start(0), range_before_abort.start(0));
EXPECT_GT(range_after_abort.end(0), range_before_abort.end(0));
}
+
+TEST_F(ChunkDemuxerTest, SeekCompleteDuringAbort) {
+ EXPECT_CALL(*this, DemuxerOpened());
+ demuxer_->Initialize(
+ &host_, CreateInitDoneCB(kInfiniteDuration(), PIPELINE_OK), true);
+ EXPECT_EQ(ChunkDemuxer::kOk, AddIdForMp2tSource(kSourceId));
+
+ // For info:
+ // DTS/PTS derived using dvbsnoop -s ts -if bear-1280x720.ts -tssubdecode
+ // Video: first PES:
+ // PTS: 126912 (0x0001efc0) [= 90 kHz-Timestamp: 0:00:01.4101]
+ // DTS: 123909 (0x0001e405) [= 90 kHz-Timestamp: 0:00:01.3767]
+ // Audio: first PES:
+ // PTS: 126000 (0x0001ec30) [= 90 kHz-Timestamp: 0:00:01.4000]
+ // DTS: 123910 (0x0001e406) [= 90 kHz-Timestamp: 0:00:01.3767]
+ // Video: last PES:
+ // PTS: 370155 (0x0005a5eb) [= 90 kHz-Timestamp: 0:00:04.1128]
+ // DTS: 367152 (0x00059a30) [= 90 kHz-Timestamp: 0:00:04.0794]
+ // Audio: last PES:
+ // PTS: 353788 (0x000565fc) [= 90 kHz-Timestamp: 0:00:03.9309]
+
+ scoped_refptr<DecoderBuffer> buffer = ReadTestDataFile("bear-1280x720.ts");
+ AppendData(kSourceId, buffer->data(), buffer->data_size());
+
+ // Confirm we're in the middle of parsing a media segment.
+ ASSERT_TRUE(demuxer_->IsParsingMediaSegment(kSourceId));
+
+ // Seek to a time corresponding to buffers that will be emitted during the
+ // abort.
+ Seek(base::TimeDelta::FromMilliseconds(4110));
+
+ // Abort on the Mpeg2 TS parser triggers the emission of the last video
+ // buffer which is pending in the stream parser.
+ demuxer_->Abort(kSourceId,
+ append_window_start_for_next_append_,
+ append_window_end_for_next_append_,
+ &timestamp_offset_map_[kSourceId]);
+}
+
#endif
#endif