 Chromium Code Reviews
 Chromium Code Reviews Issue 2888303005:
  Add PeerConnectionInterface::UpdateCallBitrate.  (Closed)
    
  
    Issue 2888303005:
  Add PeerConnectionInterface::UpdateCallBitrate.  (Closed) 
  | OLD | NEW | 
|---|---|
| 1 /* | 1 /* | 
| 2 * Copyright 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2012 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 1224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1235 kEnumCounterAddressFamily, kPeerConnection_IPv6, | 1235 kEnumCounterAddressFamily, kPeerConnection_IPv6, | 
| 1236 kPeerConnectionAddressFamilyCounter_Max); | 1236 kPeerConnectionAddressFamilyCounter_Max); | 
| 1237 } else { | 1237 } else { | 
| 1238 uma_observer_->IncrementEnumCounter( | 1238 uma_observer_->IncrementEnumCounter( | 
| 1239 kEnumCounterAddressFamily, kPeerConnection_IPv4, | 1239 kEnumCounterAddressFamily, kPeerConnection_IPv4, | 
| 1240 kPeerConnectionAddressFamilyCounter_Max); | 1240 kPeerConnectionAddressFamilyCounter_Max); | 
| 1241 } | 1241 } | 
| 1242 } | 1242 } | 
| 1243 } | 1243 } | 
| 1244 | 1244 | 
| 1245 RTCError PeerConnection::SetBitrate(const BitrateParameters& bitrate) { | |
| 
tommi
2017/08/17 07:32:52
Instead of blocking, can this function be designed
 | |
| 1246 rtc::Thread* worker_thread = factory_->worker_thread(); | |
| 1247 if (!worker_thread->IsCurrent()) { | |
| 1248 return worker_thread->Invoke<RTCError>( | |
| 1249 RTC_FROM_HERE, rtc::Bind(&PeerConnection::SetBitrate, this, bitrate)); | |
| 1250 } | |
| 1251 | |
| 1252 const bool has_min = static_cast<bool>(bitrate.min_bitrate_bps); | |
| 1253 const bool has_current = static_cast<bool>(bitrate.current_bitrate_bps); | |
| 1254 const bool has_max = static_cast<bool>(bitrate.max_bitrate_bps); | |
| 1255 if (has_min && *bitrate.min_bitrate_bps < 0) { | |
| 1256 LOG_AND_RETURN_ERROR(RTCErrorType::INVALID_PARAMETER, | |
| 
tommi
2017/08/17 07:32:52
hiding return statements in macros can be dangerou
 | |
| 1257 "min_bitrate_bps <= 0"); | |
| 1258 } | |
| 1259 if (has_current) { | |
| 1260 if (has_min && *bitrate.current_bitrate_bps < *bitrate.min_bitrate_bps) { | |
| 1261 LOG_AND_RETURN_ERROR(RTCErrorType::INVALID_PARAMETER, | |
| 1262 "current_bitrate_bps < min_bitrate_bps"); | |
| 1263 } else if (*bitrate.current_bitrate_bps < 0) { | |
| 1264 LOG_AND_RETURN_ERROR(RTCErrorType::INVALID_PARAMETER, | |
| 1265 "curent_bitrate_bps < 0"); | |
| 1266 } | |
| 1267 } | |
| 1268 if (has_max) { | |
| 1269 if (has_current && | |
| 1270 *bitrate.max_bitrate_bps < *bitrate.current_bitrate_bps) { | |
| 1271 LOG_AND_RETURN_ERROR(RTCErrorType::INVALID_PARAMETER, | |
| 1272 "max_bitrate_bps < current_bitrate_bps"); | |
| 1273 } else if (has_min && *bitrate.max_bitrate_bps < *bitrate.min_bitrate_bps) { | |
| 1274 LOG_AND_RETURN_ERROR(RTCErrorType::INVALID_PARAMETER, | |
| 1275 "max_bitrate_bps < min_bitrate_bps"); | |
| 1276 } else if (*bitrate.max_bitrate_bps < 0) { | |
| 1277 LOG_AND_RETURN_ERROR(RTCErrorType::INVALID_PARAMETER, | |
| 
tommi
2017/08/17 07:32:52
The code cost (i.e. code bloat) of each of these l
 | |
| 1278 "max_bitrate_bps < 0"); | |
| 1279 } | |
| 1280 } | |
| 1281 | |
| 1282 Call::Config::BitrateConfigMask mask; | |
| 1283 mask.min_bitrate_bps = bitrate.min_bitrate_bps; | |
| 1284 mask.start_bitrate_bps = bitrate.current_bitrate_bps; | |
| 1285 mask.max_bitrate_bps = bitrate.max_bitrate_bps; | |
| 1286 | |
| 1287 RTC_DCHECK(call_.get()); | |
| 
tommi
2017/08/17 07:32:52
we don't DCHECK a pointer that we dereference anyw
 | |
| 1288 call_->SetBitrateConfigMask(mask); | |
| 1289 | |
| 1290 return RTCError::OK(); | |
| 1291 } | |
| 1292 | |
| 1245 bool PeerConnection::StartRtcEventLog(rtc::PlatformFile file, | 1293 bool PeerConnection::StartRtcEventLog(rtc::PlatformFile file, | 
| 1246 int64_t max_size_bytes) { | 1294 int64_t max_size_bytes) { | 
| 1247 return factory_->worker_thread()->Invoke<bool>( | 1295 return factory_->worker_thread()->Invoke<bool>( | 
| 1248 RTC_FROM_HERE, rtc::Bind(&PeerConnection::StartRtcEventLog_w, this, file, | 1296 RTC_FROM_HERE, rtc::Bind(&PeerConnection::StartRtcEventLog_w, this, file, | 
| 1249 max_size_bytes)); | 1297 max_size_bytes)); | 
| 1250 } | 1298 } | 
| 1251 | 1299 | 
| 1252 void PeerConnection::StopRtcEventLog() { | 1300 void PeerConnection::StopRtcEventLog() { | 
| 1253 factory_->worker_thread()->Invoke<void>( | 1301 factory_->worker_thread()->Invoke<void>( | 
| 1254 RTC_FROM_HERE, rtc::Bind(&PeerConnection::StopRtcEventLog_w, this)); | 1302 RTC_FROM_HERE, rtc::Bind(&PeerConnection::StopRtcEventLog_w, this)); | 
| (...skipping 1083 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2338 call_config.audio_state = | 2386 call_config.audio_state = | 
| 2339 factory_->channel_manager() ->media_engine()->GetAudioState(); | 2387 factory_->channel_manager() ->media_engine()->GetAudioState(); | 
| 2340 call_config.bitrate_config.min_bitrate_bps = kMinBandwidthBps; | 2388 call_config.bitrate_config.min_bitrate_bps = kMinBandwidthBps; | 
| 2341 call_config.bitrate_config.start_bitrate_bps = kStartBandwidthBps; | 2389 call_config.bitrate_config.start_bitrate_bps = kStartBandwidthBps; | 
| 2342 call_config.bitrate_config.max_bitrate_bps = kMaxBandwidthBps; | 2390 call_config.bitrate_config.max_bitrate_bps = kMaxBandwidthBps; | 
| 2343 | 2391 | 
| 2344 call_.reset(webrtc::Call::Create(call_config)); | 2392 call_.reset(webrtc::Call::Create(call_config)); | 
| 2345 } | 2393 } | 
| 2346 | 2394 | 
| 2347 } // namespace webrtc | 2395 } // namespace webrtc | 
| OLD | NEW |