RTCError PeerConnection::SetBitrate(const BitrateParameters& bitrate) {
rtc::Thread* worker_thread = factory_->worker_thread();
if (!worker_thread->IsCurrent()) {
return worker_thread->Invoke<RTCError>(
RTC_FROM_HERE, rtc::Bind(&PeerConnection::SetBitrate, 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) {
LOG_AND_RETURN_ERROR(RTCErrorType::INVALID_PARAMETER,
"min_bitrate_bps <= 0");
}
if (has_current) {