OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
222 if (policy == "none") | 222 if (policy == "none") |
223 return WebRTCIceTransportPolicy::kNone; | 223 return WebRTCIceTransportPolicy::kNone; |
224 if (policy == "relay") | 224 if (policy == "relay") |
225 return WebRTCIceTransportPolicy::kRelay; | 225 return WebRTCIceTransportPolicy::kRelay; |
226 DCHECK_EQ(policy, "all"); | 226 DCHECK_EQ(policy, "all"); |
227 return WebRTCIceTransportPolicy::kAll; | 227 return WebRTCIceTransportPolicy::kAll; |
228 } | 228 } |
229 | 229 |
230 WebRTCConfiguration parseConfiguration(ExecutionContext* context, | 230 WebRTCConfiguration parseConfiguration(ExecutionContext* context, |
231 const RTCConfiguration& configuration, | 231 const RTCConfiguration& configuration, |
232 ExceptionState& exceptionState, | 232 ExceptionState& exceptionState) { |
233 RtcpMuxPolicy* selectedRtcpMuxPolicy) { | |
234 DCHECK(context); | 233 DCHECK(context); |
235 DCHECK(selectedRtcpMuxPolicy); | |
236 | 234 |
237 WebRTCIceTransportPolicy iceTransportPolicy = WebRTCIceTransportPolicy::kAll; | 235 WebRTCIceTransportPolicy iceTransportPolicy = WebRTCIceTransportPolicy::kAll; |
238 if (configuration.hasIceTransportPolicy()) { | 236 if (configuration.hasIceTransportPolicy()) { |
239 UseCounter::count(context, UseCounter::RTCConfigurationIceTransportPolicy); | 237 UseCounter::count(context, UseCounter::RTCConfigurationIceTransportPolicy); |
240 iceTransportPolicy = | 238 iceTransportPolicy = |
241 iceTransportPolicyFromString(configuration.iceTransportPolicy()); | 239 iceTransportPolicyFromString(configuration.iceTransportPolicy()); |
242 if (iceTransportPolicy == WebRTCIceTransportPolicy::kNone) { | 240 if (iceTransportPolicy == WebRTCIceTransportPolicy::kNone) { |
243 UseCounter::count(context, | 241 UseCounter::count(context, |
244 UseCounter::RTCConfigurationIceTransportPolicyNone); | 242 UseCounter::RTCConfigurationIceTransportPolicyNone); |
245 } | 243 } |
246 } else if (configuration.hasIceTransports()) { | 244 } else if (configuration.hasIceTransports()) { |
247 UseCounter::count(context, UseCounter::RTCConfigurationIceTransports); | 245 UseCounter::count(context, UseCounter::RTCConfigurationIceTransports); |
248 iceTransportPolicy = | 246 iceTransportPolicy = |
249 iceTransportPolicyFromString(configuration.iceTransports()); | 247 iceTransportPolicyFromString(configuration.iceTransports()); |
250 if (iceTransportPolicy == WebRTCIceTransportPolicy::kNone) | 248 if (iceTransportPolicy == WebRTCIceTransportPolicy::kNone) |
251 UseCounter::count(context, UseCounter::RTCConfigurationIceTransportsNone); | 249 UseCounter::count(context, UseCounter::RTCConfigurationIceTransportsNone); |
252 } | 250 } |
253 | 251 |
254 WebRTCBundlePolicy bundlePolicy = WebRTCBundlePolicy::kBalanced; | 252 WebRTCBundlePolicy bundlePolicy = WebRTCBundlePolicy::kBalanced; |
255 String bundlePolicyString = configuration.bundlePolicy(); | 253 String bundlePolicyString = configuration.bundlePolicy(); |
256 if (bundlePolicyString == "max-compat") { | 254 if (bundlePolicyString == "max-compat") { |
257 bundlePolicy = WebRTCBundlePolicy::kMaxCompat; | 255 bundlePolicy = WebRTCBundlePolicy::kMaxCompat; |
258 } else if (bundlePolicyString == "max-bundle") { | 256 } else if (bundlePolicyString == "max-bundle") { |
259 bundlePolicy = WebRTCBundlePolicy::kMaxBundle; | 257 bundlePolicy = WebRTCBundlePolicy::kMaxBundle; |
260 } else { | 258 } else { |
261 DCHECK_EQ(bundlePolicyString, "balanced"); | 259 DCHECK_EQ(bundlePolicyString, "balanced"); |
262 } | 260 } |
263 | 261 |
264 // For the histogram value of "WebRTC.PeerConnection.SelectedRtcpMuxPolicy". | 262 WebRTCRtcpMuxPolicy rtcpMuxPolicy = WebRTCRtcpMuxPolicy::kRequire; |
265 *selectedRtcpMuxPolicy = RtcpMuxPolicyDefault; | |
266 WebRTCRtcpMuxPolicy rtcpMuxPolicy = WebRTCRtcpMuxPolicy::kNegotiate; | |
267 if (configuration.hasRtcpMuxPolicy()) { | 263 if (configuration.hasRtcpMuxPolicy()) { |
foolip
2016/12/14 19:24:47
Now that rtcpMuxPolicy has a default value in the
zhihuang1
2016/12/15 19:14:28
Done.
| |
268 String rtcpMuxPolicyString = configuration.rtcpMuxPolicy(); | 264 String rtcpMuxPolicyString = configuration.rtcpMuxPolicy(); |
269 if (rtcpMuxPolicyString == "require") { | 265 if (rtcpMuxPolicyString != "require") { |
foolip
2016/12/14 19:24:47
To match the above structure, I'd do:
if (rtcpMux
zhihuang1
2016/12/15 19:14:28
Done.
| |
270 *selectedRtcpMuxPolicy = RtcpMuxPolicyRequire; | |
271 rtcpMuxPolicy = WebRTCRtcpMuxPolicy::kRequire; | |
272 } else { | |
273 DCHECK_EQ(rtcpMuxPolicyString, "negotiate"); | 266 DCHECK_EQ(rtcpMuxPolicyString, "negotiate"); |
274 *selectedRtcpMuxPolicy = RtcpMuxPolicyNegotiate; | 267 rtcpMuxPolicy = WebRTCRtcpMuxPolicy::kNegotiate; |
275 } | 268 } |
276 } | 269 } |
277 | 270 |
278 WebRTCConfiguration webConfiguration; | 271 WebRTCConfiguration webConfiguration; |
279 webConfiguration.iceTransportPolicy = iceTransportPolicy; | 272 webConfiguration.iceTransportPolicy = iceTransportPolicy; |
280 webConfiguration.bundlePolicy = bundlePolicy; | 273 webConfiguration.bundlePolicy = bundlePolicy; |
281 webConfiguration.rtcpMuxPolicy = rtcpMuxPolicy; | 274 webConfiguration.rtcpMuxPolicy = rtcpMuxPolicy; |
282 | 275 |
283 if (configuration.hasIceServers()) { | 276 if (configuration.hasIceServers()) { |
284 Vector<WebRTCIceServer> iceServers; | 277 Vector<WebRTCIceServer> iceServers; |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
434 const RTCConfiguration& rtcConfiguration, | 427 const RTCConfiguration& rtcConfiguration, |
435 const Dictionary& mediaConstraints, | 428 const Dictionary& mediaConstraints, |
436 ExceptionState& exceptionState) { | 429 ExceptionState& exceptionState) { |
437 if (mediaConstraints.isObject()) | 430 if (mediaConstraints.isObject()) |
438 UseCounter::count(context, | 431 UseCounter::count(context, |
439 UseCounter::RTCPeerConnectionConstructorConstraints); | 432 UseCounter::RTCPeerConnectionConstructorConstraints); |
440 else | 433 else |
441 UseCounter::count(context, | 434 UseCounter::count(context, |
442 UseCounter::RTCPeerConnectionConstructorCompliant); | 435 UseCounter::RTCPeerConnectionConstructorCompliant); |
443 | 436 |
444 // Record the RtcpMuxPolicy for histogram | 437 WebRTCConfiguration configuration = |
445 // "WebRTC.PeerConnection.SelectedRtcpMuxPolicy". | 438 parseConfiguration(context, rtcConfiguration, exceptionState); |
446 RtcpMuxPolicy selectedRtcpMuxPolicy = RtcpMuxPolicyDefault; | |
447 WebRTCConfiguration configuration = parseConfiguration( | |
448 context, rtcConfiguration, exceptionState, &selectedRtcpMuxPolicy); | |
449 if (exceptionState.hadException()) | 439 if (exceptionState.hadException()) |
450 return 0; | 440 return 0; |
451 | 441 |
452 // Make sure no certificates have expired. | 442 // Make sure no certificates have expired. |
453 if (configuration.certificates.size() > 0) { | 443 if (configuration.certificates.size() > 0) { |
454 DOMTimeStamp now = convertSecondsToDOMTimeStamp(currentTime()); | 444 DOMTimeStamp now = convertSecondsToDOMTimeStamp(currentTime()); |
455 for (const std::unique_ptr<WebRTCCertificate>& certificate : | 445 for (const std::unique_ptr<WebRTCCertificate>& certificate : |
456 configuration.certificates) { | 446 configuration.certificates) { |
457 DOMTimeStamp expires = certificate->expires(); | 447 DOMTimeStamp expires = certificate->expires(); |
458 if (expires <= now) { | 448 if (expires <= now) { |
(...skipping 11 matching lines...) Expand all Loading... | |
470 mediaErrorState.raiseException(exceptionState); | 460 mediaErrorState.raiseException(exceptionState); |
471 return 0; | 461 return 0; |
472 } | 462 } |
473 | 463 |
474 RTCPeerConnection* peerConnection = new RTCPeerConnection( | 464 RTCPeerConnection* peerConnection = new RTCPeerConnection( |
475 context, configuration, constraints, exceptionState); | 465 context, configuration, constraints, exceptionState); |
476 peerConnection->suspendIfNeeded(); | 466 peerConnection->suspendIfNeeded(); |
477 if (exceptionState.hadException()) | 467 if (exceptionState.hadException()) |
478 return 0; | 468 return 0; |
479 | 469 |
480 peerConnection->m_peerHandler->logSelectedRtcpMuxPolicy( | |
481 selectedRtcpMuxPolicy); | |
482 | |
483 return peerConnection; | 470 return peerConnection; |
484 } | 471 } |
485 | 472 |
486 RTCPeerConnection::RTCPeerConnection(ExecutionContext* context, | 473 RTCPeerConnection::RTCPeerConnection(ExecutionContext* context, |
487 const WebRTCConfiguration& configuration, | 474 const WebRTCConfiguration& configuration, |
488 WebMediaConstraints constraints, | 475 WebMediaConstraints constraints, |
489 ExceptionState& exceptionState) | 476 ExceptionState& exceptionState) |
490 : ActiveScriptWrappable(this), | 477 : ActiveScriptWrappable(this), |
491 ActiveDOMObject(context), | 478 ActiveDOMObject(context), |
492 m_signalingState(SignalingStateStable), | 479 m_signalingState(SignalingStateStable), |
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
806 return RTCSessionDescription::create(webSessionDescription); | 793 return RTCSessionDescription::create(webSessionDescription); |
807 } | 794 } |
808 | 795 |
809 void RTCPeerConnection::updateIce(ExecutionContext* context, | 796 void RTCPeerConnection::updateIce(ExecutionContext* context, |
810 const RTCConfiguration& rtcConfiguration, | 797 const RTCConfiguration& rtcConfiguration, |
811 const Dictionary& mediaConstraints, | 798 const Dictionary& mediaConstraints, |
812 ExceptionState& exceptionState) { | 799 ExceptionState& exceptionState) { |
813 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) | 800 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) |
814 return; | 801 return; |
815 | 802 |
816 RtcpMuxPolicy selectedRtcpMuxPolicy = RtcpMuxPolicyDefault; | 803 WebRTCConfiguration configuration = |
817 WebRTCConfiguration configuration = parseConfiguration( | 804 parseConfiguration(context, rtcConfiguration, exceptionState); |
818 context, rtcConfiguration, exceptionState, &selectedRtcpMuxPolicy); | |
819 | 805 |
820 if (exceptionState.hadException()) | 806 if (exceptionState.hadException()) |
821 return; | 807 return; |
822 | 808 |
823 MediaErrorState mediaErrorState; | 809 MediaErrorState mediaErrorState; |
824 if (mediaErrorState.hadException()) { | 810 if (mediaErrorState.hadException()) { |
825 mediaErrorState.raiseException(exceptionState); | 811 mediaErrorState.raiseException(exceptionState); |
826 return; | 812 return; |
827 } | 813 } |
828 | 814 |
(...skipping 662 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1491 DEFINE_TRACE(RTCPeerConnection) { | 1477 DEFINE_TRACE(RTCPeerConnection) { |
1492 visitor->trace(m_localStreams); | 1478 visitor->trace(m_localStreams); |
1493 visitor->trace(m_remoteStreams); | 1479 visitor->trace(m_remoteStreams); |
1494 visitor->trace(m_dispatchScheduledEventRunner); | 1480 visitor->trace(m_dispatchScheduledEventRunner); |
1495 visitor->trace(m_scheduledEvents); | 1481 visitor->trace(m_scheduledEvents); |
1496 EventTargetWithInlineData::trace(visitor); | 1482 EventTargetWithInlineData::trace(visitor); |
1497 ActiveDOMObject::trace(visitor); | 1483 ActiveDOMObject::trace(visitor); |
1498 } | 1484 } |
1499 | 1485 |
1500 } // namespace blink | 1486 } // namespace blink |
OLD | NEW |