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

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

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

Powered by Google App Engine
This is Rietveld 408576698