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

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

Issue 1904063003: Fixing the interaction between codec bitrate limit and "b=AS". (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Make "b=AS" take priority over "x-google-max-bitrate" for BWE max bitrate. Created 4 years, 8 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 | « no previous file | webrtc/media/engine/webrtcvideoengine2_unittest.cc » ('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 752 matching lines...) Expand 10 before | Expand all | Expand 10 after
763 763
764 // Handle RTP header extensions. 764 // Handle RTP header extensions.
765 std::vector<webrtc::RtpExtension> filtered_extensions = FilterRtpExtensions( 765 std::vector<webrtc::RtpExtension> filtered_extensions = FilterRtpExtensions(
766 params.extensions, webrtc::RtpExtension::IsSupportedForVideo, true); 766 params.extensions, webrtc::RtpExtension::IsSupportedForVideo, true);
767 if (send_rtp_extensions_ != filtered_extensions) { 767 if (send_rtp_extensions_ != filtered_extensions) {
768 changed_params->rtp_header_extensions = 768 changed_params->rtp_header_extensions =
769 rtc::Optional<std::vector<webrtc::RtpExtension>>(filtered_extensions); 769 rtc::Optional<std::vector<webrtc::RtpExtension>>(filtered_extensions);
770 } 770 }
771 771
772 // Handle max bitrate. 772 // Handle max bitrate.
773 if (params.max_bandwidth_bps != bitrate_config_.max_bitrate_bps && 773 if (params.max_bandwidth_bps != send_params_.max_bandwidth_bps &&
774 params.max_bandwidth_bps >= 0) { 774 params.max_bandwidth_bps >= 0) {
775 // 0 uncaps max bitrate (-1). 775 // 0 uncaps max bitrate (-1).
776 changed_params->max_bandwidth_bps = rtc::Optional<int>( 776 changed_params->max_bandwidth_bps = rtc::Optional<int>(
777 params.max_bandwidth_bps == 0 ? -1 : params.max_bandwidth_bps); 777 params.max_bandwidth_bps == 0 ? -1 : params.max_bandwidth_bps);
778 } 778 }
779 779
780 // Handle conference mode. 780 // Handle conference mode.
781 if (params.conference_mode != send_params_.conference_mode) { 781 if (params.conference_mode != send_params_.conference_mode) {
782 changed_params->conference_mode = 782 changed_params->conference_mode =
783 rtc::Optional<bool>(params.conference_mode); 783 rtc::Optional<bool>(params.conference_mode);
(...skipping 14 matching lines...) Expand all
798 } 798 }
799 799
800 bool WebRtcVideoChannel2::SetSendParameters(const VideoSendParameters& params) { 800 bool WebRtcVideoChannel2::SetSendParameters(const VideoSendParameters& params) {
801 TRACE_EVENT0("webrtc", "WebRtcVideoChannel2::SetSendParameters"); 801 TRACE_EVENT0("webrtc", "WebRtcVideoChannel2::SetSendParameters");
802 LOG(LS_INFO) << "SetSendParameters: " << params.ToString(); 802 LOG(LS_INFO) << "SetSendParameters: " << params.ToString();
803 ChangedSendParameters changed_params; 803 ChangedSendParameters changed_params;
804 if (!GetChangedSendParameters(params, &changed_params)) { 804 if (!GetChangedSendParameters(params, &changed_params)) {
805 return false; 805 return false;
806 } 806 }
807 807
808 bool bitrate_config_changed = false;
809
810 if (changed_params.codec) { 808 if (changed_params.codec) {
811 const VideoCodecSettings& codec_settings = *changed_params.codec; 809 const VideoCodecSettings& codec_settings = *changed_params.codec;
812 send_codec_ = rtc::Optional<VideoCodecSettings>(codec_settings); 810 send_codec_ = rtc::Optional<VideoCodecSettings>(codec_settings);
813
814 LOG(LS_INFO) << "Using codec: " << codec_settings.codec.ToString(); 811 LOG(LS_INFO) << "Using codec: " << codec_settings.codec.ToString();
815 // TODO(holmer): Changing the codec parameters shouldn't necessarily mean
816 // that we change the min/max of bandwidth estimation. Reevaluate this.
817 bitrate_config_ = GetBitrateConfigForCodec(codec_settings.codec);
818 bitrate_config_changed = true;
819 } 812 }
820 813
821 if (changed_params.rtp_header_extensions) { 814 if (changed_params.rtp_header_extensions) {
822 send_rtp_extensions_ = *changed_params.rtp_header_extensions; 815 send_rtp_extensions_ = *changed_params.rtp_header_extensions;
823 } 816 }
824 817
825 if (changed_params.max_bandwidth_bps) { 818 if (changed_params.codec || changed_params.max_bandwidth_bps) {
826 // TODO(pbos): Figure out whether b=AS means max bitrate for this 819 if (send_codec_) {
827 // WebRtcVideoChannel2 (in which case we're good), or per sender (SSRC), in 820 // TODO(holmer): Changing the codec parameters shouldn't necessarily mean
828 // which case this should not set a Call::BitrateConfig but rather 821 // that we change the min/max of bandwidth estimation. Reevaluate this.
829 // reconfigure all senders. 822 bitrate_config_ = GetBitrateConfigForCodec(send_codec_->codec);
830 int max_bitrate_bps = *changed_params.max_bandwidth_bps; 823 if (!changed_params.codec) {
831 bitrate_config_.start_bitrate_bps = -1; 824 // If the codec isn't changing, set the start bitrate to -1 which means
832 bitrate_config_.max_bitrate_bps = max_bitrate_bps; 825 // "unchanged" so that BWE isn't affected.
833 if (max_bitrate_bps > 0 && 826 bitrate_config_.start_bitrate_bps = -1;
834 bitrate_config_.min_bitrate_bps > max_bitrate_bps) { 827 }
835 bitrate_config_.min_bitrate_bps = max_bitrate_bps;
836 } 828 }
837 bitrate_config_changed = true; 829 if (params.max_bandwidth_bps >= 0) {
838 } 830 // Note that max_bandwidth_bps intentionally takes priority over the
839 831 // bitrate config for the codec. This allows FEC to be applied above the
840 if (bitrate_config_changed) { 832 // codec target bitrate.
833 // TODO(pbos): Figure out whether b=AS means max bitrate for this
stefan-webrtc 2016/04/27 07:24:41 b=AS means session bandwidth, so my interpretation
834 // WebRtcVideoChannel2 (in which case we're good), or per sender (SSRC),
835 // in which case this should not set a Call::BitrateConfig but rather
836 // reconfigure all senders.
837 bitrate_config_.max_bitrate_bps =
838 params.max_bandwidth_bps == 0 ? -1 : params.max_bandwidth_bps;
839 }
841 call_->SetBitrateConfig(bitrate_config_); 840 call_->SetBitrateConfig(bitrate_config_);
842 } 841 }
843 842
844 { 843 {
845 rtc::CritScope stream_lock(&stream_crit_); 844 rtc::CritScope stream_lock(&stream_crit_);
846 for (auto& kv : send_streams_) { 845 for (auto& kv : send_streams_) {
847 kv.second->SetSendParameters(changed_params); 846 kv.second->SetSendParameters(changed_params);
848 } 847 }
849 if (changed_params.codec || changed_params.rtcp_mode) { 848 if (changed_params.codec || changed_params.rtcp_mode) {
850 // Update receive feedback parameters from new codec or RTCP mode. 849 // Update receive feedback parameters from new codec or RTCP mode.
(...skipping 1725 matching lines...) Expand 10 before | Expand all | Expand 10 after
2576 rtx_mapping[video_codecs[i].codec.id] != 2575 rtx_mapping[video_codecs[i].codec.id] !=
2577 fec_settings.red_payload_type) { 2576 fec_settings.red_payload_type) {
2578 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id]; 2577 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id];
2579 } 2578 }
2580 } 2579 }
2581 2580
2582 return video_codecs; 2581 return video_codecs;
2583 } 2582 }
2584 2583
2585 } // namespace cricket 2584 } // namespace cricket
OLDNEW
« no previous file with comments | « no previous file | webrtc/media/engine/webrtcvideoengine2_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698