Index: webrtc/pc/peerconnection.cc |
diff --git a/webrtc/pc/peerconnection.cc b/webrtc/pc/peerconnection.cc |
index a3981039e6cfe89554092b4c14d7f2f7b0f175e4..90de260835e0061345b40479f385da790d4f5df3 100644 |
--- a/webrtc/pc/peerconnection.cc |
+++ b/webrtc/pc/peerconnection.cc |
@@ -1235,6 +1235,54 @@ void PeerConnection::RegisterUMAObserver(UMAObserver* observer) { |
} |
} |
+RTCError PeerConnection::SetBitrate(const BitrateParameters& bitrate) { |
+ return factory_->worker_thread()->Invoke<RTCError>( |
Taylor Brandstetter
2017/04/19 01:06:54
To avoid the extra indentation, and because the ch
Zach Stein
2017/04/20 20:48:00
Done.
|
+ RTC_FROM_HERE, [this, &bitrate]() { |
+ const bool has_min = static_cast<bool>(bitrate.min_bitrate_bps); |
+ const bool has_current = static_cast<bool>(bitrate.current_bitrate_bps); |
+ const bool has_max = static_cast<bool>(bitrate.max_bitrate_bps); |
+ if (has_min && *bitrate.min_bitrate_bps <= 0) { |
Taylor Brandstetter
2017/04/19 01:06:54
Isn't "min == 0" ok?
Zach Stein
2017/04/20 20:48:00
This makes setting all of the parameters to 0 lega
|
+ return RTCError(RTCErrorType::INVALID_PARAMETER, |
Taylor Brandstetter
2017/04/19 01:06:54
Can you use the "RETURN_AND_LOG_ERROR" macro, so t
Zach Stein
2017/04/20 20:48:00
Done.
|
+ "min_bitrate_bps <= 0"); |
+ } |
+ if (has_current) { |
+ if (has_min && |
+ *bitrate.current_bitrate_bps < *bitrate.min_bitrate_bps) { |
+ return RTCError(RTCErrorType::INVALID_PARAMETER, |
+ "current_bitrate_bps < min_bitrate_bps"); |
+ } else if (*bitrate.current_bitrate_bps < 0) { |
+ return RTCError(RTCErrorType::INVALID_PARAMETER, |
+ "curent_bitrate_bps < 0"); |
+ } |
+ } |
+ if (has_max) { |
+ if (has_current && |
+ *bitrate.max_bitrate_bps < *bitrate.current_bitrate_bps) { |
+ return RTCError(RTCErrorType::INVALID_PARAMETER, |
+ "max_bitrate_bps < current_bitrate_bps"); |
+ } else if (has_min && |
+ *bitrate.max_bitrate_bps < *bitrate.min_bitrate_bps) { |
+ return RTCError(RTCErrorType::INVALID_PARAMETER, |
+ "max_bitrate_bps < min_bitrate_bps"); |
+ } else if (*bitrate.max_bitrate_bps < 0) { |
+ return RTCError(RTCErrorType::INVALID_PARAMETER, |
+ "max_bitrate_bps < 0"); |
+ } |
+ } |
+ |
+ Call::Config::BitrateConfigMask mask; |
+ mask.min_bitrate_bps = bitrate.min_bitrate_bps; |
+ mask.start_bitrate_bps = bitrate.current_bitrate_bps; |
+ mask.max_bitrate_bps = bitrate.max_bitrate_bps; |
+ |
+ RTC_DCHECK(media_controller_); |
+ Call* call = media_controller_->call_w(); |
+ call->SetBitrateConfigMask(mask); |
+ |
+ return RTCError::OK(); |
+ }); |
+} |
+ |
bool PeerConnection::StartRtcEventLog(rtc::PlatformFile file, |
int64_t max_size_bytes) { |
return factory_->worker_thread()->Invoke<bool>( |