Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(421)

Unified Diff: media/filters/chunk_demuxer_unittest.cc

Issue 1922333002: Implement mapping blink track id to demuxer streams (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: CR feedback Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: media/filters/chunk_demuxer_unittest.cc
diff --git a/media/filters/chunk_demuxer_unittest.cc b/media/filters/chunk_demuxer_unittest.cc
index db320ba00e0e5ea5a0afccbcc2b0e2beb0222b25..55adf2a682c2d9308e7dd892fe4cfaea6bd34862 100644
--- a/media/filters/chunk_demuxer_unittest.cc
+++ b/media/filters/chunk_demuxer_unittest.cc
@@ -82,6 +82,8 @@ const int kVideoTrackSizeWidth = 8;
const int kVideoTrackEntryHeaderSize =
kVideoTrackSizeOffset + kVideoTrackSizeWidth;
+// Track numbers AKA bytestream track ids. Bytestream track ids might change
+// within a single playback session if there is only one track of a given type.
const int kVideoTrackNum = 1;
const int kAudioTrackNum = 2;
const int kTextTrackNum = 3;
@@ -89,6 +91,14 @@ const int kAlternateVideoTrackNum = 4;
const int kAlternateAudioTrackNum = 5;
const int kAlternateTextTrackNum = 6;
+// These value represent externally assigned track ids (for example track ids
+// assigned by blink). Not to be confused with bytestream track ids above. The
+// main difference is that these track ids must stay the same for the duration
+// of the playback session, whereas track numbers / bytestream track ids might
+// change in subsequent init segments.
+const int kExternalVideoTrackId = 10;
+const int kExternalAudioTrackId = 11;
+
const int kAudioBlockDuration = 23;
const int kVideoBlockDuration = 33;
const int kTextBlockDuration = 100;
@@ -1404,6 +1414,24 @@ class ChunkDemuxerTest : public ::testing::Test {
DCHECK(tracks.get());
DCHECK_GT(tracks->tracks().size(), 0u);
+ std::vector<unsigned> track_ids;
+ bool found_audio_track = false;
+ bool found_video_track = false;
+ for (const auto& track : tracks->tracks()) {
+ if (track->type() == MediaTrack::Audio) {
+ DCHECK(!found_audio_track);
+ found_audio_track = true;
+ track_ids.push_back(kExternalAudioTrackId);
+ } else if (track->type() == MediaTrack::Video) {
+ DCHECK(!found_video_track);
+ found_video_track = true;
+ track_ids.push_back(kExternalVideoTrackId);
+ } else {
+ NOTREACHED();
+ }
+ }
+ demuxer_->OnTrackIdsAssigned(*tracks.get(), track_ids);
+
InitSegmentReceivedMock(tracks);
}
@@ -1603,6 +1631,10 @@ TEST_F(ChunkDemuxerTest, AudioVideoTrackIdsChange) {
DemuxerStream* video_stream = demuxer_->GetStream(DemuxerStream::VIDEO);
ASSERT_TRUE(audio_stream);
ASSERT_TRUE(video_stream);
+ ASSERT_EQ(audio_stream,
+ demuxer_->GetDemuxerStreamByTrackId(kExternalAudioTrackId));
+ ASSERT_EQ(video_stream,
+ demuxer_->GetDemuxerStreamByTrackId(kExternalVideoTrackId));
AppendMuxedCluster(MuxedStreamInfo(kAudioTrackNum, "0K 23K", 23),
MuxedStreamInfo(kVideoTrackNum, "0K 30", 30));
@@ -1616,6 +1648,10 @@ TEST_F(ChunkDemuxerTest, AudioVideoTrackIdsChange) {
CheckExpectedRanges("{ [0,92) }");
CheckExpectedBuffers(audio_stream, "0K 23K 46K 69K");
CheckExpectedBuffers(video_stream, "0K 30 60K");
+ ASSERT_EQ(audio_stream,
+ demuxer_->GetDemuxerStreamByTrackId(kExternalAudioTrackId));
+ ASSERT_EQ(video_stream,
+ demuxer_->GetDemuxerStreamByTrackId(kExternalVideoTrackId));
ShutdownDemuxer();
}

Powered by Google App Engine
This is Rietveld 408576698