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 15 matching lines...) Expand all Loading... |
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/RTCIceCandidate.h" | 32 #include "modules/mediastream/RTCIceCandidate.h" |
33 | 33 |
34 #include "bindings/core/v8/ExceptionMessages.h" | 34 #include "bindings/core/v8/ExceptionMessages.h" |
35 #include "bindings/core/v8/ExceptionState.h" | 35 #include "bindings/core/v8/ExceptionState.h" |
| 36 #include "bindings/core/v8/ScriptValue.h" |
| 37 #include "bindings/core/v8/V8ObjectBuilder.h" |
36 #include "core/dom/ExceptionCode.h" | 38 #include "core/dom/ExceptionCode.h" |
37 #include "modules/mediastream/RTCIceCandidateInit.h" | 39 #include "modules/mediastream/RTCIceCandidateInit.h" |
38 | 40 |
39 namespace blink { | 41 namespace blink { |
40 | 42 |
41 RTCIceCandidate* RTCIceCandidate::create(const RTCIceCandidateInit& candidateIni
t, ExceptionState& exceptionState) | 43 RTCIceCandidate* RTCIceCandidate::create(const RTCIceCandidateInit& candidateIni
t, ExceptionState& exceptionState) |
42 { | 44 { |
43 if (!candidateInit.hasCandidate() || !candidateInit.candidate().length()) { | 45 if (!candidateInit.hasCandidate() || !candidateInit.candidate().length()) { |
44 exceptionState.throwDOMException(TypeMismatchError, ExceptionMessages::i
ncorrectPropertyType("candidate", "is not a string, or is empty.")); | 46 exceptionState.throwDOMException(TypeMismatchError, ExceptionMessages::i
ncorrectPropertyType("candidate", "is not a string, or is empty.")); |
45 return nullptr; | 47 return nullptr; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 void RTCIceCandidate::setSdpMid(String sdpMid) | 96 void RTCIceCandidate::setSdpMid(String sdpMid) |
95 { | 97 { |
96 m_webCandidate.setSdpMid(sdpMid); | 98 m_webCandidate.setSdpMid(sdpMid); |
97 } | 99 } |
98 | 100 |
99 void RTCIceCandidate::setSdpMLineIndex(unsigned short sdpMLineIndex) | 101 void RTCIceCandidate::setSdpMLineIndex(unsigned short sdpMLineIndex) |
100 { | 102 { |
101 m_webCandidate.setSdpMLineIndex(sdpMLineIndex); | 103 m_webCandidate.setSdpMLineIndex(sdpMLineIndex); |
102 } | 104 } |
103 | 105 |
| 106 ScriptValue RTCIceCandidate::toJSONForBinding(ScriptState* scriptState) |
| 107 { |
| 108 V8ObjectBuilder result(scriptState); |
| 109 result.addString("candidate", m_webCandidate.candidate()); |
| 110 result.addString("sdpMid", m_webCandidate.sdpMid()); |
| 111 result.addNumber("sdpMLineIndex", m_webCandidate.sdpMLineIndex()); |
| 112 return result.scriptValue(); |
| 113 } |
| 114 |
104 } // namespace blink | 115 } // namespace blink |
OLD | NEW |