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

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

Issue 2347843002: Add proper lifetime of encoder-specific settings (Closed)
Patch Set: nitpicks Created 4 years, 2 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/media/engine/webrtcvideoengine2.h ('k') | webrtc/modules/audio_coding/BUILD.gn » ('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) 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 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 stream.target_bitrate_bps = stream.max_bitrate_bps = max_bitrate_bps; 443 stream.target_bitrate_bps = stream.max_bitrate_bps = max_bitrate_bps;
444 444
445 int max_qp = kDefaultQpMax; 445 int max_qp = kDefaultQpMax;
446 codec.GetParam(kCodecParamMaxQuantization, &max_qp); 446 codec.GetParam(kCodecParamMaxQuantization, &max_qp);
447 stream.max_qp = max_qp; 447 stream.max_qp = max_qp;
448 std::vector<webrtc::VideoStream> streams; 448 std::vector<webrtc::VideoStream> streams;
449 streams.push_back(stream); 449 streams.push_back(stream);
450 return streams; 450 return streams;
451 } 451 }
452 452
453 void* WebRtcVideoChannel2::WebRtcVideoSendStream::ConfigureVideoEncoderSettings( 453 rtc::scoped_refptr<webrtc::VideoEncoderConfig::EncoderSpecificSettings>
454 WebRtcVideoChannel2::WebRtcVideoSendStream::ConfigureVideoEncoderSettings(
454 const VideoCodec& codec) { 455 const VideoCodec& codec) {
455 bool is_screencast = parameters_.options.is_screencast.value_or(false); 456 bool is_screencast = parameters_.options.is_screencast.value_or(false);
456 // No automatic resizing when using simulcast or screencast. 457 // No automatic resizing when using simulcast or screencast.
457 bool automatic_resize = 458 bool automatic_resize =
458 !is_screencast && parameters_.config.rtp.ssrcs.size() == 1; 459 !is_screencast && parameters_.config.rtp.ssrcs.size() == 1;
459 bool frame_dropping = !is_screencast; 460 bool frame_dropping = !is_screencast;
460 bool denoising; 461 bool denoising;
461 bool codec_default_denoising = false; 462 bool codec_default_denoising = false;
462 if (is_screencast) { 463 if (is_screencast) {
463 denoising = false; 464 denoising = false;
464 } else { 465 } else {
465 // Use codec default if video_noise_reduction is unset. 466 // Use codec default if video_noise_reduction is unset.
466 codec_default_denoising = !parameters_.options.video_noise_reduction; 467 codec_default_denoising = !parameters_.options.video_noise_reduction;
467 denoising = parameters_.options.video_noise_reduction.value_or(false); 468 denoising = parameters_.options.video_noise_reduction.value_or(false);
468 } 469 }
469 470
470 if (CodecNamesEq(codec.name, kH264CodecName)) { 471 if (CodecNamesEq(codec.name, kH264CodecName)) {
471 encoder_settings_.h264 = webrtc::VideoEncoder::GetDefaultH264Settings(); 472 webrtc::VideoCodecH264 h264_settings =
472 encoder_settings_.h264.frameDroppingOn = frame_dropping; 473 webrtc::VideoEncoder::GetDefaultH264Settings();
473 return &encoder_settings_.h264; 474 h264_settings.frameDroppingOn = frame_dropping;
475 return new rtc::RefCountedObject<
476 webrtc::VideoEncoderConfig::H264EncoderSpecificSettings>(h264_settings);
474 } 477 }
475 if (CodecNamesEq(codec.name, kVp8CodecName)) { 478 if (CodecNamesEq(codec.name, kVp8CodecName)) {
476 encoder_settings_.vp8 = webrtc::VideoEncoder::GetDefaultVp8Settings(); 479 webrtc::VideoCodecVP8 vp8_settings =
477 encoder_settings_.vp8.automaticResizeOn = automatic_resize; 480 webrtc::VideoEncoder::GetDefaultVp8Settings();
481 vp8_settings.automaticResizeOn = automatic_resize;
478 // VP8 denoising is enabled by default. 482 // VP8 denoising is enabled by default.
479 encoder_settings_.vp8.denoisingOn = 483 vp8_settings.denoisingOn = codec_default_denoising ? true : denoising;
480 codec_default_denoising ? true : denoising; 484 vp8_settings.frameDroppingOn = frame_dropping;
481 encoder_settings_.vp8.frameDroppingOn = frame_dropping; 485 return new rtc::RefCountedObject<
482 return &encoder_settings_.vp8; 486 webrtc::VideoEncoderConfig::Vp8EncoderSpecificSettings>(vp8_settings);
483 } 487 }
484 if (CodecNamesEq(codec.name, kVp9CodecName)) { 488 if (CodecNamesEq(codec.name, kVp9CodecName)) {
485 encoder_settings_.vp9 = webrtc::VideoEncoder::GetDefaultVp9Settings(); 489 webrtc::VideoCodecVP9 vp9_settings =
490 webrtc::VideoEncoder::GetDefaultVp9Settings();
486 if (is_screencast) { 491 if (is_screencast) {
487 // TODO(asapersson): Set to 2 for now since there is a DCHECK in 492 // TODO(asapersson): Set to 2 for now since there is a DCHECK in
488 // VideoSendStream::ReconfigureVideoEncoder. 493 // VideoSendStream::ReconfigureVideoEncoder.
489 encoder_settings_.vp9.numberOfSpatialLayers = 2; 494 vp9_settings.numberOfSpatialLayers = 2;
490 } else { 495 } else {
491 encoder_settings_.vp9.numberOfSpatialLayers = 496 vp9_settings.numberOfSpatialLayers = GetDefaultVp9SpatialLayers();
492 GetDefaultVp9SpatialLayers();
493 } 497 }
494 // VP9 denoising is disabled by default. 498 // VP9 denoising is disabled by default.
495 encoder_settings_.vp9.denoisingOn = 499 vp9_settings.denoisingOn = codec_default_denoising ? false : denoising;
496 codec_default_denoising ? false : denoising; 500 vp9_settings.frameDroppingOn = frame_dropping;
497 encoder_settings_.vp9.frameDroppingOn = frame_dropping; 501 return new rtc::RefCountedObject<
498 return &encoder_settings_.vp9; 502 webrtc::VideoEncoderConfig::Vp9EncoderSpecificSettings>(vp9_settings);
499 } 503 }
500 return NULL; 504 return nullptr;
501 } 505 }
502 506
503 DefaultUnsignalledSsrcHandler::DefaultUnsignalledSsrcHandler() 507 DefaultUnsignalledSsrcHandler::DefaultUnsignalledSsrcHandler()
504 : default_recv_ssrc_(0), default_sink_(NULL) {} 508 : default_recv_ssrc_(0), default_sink_(NULL) {}
505 509
506 UnsignalledSsrcHandler::Action DefaultUnsignalledSsrcHandler::OnUnsignalledSsrc( 510 UnsignalledSsrcHandler::Action DefaultUnsignalledSsrcHandler::OnUnsignalledSsrc(
507 WebRtcVideoChannel2* channel, 511 WebRtcVideoChannel2* channel,
508 uint32_t ssrc) { 512 uint32_t ssrc) {
509 if (default_recv_ssrc_ != 0) { // Already one default stream. 513 if (default_recv_ssrc_ != 0) { // Already one default stream.
510 LOG(LS_WARNING) << "Unknown SSRC, but default receive stream already set."; 514 LOG(LS_WARNING) << "Unknown SSRC, but default receive stream already set.";
(...skipping 2199 matching lines...) Expand 10 before | Expand all | Expand 10 after
2710 rtx_mapping[video_codecs[i].codec.id] != 2714 rtx_mapping[video_codecs[i].codec.id] !=
2711 fec_settings.red_payload_type) { 2715 fec_settings.red_payload_type) {
2712 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id]; 2716 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id];
2713 } 2717 }
2714 } 2718 }
2715 2719
2716 return video_codecs; 2720 return video_codecs;
2717 } 2721 }
2718 2722
2719 } // namespace cricket 2723 } // namespace cricket
OLDNEW
« no previous file with comments | « webrtc/media/engine/webrtcvideoengine2.h ('k') | webrtc/modules/audio_coding/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698