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

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

Issue 2343543002: MSE: Replace crossfade splicing overlap trimming. (Closed)
Patch Set: Created 4 years, 3 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 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 arg, "Initialization segment " + 158 arg, "Initialization segment " +
159 std::string(mime_missing_track_type_bool ? "has " 159 std::string(mime_missing_track_type_bool ? "has "
160 : "does not have ") + 160 : "does not have ") +
161 std::string(track_type_string_with_article) + 161 std::string(track_type_string_with_article) +
162 " track, but the mimetype " + 162 " track, but the mimetype " +
163 std::string(mime_missing_track_type_bool ? "does not specify " 163 std::string(mime_missing_track_type_bool ? "does not specify "
164 : "specifies ") + 164 : "specifies ") +
165 std::string(track_type_string_with_article) + " codec."); 165 std::string(track_type_string_with_article) + " codec.");
166 } 166 }
167 167
168 MATCHER_P2(GeneratedSplice, duration_microseconds, time_microseconds, "") { 168 MATCHER_P2(GeneratedSplice, splice_time_mu, overlapped_start_mu, "") {
169 return CONTAINS_STRING(arg, "Generated splice of overlap duration " + 169 int silence_duration = splice_time_mu - overlapped_start_mu;
170 base::IntToString(duration_microseconds) + 170 return CONTAINS_STRING(arg,
171 "us into new buffer at " + 171 "Generated splice for overlapping audio buffer"
172 base::IntToString(time_microseconds) + "us."); 172 " at time:" +
173 } 173 base::IntToString(splice_time_mu) +
174 174 "mu. Adding silence of length:" +
wolenetz 2016/09/15 23:47:52 s/mu/us/
chcunningham 2016/09/16 20:42:44 Done.
175 MATCHER_P2(SkippingSpliceAtOrBefore, 175 base::IntToString(silence_duration) +
176 new_microseconds, 176 "mu to replace overlapped buffer at time:" +
177 existing_microseconds, 177 base::IntToString(overlapped_start_mu) + "mu.");
178 "") {
179 return CONTAINS_STRING(
180 arg, "Skipping splice frame generation: first new buffer at " +
181 base::IntToString(new_microseconds) +
182 "us begins at or before existing buffer at " +
183 base::IntToString(existing_microseconds) + "us.");
184 }
185
186 MATCHER_P(SkippingSpliceAlreadySpliced, time_microseconds, "") {
187 return CONTAINS_STRING(
188 arg, "Skipping splice frame generation: overlapped buffers at " +
189 base::IntToString(time_microseconds) +
190 "us are in a previously buffered splice.");
191 } 178 }
192 179
193 MATCHER_P(WebMSimpleBlockDurationEstimated, estimated_duration_ms, "") { 180 MATCHER_P(WebMSimpleBlockDurationEstimated, estimated_duration_ms, "") {
194 return CONTAINS_STRING(arg, "Estimating WebM block duration to be " + 181 return CONTAINS_STRING(arg, "Estimating WebM block duration to be " +
195 base::IntToString(estimated_duration_ms) + 182 base::IntToString(estimated_duration_ms) +
196 "ms for the last (Simple)Block in the " 183 "ms for the last (Simple)Block in the "
197 "Cluster for this Track. Use BlockGroups " 184 "Cluster for this Track. Use BlockGroups "
198 "with BlockDurations at the end of each " 185 "with BlockDurations at the end of each "
199 "Track in a Cluster to avoid estimation."); 186 "Track in a Cluster to avoid estimation.");
200 } 187 }
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 init_segment_received_cb_ = base::Bind( 258 init_segment_received_cb_ = base::Bind(
272 &ChunkDemuxerTest::InitSegmentReceived, base::Unretained(this)); 259 &ChunkDemuxerTest::InitSegmentReceived, base::Unretained(this));
273 CreateNewDemuxer(); 260 CreateNewDemuxer();
274 } 261 }
275 262
276 void CreateNewDemuxer() { 263 void CreateNewDemuxer() {
277 base::Closure open_cb = 264 base::Closure open_cb =
278 base::Bind(&ChunkDemuxerTest::DemuxerOpened, base::Unretained(this)); 265 base::Bind(&ChunkDemuxerTest::DemuxerOpened, base::Unretained(this));
279 Demuxer::EncryptedMediaInitDataCB encrypted_media_init_data_cb = base::Bind( 266 Demuxer::EncryptedMediaInitDataCB encrypted_media_init_data_cb = base::Bind(
280 &ChunkDemuxerTest::OnEncryptedMediaInitData, base::Unretained(this)); 267 &ChunkDemuxerTest::OnEncryptedMediaInitData, base::Unretained(this));
281 demuxer_.reset(new ChunkDemuxer(open_cb, encrypted_media_init_data_cb, 268 demuxer_.reset(
282 media_log_, true)); 269 new ChunkDemuxer(open_cb, encrypted_media_init_data_cb, media_log_));
283 } 270 }
284 271
285 virtual ~ChunkDemuxerTest() { 272 virtual ~ChunkDemuxerTest() {
286 ShutdownDemuxer(); 273 ShutdownDemuxer();
287 } 274 }
288 275
289 void CreateInitSegment(int stream_flags, 276 void CreateInitSegment(int stream_flags,
290 bool is_audio_encrypted, 277 bool is_audio_encrypted,
291 bool is_video_encrypted, 278 bool is_video_encrypted,
292 std::unique_ptr<uint8_t[]>* buffer, 279 std::unique_ptr<uint8_t[]>* buffer,
(...skipping 672 matching lines...) Expand 10 before | Expand all | Expand 10 after
965 // Note: Offsets here and below are derived from 952 // Note: Offsets here and below are derived from
966 // media/test/data/bear-640x360-manifest.js and 953 // media/test/data/bear-640x360-manifest.js and
967 // media/test/data/bear-320x240-manifest.js which were 954 // media/test/data/bear-320x240-manifest.js which were
968 // generated from media/test/data/bear-640x360.webm and 955 // generated from media/test/data/bear-640x360.webm and
969 // media/test/data/bear-320x240.webm respectively. 956 // media/test/data/bear-320x240.webm respectively.
970 EXPECT_CALL(*this, InitSegmentReceivedMock(_)); 957 EXPECT_CALL(*this, InitSegmentReceivedMock(_));
971 EXPECT_TRUE(AppendData(bear2->data(), 4340)); 958 EXPECT_TRUE(AppendData(bear2->data(), 4340));
972 959
973 // Append a media segment that goes from [0.527000, 1.014000). 960 // Append a media segment that goes from [0.527000, 1.014000).
974 EXPECT_MEDIA_LOG(WebMSimpleBlockDurationEstimated(2)); 961 EXPECT_MEDIA_LOG(WebMSimpleBlockDurationEstimated(2));
975 EXPECT_MEDIA_LOG(GeneratedSplice(20000, 527000)); 962 EXPECT_MEDIA_LOG(GeneratedSplice(527000, 524000));
976 EXPECT_TRUE(AppendData(bear2->data() + 55290, 18785)); 963 EXPECT_TRUE(AppendData(bear2->data() + 55290, 18785));
977 CheckExpectedRanges("{ [0,1027) [1201,2736) }"); 964 CheckExpectedRanges("{ [0,1027) [1201,2736) }");
978 965
979 // Append initialization segment for bear1 & fill gap with [779-1197) 966 // Append initialization segment for bear1 & fill gap with [779-1197)
980 // segment. 967 // segment.
981 EXPECT_CALL(*this, InitSegmentReceivedMock(_)); 968 EXPECT_CALL(*this, InitSegmentReceivedMock(_));
982 EXPECT_TRUE(AppendData(bear1->data(), 4370)); 969 EXPECT_TRUE(AppendData(bear1->data(), 4370));
983 EXPECT_MEDIA_LOG(WebMSimpleBlockDurationEstimated(23)); 970 EXPECT_MEDIA_LOG(WebMSimpleBlockDurationEstimated(23));
984 EXPECT_MEDIA_LOG(GeneratedSplice(26000, 779000)); 971 EXPECT_MEDIA_LOG(GeneratedSplice(779000, 759000));
985 EXPECT_TRUE(AppendData(bear1->data() + 72737, 28183)); 972 EXPECT_TRUE(AppendData(bear1->data() + 72737, 28183));
986 CheckExpectedRanges("{ [0,2736) }"); 973 CheckExpectedRanges("{ [0,2736) }");
987 974
988 MarkEndOfStream(PIPELINE_OK); 975 MarkEndOfStream(PIPELINE_OK);
989 return true; 976 return true;
990 } 977 }
991 978
992 void ShutdownDemuxer() { 979 void ShutdownDemuxer() {
993 if (demuxer_) { 980 if (demuxer_) {
994 demuxer_->Shutdown(); 981 demuxer_->Shutdown();
(...skipping 838 matching lines...) Expand 10 before | Expand all | Expand 10 after
1833 base::TimeDelta::FromMilliseconds(0), 1820 base::TimeDelta::FromMilliseconds(0),
1834 &video_read_done)); 1821 &video_read_done));
1835 1822
1836 EXPECT_TRUE(audio_read_done); 1823 EXPECT_TRUE(audio_read_done);
1837 EXPECT_TRUE(video_read_done); 1824 EXPECT_TRUE(video_read_done);
1838 } 1825 }
1839 1826
1840 TEST_F(ChunkDemuxerTest, OutOfOrderClusters) { 1827 TEST_F(ChunkDemuxerTest, OutOfOrderClusters) {
1841 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); 1828 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO));
1842 ASSERT_TRUE(AppendCluster(kDefaultFirstCluster())); 1829 ASSERT_TRUE(AppendCluster(kDefaultFirstCluster()));
1843 EXPECT_MEDIA_LOG(GeneratedSplice(13000, 10000)); 1830 EXPECT_MEDIA_LOG(GeneratedSplice(10000, 0));
1844 ASSERT_TRUE(AppendCluster(GenerateCluster(10, 4))); 1831 ASSERT_TRUE(AppendCluster(GenerateCluster(10, 4)));
1845 1832
1846 // Make sure that AppendCluster() does not fail with a cluster that has 1833 // Make sure that AppendCluster() does not fail with a cluster that has
1847 // overlaps with the previously appended cluster. 1834 // overlaps with the previously appended cluster.
1848 EXPECT_MEDIA_LOG(SkippingSpliceAlreadySpliced(0)); 1835 EXPECT_MEDIA_LOG(GeneratedSplice(5000, 0));
1849 ASSERT_TRUE(AppendCluster(GenerateCluster(5, 4))); 1836 ASSERT_TRUE(AppendCluster(GenerateCluster(5, 4)));
1850 1837
1851 // Verify that AppendData() can still accept more data. 1838 // Verify that AppendData() can still accept more data.
1839 EXPECT_MEDIA_LOG(GeneratedSplice(45000, 28000));
1852 std::unique_ptr<Cluster> cluster_c(GenerateCluster(45, 2)); 1840 std::unique_ptr<Cluster> cluster_c(GenerateCluster(45, 2));
1853 EXPECT_MEDIA_LOG(GeneratedSplice(6000, 45000));
1854 ASSERT_TRUE(demuxer_->AppendData( 1841 ASSERT_TRUE(demuxer_->AppendData(
1855 kSourceId, cluster_c->data(), cluster_c->size(), 1842 kSourceId, cluster_c->data(), cluster_c->size(),
1856 append_window_start_for_next_append_, append_window_end_for_next_append_, 1843 append_window_start_for_next_append_, append_window_end_for_next_append_,
1857 &timestamp_offset_map_[kSourceId])); 1844 &timestamp_offset_map_[kSourceId]));
1858 } 1845 }
1859 1846
1860 TEST_F(ChunkDemuxerTest, NonMonotonicButAboveClusterTimecode) { 1847 TEST_F(ChunkDemuxerTest, NonMonotonicButAboveClusterTimecode) {
1861 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); 1848 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO));
1862 ASSERT_TRUE(AppendCluster(kDefaultFirstCluster())); 1849 ASSERT_TRUE(AppendCluster(kDefaultFirstCluster()));
1863 1850
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
2176 // affect the expected ranges. 2163 // affect the expected ranges.
2177 CheckExpectedRanges("{ [0,66) }"); 2164 CheckExpectedRanges("{ [0,66) }");
2178 2165
2179 // Unmark end of stream state and verify that the ranges return to 2166 // Unmark end of stream state and verify that the ranges return to
2180 // their pre-"end of stream" values. 2167 // their pre-"end of stream" values.
2181 demuxer_->UnmarkEndOfStream(); 2168 demuxer_->UnmarkEndOfStream();
2182 CheckExpectedRanges("{ [0,46) }"); 2169 CheckExpectedRanges("{ [0,46) }");
2183 2170
2184 // Add text track data and verify that the buffered ranges don't change 2171 // Add text track data and verify that the buffered ranges don't change
2185 // since the intersection of all the tracks doesn't change. 2172 // since the intersection of all the tracks doesn't change.
2186 EXPECT_MEDIA_LOG(SkippingSpliceAtOrBefore(0, 0));
2187 EXPECT_CALL(host_, SetDuration(base::TimeDelta::FromMilliseconds(200))); 2173 EXPECT_CALL(host_, SetDuration(base::TimeDelta::FromMilliseconds(200)));
2188 AppendMuxedCluster(MuxedStreamInfo(kVideoTrackNum, "0K 33", 33), 2174 AppendMuxedCluster(MuxedStreamInfo(kVideoTrackNum, "0K 33", 33),
2189 MuxedStreamInfo(kAudioTrackNum, "0K 23K", 23), 2175 MuxedStreamInfo(kAudioTrackNum, "0K 23K", 23),
2190 MuxedStreamInfo(kTextTrackNum, "0K 100K")); 2176 MuxedStreamInfo(kTextTrackNum, "0K 100K"));
2191 CheckExpectedRanges("{ [0,46) }"); 2177 CheckExpectedRanges("{ [0,46) }");
2192 2178
2193 // Mark end of stream and verify that text track data is reflected in 2179 // Mark end of stream and verify that text track data is reflected in
2194 // the new range. 2180 // the new range.
2195 MarkEndOfStream(PIPELINE_OK); 2181 MarkEndOfStream(PIPELINE_OK);
2196 CheckExpectedRanges("{ [0,200) }"); 2182 CheckExpectedRanges("{ [0,200) }");
(...skipping 689 matching lines...) Expand 10 before | Expand all | Expand 10 after
2886 audio_id, GenerateSingleStreamCluster(900, 970, kAudioTrackNum, 70))); 2872 audio_id, GenerateSingleStreamCluster(900, 970, kAudioTrackNum, 70)));
2887 ASSERT_TRUE(AppendCluster( 2873 ASSERT_TRUE(AppendCluster(
2888 video_id, GenerateSingleStreamCluster(920, 950, kVideoTrackNum, 30))); 2874 video_id, GenerateSingleStreamCluster(920, 950, kVideoTrackNum, 30)));
2889 CheckExpectedRanges(DemuxerStream::AUDIO, 2875 CheckExpectedRanges(DemuxerStream::AUDIO,
2890 "{ [0,23) [300,400) [520,590) [720,750) [900,970) }"); 2876 "{ [0,23) [300,400) [520,590) [720,750) [900,970) }");
2891 CheckExpectedRanges(DemuxerStream::VIDEO, 2877 CheckExpectedRanges(DemuxerStream::VIDEO,
2892 "{ [0,33) [320,420) [500,570) [700,770) [920,950) }"); 2878 "{ [0,33) [320,420) [500,570) [700,770) [920,950) }");
2893 CheckExpectedRangesForMediaSource( 2879 CheckExpectedRangesForMediaSource(
2894 "{ [0,23) [320,400) [520,570) [720,750) [920,950) }"); 2880 "{ [0,23) [320,400) [520,570) [720,750) [920,950) }");
2895 2881
2896 // Appending within buffered range should not affect buffered ranges. 2882 // Audio buffered ranges are trimmed from 970 to 950 due to splicing the
2897 EXPECT_MEDIA_LOG(GeneratedSplice(40000, 930000)); 2883 // previously buffered audio frame (now silence from [900-930), newly
2884 // appended audio from [930, 950)
2885 EXPECT_MEDIA_LOG(GeneratedSplice(930000, 900000));
2898 ASSERT_TRUE(AppendCluster( 2886 ASSERT_TRUE(AppendCluster(
2899 audio_id, GenerateSingleStreamCluster(930, 950, kAudioTrackNum, 20))); 2887 audio_id, GenerateSingleStreamCluster(930, 950, kAudioTrackNum, 20)));
2888 CheckExpectedRanges(DemuxerStream::AUDIO,
2889 "{ [0,23) [300,400) [520,590) [720,750) [900,950) }");
2890
2891 // Appending within buffered range should not affect video buffered ranges.
2900 ASSERT_TRUE(AppendCluster( 2892 ASSERT_TRUE(AppendCluster(
2901 video_id, GenerateSingleStreamCluster(930, 950, kVideoTrackNum, 20))); 2893 video_id, GenerateSingleStreamCluster(930, 950, kVideoTrackNum, 20)));
2902 CheckExpectedRanges(DemuxerStream::AUDIO,
2903 "{ [0,23) [300,400) [520,590) [720,750) [900,970) }");
2904 CheckExpectedRanges(DemuxerStream::VIDEO, 2894 CheckExpectedRanges(DemuxerStream::VIDEO,
2905 "{ [0,33) [320,420) [500,570) [700,770) [920,950) }"); 2895 "{ [0,33) [320,420) [500,570) [700,770) [920,950) }");
2896
2906 CheckExpectedRangesForMediaSource( 2897 CheckExpectedRangesForMediaSource(
2907 "{ [0,23) [320,400) [520,570) [720,750) [920,950) }"); 2898 "{ [0,23) [320,400) [520,570) [720,750) [920,950) }");
2908 } 2899 }
2909 2900
2910 TEST_F(ChunkDemuxerTest, GetBufferedRanges_AudioVideo) { 2901 TEST_F(ChunkDemuxerTest, GetBufferedRanges_AudioVideo) {
2911 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); 2902 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO));
2912 2903
2913 // Audio block: 0 -> 23 2904 // Audio block: 0 -> 23
2914 // Video block: 0 -> 33 2905 // Video block: 0 -> 33
2915 // Buffered Range: 0 -> 23 2906 // Buffered Range: 0 -> 23
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
2967 // 900, so the added buffered range is 900 -> 950 2958 // 900, so the added buffered range is 900 -> 950
2968 AppendMuxedCluster(MuxedStreamInfo(kAudioTrackNum, "900D70K"), 2959 AppendMuxedCluster(MuxedStreamInfo(kAudioTrackNum, "900D70K"),
2969 MuxedStreamInfo(kVideoTrackNum, "920D30K")); 2960 MuxedStreamInfo(kVideoTrackNum, "920D30K"));
2970 2961
2971 CheckExpectedRanges(DemuxerStream::AUDIO, 2962 CheckExpectedRanges(DemuxerStream::AUDIO,
2972 "{ [0,23) [300,400) [500,590) [700,750) [900,970) }"); 2963 "{ [0,23) [300,400) [500,590) [700,750) [900,970) }");
2973 CheckExpectedRanges(DemuxerStream::VIDEO, 2964 CheckExpectedRanges(DemuxerStream::VIDEO,
2974 "{ [0,33) [300,420) [500,570) [700,770) [900,950) }"); 2965 "{ [0,33) [300,420) [500,570) [700,770) [900,950) }");
2975 CheckExpectedRanges("{ [0,23) [300,400) [500,570) [700,750) [900,950) }"); 2966 CheckExpectedRanges("{ [0,23) [300,400) [500,570) [700,750) [900,950) }");
2976 2967
2977 // Appending within buffered range should not affect buffered ranges. 2968 // Appending within buffered range should not affect video buffered ranges.
2978 EXPECT_MEDIA_LOG(GeneratedSplice(40000, 930000)); 2969 EXPECT_MEDIA_LOG(GeneratedSplice(930000, 900000));
2979 AppendMuxedCluster(MuxedStreamInfo(kAudioTrackNum, "930D20K"), 2970 AppendMuxedCluster(MuxedStreamInfo(kAudioTrackNum, "930D20K"),
2980 MuxedStreamInfo(kVideoTrackNum, "930D20K")); 2971 MuxedStreamInfo(kVideoTrackNum, "930D20K"));
2981 CheckExpectedRanges(DemuxerStream::AUDIO,
2982 "{ [0,23) [300,400) [500,590) [700,750) [900,970) }");
2983 CheckExpectedRanges(DemuxerStream::VIDEO, 2972 CheckExpectedRanges(DemuxerStream::VIDEO,
2984 "{ [0,33) [300,420) [500,570) [700,770) [900,950) }"); 2973 "{ [0,33) [300,420) [500,570) [700,770) [900,950) }");
2974
2975 // Audio buffered ranges are trimmed from 970 to 950 due to splicing the
2976 // previously buffered audio frame - now silence from [900-930), newly
2977 // appended audio from [930, 950).
2978 CheckExpectedRanges(DemuxerStream::AUDIO,
2979 "{ [0,23) [300,400) [500,590) [700,750) [900,950) }");
2980
2985 CheckExpectedRanges("{ [0,23) [300,400) [500,570) [700,750) [900,950) }"); 2981 CheckExpectedRanges("{ [0,23) [300,400) [500,570) [700,750) [900,950) }");
2986 } 2982 }
2987 2983
2988 TEST_F(ChunkDemuxerTest, GetBufferedRanges_AudioVideoText) { 2984 TEST_F(ChunkDemuxerTest, GetBufferedRanges_AudioVideoText) {
2989 EXPECT_CALL(host_, AddTextStream(_, _)); 2985 EXPECT_CALL(host_, AddTextStream(_, _));
2990 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO | HAS_TEXT)); 2986 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO | HAS_TEXT));
2991 2987
2992 // Append audio & video data 2988 // Append audio & video data
2993 AppendMuxedCluster(MuxedStreamInfo(kAudioTrackNum, "0K 23K", 23), 2989 AppendMuxedCluster(MuxedStreamInfo(kAudioTrackNum, "0K 23K", 23),
2994 MuxedStreamInfo(kVideoTrackNum, "0K 33", 33)); 2990 MuxedStreamInfo(kVideoTrackNum, "0K 33", 33));
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
3314 DemuxerStream* audio = demuxer_->GetStream(DemuxerStream::AUDIO); 3310 DemuxerStream* audio = demuxer_->GetStream(DemuxerStream::AUDIO);
3315 3311
3316 // Fetch initial audio config and verify it matches what we expect. 3312 // Fetch initial audio config and verify it matches what we expect.
3317 const AudioDecoderConfig& audio_config_1 = audio->audio_decoder_config(); 3313 const AudioDecoderConfig& audio_config_1 = audio->audio_decoder_config();
3318 ASSERT_TRUE(audio_config_1.IsValidConfig()); 3314 ASSERT_TRUE(audio_config_1.IsValidConfig());
3319 EXPECT_EQ(audio_config_1.samples_per_second(), 44100); 3315 EXPECT_EQ(audio_config_1.samples_per_second(), 44100);
3320 EXPECT_EQ(audio_config_1.extra_data().size(), 3863u); 3316 EXPECT_EQ(audio_config_1.extra_data().size(), 3863u);
3321 3317
3322 ExpectRead(DemuxerStream::AUDIO, 0); 3318 ExpectRead(DemuxerStream::AUDIO, 0);
3323 3319
3324 // The first config change seen is from a splice frame representing an overlap 3320 // Read until we encounter config 2.
3325 // of buffer from config 1 by buffers from config 2.
3326 ReadUntilNotOkOrEndOfStream(DemuxerStream::AUDIO, &status, &last_timestamp); 3321 ReadUntilNotOkOrEndOfStream(DemuxerStream::AUDIO, &status, &last_timestamp);
3327 ASSERT_EQ(status, DemuxerStream::kConfigChanged); 3322 ASSERT_EQ(status, DemuxerStream::kConfigChanged);
3328 EXPECT_EQ(last_timestamp.InMilliseconds(), 524); 3323 EXPECT_EQ(last_timestamp.InMilliseconds(), 501);
3329 3324
3330 // Fetch the new decoder config. 3325 // Fetch the new decoder config.
3331 const AudioDecoderConfig& audio_config_2 = audio->audio_decoder_config(); 3326 const AudioDecoderConfig& audio_config_2 = audio->audio_decoder_config();
3332 ASSERT_TRUE(audio_config_2.IsValidConfig()); 3327 ASSERT_TRUE(audio_config_2.IsValidConfig());
3333 EXPECT_EQ(audio_config_2.samples_per_second(), 44100); 3328 EXPECT_EQ(audio_config_2.samples_per_second(), 44100);
3334 EXPECT_EQ(audio_config_2.extra_data().size(), 3935u); 3329 EXPECT_EQ(audio_config_2.extra_data().size(), 3935u);
3335 3330
3336 // The next config change is from a splice frame representing an overlap of 3331 // Read until we encounter config 1 again.
3337 // buffers from config 2 by buffers from config 1.
3338 ReadUntilNotOkOrEndOfStream(DemuxerStream::AUDIO, &status, &last_timestamp); 3332 ReadUntilNotOkOrEndOfStream(DemuxerStream::AUDIO, &status, &last_timestamp);
3339 ASSERT_EQ(status, DemuxerStream::kConfigChanged); 3333 ASSERT_EQ(status, DemuxerStream::kConfigChanged);
3340 EXPECT_EQ(last_timestamp.InMilliseconds(), 782); 3334 EXPECT_EQ(last_timestamp.InMilliseconds(), 736);
3341 ASSERT_TRUE(audio_config_1.Matches(audio->audio_decoder_config())); 3335 ASSERT_TRUE(audio_config_1.Matches(audio->audio_decoder_config()));
3342 3336
3343 // Read until the end of the stream just to make sure there aren't any other 3337 // Read until the end of the stream just to make sure there aren't any other
3344 // config changes. 3338 // config changes.
3345 ReadUntilNotOkOrEndOfStream(DemuxerStream::AUDIO, &status, &last_timestamp); 3339 ReadUntilNotOkOrEndOfStream(DemuxerStream::AUDIO, &status, &last_timestamp);
3346 ASSERT_EQ(status, DemuxerStream::kOk); 3340 ASSERT_EQ(status, DemuxerStream::kOk);
3347 EXPECT_EQ(last_timestamp.InMilliseconds(), 2744); 3341 EXPECT_EQ(last_timestamp.InMilliseconds(), 2744);
3348 } 3342 }
3349 3343
3350 TEST_F(ChunkDemuxerTest, ConfigChange_Seek) { 3344 TEST_F(ChunkDemuxerTest, ConfigChange_Seek) {
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
3631 true, true, true, true, false, 3625 true, true, true, true, false,
3632 }; 3626 };
3633 3627
3634 static_assert(arraysize(kBuffer) == arraysize(kExpectedReturnValues), 3628 static_assert(arraysize(kBuffer) == arraysize(kExpectedReturnValues),
3635 "test arrays out of sync"); 3629 "test arrays out of sync");
3636 static_assert(arraysize(kBuffer) == sizeof(kBuffer), 3630 static_assert(arraysize(kBuffer) == sizeof(kBuffer),
3637 "there should be one byte per index"); 3631 "there should be one byte per index");
3638 3632
3639 ASSERT_TRUE(InitDemuxer(HAS_AUDIO)); 3633 ASSERT_TRUE(InitDemuxer(HAS_AUDIO));
3640 EXPECT_MEDIA_LOG(WebMSimpleBlockDurationEstimated(23)).Times(2); 3634 EXPECT_MEDIA_LOG(WebMSimpleBlockDurationEstimated(23)).Times(2);
3641 EXPECT_MEDIA_LOG(GeneratedSplice(22000, 2000)); 3635 EXPECT_MEDIA_LOG(GeneratedSplice(2000, 1000));
3642 for (size_t i = 0; i < sizeof(kBuffer); i++) { 3636 for (size_t i = 0; i < sizeof(kBuffer); i++) {
3643 DVLOG(3) << "Appending and testing index " << i; 3637 DVLOG(3) << "Appending and testing index " << i;
3644 ASSERT_TRUE(AppendData(kBuffer + i, 1)); 3638 ASSERT_TRUE(AppendData(kBuffer + i, 1));
3645 bool expected_return_value = kExpectedReturnValues[i]; 3639 bool expected_return_value = kExpectedReturnValues[i];
3646 EXPECT_EQ(expected_return_value, 3640 EXPECT_EQ(expected_return_value,
3647 demuxer_->IsParsingMediaSegment(kSourceId)); 3641 demuxer_->IsParsingMediaSegment(kSourceId));
3648 } 3642 }
3649 } 3643 }
3650 3644
3651 TEST_F(ChunkDemuxerTest, DurationChange) { 3645 TEST_F(ChunkDemuxerTest, DurationChange) {
(...skipping 1086 matching lines...) Expand 10 before | Expand all | Expand 10 after
4738 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); 4732 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO));
4739 DemuxerStream* audio_stream = demuxer_->GetStream(DemuxerStream::AUDIO); 4733 DemuxerStream* audio_stream = demuxer_->GetStream(DemuxerStream::AUDIO);
4740 EXPECT_NE(nullptr, audio_stream); 4734 EXPECT_NE(nullptr, audio_stream);
4741 CheckStreamStatusNotifications(audio_stream); 4735 CheckStreamStatusNotifications(audio_stream);
4742 DemuxerStream* video_stream = demuxer_->GetStream(DemuxerStream::VIDEO); 4736 DemuxerStream* video_stream = demuxer_->GetStream(DemuxerStream::VIDEO);
4743 EXPECT_NE(nullptr, video_stream); 4737 EXPECT_NE(nullptr, video_stream);
4744 CheckStreamStatusNotifications(video_stream); 4738 CheckStreamStatusNotifications(video_stream);
4745 } 4739 }
4746 4740
4747 } // namespace media 4741 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698