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

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

Issue 180153003: Implement core of compliant MediaSource coded frame processing (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Aligned with April 1 spec editor's draft, tests added Created 6 years, 7 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 | Annotate | Revision Log
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 <algorithm> 5 #include <algorithm>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 #include "base/strings/string_split.h" 10 #include "base/strings/string_split.h"
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 } 127 }
128 128
129 static void OnSeekDone_OKExpected(bool* called, PipelineStatus status) { 129 static void OnSeekDone_OKExpected(bool* called, PipelineStatus status) {
130 EXPECT_EQ(status, PIPELINE_OK); 130 EXPECT_EQ(status, PIPELINE_OK);
131 *called = true; 131 *called = true;
132 } 132 }
133 133
134 static void LogFunc(const std::string& str) { DVLOG(1) << str; } 134 static void LogFunc(const std::string& str) { DVLOG(1) << str; }
135 135
136 // Test parameter determines which coded frame processor is used to process 136 // Test parameter determines which coded frame processor is used to process
137 // appended data. If true, LegacyFrameProcessor is used. Otherwise, (not yet 137 // appended data. If true, LegacyFrameProcessor is used. Otherwise, the new
138 // supported), a more compliant frame processor is used. 138 // FrameProcessor is used.
139 // TODO(wolenetz): Enable usage of new frame processor based on this flag.
140 // See http://crbug.com/249422.
141 class ChunkDemuxerTest : public ::testing::TestWithParam<bool> { 139 class ChunkDemuxerTest : public ::testing::TestWithParam<bool> {
142 protected: 140 protected:
143 enum CodecsIndex { 141 enum CodecsIndex {
144 AUDIO, 142 AUDIO,
145 VIDEO, 143 VIDEO,
146 MAX_CODECS_INDEX 144 MAX_CODECS_INDEX
147 }; 145 };
148 146
149 // Default cluster to append first for simple tests. 147 // Default cluster to append first for simple tests.
150 scoped_ptr<Cluster> kDefaultFirstCluster() { 148 scoped_ptr<Cluster> kDefaultFirstCluster() {
(...skipping 2659 matching lines...) Expand 10 before | Expand all | Expand 10 after
2810 // Add data leading up to the currently set duration. 2808 // Add data leading up to the currently set duration.
2811 AppendCluster(GenerateCluster(kStreamDuration - kAudioBlockDuration, 2809 AppendCluster(GenerateCluster(kStreamDuration - kAudioBlockDuration,
2812 kStreamDuration - kVideoBlockDuration, 2810 kStreamDuration - kVideoBlockDuration,
2813 2)); 2811 2));
2814 2812
2815 CheckExpectedRanges(kSourceId, "{ [201191,201224) }"); 2813 CheckExpectedRanges(kSourceId, "{ [201191,201224) }");
2816 2814
2817 // Add data beginning at the currently set duration and expect a new duration 2815 // Add data beginning at the currently set duration and expect a new duration
2818 // to be signaled. Note that the last video block will have a higher end 2816 // to be signaled. Note that the last video block will have a higher end
2819 // timestamp than the last audio block. 2817 // timestamp than the last audio block.
2820 // TODO(wolenetz): Compliant coded frame processor will emit a max of one 2818 if (use_legacy_frame_processor_) {
2821 // duration change per each ProcessFrames(). Remove the first expectation here 2819 const int kNewStreamDurationAudio = kStreamDuration + kAudioBlockDuration;
2822 // once compliant coded frame processor is used. See http://crbug.com/249422. 2820 EXPECT_CALL(host_, SetDuration(
2823 const int kNewStreamDurationAudio = kStreamDuration + kAudioBlockDuration;
2824 EXPECT_CALL(host_, SetDuration(
2825 base::TimeDelta::FromMilliseconds(kNewStreamDurationAudio))); 2821 base::TimeDelta::FromMilliseconds(kNewStreamDurationAudio)));
2822 }
2826 const int kNewStreamDurationVideo = kStreamDuration + kVideoBlockDuration; 2823 const int kNewStreamDurationVideo = kStreamDuration + kVideoBlockDuration;
2827 EXPECT_CALL(host_, SetDuration( 2824 EXPECT_CALL(host_, SetDuration(
2828 base::TimeDelta::FromMilliseconds(kNewStreamDurationVideo))); 2825 base::TimeDelta::FromMilliseconds(kNewStreamDurationVideo)));
2829 AppendCluster(GenerateCluster(kDefaultDuration().InMilliseconds(), 2)); 2826 AppendCluster(GenerateCluster(kDefaultDuration().InMilliseconds(), 2));
2830 2827
2831 CheckExpectedRanges(kSourceId, "{ [201191,201247) }"); 2828 CheckExpectedRanges(kSourceId, "{ [201191,201247) }");
2832 2829
2833 // Add more data to the end of each media type. Note that the last audio block 2830 // Add more data to the end of each media type. Note that the last audio block
2834 // will have a higher end timestamp than the last video block. 2831 // will have a higher end timestamp than the last video block.
2835 const int kFinalStreamDuration = kStreamDuration + kAudioBlockDuration * 3; 2832 const int kFinalStreamDuration = kStreamDuration + kAudioBlockDuration * 3;
2836 EXPECT_CALL(host_, SetDuration( 2833 EXPECT_CALL(host_, SetDuration(
2837 base::TimeDelta::FromMilliseconds(kFinalStreamDuration))); 2834 base::TimeDelta::FromMilliseconds(kFinalStreamDuration)));
2838 AppendCluster(GenerateCluster(kStreamDuration + kAudioBlockDuration, 2835 AppendCluster(GenerateCluster(kStreamDuration + kAudioBlockDuration,
2839 kStreamDuration + kVideoBlockDuration, 2836 kStreamDuration + kVideoBlockDuration,
2840 3)); 2837 3));
2841 2838
2842 // See that the range has increased appropriately (but not to the full 2839 // See that the range has increased appropriately (but not to the full
2843 // duration of 201293, since there is not enough video appended for that). 2840 // duration of 201293, since there is not enough video appended for that).
2844 CheckExpectedRanges(kSourceId, "{ [201191,201290) }"); 2841 CheckExpectedRanges(kSourceId, "{ [201191,201290) }");
2845 } 2842 }
2846 2843
2847 TEST_P(ChunkDemuxerTest, DurationChangeTimestampOffset) { 2844 TEST_P(ChunkDemuxerTest, DurationChangeTimestampOffset) {
2848 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); 2845 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO));
2849 2846
2850 ASSERT_TRUE(SetTimestampOffset(kSourceId, kDefaultDuration())); 2847 ASSERT_TRUE(SetTimestampOffset(kSourceId, kDefaultDuration()));
2851 2848
2852 // TODO(wolenetz): Compliant coded frame processor will emit a max of one 2849 if (use_legacy_frame_processor_) {
2853 // duration change per each ProcessFrames(). Remove the first expectation here 2850 EXPECT_CALL(host_, SetDuration(
2854 // once compliant coded frame processor is used. See http://crbug.com/249422. 2851 kDefaultDuration() + base::TimeDelta::FromMilliseconds(
2855 EXPECT_CALL(host_, SetDuration( 2852 kAudioBlockDuration * 2)));
2856 kDefaultDuration() + base::TimeDelta::FromMilliseconds( 2853 }
2857 kAudioBlockDuration * 2)));
2858 EXPECT_CALL(host_, SetDuration( 2854 EXPECT_CALL(host_, SetDuration(
2859 kDefaultDuration() + base::TimeDelta::FromMilliseconds( 2855 kDefaultDuration() + base::TimeDelta::FromMilliseconds(
2860 kVideoBlockDuration * 2))); 2856 kVideoBlockDuration * 2)));
2861 AppendCluster(GenerateCluster(0, 4)); 2857 AppendCluster(GenerateCluster(0, 4));
2862 } 2858 }
2863 2859
2864 TEST_P(ChunkDemuxerTest, EndOfStreamTruncateDuration) { 2860 TEST_P(ChunkDemuxerTest, EndOfStreamTruncateDuration) {
2865 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); 2861 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO));
2866 2862
2867 AppendCluster(kDefaultFirstCluster()); 2863 AppendCluster(kDefaultFirstCluster());
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after
3268 3264
3269 // NOTE: we start at 175 here because the buffer at 125 was returned 3265 // NOTE: we start at 175 here because the buffer at 125 was returned
3270 // to the pending read initiated above. 3266 // to the pending read initiated above.
3271 CheckExpectedBuffers(text_stream, "175 225"); 3267 CheckExpectedBuffers(text_stream, "175 225");
3272 3268
3273 // Verify that audio & video streams continue to return expected values. 3269 // Verify that audio & video streams continue to return expected values.
3274 CheckExpectedBuffers(audio_stream, "160 180"); 3270 CheckExpectedBuffers(audio_stream, "160 180");
3275 CheckExpectedBuffers(video_stream, "180 210"); 3271 CheckExpectedBuffers(video_stream, "180 210");
3276 } 3272 }
3277 3273
3278 // TODO(wolenetz): Enable testing of new frame processor based on this flag, 3274 // Generate two sets of tests: one using FrameProcessor, and one using
3279 // once the new processor has landed. See http://crbug.com/249422. 3275 // LegacyFrameProcessor.
3276 INSTANTIATE_TEST_CASE_P(NewFrameProcessor, ChunkDemuxerTest, Values(false));
3280 INSTANTIATE_TEST_CASE_P(LegacyFrameProcessor, ChunkDemuxerTest, Values(true)); 3277 INSTANTIATE_TEST_CASE_P(LegacyFrameProcessor, ChunkDemuxerTest, Values(true));
3281 3278
3282 } // namespace media 3279 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698