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

Side by Side Diff: media/filters/chunk_demuxer_unittest.cc

Issue 1894073002: Revert of Allow muting/unmuting audio through media track API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@blink-sb-tracks6
Patch Set: Rebased Created 4 years, 8 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
« no previous file with comments | « media/filters/chunk_demuxer.cc ('k') | media/filters/ffmpeg_demuxer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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.
87 const int kVideoTrackNum = 1; 85 const int kVideoTrackNum = 1;
88 const int kAudioTrackNum = 2; 86 const int kAudioTrackNum = 2;
89 const int kTextTrackNum = 3; 87 const int kTextTrackNum = 3;
90 const int kAlternateVideoTrackNum = 4; 88 const int kAlternateVideoTrackNum = 4;
91 const int kAlternateAudioTrackNum = 5; 89 const int kAlternateAudioTrackNum = 5;
92 const int kAlternateTextTrackNum = 6; 90 const int kAlternateTextTrackNum = 6;
93 91
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
98 // change in subsequent init segments.
99 const int kVideoTrackId = 10;
100 const int kAudioTrackId = 11;
101
102 const int kAudioBlockDuration = 23; 92 const int kAudioBlockDuration = 23;
103 const int kVideoBlockDuration = 33; 93 const int kVideoBlockDuration = 33;
104 const int kTextBlockDuration = 100; 94 const int kTextBlockDuration = 100;
105 const int kBlockSize = 10; 95 const int kBlockSize = 10;
106 96
107 const char kSourceId[] = "SourceId"; 97 const char kSourceId[] = "SourceId";
108 const char kDefaultFirstClusterRange[] = "{ [0,46) }"; 98 const char kDefaultFirstClusterRange[] = "{ [0,46) }";
109 const int kDefaultFirstClusterEndTimestamp = 66; 99 const int kDefaultFirstClusterEndTimestamp = 66;
110 const int kDefaultSecondClusterEndTimestamp = 132; 100 const int kDefaultSecondClusterEndTimestamp = 132;
111 101
(...skipping 1291 matching lines...) Expand 10 before | Expand all | Expand 10 after
1403 1393
1404 // Map of source id to timestamp offset to use for the next AppendData() 1394 // Map of source id to timestamp offset to use for the next AppendData()
1405 // operation for that source id. 1395 // operation for that source id.
1406 std::map<std::string, base::TimeDelta> timestamp_offset_map_; 1396 std::map<std::string, base::TimeDelta> timestamp_offset_map_;
1407 1397
1408 public: 1398 public:
1409 void InitSegmentReceived(scoped_ptr<MediaTracks> tracks) { 1399 void InitSegmentReceived(scoped_ptr<MediaTracks> tracks) {
1410 DCHECK(tracks.get()); 1400 DCHECK(tracks.get());
1411 DCHECK_GT(tracks->tracks().size(), 0u); 1401 DCHECK_GT(tracks->tracks().size(), 0u);
1412 1402
1413 std::vector<unsigned> track_ids;
1414 for (const auto& track : tracks->tracks()) {
1415 if (track->type() == MediaTrack::Audio) {
1416 track_ids.push_back(kAudioTrackId);
1417 } else if (track->type() == MediaTrack::Video) {
1418 track_ids.push_back(kVideoTrackId);
1419 } else {
1420 NOTREACHED();
1421 }
1422 }
1423 demuxer_->OnTrackIdsAssigned(*tracks.get(), track_ids);
1424
1425 InitSegmentReceivedMock(tracks); 1403 InitSegmentReceivedMock(tracks);
1426 } 1404 }
1427 1405
1428 private: 1406 private:
1429 DISALLOW_COPY_AND_ASSIGN(ChunkDemuxerTest); 1407 DISALLOW_COPY_AND_ASSIGN(ChunkDemuxerTest);
1430 }; 1408 };
1431 1409
1432 TEST_F(ChunkDemuxerTest, Init) { 1410 TEST_F(ChunkDemuxerTest, Init) {
1433 InSequence s; 1411 InSequence s;
1434 1412
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
1614 // Test with 1 audio and 1 video stream. Send a second init segment in which 1592 // Test with 1 audio and 1 video stream. Send a second init segment in which
1615 // the audio and video track IDs change. Verify that appended buffers before 1593 // the audio and video track IDs change. Verify that appended buffers before
1616 // and after the second init segment map to the same underlying track buffers. 1594 // and after the second init segment map to the same underlying track buffers.
1617 CreateNewDemuxer(); 1595 CreateNewDemuxer();
1618 ASSERT_TRUE( 1596 ASSERT_TRUE(
1619 InitDemuxerWithEncryptionInfo(HAS_AUDIO | HAS_VIDEO, false, false)); 1597 InitDemuxerWithEncryptionInfo(HAS_AUDIO | HAS_VIDEO, false, false));
1620 DemuxerStream* audio_stream = demuxer_->GetStream(DemuxerStream::AUDIO); 1598 DemuxerStream* audio_stream = demuxer_->GetStream(DemuxerStream::AUDIO);
1621 DemuxerStream* video_stream = demuxer_->GetStream(DemuxerStream::VIDEO); 1599 DemuxerStream* video_stream = demuxer_->GetStream(DemuxerStream::VIDEO);
1622 ASSERT_TRUE(audio_stream); 1600 ASSERT_TRUE(audio_stream);
1623 ASSERT_TRUE(video_stream); 1601 ASSERT_TRUE(video_stream);
1624 ASSERT_EQ(audio_stream, demuxer_->GetDemuxerStreamByTrackId(kAudioTrackId));
1625 ASSERT_EQ(video_stream, demuxer_->GetDemuxerStreamByTrackId(kVideoTrackId));
1626 1602
1627 AppendMuxedCluster(MuxedStreamInfo(kAudioTrackNum, "0K 23K", 23), 1603 AppendMuxedCluster(MuxedStreamInfo(kAudioTrackNum, "0K 23K", 23),
1628 MuxedStreamInfo(kVideoTrackNum, "0K 30", 30)); 1604 MuxedStreamInfo(kVideoTrackNum, "0K 30", 30));
1629 CheckExpectedRanges("{ [0,46) }"); 1605 CheckExpectedRanges("{ [0,46) }");
1630 1606
1631 EXPECT_CALL(*this, InitSegmentReceivedMock(_)); 1607 EXPECT_CALL(*this, InitSegmentReceivedMock(_));
1632 AppendInitSegment(HAS_AUDIO | HAS_VIDEO | USE_ALTERNATE_AUDIO_TRACK_ID | 1608 AppendInitSegment(HAS_AUDIO | HAS_VIDEO | USE_ALTERNATE_AUDIO_TRACK_ID |
1633 USE_ALTERNATE_VIDEO_TRACK_ID); 1609 USE_ALTERNATE_VIDEO_TRACK_ID);
1634 AppendMuxedCluster(MuxedStreamInfo(kAlternateAudioTrackNum, "46K 69K", 63), 1610 AppendMuxedCluster(MuxedStreamInfo(kAlternateAudioTrackNum, "46K 69K", 63),
1635 MuxedStreamInfo(kAlternateVideoTrackNum, "60K", 23)); 1611 MuxedStreamInfo(kAlternateVideoTrackNum, "60K", 23));
1636 CheckExpectedRanges("{ [0,92) }"); 1612 CheckExpectedRanges("{ [0,92) }");
1637 CheckExpectedBuffers(audio_stream, "0K 23K 46K 69K"); 1613 CheckExpectedBuffers(audio_stream, "0K 23K 46K 69K");
1638 CheckExpectedBuffers(video_stream, "0K 30 60K"); 1614 CheckExpectedBuffers(video_stream, "0K 30 60K");
1639 ASSERT_EQ(audio_stream, demuxer_->GetDemuxerStreamByTrackId(kAudioTrackId));
1640 ASSERT_EQ(video_stream, demuxer_->GetDemuxerStreamByTrackId(kVideoTrackId));
1641 1615
1642 ShutdownDemuxer(); 1616 ShutdownDemuxer();
1643 } 1617 }
1644 1618
1645 TEST_F(ChunkDemuxerTest, InitSegmentSetsNeedRandomAccessPointFlag) { 1619 TEST_F(ChunkDemuxerTest, InitSegmentSetsNeedRandomAccessPointFlag) {
1646 // Tests that non-key-frames following an init segment are allowed 1620 // Tests that non-key-frames following an init segment are allowed
1647 // and dropped, as expected if the initialization segment received 1621 // and dropped, as expected if the initialization segment received
1648 // algorithm correctly sets the needs random access point flag to true for all 1622 // algorithm correctly sets the needs random access point flag to true for all
1649 // track buffers. Note that the first initialization segment is insufficient 1623 // track buffers. Note that the first initialization segment is insufficient
1650 // to fully test this since needs random access point flag initializes to 1624 // to fully test this since needs random access point flag initializes to
(...skipping 3050 matching lines...) Expand 10 before | Expand all | Expand 10 after
4701 cluster->size() - video_start); 4675 cluster->size() - video_start);
4702 4676
4703 CheckExpectedRanges(DemuxerStream::AUDIO, "{ [30,90) }"); 4677 CheckExpectedRanges(DemuxerStream::AUDIO, "{ [30,90) }");
4704 CheckExpectedRanges(DemuxerStream::VIDEO, "{ [0,91) }"); 4678 CheckExpectedRanges(DemuxerStream::VIDEO, "{ [0,91) }");
4705 CheckExpectedRanges("{ [30,90) }"); 4679 CheckExpectedRanges("{ [30,90) }");
4706 CheckExpectedBuffers(audio_stream, "30K 40K 50K 60K 70K 80K"); 4680 CheckExpectedBuffers(audio_stream, "30K 40K 50K 60K 70K 80K");
4707 CheckExpectedBuffers(video_stream, "71K 81"); 4681 CheckExpectedBuffers(video_stream, "71K 81");
4708 } 4682 }
4709 4683
4710 } // namespace media 4684 } // namespace media
OLDNEW
« no previous file with comments | « media/filters/chunk_demuxer.cc ('k') | media/filters/ffmpeg_demuxer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698