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" | |
9 #include "chromecast/media/cma/base/buffering_defs.h" | 8 #include "chromecast/media/cma/base/buffering_defs.h" |
10 #include "chromecast/media/cma/base/cma_logging.h" | 9 #include "chromecast/media/cma/base/cma_logging.h" |
11 #include "chromecast/media/cma/base/coded_frame_provider.h" | 10 #include "chromecast/media/cma/base/coded_frame_provider.h" |
12 #include "chromecast/media/cma/base/decoder_config_adapter.h" | 11 #include "chromecast/media/cma/base/decoder_config_adapter.h" |
13 #include "chromecast/media/cma/pipeline/av_pipeline_impl.h" | 12 #include "chromecast/media/cma/pipeline/av_pipeline_impl.h" |
| 13 #include "chromecast/media/cma/pipeline/video_pipeline_device_client_impl.h" |
| 14 #include "chromecast/public/graphics_types.h" |
14 #include "chromecast/public/media/decoder_config.h" | 15 #include "chromecast/public/media/decoder_config.h" |
| 16 #include "chromecast/public/media/video_pipeline_device.h" |
15 #include "media/base/video_decoder_config.h" | 17 #include "media/base/video_decoder_config.h" |
16 | 18 |
17 namespace chromecast { | 19 namespace chromecast { |
18 namespace media { | 20 namespace media { |
19 | 21 |
20 namespace { | 22 namespace { |
21 const size_t kMaxVideoFrameSize = 1024 * 1024; | 23 const size_t kMaxVideoFrameSize = 1024 * 1024; |
22 } | 24 } |
23 | 25 |
24 VideoPipelineImpl::VideoPipelineImpl(VideoPipelineDevice* video_device) | 26 VideoPipelineImpl::VideoPipelineImpl(VideoPipelineDevice* video_device) |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 | 104 |
103 void VideoPipelineImpl::Initialize( | 105 void VideoPipelineImpl::Initialize( |
104 const std::vector<::media::VideoDecoderConfig>& configs, | 106 const std::vector<::media::VideoDecoderConfig>& configs, |
105 scoped_ptr<CodedFrameProvider> frame_provider, | 107 scoped_ptr<CodedFrameProvider> frame_provider, |
106 const ::media::PipelineStatusCB& status_cb) { | 108 const ::media::PipelineStatusCB& status_cb) { |
107 DCHECK_GT(configs.size(), 0u); | 109 DCHECK_GT(configs.size(), 0u); |
108 for (const auto& config : configs) { | 110 for (const auto& config : configs) { |
109 CMALOG(kLogControl) << __FUNCTION__ << " " | 111 CMALOG(kLogControl) << __FUNCTION__ << " " |
110 << config.AsHumanReadableString(); | 112 << config.AsHumanReadableString(); |
111 } | 113 } |
112 VideoPipelineDevice::VideoClient client; | 114 video_device_->SetVideoClient(new VideoPipelineDeviceClientImpl( |
113 client.natural_size_changed_cb = | 115 base::Bind(&VideoPipelineImpl::OnNaturalSizeChanged, weak_this_))); |
114 base::Bind(&VideoPipelineImpl::OnNaturalSizeChanged, weak_this_); | |
115 video_device_->SetVideoClient(client); | |
116 if (frame_provider) | 116 if (frame_provider) |
117 SetCodedFrameProvider(frame_provider.Pass()); | 117 SetCodedFrameProvider(frame_provider.Pass()); |
118 | 118 |
119 if (configs.empty()) { | 119 if (configs.empty()) { |
120 status_cb.Run(::media::PIPELINE_ERROR_INITIALIZATION_FAILED); | 120 status_cb.Run(::media::PIPELINE_ERROR_INITIALIZATION_FAILED); |
121 return; | 121 return; |
122 } | 122 } |
123 DCHECK(configs.size() <= 2); | 123 DCHECK(configs.size() <= 2); |
124 DCHECK(configs[0].IsValidConfig()); | 124 DCHECK(configs[0].IsValidConfig()); |
125 VideoConfig video_config = | 125 VideoConfig video_config = |
(...skipping 26 matching lines...) Expand all Loading... |
152 bool success = video_device_->SetConfig( | 152 bool success = video_device_->SetConfig( |
153 DecoderConfigAdapter::ToCastVideoConfig(id, video_config)); | 153 DecoderConfigAdapter::ToCastVideoConfig(id, video_config)); |
154 if (!success && | 154 if (!success && |
155 !video_client_.av_pipeline_client.playback_error_cb.is_null()) { | 155 !video_client_.av_pipeline_client.playback_error_cb.is_null()) { |
156 video_client_.av_pipeline_client.playback_error_cb.Run( | 156 video_client_.av_pipeline_client.playback_error_cb.Run( |
157 ::media::PIPELINE_ERROR_DECODE); | 157 ::media::PIPELINE_ERROR_DECODE); |
158 } | 158 } |
159 } | 159 } |
160 } | 160 } |
161 | 161 |
162 void VideoPipelineImpl::OnNaturalSizeChanged(const gfx::Size& size) { | 162 void VideoPipelineImpl::OnNaturalSizeChanged(const Size& size) { |
163 if (av_pipeline_impl_->GetState() != AvPipelineImpl::kPlaying) | 163 if (av_pipeline_impl_->GetState() != AvPipelineImpl::kPlaying) |
164 return; | 164 return; |
165 | 165 |
166 if (!video_client_.natural_size_changed_cb.is_null()) | 166 if (!video_client_.natural_size_changed_cb.is_null()) { |
167 video_client_.natural_size_changed_cb.Run(size); | 167 video_client_.natural_size_changed_cb.Run( |
| 168 gfx::Size(size.width, size.height)); |
| 169 } |
168 } | 170 } |
169 | 171 |
170 void VideoPipelineImpl::UpdateStatistics() { | 172 void VideoPipelineImpl::UpdateStatistics() { |
171 if (video_client_.av_pipeline_client.statistics_cb.is_null()) | 173 if (video_client_.av_pipeline_client.statistics_cb.is_null()) |
172 return; | 174 return; |
173 | 175 |
174 MediaComponentDevice::Statistics device_stats; | 176 MediaComponentDevice::Statistics device_stats; |
175 if (!video_device_->GetStatistics(&device_stats)) | 177 if (!video_device_->GetStatistics(&device_stats)) |
176 return; | 178 return; |
177 | 179 |
(...skipping 10 matching lines...) Expand all Loading... |
188 delta_stats.video_frames_dropped = | 190 delta_stats.video_frames_dropped = |
189 current_stats.video_frames_dropped - previous_stats_.video_frames_dropped; | 191 current_stats.video_frames_dropped - previous_stats_.video_frames_dropped; |
190 | 192 |
191 previous_stats_ = current_stats; | 193 previous_stats_ = current_stats; |
192 | 194 |
193 video_client_.av_pipeline_client.statistics_cb.Run(delta_stats); | 195 video_client_.av_pipeline_client.statistics_cb.Run(delta_stats); |
194 } | 196 } |
195 | 197 |
196 } // namespace media | 198 } // namespace media |
197 } // namespace chromecast | 199 } // namespace chromecast |
OLD | NEW |