| 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 } | 81 } |
| 82 | 82 |
| 83 } // namespace | 83 } // namespace |
| 84 | 84 |
| 85 PassRefPtr<RTCConfiguration> RTCPeerConnection::parseConfiguration(const Diction
ary& configuration, ExceptionState& exceptionState) | 85 PassRefPtr<RTCConfiguration> RTCPeerConnection::parseConfiguration(const Diction
ary& configuration, ExceptionState& exceptionState) |
| 86 { | 86 { |
| 87 if (configuration.isUndefinedOrNull()) | 87 if (configuration.isUndefinedOrNull()) |
| 88 return nullptr; | 88 return nullptr; |
| 89 | 89 |
| 90 ArrayValue iceServers; | 90 ArrayValue iceServers; |
| 91 bool ok = configuration.get("iceServers", iceServers); | 91 bool ok = DictionaryHelper::get(configuration, "iceServers", iceServers); |
| 92 if (!ok || iceServers.isUndefinedOrNull()) { | 92 if (!ok || iceServers.isUndefinedOrNull()) { |
| 93 exceptionState.throwTypeError("Malformed RTCConfiguration"); | 93 exceptionState.throwTypeError("Malformed RTCConfiguration"); |
| 94 return nullptr; | 94 return nullptr; |
| 95 } | 95 } |
| 96 | 96 |
| 97 size_t numberOfServers; | 97 size_t numberOfServers; |
| 98 ok = iceServers.length(numberOfServers); | 98 ok = iceServers.length(numberOfServers); |
| 99 if (!ok) { | 99 if (!ok) { |
| 100 exceptionState.throwTypeError("Malformed RTCConfiguration"); | 100 exceptionState.throwTypeError("Malformed RTCConfiguration"); |
| 101 return nullptr; | 101 return nullptr; |
| 102 } | 102 } |
| 103 | 103 |
| 104 RefPtr<RTCConfiguration> rtcConfiguration = RTCConfiguration::create(); | 104 RefPtr<RTCConfiguration> rtcConfiguration = RTCConfiguration::create(); |
| 105 | 105 |
| 106 for (size_t i = 0; i < numberOfServers; ++i) { | 106 for (size_t i = 0; i < numberOfServers; ++i) { |
| 107 Dictionary iceServer; | 107 Dictionary iceServer; |
| 108 ok = iceServers.get(i, iceServer); | 108 ok = iceServers.get(i, iceServer); |
| 109 if (!ok) { | 109 if (!ok) { |
| 110 exceptionState.throwTypeError("Malformed RTCIceServer"); | 110 exceptionState.throwTypeError("Malformed RTCIceServer"); |
| 111 return nullptr; | 111 return nullptr; |
| 112 } | 112 } |
| 113 | 113 |
| 114 Vector<String> names; | 114 Vector<String> names; |
| 115 iceServer.getOwnPropertyNames(names); | 115 iceServer.getOwnPropertyNames(names); |
| 116 | 116 |
| 117 Vector<String> urlStrings; | 117 Vector<String> urlStrings; |
| 118 if (names.contains("urls")) { | 118 if (names.contains("urls")) { |
| 119 if (!iceServer.get("urls", urlStrings) || !urlStrings.size()) { | 119 if (!DictionaryHelper::get(iceServer, "urls", urlStrings) || !urlStr
ings.size()) { |
| 120 String urlString; | 120 String urlString; |
| 121 if (iceServer.get("urls", urlString)) { | 121 if (DictionaryHelper::get(iceServer, "urls", urlString)) { |
| 122 urlStrings.append(urlString); | 122 urlStrings.append(urlString); |
| 123 } else { | 123 } else { |
| 124 exceptionState.throwTypeError("Malformed RTCIceServer"); | 124 exceptionState.throwTypeError("Malformed RTCIceServer"); |
| 125 return nullptr; | 125 return nullptr; |
| 126 } | 126 } |
| 127 } | 127 } |
| 128 } else if (names.contains("url")) { | 128 } else if (names.contains("url")) { |
| 129 String urlString; | 129 String urlString; |
| 130 if (iceServer.get("url", urlString)) { | 130 if (DictionaryHelper::get(iceServer, "url", urlString)) { |
| 131 urlStrings.append(urlString); | 131 urlStrings.append(urlString); |
| 132 } else { | 132 } else { |
| 133 exceptionState.throwTypeError("Malformed RTCIceServer"); | 133 exceptionState.throwTypeError("Malformed RTCIceServer"); |
| 134 return nullptr; | 134 return nullptr; |
| 135 } | 135 } |
| 136 } else { | 136 } else { |
| 137 exceptionState.throwTypeError("Malformed RTCIceServer"); | 137 exceptionState.throwTypeError("Malformed RTCIceServer"); |
| 138 return nullptr; | 138 return nullptr; |
| 139 } | 139 } |
| 140 | 140 |
| 141 String username, credential; | 141 String username, credential; |
| 142 iceServer.get("username", username); | 142 DictionaryHelper::get(iceServer, "username", username); |
| 143 iceServer.get("credential", credential); | 143 DictionaryHelper::get(iceServer, "credential", credential); |
| 144 | 144 |
| 145 for (Vector<String>::iterator iter = urlStrings.begin(); iter != urlStri
ngs.end(); ++iter) { | 145 for (Vector<String>::iterator iter = urlStrings.begin(); iter != urlStri
ngs.end(); ++iter) { |
| 146 KURL url(KURL(), *iter); | 146 KURL url(KURL(), *iter); |
| 147 if (!url.isValid() || !(url.protocolIs("turn") || url.protocolIs("tu
rns") || url.protocolIs("stun"))) { | 147 if (!url.isValid() || !(url.protocolIs("turn") || url.protocolIs("tu
rns") || url.protocolIs("stun"))) { |
| 148 exceptionState.throwTypeError("Malformed URL"); | 148 exceptionState.throwTypeError("Malformed URL"); |
| 149 return nullptr; | 149 return nullptr; |
| 150 } | 150 } |
| 151 | 151 |
| 152 rtcConfiguration->appendServer(RTCIceServer::create(url, username, c
redential)); | 152 rtcConfiguration->appendServer(RTCIceServer::create(url, username, c
redential)); |
| 153 } | 153 } |
| (...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 482 // FIXME: Add passing selector as part of the statsRequest. | 482 // FIXME: Add passing selector as part of the statsRequest. |
| 483 m_peerHandler->getStats(statsRequest.release()); | 483 m_peerHandler->getStats(statsRequest.release()); |
| 484 } | 484 } |
| 485 | 485 |
| 486 RTCDataChannel* RTCPeerConnection::createDataChannel(String label, const Diction
ary& options, ExceptionState& exceptionState) | 486 RTCDataChannel* RTCPeerConnection::createDataChannel(String label, const Diction
ary& options, ExceptionState& exceptionState) |
| 487 { | 487 { |
| 488 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) | 488 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) |
| 489 return nullptr; | 489 return nullptr; |
| 490 | 490 |
| 491 blink::WebRTCDataChannelInit init; | 491 blink::WebRTCDataChannelInit init; |
| 492 options.get("ordered", init.ordered); | 492 DictionaryHelper::get(options, "ordered", init.ordered); |
| 493 options.get("negotiated", init.negotiated); | 493 DictionaryHelper::get(options, "negotiated", init.negotiated); |
| 494 | 494 |
| 495 unsigned short value = 0; | 495 unsigned short value = 0; |
| 496 if (options.get("id", value)) | 496 if (DictionaryHelper::get(options, "id", value)) |
| 497 init.id = value; | 497 init.id = value; |
| 498 if (options.get("maxRetransmits", value)) | 498 if (DictionaryHelper::get(options, "maxRetransmits", value)) |
| 499 init.maxRetransmits = value; | 499 init.maxRetransmits = value; |
| 500 if (options.get("maxRetransmitTime", value)) | 500 if (DictionaryHelper::get(options, "maxRetransmitTime", value)) |
| 501 init.maxRetransmitTime = value; | 501 init.maxRetransmitTime = value; |
| 502 | 502 |
| 503 String protocolString; | 503 String protocolString; |
| 504 options.get("protocol", protocolString); | 504 DictionaryHelper::get(options, "protocol", protocolString); |
| 505 init.protocol = protocolString; | 505 init.protocol = protocolString; |
| 506 | 506 |
| 507 RTCDataChannel* channel = RTCDataChannel::create(executionContext(), this, m
_peerHandler.get(), label, init, exceptionState); | 507 RTCDataChannel* channel = RTCDataChannel::create(executionContext(), this, m
_peerHandler.get(), label, init, exceptionState); |
| 508 if (exceptionState.hadException()) | 508 if (exceptionState.hadException()) |
| 509 return nullptr; | 509 return nullptr; |
| 510 m_dataChannels.append(channel); | 510 m_dataChannels.append(channel); |
| 511 return channel; | 511 return channel; |
| 512 } | 512 } |
| 513 | 513 |
| 514 bool RTCPeerConnection::hasLocalStreamWithTrackId(const String& trackId) | 514 bool RTCPeerConnection::hasLocalStreamWithTrackId(const String& trackId) |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 734 visitor->trace(m_localStreams); | 734 visitor->trace(m_localStreams); |
| 735 visitor->trace(m_remoteStreams); | 735 visitor->trace(m_remoteStreams); |
| 736 visitor->trace(m_dataChannels); | 736 visitor->trace(m_dataChannels); |
| 737 #if ENABLE(OILPAN) | 737 #if ENABLE(OILPAN) |
| 738 visitor->trace(m_scheduledEvents); | 738 visitor->trace(m_scheduledEvents); |
| 739 #endif | 739 #endif |
| 740 EventTargetWithInlineData::trace(visitor); | 740 EventTargetWithInlineData::trace(visitor); |
| 741 } | 741 } |
| 742 | 742 |
| 743 } // namespace WebCore | 743 } // namespace WebCore |
| OLD | NEW |