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 14 matching lines...) Expand all Loading... |
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #include "config.h" | 31 #include "config.h" |
32 #include "modules/mediastream/RTCPeerConnection.h" | 32 #include "modules/mediastream/RTCPeerConnection.h" |
33 | 33 |
34 #include "bindings/core/v8/ArrayValue.h" | 34 #include "bindings/core/v8/ArrayValue.h" |
| 35 #include "bindings/core/v8/DictionaryHelper.h" |
35 #include "bindings/core/v8/ExceptionMessages.h" | 36 #include "bindings/core/v8/ExceptionMessages.h" |
36 #include "bindings/core/v8/ExceptionState.h" | 37 #include "bindings/core/v8/ExceptionState.h" |
37 #include "core/dom/Document.h" | 38 #include "core/dom/Document.h" |
38 #include "core/dom/ExceptionCode.h" | 39 #include "core/dom/ExceptionCode.h" |
39 #include "core/dom/ExecutionContext.h" | 40 #include "core/dom/ExecutionContext.h" |
40 #include "core/frame/LocalFrame.h" | 41 #include "core/frame/LocalFrame.h" |
41 #include "core/html/VoidCallback.h" | 42 #include "core/html/VoidCallback.h" |
42 #include "core/loader/FrameLoader.h" | 43 #include "core/loader/FrameLoader.h" |
43 #include "core/loader/FrameLoaderClient.h" | 44 #include "core/loader/FrameLoaderClient.h" |
44 #include "modules/mediastream/MediaConstraintsImpl.h" | 45 #include "modules/mediastream/MediaConstraintsImpl.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 } | 82 } |
82 | 83 |
83 } // namespace | 84 } // namespace |
84 | 85 |
85 PassRefPtr<RTCConfiguration> RTCPeerConnection::parseConfiguration(const Diction
ary& configuration, ExceptionState& exceptionState) | 86 PassRefPtr<RTCConfiguration> RTCPeerConnection::parseConfiguration(const Diction
ary& configuration, ExceptionState& exceptionState) |
86 { | 87 { |
87 if (configuration.isUndefinedOrNull()) | 88 if (configuration.isUndefinedOrNull()) |
88 return nullptr; | 89 return nullptr; |
89 | 90 |
90 ArrayValue iceServers; | 91 ArrayValue iceServers; |
91 bool ok = configuration.get("iceServers", iceServers); | 92 bool ok = DictionaryHelper::get(configuration, "iceServers", iceServers); |
92 if (!ok || iceServers.isUndefinedOrNull()) { | 93 if (!ok || iceServers.isUndefinedOrNull()) { |
93 exceptionState.throwTypeError("Malformed RTCConfiguration"); | 94 exceptionState.throwTypeError("Malformed RTCConfiguration"); |
94 return nullptr; | 95 return nullptr; |
95 } | 96 } |
96 | 97 |
97 size_t numberOfServers; | 98 size_t numberOfServers; |
98 ok = iceServers.length(numberOfServers); | 99 ok = iceServers.length(numberOfServers); |
99 if (!ok) { | 100 if (!ok) { |
100 exceptionState.throwTypeError("Malformed RTCConfiguration"); | 101 exceptionState.throwTypeError("Malformed RTCConfiguration"); |
101 return nullptr; | 102 return nullptr; |
102 } | 103 } |
103 | 104 |
104 RefPtr<RTCConfiguration> rtcConfiguration = RTCConfiguration::create(); | 105 RefPtr<RTCConfiguration> rtcConfiguration = RTCConfiguration::create(); |
105 | 106 |
106 for (size_t i = 0; i < numberOfServers; ++i) { | 107 for (size_t i = 0; i < numberOfServers; ++i) { |
107 Dictionary iceServer; | 108 Dictionary iceServer; |
108 ok = iceServers.get(i, iceServer); | 109 ok = iceServers.get(i, iceServer); |
109 if (!ok) { | 110 if (!ok) { |
110 exceptionState.throwTypeError("Malformed RTCIceServer"); | 111 exceptionState.throwTypeError("Malformed RTCIceServer"); |
111 return nullptr; | 112 return nullptr; |
112 } | 113 } |
113 | 114 |
114 Vector<String> names; | 115 Vector<String> names; |
115 iceServer.getOwnPropertyNames(names); | 116 iceServer.getOwnPropertyNames(names); |
116 | 117 |
117 Vector<String> urlStrings; | 118 Vector<String> urlStrings; |
118 if (names.contains("urls")) { | 119 if (names.contains("urls")) { |
119 if (!iceServer.get("urls", urlStrings) || !urlStrings.size()) { | 120 if (!DictionaryHelper::get(iceServer, "urls", urlStrings) || !urlStr
ings.size()) { |
120 String urlString; | 121 String urlString; |
121 if (iceServer.get("urls", urlString)) { | 122 if (DictionaryHelper::get(iceServer, "urls", urlString)) { |
122 urlStrings.append(urlString); | 123 urlStrings.append(urlString); |
123 } else { | 124 } else { |
124 exceptionState.throwTypeError("Malformed RTCIceServer"); | 125 exceptionState.throwTypeError("Malformed RTCIceServer"); |
125 return nullptr; | 126 return nullptr; |
126 } | 127 } |
127 } | 128 } |
128 } else if (names.contains("url")) { | 129 } else if (names.contains("url")) { |
129 String urlString; | 130 String urlString; |
130 if (iceServer.get("url", urlString)) { | 131 if (DictionaryHelper::get(iceServer, "url", urlString)) { |
131 urlStrings.append(urlString); | 132 urlStrings.append(urlString); |
132 } else { | 133 } else { |
133 exceptionState.throwTypeError("Malformed RTCIceServer"); | 134 exceptionState.throwTypeError("Malformed RTCIceServer"); |
134 return nullptr; | 135 return nullptr; |
135 } | 136 } |
136 } else { | 137 } else { |
137 exceptionState.throwTypeError("Malformed RTCIceServer"); | 138 exceptionState.throwTypeError("Malformed RTCIceServer"); |
138 return nullptr; | 139 return nullptr; |
139 } | 140 } |
140 | 141 |
141 String username, credential; | 142 String username, credential; |
142 iceServer.get("username", username); | 143 DictionaryHelper::get(iceServer, "username", username); |
143 iceServer.get("credential", credential); | 144 DictionaryHelper::get(iceServer, "credential", credential); |
144 | 145 |
145 for (Vector<String>::iterator iter = urlStrings.begin(); iter != urlStri
ngs.end(); ++iter) { | 146 for (Vector<String>::iterator iter = urlStrings.begin(); iter != urlStri
ngs.end(); ++iter) { |
146 KURL url(KURL(), *iter); | 147 KURL url(KURL(), *iter); |
147 if (!url.isValid() || !(url.protocolIs("turn") || url.protocolIs("tu
rns") || url.protocolIs("stun"))) { | 148 if (!url.isValid() || !(url.protocolIs("turn") || url.protocolIs("tu
rns") || url.protocolIs("stun"))) { |
148 exceptionState.throwTypeError("Malformed URL"); | 149 exceptionState.throwTypeError("Malformed URL"); |
149 return nullptr; | 150 return nullptr; |
150 } | 151 } |
151 | 152 |
152 rtcConfiguration->appendServer(RTCIceServer::create(url, username, c
redential)); | 153 rtcConfiguration->appendServer(RTCIceServer::create(url, username, c
redential)); |
153 } | 154 } |
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
482 // FIXME: Add passing selector as part of the statsRequest. | 483 // FIXME: Add passing selector as part of the statsRequest. |
483 m_peerHandler->getStats(statsRequest.release()); | 484 m_peerHandler->getStats(statsRequest.release()); |
484 } | 485 } |
485 | 486 |
486 RTCDataChannel* RTCPeerConnection::createDataChannel(String label, const Diction
ary& options, ExceptionState& exceptionState) | 487 RTCDataChannel* RTCPeerConnection::createDataChannel(String label, const Diction
ary& options, ExceptionState& exceptionState) |
487 { | 488 { |
488 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) | 489 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) |
489 return nullptr; | 490 return nullptr; |
490 | 491 |
491 blink::WebRTCDataChannelInit init; | 492 blink::WebRTCDataChannelInit init; |
492 options.get("ordered", init.ordered); | 493 DictionaryHelper::get(options, "ordered", init.ordered); |
493 options.get("negotiated", init.negotiated); | 494 DictionaryHelper::get(options, "negotiated", init.negotiated); |
494 | 495 |
495 unsigned short value = 0; | 496 unsigned short value = 0; |
496 if (options.get("id", value)) | 497 if (DictionaryHelper::get(options, "id", value)) |
497 init.id = value; | 498 init.id = value; |
498 if (options.get("maxRetransmits", value)) | 499 if (DictionaryHelper::get(options, "maxRetransmits", value)) |
499 init.maxRetransmits = value; | 500 init.maxRetransmits = value; |
500 if (options.get("maxRetransmitTime", value)) | 501 if (DictionaryHelper::get(options, "maxRetransmitTime", value)) |
501 init.maxRetransmitTime = value; | 502 init.maxRetransmitTime = value; |
502 | 503 |
503 String protocolString; | 504 String protocolString; |
504 options.get("protocol", protocolString); | 505 DictionaryHelper::get(options, "protocol", protocolString); |
505 init.protocol = protocolString; | 506 init.protocol = protocolString; |
506 | 507 |
507 RTCDataChannel* channel = RTCDataChannel::create(executionContext(), this, m
_peerHandler.get(), label, init, exceptionState); | 508 RTCDataChannel* channel = RTCDataChannel::create(executionContext(), this, m
_peerHandler.get(), label, init, exceptionState); |
508 if (exceptionState.hadException()) | 509 if (exceptionState.hadException()) |
509 return nullptr; | 510 return nullptr; |
510 m_dataChannels.append(channel); | 511 m_dataChannels.append(channel); |
511 return channel; | 512 return channel; |
512 } | 513 } |
513 | 514 |
514 bool RTCPeerConnection::hasLocalStreamWithTrackId(const String& trackId) | 515 bool RTCPeerConnection::hasLocalStreamWithTrackId(const String& trackId) |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
734 visitor->trace(m_localStreams); | 735 visitor->trace(m_localStreams); |
735 visitor->trace(m_remoteStreams); | 736 visitor->trace(m_remoteStreams); |
736 visitor->trace(m_dataChannels); | 737 visitor->trace(m_dataChannels); |
737 #if ENABLE(OILPAN) | 738 #if ENABLE(OILPAN) |
738 visitor->trace(m_scheduledEvents); | 739 visitor->trace(m_scheduledEvents); |
739 #endif | 740 #endif |
740 EventTargetWithInlineData::trace(visitor); | 741 EventTargetWithInlineData::trace(visitor); |
741 } | 742 } |
742 | 743 |
743 } // namespace WebCore | 744 } // namespace WebCore |
OLD | NEW |