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

Side by Side Diff: webrtc/media/engine/webrtcvideoengine2.cc

Issue 2047513002: Add proper lifetime of encoder-specific settings. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: typo Created 4 years, 6 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
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2014 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 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 stream.target_bitrate_bps = stream.max_bitrate_bps = max_bitrate_bps; 422 stream.target_bitrate_bps = stream.max_bitrate_bps = max_bitrate_bps;
423 423
424 int max_qp = kDefaultQpMax; 424 int max_qp = kDefaultQpMax;
425 codec.GetParam(kCodecParamMaxQuantization, &max_qp); 425 codec.GetParam(kCodecParamMaxQuantization, &max_qp);
426 stream.max_qp = max_qp; 426 stream.max_qp = max_qp;
427 std::vector<webrtc::VideoStream> streams; 427 std::vector<webrtc::VideoStream> streams;
428 streams.push_back(stream); 428 streams.push_back(stream);
429 return streams; 429 return streams;
430 } 430 }
431 431
432 void* WebRtcVideoChannel2::WebRtcVideoSendStream::ConfigureVideoEncoderSettings( 432 rtc::scoped_refptr<webrtc::VideoEncoderConfig::EncoderSpecificSettings>
433 WebRtcVideoChannel2::WebRtcVideoSendStream::ConfigureVideoEncoderSettings(
433 const VideoCodec& codec) { 434 const VideoCodec& codec) {
434 bool is_screencast = parameters_.options.is_screencast.value_or(false); 435 bool is_screencast = parameters_.options.is_screencast.value_or(false);
435 // No automatic resizing when using simulcast or screencast. 436 // No automatic resizing when using simulcast or screencast.
436 bool automatic_resize = 437 bool automatic_resize =
437 !is_screencast && parameters_.config.rtp.ssrcs.size() == 1; 438 !is_screencast && parameters_.config.rtp.ssrcs.size() == 1;
438 bool frame_dropping = !is_screencast; 439 bool frame_dropping = !is_screencast;
439 bool denoising; 440 bool denoising;
440 bool codec_default_denoising = false; 441 bool codec_default_denoising = false;
441 if (is_screencast) { 442 if (is_screencast) {
442 denoising = false; 443 denoising = false;
443 } else { 444 } else {
444 // Use codec default if video_noise_reduction is unset. 445 // Use codec default if video_noise_reduction is unset.
445 codec_default_denoising = !parameters_.options.video_noise_reduction; 446 codec_default_denoising = !parameters_.options.video_noise_reduction;
446 denoising = parameters_.options.video_noise_reduction.value_or(false); 447 denoising = parameters_.options.video_noise_reduction.value_or(false);
447 } 448 }
448 449
449 if (CodecNamesEq(codec.name, kH264CodecName)) { 450 if (CodecNamesEq(codec.name, kH264CodecName)) {
450 encoder_settings_.h264 = webrtc::VideoEncoder::GetDefaultH264Settings(); 451 webrtc::VideoCodecH264 h264_settings =
451 encoder_settings_.h264.frameDroppingOn = frame_dropping; 452 webrtc::VideoEncoder::GetDefaultH264Settings();
452 return &encoder_settings_.h264; 453 h264_settings.frameDroppingOn = frame_dropping;
454 return new rtc::RefCountedObject<
455 webrtc::VideoEncoderConfig::H264EncoderSpecificSettings>(h264_settings);
453 } 456 }
454 if (CodecNamesEq(codec.name, kVp8CodecName)) { 457 if (CodecNamesEq(codec.name, kVp8CodecName)) {
455 encoder_settings_.vp8 = webrtc::VideoEncoder::GetDefaultVp8Settings(); 458 webrtc::VideoCodecVP8 vp8_settings =
456 encoder_settings_.vp8.automaticResizeOn = automatic_resize; 459 webrtc::VideoEncoder::GetDefaultVp8Settings();
460 vp8_settings.automaticResizeOn = automatic_resize;
457 // VP8 denoising is enabled by default. 461 // VP8 denoising is enabled by default.
458 encoder_settings_.vp8.denoisingOn = 462 vp8_settings.denoisingOn = codec_default_denoising ? true : denoising;
459 codec_default_denoising ? true : denoising; 463 vp8_settings.frameDroppingOn = frame_dropping;
460 encoder_settings_.vp8.frameDroppingOn = frame_dropping; 464 return new rtc::RefCountedObject<
461 return &encoder_settings_.vp8; 465 webrtc::VideoEncoderConfig::Vp8EncoderSpecificSettings>(vp8_settings);
462 } 466 }
463 if (CodecNamesEq(codec.name, kVp9CodecName)) { 467 if (CodecNamesEq(codec.name, kVp9CodecName)) {
464 encoder_settings_.vp9 = webrtc::VideoEncoder::GetDefaultVp9Settings(); 468 webrtc::VideoCodecVP9 vp9_settings =
469 webrtc::VideoEncoder::GetDefaultVp9Settings();
465 if (is_screencast) { 470 if (is_screencast) {
466 // TODO(asapersson): Set to 2 for now since there is a DCHECK in 471 // TODO(asapersson): Set to 2 for now since there is a DCHECK in
467 // VideoSendStream::ReconfigureVideoEncoder. 472 // VideoSendStream::ReconfigureVideoEncoder.
468 encoder_settings_.vp9.numberOfSpatialLayers = 2; 473 vp9_settings.numberOfSpatialLayers = 2;
469 } else { 474 } else {
470 encoder_settings_.vp9.numberOfSpatialLayers = 475 vp9_settings.numberOfSpatialLayers = GetDefaultVp9SpatialLayers();
471 GetDefaultVp9SpatialLayers();
472 } 476 }
473 // VP9 denoising is disabled by default. 477 // VP9 denoising is disabled by default.
474 encoder_settings_.vp9.denoisingOn = 478 vp9_settings.denoisingOn = codec_default_denoising ? false : denoising;
475 codec_default_denoising ? false : denoising; 479 vp9_settings.frameDroppingOn = frame_dropping;
476 encoder_settings_.vp9.frameDroppingOn = frame_dropping; 480 return new rtc::RefCountedObject<
477 return &encoder_settings_.vp9; 481 webrtc::VideoEncoderConfig::Vp9EncoderSpecificSettings>(vp9_settings);
478 } 482 }
479 return NULL; 483 return nullptr;
480 } 484 }
481 485
482 DefaultUnsignalledSsrcHandler::DefaultUnsignalledSsrcHandler() 486 DefaultUnsignalledSsrcHandler::DefaultUnsignalledSsrcHandler()
483 : default_recv_ssrc_(0), default_sink_(NULL) {} 487 : default_recv_ssrc_(0), default_sink_(NULL) {}
484 488
485 UnsignalledSsrcHandler::Action DefaultUnsignalledSsrcHandler::OnUnsignalledSsrc( 489 UnsignalledSsrcHandler::Action DefaultUnsignalledSsrcHandler::OnUnsignalledSsrc(
486 WebRtcVideoChannel2* channel, 490 WebRtcVideoChannel2* channel,
487 uint32_t ssrc) { 491 uint32_t ssrc) {
488 if (default_recv_ssrc_ != 0) { // Already one default stream. 492 if (default_recv_ssrc_ != 0) { // Already one default stream.
489 LOG(LS_WARNING) << "Unknown SSRC, but default receive stream already set."; 493 LOG(LS_WARNING) << "Unknown SSRC, but default receive stream already set.";
(...skipping 2120 matching lines...) Expand 10 before | Expand all | Expand 10 after
2610 rtx_mapping[video_codecs[i].codec.id] != 2614 rtx_mapping[video_codecs[i].codec.id] !=
2611 fec_settings.red_payload_type) { 2615 fec_settings.red_payload_type) {
2612 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id]; 2616 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id];
2613 } 2617 }
2614 } 2618 }
2615 2619
2616 return video_codecs; 2620 return video_codecs;
2617 } 2621 }
2618 2622
2619 } // namespace cricket 2623 } // namespace cricket
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698