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