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

Side by Side 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: rebase Created 4 years, 6 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/filters/chunk_demuxer.h" 5 #include "media/filters/chunk_demuxer.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <algorithm> 9 #include <algorithm>
10 #include <utility> 10 #include <utility>
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 const int kAudioTrackSizeWidth = 8; 74 const int kAudioTrackSizeWidth = 8;
75 const int kAudioTrackEntryHeaderSize = 75 const int kAudioTrackEntryHeaderSize =
76 kAudioTrackSizeOffset + kAudioTrackSizeWidth; 76 kAudioTrackSizeOffset + kAudioTrackSizeWidth;
77 77
78 // The size of TrackEntry element in test file "webm_vp8_track_entry" starts at 78 // The size of TrackEntry element in test file "webm_vp8_track_entry" starts at
79 // index 1 and spans 8 bytes. 79 // index 1 and spans 8 bytes.
80 const int kVideoTrackSizeOffset = 1; 80 const int kVideoTrackSizeOffset = 1;
81 const int kVideoTrackSizeWidth = 8; 81 const int kVideoTrackSizeWidth = 8;
82 const int kVideoTrackEntryHeaderSize = 82 const int kVideoTrackEntryHeaderSize =
83 kVideoTrackSizeOffset + kVideoTrackSizeWidth; 83 kVideoTrackSizeOffset + kVideoTrackSizeWidth;
84 84
chcunningham 2016/06/02 21:24:45 Similar test for ffmpeg_demuxer would be good
servolk 2016/06/02 23:53:11 FFmpeg demuxer currently doesn't support mid-strea
85 // Track numbers AKA bytestream track ids. Bytestream track ids might change
86 // within a single playback session if there is only one track of a given type.
85 const int kVideoTrackNum = 1; 87 const int kVideoTrackNum = 1;
86 const int kAudioTrackNum = 2; 88 const int kAudioTrackNum = 2;
87 const int kTextTrackNum = 3; 89 const int kTextTrackNum = 3;
88 const int kAlternateVideoTrackNum = 4; 90 const int kAlternateVideoTrackNum = 4;
89 const int kAlternateAudioTrackNum = 5; 91 const int kAlternateAudioTrackNum = 5;
90 const int kAlternateTextTrackNum = 6; 92 const int kAlternateTextTrackNum = 6;
91 93
94 // These value represent externally assigned track ids (for example track ids
95 // assigned by blink). Not to be confused with bytestream track ids above. The
96 // main difference is that these track ids must stay the same for the duration
97 // of the playback session, whereas track numbers / bytestream track ids might
chcunningham 2016/06/02 21:24:45 I was surprised to read this. Looking at the code
servolk 2016/06/02 23:53:11 That's right. If we encounter a new bytestream tra
chcunningham 2016/06/03 20:42:49 I see. Are we missing some code in SourceBuffer.cp
98 // change in subsequent init segments.
99 const int kVideoTrackId = 10;
chcunningham 2016/06/02 21:24:45 Also, can you name these in a way that describes t
servolk 2016/06/02 23:53:11 Done.
100 const int kAudioTrackId = 11;
101
92 const int kAudioBlockDuration = 23; 102 const int kAudioBlockDuration = 23;
93 const int kVideoBlockDuration = 33; 103 const int kVideoBlockDuration = 33;
94 const int kTextBlockDuration = 100; 104 const int kTextBlockDuration = 100;
95 const int kBlockSize = 10; 105 const int kBlockSize = 10;
96 106
97 const char kSourceId[] = "SourceId"; 107 const char kSourceId[] = "SourceId";
98 const char kDefaultFirstClusterRange[] = "{ [0,46) }"; 108 const char kDefaultFirstClusterRange[] = "{ [0,46) }";
99 const int kDefaultFirstClusterEndTimestamp = 66; 109 const int kDefaultFirstClusterEndTimestamp = 66;
100 const int kDefaultSecondClusterEndTimestamp = 132; 110 const int kDefaultSecondClusterEndTimestamp = 132;
101 111
(...skipping 1294 matching lines...) Expand 10 before | Expand all | Expand 10 after
1396 base::TimeDelta append_window_end_for_next_append_; 1406 base::TimeDelta append_window_end_for_next_append_;
1397 1407
1398 // Map of source id to timestamp offset to use for the next AppendData() 1408 // Map of source id to timestamp offset to use for the next AppendData()
1399 // operation for that source id. 1409 // operation for that source id.
1400 std::map<std::string, base::TimeDelta> timestamp_offset_map_; 1410 std::map<std::string, base::TimeDelta> timestamp_offset_map_;
1401 1411
1402 public: 1412 public:
1403 void InitSegmentReceived(std::unique_ptr<MediaTracks> tracks) { 1413 void InitSegmentReceived(std::unique_ptr<MediaTracks> tracks) {
1404 DCHECK(tracks.get()); 1414 DCHECK(tracks.get());
1405 DCHECK_GT(tracks->tracks().size(), 0u); 1415 DCHECK_GT(tracks->tracks().size(), 0u);
1406 1416
chcunningham 2016/06/02 21:24:45 This is busted for multi-track right? You might as
servolk 2016/06/02 23:53:11 Yes, but there are many other places in Chromium m
1417 std::vector<unsigned> track_ids;
1418 for (const auto& track : tracks->tracks()) {
1419 if (track->type() == MediaTrack::Audio) {
1420 track_ids.push_back(kAudioTrackId);
1421 } else if (track->type() == MediaTrack::Video) {
1422 track_ids.push_back(kVideoTrackId);
1423 } else {
1424 NOTREACHED();
1425 }
1426 }
1427 demuxer_->OnTrackIdsAssigned(*tracks.get(), track_ids);
1428
1407 InitSegmentReceivedMock(tracks); 1429 InitSegmentReceivedMock(tracks);
1408 } 1430 }
1409 1431
1410 private: 1432 private:
1411 DISALLOW_COPY_AND_ASSIGN(ChunkDemuxerTest); 1433 DISALLOW_COPY_AND_ASSIGN(ChunkDemuxerTest);
1412 }; 1434 };
1413 1435
1414 TEST_F(ChunkDemuxerTest, Init) { 1436 TEST_F(ChunkDemuxerTest, Init) {
1415 InSequence s; 1437 InSequence s;
1416 1438
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
1596 // Test with 1 audio and 1 video stream. Send a second init segment in which 1618 // Test with 1 audio and 1 video stream. Send a second init segment in which
1597 // the audio and video track IDs change. Verify that appended buffers before 1619 // the audio and video track IDs change. Verify that appended buffers before
1598 // and after the second init segment map to the same underlying track buffers. 1620 // and after the second init segment map to the same underlying track buffers.
1599 CreateNewDemuxer(); 1621 CreateNewDemuxer();
1600 ASSERT_TRUE( 1622 ASSERT_TRUE(
1601 InitDemuxerWithEncryptionInfo(HAS_AUDIO | HAS_VIDEO, false, false)); 1623 InitDemuxerWithEncryptionInfo(HAS_AUDIO | HAS_VIDEO, false, false));
1602 DemuxerStream* audio_stream = demuxer_->GetStream(DemuxerStream::AUDIO); 1624 DemuxerStream* audio_stream = demuxer_->GetStream(DemuxerStream::AUDIO);
1603 DemuxerStream* video_stream = demuxer_->GetStream(DemuxerStream::VIDEO); 1625 DemuxerStream* video_stream = demuxer_->GetStream(DemuxerStream::VIDEO);
1604 ASSERT_TRUE(audio_stream); 1626 ASSERT_TRUE(audio_stream);
1605 ASSERT_TRUE(video_stream); 1627 ASSERT_TRUE(video_stream);
1628 ASSERT_EQ(audio_stream, demuxer_->GetDemuxerStreamByTrackId(kAudioTrackId));
1629 ASSERT_EQ(video_stream, demuxer_->GetDemuxerStreamByTrackId(kVideoTrackId));
1606 1630
1607 AppendMuxedCluster(MuxedStreamInfo(kAudioTrackNum, "0K 23K", 23), 1631 AppendMuxedCluster(MuxedStreamInfo(kAudioTrackNum, "0K 23K", 23),
1608 MuxedStreamInfo(kVideoTrackNum, "0K 30", 30)); 1632 MuxedStreamInfo(kVideoTrackNum, "0K 30", 30));
1609 CheckExpectedRanges("{ [0,46) }"); 1633 CheckExpectedRanges("{ [0,46) }");
1610 1634
1611 EXPECT_CALL(*this, InitSegmentReceivedMock(_)); 1635 EXPECT_CALL(*this, InitSegmentReceivedMock(_));
1612 AppendInitSegment(HAS_AUDIO | HAS_VIDEO | USE_ALTERNATE_AUDIO_TRACK_ID | 1636 AppendInitSegment(HAS_AUDIO | HAS_VIDEO | USE_ALTERNATE_AUDIO_TRACK_ID |
1613 USE_ALTERNATE_VIDEO_TRACK_ID); 1637 USE_ALTERNATE_VIDEO_TRACK_ID);
1614 AppendMuxedCluster(MuxedStreamInfo(kAlternateAudioTrackNum, "46K 69K", 63), 1638 AppendMuxedCluster(MuxedStreamInfo(kAlternateAudioTrackNum, "46K 69K", 63),
1615 MuxedStreamInfo(kAlternateVideoTrackNum, "60K", 23)); 1639 MuxedStreamInfo(kAlternateVideoTrackNum, "60K", 23));
1616 CheckExpectedRanges("{ [0,92) }"); 1640 CheckExpectedRanges("{ [0,92) }");
1617 CheckExpectedBuffers(audio_stream, "0K 23K 46K 69K"); 1641 CheckExpectedBuffers(audio_stream, "0K 23K 46K 69K");
1618 CheckExpectedBuffers(video_stream, "0K 30 60K"); 1642 CheckExpectedBuffers(video_stream, "0K 30 60K");
1643 ASSERT_EQ(audio_stream, demuxer_->GetDemuxerStreamByTrackId(kAudioTrackId));
1644 ASSERT_EQ(video_stream, demuxer_->GetDemuxerStreamByTrackId(kVideoTrackId));
1619 1645
1620 ShutdownDemuxer(); 1646 ShutdownDemuxer();
1621 } 1647 }
1622 1648
1623 TEST_F(ChunkDemuxerTest, InitSegmentSetsNeedRandomAccessPointFlag) { 1649 TEST_F(ChunkDemuxerTest, InitSegmentSetsNeedRandomAccessPointFlag) {
1624 // Tests that non-key-frames following an init segment are allowed 1650 // Tests that non-key-frames following an init segment are allowed
1625 // and dropped, as expected if the initialization segment received 1651 // and dropped, as expected if the initialization segment received
1626 // algorithm correctly sets the needs random access point flag to true for all 1652 // algorithm correctly sets the needs random access point flag to true for all
1627 // track buffers. Note that the first initialization segment is insufficient 1653 // track buffers. Note that the first initialization segment is insufficient
1628 // to fully test this since needs random access point flag initializes to 1654 // to fully test this since needs random access point flag initializes to
(...skipping 3050 matching lines...) Expand 10 before | Expand all | Expand 10 after
4679 cluster->size() - video_start); 4705 cluster->size() - video_start);
4680 4706
4681 CheckExpectedRanges(DemuxerStream::AUDIO, "{ [30,90) }"); 4707 CheckExpectedRanges(DemuxerStream::AUDIO, "{ [30,90) }");
4682 CheckExpectedRanges(DemuxerStream::VIDEO, "{ [0,91) }"); 4708 CheckExpectedRanges(DemuxerStream::VIDEO, "{ [0,91) }");
4683 CheckExpectedRanges("{ [30,90) }"); 4709 CheckExpectedRanges("{ [30,90) }");
4684 CheckExpectedBuffers(audio_stream, "30K 40K 50K 60K 70K 80K"); 4710 CheckExpectedBuffers(audio_stream, "30K 40K 50K 60K 70K 80K");
4685 CheckExpectedBuffers(video_stream, "71K 81"); 4711 CheckExpectedBuffers(video_stream, "71K 81");
4686 } 4712 }
4687 4713
4688 } // namespace media 4714 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698