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

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

Issue 1788583004: Enable setting the maximum bitrate limit in RtpSender. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 9 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 772 matching lines...) Expand 10 before | Expand all | Expand 10 after
783 // TODO(holmer): Changing the codec parameters shouldn't necessarily mean 783 // TODO(holmer): Changing the codec parameters shouldn't necessarily mean
784 // that we change the min/max of bandwidth estimation. Reevaluate this. 784 // that we change the min/max of bandwidth estimation. Reevaluate this.
785 bitrate_config_ = GetBitrateConfigForCodec(codec_settings.codec); 785 bitrate_config_ = GetBitrateConfigForCodec(codec_settings.codec);
786 bitrate_config_changed = true; 786 bitrate_config_changed = true;
787 } 787 }
788 788
789 if (changed_params.rtp_header_extensions) { 789 if (changed_params.rtp_header_extensions) {
790 send_rtp_extensions_ = *changed_params.rtp_header_extensions; 790 send_rtp_extensions_ = *changed_params.rtp_header_extensions;
791 } 791 }
792 792
793 int max_global_bitrate = -1;
Taylor Brandstetter 2016/03/12 01:57:06 This variable can remain inside the scoped block.
skvlad 2016/03/15 21:18:18 Good catch, thanks!
793 if (changed_params.max_bandwidth_bps) { 794 if (changed_params.max_bandwidth_bps) {
794 // TODO(pbos): Figure out whether b=AS means max bitrate for this 795 // TODO(pbos): Figure out whether b=AS means max bitrate for this
795 // WebRtcVideoChannel2 (in which case we're good), or per sender (SSRC), in 796 // WebRtcVideoChannel2 (in which case we're good), or per sender (SSRC), in
796 // which case this should not set a Call::BitrateConfig but rather 797 // which case this should not set a Call::BitrateConfig but rather
797 // reconfigure all senders. 798 // reconfigure all senders.
798 int max_bitrate_bps = *changed_params.max_bandwidth_bps; 799 max_global_bitrate = *changed_params.max_bandwidth_bps;
799 bitrate_config_.start_bitrate_bps = -1; 800 bitrate_config_.start_bitrate_bps = -1;
800 bitrate_config_.max_bitrate_bps = max_bitrate_bps; 801 bitrate_config_.max_bitrate_bps = max_global_bitrate;
801 if (max_bitrate_bps > 0 && 802 if (max_global_bitrate > 0 &&
802 bitrate_config_.min_bitrate_bps > max_bitrate_bps) { 803 bitrate_config_.min_bitrate_bps > max_global_bitrate) {
803 bitrate_config_.min_bitrate_bps = max_bitrate_bps; 804 bitrate_config_.min_bitrate_bps = max_global_bitrate;
805 // TODO(skvlad): limit min_bitrate_bps to not exceed the lowest of all
pthatcher1 2016/03/12 01:21:04 limit => Limit
skvlad 2016/03/15 21:18:18 Done.
806 // per-SSRC bitrate limits
pthatcher1 2016/03/12 01:21:04 Actually, pbos said that once we move to UnifiedPl
skvlad 2016/03/15 21:18:18 Done.
804 } 807 }
805 bitrate_config_changed = true; 808 bitrate_config_changed = true;
806 } 809 }
807 810
808 if (bitrate_config_changed) { 811 if (bitrate_config_changed) {
809 call_->SetBitrateConfig(bitrate_config_); 812 call_->SetBitrateConfig(bitrate_config_);
810 } 813 }
811 814
812 if (changed_params.options) 815 if (changed_params.options)
813 send_params_.options.SetAll(*changed_params.options); 816 send_params_.options.SetAll(*changed_params.options);
814 817
815 { 818 {
816 rtc::CritScope stream_lock(&stream_crit_); 819 rtc::CritScope stream_lock(&stream_crit_);
817 for (auto& kv : send_streams_) { 820 for (auto& kv : send_streams_) {
821 if (changed_params.max_bandwidth_bps) {
822 changed_params.max_bandwidth_bps = rtc::Optional<int>(MinPositive(
823 max_global_bitrate,
pthatcher1 2016/03/12 01:21:04 You could make max_global_bitrate rtc::Optional<in
skvlad 2016/03/15 21:18:18 rtc::Optional changes will come in a separate code
824 kv.second->rtp_parameters().encodings[0].max_bitrate_bps));
Taylor Brandstetter 2016/03/12 01:57:06 A problem with this is that even if the minimum of
pthatcher1 2016/03/14 16:26:50 Good point to avoid reconfiguration.
skvlad 2016/03/15 21:18:18 Added a TODO. I'll address this as part of the rtc
825 }
pthatcher1 2016/03/12 01:21:03 Actually, I think this isn't necessary. If the pe
skvlad 2016/03/15 21:18:18 Looks like you are right: the global minimum bitra
818 kv.second->SetSendParameters(changed_params); 826 kv.second->SetSendParameters(changed_params);
819 } 827 }
820 if (changed_params.codec) { 828 if (changed_params.codec) {
821 // Update receive feedback parameters from new codec. 829 // Update receive feedback parameters from new codec.
822 LOG(LS_INFO) 830 LOG(LS_INFO)
823 << "SetFeedbackOptions on all the receive streams because the send " 831 << "SetFeedbackOptions on all the receive streams because the send "
824 "codec has changed."; 832 "codec has changed.";
825 for (auto& kv : receive_streams_) { 833 for (auto& kv : receive_streams_) {
826 RTC_DCHECK(kv.second != nullptr); 834 RTC_DCHECK(kv.second != nullptr);
827 kv.second->SetFeedbackParameters(HasNack(send_codec_->codec), 835 kv.second->SetFeedbackParameters(HasNack(send_codec_->codec),
828 HasRemb(send_codec_->codec), 836 HasRemb(send_codec_->codec),
829 HasTransportCc(send_codec_->codec)); 837 HasTransportCc(send_codec_->codec));
830 } 838 }
831 } 839 }
832 } 840 }
833 send_params_ = params; 841 send_params_ = params;
834 return true; 842 return true;
835 } 843 }
844 webrtc::RTCRtpParameters WebRtcVideoChannel2::GetRtpParameters(uint32_t ssrc) {
845 rtc::CritScope stream_lock(&stream_crit_);
846 auto it = send_streams_.find(ssrc);
847 if (it == send_streams_.end()) {
848 LOG(LS_WARNING) << "Attempting to get RTP parameters for stream with ssrc "
849 << ssrc << " which doesn't exist.";
850 return webrtc::RTCRtpParameters();
851 }
852
853 return it->second->rtp_parameters();
854 }
855
856 bool WebRtcVideoChannel2::SetRtpParameters(
857 uint32_t ssrc,
858 const webrtc::RTCRtpParameters& parameters) {
859 rtc::CritScope stream_lock(&stream_crit_);
860 auto it = send_streams_.find(ssrc);
861 if (it == send_streams_.end()) {
862 LOG(LS_WARNING) << "Attempting to set RTP parameters for stream with ssrc "
863 << ssrc << " which doesn't exist.";
864 return false;
865 }
866
867 if (parameters.encodings.size() != 1) {
868 LOG(LS_WARNING)
869 << "Attempting to set RTP parameters without exactly 1 encoding";
870 return false;
871 }
872
873 it->second->set_rtp_parameters(parameters);
pthatcher1 2016/03/12 01:21:03 I think we should have a SetRtpParameters on the s
Taylor Brandstetter 2016/03/12 01:57:06 I would say the same thing, but the send stream do
pthatcher1 2016/03/14 16:26:50 I think adding a new state variable to the SendStr
874 ChangedSendParameters changed_params;
875 changed_params.max_bandwidth_bps =
876 rtc::Optional<int>(MinPositive(bitrate_config_.max_bitrate_bps,
pthatcher1 2016/03/12 01:21:03 I don't think we need the min with bitrate_config_
Taylor Brandstetter 2016/03/12 01:57:06 It shouldn't be the last ChangedSendParameters, bu
877 parameters.encodings[0].max_bitrate_bps));
878 it->second->SetSendParameters(changed_params);
879 return true;
880 }
836 881
837 bool WebRtcVideoChannel2::GetChangedRecvParameters( 882 bool WebRtcVideoChannel2::GetChangedRecvParameters(
838 const VideoRecvParameters& params, 883 const VideoRecvParameters& params,
839 ChangedRecvParameters* changed_params) const { 884 ChangedRecvParameters* changed_params) const {
840 if (!ValidateCodecFormats(params.codecs) || 885 if (!ValidateCodecFormats(params.codecs) ||
841 !ValidateRtpExtensions(params.extensions)) { 886 !ValidateRtpExtensions(params.extensions)) {
842 return false; 887 return false;
843 } 888 }
844 889
845 // Handle receive codecs. 890 // Handle receive codecs.
(...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after
1486 capturer_(nullptr), 1531 capturer_(nullptr),
1487 external_encoder_factory_(external_encoder_factory), 1532 external_encoder_factory_(external_encoder_factory),
1488 stream_(nullptr), 1533 stream_(nullptr),
1489 parameters_(config, send_params.options, max_bitrate_bps, codec_settings), 1534 parameters_(config, send_params.options, max_bitrate_bps, codec_settings),
1490 pending_encoder_reconfiguration_(false), 1535 pending_encoder_reconfiguration_(false),
1491 allocated_encoder_(nullptr, webrtc::kVideoCodecUnknown, false), 1536 allocated_encoder_(nullptr, webrtc::kVideoCodecUnknown, false),
1492 capturer_is_screencast_(false), 1537 capturer_is_screencast_(false),
1493 sending_(false), 1538 sending_(false),
1494 muted_(false), 1539 muted_(false),
1495 first_frame_timestamp_ms_(0), 1540 first_frame_timestamp_ms_(0),
1496 last_frame_timestamp_ms_(0) { 1541 last_frame_timestamp_ms_(0),
1542 rtp_parameters_(webrtc::RTCRtpParameters::CreateDefault()) {
1497 parameters_.config.rtp.max_packet_size = kVideoMtu; 1543 parameters_.config.rtp.max_packet_size = kVideoMtu;
1498 parameters_.conference_mode = send_params.conference_mode; 1544 parameters_.conference_mode = send_params.conference_mode;
1499 1545
1500 sp.GetPrimarySsrcs(&parameters_.config.rtp.ssrcs); 1546 sp.GetPrimarySsrcs(&parameters_.config.rtp.ssrcs);
1501 sp.GetFidSsrcs(parameters_.config.rtp.ssrcs, 1547 sp.GetFidSsrcs(parameters_.config.rtp.ssrcs,
1502 &parameters_.config.rtp.rtx.ssrcs); 1548 &parameters_.config.rtp.rtx.ssrcs);
1503 parameters_.config.rtp.c_name = sp.cname; 1549 parameters_.config.rtp.c_name = sp.cname;
1504 parameters_.config.rtp.extensions = rtp_extensions; 1550 parameters_.config.rtp.extensions = rtp_extensions;
1505 parameters_.config.rtp.rtcp_mode = send_params.rtcp.reduced_size 1551 parameters_.config.rtp.rtcp_mode = send_params.rtcp.reduced_size
1506 ? webrtc::RtcpMode::kReducedSize 1552 ? webrtc::RtcpMode::kReducedSize
(...skipping 1027 matching lines...) Expand 10 before | Expand all | Expand 10 after
2534 rtx_mapping[video_codecs[i].codec.id] != 2580 rtx_mapping[video_codecs[i].codec.id] !=
2535 fec_settings.red_payload_type) { 2581 fec_settings.red_payload_type) {
2536 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id]; 2582 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id];
2537 } 2583 }
2538 } 2584 }
2539 2585
2540 return video_codecs; 2586 return video_codecs;
2541 } 2587 }
2542 2588
2543 } // namespace cricket 2589 } // namespace cricket
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698