Chromium Code Reviews| 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 1217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1228 kEnumCounterAddressFamily, kPeerConnection_IPv6, | 1228 kEnumCounterAddressFamily, kPeerConnection_IPv6, |
| 1229 kPeerConnectionAddressFamilyCounter_Max); | 1229 kPeerConnectionAddressFamilyCounter_Max); |
| 1230 } else { | 1230 } else { |
| 1231 uma_observer_->IncrementEnumCounter( | 1231 uma_observer_->IncrementEnumCounter( |
| 1232 kEnumCounterAddressFamily, kPeerConnection_IPv4, | 1232 kEnumCounterAddressFamily, kPeerConnection_IPv4, |
| 1233 kPeerConnectionAddressFamilyCounter_Max); | 1233 kPeerConnectionAddressFamilyCounter_Max); |
| 1234 } | 1234 } |
| 1235 } | 1235 } |
| 1236 } | 1236 } |
| 1237 | 1237 |
| 1238 RTCError PeerConnection::SetBitrate(const BitrateParameters& bitrate) { | |
| 1239 rtc::Thread* worker_thread = factory_->worker_thread(); | |
| 1240 if (!worker_thread->IsCurrent()) { | |
| 1241 return worker_thread->Invoke<RTCError>( | |
| 1242 RTC_FROM_HERE, rtc::Bind(&PeerConnection::SetBitrate, this, bitrate)); | |
| 1243 } | |
| 1244 | |
| 1245 const bool has_min = static_cast<bool>(bitrate.min_bitrate_bps); | |
| 1246 const bool has_current = static_cast<bool>(bitrate.current_bitrate_bps); | |
| 1247 const bool has_max = static_cast<bool>(bitrate.max_bitrate_bps); | |
| 1248 if (has_min && *bitrate.min_bitrate_bps < 0) { | |
| 1249 LOG_AND_RETURN_ERROR(RTCErrorType::INVALID_PARAMETER, | |
| 1250 "min_bitrate_bps <= 0"); | |
| 1251 } | |
| 1252 if (has_current) { | |
| 1253 if (has_min && *bitrate.current_bitrate_bps < *bitrate.min_bitrate_bps) { | |
| 1254 LOG_AND_RETURN_ERROR(RTCErrorType::INVALID_PARAMETER, | |
| 1255 "current_bitrate_bps < min_bitrate_bps"); | |
| 1256 } else if (*bitrate.current_bitrate_bps < 0) { | |
| 1257 LOG_AND_RETURN_ERROR(RTCErrorType::INVALID_PARAMETER, | |
| 1258 "curent_bitrate_bps < 0"); | |
| 1259 } | |
| 1260 } | |
| 1261 if (has_max) { | |
| 1262 if (has_current && | |
| 1263 *bitrate.max_bitrate_bps < *bitrate.current_bitrate_bps) { | |
| 1264 LOG_AND_RETURN_ERROR(RTCErrorType::INVALID_PARAMETER, | |
| 1265 "max_bitrate_bps < current_bitrate_bps"); | |
| 1266 } else if (has_min && *bitrate.max_bitrate_bps < *bitrate.min_bitrate_bps) { | |
| 1267 LOG_AND_RETURN_ERROR(RTCErrorType::INVALID_PARAMETER, | |
| 1268 "max_bitrate_bps < min_bitrate_bps"); | |
| 1269 } else if (*bitrate.max_bitrate_bps < 0) { | |
| 1270 LOG_AND_RETURN_ERROR(RTCErrorType::INVALID_PARAMETER, | |
| 1271 "max_bitrate_bps < 0"); | |
| 1272 } | |
| 1273 } | |
| 1274 | |
| 1275 Call::Config::BitrateConfigMask mask; | |
| 1276 mask.min_bitrate_bps = bitrate.min_bitrate_bps; | |
| 1277 mask.start_bitrate_bps = bitrate.current_bitrate_bps; | |
| 1278 mask.max_bitrate_bps = bitrate.max_bitrate_bps; | |
| 1279 | |
| 1280 RTC_DCHECK(media_controller_); | |
| 1281 Call* call = media_controller_->call_w(); | |
| 1282 call->SetBitrateConfigMask(mask); | |
|
Taylor_Brandstetter
2017/04/26 15:46:11
Should check the return value (if it still has a r
Zach Stein
2017/05/04 22:32:44
Nice catch. I also added a test case.
| |
| 1283 | |
| 1284 return RTCError::OK(); | |
| 1285 } | |
| 1286 | |
| 1238 bool PeerConnection::StartRtcEventLog(rtc::PlatformFile file, | 1287 bool PeerConnection::StartRtcEventLog(rtc::PlatformFile file, |
| 1239 int64_t max_size_bytes) { | 1288 int64_t max_size_bytes) { |
| 1240 return factory_->worker_thread()->Invoke<bool>( | 1289 return factory_->worker_thread()->Invoke<bool>( |
| 1241 RTC_FROM_HERE, rtc::Bind(&PeerConnection::StartRtcEventLog_w, this, file, | 1290 RTC_FROM_HERE, rtc::Bind(&PeerConnection::StartRtcEventLog_w, this, file, |
| 1242 max_size_bytes)); | 1291 max_size_bytes)); |
| 1243 } | 1292 } |
| 1244 | 1293 |
| 1245 void PeerConnection::StopRtcEventLog() { | 1294 void PeerConnection::StopRtcEventLog() { |
| 1246 factory_->worker_thread()->Invoke<void>( | 1295 factory_->worker_thread()->Invoke<void>( |
| 1247 RTC_FROM_HERE, rtc::Bind(&PeerConnection::StopRtcEventLog_w, this)); | 1296 RTC_FROM_HERE, rtc::Bind(&PeerConnection::StopRtcEventLog_w, this)); |
| (...skipping 1060 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2308 } | 2357 } |
| 2309 return event_log_->StartLogging(file, max_size_bytes); | 2358 return event_log_->StartLogging(file, max_size_bytes); |
| 2310 } | 2359 } |
| 2311 | 2360 |
| 2312 void PeerConnection::StopRtcEventLog_w() { | 2361 void PeerConnection::StopRtcEventLog_w() { |
| 2313 if (event_log_) { | 2362 if (event_log_) { |
| 2314 event_log_->StopLogging(); | 2363 event_log_->StopLogging(); |
| 2315 } | 2364 } |
| 2316 } | 2365 } |
| 2317 } // namespace webrtc | 2366 } // namespace webrtc |
| OLD | NEW |