| 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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 | 84 |
| 85 } // namespace | 85 } // namespace |
| 86 | 86 |
| 87 RTCConfiguration* RTCPeerConnection::parseConfiguration(const Dictionary& config
uration, ExceptionState& exceptionState) | 87 RTCConfiguration* RTCPeerConnection::parseConfiguration(const Dictionary& config
uration, ExceptionState& exceptionState) |
| 88 { | 88 { |
| 89 if (configuration.isUndefinedOrNull()) | 89 if (configuration.isUndefinedOrNull()) |
| 90 return 0; | 90 return 0; |
| 91 | 91 |
| 92 RTCIceTransports iceTransports = RTCIceTransportsAll; | 92 RTCIceTransports iceTransports = RTCIceTransportsAll; |
| 93 String iceTransportsString; | 93 String iceTransportsString; |
| 94 if (DictionaryHelper::get(configuration, "iceTransports", iceTransportsStrin
g)) { | 94 if (configuration.get("iceTransports", iceTransportsString)) { |
| 95 if (iceTransportsString == "none") { | 95 if (iceTransportsString == "none") { |
| 96 iceTransports = RTCIceTransportsNone; | 96 iceTransports = RTCIceTransportsNone; |
| 97 } else if (iceTransportsString == "relay") { | 97 } else if (iceTransportsString == "relay") { |
| 98 iceTransports = RTCIceTransportsRelay; | 98 iceTransports = RTCIceTransportsRelay; |
| 99 } else if (iceTransportsString != "all") { | 99 } else if (iceTransportsString != "all") { |
| 100 exceptionState.throwTypeError("Malformed RTCIceTransports"); | 100 exceptionState.throwTypeError("Malformed RTCIceTransports"); |
| 101 return 0; | 101 return 0; |
| 102 } | 102 } |
| 103 } | 103 } |
| 104 | 104 |
| 105 ArrayValue iceServers; | 105 ArrayValue iceServers; |
| 106 bool ok = DictionaryHelper::get(configuration, "iceServers", iceServers); | 106 bool ok = configuration.get("iceServers", iceServers); |
| 107 if (!ok || iceServers.isUndefinedOrNull()) { | 107 if (!ok || iceServers.isUndefinedOrNull()) { |
| 108 exceptionState.throwTypeError("Malformed RTCConfiguration"); | 108 exceptionState.throwTypeError("Malformed RTCConfiguration"); |
| 109 return 0; | 109 return 0; |
| 110 } | 110 } |
| 111 | 111 |
| 112 size_t numberOfServers; | 112 size_t numberOfServers; |
| 113 ok = iceServers.length(numberOfServers); | 113 ok = iceServers.length(numberOfServers); |
| 114 if (!ok) { | 114 if (!ok) { |
| 115 exceptionState.throwTypeError("Malformed RTCConfiguration"); | 115 exceptionState.throwTypeError("Malformed RTCConfiguration"); |
| 116 return 0; | 116 return 0; |
| 117 } | 117 } |
| 118 | 118 |
| 119 RTCConfiguration* rtcConfiguration = RTCConfiguration::create(); | 119 RTCConfiguration* rtcConfiguration = RTCConfiguration::create(); |
| 120 rtcConfiguration->setIceTransports(iceTransports); | 120 rtcConfiguration->setIceTransports(iceTransports); |
| 121 | 121 |
| 122 for (size_t i = 0; i < numberOfServers; ++i) { | 122 for (size_t i = 0; i < numberOfServers; ++i) { |
| 123 Dictionary iceServer; | 123 Dictionary iceServer; |
| 124 ok = iceServers.get(i, iceServer); | 124 ok = iceServers.get(i, iceServer); |
| 125 if (!ok) { | 125 if (!ok) { |
| 126 exceptionState.throwTypeError("Malformed RTCIceServer"); | 126 exceptionState.throwTypeError("Malformed RTCIceServer"); |
| 127 return 0; | 127 return 0; |
| 128 } | 128 } |
| 129 | 129 |
| 130 Vector<String> names; | 130 Vector<String> names; |
| 131 iceServer.getOwnPropertyNames(names); | 131 iceServer.getOwnPropertyNames(names); |
| 132 | 132 |
| 133 Vector<String> urlStrings; | 133 Vector<String> urlStrings; |
| 134 if (names.contains("urls")) { | 134 if (names.contains("urls")) { |
| 135 if (!DictionaryHelper::get(iceServer, "urls", urlStrings) || !urlStr
ings.size()) { | 135 if (!iceServer.get("urls", urlStrings) || !urlStrings.size()) { |
| 136 String urlString; | 136 String urlString; |
| 137 if (DictionaryHelper::get(iceServer, "urls", urlString)) { | 137 if (iceServer.get("urls", urlString)) { |
| 138 urlStrings.append(urlString); | 138 urlStrings.append(urlString); |
| 139 } else { | 139 } else { |
| 140 exceptionState.throwTypeError("Malformed RTCIceServer"); | 140 exceptionState.throwTypeError("Malformed RTCIceServer"); |
| 141 return 0; | 141 return 0; |
| 142 } | 142 } |
| 143 } | 143 } |
| 144 } else if (names.contains("url")) { | 144 } else if (names.contains("url")) { |
| 145 String urlString; | 145 String urlString; |
| 146 if (DictionaryHelper::get(iceServer, "url", urlString)) { | 146 if (iceServer.get("url", urlString)) { |
| 147 urlStrings.append(urlString); | 147 urlStrings.append(urlString); |
| 148 } else { | 148 } else { |
| 149 exceptionState.throwTypeError("Malformed RTCIceServer"); | 149 exceptionState.throwTypeError("Malformed RTCIceServer"); |
| 150 return 0; | 150 return 0; |
| 151 } | 151 } |
| 152 } else { | 152 } else { |
| 153 exceptionState.throwTypeError("Malformed RTCIceServer"); | 153 exceptionState.throwTypeError("Malformed RTCIceServer"); |
| 154 return 0; | 154 return 0; |
| 155 } | 155 } |
| 156 | 156 |
| 157 String username, credential; | 157 String username, credential; |
| 158 DictionaryHelper::get(iceServer, "username", username); | 158 iceServer.get("username", username); |
| 159 DictionaryHelper::get(iceServer, "credential", credential); | 159 iceServer.get("credential", credential); |
| 160 | 160 |
| 161 for (Vector<String>::iterator iter = urlStrings.begin(); iter != urlStri
ngs.end(); ++iter) { | 161 for (Vector<String>::iterator iter = urlStrings.begin(); iter != urlStri
ngs.end(); ++iter) { |
| 162 KURL url(KURL(), *iter); | 162 KURL url(KURL(), *iter); |
| 163 if (!url.isValid() || !(url.protocolIs("turn") || url.protocolIs("tu
rns") || url.protocolIs("stun"))) { | 163 if (!url.isValid() || !(url.protocolIs("turn") || url.protocolIs("tu
rns") || url.protocolIs("stun"))) { |
| 164 exceptionState.throwTypeError("Malformed URL"); | 164 exceptionState.throwTypeError("Malformed URL"); |
| 165 return 0; | 165 return 0; |
| 166 } | 166 } |
| 167 | 167 |
| 168 rtcConfiguration->appendServer(RTCIceServer::create(url, username, c
redential)); | 168 rtcConfiguration->appendServer(RTCIceServer::create(url, username, c
redential)); |
| 169 } | 169 } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 183 // Treat |options| as MediaConstraints if it is empty or has "optional" or "
mandatory" properties for compatibility. | 183 // Treat |options| as MediaConstraints if it is empty or has "optional" or "
mandatory" properties for compatibility. |
| 184 // TODO(jiayl): remove constraints when RTCOfferOptions reaches Stable and c
lient code is ready. | 184 // TODO(jiayl): remove constraints when RTCOfferOptions reaches Stable and c
lient code is ready. |
| 185 if (propertyNames.isEmpty() || propertyNames.contains("optional") || propert
yNames.contains("mandatory")) | 185 if (propertyNames.isEmpty() || propertyNames.contains("optional") || propert
yNames.contains("mandatory")) |
| 186 return 0; | 186 return 0; |
| 187 | 187 |
| 188 int32_t offerToReceiveVideo = -1; | 188 int32_t offerToReceiveVideo = -1; |
| 189 int32_t offerToReceiveAudio = -1; | 189 int32_t offerToReceiveAudio = -1; |
| 190 bool voiceActivityDetection = true; | 190 bool voiceActivityDetection = true; |
| 191 bool iceRestart = false; | 191 bool iceRestart = false; |
| 192 | 192 |
| 193 if (DictionaryHelper::get(options, "offerToReceiveVideo", offerToReceiveVide
o) && offerToReceiveVideo < 0) { | 193 if (options.get("offerToReceiveVideo", offerToReceiveVideo) && offerToReceiv
eVideo < 0) { |
| 194 exceptionState.throwTypeError("Invalid offerToReceiveVideo"); | 194 exceptionState.throwTypeError("Invalid offerToReceiveVideo"); |
| 195 return 0; | 195 return 0; |
| 196 } | 196 } |
| 197 | 197 |
| 198 if (DictionaryHelper::get(options, "offerToReceiveAudio", offerToReceiveAudi
o) && offerToReceiveAudio < 0) { | 198 if (options.get("offerToReceiveAudio", offerToReceiveAudio) && offerToReceiv
eAudio < 0) { |
| 199 exceptionState.throwTypeError("Invalid offerToReceiveAudio"); | 199 exceptionState.throwTypeError("Invalid offerToReceiveAudio"); |
| 200 return 0; | 200 return 0; |
| 201 } | 201 } |
| 202 | 202 |
| 203 DictionaryHelper::get(options, "voiceActivityDetection", voiceActivityDetect
ion); | 203 options.get("voiceActivityDetection", voiceActivityDetection); |
| 204 DictionaryHelper::get(options, "iceRestart", iceRestart); | 204 options.get("iceRestart", iceRestart); |
| 205 | 205 |
| 206 RTCOfferOptions* rtcOfferOptions = RTCOfferOptions::create(offerToReceiveVid
eo, offerToReceiveAudio, voiceActivityDetection, iceRestart); | 206 RTCOfferOptions* rtcOfferOptions = RTCOfferOptions::create(offerToReceiveVid
eo, offerToReceiveAudio, voiceActivityDetection, iceRestart); |
| 207 return rtcOfferOptions; | 207 return rtcOfferOptions; |
| 208 } | 208 } |
| 209 | 209 |
| 210 RTCPeerConnection* RTCPeerConnection::create(ExecutionContext* context, const Di
ctionary& rtcConfiguration, const Dictionary& mediaConstraints, ExceptionState&
exceptionState) | 210 RTCPeerConnection* RTCPeerConnection::create(ExecutionContext* context, const Di
ctionary& rtcConfiguration, const Dictionary& mediaConstraints, ExceptionState&
exceptionState) |
| 211 { | 211 { |
| 212 RTCConfiguration* configuration = parseConfiguration(rtcConfiguration, excep
tionState); | 212 RTCConfiguration* configuration = parseConfiguration(rtcConfiguration, excep
tionState); |
| 213 if (exceptionState.hadException()) | 213 if (exceptionState.hadException()) |
| 214 return 0; | 214 return 0; |
| (...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 541 // FIXME: Add passing selector as part of the statsRequest. | 541 // FIXME: Add passing selector as part of the statsRequest. |
| 542 m_peerHandler->getStats(statsRequest); | 542 m_peerHandler->getStats(statsRequest); |
| 543 } | 543 } |
| 544 | 544 |
| 545 RTCDataChannel* RTCPeerConnection::createDataChannel(String label, const Diction
ary& options, ExceptionState& exceptionState) | 545 RTCDataChannel* RTCPeerConnection::createDataChannel(String label, const Diction
ary& options, ExceptionState& exceptionState) |
| 546 { | 546 { |
| 547 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) | 547 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) |
| 548 return nullptr; | 548 return nullptr; |
| 549 | 549 |
| 550 WebRTCDataChannelInit init; | 550 WebRTCDataChannelInit init; |
| 551 DictionaryHelper::get(options, "ordered", init.ordered); | 551 options.get("ordered", init.ordered); |
| 552 DictionaryHelper::get(options, "negotiated", init.negotiated); | 552 options.get("negotiated", init.negotiated); |
| 553 | 553 |
| 554 unsigned short value = 0; | 554 unsigned short value = 0; |
| 555 if (DictionaryHelper::get(options, "id", value)) | 555 if (options.get("id", value)) |
| 556 init.id = value; | 556 init.id = value; |
| 557 if (DictionaryHelper::get(options, "maxRetransmits", value)) | 557 if (options.get("maxRetransmits", value)) |
| 558 init.maxRetransmits = value; | 558 init.maxRetransmits = value; |
| 559 if (DictionaryHelper::get(options, "maxRetransmitTime", value)) | 559 if (options.get("maxRetransmitTime", value)) |
| 560 init.maxRetransmitTime = value; | 560 init.maxRetransmitTime = value; |
| 561 | 561 |
| 562 String protocolString; | 562 String protocolString; |
| 563 DictionaryHelper::get(options, "protocol", protocolString); | 563 options.get("protocol", protocolString); |
| 564 init.protocol = protocolString; | 564 init.protocol = protocolString; |
| 565 | 565 |
| 566 RTCDataChannel* channel = RTCDataChannel::create(executionContext(), this, m
_peerHandler.get(), label, init, exceptionState); | 566 RTCDataChannel* channel = RTCDataChannel::create(executionContext(), this, m
_peerHandler.get(), label, init, exceptionState); |
| 567 if (exceptionState.hadException()) | 567 if (exceptionState.hadException()) |
| 568 return nullptr; | 568 return nullptr; |
| 569 m_dataChannels.append(channel); | 569 m_dataChannels.append(channel); |
| 570 return channel; | 570 return channel; |
| 571 } | 571 } |
| 572 | 572 |
| 573 bool RTCPeerConnection::hasLocalStreamWithTrackId(const String& trackId) | 573 bool RTCPeerConnection::hasLocalStreamWithTrackId(const String& trackId) |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 805 visitor->trace(m_localStreams); | 805 visitor->trace(m_localStreams); |
| 806 visitor->trace(m_remoteStreams); | 806 visitor->trace(m_remoteStreams); |
| 807 visitor->trace(m_dataChannels); | 807 visitor->trace(m_dataChannels); |
| 808 #if ENABLE(OILPAN) | 808 #if ENABLE(OILPAN) |
| 809 visitor->trace(m_scheduledEvents); | 809 visitor->trace(m_scheduledEvents); |
| 810 #endif | 810 #endif |
| 811 EventTargetWithInlineData::trace(visitor); | 811 EventTargetWithInlineData::trace(visitor); |
| 812 } | 812 } |
| 813 | 813 |
| 814 } // namespace blink | 814 } // namespace blink |
| OLD | NEW |