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

Side by Side Diff: chromecast/media/cma/backend/audio_video_pipeline_device_unittest.cc

Issue 1074383002: Introduce VideoConfig/AudioConfig class for CMA backend (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add TODO comments and fix unit test Created 5 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
OLDNEW
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"
28 #include "chromecast/media/cma/test/frame_segmenter_for_test.h" 29 #include "chromecast/media/cma/test/frame_segmenter_for_test.h"
29 #include "chromecast/media/cma/test/media_component_device_feeder_for_test.h" 30 #include "chromecast/media/cma/test/media_component_device_feeder_for_test.h"
31 #include "chromecast/public/media/decoder_config.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 {
38 40
39 namespace { 41 namespace {
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 = audio_pipeline_device->SetConfig(
160 DecoderConfigAdapter::ToCastAudioConfig(demux_result.audio_config));
158 ASSERT_TRUE(success); 161 ASSERT_TRUE(success);
159 162
160 VLOG(2) << "Got " << frames.size() << " audio input frames"; 163 VLOG(2) << "Got " << frames.size() << " audio input frames";
161 164
162 frames.push_back( 165 frames.push_back(
163 scoped_refptr<DecoderBufferBase>( 166 scoped_refptr<DecoderBufferBase>(
164 new DecoderBufferAdapter(::media::DecoderBuffer::CreateEOSBuffer()))); 167 new DecoderBufferAdapter(::media::DecoderBuffer::CreateEOSBuffer())));
165 168
166 MediaComponentDeviceFeederForTest* device_feeder = 169 MediaComponentDeviceFeederForTest* device_feeder =
167 new MediaComponentDeviceFeederForTest(audio_pipeline_device, frames); 170 new MediaComponentDeviceFeederForTest(audio_pipeline_device, frames);
168 device_feeder->Initialize(base::Bind(&AudioVideoPipelineDeviceTest::OnEos, 171 device_feeder->Initialize(base::Bind(&AudioVideoPipelineDeviceTest::OnEos,
169 base::Unretained(this), 172 base::Unretained(this),
170 device_feeder)); 173 device_feeder));
171 component_device_feeders_.push_back(device_feeder); 174 component_device_feeders_.push_back(device_feeder);
172 } 175 }
173 176
174 void AudioVideoPipelineDeviceTest::LoadVideoStream(std::string filename, 177 void AudioVideoPipelineDeviceTest::LoadVideoStream(std::string filename,
175 bool raw_h264) { 178 bool raw_h264) {
176 BufferList frames; 179 BufferList frames;
177 ::media::VideoDecoderConfig video_config; 180 VideoConfig video_config;
178 181
179 if (raw_h264) { 182 if (raw_h264) {
180 base::FilePath file_path = GetTestDataFilePath(filename); 183 base::FilePath file_path = GetTestDataFilePath(filename);
181 base::MemoryMappedFile video_stream; 184 base::MemoryMappedFile video_stream;
182 ASSERT_TRUE(video_stream.Initialize(file_path)) 185 ASSERT_TRUE(video_stream.Initialize(file_path))
183 << "Couldn't open stream file: " << file_path.MaybeAsASCII(); 186 << "Couldn't open stream file: " << file_path.MaybeAsASCII();
184 frames = H264SegmenterForTest(video_stream.data(), video_stream.length()); 187 frames = H264SegmenterForTest(video_stream.data(), video_stream.length());
185 188
186 // Use arbitraty sizes. 189 // TODO(erickung): Either pull data from stream or make caller specify value
187 gfx::Size coded_size(320, 240); 190 video_config.codec = kCodecH264;
188 gfx::Rect visible_rect(0, 0, 320, 240); 191 video_config.profile = kH264Main;
189 gfx::Size natural_size(320, 240); 192 video_config.additional_config = NULL;
190 193 video_config.is_encrypted = false;
191 // TODO(kjoswiak): Either pull data from stream or make caller specify value
192 video_config = ::media::VideoDecoderConfig(
193 ::media::kCodecH264,
194 ::media::H264PROFILE_MAIN,
195 ::media::VideoFrame::I420,
196 coded_size,
197 visible_rect,
198 natural_size,
199 NULL, 0, false);
200 } else { 194 } else {
201 base::FilePath file_path = GetTestDataFilePath(filename); 195 base::FilePath file_path = GetTestDataFilePath(filename);
202 DemuxResult demux_result = FFmpegDemuxForTest(file_path, 196 DemuxResult demux_result = FFmpegDemuxForTest(file_path,
203 /*audio*/ false); 197 /*audio*/ false);
204 frames = demux_result.frames; 198 frames = demux_result.frames;
205 video_config = demux_result.video_config; 199 video_config =
200 DecoderConfigAdapter::ToCastVideoConfig(demux_result.video_config);
206 } 201 }
207 202
208 VideoPipelineDevice* video_pipeline_device = 203 VideoPipelineDevice* video_pipeline_device =
209 media_pipeline_device_->GetVideoPipelineDevice(); 204 media_pipeline_device_->GetVideoPipelineDevice();
210 205
211 // Set configuration. 206 // Set configuration.
212 bool success = video_pipeline_device->SetConfig(video_config); 207 bool success = video_pipeline_device->SetConfig(video_config);
213 ASSERT_TRUE(success); 208 ASSERT_TRUE(success);
214 209
215 VLOG(2) << "Got " << frames.size() << " video input frames"; 210 VLOG(2) << "Got " << frames.size() << " video input frames";
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 TEST_F(AudioVideoPipelineDeviceTest, WebmPlayback) { 372 TEST_F(AudioVideoPipelineDeviceTest, WebmPlayback) {
378 scoped_ptr<base::MessageLoop> message_loop(new base::MessageLoop()); 373 scoped_ptr<base::MessageLoop> message_loop(new base::MessageLoop());
379 374
380 ConfigureForFile("bear-640x360.webm"); 375 ConfigureForFile("bear-640x360.webm");
381 Start(); 376 Start();
382 message_loop->Run(); 377 message_loop->Run();
383 } 378 }
384 379
385 } // namespace media 380 } // namespace media
386 } // namespace chromecast 381 } // namespace chromecast
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698