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" |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 void VideoPipelineImpl::SetCdm(BrowserCdmCast* media_keys) { | 94 void VideoPipelineImpl::SetCdm(BrowserCdmCast* media_keys) { |
95 av_pipeline_impl_->SetCdm(media_keys); | 95 av_pipeline_impl_->SetCdm(media_keys); |
96 } | 96 } |
97 | 97 |
98 void VideoPipelineImpl::SetClient(const VideoPipelineClient& client) { | 98 void VideoPipelineImpl::SetClient(const VideoPipelineClient& client) { |
99 video_client_ = client; | 99 video_client_ = client; |
100 av_pipeline_impl_->SetClient(client.av_pipeline_client); | 100 av_pipeline_impl_->SetClient(client.av_pipeline_client); |
101 } | 101 } |
102 | 102 |
103 void VideoPipelineImpl::Initialize( | 103 void VideoPipelineImpl::Initialize( |
104 const ::media::VideoDecoderConfig& video_config, | 104 const std::vector<::media::VideoDecoderConfig>& configs, |
105 scoped_ptr<CodedFrameProvider> frame_provider, | 105 scoped_ptr<CodedFrameProvider> frame_provider, |
106 const ::media::PipelineStatusCB& status_cb) { | 106 const ::media::PipelineStatusCB& status_cb) { |
107 CMALOG(kLogControl) << "VideoPipelineImpl::Initialize " | 107 CMALOG(kLogControl) << __FUNCTION__ << " config (" << configs.size() << ")"; |
108 << video_config.AsHumanReadableString(); | |
109 VideoPipelineDevice::VideoClient client; | 108 VideoPipelineDevice::VideoClient client; |
110 client.natural_size_changed_cb = | 109 client.natural_size_changed_cb = |
111 base::Bind(&VideoPipelineImpl::OnNaturalSizeChanged, weak_this_); | 110 base::Bind(&VideoPipelineImpl::OnNaturalSizeChanged, weak_this_); |
112 video_device_->SetVideoClient(client); | 111 video_device_->SetVideoClient(client); |
113 if (frame_provider) | 112 if (frame_provider) |
114 SetCodedFrameProvider(frame_provider.Pass()); | 113 SetCodedFrameProvider(frame_provider.Pass()); |
115 | 114 |
116 if (!video_device_->SetConfig( | 115 if (configs.empty()) { |
117 DecoderConfigAdapter::ToCastVideoConfig(kPrimary, video_config)) || | 116 status_cb.Run(::media::PIPELINE_ERROR_INITIALIZATION_FAILED); |
| 117 return; |
| 118 } |
| 119 DCHECK(configs.size() <= 2); |
| 120 DCHECK(configs[0].IsValidConfig()); |
| 121 VideoConfig video_config = |
| 122 DecoderConfigAdapter::ToCastVideoConfig(kPrimary, configs[0]); |
| 123 VideoConfig secondary_config; |
| 124 if (configs.size() == 2) { |
| 125 DCHECK(configs[1].IsValidConfig()); |
| 126 secondary_config = DecoderConfigAdapter::ToCastVideoConfig(kSecondary, |
| 127 configs[1]); |
| 128 video_config.additional_config = &secondary_config; |
| 129 } |
| 130 |
| 131 if (!video_device_->SetConfig(video_config) || |
118 !av_pipeline_impl_->Initialize()) { | 132 !av_pipeline_impl_->Initialize()) { |
119 status_cb.Run(::media::PIPELINE_ERROR_INITIALIZATION_FAILED); | 133 status_cb.Run(::media::PIPELINE_ERROR_INITIALIZATION_FAILED); |
120 return; | 134 return; |
121 } | 135 } |
122 av_pipeline_impl_->TransitionToState(AvPipelineImpl::kFlushed); | 136 av_pipeline_impl_->TransitionToState(AvPipelineImpl::kFlushed); |
123 status_cb.Run(::media::PIPELINE_OK); | 137 status_cb.Run(::media::PIPELINE_OK); |
124 } | 138 } |
125 | 139 |
126 void VideoPipelineImpl::OnUpdateConfig( | 140 void VideoPipelineImpl::OnUpdateConfig( |
127 StreamId id, | 141 StreamId id, |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 delta_stats.video_frames_dropped = | 184 delta_stats.video_frames_dropped = |
171 current_stats.video_frames_dropped - previous_stats_.video_frames_dropped; | 185 current_stats.video_frames_dropped - previous_stats_.video_frames_dropped; |
172 | 186 |
173 previous_stats_ = current_stats; | 187 previous_stats_ = current_stats; |
174 | 188 |
175 video_client_.av_pipeline_client.statistics_cb.Run(delta_stats); | 189 video_client_.av_pipeline_client.statistics_cb.Run(delta_stats); |
176 } | 190 } |
177 | 191 |
178 } // namespace media | 192 } // namespace media |
179 } // namespace chromecast | 193 } // namespace chromecast |
OLD | NEW |