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 <vector> | 5 #include <vector> |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/files/memory_mapped_file.h" | 10 #include "base/files/memory_mapped_file.h" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/memory/scoped_vector.h" | 14 #include "base/memory/scoped_vector.h" |
15 #include "base/message_loop/message_loop.h" | 15 #include "base/message_loop/message_loop.h" |
16 #include "base/message_loop/message_loop_proxy.h" | 16 #include "base/message_loop/message_loop_proxy.h" |
17 #include "base/path_service.h" | 17 #include "base/path_service.h" |
18 #include "base/threading/thread.h" | 18 #include "base/threading/thread.h" |
19 #include "base/time/time.h" | 19 #include "base/time/time.h" |
20 #include "chromecast/media/base/decrypt_context.h" | 20 #include "chromecast/media/base/decrypt_context.h" |
21 #include "chromecast/media/cma/backend/audio_pipeline_device.h" | 21 #include "chromecast/media/cma/backend/audio_pipeline_device.h" |
22 #include "chromecast/media/cma/backend/media_clock_device.h" | 22 #include "chromecast/media/cma/backend/media_clock_device.h" |
23 #include "chromecast/media/cma/backend/media_pipeline_device.h" | 23 #include "chromecast/media/cma/backend/media_pipeline_device.h" |
24 #include "chromecast/media/cma/backend/media_pipeline_device_params.h" | 24 #include "chromecast/media/cma/backend/media_pipeline_device_params.h" |
25 #include "chromecast/media/cma/backend/video_pipeline_device.h" | 25 #include "chromecast/media/cma/backend/video_pipeline_device.h" |
26 #include "chromecast/media/cma/base/decoder_buffer_adapter.h" | 26 #include "chromecast/media/cma/base/decoder_buffer_adapter.h" |
27 #include "chromecast/media/cma/base/decoder_buffer_base.h" | 27 #include "chromecast/media/cma/base/decoder_buffer_base.h" |
| 28 #include "chromecast/media/cma/base/decoder_config_adapter.h" |
| 29 #include "chromecast/media/cma/public/decoder_config.h" |
28 #include "chromecast/media/cma/test/frame_segmenter_for_test.h" | 30 #include "chromecast/media/cma/test/frame_segmenter_for_test.h" |
29 #include "chromecast/media/cma/test/media_component_device_feeder_for_test.h" | 31 #include "chromecast/media/cma/test/media_component_device_feeder_for_test.h" |
30 #include "media/base/audio_decoder_config.h" | 32 #include "media/base/audio_decoder_config.h" |
31 #include "media/base/buffers.h" | 33 #include "media/base/buffers.h" |
32 #include "media/base/decoder_buffer.h" | 34 #include "media/base/decoder_buffer.h" |
33 #include "media/base/video_decoder_config.h" | 35 #include "media/base/video_decoder_config.h" |
34 #include "testing/gtest/include/gtest/gtest.h" | 36 #include "testing/gtest/include/gtest/gtest.h" |
35 | 37 |
36 namespace chromecast { | 38 namespace chromecast { |
37 namespace media { | 39 namespace media { |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 } | 149 } |
148 | 150 |
149 void AudioVideoPipelineDeviceTest::LoadAudioStream(std::string filename) { | 151 void AudioVideoPipelineDeviceTest::LoadAudioStream(std::string filename) { |
150 base::FilePath file_path = GetTestDataFilePath(filename); | 152 base::FilePath file_path = GetTestDataFilePath(filename); |
151 DemuxResult demux_result = FFmpegDemuxForTest(file_path, true /* audio */); | 153 DemuxResult demux_result = FFmpegDemuxForTest(file_path, true /* audio */); |
152 BufferList frames = demux_result.frames; | 154 BufferList frames = demux_result.frames; |
153 | 155 |
154 AudioPipelineDevice* audio_pipeline_device = | 156 AudioPipelineDevice* audio_pipeline_device = |
155 media_pipeline_device_->GetAudioPipelineDevice(); | 157 media_pipeline_device_->GetAudioPipelineDevice(); |
156 | 158 |
157 bool success = audio_pipeline_device->SetConfig(demux_result.audio_config); | 159 bool success = |
| 160 audio_pipeline_device->SetConfig( |
| 161 DecoderConfigAdapter::ToAudioConfig(demux_result.audio_config)); |
158 ASSERT_TRUE(success); | 162 ASSERT_TRUE(success); |
159 | 163 |
160 VLOG(2) << "Got " << frames.size() << " audio input frames"; | 164 VLOG(2) << "Got " << frames.size() << " audio input frames"; |
161 | 165 |
162 frames.push_back( | 166 frames.push_back( |
163 scoped_refptr<DecoderBufferBase>( | 167 scoped_refptr<DecoderBufferBase>( |
164 new DecoderBufferAdapter(::media::DecoderBuffer::CreateEOSBuffer()))); | 168 new DecoderBufferAdapter(::media::DecoderBuffer::CreateEOSBuffer()))); |
165 | 169 |
166 MediaComponentDeviceFeederForTest* device_feeder = | 170 MediaComponentDeviceFeederForTest* device_feeder = |
167 new MediaComponentDeviceFeederForTest(audio_pipeline_device, frames); | 171 new MediaComponentDeviceFeederForTest(audio_pipeline_device, frames); |
168 device_feeder->Initialize(base::Bind(&AudioVideoPipelineDeviceTest::OnEos, | 172 device_feeder->Initialize(base::Bind(&AudioVideoPipelineDeviceTest::OnEos, |
169 base::Unretained(this), | 173 base::Unretained(this), |
170 device_feeder)); | 174 device_feeder)); |
171 component_device_feeders_.push_back(device_feeder); | 175 component_device_feeders_.push_back(device_feeder); |
172 } | 176 } |
173 | 177 |
174 void AudioVideoPipelineDeviceTest::LoadVideoStream(std::string filename, | 178 void AudioVideoPipelineDeviceTest::LoadVideoStream(std::string filename, |
175 bool raw_h264) { | 179 bool raw_h264) { |
176 BufferList frames; | 180 BufferList frames; |
177 ::media::VideoDecoderConfig video_config; | 181 VideoConfig video_config; |
178 | 182 |
179 if (raw_h264) { | 183 if (raw_h264) { |
180 base::FilePath file_path = GetTestDataFilePath(filename); | 184 base::FilePath file_path = GetTestDataFilePath(filename); |
181 base::MemoryMappedFile video_stream; | 185 base::MemoryMappedFile video_stream; |
182 ASSERT_TRUE(video_stream.Initialize(file_path)) | 186 ASSERT_TRUE(video_stream.Initialize(file_path)) |
183 << "Couldn't open stream file: " << file_path.MaybeAsASCII(); | 187 << "Couldn't open stream file: " << file_path.MaybeAsASCII(); |
184 frames = H264SegmenterForTest(video_stream.data(), video_stream.length()); | 188 frames = H264SegmenterForTest(video_stream.data(), video_stream.length()); |
185 | 189 |
186 // Use arbitraty sizes. | 190 // Use arbitraty sizes. |
187 gfx::Size coded_size(320, 240); | 191 gfx::Size coded_size(320, 240); |
188 gfx::Rect visible_rect(0, 0, 320, 240); | 192 gfx::Rect visible_rect(0, 0, 320, 240); |
189 gfx::Size natural_size(320, 240); | 193 gfx::Size natural_size(320, 240); |
190 | 194 |
191 // TODO(kjoswiak): Either pull data from stream or make caller specify value | 195 // TODO(kjoswiak): Either pull data from stream or make caller specify value |
192 video_config = ::media::VideoDecoderConfig( | 196 video_config = VideoConfig( |
193 ::media::kCodecH264, | 197 VideoConfig::kCodecH264, |
194 ::media::H264PROFILE_MAIN, | 198 VideoConfig::H264PROFILE_MAIN, |
195 ::media::VideoFrame::I420, | |
196 coded_size, | |
197 visible_rect, | |
198 natural_size, | |
199 NULL, 0, false); | 199 NULL, 0, false); |
200 } else { | 200 } else { |
201 base::FilePath file_path = GetTestDataFilePath(filename); | 201 base::FilePath file_path = GetTestDataFilePath(filename); |
202 DemuxResult demux_result = FFmpegDemuxForTest(file_path, | 202 DemuxResult demux_result = FFmpegDemuxForTest(file_path, |
203 /*audio*/ false); | 203 /*audio*/ false); |
204 frames = demux_result.frames; | 204 frames = demux_result.frames; |
205 video_config = demux_result.video_config; | 205 video_config = |
| 206 DecoderConfigAdapter::ToVideoConfig(demux_result.video_config); |
206 } | 207 } |
207 | 208 |
208 VideoPipelineDevice* video_pipeline_device = | 209 VideoPipelineDevice* video_pipeline_device = |
209 media_pipeline_device_->GetVideoPipelineDevice(); | 210 media_pipeline_device_->GetVideoPipelineDevice(); |
210 | 211 |
211 // Set configuration. | 212 // Set configuration. |
212 bool success = video_pipeline_device->SetConfig(video_config); | 213 bool success = video_pipeline_device->SetConfig(video_config); |
213 ASSERT_TRUE(success); | 214 ASSERT_TRUE(success); |
214 | 215 |
215 VLOG(2) << "Got " << frames.size() << " video input frames"; | 216 VLOG(2) << "Got " << frames.size() << " video input frames"; |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 TEST_F(AudioVideoPipelineDeviceTest, WebmPlayback) { | 378 TEST_F(AudioVideoPipelineDeviceTest, WebmPlayback) { |
378 scoped_ptr<base::MessageLoop> message_loop(new base::MessageLoop()); | 379 scoped_ptr<base::MessageLoop> message_loop(new base::MessageLoop()); |
379 | 380 |
380 ConfigureForFile("bear-640x360.webm"); | 381 ConfigureForFile("bear-640x360.webm"); |
381 Start(); | 382 Start(); |
382 message_loop->Run(); | 383 message_loop->Run(); |
383 } | 384 } |
384 | 385 |
385 } // namespace media | 386 } // namespace media |
386 } // namespace chromecast | 387 } // namespace chromecast |
OLD | NEW |