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

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

Issue 2343543002: MSE: Replace crossfade splicing overlap trimming. (Closed)
Patch Set: Merge and feedback. Created 4 years, 1 month 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/frame_processor_unittest.cc » ('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 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 init_segment_received_cb_ = base::Bind( 180 init_segment_received_cb_ = base::Bind(
181 &ChunkDemuxerTest::InitSegmentReceived, base::Unretained(this)); 181 &ChunkDemuxerTest::InitSegmentReceived, base::Unretained(this));
182 CreateNewDemuxer(); 182 CreateNewDemuxer();
183 } 183 }
184 184
185 void CreateNewDemuxer() { 185 void CreateNewDemuxer() {
186 base::Closure open_cb = 186 base::Closure open_cb =
187 base::Bind(&ChunkDemuxerTest::DemuxerOpened, base::Unretained(this)); 187 base::Bind(&ChunkDemuxerTest::DemuxerOpened, base::Unretained(this));
188 Demuxer::EncryptedMediaInitDataCB encrypted_media_init_data_cb = base::Bind( 188 Demuxer::EncryptedMediaInitDataCB encrypted_media_init_data_cb = base::Bind(
189 &ChunkDemuxerTest::OnEncryptedMediaInitData, base::Unretained(this)); 189 &ChunkDemuxerTest::OnEncryptedMediaInitData, base::Unretained(this));
190 demuxer_.reset(new ChunkDemuxer(open_cb, encrypted_media_init_data_cb, 190 demuxer_.reset(
191 media_log_, true)); 191 new ChunkDemuxer(open_cb, encrypted_media_init_data_cb, media_log_));
192 } 192 }
193 193
194 virtual ~ChunkDemuxerTest() { 194 virtual ~ChunkDemuxerTest() {
195 ShutdownDemuxer(); 195 ShutdownDemuxer();
196 } 196 }
197 197
198 void CreateInitSegment(int stream_flags, 198 void CreateInitSegment(int stream_flags,
199 bool is_audio_encrypted, 199 bool is_audio_encrypted,
200 bool is_video_encrypted, 200 bool is_video_encrypted,
201 std::unique_ptr<uint8_t[]>* buffer, 201 std::unique_ptr<uint8_t[]>* buffer,
(...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after
863 // Note: Offsets here and below are derived from 863 // Note: Offsets here and below are derived from
864 // media/test/data/bear-640x360-manifest.js and 864 // media/test/data/bear-640x360-manifest.js and
865 // media/test/data/bear-320x240-manifest.js which were 865 // media/test/data/bear-320x240-manifest.js which were
866 // generated from media/test/data/bear-640x360.webm and 866 // generated from media/test/data/bear-640x360.webm and
867 // media/test/data/bear-320x240.webm respectively. 867 // media/test/data/bear-320x240.webm respectively.
868 EXPECT_CALL(*this, InitSegmentReceivedMock(_)); 868 EXPECT_CALL(*this, InitSegmentReceivedMock(_));
869 EXPECT_TRUE(AppendData(bear2->data(), 4340)); 869 EXPECT_TRUE(AppendData(bear2->data(), 4340));
870 870
871 // Append a media segment that goes from [0.527000, 1.014000). 871 // Append a media segment that goes from [0.527000, 1.014000).
872 EXPECT_MEDIA_LOG(WebMSimpleBlockDurationEstimated(2)); 872 EXPECT_MEDIA_LOG(WebMSimpleBlockDurationEstimated(2));
873 EXPECT_MEDIA_LOG(GeneratedSplice(20000, 527000)); 873 EXPECT_MEDIA_LOG(TrimmedSpliceOverlap(527000, 524000, 20000));
874 EXPECT_TRUE(AppendData(bear2->data() + 55290, 18785)); 874 EXPECT_TRUE(AppendData(bear2->data() + 55290, 18785));
875 CheckExpectedRanges("{ [0,1027) [1201,2736) }"); 875 CheckExpectedRanges("{ [0,1027) [1201,2736) }");
876 876
877 // Append initialization segment for bear1 & fill gap with [779-1197) 877 // Append initialization segment for bear1 & fill gap with [779-1197)
878 // segment. 878 // segment.
879 EXPECT_CALL(*this, InitSegmentReceivedMock(_)); 879 EXPECT_CALL(*this, InitSegmentReceivedMock(_));
880 EXPECT_TRUE(AppendData(bear1->data(), 4370)); 880 EXPECT_TRUE(AppendData(bear1->data(), 4370));
881 EXPECT_MEDIA_LOG(WebMSimpleBlockDurationEstimated(23)); 881 EXPECT_MEDIA_LOG(WebMSimpleBlockDurationEstimated(23));
882 EXPECT_MEDIA_LOG(GeneratedSplice(26000, 779000)); 882 EXPECT_MEDIA_LOG(TrimmedSpliceOverlap(779000, 759000, 3000));
883 EXPECT_TRUE(AppendData(bear1->data() + 72737, 28183)); 883 EXPECT_TRUE(AppendData(bear1->data() + 72737, 28183));
884 CheckExpectedRanges("{ [0,2736) }"); 884 CheckExpectedRanges("{ [0,2736) }");
885 885
886 MarkEndOfStream(PIPELINE_OK); 886 MarkEndOfStream(PIPELINE_OK);
887 return true; 887 return true;
888 } 888 }
889 889
890 void ShutdownDemuxer() { 890 void ShutdownDemuxer() {
891 if (demuxer_) { 891 if (demuxer_) {
892 demuxer_->Shutdown(); 892 demuxer_->Shutdown();
(...skipping 835 matching lines...) Expand 10 before | Expand all | Expand 10 after
1728 ReadVideo(base::Bind(&OnReadDone, 1728 ReadVideo(base::Bind(&OnReadDone,
1729 base::TimeDelta::FromMilliseconds(0), 1729 base::TimeDelta::FromMilliseconds(0),
1730 &video_read_done)); 1730 &video_read_done));
1731 1731
1732 EXPECT_TRUE(audio_read_done); 1732 EXPECT_TRUE(audio_read_done);
1733 EXPECT_TRUE(video_read_done); 1733 EXPECT_TRUE(video_read_done);
1734 } 1734 }
1735 1735
1736 TEST_F(ChunkDemuxerTest, OutOfOrderClusters) { 1736 TEST_F(ChunkDemuxerTest, OutOfOrderClusters) {
1737 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); 1737 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO));
1738 DemuxerStream* audio_stream = demuxer_->GetStream(DemuxerStream::AUDIO);
1739 DemuxerStream* video_stream = demuxer_->GetStream(DemuxerStream::VIDEO);
1740
1738 ASSERT_TRUE(AppendCluster(kDefaultFirstCluster())); 1741 ASSERT_TRUE(AppendCluster(kDefaultFirstCluster()));
1739 EXPECT_MEDIA_LOG(GeneratedSplice(13000, 10000)); 1742 CheckExpectedBuffers(audio_stream, "0K 23K");
1743 CheckExpectedBuffers(video_stream, "0K 33");
1744 // Note: splice trimming changes durations. These are verified in lower level
1745 // tests. See SourceBufferStreamTest.Audio_SpliceTrimmingForOverlap.
1746 EXPECT_MEDIA_LOG(TrimmedSpliceOverlap(10000, 0, 13000));
1740 ASSERT_TRUE(AppendCluster(GenerateCluster(10, 4))); 1747 ASSERT_TRUE(AppendCluster(GenerateCluster(10, 4)));
1748 Seek(base::TimeDelta());
1749 CheckExpectedBuffers(audio_stream, "0K 10K 33K");
1750 CheckExpectedBuffers(video_stream, "0K 10K 43");
1741 1751
1742 // Make sure that AppendCluster() does not fail with a cluster that has 1752 // Make sure that AppendCluster() does not fail with a cluster that has
1743 // overlaps with the previously appended cluster. 1753 // overlaps with the previously appended cluster.
1744 EXPECT_MEDIA_LOG(SkippingSpliceAlreadySpliced(0)); 1754 EXPECT_MEDIA_LOG(TrimmedSpliceOverlap(5000, 0, 5000));
1745 ASSERT_TRUE(AppendCluster(GenerateCluster(5, 4))); 1755 ASSERT_TRUE(AppendCluster(GenerateCluster(5, 4)));
1756 Seek(base::TimeDelta());
1757 CheckExpectedBuffers(audio_stream, "0K 5K 28K");
1758 CheckExpectedBuffers(video_stream, "0K 5K 38");
1746 1759
1747 // Verify that AppendData() can still accept more data. 1760 // Verify that AppendData() can still accept more data.
1748 std::unique_ptr<Cluster> cluster_c(GenerateCluster(45, 2)); 1761 std::unique_ptr<Cluster> cluster_c(GenerateCluster(45, 2));
1749 EXPECT_MEDIA_LOG(GeneratedSplice(6000, 45000)); 1762 EXPECT_MEDIA_LOG(TrimmedSpliceOverlap(45000, 28000, 6000));
1750 ASSERT_TRUE(demuxer_->AppendData( 1763 ASSERT_TRUE(demuxer_->AppendData(
1751 kSourceId, cluster_c->data(), cluster_c->size(), 1764 kSourceId, cluster_c->data(), cluster_c->size(),
1752 append_window_start_for_next_append_, append_window_end_for_next_append_, 1765 append_window_start_for_next_append_, append_window_end_for_next_append_,
1753 &timestamp_offset_map_[kSourceId])); 1766 &timestamp_offset_map_[kSourceId]));
1767 Seek(base::TimeDelta::FromMilliseconds(45));
1768 CheckExpectedBuffers(audio_stream, "45K");
1769 CheckExpectedBuffers(video_stream, "45K");
1754 } 1770 }
1755 1771
1756 TEST_F(ChunkDemuxerTest, NonMonotonicButAboveClusterTimecode) { 1772 TEST_F(ChunkDemuxerTest, NonMonotonicButAboveClusterTimecode) {
1757 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); 1773 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO));
1758 ASSERT_TRUE(AppendCluster(kDefaultFirstCluster())); 1774 ASSERT_TRUE(AppendCluster(kDefaultFirstCluster()));
1759 1775
1760 ClusterBuilder cb; 1776 ClusterBuilder cb;
1761 1777
1762 // Test the case where block timecodes are not monotonically 1778 // Test the case where block timecodes are not monotonically
1763 // increasing but stay above the cluster timecode. 1779 // increasing but stay above the cluster timecode.
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
2072 // affect the expected ranges. 2088 // affect the expected ranges.
2073 CheckExpectedRanges("{ [0,66) }"); 2089 CheckExpectedRanges("{ [0,66) }");
2074 2090
2075 // Unmark end of stream state and verify that the ranges return to 2091 // Unmark end of stream state and verify that the ranges return to
2076 // their pre-"end of stream" values. 2092 // their pre-"end of stream" values.
2077 demuxer_->UnmarkEndOfStream(); 2093 demuxer_->UnmarkEndOfStream();
2078 CheckExpectedRanges("{ [0,46) }"); 2094 CheckExpectedRanges("{ [0,46) }");
2079 2095
2080 // Add text track data and verify that the buffered ranges don't change 2096 // Add text track data and verify that the buffered ranges don't change
2081 // since the intersection of all the tracks doesn't change. 2097 // since the intersection of all the tracks doesn't change.
2082 EXPECT_MEDIA_LOG(SkippingSpliceAtOrBefore(0, 0));
2083 EXPECT_CALL(host_, SetDuration(base::TimeDelta::FromMilliseconds(200))); 2098 EXPECT_CALL(host_, SetDuration(base::TimeDelta::FromMilliseconds(200)));
2084 AppendMuxedCluster(MuxedStreamInfo(kVideoTrackNum, "0K 33", 33), 2099 AppendMuxedCluster(MuxedStreamInfo(kVideoTrackNum, "0K 33", 33),
2085 MuxedStreamInfo(kAudioTrackNum, "0K 23K", 23), 2100 MuxedStreamInfo(kAudioTrackNum, "0K 23K", 23),
2086 MuxedStreamInfo(kTextTrackNum, "0K 100K")); 2101 MuxedStreamInfo(kTextTrackNum, "0K 100K"));
2087 CheckExpectedRanges("{ [0,46) }"); 2102 CheckExpectedRanges("{ [0,46) }");
2088 2103
2089 // Mark end of stream and verify that text track data is reflected in 2104 // Mark end of stream and verify that text track data is reflected in
2090 // the new range. 2105 // the new range.
2091 MarkEndOfStream(PIPELINE_OK); 2106 MarkEndOfStream(PIPELINE_OK);
2092 CheckExpectedRanges("{ [0,200) }"); 2107 CheckExpectedRanges("{ [0,200) }");
(...skipping 685 matching lines...) Expand 10 before | Expand all | Expand 10 after
2778 audio_id, GenerateSingleStreamCluster(900, 970, kAudioTrackNum, 70))); 2793 audio_id, GenerateSingleStreamCluster(900, 970, kAudioTrackNum, 70)));
2779 ASSERT_TRUE(AppendCluster( 2794 ASSERT_TRUE(AppendCluster(
2780 video_id, GenerateSingleStreamCluster(920, 950, kVideoTrackNum, 30))); 2795 video_id, GenerateSingleStreamCluster(920, 950, kVideoTrackNum, 30)));
2781 CheckExpectedRanges(DemuxerStream::AUDIO, 2796 CheckExpectedRanges(DemuxerStream::AUDIO,
2782 "{ [0,23) [300,400) [520,590) [720,750) [900,970) }"); 2797 "{ [0,23) [300,400) [520,590) [720,750) [900,970) }");
2783 CheckExpectedRanges(DemuxerStream::VIDEO, 2798 CheckExpectedRanges(DemuxerStream::VIDEO,
2784 "{ [0,33) [320,420) [500,570) [700,770) [920,950) }"); 2799 "{ [0,33) [320,420) [500,570) [700,770) [920,950) }");
2785 CheckExpectedRangesForMediaSource( 2800 CheckExpectedRangesForMediaSource(
2786 "{ [0,23) [320,400) [520,570) [720,750) [920,950) }"); 2801 "{ [0,23) [320,400) [520,570) [720,750) [920,950) }");
2787 2802
2788 // Appending within buffered range should not affect buffered ranges. 2803 // Audio buffered ranges are trimmed from 970 to 950 due to splicing the
2789 EXPECT_MEDIA_LOG(GeneratedSplice(40000, 930000)); 2804 // previously buffered audio frame
2805 // - existing frame trimmed from [900, 970) to [900,930),
2806 // - newly appended audio from [930, 950).
2807 EXPECT_MEDIA_LOG(TrimmedSpliceOverlap(930000, 900000, 40000));
2790 ASSERT_TRUE(AppendCluster( 2808 ASSERT_TRUE(AppendCluster(
2791 audio_id, GenerateSingleStreamCluster(930, 950, kAudioTrackNum, 20))); 2809 audio_id, GenerateSingleStreamCluster(930, 950, kAudioTrackNum, 20)));
2810 CheckExpectedRanges(DemuxerStream::AUDIO,
2811 "{ [0,23) [300,400) [520,590) [720,750) [900,950) }");
2812
2813 // Video buffer range is unchanged by next append. The time and duration of
2814 // the new key frame line up with previous range boundaries.
2792 ASSERT_TRUE(AppendCluster( 2815 ASSERT_TRUE(AppendCluster(
2793 video_id, GenerateSingleStreamCluster(930, 950, kVideoTrackNum, 20))); 2816 video_id, GenerateSingleStreamCluster(930, 950, kVideoTrackNum, 20)));
2794 CheckExpectedRanges(DemuxerStream::AUDIO,
2795 "{ [0,23) [300,400) [520,590) [720,750) [900,970) }");
2796 CheckExpectedRanges(DemuxerStream::VIDEO, 2817 CheckExpectedRanges(DemuxerStream::VIDEO,
2797 "{ [0,33) [320,420) [500,570) [700,770) [920,950) }"); 2818 "{ [0,33) [320,420) [500,570) [700,770) [920,950) }");
2819
2798 CheckExpectedRangesForMediaSource( 2820 CheckExpectedRangesForMediaSource(
2799 "{ [0,23) [320,400) [520,570) [720,750) [920,950) }"); 2821 "{ [0,23) [320,400) [520,570) [720,750) [920,950) }");
2800 } 2822 }
2801 2823
2802 TEST_F(ChunkDemuxerTest, GetBufferedRanges_AudioVideo) { 2824 TEST_F(ChunkDemuxerTest, GetBufferedRanges_AudioVideo) {
2803 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); 2825 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO));
2804 2826
2805 // Audio block: 0 -> 23 2827 // Audio block: 0 -> 23
2806 // Video block: 0 -> 33 2828 // Video block: 0 -> 33
2807 // Buffered Range: 0 -> 23 2829 // Buffered Range: 0 -> 23
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
2859 // 900, so the added buffered range is 900 -> 950 2881 // 900, so the added buffered range is 900 -> 950
2860 AppendMuxedCluster(MuxedStreamInfo(kAudioTrackNum, "900D70K"), 2882 AppendMuxedCluster(MuxedStreamInfo(kAudioTrackNum, "900D70K"),
2861 MuxedStreamInfo(kVideoTrackNum, "920D30K")); 2883 MuxedStreamInfo(kVideoTrackNum, "920D30K"));
2862 2884
2863 CheckExpectedRanges(DemuxerStream::AUDIO, 2885 CheckExpectedRanges(DemuxerStream::AUDIO,
2864 "{ [0,23) [300,400) [500,590) [700,750) [900,970) }"); 2886 "{ [0,23) [300,400) [500,590) [700,750) [900,970) }");
2865 CheckExpectedRanges(DemuxerStream::VIDEO, 2887 CheckExpectedRanges(DemuxerStream::VIDEO,
2866 "{ [0,33) [300,420) [500,570) [700,770) [900,950) }"); 2888 "{ [0,33) [300,420) [500,570) [700,770) [900,950) }");
2867 CheckExpectedRanges("{ [0,23) [300,400) [500,570) [700,750) [900,950) }"); 2889 CheckExpectedRanges("{ [0,23) [300,400) [500,570) [700,750) [900,950) }");
2868 2890
2869 // Appending within buffered range should not affect buffered ranges. 2891 // Appending within existing buffered range.
2870 EXPECT_MEDIA_LOG(GeneratedSplice(40000, 930000)); 2892 EXPECT_MEDIA_LOG(TrimmedSpliceOverlap(930000, 900000, 40000));
2871 AppendMuxedCluster(MuxedStreamInfo(kAudioTrackNum, "930D20K"), 2893 AppendMuxedCluster(MuxedStreamInfo(kAudioTrackNum, "930D20K"),
2872 MuxedStreamInfo(kVideoTrackNum, "930D20K")); 2894 MuxedStreamInfo(kVideoTrackNum, "930D20K"));
2873 CheckExpectedRanges(DemuxerStream::AUDIO, 2895 // Video buffer range is unchanged. The time and duration of the new key frame
2874 "{ [0,23) [300,400) [500,590) [700,750) [900,970) }"); 2896 // line up with previous range boundaries.
2875 CheckExpectedRanges(DemuxerStream::VIDEO, 2897 CheckExpectedRanges(DemuxerStream::VIDEO,
2876 "{ [0,33) [300,420) [500,570) [700,770) [900,950) }"); 2898 "{ [0,33) [300,420) [500,570) [700,770) [900,950) }");
2899
2900 // Audio buffered ranges are trimmed from 970 to 950 due to splicing the
2901 // previously buffered audio frame.
2902 // - existing frame trimmed from [900, 970) to [900, 930),
2903 // - newly appended audio from [930, 950).
2904 CheckExpectedRanges(DemuxerStream::AUDIO,
2905 "{ [0,23) [300,400) [500,590) [700,750) [900,950) }");
2906
2877 CheckExpectedRanges("{ [0,23) [300,400) [500,570) [700,750) [900,950) }"); 2907 CheckExpectedRanges("{ [0,23) [300,400) [500,570) [700,750) [900,950) }");
2878 } 2908 }
2879 2909
2880 TEST_F(ChunkDemuxerTest, GetBufferedRanges_AudioVideoText) { 2910 TEST_F(ChunkDemuxerTest, GetBufferedRanges_AudioVideoText) {
2881 EXPECT_CALL(host_, AddTextStream(_, _)); 2911 EXPECT_CALL(host_, AddTextStream(_, _));
2882 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO | HAS_TEXT)); 2912 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO | HAS_TEXT));
2883 2913
2884 // Append audio & video data 2914 // Append audio & video data
2885 AppendMuxedCluster(MuxedStreamInfo(kAudioTrackNum, "0K 23K", 23), 2915 AppendMuxedCluster(MuxedStreamInfo(kAudioTrackNum, "0K 23K", 23),
2886 MuxedStreamInfo(kVideoTrackNum, "0K 33", 33)); 2916 MuxedStreamInfo(kVideoTrackNum, "0K 33", 33));
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
3202 DemuxerStream* audio = demuxer_->GetStream(DemuxerStream::AUDIO); 3232 DemuxerStream* audio = demuxer_->GetStream(DemuxerStream::AUDIO);
3203 3233
3204 // Fetch initial audio config and verify it matches what we expect. 3234 // Fetch initial audio config and verify it matches what we expect.
3205 const AudioDecoderConfig& audio_config_1 = audio->audio_decoder_config(); 3235 const AudioDecoderConfig& audio_config_1 = audio->audio_decoder_config();
3206 ASSERT_TRUE(audio_config_1.IsValidConfig()); 3236 ASSERT_TRUE(audio_config_1.IsValidConfig());
3207 EXPECT_EQ(audio_config_1.samples_per_second(), 44100); 3237 EXPECT_EQ(audio_config_1.samples_per_second(), 44100);
3208 EXPECT_EQ(audio_config_1.extra_data().size(), 3863u); 3238 EXPECT_EQ(audio_config_1.extra_data().size(), 3863u);
3209 3239
3210 ExpectRead(DemuxerStream::AUDIO, 0); 3240 ExpectRead(DemuxerStream::AUDIO, 0);
3211 3241
3212 // The first config change seen is from a splice frame representing an overlap 3242 // Read until we encounter config 2.
3213 // of buffer from config 1 by buffers from config 2.
3214 ReadUntilNotOkOrEndOfStream(DemuxerStream::AUDIO, &status, &last_timestamp); 3243 ReadUntilNotOkOrEndOfStream(DemuxerStream::AUDIO, &status, &last_timestamp);
3215 ASSERT_EQ(status, DemuxerStream::kConfigChanged); 3244 ASSERT_EQ(status, DemuxerStream::kConfigChanged);
3216 EXPECT_EQ(last_timestamp.InMilliseconds(), 524); 3245 EXPECT_EQ(last_timestamp.InMilliseconds(), 524);
3217 3246
3218 // Fetch the new decoder config. 3247 // Fetch the new decoder config.
3219 const AudioDecoderConfig& audio_config_2 = audio->audio_decoder_config(); 3248 const AudioDecoderConfig& audio_config_2 = audio->audio_decoder_config();
3220 ASSERT_TRUE(audio_config_2.IsValidConfig()); 3249 ASSERT_TRUE(audio_config_2.IsValidConfig());
3221 EXPECT_EQ(audio_config_2.samples_per_second(), 44100); 3250 EXPECT_EQ(audio_config_2.samples_per_second(), 44100);
3222 EXPECT_EQ(audio_config_2.extra_data().size(), 3935u); 3251 EXPECT_EQ(audio_config_2.extra_data().size(), 3935u);
3223 3252
3224 // The next config change is from a splice frame representing an overlap of 3253 // Read until we encounter config 1 again.
3225 // buffers from config 2 by buffers from config 1.
3226 ReadUntilNotOkOrEndOfStream(DemuxerStream::AUDIO, &status, &last_timestamp); 3254 ReadUntilNotOkOrEndOfStream(DemuxerStream::AUDIO, &status, &last_timestamp);
3227 ASSERT_EQ(status, DemuxerStream::kConfigChanged); 3255 ASSERT_EQ(status, DemuxerStream::kConfigChanged);
3228 EXPECT_EQ(last_timestamp.InMilliseconds(), 782); 3256 EXPECT_EQ(last_timestamp.InMilliseconds(), 759);
3229 ASSERT_TRUE(audio_config_1.Matches(audio->audio_decoder_config())); 3257 ASSERT_TRUE(audio_config_1.Matches(audio->audio_decoder_config()));
3230 3258
3231 // Read until the end of the stream just to make sure there aren't any other 3259 // Read until the end of the stream just to make sure there aren't any other
3232 // config changes. 3260 // config changes.
3233 ReadUntilNotOkOrEndOfStream(DemuxerStream::AUDIO, &status, &last_timestamp); 3261 ReadUntilNotOkOrEndOfStream(DemuxerStream::AUDIO, &status, &last_timestamp);
3234 ASSERT_EQ(status, DemuxerStream::kOk); 3262 ASSERT_EQ(status, DemuxerStream::kOk);
3235 EXPECT_EQ(last_timestamp.InMilliseconds(), 2744); 3263 EXPECT_EQ(last_timestamp.InMilliseconds(), 2744);
3236 } 3264 }
3237 3265
3238 TEST_F(ChunkDemuxerTest, ConfigChange_Seek) { 3266 TEST_F(ChunkDemuxerTest, ConfigChange_Seek) {
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
3524 true, true, true, true, false, 3552 true, true, true, true, false,
3525 }; 3553 };
3526 3554
3527 static_assert(arraysize(kBuffer) == arraysize(kExpectedReturnValues), 3555 static_assert(arraysize(kBuffer) == arraysize(kExpectedReturnValues),
3528 "test arrays out of sync"); 3556 "test arrays out of sync");
3529 static_assert(arraysize(kBuffer) == sizeof(kBuffer), 3557 static_assert(arraysize(kBuffer) == sizeof(kBuffer),
3530 "there should be one byte per index"); 3558 "there should be one byte per index");
3531 3559
3532 ASSERT_TRUE(InitDemuxer(HAS_AUDIO)); 3560 ASSERT_TRUE(InitDemuxer(HAS_AUDIO));
3533 EXPECT_MEDIA_LOG(WebMSimpleBlockDurationEstimated(23)).Times(2); 3561 EXPECT_MEDIA_LOG(WebMSimpleBlockDurationEstimated(23)).Times(2);
3534 EXPECT_MEDIA_LOG(GeneratedSplice(22000, 2000)); 3562 EXPECT_MEDIA_LOG(TrimmedSpliceOverlap(2000, 1000, 22000));
3535 for (size_t i = 0; i < sizeof(kBuffer); i++) { 3563 for (size_t i = 0; i < sizeof(kBuffer); i++) {
3536 DVLOG(3) << "Appending and testing index " << i; 3564 DVLOG(3) << "Appending and testing index " << i;
3537 ASSERT_TRUE(AppendData(kBuffer + i, 1)); 3565 ASSERT_TRUE(AppendData(kBuffer + i, 1));
3538 bool expected_return_value = kExpectedReturnValues[i]; 3566 bool expected_return_value = kExpectedReturnValues[i];
3539 EXPECT_EQ(expected_return_value, 3567 EXPECT_EQ(expected_return_value,
3540 demuxer_->IsParsingMediaSegment(kSourceId)); 3568 demuxer_->IsParsingMediaSegment(kSourceId));
3541 } 3569 }
3542 } 3570 }
3543 3571
3544 TEST_F(ChunkDemuxerTest, DurationChange) { 3572 TEST_F(ChunkDemuxerTest, DurationChange) {
(...skipping 1167 matching lines...) Expand 10 before | Expand all | Expand 10 after
4712 demuxer_->RemoveId(kId1); 4740 demuxer_->RemoveId(kId1);
4713 EXPECT_EQ(nullptr, demuxer_->GetStream(DemuxerStream::AUDIO)); 4741 EXPECT_EQ(nullptr, demuxer_->GetStream(DemuxerStream::AUDIO));
4714 EXPECT_EQ(nullptr, demuxer_->GetStream(DemuxerStream::VIDEO)); 4742 EXPECT_EQ(nullptr, demuxer_->GetStream(DemuxerStream::VIDEO));
4715 } 4743 }
4716 4744
4717 // TODO(servolk): Add a unit test with multiple audio/video tracks using the 4745 // TODO(servolk): Add a unit test with multiple audio/video tracks using the
4718 // same codec type in a single SourceBufferState, when WebM parser supports 4746 // same codec type in a single SourceBufferState, when WebM parser supports
4719 // multiple tracks. crbug.com/646900 4747 // multiple tracks. crbug.com/646900
4720 4748
4721 } // namespace media 4749 } // namespace media
OLDNEW
« no previous file with comments | « media/filters/chunk_demuxer.cc ('k') | media/filters/frame_processor_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698