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::ToCastVideoConfig(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 = video_device_->SetConfig( |
| 134 DecoderConfigAdapter::ToCastVideoConfig(video_config)); |
131 if (!success && | 135 if (!success && |
132 !video_client_.av_pipeline_client.playback_error_cb.is_null()) { | 136 !video_client_.av_pipeline_client.playback_error_cb.is_null()) { |
133 video_client_.av_pipeline_client.playback_error_cb.Run( | 137 video_client_.av_pipeline_client.playback_error_cb.Run( |
134 ::media::PIPELINE_ERROR_DECODE); | 138 ::media::PIPELINE_ERROR_DECODE); |
135 } | 139 } |
136 } | 140 } |
137 } | 141 } |
138 | 142 |
139 void VideoPipelineImpl::OnNaturalSizeChanged(const gfx::Size& size) { | 143 void VideoPipelineImpl::OnNaturalSizeChanged(const gfx::Size& size) { |
140 if (av_pipeline_impl_->GetState() != AvPipelineImpl::kPlaying) | 144 if (av_pipeline_impl_->GetState() != AvPipelineImpl::kPlaying) |
(...skipping 24 matching lines...) Expand all Loading... |
165 delta_stats.video_frames_dropped = | 169 delta_stats.video_frames_dropped = |
166 current_stats.video_frames_dropped - previous_stats_.video_frames_dropped; | 170 current_stats.video_frames_dropped - previous_stats_.video_frames_dropped; |
167 | 171 |
168 previous_stats_ = current_stats; | 172 previous_stats_ = current_stats; |
169 | 173 |
170 video_client_.av_pipeline_client.statistics_cb.Run(delta_stats); | 174 video_client_.av_pipeline_client.statistics_cb.Run(delta_stats); |
171 } | 175 } |
172 | 176 |
173 } // namespace media | 177 } // namespace media |
174 } // namespace chromecast | 178 } // namespace chromecast |
OLD | NEW |