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