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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 size_t numberOfServers = 0; |
| 107 bool enableLocalhostCandidate = false; |
106 bool ok = DictionaryHelper::get(configuration, "iceServers", iceServers); | 108 bool ok = DictionaryHelper::get(configuration, "iceServers", iceServers); |
107 if (!ok || iceServers.isUndefinedOrNull()) { | |
108 exceptionState.throwTypeError("Malformed RTCConfiguration"); | |
109 return 0; | |
110 } | |
111 | |
112 size_t numberOfServers; | |
113 ok = iceServers.length(numberOfServers); | |
114 if (!ok) { | 109 if (!ok) { |
115 exceptionState.throwTypeError("Malformed RTCConfiguration"); | 110 v8::Local<v8::Value> iceServersValue; |
116 return 0; | 111 // Failed to parse iceServers as ArrayValue, try it as a scalar. |
| 112 ok = DictionaryHelper::get(configuration, "iceServers", iceServersValue)
; |
| 113 if (!ok || iceServersValue->IsUndefined()) { |
| 114 // if iceServers is not specified (|ok| is false) or specified as |
| 115 // "undefined", treat it as the special case which generates |
| 116 // localhost candidate. |
| 117 enableLocalhostCandidate = true; |
| 118 } else { |
| 119 exceptionState.throwTypeError("Malformed RTCConfiguration"); |
| 120 return 0; |
| 121 } |
| 122 } else { |
| 123 ok = iceServers.length(numberOfServers); |
| 124 if (!ok) { |
| 125 exceptionState.throwTypeError("Malformed RTCConfiguration"); |
| 126 return 0; |
| 127 } |
117 } | 128 } |
118 | 129 |
119 RTCBundlePolicy bundlePolicy = RTCBundlePolicyBalanced; | 130 RTCBundlePolicy bundlePolicy = RTCBundlePolicyBalanced; |
120 String bundlePolicyString; | 131 String bundlePolicyString; |
121 if (DictionaryHelper::get(configuration, "bundlePolicy", bundlePolicyString)
) { | 132 if (DictionaryHelper::get(configuration, "bundlePolicy", bundlePolicyString)
) { |
122 if (bundlePolicyString == "max-compat") { | 133 if (bundlePolicyString == "max-compat") { |
123 bundlePolicy = RTCBundlePolicyMaxCompat; | 134 bundlePolicy = RTCBundlePolicyMaxCompat; |
124 } else if (bundlePolicyString == "max-bundle") { | 135 } else if (bundlePolicyString == "max-bundle") { |
125 bundlePolicy = RTCBundlePolicyMaxBundle; | 136 bundlePolicy = RTCBundlePolicyMaxBundle; |
126 } else if (bundlePolicyString != "balanced") { | 137 } else if (bundlePolicyString != "balanced") { |
(...skipping 10 matching lines...) Expand all Loading... |
137 } else if (rtcpMuxPolicyString != "negotiate") { | 148 } else if (rtcpMuxPolicyString != "negotiate") { |
138 exceptionState.throwTypeError("Malformed RTCRtcpMuxPolicy"); | 149 exceptionState.throwTypeError("Malformed RTCRtcpMuxPolicy"); |
139 return 0; | 150 return 0; |
140 } | 151 } |
141 } | 152 } |
142 | 153 |
143 RTCConfiguration* rtcConfiguration = RTCConfiguration::create(); | 154 RTCConfiguration* rtcConfiguration = RTCConfiguration::create(); |
144 rtcConfiguration->setIceTransports(iceTransports); | 155 rtcConfiguration->setIceTransports(iceTransports); |
145 rtcConfiguration->setBundlePolicy(bundlePolicy); | 156 rtcConfiguration->setBundlePolicy(bundlePolicy); |
146 rtcConfiguration->setRtcpMuxPolicy(rtcpMuxPolicy); | 157 rtcConfiguration->setRtcpMuxPolicy(rtcpMuxPolicy); |
| 158 rtcConfiguration->setEnableLocalhostCandidate(enableLocalhostCandidate); |
147 | 159 |
148 for (size_t i = 0; i < numberOfServers; ++i) { | 160 for (size_t i = 0; i < numberOfServers; ++i) { |
149 Dictionary iceServer; | 161 Dictionary iceServer; |
150 ok = iceServers.get(i, iceServer); | 162 ok = iceServers.get(i, iceServer); |
151 if (!ok) { | 163 if (!ok) { |
152 exceptionState.throwTypeError("Malformed RTCIceServer"); | 164 exceptionState.throwTypeError("Malformed RTCIceServer"); |
153 return 0; | 165 return 0; |
154 } | 166 } |
155 | 167 |
156 Vector<String> names; | 168 Vector<String> names; |
(...skipping 678 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
835 { | 847 { |
836 visitor->trace(m_localStreams); | 848 visitor->trace(m_localStreams); |
837 visitor->trace(m_remoteStreams); | 849 visitor->trace(m_remoteStreams); |
838 visitor->trace(m_dataChannels); | 850 visitor->trace(m_dataChannels); |
839 visitor->trace(m_scheduledEvents); | 851 visitor->trace(m_scheduledEvents); |
840 RefCountedGarbageCollectedEventTargetWithInlineData<RTCPeerConnection>::trac
e(visitor); | 852 RefCountedGarbageCollectedEventTargetWithInlineData<RTCPeerConnection>::trac
e(visitor); |
841 ActiveDOMObject::trace(visitor); | 853 ActiveDOMObject::trace(visitor); |
842 } | 854 } |
843 | 855 |
844 } // namespace blink | 856 } // namespace blink |
OLD | NEW |