OLD | NEW |
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 Loading... |
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 Loading... |
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 // TODO(holmer): Changing the codec parameters shouldn't necessarily mean |
| 819 // that we change the min/max of bandwidth estimation. Reevaluate this. |
| 820 if (changed_params.codec || changed_params.max_bandwidth_bps) { |
| 821 if (send_codec_) { |
| 822 bitrate_config_ = GetBitrateConfigForCodec(send_codec_->codec); |
| 823 } |
826 // TODO(pbos): Figure out whether b=AS means max bitrate for this | 824 // TODO(pbos): Figure out whether b=AS means max bitrate for this |
827 // WebRtcVideoChannel2 (in which case we're good), or per sender (SSRC), in | 825 // WebRtcVideoChannel2 (in which case we're good), or per sender (SSRC), in |
828 // which case this should not set a Call::BitrateConfig but rather | 826 // which case this should not set a Call::BitrateConfig but rather |
829 // reconfigure all senders. | 827 // reconfigure all senders. |
830 int max_bitrate_bps = *changed_params.max_bandwidth_bps; | 828 int max_bandwidth_bps = |
831 bitrate_config_.start_bitrate_bps = -1; | 829 params.max_bandwidth_bps == 0 ? -1 : params.max_bandwidth_bps; |
832 bitrate_config_.max_bitrate_bps = max_bitrate_bps; | 830 bitrate_config_.max_bitrate_bps = |
833 if (max_bitrate_bps > 0 && | 831 send_codec_ |
834 bitrate_config_.min_bitrate_bps > max_bitrate_bps) { | 832 ? MinNonNegative(bitrate_config_.max_bitrate_bps, max_bandwidth_bps) |
835 bitrate_config_.min_bitrate_bps = max_bitrate_bps; | 833 : max_bandwidth_bps; |
| 834 if (!changed_params.codec) { |
| 835 // If the codec isn't changing, set the start bitrate to -1 which means |
| 836 // "unchanged" so that BWE isn't affected. |
| 837 bitrate_config_.start_bitrate_bps = -1; |
836 } | 838 } |
837 bitrate_config_changed = true; | |
838 } | |
839 | |
840 if (bitrate_config_changed) { | |
841 call_->SetBitrateConfig(bitrate_config_); | 839 call_->SetBitrateConfig(bitrate_config_); |
842 } | 840 } |
843 | 841 |
844 { | 842 { |
845 rtc::CritScope stream_lock(&stream_crit_); | 843 rtc::CritScope stream_lock(&stream_crit_); |
846 for (auto& kv : send_streams_) { | 844 for (auto& kv : send_streams_) { |
847 kv.second->SetSendParameters(changed_params); | 845 kv.second->SetSendParameters(changed_params); |
848 } | 846 } |
849 if (changed_params.codec || changed_params.rtcp_mode) { | 847 if (changed_params.codec || changed_params.rtcp_mode) { |
850 // Update receive feedback parameters from new codec or RTCP mode. | 848 // Update receive feedback parameters from new codec or RTCP mode. |
(...skipping 1725 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2576 rtx_mapping[video_codecs[i].codec.id] != | 2574 rtx_mapping[video_codecs[i].codec.id] != |
2577 fec_settings.red_payload_type) { | 2575 fec_settings.red_payload_type) { |
2578 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id]; | 2576 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id]; |
2579 } | 2577 } |
2580 } | 2578 } |
2581 | 2579 |
2582 return video_codecs; | 2580 return video_codecs; |
2583 } | 2581 } |
2584 | 2582 |
2585 } // namespace cricket | 2583 } // namespace cricket |
OLD | NEW |