| 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/media/cma/pipeline/video_pipeline_impl.h" | 5 #include "chromecast/media/cma/pipeline/video_pipeline_impl.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "chromecast/media/cma/backend/video_pipeline_device.h" | 8 #include "chromecast/media/cma/backend/video_pipeline_device.h" |
| 9 #include "chromecast/media/cma/base/buffering_defs.h" | 9 #include "chromecast/media/cma/base/buffering_defs.h" |
| 10 #include "chromecast/media/cma/base/cma_logging.h" | 10 #include "chromecast/media/cma/base/cma_logging.h" |
| 11 #include "chromecast/media/cma/base/coded_frame_provider.h" | 11 #include "chromecast/media/cma/base/coded_frame_provider.h" |
| 12 #include "chromecast/media/cma/base/decoder_config_adapter.h" |
| 12 #include "chromecast/media/cma/pipeline/av_pipeline_impl.h" | 13 #include "chromecast/media/cma/pipeline/av_pipeline_impl.h" |
| 14 #include "chromecast/media/cma/public/audio_config.h" |
| 15 #include "chromecast/media/cma/public/video_config.h" |
| 13 #include "media/base/video_decoder_config.h" | 16 #include "media/base/video_decoder_config.h" |
| 14 | 17 |
| 15 namespace chromecast { | 18 namespace chromecast { |
| 16 namespace media { | 19 namespace media { |
| 17 | 20 |
| 18 namespace { | 21 namespace { |
| 19 const size_t kMaxVideoFrameSize = 1024 * 1024; | 22 const size_t kMaxVideoFrameSize = 1024 * 1024; |
| 20 } | 23 } |
| 21 | 24 |
| 22 VideoPipelineImpl::VideoPipelineImpl(VideoPipelineDevice* video_device) | 25 VideoPipelineImpl::VideoPipelineImpl(VideoPipelineDevice* video_device) |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 const ::media::PipelineStatusCB& status_cb) { | 107 const ::media::PipelineStatusCB& status_cb) { |
| 105 CMALOG(kLogControl) << "VideoPipelineImpl::Initialize " | 108 CMALOG(kLogControl) << "VideoPipelineImpl::Initialize " |
| 106 << video_config.AsHumanReadableString(); | 109 << video_config.AsHumanReadableString(); |
| 107 VideoPipelineDevice::VideoClient client; | 110 VideoPipelineDevice::VideoClient client; |
| 108 client.natural_size_changed_cb = | 111 client.natural_size_changed_cb = |
| 109 base::Bind(&VideoPipelineImpl::OnNaturalSizeChanged, weak_this_); | 112 base::Bind(&VideoPipelineImpl::OnNaturalSizeChanged, weak_this_); |
| 110 video_device_->SetVideoClient(client); | 113 video_device_->SetVideoClient(client); |
| 111 if (frame_provider) | 114 if (frame_provider) |
| 112 SetCodedFrameProvider(frame_provider.Pass()); | 115 SetCodedFrameProvider(frame_provider.Pass()); |
| 113 | 116 |
| 114 if (!video_device_->SetConfig(video_config) || | 117 if (!video_device_->SetConfig( |
| 118 DecoderConfigAdapter::ToVideoConfig(video_config)) || |
| 115 !av_pipeline_impl_->Initialize()) { | 119 !av_pipeline_impl_->Initialize()) { |
| 116 status_cb.Run(::media::PIPELINE_ERROR_INITIALIZATION_FAILED); | 120 status_cb.Run(::media::PIPELINE_ERROR_INITIALIZATION_FAILED); |
| 117 return; | 121 return; |
| 118 } | 122 } |
| 119 av_pipeline_impl_->TransitionToState(AvPipelineImpl::kFlushed); | 123 av_pipeline_impl_->TransitionToState(AvPipelineImpl::kFlushed); |
| 120 status_cb.Run(::media::PIPELINE_OK); | 124 status_cb.Run(::media::PIPELINE_OK); |
| 121 } | 125 } |
| 122 | 126 |
| 123 void VideoPipelineImpl::OnUpdateConfig( | 127 void VideoPipelineImpl::OnUpdateConfig( |
| 124 const ::media::AudioDecoderConfig& audio_config, | 128 const ::media::AudioDecoderConfig& audio_config, |
| 125 const ::media::VideoDecoderConfig& video_config) { | 129 const ::media::VideoDecoderConfig& video_config) { |
| 126 if (video_config.IsValidConfig()) { | 130 if (video_config.IsValidConfig()) { |
| 127 CMALOG(kLogControl) << "VideoPipelineImpl::OnUpdateConfig " | 131 CMALOG(kLogControl) << "VideoPipelineImpl::OnUpdateConfig " |
| 128 << video_config.AsHumanReadableString(); | 132 << video_config.AsHumanReadableString(); |
| 129 | 133 |
| 130 bool success = video_device_->SetConfig(video_config); | 134 bool success = |
| 135 video_device_->SetConfig( |
| 136 DecoderConfigAdapter::ToVideoConfig(video_config)); |
| 131 if (!success && | 137 if (!success && |
| 132 !video_client_.av_pipeline_client.playback_error_cb.is_null()) { | 138 !video_client_.av_pipeline_client.playback_error_cb.is_null()) { |
| 133 video_client_.av_pipeline_client.playback_error_cb.Run( | 139 video_client_.av_pipeline_client.playback_error_cb.Run( |
| 134 ::media::PIPELINE_ERROR_DECODE); | 140 ::media::PIPELINE_ERROR_DECODE); |
| 135 } | 141 } |
| 136 } | 142 } |
| 137 } | 143 } |
| 138 | 144 |
| 139 void VideoPipelineImpl::OnNaturalSizeChanged(const gfx::Size& size) { | 145 void VideoPipelineImpl::OnNaturalSizeChanged(const gfx::Size& size) { |
| 140 if (av_pipeline_impl_->GetState() != AvPipelineImpl::kPlaying) | 146 if (av_pipeline_impl_->GetState() != AvPipelineImpl::kPlaying) |
| (...skipping 24 matching lines...) Expand all Loading... |
| 165 delta_stats.video_frames_dropped = | 171 delta_stats.video_frames_dropped = |
| 166 current_stats.video_frames_dropped - previous_stats_.video_frames_dropped; | 172 current_stats.video_frames_dropped - previous_stats_.video_frames_dropped; |
| 167 | 173 |
| 168 previous_stats_ = current_stats; | 174 previous_stats_ = current_stats; |
| 169 | 175 |
| 170 video_client_.av_pipeline_client.statistics_cb.Run(delta_stats); | 176 video_client_.av_pipeline_client.statistics_cb.Run(delta_stats); |
| 171 } | 177 } |
| 172 | 178 |
| 173 } // namespace media | 179 } // namespace media |
| 174 } // namespace chromecast | 180 } // namespace chromecast |
| OLD | NEW |