OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <memory> |
5 #include <vector> | 6 #include <vector> |
6 | 7 |
7 #include "base/bind.h" | 8 #include "base/bind.h" |
8 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/ptr_util.h" |
9 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
10 #include "chromecast/media/cma/backend/audio_decoder_default.h" | 11 #include "chromecast/media/cma/backend/audio_decoder_default.h" |
11 #include "chromecast/media/cma/backend/media_pipeline_backend_default.h" | 12 #include "chromecast/media/cma/backend/media_pipeline_backend_default.h" |
12 #include "chromecast/media/cma/backend/video_decoder_default.h" | 13 #include "chromecast/media/cma/backend/video_decoder_default.h" |
13 #include "chromecast/media/cma/pipeline/av_pipeline_client.h" | 14 #include "chromecast/media/cma/pipeline/av_pipeline_client.h" |
14 #include "chromecast/media/cma/pipeline/media_pipeline_impl.h" | 15 #include "chromecast/media/cma/pipeline/media_pipeline_impl.h" |
15 #include "chromecast/media/cma/pipeline/video_pipeline_client.h" | 16 #include "chromecast/media/cma/pipeline/video_pipeline_client.h" |
16 #include "chromecast/media/cma/test/frame_generator_for_test.h" | 17 #include "chromecast/media/cma/test/frame_generator_for_test.h" |
17 #include "chromecast/media/cma/test/mock_frame_provider.h" | 18 #include "chromecast/media/cma/test/mock_frame_provider.h" |
18 #include "media/base/audio_decoder_config.h" | 19 #include "media/base/audio_decoder_config.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 void Flush(const base::Closure& flush_cb) { media_pipeline_.Flush(flush_cb); } | 51 void Flush(const base::Closure& flush_cb) { media_pipeline_.Flush(flush_cb); } |
51 void Stop() { | 52 void Stop() { |
52 media_pipeline_.Stop(); | 53 media_pipeline_.Stop(); |
53 base::MessageLoop::current()->QuitWhenIdle(); | 54 base::MessageLoop::current()->QuitWhenIdle(); |
54 } | 55 } |
55 | 56 |
56 MediaPipelineBackendDefault* pipeline_backend() { return pipeline_backend_; } | 57 MediaPipelineBackendDefault* pipeline_backend() { return pipeline_backend_; } |
57 | 58 |
58 protected: | 59 protected: |
59 void SetUp() override { | 60 void SetUp() override { |
60 scoped_ptr<MediaPipelineBackendDefault> backend = | 61 std::unique_ptr<MediaPipelineBackendDefault> backend = |
61 make_scoped_ptr(new MediaPipelineBackendDefault()); | 62 base::WrapUnique(new MediaPipelineBackendDefault()); |
62 pipeline_backend_ = backend.get(); | 63 pipeline_backend_ = backend.get(); |
63 media_pipeline_.Initialize(kLoadTypeURL, std::move(backend)); | 64 media_pipeline_.Initialize(kLoadTypeURL, std::move(backend)); |
64 | 65 |
65 if (::testing::get<0>(GetParam())) { | 66 if (::testing::get<0>(GetParam())) { |
66 ::media::AudioDecoderConfig audio_config( | 67 ::media::AudioDecoderConfig audio_config( |
67 ::media::kCodecMP3, ::media::kSampleFormatS16, | 68 ::media::kCodecMP3, ::media::kSampleFormatS16, |
68 ::media::CHANNEL_LAYOUT_STEREO, 44100, ::media::EmptyExtraData(), | 69 ::media::CHANNEL_LAYOUT_STEREO, 44100, ::media::EmptyExtraData(), |
69 ::media::Unencrypted()); | 70 ::media::Unencrypted()); |
70 AvPipelineClient client; | 71 AvPipelineClient client; |
71 client.eos_cb = base::Bind(&AudioVideoPipelineImplTest::OnEos, | 72 client.eos_cb = base::Bind(&AudioVideoPipelineImplTest::OnEos, |
(...skipping 18 matching lines...) Expand all Loading... |
90 ASSERT_EQ(::media::PIPELINE_OK, status); | 91 ASSERT_EQ(::media::PIPELINE_OK, status); |
91 } | 92 } |
92 } | 93 } |
93 | 94 |
94 base::MessageLoop message_loop_; | 95 base::MessageLoop message_loop_; |
95 | 96 |
96 private: | 97 private: |
97 enum Stream { STREAM_AUDIO, STREAM_VIDEO }; | 98 enum Stream { STREAM_AUDIO, STREAM_VIDEO }; |
98 DISALLOW_COPY_AND_ASSIGN(AudioVideoPipelineImplTest); | 99 DISALLOW_COPY_AND_ASSIGN(AudioVideoPipelineImplTest); |
99 | 100 |
100 scoped_ptr<CodedFrameProvider> CreateFrameProvider() { | 101 std::unique_ptr<CodedFrameProvider> CreateFrameProvider() { |
101 std::vector<FrameGeneratorForTest::FrameSpec> frame_specs; | 102 std::vector<FrameGeneratorForTest::FrameSpec> frame_specs; |
102 frame_specs.resize(kNumFrames); | 103 frame_specs.resize(kNumFrames); |
103 for (size_t k = 0; k < frame_specs.size() - 1; k++) { | 104 for (size_t k = 0; k < frame_specs.size() - 1; k++) { |
104 frame_specs[k].has_config = (k == 0); | 105 frame_specs[k].has_config = (k == 0); |
105 frame_specs[k].timestamp = | 106 frame_specs[k].timestamp = |
106 base::TimeDelta::FromMicroseconds(kFrameDurationUs) * k; | 107 base::TimeDelta::FromMicroseconds(kFrameDurationUs) * k; |
107 frame_specs[k].size = kFrameSize; | 108 frame_specs[k].size = kFrameSize; |
108 frame_specs[k].has_decrypt_config = false; | 109 frame_specs[k].has_decrypt_config = false; |
109 } | 110 } |
110 frame_specs[frame_specs.size() - 1].is_eos = true; | 111 frame_specs[frame_specs.size() - 1].is_eos = true; |
111 | 112 |
112 scoped_ptr<FrameGeneratorForTest> frame_generator( | 113 std::unique_ptr<FrameGeneratorForTest> frame_generator( |
113 new FrameGeneratorForTest(frame_specs)); | 114 new FrameGeneratorForTest(frame_specs)); |
114 bool provider_delayed_pattern[] = {false, true}; | 115 bool provider_delayed_pattern[] = {false, true}; |
115 scoped_ptr<MockFrameProvider> frame_provider(new MockFrameProvider()); | 116 std::unique_ptr<MockFrameProvider> frame_provider(new MockFrameProvider()); |
116 frame_provider->Configure( | 117 frame_provider->Configure( |
117 std::vector<bool>( | 118 std::vector<bool>( |
118 provider_delayed_pattern, | 119 provider_delayed_pattern, |
119 provider_delayed_pattern + arraysize(provider_delayed_pattern)), | 120 provider_delayed_pattern + arraysize(provider_delayed_pattern)), |
120 std::move(frame_generator)); | 121 std::move(frame_generator)); |
121 frame_provider->SetDelayFlush(true); | 122 frame_provider->SetDelayFlush(true); |
122 return std::move(frame_provider); | 123 return std::move(frame_provider); |
123 } | 124 } |
124 | 125 |
125 void OnEos(Stream stream) { | 126 void OnEos(Stream stream) { |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 // Test all three types of pipeline: audio-only, video-only, audio-video. | 209 // Test all three types of pipeline: audio-only, video-only, audio-video. |
209 INSTANTIATE_TEST_CASE_P( | 210 INSTANTIATE_TEST_CASE_P( |
210 MediaPipelineImplTests, | 211 MediaPipelineImplTests, |
211 AudioVideoPipelineImplTest, | 212 AudioVideoPipelineImplTest, |
212 ::testing::Values(AudioVideoTuple(true, false), // Audio only. | 213 ::testing::Values(AudioVideoTuple(true, false), // Audio only. |
213 AudioVideoTuple(false, true), // Video only. | 214 AudioVideoTuple(false, true), // Video only. |
214 AudioVideoTuple(true, true))); // Audio and Video. | 215 AudioVideoTuple(true, true))); // Audio and Video. |
215 | 216 |
216 } // namespace media | 217 } // namespace media |
217 } // namespace chromecast | 218 } // namespace chromecast |
OLD | NEW |