1 | /* |
2 | This file is part of the WebKit open source project. |
3 | This file has been generated by generate-bindings.pl. DO NOT MODIFY! |
4 | |
5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. |
9 | |
10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. |
14 | |
15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
18 | Boston, MA 02110-1301, USA. |
19 | */ |
20 | |
21 | #include "config.h" |
22 | |
23 | #if ENABLE(WEB_RTC) |
24 | |
25 | #include "JSRTCRtpEncodingParameters.h" |
26 | |
27 | #include "JSDOMConvertBoolean.h" |
28 | #include "JSDOMConvertEnumeration.h" |
29 | #include "JSDOMConvertNumbers.h" |
30 | #include "JSDOMConvertStrings.h" |
31 | #include "JSDOMGlobalObject.h" |
32 | #include "JSRTCDtxStatus.h" |
33 | #include "JSRTCPriorityType.h" |
34 | #include "JSRTCRtpFecParameters.h" |
35 | #include "JSRTCRtpRtxParameters.h" |
36 | #include <JavaScriptCore/JSCInlines.h> |
37 | #include <JavaScriptCore/ObjectConstructor.h> |
38 | |
39 | |
40 | namespace WebCore { |
41 | using namespace JSC; |
42 | |
43 | #if ENABLE(WEB_RTC) |
44 | |
45 | template<> RTCRtpEncodingParameters convertDictionary<RTCRtpEncodingParameters>(ExecState& state, JSValue value) |
46 | { |
47 | VM& vm = state.vm(); |
48 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
49 | bool isNullOrUndefined = value.isUndefinedOrNull(); |
50 | auto* object = isNullOrUndefined ? nullptr : value.getObject(); |
51 | if (UNLIKELY(!isNullOrUndefined && !object)) { |
52 | throwTypeError(&state, throwScope); |
53 | return { }; |
54 | } |
55 | RTCRtpEncodingParameters result; |
56 | JSValue ridValue; |
57 | if (isNullOrUndefined) |
58 | ridValue = jsUndefined(); |
59 | else { |
60 | ridValue = object->get(&state, Identifier::fromString(&state, "rid" )); |
61 | RETURN_IF_EXCEPTION(throwScope, { }); |
62 | } |
63 | if (!ridValue.isUndefined()) { |
64 | result.rid = convert<IDLDOMString>(state, ridValue); |
65 | RETURN_IF_EXCEPTION(throwScope, { }); |
66 | } |
67 | JSValue activeValue; |
68 | if (isNullOrUndefined) |
69 | activeValue = jsUndefined(); |
70 | else { |
71 | activeValue = object->get(&state, Identifier::fromString(&state, "active" )); |
72 | RETURN_IF_EXCEPTION(throwScope, { }); |
73 | } |
74 | if (!activeValue.isUndefined()) { |
75 | result.active = convert<IDLBoolean>(state, activeValue); |
76 | RETURN_IF_EXCEPTION(throwScope, { }); |
77 | } |
78 | JSValue dtxValue; |
79 | if (isNullOrUndefined) |
80 | dtxValue = jsUndefined(); |
81 | else { |
82 | dtxValue = object->get(&state, Identifier::fromString(&state, "dtx" )); |
83 | RETURN_IF_EXCEPTION(throwScope, { }); |
84 | } |
85 | if (!dtxValue.isUndefined()) { |
86 | result.dtx = convert<IDLEnumeration<RTCDtxStatus>>(state, dtxValue); |
87 | RETURN_IF_EXCEPTION(throwScope, { }); |
88 | } |
89 | JSValue fecValue; |
90 | if (isNullOrUndefined) |
91 | fecValue = jsUndefined(); |
92 | else { |
93 | fecValue = object->get(&state, Identifier::fromString(&state, "fec" )); |
94 | RETURN_IF_EXCEPTION(throwScope, { }); |
95 | } |
96 | if (!fecValue.isUndefined()) { |
97 | result.fec = convert<IDLDictionary<RTCRtpFecParameters>>(state, fecValue); |
98 | RETURN_IF_EXCEPTION(throwScope, { }); |
99 | } |
100 | JSValue maxBitrateValue; |
101 | if (isNullOrUndefined) |
102 | maxBitrateValue = jsUndefined(); |
103 | else { |
104 | maxBitrateValue = object->get(&state, Identifier::fromString(&state, "maxBitrate" )); |
105 | RETURN_IF_EXCEPTION(throwScope, { }); |
106 | } |
107 | if (!maxBitrateValue.isUndefined()) { |
108 | result.maxBitrate = convert<IDLUnsignedLong>(state, maxBitrateValue); |
109 | RETURN_IF_EXCEPTION(throwScope, { }); |
110 | } |
111 | JSValue maxFramerateValue; |
112 | if (isNullOrUndefined) |
113 | maxFramerateValue = jsUndefined(); |
114 | else { |
115 | maxFramerateValue = object->get(&state, Identifier::fromString(&state, "maxFramerate" )); |
116 | RETURN_IF_EXCEPTION(throwScope, { }); |
117 | } |
118 | if (!maxFramerateValue.isUndefined()) { |
119 | result.maxFramerate = convert<IDLUnsignedLong>(state, maxFramerateValue); |
120 | RETURN_IF_EXCEPTION(throwScope, { }); |
121 | } |
122 | JSValue priorityValue; |
123 | if (isNullOrUndefined) |
124 | priorityValue = jsUndefined(); |
125 | else { |
126 | priorityValue = object->get(&state, Identifier::fromString(&state, "priority" )); |
127 | RETURN_IF_EXCEPTION(throwScope, { }); |
128 | } |
129 | if (!priorityValue.isUndefined()) { |
130 | result.priority = convert<IDLEnumeration<RTCPriorityType>>(state, priorityValue); |
131 | RETURN_IF_EXCEPTION(throwScope, { }); |
132 | } |
133 | JSValue rtxValue; |
134 | if (isNullOrUndefined) |
135 | rtxValue = jsUndefined(); |
136 | else { |
137 | rtxValue = object->get(&state, Identifier::fromString(&state, "rtx" )); |
138 | RETURN_IF_EXCEPTION(throwScope, { }); |
139 | } |
140 | if (!rtxValue.isUndefined()) { |
141 | result.rtx = convert<IDLDictionary<RTCRtpRtxParameters>>(state, rtxValue); |
142 | RETURN_IF_EXCEPTION(throwScope, { }); |
143 | } |
144 | JSValue scaleResolutionDownByValue; |
145 | if (isNullOrUndefined) |
146 | scaleResolutionDownByValue = jsUndefined(); |
147 | else { |
148 | scaleResolutionDownByValue = object->get(&state, Identifier::fromString(&state, "scaleResolutionDownBy" )); |
149 | RETURN_IF_EXCEPTION(throwScope, { }); |
150 | } |
151 | if (!scaleResolutionDownByValue.isUndefined()) { |
152 | result.scaleResolutionDownBy = convert<IDLDouble>(state, scaleResolutionDownByValue); |
153 | RETURN_IF_EXCEPTION(throwScope, { }); |
154 | } else |
155 | result.scaleResolutionDownBy = 1; |
156 | JSValue ssrcValue; |
157 | if (isNullOrUndefined) |
158 | ssrcValue = jsUndefined(); |
159 | else { |
160 | ssrcValue = object->get(&state, Identifier::fromString(&state, "ssrc" )); |
161 | RETURN_IF_EXCEPTION(throwScope, { }); |
162 | } |
163 | if (!ssrcValue.isUndefined()) { |
164 | result.ssrc = convert<IDLUnsignedLong>(state, ssrcValue); |
165 | RETURN_IF_EXCEPTION(throwScope, { }); |
166 | } |
167 | return result; |
168 | } |
169 | |
170 | JSC::JSObject* convertDictionaryToJS(JSC::ExecState& state, JSDOMGlobalObject& globalObject, const RTCRtpEncodingParameters& dictionary) |
171 | { |
172 | auto& vm = state.vm(); |
173 | |
174 | auto result = constructEmptyObject(&state, globalObject.objectPrototype()); |
175 | |
176 | if (!IDLDOMString::isNullValue(dictionary.rid)) { |
177 | auto ridValue = toJS<IDLDOMString>(state, IDLDOMString::extractValueFromNullable(dictionary.rid)); |
178 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "rid" ), ridValue); |
179 | } |
180 | if (!IDLBoolean::isNullValue(dictionary.active)) { |
181 | auto activeValue = toJS<IDLBoolean>(IDLBoolean::extractValueFromNullable(dictionary.active)); |
182 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "active" ), activeValue); |
183 | } |
184 | if (!IDLEnumeration<RTCDtxStatus>::isNullValue(dictionary.dtx)) { |
185 | auto dtxValue = toJS<IDLEnumeration<RTCDtxStatus>>(state, IDLEnumeration<RTCDtxStatus>::extractValueFromNullable(dictionary.dtx)); |
186 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "dtx" ), dtxValue); |
187 | } |
188 | if (!IDLDictionary<RTCRtpFecParameters>::isNullValue(dictionary.fec)) { |
189 | auto fecValue = toJS<IDLDictionary<RTCRtpFecParameters>>(state, globalObject, IDLDictionary<RTCRtpFecParameters>::extractValueFromNullable(dictionary.fec)); |
190 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "fec" ), fecValue); |
191 | } |
192 | if (!IDLUnsignedLong::isNullValue(dictionary.maxBitrate)) { |
193 | auto maxBitrateValue = toJS<IDLUnsignedLong>(IDLUnsignedLong::extractValueFromNullable(dictionary.maxBitrate)); |
194 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "maxBitrate" ), maxBitrateValue); |
195 | } |
196 | if (!IDLUnsignedLong::isNullValue(dictionary.maxFramerate)) { |
197 | auto maxFramerateValue = toJS<IDLUnsignedLong>(IDLUnsignedLong::extractValueFromNullable(dictionary.maxFramerate)); |
198 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "maxFramerate" ), maxFramerateValue); |
199 | } |
200 | if (!IDLEnumeration<RTCPriorityType>::isNullValue(dictionary.priority)) { |
201 | auto priorityValue = toJS<IDLEnumeration<RTCPriorityType>>(state, IDLEnumeration<RTCPriorityType>::extractValueFromNullable(dictionary.priority)); |
202 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "priority" ), priorityValue); |
203 | } |
204 | if (!IDLDictionary<RTCRtpRtxParameters>::isNullValue(dictionary.rtx)) { |
205 | auto rtxValue = toJS<IDLDictionary<RTCRtpRtxParameters>>(state, globalObject, IDLDictionary<RTCRtpRtxParameters>::extractValueFromNullable(dictionary.rtx)); |
206 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "rtx" ), rtxValue); |
207 | } |
208 | auto scaleResolutionDownByValue = toJS<IDLDouble>(dictionary.scaleResolutionDownBy); |
209 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "scaleResolutionDownBy" ), scaleResolutionDownByValue); |
210 | if (!IDLUnsignedLong::isNullValue(dictionary.ssrc)) { |
211 | auto ssrcValue = toJS<IDLUnsignedLong>(IDLUnsignedLong::extractValueFromNullable(dictionary.ssrc)); |
212 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "ssrc" ), ssrcValue); |
213 | } |
214 | return result; |
215 | } |
216 | |
217 | #endif |
218 | |
219 | } // namespace WebCore |
220 | |
221 | #endif // ENABLE(WEB_RTC) |
222 | |