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; | 263 String rtcpMuxPolicyString = configuration.rtcpMuxPolicy(); |
266 WebRTCRtcpMuxPolicy rtcpMuxPolicy = WebRTCRtcpMuxPolicy::kNegotiate; | 264 if (rtcpMuxPolicyString == "negotiate") { |
267 if (configuration.hasRtcpMuxPolicy()) { | 265 rtcpMuxPolicy = WebRTCRtcpMuxPolicy::kNegotiate; |
268 String rtcpMuxPolicyString = configuration.rtcpMuxPolicy(); | 266 } else { |
269 if (rtcpMuxPolicyString == "require") { | 267 DCHECK_EQ(rtcpMuxPolicyString, "require"); |
270 *selectedRtcpMuxPolicy = RtcpMuxPolicyRequire; | |
271 rtcpMuxPolicy = WebRTCRtcpMuxPolicy::kRequire; | |
272 } else { | |
273 DCHECK_EQ(rtcpMuxPolicyString, "negotiate"); | |
274 *selectedRtcpMuxPolicy = RtcpMuxPolicyNegotiate; | |
275 } | |
276 } | 268 } |
277 | |
278 WebRTCConfiguration webConfiguration; | 269 WebRTCConfiguration webConfiguration; |
279 webConfiguration.iceTransportPolicy = iceTransportPolicy; | 270 webConfiguration.iceTransportPolicy = iceTransportPolicy; |
280 webConfiguration.bundlePolicy = bundlePolicy; | 271 webConfiguration.bundlePolicy = bundlePolicy; |
281 webConfiguration.rtcpMuxPolicy = rtcpMuxPolicy; | 272 webConfiguration.rtcpMuxPolicy = rtcpMuxPolicy; |
282 | 273 |
283 if (configuration.hasIceServers()) { | 274 if (configuration.hasIceServers()) { |
284 Vector<WebRTCIceServer> iceServers; | 275 Vector<WebRTCIceServer> iceServers; |
285 for (const RTCIceServer& iceServer : configuration.iceServers()) { | 276 for (const RTCIceServer& iceServer : configuration.iceServers()) { |
286 Vector<String> urlStrings; | 277 Vector<String> urlStrings; |
287 if (iceServer.hasURLs()) { | 278 if (iceServer.hasURLs()) { |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
434 const RTCConfiguration& rtcConfiguration, | 425 const RTCConfiguration& rtcConfiguration, |
435 const Dictionary& mediaConstraints, | 426 const Dictionary& mediaConstraints, |
436 ExceptionState& exceptionState) { | 427 ExceptionState& exceptionState) { |
437 if (mediaConstraints.isObject()) | 428 if (mediaConstraints.isObject()) |
438 UseCounter::count(context, | 429 UseCounter::count(context, |
439 UseCounter::RTCPeerConnectionConstructorConstraints); | 430 UseCounter::RTCPeerConnectionConstructorConstraints); |
440 else | 431 else |
441 UseCounter::count(context, | 432 UseCounter::count(context, |
442 UseCounter::RTCPeerConnectionConstructorCompliant); | 433 UseCounter::RTCPeerConnectionConstructorCompliant); |
443 | 434 |
444 // Record the RtcpMuxPolicy for histogram | 435 WebRTCConfiguration configuration = |
445 // "WebRTC.PeerConnection.SelectedRtcpMuxPolicy". | 436 parseConfiguration(context, rtcConfiguration, exceptionState); |
446 RtcpMuxPolicy selectedRtcpMuxPolicy = RtcpMuxPolicyDefault; | |
447 WebRTCConfiguration configuration = parseConfiguration( | |
448 context, rtcConfiguration, exceptionState, &selectedRtcpMuxPolicy); | |
449 if (exceptionState.hadException()) | 437 if (exceptionState.hadException()) |
450 return 0; | 438 return 0; |
451 | 439 |
452 // Make sure no certificates have expired. | 440 // Make sure no certificates have expired. |
453 if (configuration.certificates.size() > 0) { | 441 if (configuration.certificates.size() > 0) { |
454 DOMTimeStamp now = convertSecondsToDOMTimeStamp(currentTime()); | 442 DOMTimeStamp now = convertSecondsToDOMTimeStamp(currentTime()); |
455 for (const std::unique_ptr<WebRTCCertificate>& certificate : | 443 for (const std::unique_ptr<WebRTCCertificate>& certificate : |
456 configuration.certificates) { | 444 configuration.certificates) { |
457 DOMTimeStamp expires = certificate->expires(); | 445 DOMTimeStamp expires = certificate->expires(); |
458 if (expires <= now) { | 446 if (expires <= now) { |
(...skipping 11 matching lines...) Expand all Loading... |
470 mediaErrorState.raiseException(exceptionState); | 458 mediaErrorState.raiseException(exceptionState); |
471 return 0; | 459 return 0; |
472 } | 460 } |
473 | 461 |
474 RTCPeerConnection* peerConnection = new RTCPeerConnection( | 462 RTCPeerConnection* peerConnection = new RTCPeerConnection( |
475 context, configuration, constraints, exceptionState); | 463 context, configuration, constraints, exceptionState); |
476 peerConnection->suspendIfNeeded(); | 464 peerConnection->suspendIfNeeded(); |
477 if (exceptionState.hadException()) | 465 if (exceptionState.hadException()) |
478 return 0; | 466 return 0; |
479 | 467 |
480 peerConnection->m_peerHandler->logSelectedRtcpMuxPolicy( | |
481 selectedRtcpMuxPolicy); | |
482 | |
483 return peerConnection; | 468 return peerConnection; |
484 } | 469 } |
485 | 470 |
486 RTCPeerConnection::RTCPeerConnection(ExecutionContext* context, | 471 RTCPeerConnection::RTCPeerConnection(ExecutionContext* context, |
487 const WebRTCConfiguration& configuration, | 472 const WebRTCConfiguration& configuration, |
488 WebMediaConstraints constraints, | 473 WebMediaConstraints constraints, |
489 ExceptionState& exceptionState) | 474 ExceptionState& exceptionState) |
490 : SuspendableObject(context), | 475 : SuspendableObject(context), |
491 m_signalingState(SignalingStateStable), | 476 m_signalingState(SignalingStateStable), |
492 m_iceGatheringState(ICEGatheringStateNew), | 477 m_iceGatheringState(ICEGatheringStateNew), |
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
804 return RTCSessionDescription::create(webSessionDescription); | 789 return RTCSessionDescription::create(webSessionDescription); |
805 } | 790 } |
806 | 791 |
807 void RTCPeerConnection::updateIce(ExecutionContext* context, | 792 void RTCPeerConnection::updateIce(ExecutionContext* context, |
808 const RTCConfiguration& rtcConfiguration, | 793 const RTCConfiguration& rtcConfiguration, |
809 const Dictionary&, | 794 const Dictionary&, |
810 ExceptionState& exceptionState) { | 795 ExceptionState& exceptionState) { |
811 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) | 796 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) |
812 return; | 797 return; |
813 | 798 |
814 RtcpMuxPolicy selectedRtcpMuxPolicy = RtcpMuxPolicyDefault; | 799 WebRTCConfiguration configuration = |
815 WebRTCConfiguration configuration = parseConfiguration( | 800 parseConfiguration(context, rtcConfiguration, exceptionState); |
816 context, rtcConfiguration, exceptionState, &selectedRtcpMuxPolicy); | |
817 | 801 |
818 if (exceptionState.hadException()) | 802 if (exceptionState.hadException()) |
819 return; | 803 return; |
820 | 804 |
821 MediaErrorState mediaErrorState; | 805 MediaErrorState mediaErrorState; |
822 if (mediaErrorState.hadException()) { | 806 if (mediaErrorState.hadException()) { |
823 mediaErrorState.raiseException(exceptionState); | 807 mediaErrorState.raiseException(exceptionState); |
824 return; | 808 return; |
825 } | 809 } |
826 | 810 |
(...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1488 DEFINE_TRACE(RTCPeerConnection) { | 1472 DEFINE_TRACE(RTCPeerConnection) { |
1489 visitor->trace(m_localStreams); | 1473 visitor->trace(m_localStreams); |
1490 visitor->trace(m_remoteStreams); | 1474 visitor->trace(m_remoteStreams); |
1491 visitor->trace(m_dispatchScheduledEventRunner); | 1475 visitor->trace(m_dispatchScheduledEventRunner); |
1492 visitor->trace(m_scheduledEvents); | 1476 visitor->trace(m_scheduledEvents); |
1493 EventTargetWithInlineData::trace(visitor); | 1477 EventTargetWithInlineData::trace(visitor); |
1494 SuspendableObject::trace(visitor); | 1478 SuspendableObject::trace(visitor); |
1495 } | 1479 } |
1496 | 1480 |
1497 } // namespace blink | 1481 } // namespace blink |
OLD | NEW |