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

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: feedback Created 4 years, 4 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 428 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 stream.target_bitrate_bps = stream.max_bitrate_bps = max_bitrate_bps; 439 stream.target_bitrate_bps = stream.max_bitrate_bps = max_bitrate_bps;
440 440
441 int max_qp = kDefaultQpMax; 441 int max_qp = kDefaultQpMax;
442 codec.GetParam(kCodecParamMaxQuantization, &max_qp); 442 codec.GetParam(kCodecParamMaxQuantization, &max_qp);
443 stream.max_qp = max_qp; 443 stream.max_qp = max_qp;
444 std::vector<webrtc::VideoStream> streams; 444 std::vector<webrtc::VideoStream> streams;
445 streams.push_back(stream); 445 streams.push_back(stream);
446 return streams; 446 return streams;
447 } 447 }
448 448
449 void* WebRtcVideoChannel2::WebRtcVideoSendStream::ConfigureVideoEncoderSettings( 449 rtc::scoped_refptr<webrtc::VideoEncoderConfig::EncoderSpecificSettings>
450 WebRtcVideoChannel2::WebRtcVideoSendStream::ConfigureVideoEncoderSettings(
450 const VideoCodec& codec) { 451 const VideoCodec& codec) {
451 bool is_screencast = parameters_.options.is_screencast.value_or(false); 452 bool is_screencast = parameters_.options.is_screencast.value_or(false);
452 // No automatic resizing when using simulcast or screencast. 453 // No automatic resizing when using simulcast or screencast.
453 bool automatic_resize = 454 bool automatic_resize =
454 !is_screencast && parameters_.config.rtp.ssrcs.size() == 1; 455 !is_screencast && parameters_.config.rtp.ssrcs.size() == 1;
455 bool frame_dropping = !is_screencast; 456 bool frame_dropping = !is_screencast;
456 bool denoising; 457 bool denoising;
457 bool codec_default_denoising = false; 458 bool codec_default_denoising = false;
458 if (is_screencast) { 459 if (is_screencast) {
459 denoising = false; 460 denoising = false;
460 } else { 461 } else {
461 // Use codec default if video_noise_reduction is unset. 462 // Use codec default if video_noise_reduction is unset.
462 codec_default_denoising = !parameters_.options.video_noise_reduction; 463 codec_default_denoising = !parameters_.options.video_noise_reduction;
463 denoising = parameters_.options.video_noise_reduction.value_or(false); 464 denoising = parameters_.options.video_noise_reduction.value_or(false);
464 } 465 }
465 466
466 if (CodecNamesEq(codec.name, kH264CodecName)) { 467 if (CodecNamesEq(codec.name, kH264CodecName)) {
467 encoder_settings_.h264 = webrtc::VideoEncoder::GetDefaultH264Settings(); 468 webrtc::VideoCodecH264 h264_settings =
468 encoder_settings_.h264.frameDroppingOn = frame_dropping; 469 webrtc::VideoEncoder::GetDefaultH264Settings();
469 return &encoder_settings_.h264; 470 h264_settings.frameDroppingOn = frame_dropping;
471 return new rtc::RefCountedObject<
472 webrtc::VideoEncoderConfig::H264EncoderSpecificSettings>(h264_settings);
470 } 473 }
471 if (CodecNamesEq(codec.name, kVp8CodecName)) { 474 if (CodecNamesEq(codec.name, kVp8CodecName)) {
472 encoder_settings_.vp8 = webrtc::VideoEncoder::GetDefaultVp8Settings(); 475 webrtc::VideoCodecVP8 vp8_settings =
473 encoder_settings_.vp8.automaticResizeOn = automatic_resize; 476 webrtc::VideoEncoder::GetDefaultVp8Settings();
477 vp8_settings.automaticResizeOn = automatic_resize;
474 // VP8 denoising is enabled by default. 478 // VP8 denoising is enabled by default.
475 encoder_settings_.vp8.denoisingOn = 479 vp8_settings.denoisingOn = codec_default_denoising ? true : denoising;
476 codec_default_denoising ? true : denoising; 480 vp8_settings.frameDroppingOn = frame_dropping;
477 encoder_settings_.vp8.frameDroppingOn = frame_dropping; 481 return new rtc::RefCountedObject<
478 return &encoder_settings_.vp8; 482 webrtc::VideoEncoderConfig::Vp8EncoderSpecificSettings>(vp8_settings);
479 } 483 }
480 if (CodecNamesEq(codec.name, kVp9CodecName)) { 484 if (CodecNamesEq(codec.name, kVp9CodecName)) {
481 encoder_settings_.vp9 = webrtc::VideoEncoder::GetDefaultVp9Settings(); 485 webrtc::VideoCodecVP9 vp9_settings =
486 webrtc::VideoEncoder::GetDefaultVp9Settings();
482 if (is_screencast) { 487 if (is_screencast) {
483 // TODO(asapersson): Set to 2 for now since there is a DCHECK in 488 // TODO(asapersson): Set to 2 for now since there is a DCHECK in
484 // VideoSendStream::ReconfigureVideoEncoder. 489 // VideoSendStream::ReconfigureVideoEncoder.
485 encoder_settings_.vp9.numberOfSpatialLayers = 2; 490 vp9_settings.numberOfSpatialLayers = 2;
486 } else { 491 } else {
487 encoder_settings_.vp9.numberOfSpatialLayers = 492 vp9_settings.numberOfSpatialLayers = GetDefaultVp9SpatialLayers();
488 GetDefaultVp9SpatialLayers();
489 } 493 }
490 // VP9 denoising is disabled by default. 494 // VP9 denoising is disabled by default.
491 encoder_settings_.vp9.denoisingOn = 495 vp9_settings.denoisingOn = codec_default_denoising ? false : denoising;
492 codec_default_denoising ? false : denoising; 496 vp9_settings.frameDroppingOn = frame_dropping;
493 encoder_settings_.vp9.frameDroppingOn = frame_dropping; 497 return new rtc::RefCountedObject<
494 return &encoder_settings_.vp9; 498 webrtc::VideoEncoderConfig::Vp9EncoderSpecificSettings>(vp9_settings);
495 } 499 }
496 return NULL; 500 return nullptr;
497 } 501 }
498 502
499 DefaultUnsignalledSsrcHandler::DefaultUnsignalledSsrcHandler() 503 DefaultUnsignalledSsrcHandler::DefaultUnsignalledSsrcHandler()
500 : default_recv_ssrc_(0), default_sink_(NULL) {} 504 : default_recv_ssrc_(0), default_sink_(NULL) {}
501 505
502 UnsignalledSsrcHandler::Action DefaultUnsignalledSsrcHandler::OnUnsignalledSsrc( 506 UnsignalledSsrcHandler::Action DefaultUnsignalledSsrcHandler::OnUnsignalledSsrc(
503 WebRtcVideoChannel2* channel, 507 WebRtcVideoChannel2* channel,
504 uint32_t ssrc) { 508 uint32_t ssrc) {
505 if (default_recv_ssrc_ != 0) { // Already one default stream. 509 if (default_recv_ssrc_ != 0) { // Already one default stream.
506 LOG(LS_WARNING) << "Unknown SSRC, but default receive stream already set."; 510 LOG(LS_WARNING) << "Unknown SSRC, but default receive stream already set.";
(...skipping 2159 matching lines...) Expand 10 before | Expand all | Expand 10 after
2666 rtx_mapping[video_codecs[i].codec.id] != 2670 rtx_mapping[video_codecs[i].codec.id] !=
2667 fec_settings.red_payload_type) { 2671 fec_settings.red_payload_type) {
2668 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id]; 2672 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id];
2669 } 2673 }
2670 } 2674 }
2671 2675
2672 return video_codecs; 2676 return video_codecs;
2673 } 2677 }
2674 2678
2675 } // namespace cricket 2679 } // namespace cricket
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698