Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(264)

Side by Side Diff: webrtc/video/vie_encoder.cc

Issue 1600973002: Initialize VideoEncoder objects asynchronously. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: rename new_codec_settings Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/video/vie_encoder.h ('k') | webrtc/video_send_stream.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 void ViEEncoder::Pause() { 183 void ViEEncoder::Pause() {
184 CriticalSectionScoped cs(data_cs_.get()); 184 CriticalSectionScoped cs(data_cs_.get());
185 encoder_paused_ = true; 185 encoder_paused_ = true;
186 } 186 }
187 187
188 void ViEEncoder::Restart() { 188 void ViEEncoder::Restart() {
189 CriticalSectionScoped cs(data_cs_.get()); 189 CriticalSectionScoped cs(data_cs_.get());
190 encoder_paused_ = false; 190 encoder_paused_ = false;
191 } 191 }
192 192
193 int32_t ViEEncoder::RegisterExternalEncoder(webrtc::VideoEncoder* encoder, 193 void ViEEncoder::SetEncoder(const webrtc::VideoCodec& video_codec) {
194 uint8_t pl_type,
195 bool internal_source) {
196 if (vcm_->RegisterExternalEncoder(encoder, pl_type, internal_source) !=
197 VCM_OK) {
198 return -1;
199 }
200 return 0;
201 }
202
203 int32_t ViEEncoder::DeRegisterExternalEncoder(uint8_t pl_type) {
204 if (vcm_->RegisterExternalEncoder(NULL, pl_type) != VCM_OK) {
205 return -1;
206 }
207 return 0;
208 }
209
210 int32_t ViEEncoder::SetEncoder(const webrtc::VideoCodec& video_codec) {
211 RTC_DCHECK(send_payload_router_ != NULL); 194 RTC_DCHECK(send_payload_router_ != NULL);
212 // Setting target width and height for VPM. 195 // Setting target width and height for VPM.
213 if (vp_->SetTargetResolution(video_codec.width, video_codec.height, 196 RTC_CHECK_EQ(VPM_OK,
214 video_codec.maxFramerate) != VPM_OK) { 197 vp_->SetTargetResolution(video_codec.width, video_codec.height,
215 return -1; 198 video_codec.maxFramerate));
216 }
217 199
218 // Cache codec before calling AddBitrateObserver (which calls OnNetworkChanged 200 // Cache codec before calling AddBitrateObserver (which calls OnNetworkChanged
219 // that makes use of the number of simulcast streams configured). 201 // that makes use of the number of simulcast streams configured).
220 { 202 {
221 CriticalSectionScoped cs(data_cs_.get()); 203 CriticalSectionScoped cs(data_cs_.get());
222 encoder_config_ = video_codec; 204 encoder_config_ = video_codec;
223 } 205 }
224 206
225 // Add a bitrate observer to the allocator and update the start, max and 207 // Add a bitrate observer to the allocator and update the start, max and
226 // min bitrates of the bitrate controller as needed. 208 // min bitrates of the bitrate controller as needed.
227 int allocated_bitrate_bps = bitrate_allocator_->AddBitrateObserver( 209 int allocated_bitrate_bps = bitrate_allocator_->AddBitrateObserver(
228 bitrate_observer_.get(), video_codec.minBitrate * 1000, 210 bitrate_observer_.get(), video_codec.minBitrate * 1000,
229 video_codec.maxBitrate * 1000); 211 video_codec.maxBitrate * 1000);
230 212
231 webrtc::VideoCodec modified_video_codec = video_codec; 213 webrtc::VideoCodec modified_video_codec = video_codec;
232 modified_video_codec.startBitrate = allocated_bitrate_bps / 1000; 214 modified_video_codec.startBitrate = allocated_bitrate_bps / 1000;
233 215
234 size_t max_data_payload_length = send_payload_router_->MaxPayloadLength(); 216 size_t max_data_payload_length = send_payload_router_->MaxPayloadLength();
235 if (vcm_->RegisterSendCodec(&modified_video_codec, number_of_cores_, 217 RTC_CHECK_EQ(VCM_OK, vcm_->RegisterSendCodec(
236 static_cast<uint32_t>(max_data_payload_length)) != 218 &modified_video_codec, number_of_cores_,
237 VCM_OK) { 219 static_cast<uint32_t>(max_data_payload_length)));
238 return -1; 220 }
239 } 221
240 return 0; 222 VideoCodingModule* ViEEncoder::vcm() const {
223 return vcm_.get();
241 } 224 }
242 225
243 int ViEEncoder::GetPaddingNeededBps() const { 226 int ViEEncoder::GetPaddingNeededBps() const {
244 int64_t time_of_last_frame_activity_ms; 227 int64_t time_of_last_frame_activity_ms;
245 int min_transmit_bitrate_bps; 228 int min_transmit_bitrate_bps;
246 int bitrate_bps; 229 int bitrate_bps;
247 VideoCodec send_codec; 230 VideoCodec send_codec;
248 { 231 {
249 CriticalSectionScoped cs(data_cs_.get()); 232 CriticalSectionScoped cs(data_cs_.get());
250 bool send_padding = encoder_config_.numberOfSimulcastStreams > 1 || 233 bool send_padding = encoder_config_.numberOfSimulcastStreams > 1 ||
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
596 579
597 if (!video_suspension_changed) 580 if (!video_suspension_changed)
598 return; 581 return;
599 // Video suspend-state changed, inform codec observer. 582 // Video suspend-state changed, inform codec observer.
600 LOG(LS_INFO) << "Video suspend state changed " << video_is_suspended 583 LOG(LS_INFO) << "Video suspend state changed " << video_is_suspended
601 << " for ssrc " << first_ssrc; 584 << " for ssrc " << first_ssrc;
602 if (stats_proxy_) 585 if (stats_proxy_)
603 stats_proxy_->OnSuspendChange(video_is_suspended); 586 stats_proxy_->OnSuspendChange(video_is_suspended);
604 } 587 }
605 588
606 void ViEEncoder::SuspendBelowMinBitrate() {
607 vcm_->SuspendBelowMinBitrate();
608 bitrate_allocator_->EnforceMinBitrate(false);
609 }
610
611 void ViEEncoder::RegisterPostEncodeImageCallback( 589 void ViEEncoder::RegisterPostEncodeImageCallback(
612 EncodedImageCallback* post_encode_callback) { 590 EncodedImageCallback* post_encode_callback) {
613 vcm_->RegisterPostEncodeImageCallback(post_encode_callback); 591 vcm_->RegisterPostEncodeImageCallback(post_encode_callback);
614 } 592 }
615 593
616 QMVideoSettingsCallback::QMVideoSettingsCallback(VideoProcessing* vpm) 594 QMVideoSettingsCallback::QMVideoSettingsCallback(VideoProcessing* vpm)
617 : vp_(vpm) { 595 : vp_(vpm) {
618 } 596 }
619 597
620 QMVideoSettingsCallback::~QMVideoSettingsCallback() { 598 QMVideoSettingsCallback::~QMVideoSettingsCallback() {
621 } 599 }
622 600
623 int32_t QMVideoSettingsCallback::SetVideoQMSettings( 601 int32_t QMVideoSettingsCallback::SetVideoQMSettings(
624 const uint32_t frame_rate, 602 const uint32_t frame_rate,
625 const uint32_t width, 603 const uint32_t width,
626 const uint32_t height) { 604 const uint32_t height) {
627 return vp_->SetTargetResolution(width, height, frame_rate); 605 return vp_->SetTargetResolution(width, height, frame_rate);
628 } 606 }
629 607
630 void QMVideoSettingsCallback::SetTargetFramerate(int frame_rate) { 608 void QMVideoSettingsCallback::SetTargetFramerate(int frame_rate) {
631 vp_->SetTargetFramerate(frame_rate); 609 vp_->SetTargetFramerate(frame_rate);
632 } 610 }
633 611
634 } // namespace webrtc 612 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/video/vie_encoder.h ('k') | webrtc/video_send_stream.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698