| 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 "chromecast/renderer/media/cma_renderer.h" | 5 #include "chromecast/renderer/media/cma_renderer.h" |
| 6 | 6 |
| 7 #include <utility> |
| 8 |
| 7 #include "base/bind.h" | 9 #include "base/bind.h" |
| 8 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
| 9 #include "base/location.h" | 11 #include "base/location.h" |
| 10 #include "base/single_thread_task_runner.h" | 12 #include "base/single_thread_task_runner.h" |
| 11 #include "base/thread_task_runner_handle.h" | 13 #include "base/thread_task_runner_handle.h" |
| 12 #include "chromecast/media/cma/base/balanced_media_task_runner_factory.h" | 14 #include "chromecast/media/cma/base/balanced_media_task_runner_factory.h" |
| 13 #include "chromecast/media/cma/base/cma_logging.h" | 15 #include "chromecast/media/cma/base/cma_logging.h" |
| 14 #include "chromecast/media/cma/pipeline/av_pipeline_client.h" | 16 #include "chromecast/media/cma/pipeline/av_pipeline_client.h" |
| 15 #include "chromecast/media/cma/pipeline/media_pipeline_client.h" | 17 #include "chromecast/media/cma/pipeline/media_pipeline_client.h" |
| 16 #include "chromecast/media/cma/pipeline/video_pipeline_client.h" | 18 #include "chromecast/media/cma/pipeline/video_pipeline_client.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 39 void MediaPipelineClientDummyCallback() { | 41 void MediaPipelineClientDummyCallback() { |
| 40 } | 42 } |
| 41 | 43 |
| 42 } // namespace | 44 } // namespace |
| 43 | 45 |
| 44 CmaRenderer::CmaRenderer(scoped_ptr<MediaPipelineProxy> media_pipeline, | 46 CmaRenderer::CmaRenderer(scoped_ptr<MediaPipelineProxy> media_pipeline, |
| 45 ::media::VideoRendererSink* video_renderer_sink, | 47 ::media::VideoRendererSink* video_renderer_sink, |
| 46 ::media::GpuVideoAcceleratorFactories* gpu_factories) | 48 ::media::GpuVideoAcceleratorFactories* gpu_factories) |
| 47 : media_task_runner_factory_( | 49 : media_task_runner_factory_( |
| 48 new BalancedMediaTaskRunnerFactory(kMaxDeltaFetcher)), | 50 new BalancedMediaTaskRunnerFactory(kMaxDeltaFetcher)), |
| 49 media_pipeline_(media_pipeline.Pass()), | 51 media_pipeline_(std::move(media_pipeline)), |
| 50 audio_pipeline_(media_pipeline_->GetAudioPipeline()), | 52 audio_pipeline_(media_pipeline_->GetAudioPipeline()), |
| 51 video_pipeline_(media_pipeline_->GetVideoPipeline()), | 53 video_pipeline_(media_pipeline_->GetVideoPipeline()), |
| 52 video_renderer_sink_(video_renderer_sink), | 54 video_renderer_sink_(video_renderer_sink), |
| 53 state_(kUninitialized), | 55 state_(kUninitialized), |
| 54 is_pending_transition_(false), | 56 is_pending_transition_(false), |
| 55 has_audio_(false), | 57 has_audio_(false), |
| 56 has_video_(false), | 58 has_video_(false), |
| 57 received_audio_eos_(false), | 59 received_audio_eos_(false), |
| 58 received_video_eos_(false), | 60 received_video_eos_(false), |
| 59 initial_natural_size_(gfx::Size()), | 61 initial_natural_size_(gfx::Size()), |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 base::Bind(&CmaRenderer::OnStatisticsUpdated, weak_this_)); | 268 base::Bind(&CmaRenderer::OnStatisticsUpdated, weak_this_)); |
| 267 audio_pipeline_->SetClient(av_pipeline_client); | 269 audio_pipeline_->SetClient(av_pipeline_client); |
| 268 | 270 |
| 269 scoped_ptr<CodedFrameProvider> frame_provider(new DemuxerStreamAdapter( | 271 scoped_ptr<CodedFrameProvider> frame_provider(new DemuxerStreamAdapter( |
| 270 base::ThreadTaskRunnerHandle::Get(), media_task_runner_factory_, stream)); | 272 base::ThreadTaskRunnerHandle::Get(), media_task_runner_factory_, stream)); |
| 271 | 273 |
| 272 const ::media::AudioDecoderConfig& config = stream->audio_decoder_config(); | 274 const ::media::AudioDecoderConfig& config = stream->audio_decoder_config(); |
| 273 if (config.codec() == ::media::kCodecAAC) | 275 if (config.codec() == ::media::kCodecAAC) |
| 274 stream->EnableBitstreamConverter(); | 276 stream->EnableBitstreamConverter(); |
| 275 | 277 |
| 276 media_pipeline_->InitializeAudio( | 278 media_pipeline_->InitializeAudio(config, std::move(frame_provider), |
| 277 config, frame_provider.Pass(), audio_initialization_done_cb); | 279 audio_initialization_done_cb); |
| 278 } | 280 } |
| 279 | 281 |
| 280 void CmaRenderer::OnAudioPipelineInitializeDone( | 282 void CmaRenderer::OnAudioPipelineInitializeDone( |
| 281 bool audio_stream_present, | 283 bool audio_stream_present, |
| 282 ::media::PipelineStatus status) { | 284 ::media::PipelineStatus status) { |
| 283 CMALOG(kLogControl) << __FUNCTION__ << ": state=" << state_; | 285 CMALOG(kLogControl) << __FUNCTION__ << ": state=" << state_; |
| 284 DCHECK(thread_checker_.CalledOnValidThread()); | 286 DCHECK(thread_checker_.CalledOnValidThread()); |
| 285 | 287 |
| 286 // OnError() may be fired at any time, even before initialization is complete. | 288 // OnError() may be fired at any time, even before initialization is complete. |
| 287 if (state_ == kError) | 289 if (state_ == kError) |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 base::ThreadTaskRunnerHandle::Get(), media_task_runner_factory_, stream)); | 336 base::ThreadTaskRunnerHandle::Get(), media_task_runner_factory_, stream)); |
| 335 | 337 |
| 336 const ::media::VideoDecoderConfig& config = stream->video_decoder_config(); | 338 const ::media::VideoDecoderConfig& config = stream->video_decoder_config(); |
| 337 if (config.codec() == ::media::kCodecH264) | 339 if (config.codec() == ::media::kCodecH264) |
| 338 stream->EnableBitstreamConverter(); | 340 stream->EnableBitstreamConverter(); |
| 339 | 341 |
| 340 initial_natural_size_ = config.natural_size(); | 342 initial_natural_size_ = config.natural_size(); |
| 341 | 343 |
| 342 std::vector<::media::VideoDecoderConfig> configs; | 344 std::vector<::media::VideoDecoderConfig> configs; |
| 343 configs.push_back(config); | 345 configs.push_back(config); |
| 344 media_pipeline_->InitializeVideo( | 346 media_pipeline_->InitializeVideo(configs, std::move(frame_provider), |
| 345 configs, frame_provider.Pass(), video_initialization_done_cb); | 347 video_initialization_done_cb); |
| 346 } | 348 } |
| 347 | 349 |
| 348 void CmaRenderer::OnVideoPipelineInitializeDone( | 350 void CmaRenderer::OnVideoPipelineInitializeDone( |
| 349 bool video_stream_present, | 351 bool video_stream_present, |
| 350 ::media::PipelineStatus status) { | 352 ::media::PipelineStatus status) { |
| 351 CMALOG(kLogControl) << __FUNCTION__ << ": state=" << state_; | 353 CMALOG(kLogControl) << __FUNCTION__ << ": state=" << state_; |
| 352 DCHECK(thread_checker_.CalledOnValidThread()); | 354 DCHECK(thread_checker_.CalledOnValidThread()); |
| 353 | 355 |
| 354 // OnError() may be fired at any time, even before initialization is complete. | 356 // OnError() may be fired at any time, even before initialization is complete. |
| 355 if (state_ == kError) | 357 if (state_ == kError) |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 483 is_pending_transition_ = true; | 485 is_pending_transition_ = true; |
| 484 } | 486 } |
| 485 | 487 |
| 486 void CmaRenderer::CompleteStateTransition(State new_state) { | 488 void CmaRenderer::CompleteStateTransition(State new_state) { |
| 487 state_ = new_state; | 489 state_ = new_state; |
| 488 is_pending_transition_ = false; | 490 is_pending_transition_ = false; |
| 489 } | 491 } |
| 490 | 492 |
| 491 } // namespace media | 493 } // namespace media |
| 492 } // namespace chromecast | 494 } // namespace chromecast |
| OLD | NEW |