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 "JSRTCPeerConnection.h"
26
27#include "Document.h"
28#include "EventNames.h"
29#include "JSDOMAttribute.h"
30#include "JSDOMBinding.h"
31#include "JSDOMBuiltinConstructor.h"
32#include "JSDOMConvertBoolean.h"
33#include "JSDOMConvertBufferSource.h"
34#include "JSDOMConvertEnumeration.h"
35#include "JSDOMConvertInterface.h"
36#include "JSDOMConvertNullable.h"
37#include "JSDOMConvertNumbers.h"
38#include "JSDOMConvertObject.h"
39#include "JSDOMConvertSequences.h"
40#include "JSDOMConvertStrings.h"
41#include "JSDOMConvertUnion.h"
42#include "JSDOMConvertVariadic.h"
43#include "JSDOMExceptionHandling.h"
44#include "JSDOMGlobalObject.h"
45#include "JSDOMOperation.h"
46#include "JSDOMOperationReturningPromise.h"
47#include "JSDOMWrapperCache.h"
48#include "JSEventListener.h"
49#include "JSMediaStream.h"
50#include "JSMediaStreamTrack.h"
51#include "JSRTCAnswerOptions.h"
52#include "JSRTCConfiguration.h"
53#include "JSRTCDataChannel.h"
54#include "JSRTCIceCandidate.h"
55#include "JSRTCIceConnectionState.h"
56#include "JSRTCIceGatheringState.h"
57#include "JSRTCOfferOptions.h"
58#include "JSRTCPeerConnectionState.h"
59#include "JSRTCRtpReceiver.h"
60#include "JSRTCRtpSender.h"
61#include "JSRTCRtpTransceiver.h"
62#include "JSRTCRtpTransceiverDirection.h"
63#include "JSRTCSessionDescription.h"
64#include "JSRTCSignalingState.h"
65#include "RTCPeerConnectionBuiltins.h"
66#include "ScriptExecutionContext.h"
67#include "WebCoreJSClientData.h"
68#include <JavaScriptCore/HeapSnapshotBuilder.h>
69#include <JavaScriptCore/JSArray.h>
70#include <JavaScriptCore/JSCInlines.h>
71#include <wtf/GetPtr.h>
72#include <wtf/PointerPreparations.h>
73#include <wtf/URL.h>
74#include <wtf/Variant.h>
75
76
77namespace WebCore {
78using namespace JSC;
79
80#if ENABLE(WEB_RTC)
81
82template<> RTCPeerConnection::DataChannelInit convertDictionary<RTCPeerConnection::DataChannelInit>(ExecState& state, JSValue value)
83{
84 VM& vm = state.vm();
85 auto throwScope = DECLARE_THROW_SCOPE(vm);
86 bool isNullOrUndefined = value.isUndefinedOrNull();
87 auto* object = isNullOrUndefined ? nullptr : value.getObject();
88 if (UNLIKELY(!isNullOrUndefined && !object)) {
89 throwTypeError(&state, throwScope);
90 return { };
91 }
92 RTCPeerConnection::DataChannelInit result;
93 JSValue idValue;
94 if (isNullOrUndefined)
95 idValue = jsUndefined();
96 else {
97 idValue = object->get(&state, Identifier::fromString(&state, "id"));
98 RETURN_IF_EXCEPTION(throwScope, { });
99 }
100 if (!idValue.isUndefined()) {
101 result.id = convert<IDLEnforceRangeAdaptor<IDLUnsignedShort>>(state, idValue);
102 RETURN_IF_EXCEPTION(throwScope, { });
103 }
104 JSValue maxPacketLifeTimeValue;
105 if (isNullOrUndefined)
106 maxPacketLifeTimeValue = jsUndefined();
107 else {
108 maxPacketLifeTimeValue = object->get(&state, Identifier::fromString(&state, "maxPacketLifeTime"));
109 RETURN_IF_EXCEPTION(throwScope, { });
110 }
111 if (!maxPacketLifeTimeValue.isUndefined()) {
112 result.maxPacketLifeTime = convert<IDLUnsignedShort>(state, maxPacketLifeTimeValue);
113 RETURN_IF_EXCEPTION(throwScope, { });
114 }
115 JSValue maxRetransmitsValue;
116 if (isNullOrUndefined)
117 maxRetransmitsValue = jsUndefined();
118 else {
119 maxRetransmitsValue = object->get(&state, Identifier::fromString(&state, "maxRetransmits"));
120 RETURN_IF_EXCEPTION(throwScope, { });
121 }
122 if (!maxRetransmitsValue.isUndefined()) {
123 result.maxRetransmits = convert<IDLUnsignedShort>(state, maxRetransmitsValue);
124 RETURN_IF_EXCEPTION(throwScope, { });
125 }
126 JSValue negotiatedValue;
127 if (isNullOrUndefined)
128 negotiatedValue = jsUndefined();
129 else {
130 negotiatedValue = object->get(&state, Identifier::fromString(&state, "negotiated"));
131 RETURN_IF_EXCEPTION(throwScope, { });
132 }
133 if (!negotiatedValue.isUndefined()) {
134 result.negotiated = convert<IDLBoolean>(state, negotiatedValue);
135 RETURN_IF_EXCEPTION(throwScope, { });
136 } else
137 result.negotiated = false;
138 JSValue orderedValue;
139 if (isNullOrUndefined)
140 orderedValue = jsUndefined();
141 else {
142 orderedValue = object->get(&state, Identifier::fromString(&state, "ordered"));
143 RETURN_IF_EXCEPTION(throwScope, { });
144 }
145 if (!orderedValue.isUndefined()) {
146 result.ordered = convert<IDLBoolean>(state, orderedValue);
147 RETURN_IF_EXCEPTION(throwScope, { });
148 } else
149 result.ordered = true;
150 JSValue protocolValue;
151 if (isNullOrUndefined)
152 protocolValue = jsUndefined();
153 else {
154 protocolValue = object->get(&state, Identifier::fromString(&state, "protocol"));
155 RETURN_IF_EXCEPTION(throwScope, { });
156 }
157 if (!protocolValue.isUndefined()) {
158 result.protocol = convert<IDLUSVString>(state, protocolValue);
159 RETURN_IF_EXCEPTION(throwScope, { });
160 } else
161 result.protocol = emptyString();
162 return result;
163}
164
165#endif
166
167#if ENABLE(WEB_RTC)
168
169template<> RTCPeerConnection::CertificateParameters convertDictionary<RTCPeerConnection::CertificateParameters>(ExecState& state, JSValue value)
170{
171 VM& vm = state.vm();
172 auto throwScope = DECLARE_THROW_SCOPE(vm);
173 bool isNullOrUndefined = value.isUndefinedOrNull();
174 auto* object = isNullOrUndefined ? nullptr : value.getObject();
175 if (UNLIKELY(!isNullOrUndefined && !object)) {
176 throwTypeError(&state, throwScope);
177 return { };
178 }
179 RTCPeerConnection::CertificateParameters result;
180 JSValue expiresValue;
181 if (isNullOrUndefined)
182 expiresValue = jsUndefined();
183 else {
184 expiresValue = object->get(&state, Identifier::fromString(&state, "expires"));
185 RETURN_IF_EXCEPTION(throwScope, { });
186 }
187 if (!expiresValue.isUndefined()) {
188 result.expires = convert<IDLDouble>(state, expiresValue);
189 RETURN_IF_EXCEPTION(throwScope, { });
190 }
191 JSValue hashValue;
192 if (isNullOrUndefined)
193 hashValue = jsUndefined();
194 else {
195 hashValue = object->get(&state, Identifier::fromString(&state, "hash"));
196 RETURN_IF_EXCEPTION(throwScope, { });
197 }
198 if (!hashValue.isUndefined()) {
199 result.hash = convert<IDLDOMString>(state, hashValue);
200 RETURN_IF_EXCEPTION(throwScope, { });
201 }
202 JSValue modulusLengthValue;
203 if (isNullOrUndefined)
204 modulusLengthValue = jsUndefined();
205 else {
206 modulusLengthValue = object->get(&state, Identifier::fromString(&state, "modulusLength"));
207 RETURN_IF_EXCEPTION(throwScope, { });
208 }
209 if (!modulusLengthValue.isUndefined()) {
210 result.modulusLength = convert<IDLUnsignedLong>(state, modulusLengthValue);
211 RETURN_IF_EXCEPTION(throwScope, { });
212 }
213 JSValue nameValue;
214 if (isNullOrUndefined)
215 nameValue = jsUndefined();
216 else {
217 nameValue = object->get(&state, Identifier::fromString(&state, "name"));
218 RETURN_IF_EXCEPTION(throwScope, { });
219 }
220 if (!nameValue.isUndefined()) {
221 result.name = convert<IDLDOMString>(state, nameValue);
222 RETURN_IF_EXCEPTION(throwScope, { });
223 }
224 JSValue namedCurveValue;
225 if (isNullOrUndefined)
226 namedCurveValue = jsUndefined();
227 else {
228 namedCurveValue = object->get(&state, Identifier::fromString(&state, "namedCurve"));
229 RETURN_IF_EXCEPTION(throwScope, { });
230 }
231 if (!namedCurveValue.isUndefined()) {
232 result.namedCurve = convert<IDLDOMString>(state, namedCurveValue);
233 RETURN_IF_EXCEPTION(throwScope, { });
234 }
235 JSValue publicExponentValue;
236 if (isNullOrUndefined)
237 publicExponentValue = jsUndefined();
238 else {
239 publicExponentValue = object->get(&state, Identifier::fromString(&state, "publicExponent"));
240 RETURN_IF_EXCEPTION(throwScope, { });
241 }
242 if (!publicExponentValue.isUndefined()) {
243 result.publicExponent = convert<IDLUint8Array>(state, publicExponentValue);
244 RETURN_IF_EXCEPTION(throwScope, { });
245 }
246 return result;
247}
248
249#endif
250
251#if ENABLE(WEB_RTC)
252
253template<> RTCRtpTransceiverInit convertDictionary<RTCRtpTransceiverInit>(ExecState& state, JSValue value)
254{
255 VM& vm = state.vm();
256 auto throwScope = DECLARE_THROW_SCOPE(vm);
257 bool isNullOrUndefined = value.isUndefinedOrNull();
258 auto* object = isNullOrUndefined ? nullptr : value.getObject();
259 if (UNLIKELY(!isNullOrUndefined && !object)) {
260 throwTypeError(&state, throwScope);
261 return { };
262 }
263 RTCRtpTransceiverInit result;
264 JSValue directionValue;
265 if (isNullOrUndefined)
266 directionValue = jsUndefined();
267 else {
268 directionValue = object->get(&state, Identifier::fromString(&state, "direction"));
269 RETURN_IF_EXCEPTION(throwScope, { });
270 }
271 if (!directionValue.isUndefined()) {
272 result.direction = convert<IDLEnumeration<RTCRtpTransceiverDirection>>(state, directionValue);
273 RETURN_IF_EXCEPTION(throwScope, { });
274 } else
275 result.direction = RTCRtpTransceiverDirection::Sendrecv;
276 JSValue streamsValue;
277 if (isNullOrUndefined)
278 streamsValue = jsUndefined();
279 else {
280 streamsValue = object->get(&state, Identifier::fromString(&state, "streams"));
281 RETURN_IF_EXCEPTION(throwScope, { });
282 }
283 if (!streamsValue.isUndefined()) {
284 result.streams = convert<IDLSequence<IDLInterface<MediaStream>>>(state, streamsValue);
285 RETURN_IF_EXCEPTION(throwScope, { });
286 } else
287 result.streams = Converter<IDLSequence<IDLInterface<MediaStream>>>::ReturnType{ };
288 return result;
289}
290
291#endif
292
293// Functions
294
295JSC::EncodedJSValue JSC_HOST_CALL jsRTCPeerConnectionPrototypeFunctionInitializeWith(JSC::ExecState*);
296JSC::EncodedJSValue JSC_HOST_CALL jsRTCPeerConnectionPrototypeFunctionGetConfiguration(JSC::ExecState*);
297JSC::EncodedJSValue JSC_HOST_CALL jsRTCPeerConnectionPrototypeFunctionSetConfiguration(JSC::ExecState*);
298JSC::EncodedJSValue JSC_HOST_CALL jsRTCPeerConnectionPrototypeFunctionClose(JSC::ExecState*);
299JSC::EncodedJSValue JSC_HOST_CALL jsRTCPeerConnectionPrototypeFunctionQueuedCreateOffer(JSC::ExecState*);
300JSC::EncodedJSValue JSC_HOST_CALL jsRTCPeerConnectionPrototypeFunctionQueuedCreateAnswer(JSC::ExecState*);
301JSC::EncodedJSValue JSC_HOST_CALL jsRTCPeerConnectionPrototypeFunctionQueuedSetLocalDescription(JSC::ExecState*);
302JSC::EncodedJSValue JSC_HOST_CALL jsRTCPeerConnectionPrototypeFunctionQueuedSetRemoteDescription(JSC::ExecState*);
303JSC::EncodedJSValue JSC_HOST_CALL jsRTCPeerConnectionPrototypeFunctionQueuedAddIceCandidate(JSC::ExecState*);
304JSC::EncodedJSValue JSC_HOST_CALL jsRTCPeerConnectionConstructorFunctionGenerateCertificate(JSC::ExecState*);
305JSC::EncodedJSValue JSC_HOST_CALL jsRTCPeerConnectionPrototypeFunctionGetSenders(JSC::ExecState*);
306JSC::EncodedJSValue JSC_HOST_CALL jsRTCPeerConnectionPrototypeFunctionGetReceivers(JSC::ExecState*);
307JSC::EncodedJSValue JSC_HOST_CALL jsRTCPeerConnectionPrototypeFunctionGetTransceivers(JSC::ExecState*);
308JSC::EncodedJSValue JSC_HOST_CALL jsRTCPeerConnectionPrototypeFunctionAddTrack(JSC::ExecState*);
309JSC::EncodedJSValue JSC_HOST_CALL jsRTCPeerConnectionPrototypeFunctionRemoveTrack(JSC::ExecState*);
310JSC::EncodedJSValue JSC_HOST_CALL jsRTCPeerConnectionPrototypeFunctionAddTransceiver(JSC::ExecState*);
311JSC::EncodedJSValue JSC_HOST_CALL jsRTCPeerConnectionPrototypeFunctionCreateDataChannel(JSC::ExecState*);
312JSC::EncodedJSValue JSC_HOST_CALL jsRTCPeerConnectionPrototypeFunctionGetStats(JSC::ExecState*);
313
314// Attributes
315
316JSC::EncodedJSValue jsRTCPeerConnectionConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
317bool setJSRTCPeerConnectionConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
318JSC::EncodedJSValue jsRTCPeerConnectionLocalDescription(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
319JSC::EncodedJSValue jsRTCPeerConnectionCurrentLocalDescription(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
320JSC::EncodedJSValue jsRTCPeerConnectionPendingLocalDescription(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
321JSC::EncodedJSValue jsRTCPeerConnectionRemoteDescription(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
322JSC::EncodedJSValue jsRTCPeerConnectionCurrentRemoteDescription(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
323JSC::EncodedJSValue jsRTCPeerConnectionPendingRemoteDescription(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
324JSC::EncodedJSValue jsRTCPeerConnectionSignalingState(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
325JSC::EncodedJSValue jsRTCPeerConnectionIceGatheringState(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
326JSC::EncodedJSValue jsRTCPeerConnectionIceConnectionState(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
327JSC::EncodedJSValue jsRTCPeerConnectionConnectionState(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
328JSC::EncodedJSValue jsRTCPeerConnectionOnnegotiationneeded(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
329bool setJSRTCPeerConnectionOnnegotiationneeded(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
330JSC::EncodedJSValue jsRTCPeerConnectionOnicecandidate(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
331bool setJSRTCPeerConnectionOnicecandidate(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
332JSC::EncodedJSValue jsRTCPeerConnectionOnsignalingstatechange(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
333bool setJSRTCPeerConnectionOnsignalingstatechange(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
334JSC::EncodedJSValue jsRTCPeerConnectionOniceconnectionstatechange(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
335bool setJSRTCPeerConnectionOniceconnectionstatechange(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
336JSC::EncodedJSValue jsRTCPeerConnectionOnicegatheringstatechange(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
337bool setJSRTCPeerConnectionOnicegatheringstatechange(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
338JSC::EncodedJSValue jsRTCPeerConnectionOnconnectionstatechange(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
339bool setJSRTCPeerConnectionOnconnectionstatechange(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
340JSC::EncodedJSValue jsRTCPeerConnectionOntrack(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
341bool setJSRTCPeerConnectionOntrack(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
342JSC::EncodedJSValue jsRTCPeerConnectionOndatachannel(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
343bool setJSRTCPeerConnectionOndatachannel(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
344
345class JSRTCPeerConnectionPrototype : public JSC::JSNonFinalObject {
346public:
347 using Base = JSC::JSNonFinalObject;
348 static JSRTCPeerConnectionPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure)
349 {
350 JSRTCPeerConnectionPrototype* ptr = new (NotNull, JSC::allocateCell<JSRTCPeerConnectionPrototype>(vm.heap)) JSRTCPeerConnectionPrototype(vm, globalObject, structure);
351 ptr->finishCreation(vm);
352 return ptr;
353 }
354
355 DECLARE_INFO;
356 static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
357 {
358 return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
359 }
360
361private:
362 JSRTCPeerConnectionPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
363 : JSC::JSNonFinalObject(vm, structure)
364 {
365 }
366
367 void finishCreation(JSC::VM&);
368};
369
370using JSRTCPeerConnectionConstructor = JSDOMBuiltinConstructor<JSRTCPeerConnection>;
371
372/* Hash table for constructor */
373
374static const HashTableValue JSRTCPeerConnectionConstructorTableValues[] =
375{
376 { "generateCertificate", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsRTCPeerConnectionConstructorFunctionGenerateCertificate), (intptr_t) (1) } },
377};
378
379template<> JSValue JSRTCPeerConnectionConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
380{
381 return JSEventTarget::getConstructor(vm, &globalObject);
382}
383
384template<> void JSRTCPeerConnectionConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
385{
386 putDirect(vm, vm.propertyNames->prototype, JSRTCPeerConnection::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
387 putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("RTCPeerConnection"_s)), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
388 putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
389 reifyStaticProperties(vm, JSRTCPeerConnection::info(), JSRTCPeerConnectionConstructorTableValues, *this);
390}
391
392template<> FunctionExecutable* JSRTCPeerConnectionConstructor::initializeExecutable(VM& vm)
393{
394 return rtcPeerConnectionInitializeRTCPeerConnectionCodeGenerator(vm);
395}
396
397template<> const ClassInfo JSRTCPeerConnectionConstructor::s_info = { "RTCPeerConnection", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSRTCPeerConnectionConstructor) };
398
399/* Hash table for prototype */
400
401static const HashTableValue JSRTCPeerConnectionPrototypeTableValues[] =
402{
403 { "constructor", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRTCPeerConnectionConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSRTCPeerConnectionConstructor) } },
404 { "localDescription", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRTCPeerConnectionLocalDescription), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
405 { "currentLocalDescription", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRTCPeerConnectionCurrentLocalDescription), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
406 { "pendingLocalDescription", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRTCPeerConnectionPendingLocalDescription), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
407 { "remoteDescription", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRTCPeerConnectionRemoteDescription), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
408 { "currentRemoteDescription", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRTCPeerConnectionCurrentRemoteDescription), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
409 { "pendingRemoteDescription", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRTCPeerConnectionPendingRemoteDescription), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
410 { "signalingState", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRTCPeerConnectionSignalingState), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
411 { "iceGatheringState", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRTCPeerConnectionIceGatheringState), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
412 { "iceConnectionState", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRTCPeerConnectionIceConnectionState), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
413 { "connectionState", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRTCPeerConnectionConnectionState), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
414 { "onnegotiationneeded", static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRTCPeerConnectionOnnegotiationneeded), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSRTCPeerConnectionOnnegotiationneeded) } },
415 { "onicecandidate", static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRTCPeerConnectionOnicecandidate), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSRTCPeerConnectionOnicecandidate) } },
416 { "onsignalingstatechange", static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRTCPeerConnectionOnsignalingstatechange), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSRTCPeerConnectionOnsignalingstatechange) } },
417 { "oniceconnectionstatechange", static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRTCPeerConnectionOniceconnectionstatechange), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSRTCPeerConnectionOniceconnectionstatechange) } },
418 { "onicegatheringstatechange", static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRTCPeerConnectionOnicegatheringstatechange), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSRTCPeerConnectionOnicegatheringstatechange) } },
419 { "onconnectionstatechange", static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRTCPeerConnectionOnconnectionstatechange), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSRTCPeerConnectionOnconnectionstatechange) } },
420 { "ontrack", static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRTCPeerConnectionOntrack), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSRTCPeerConnectionOntrack) } },
421 { "ondatachannel", static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRTCPeerConnectionOndatachannel), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSRTCPeerConnectionOndatachannel) } },
422 { "createOffer", static_cast<unsigned>(JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t)static_cast<BuiltinGenerator>(rtcPeerConnectionCreateOfferCodeGenerator), (intptr_t) (0) } },
423 { "createAnswer", static_cast<unsigned>(JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t)static_cast<BuiltinGenerator>(rtcPeerConnectionCreateAnswerCodeGenerator), (intptr_t) (0) } },
424 { "setLocalDescription", static_cast<unsigned>(JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t)static_cast<BuiltinGenerator>(rtcPeerConnectionSetLocalDescriptionCodeGenerator), (intptr_t) (1) } },
425 { "setRemoteDescription", static_cast<unsigned>(JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t)static_cast<BuiltinGenerator>(rtcPeerConnectionSetRemoteDescriptionCodeGenerator), (intptr_t) (1) } },
426 { "addIceCandidate", static_cast<unsigned>(JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t)static_cast<BuiltinGenerator>(rtcPeerConnectionAddIceCandidateCodeGenerator), (intptr_t) (1) } },
427 { "getConfiguration", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsRTCPeerConnectionPrototypeFunctionGetConfiguration), (intptr_t) (0) } },
428 { "setConfiguration", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsRTCPeerConnectionPrototypeFunctionSetConfiguration), (intptr_t) (1) } },
429 { "close", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsRTCPeerConnectionPrototypeFunctionClose), (intptr_t) (0) } },
430 { "getSenders", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsRTCPeerConnectionPrototypeFunctionGetSenders), (intptr_t) (0) } },
431 { "getReceivers", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsRTCPeerConnectionPrototypeFunctionGetReceivers), (intptr_t) (0) } },
432 { "getTransceivers", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsRTCPeerConnectionPrototypeFunctionGetTransceivers), (intptr_t) (0) } },
433 { "addTrack", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsRTCPeerConnectionPrototypeFunctionAddTrack), (intptr_t) (1) } },
434 { "removeTrack", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsRTCPeerConnectionPrototypeFunctionRemoveTrack), (intptr_t) (1) } },
435 { "addTransceiver", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsRTCPeerConnectionPrototypeFunctionAddTransceiver), (intptr_t) (1) } },
436 { "createDataChannel", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsRTCPeerConnectionPrototypeFunctionCreateDataChannel), (intptr_t) (1) } },
437 { "getStats", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsRTCPeerConnectionPrototypeFunctionGetStats), (intptr_t) (0) } },
438};
439
440const ClassInfo JSRTCPeerConnectionPrototype::s_info = { "RTCPeerConnectionPrototype", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSRTCPeerConnectionPrototype) };
441
442void JSRTCPeerConnectionPrototype::finishCreation(VM& vm)
443{
444 Base::finishCreation(vm);
445 reifyStaticProperties(vm, JSRTCPeerConnection::info(), JSRTCPeerConnectionPrototypeTableValues, *this);
446 putDirect(vm, static_cast<JSVMClientData*>(vm.clientData)->builtinNames().initializeWithPrivateName(), JSFunction::create(vm, globalObject(), 0, String(), jsRTCPeerConnectionPrototypeFunctionInitializeWith), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
447 putDirect(vm, static_cast<JSVMClientData*>(vm.clientData)->builtinNames().queuedCreateOfferPrivateName(), JSFunction::create(vm, globalObject(), 0, String(), jsRTCPeerConnectionPrototypeFunctionQueuedCreateOffer), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
448 putDirect(vm, static_cast<JSVMClientData*>(vm.clientData)->builtinNames().queuedCreateAnswerPrivateName(), JSFunction::create(vm, globalObject(), 0, String(), jsRTCPeerConnectionPrototypeFunctionQueuedCreateAnswer), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
449 putDirect(vm, static_cast<JSVMClientData*>(vm.clientData)->builtinNames().queuedSetLocalDescriptionPrivateName(), JSFunction::create(vm, globalObject(), 0, String(), jsRTCPeerConnectionPrototypeFunctionQueuedSetLocalDescription), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
450 putDirect(vm, static_cast<JSVMClientData*>(vm.clientData)->builtinNames().queuedSetRemoteDescriptionPrivateName(), JSFunction::create(vm, globalObject(), 0, String(), jsRTCPeerConnectionPrototypeFunctionQueuedSetRemoteDescription), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
451 putDirect(vm, static_cast<JSVMClientData*>(vm.clientData)->builtinNames().queuedAddIceCandidatePrivateName(), JSFunction::create(vm, globalObject(), 0, String(), jsRTCPeerConnectionPrototypeFunctionQueuedAddIceCandidate), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
452}
453
454const ClassInfo JSRTCPeerConnection::s_info = { "RTCPeerConnection", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSRTCPeerConnection) };
455
456JSRTCPeerConnection::JSRTCPeerConnection(Structure* structure, JSDOMGlobalObject& globalObject, Ref<RTCPeerConnection>&& impl)
457 : JSEventTarget(structure, globalObject, WTFMove(impl))
458{
459}
460
461void JSRTCPeerConnection::finishCreation(VM& vm)
462{
463 Base::finishCreation(vm);
464 ASSERT(inherits(vm, info()));
465
466}
467
468JSObject* JSRTCPeerConnection::createPrototype(VM& vm, JSDOMGlobalObject& globalObject)
469{
470 return JSRTCPeerConnectionPrototype::create(vm, &globalObject, JSRTCPeerConnectionPrototype::createStructure(vm, &globalObject, JSEventTarget::prototype(vm, globalObject)));
471}
472
473JSObject* JSRTCPeerConnection::prototype(VM& vm, JSDOMGlobalObject& globalObject)
474{
475 return getDOMPrototype<JSRTCPeerConnection>(vm, globalObject);
476}
477
478JSValue JSRTCPeerConnection::getConstructor(VM& vm, const JSGlobalObject* globalObject)
479{
480 return getDOMConstructor<JSRTCPeerConnectionConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
481}
482
483template<> inline JSRTCPeerConnection* IDLAttribute<JSRTCPeerConnection>::cast(ExecState& state, EncodedJSValue thisValue)
484{
485 return jsDynamicCast<JSRTCPeerConnection*>(state.vm(), JSValue::decode(thisValue));
486}
487
488template<> inline JSRTCPeerConnection* IDLOperation<JSRTCPeerConnection>::cast(ExecState& state)
489{
490 return jsDynamicCast<JSRTCPeerConnection*>(state.vm(), state.thisValue());
491}
492
493EncodedJSValue jsRTCPeerConnectionConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName)
494{
495 VM& vm = state->vm();
496 auto throwScope = DECLARE_THROW_SCOPE(vm);
497 auto* prototype = jsDynamicCast<JSRTCPeerConnectionPrototype*>(vm, JSValue::decode(thisValue));
498 if (UNLIKELY(!prototype))
499 return throwVMTypeError(state, throwScope);
500 return JSValue::encode(JSRTCPeerConnection::getConstructor(state->vm(), prototype->globalObject()));
501}
502
503bool setJSRTCPeerConnectionConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
504{
505 VM& vm = state->vm();
506 auto throwScope = DECLARE_THROW_SCOPE(vm);
507 auto* prototype = jsDynamicCast<JSRTCPeerConnectionPrototype*>(vm, JSValue::decode(thisValue));
508 if (UNLIKELY(!prototype)) {
509 throwVMTypeError(state, throwScope);
510 return false;
511 }
512 // Shadowing a built-in constructor
513 return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue));
514}
515
516static inline JSValue jsRTCPeerConnectionLocalDescriptionGetter(ExecState& state, JSRTCPeerConnection& thisObject, ThrowScope& throwScope)
517{
518 UNUSED_PARAM(throwScope);
519 UNUSED_PARAM(state);
520 auto& impl = thisObject.wrapped();
521 JSValue result = toJS<IDLNullable<IDLInterface<RTCSessionDescription>>>(state, *thisObject.globalObject(), throwScope, impl.localDescription());
522 return result;
523}
524
525EncodedJSValue jsRTCPeerConnectionLocalDescription(ExecState* state, EncodedJSValue thisValue, PropertyName)
526{
527 return IDLAttribute<JSRTCPeerConnection>::get<jsRTCPeerConnectionLocalDescriptionGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "localDescription");
528}
529
530static inline JSValue jsRTCPeerConnectionCurrentLocalDescriptionGetter(ExecState& state, JSRTCPeerConnection& thisObject, ThrowScope& throwScope)
531{
532 UNUSED_PARAM(throwScope);
533 UNUSED_PARAM(state);
534 auto& impl = thisObject.wrapped();
535 JSValue result = toJS<IDLNullable<IDLInterface<RTCSessionDescription>>>(state, *thisObject.globalObject(), throwScope, impl.currentLocalDescription());
536 return result;
537}
538
539EncodedJSValue jsRTCPeerConnectionCurrentLocalDescription(ExecState* state, EncodedJSValue thisValue, PropertyName)
540{
541 return IDLAttribute<JSRTCPeerConnection>::get<jsRTCPeerConnectionCurrentLocalDescriptionGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "currentLocalDescription");
542}
543
544static inline JSValue jsRTCPeerConnectionPendingLocalDescriptionGetter(ExecState& state, JSRTCPeerConnection& thisObject, ThrowScope& throwScope)
545{
546 UNUSED_PARAM(throwScope);
547 UNUSED_PARAM(state);
548 auto& impl = thisObject.wrapped();
549 JSValue result = toJS<IDLNullable<IDLInterface<RTCSessionDescription>>>(state, *thisObject.globalObject(), throwScope, impl.pendingLocalDescription());
550 return result;
551}
552
553EncodedJSValue jsRTCPeerConnectionPendingLocalDescription(ExecState* state, EncodedJSValue thisValue, PropertyName)
554{
555 return IDLAttribute<JSRTCPeerConnection>::get<jsRTCPeerConnectionPendingLocalDescriptionGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "pendingLocalDescription");
556}
557
558static inline JSValue jsRTCPeerConnectionRemoteDescriptionGetter(ExecState& state, JSRTCPeerConnection& thisObject, ThrowScope& throwScope)
559{
560 UNUSED_PARAM(throwScope);
561 UNUSED_PARAM(state);
562 auto& impl = thisObject.wrapped();
563 JSValue result = toJS<IDLNullable<IDLInterface<RTCSessionDescription>>>(state, *thisObject.globalObject(), throwScope, impl.remoteDescription());
564 return result;
565}
566
567EncodedJSValue jsRTCPeerConnectionRemoteDescription(ExecState* state, EncodedJSValue thisValue, PropertyName)
568{
569 return IDLAttribute<JSRTCPeerConnection>::get<jsRTCPeerConnectionRemoteDescriptionGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "remoteDescription");
570}
571
572static inline JSValue jsRTCPeerConnectionCurrentRemoteDescriptionGetter(ExecState& state, JSRTCPeerConnection& thisObject, ThrowScope& throwScope)
573{
574 UNUSED_PARAM(throwScope);
575 UNUSED_PARAM(state);
576 auto& impl = thisObject.wrapped();
577 JSValue result = toJS<IDLNullable<IDLInterface<RTCSessionDescription>>>(state, *thisObject.globalObject(), throwScope, impl.currentRemoteDescription());
578 return result;
579}
580
581EncodedJSValue jsRTCPeerConnectionCurrentRemoteDescription(ExecState* state, EncodedJSValue thisValue, PropertyName)
582{
583 return IDLAttribute<JSRTCPeerConnection>::get<jsRTCPeerConnectionCurrentRemoteDescriptionGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "currentRemoteDescription");
584}
585
586static inline JSValue jsRTCPeerConnectionPendingRemoteDescriptionGetter(ExecState& state, JSRTCPeerConnection& thisObject, ThrowScope& throwScope)
587{
588 UNUSED_PARAM(throwScope);
589 UNUSED_PARAM(state);
590 auto& impl = thisObject.wrapped();
591 JSValue result = toJS<IDLNullable<IDLInterface<RTCSessionDescription>>>(state, *thisObject.globalObject(), throwScope, impl.pendingRemoteDescription());
592 return result;
593}
594
595EncodedJSValue jsRTCPeerConnectionPendingRemoteDescription(ExecState* state, EncodedJSValue thisValue, PropertyName)
596{
597 return IDLAttribute<JSRTCPeerConnection>::get<jsRTCPeerConnectionPendingRemoteDescriptionGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "pendingRemoteDescription");
598}
599
600static inline JSValue jsRTCPeerConnectionSignalingStateGetter(ExecState& state, JSRTCPeerConnection& thisObject, ThrowScope& throwScope)
601{
602 UNUSED_PARAM(throwScope);
603 UNUSED_PARAM(state);
604 auto& impl = thisObject.wrapped();
605 JSValue result = toJS<IDLEnumeration<RTCSignalingState>>(state, throwScope, impl.signalingState());
606 return result;
607}
608
609EncodedJSValue jsRTCPeerConnectionSignalingState(ExecState* state, EncodedJSValue thisValue, PropertyName)
610{
611 return IDLAttribute<JSRTCPeerConnection>::get<jsRTCPeerConnectionSignalingStateGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "signalingState");
612}
613
614static inline JSValue jsRTCPeerConnectionIceGatheringStateGetter(ExecState& state, JSRTCPeerConnection& thisObject, ThrowScope& throwScope)
615{
616 UNUSED_PARAM(throwScope);
617 UNUSED_PARAM(state);
618 auto& impl = thisObject.wrapped();
619 JSValue result = toJS<IDLEnumeration<RTCIceGatheringState>>(state, throwScope, impl.iceGatheringState());
620 return result;
621}
622
623EncodedJSValue jsRTCPeerConnectionIceGatheringState(ExecState* state, EncodedJSValue thisValue, PropertyName)
624{
625 return IDLAttribute<JSRTCPeerConnection>::get<jsRTCPeerConnectionIceGatheringStateGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "iceGatheringState");
626}
627
628static inline JSValue jsRTCPeerConnectionIceConnectionStateGetter(ExecState& state, JSRTCPeerConnection& thisObject, ThrowScope& throwScope)
629{
630 UNUSED_PARAM(throwScope);
631 UNUSED_PARAM(state);
632 auto& impl = thisObject.wrapped();
633 JSValue result = toJS<IDLEnumeration<RTCIceConnectionState>>(state, throwScope, impl.iceConnectionState());
634 return result;
635}
636
637EncodedJSValue jsRTCPeerConnectionIceConnectionState(ExecState* state, EncodedJSValue thisValue, PropertyName)
638{
639 return IDLAttribute<JSRTCPeerConnection>::get<jsRTCPeerConnectionIceConnectionStateGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "iceConnectionState");
640}
641
642static inline JSValue jsRTCPeerConnectionConnectionStateGetter(ExecState& state, JSRTCPeerConnection& thisObject, ThrowScope& throwScope)
643{
644 UNUSED_PARAM(throwScope);
645 UNUSED_PARAM(state);
646 auto& impl = thisObject.wrapped();
647 JSValue result = toJS<IDLEnumeration<RTCPeerConnectionState>>(state, throwScope, impl.connectionState());
648 return result;
649}
650
651EncodedJSValue jsRTCPeerConnectionConnectionState(ExecState* state, EncodedJSValue thisValue, PropertyName)
652{
653 return IDLAttribute<JSRTCPeerConnection>::get<jsRTCPeerConnectionConnectionStateGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "connectionState");
654}
655
656static inline JSValue jsRTCPeerConnectionOnnegotiationneededGetter(ExecState& state, JSRTCPeerConnection& thisObject, ThrowScope& throwScope)
657{
658 UNUSED_PARAM(throwScope);
659 UNUSED_PARAM(state);
660 return eventHandlerAttribute(thisObject.wrapped(), eventNames().negotiationneededEvent, worldForDOMObject(thisObject));
661}
662
663EncodedJSValue jsRTCPeerConnectionOnnegotiationneeded(ExecState* state, EncodedJSValue thisValue, PropertyName)
664{
665 return IDLAttribute<JSRTCPeerConnection>::get<jsRTCPeerConnectionOnnegotiationneededGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "onnegotiationneeded");
666}
667
668static inline bool setJSRTCPeerConnectionOnnegotiationneededSetter(ExecState& state, JSRTCPeerConnection& thisObject, JSValue value, ThrowScope& throwScope)
669{
670 UNUSED_PARAM(throwScope);
671 setEventHandlerAttribute(state, thisObject, thisObject.wrapped(), eventNames().negotiationneededEvent, value);
672 return true;
673}
674
675bool setJSRTCPeerConnectionOnnegotiationneeded(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
676{
677 return IDLAttribute<JSRTCPeerConnection>::set<setJSRTCPeerConnectionOnnegotiationneededSetter>(*state, thisValue, encodedValue, "onnegotiationneeded");
678}
679
680static inline JSValue jsRTCPeerConnectionOnicecandidateGetter(ExecState& state, JSRTCPeerConnection& thisObject, ThrowScope& throwScope)
681{
682 UNUSED_PARAM(throwScope);
683 UNUSED_PARAM(state);
684 return eventHandlerAttribute(thisObject.wrapped(), eventNames().icecandidateEvent, worldForDOMObject(thisObject));
685}
686
687EncodedJSValue jsRTCPeerConnectionOnicecandidate(ExecState* state, EncodedJSValue thisValue, PropertyName)
688{
689 return IDLAttribute<JSRTCPeerConnection>::get<jsRTCPeerConnectionOnicecandidateGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "onicecandidate");
690}
691
692static inline bool setJSRTCPeerConnectionOnicecandidateSetter(ExecState& state, JSRTCPeerConnection& thisObject, JSValue value, ThrowScope& throwScope)
693{
694 UNUSED_PARAM(throwScope);
695 setEventHandlerAttribute(state, thisObject, thisObject.wrapped(), eventNames().icecandidateEvent, value);
696 return true;
697}
698
699bool setJSRTCPeerConnectionOnicecandidate(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
700{
701 return IDLAttribute<JSRTCPeerConnection>::set<setJSRTCPeerConnectionOnicecandidateSetter>(*state, thisValue, encodedValue, "onicecandidate");
702}
703
704static inline JSValue jsRTCPeerConnectionOnsignalingstatechangeGetter(ExecState& state, JSRTCPeerConnection& thisObject, ThrowScope& throwScope)
705{
706 UNUSED_PARAM(throwScope);
707 UNUSED_PARAM(state);
708 return eventHandlerAttribute(thisObject.wrapped(), eventNames().signalingstatechangeEvent, worldForDOMObject(thisObject));
709}
710
711EncodedJSValue jsRTCPeerConnectionOnsignalingstatechange(ExecState* state, EncodedJSValue thisValue, PropertyName)
712{
713 return IDLAttribute<JSRTCPeerConnection>::get<jsRTCPeerConnectionOnsignalingstatechangeGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "onsignalingstatechange");
714}
715
716static inline bool setJSRTCPeerConnectionOnsignalingstatechangeSetter(ExecState& state, JSRTCPeerConnection& thisObject, JSValue value, ThrowScope& throwScope)
717{
718 UNUSED_PARAM(throwScope);
719 setEventHandlerAttribute(state, thisObject, thisObject.wrapped(), eventNames().signalingstatechangeEvent, value);
720 return true;
721}
722
723bool setJSRTCPeerConnectionOnsignalingstatechange(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
724{
725 return IDLAttribute<JSRTCPeerConnection>::set<setJSRTCPeerConnectionOnsignalingstatechangeSetter>(*state, thisValue, encodedValue, "onsignalingstatechange");
726}
727
728static inline JSValue jsRTCPeerConnectionOniceconnectionstatechangeGetter(ExecState& state, JSRTCPeerConnection& thisObject, ThrowScope& throwScope)
729{
730 UNUSED_PARAM(throwScope);
731 UNUSED_PARAM(state);
732 return eventHandlerAttribute(thisObject.wrapped(), eventNames().iceconnectionstatechangeEvent, worldForDOMObject(thisObject));
733}
734
735EncodedJSValue jsRTCPeerConnectionOniceconnectionstatechange(ExecState* state, EncodedJSValue thisValue, PropertyName)
736{
737 return IDLAttribute<JSRTCPeerConnection>::get<jsRTCPeerConnectionOniceconnectionstatechangeGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "oniceconnectionstatechange");
738}
739
740static inline bool setJSRTCPeerConnectionOniceconnectionstatechangeSetter(ExecState& state, JSRTCPeerConnection& thisObject, JSValue value, ThrowScope& throwScope)
741{
742 UNUSED_PARAM(throwScope);
743 setEventHandlerAttribute(state, thisObject, thisObject.wrapped(), eventNames().iceconnectionstatechangeEvent, value);
744 return true;
745}
746
747bool setJSRTCPeerConnectionOniceconnectionstatechange(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
748{
749 return IDLAttribute<JSRTCPeerConnection>::set<setJSRTCPeerConnectionOniceconnectionstatechangeSetter>(*state, thisValue, encodedValue, "oniceconnectionstatechange");
750}
751
752static inline JSValue jsRTCPeerConnectionOnicegatheringstatechangeGetter(ExecState& state, JSRTCPeerConnection& thisObject, ThrowScope& throwScope)
753{
754 UNUSED_PARAM(throwScope);
755 UNUSED_PARAM(state);
756 return eventHandlerAttribute(thisObject.wrapped(), eventNames().icegatheringstatechangeEvent, worldForDOMObject(thisObject));
757}
758
759EncodedJSValue jsRTCPeerConnectionOnicegatheringstatechange(ExecState* state, EncodedJSValue thisValue, PropertyName)
760{
761 return IDLAttribute<JSRTCPeerConnection>::get<jsRTCPeerConnectionOnicegatheringstatechangeGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "onicegatheringstatechange");
762}
763
764static inline bool setJSRTCPeerConnectionOnicegatheringstatechangeSetter(ExecState& state, JSRTCPeerConnection& thisObject, JSValue value, ThrowScope& throwScope)
765{
766 UNUSED_PARAM(throwScope);
767 setEventHandlerAttribute(state, thisObject, thisObject.wrapped(), eventNames().icegatheringstatechangeEvent, value);
768 return true;
769}
770
771bool setJSRTCPeerConnectionOnicegatheringstatechange(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
772{
773 return IDLAttribute<JSRTCPeerConnection>::set<setJSRTCPeerConnectionOnicegatheringstatechangeSetter>(*state, thisValue, encodedValue, "onicegatheringstatechange");
774}
775
776static inline JSValue jsRTCPeerConnectionOnconnectionstatechangeGetter(ExecState& state, JSRTCPeerConnection& thisObject, ThrowScope& throwScope)
777{
778 UNUSED_PARAM(throwScope);
779 UNUSED_PARAM(state);
780 return eventHandlerAttribute(thisObject.wrapped(), eventNames().connectionstatechangeEvent, worldForDOMObject(thisObject));
781}
782
783EncodedJSValue jsRTCPeerConnectionOnconnectionstatechange(ExecState* state, EncodedJSValue thisValue, PropertyName)
784{
785 return IDLAttribute<JSRTCPeerConnection>::get<jsRTCPeerConnectionOnconnectionstatechangeGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "onconnectionstatechange");
786}
787
788static inline bool setJSRTCPeerConnectionOnconnectionstatechangeSetter(ExecState& state, JSRTCPeerConnection& thisObject, JSValue value, ThrowScope& throwScope)
789{
790 UNUSED_PARAM(throwScope);
791 setEventHandlerAttribute(state, thisObject, thisObject.wrapped(), eventNames().connectionstatechangeEvent, value);
792 return true;
793}
794
795bool setJSRTCPeerConnectionOnconnectionstatechange(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
796{
797 return IDLAttribute<JSRTCPeerConnection>::set<setJSRTCPeerConnectionOnconnectionstatechangeSetter>(*state, thisValue, encodedValue, "onconnectionstatechange");
798}
799
800static inline JSValue jsRTCPeerConnectionOntrackGetter(ExecState& state, JSRTCPeerConnection& thisObject, ThrowScope& throwScope)
801{
802 UNUSED_PARAM(throwScope);
803 UNUSED_PARAM(state);
804 return eventHandlerAttribute(thisObject.wrapped(), eventNames().trackEvent, worldForDOMObject(thisObject));
805}
806
807EncodedJSValue jsRTCPeerConnectionOntrack(ExecState* state, EncodedJSValue thisValue, PropertyName)
808{
809 return IDLAttribute<JSRTCPeerConnection>::get<jsRTCPeerConnectionOntrackGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "ontrack");
810}
811
812static inline bool setJSRTCPeerConnectionOntrackSetter(ExecState& state, JSRTCPeerConnection& thisObject, JSValue value, ThrowScope& throwScope)
813{
814 UNUSED_PARAM(throwScope);
815 setEventHandlerAttribute(state, thisObject, thisObject.wrapped(), eventNames().trackEvent, value);
816 return true;
817}
818
819bool setJSRTCPeerConnectionOntrack(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
820{
821 return IDLAttribute<JSRTCPeerConnection>::set<setJSRTCPeerConnectionOntrackSetter>(*state, thisValue, encodedValue, "ontrack");
822}
823
824static inline JSValue jsRTCPeerConnectionOndatachannelGetter(ExecState& state, JSRTCPeerConnection& thisObject, ThrowScope& throwScope)
825{
826 UNUSED_PARAM(throwScope);
827 UNUSED_PARAM(state);
828 return eventHandlerAttribute(thisObject.wrapped(), eventNames().datachannelEvent, worldForDOMObject(thisObject));
829}
830
831EncodedJSValue jsRTCPeerConnectionOndatachannel(ExecState* state, EncodedJSValue thisValue, PropertyName)
832{
833 return IDLAttribute<JSRTCPeerConnection>::get<jsRTCPeerConnectionOndatachannelGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "ondatachannel");
834}
835
836static inline bool setJSRTCPeerConnectionOndatachannelSetter(ExecState& state, JSRTCPeerConnection& thisObject, JSValue value, ThrowScope& throwScope)
837{
838 UNUSED_PARAM(throwScope);
839 setEventHandlerAttribute(state, thisObject, thisObject.wrapped(), eventNames().datachannelEvent, value);
840 return true;
841}
842
843bool setJSRTCPeerConnectionOndatachannel(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
844{
845 return IDLAttribute<JSRTCPeerConnection>::set<setJSRTCPeerConnectionOndatachannelSetter>(*state, thisValue, encodedValue, "ondatachannel");
846}
847
848static inline JSC::EncodedJSValue jsRTCPeerConnectionPrototypeFunctionInitializeWithBody(JSC::ExecState* state, typename IDLOperation<JSRTCPeerConnection>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
849{
850 UNUSED_PARAM(state);
851 UNUSED_PARAM(throwScope);
852 auto& impl = castedThis->wrapped();
853 if (UNLIKELY(state->argumentCount() < 1))
854 return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
855 auto* context = jsCast<JSDOMGlobalObject*>(state->lexicalGlobalObject())->scriptExecutionContext();
856 if (UNLIKELY(!context))
857 return JSValue::encode(jsUndefined());
858 ASSERT(context->isDocument());
859 auto& document = downcast<Document>(*context);
860 auto configuration = convert<IDLDictionary<RTCConfiguration>>(*state, state->uncheckedArgument(0));
861 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
862 propagateException(*state, throwScope, impl.initializeWith(document, WTFMove(configuration)));
863 return JSValue::encode(jsUndefined());
864}
865
866EncodedJSValue JSC_HOST_CALL jsRTCPeerConnectionPrototypeFunctionInitializeWith(ExecState* state)
867{
868 return IDLOperation<JSRTCPeerConnection>::call<jsRTCPeerConnectionPrototypeFunctionInitializeWithBody, CastedThisErrorBehavior::Assert>(*state, "initializeWith");
869}
870
871static inline JSC::EncodedJSValue jsRTCPeerConnectionPrototypeFunctionGetConfigurationBody(JSC::ExecState* state, typename IDLOperation<JSRTCPeerConnection>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
872{
873 UNUSED_PARAM(state);
874 UNUSED_PARAM(throwScope);
875 auto& impl = castedThis->wrapped();
876 return JSValue::encode(toJS<IDLDictionary<RTCConfiguration>>(*state, *castedThis->globalObject(), impl.getConfiguration()));
877}
878
879EncodedJSValue JSC_HOST_CALL jsRTCPeerConnectionPrototypeFunctionGetConfiguration(ExecState* state)
880{
881 return IDLOperation<JSRTCPeerConnection>::call<jsRTCPeerConnectionPrototypeFunctionGetConfigurationBody>(*state, "getConfiguration");
882}
883
884static inline JSC::EncodedJSValue jsRTCPeerConnectionPrototypeFunctionSetConfigurationBody(JSC::ExecState* state, typename IDLOperation<JSRTCPeerConnection>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
885{
886 UNUSED_PARAM(state);
887 UNUSED_PARAM(throwScope);
888 auto& impl = castedThis->wrapped();
889 if (UNLIKELY(state->argumentCount() < 1))
890 return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
891 auto configuration = convert<IDLDictionary<RTCConfiguration>>(*state, state->uncheckedArgument(0));
892 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
893 propagateException(*state, throwScope, impl.setConfiguration(WTFMove(configuration)));
894 return JSValue::encode(jsUndefined());
895}
896
897EncodedJSValue JSC_HOST_CALL jsRTCPeerConnectionPrototypeFunctionSetConfiguration(ExecState* state)
898{
899 return IDLOperation<JSRTCPeerConnection>::call<jsRTCPeerConnectionPrototypeFunctionSetConfigurationBody>(*state, "setConfiguration");
900}
901
902static inline JSC::EncodedJSValue jsRTCPeerConnectionPrototypeFunctionCloseBody(JSC::ExecState* state, typename IDLOperation<JSRTCPeerConnection>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
903{
904 UNUSED_PARAM(state);
905 UNUSED_PARAM(throwScope);
906 auto& impl = castedThis->wrapped();
907 impl.close();
908 return JSValue::encode(jsUndefined());
909}
910
911EncodedJSValue JSC_HOST_CALL jsRTCPeerConnectionPrototypeFunctionClose(ExecState* state)
912{
913 return IDLOperation<JSRTCPeerConnection>::call<jsRTCPeerConnectionPrototypeFunctionCloseBody>(*state, "close");
914}
915
916static inline JSC::EncodedJSValue jsRTCPeerConnectionPrototypeFunctionQueuedCreateOfferBody(JSC::ExecState* state, typename IDLOperationReturningPromise<JSRTCPeerConnection>::ClassParameter castedThis, Ref<DeferredPromise>&& promise, JSC::ThrowScope& throwScope)
917{
918 UNUSED_PARAM(state);
919 UNUSED_PARAM(throwScope);
920 auto& impl = castedThis->wrapped();
921 auto offerOptions = convert<IDLDictionary<RTCOfferOptions>>(*state, state->argument(0));
922 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
923 impl.queuedCreateOffer(WTFMove(offerOptions), WTFMove(promise));
924 return JSValue::encode(jsUndefined());
925}
926
927EncodedJSValue JSC_HOST_CALL jsRTCPeerConnectionPrototypeFunctionQueuedCreateOffer(ExecState* state)
928{
929 return IDLOperationReturningPromise<JSRTCPeerConnection>::call<jsRTCPeerConnectionPrototypeFunctionQueuedCreateOfferBody, PromiseExecutionScope::WindowOnly, CastedThisErrorBehavior::Assert>(*state, "queuedCreateOffer");
930}
931
932static inline JSC::EncodedJSValue jsRTCPeerConnectionPrototypeFunctionQueuedCreateAnswerBody(JSC::ExecState* state, typename IDLOperationReturningPromise<JSRTCPeerConnection>::ClassParameter castedThis, Ref<DeferredPromise>&& promise, JSC::ThrowScope& throwScope)
933{
934 UNUSED_PARAM(state);
935 UNUSED_PARAM(throwScope);
936 auto& impl = castedThis->wrapped();
937 auto answerOptions = convert<IDLDictionary<RTCAnswerOptions>>(*state, state->argument(0));
938 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
939 impl.queuedCreateAnswer(WTFMove(answerOptions), WTFMove(promise));
940 return JSValue::encode(jsUndefined());
941}
942
943EncodedJSValue JSC_HOST_CALL jsRTCPeerConnectionPrototypeFunctionQueuedCreateAnswer(ExecState* state)
944{
945 return IDLOperationReturningPromise<JSRTCPeerConnection>::call<jsRTCPeerConnectionPrototypeFunctionQueuedCreateAnswerBody, PromiseExecutionScope::WindowOnly, CastedThisErrorBehavior::Assert>(*state, "queuedCreateAnswer");
946}
947
948static inline JSC::EncodedJSValue jsRTCPeerConnectionPrototypeFunctionQueuedSetLocalDescriptionBody(JSC::ExecState* state, typename IDLOperationReturningPromise<JSRTCPeerConnection>::ClassParameter castedThis, Ref<DeferredPromise>&& promise, JSC::ThrowScope& throwScope)
949{
950 UNUSED_PARAM(state);
951 UNUSED_PARAM(throwScope);
952 auto& impl = castedThis->wrapped();
953 if (UNLIKELY(state->argumentCount() < 1))
954 return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
955 auto description = convert<IDLInterface<RTCSessionDescription>>(*state, state->uncheckedArgument(0), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentTypeError(state, scope, 0, "description", "RTCPeerConnection", "queuedSetLocalDescription", "RTCSessionDescription"); });
956 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
957 impl.queuedSetLocalDescription(*description, WTFMove(promise));
958 return JSValue::encode(jsUndefined());
959}
960
961EncodedJSValue JSC_HOST_CALL jsRTCPeerConnectionPrototypeFunctionQueuedSetLocalDescription(ExecState* state)
962{
963 return IDLOperationReturningPromise<JSRTCPeerConnection>::call<jsRTCPeerConnectionPrototypeFunctionQueuedSetLocalDescriptionBody, PromiseExecutionScope::WindowOnly, CastedThisErrorBehavior::Assert>(*state, "queuedSetLocalDescription");
964}
965
966static inline JSC::EncodedJSValue jsRTCPeerConnectionPrototypeFunctionQueuedSetRemoteDescriptionBody(JSC::ExecState* state, typename IDLOperationReturningPromise<JSRTCPeerConnection>::ClassParameter castedThis, Ref<DeferredPromise>&& promise, JSC::ThrowScope& throwScope)
967{
968 UNUSED_PARAM(state);
969 UNUSED_PARAM(throwScope);
970 auto& impl = castedThis->wrapped();
971 if (UNLIKELY(state->argumentCount() < 1))
972 return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
973 auto description = convert<IDLInterface<RTCSessionDescription>>(*state, state->uncheckedArgument(0), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentTypeError(state, scope, 0, "description", "RTCPeerConnection", "queuedSetRemoteDescription", "RTCSessionDescription"); });
974 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
975 impl.queuedSetRemoteDescription(*description, WTFMove(promise));
976 return JSValue::encode(jsUndefined());
977}
978
979EncodedJSValue JSC_HOST_CALL jsRTCPeerConnectionPrototypeFunctionQueuedSetRemoteDescription(ExecState* state)
980{
981 return IDLOperationReturningPromise<JSRTCPeerConnection>::call<jsRTCPeerConnectionPrototypeFunctionQueuedSetRemoteDescriptionBody, PromiseExecutionScope::WindowOnly, CastedThisErrorBehavior::Assert>(*state, "queuedSetRemoteDescription");
982}
983
984static inline JSC::EncodedJSValue jsRTCPeerConnectionPrototypeFunctionQueuedAddIceCandidateBody(JSC::ExecState* state, typename IDLOperationReturningPromise<JSRTCPeerConnection>::ClassParameter castedThis, Ref<DeferredPromise>&& promise, JSC::ThrowScope& throwScope)
985{
986 UNUSED_PARAM(state);
987 UNUSED_PARAM(throwScope);
988 auto& impl = castedThis->wrapped();
989 if (UNLIKELY(state->argumentCount() < 1))
990 return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
991 auto candidate = convert<IDLNullable<IDLInterface<RTCIceCandidate>>>(*state, state->uncheckedArgument(0), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentTypeError(state, scope, 0, "candidate", "RTCPeerConnection", "queuedAddIceCandidate", "RTCIceCandidate"); });
992 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
993 impl.queuedAddIceCandidate(WTFMove(candidate), WTFMove(promise));
994 return JSValue::encode(jsUndefined());
995}
996
997EncodedJSValue JSC_HOST_CALL jsRTCPeerConnectionPrototypeFunctionQueuedAddIceCandidate(ExecState* state)
998{
999 return IDLOperationReturningPromise<JSRTCPeerConnection>::call<jsRTCPeerConnectionPrototypeFunctionQueuedAddIceCandidateBody, PromiseExecutionScope::WindowOnly, CastedThisErrorBehavior::Assert>(*state, "queuedAddIceCandidate");
1000}
1001
1002static inline JSC::EncodedJSValue jsRTCPeerConnectionConstructorFunctionGenerateCertificateBody(JSC::ExecState* state, Ref<DeferredPromise>&& promise, JSC::ThrowScope& throwScope)
1003{
1004 UNUSED_PARAM(state);
1005 UNUSED_PARAM(throwScope);
1006 if (UNLIKELY(state->argumentCount() < 1))
1007 return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
1008 auto keygenAlgorithm = convert<IDLUnion<IDLObject, IDLDOMString>>(*state, state->uncheckedArgument(0));
1009 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
1010 RTCPeerConnection::generateCertificate(*state, WTFMove(keygenAlgorithm), WTFMove(promise));
1011 return JSValue::encode(jsUndefined());
1012}
1013
1014EncodedJSValue JSC_HOST_CALL jsRTCPeerConnectionConstructorFunctionGenerateCertificate(ExecState* state)
1015{
1016 return IDLOperationReturningPromise<JSRTCPeerConnection>::callStatic<jsRTCPeerConnectionConstructorFunctionGenerateCertificateBody, PromiseExecutionScope::WindowOnly>(*state, "generateCertificate");
1017}
1018
1019static inline JSC::EncodedJSValue jsRTCPeerConnectionPrototypeFunctionGetSendersBody(JSC::ExecState* state, typename IDLOperation<JSRTCPeerConnection>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
1020{
1021 UNUSED_PARAM(state);
1022 UNUSED_PARAM(throwScope);
1023 auto& impl = castedThis->wrapped();
1024 return JSValue::encode(toJS<IDLSequence<IDLInterface<RTCRtpSender>>>(*state, *castedThis->globalObject(), impl.getSenders()));
1025}
1026
1027EncodedJSValue JSC_HOST_CALL jsRTCPeerConnectionPrototypeFunctionGetSenders(ExecState* state)
1028{
1029 return IDLOperation<JSRTCPeerConnection>::call<jsRTCPeerConnectionPrototypeFunctionGetSendersBody>(*state, "getSenders");
1030}
1031
1032static inline JSC::EncodedJSValue jsRTCPeerConnectionPrototypeFunctionGetReceiversBody(JSC::ExecState* state, typename IDLOperation<JSRTCPeerConnection>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
1033{
1034 UNUSED_PARAM(state);
1035 UNUSED_PARAM(throwScope);
1036 auto& impl = castedThis->wrapped();
1037 return JSValue::encode(toJS<IDLSequence<IDLInterface<RTCRtpReceiver>>>(*state, *castedThis->globalObject(), impl.getReceivers()));
1038}
1039
1040EncodedJSValue JSC_HOST_CALL jsRTCPeerConnectionPrototypeFunctionGetReceivers(ExecState* state)
1041{
1042 return IDLOperation<JSRTCPeerConnection>::call<jsRTCPeerConnectionPrototypeFunctionGetReceiversBody>(*state, "getReceivers");
1043}
1044
1045static inline JSC::EncodedJSValue jsRTCPeerConnectionPrototypeFunctionGetTransceiversBody(JSC::ExecState* state, typename IDLOperation<JSRTCPeerConnection>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
1046{
1047 UNUSED_PARAM(state);
1048 UNUSED_PARAM(throwScope);
1049 auto& impl = castedThis->wrapped();
1050 return JSValue::encode(toJS<IDLSequence<IDLInterface<RTCRtpTransceiver>>>(*state, *castedThis->globalObject(), impl.getTransceivers()));
1051}
1052
1053EncodedJSValue JSC_HOST_CALL jsRTCPeerConnectionPrototypeFunctionGetTransceivers(ExecState* state)
1054{
1055 return IDLOperation<JSRTCPeerConnection>::call<jsRTCPeerConnectionPrototypeFunctionGetTransceiversBody>(*state, "getTransceivers");
1056}
1057
1058static inline JSC::EncodedJSValue jsRTCPeerConnectionPrototypeFunctionAddTrackBody(JSC::ExecState* state, typename IDLOperation<JSRTCPeerConnection>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
1059{
1060 UNUSED_PARAM(state);
1061 UNUSED_PARAM(throwScope);
1062 auto& impl = castedThis->wrapped();
1063 if (UNLIKELY(state->argumentCount() < 1))
1064 return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
1065 auto track = convert<IDLInterface<MediaStreamTrack>>(*state, state->uncheckedArgument(0), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentTypeError(state, scope, 0, "track", "RTCPeerConnection", "addTrack", "MediaStreamTrack"); });
1066 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
1067 auto streams = convertVariadicArguments<IDLInterface<MediaStream>>(*state, 1);
1068 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
1069 return JSValue::encode(toJS<IDLInterface<RTCRtpSender>>(*state, *castedThis->globalObject(), throwScope, impl.addTrack(*track, WTFMove(streams))));
1070}
1071
1072EncodedJSValue JSC_HOST_CALL jsRTCPeerConnectionPrototypeFunctionAddTrack(ExecState* state)
1073{
1074 return IDLOperation<JSRTCPeerConnection>::call<jsRTCPeerConnectionPrototypeFunctionAddTrackBody>(*state, "addTrack");
1075}
1076
1077static inline JSC::EncodedJSValue jsRTCPeerConnectionPrototypeFunctionRemoveTrackBody(JSC::ExecState* state, typename IDLOperation<JSRTCPeerConnection>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
1078{
1079 UNUSED_PARAM(state);
1080 UNUSED_PARAM(throwScope);
1081 auto& impl = castedThis->wrapped();
1082 if (UNLIKELY(state->argumentCount() < 1))
1083 return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
1084 auto sender = convert<IDLInterface<RTCRtpSender>>(*state, state->uncheckedArgument(0), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentTypeError(state, scope, 0, "sender", "RTCPeerConnection", "removeTrack", "RTCRtpSender"); });
1085 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
1086 propagateException(*state, throwScope, impl.removeTrack(*sender));
1087 return JSValue::encode(jsUndefined());
1088}
1089
1090EncodedJSValue JSC_HOST_CALL jsRTCPeerConnectionPrototypeFunctionRemoveTrack(ExecState* state)
1091{
1092 return IDLOperation<JSRTCPeerConnection>::call<jsRTCPeerConnectionPrototypeFunctionRemoveTrackBody>(*state, "removeTrack");
1093}
1094
1095static inline JSC::EncodedJSValue jsRTCPeerConnectionPrototypeFunctionAddTransceiverBody(JSC::ExecState* state, typename IDLOperation<JSRTCPeerConnection>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
1096{
1097 UNUSED_PARAM(state);
1098 UNUSED_PARAM(throwScope);
1099 auto& impl = castedThis->wrapped();
1100 if (UNLIKELY(state->argumentCount() < 1))
1101 return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
1102 auto track = convert<IDLUnion<IDLInterface<MediaStreamTrack>, IDLDOMString>>(*state, state->uncheckedArgument(0));
1103 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
1104 auto init = convert<IDLDictionary<RTCRtpTransceiverInit>>(*state, state->argument(1));
1105 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
1106 return JSValue::encode(toJS<IDLInterface<RTCRtpTransceiver>>(*state, *castedThis->globalObject(), throwScope, impl.addTransceiver(WTFMove(track), WTFMove(init))));
1107}
1108
1109EncodedJSValue JSC_HOST_CALL jsRTCPeerConnectionPrototypeFunctionAddTransceiver(ExecState* state)
1110{
1111 return IDLOperation<JSRTCPeerConnection>::call<jsRTCPeerConnectionPrototypeFunctionAddTransceiverBody>(*state, "addTransceiver");
1112}
1113
1114static inline JSC::EncodedJSValue jsRTCPeerConnectionPrototypeFunctionCreateDataChannelBody(JSC::ExecState* state, typename IDLOperation<JSRTCPeerConnection>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
1115{
1116 UNUSED_PARAM(state);
1117 UNUSED_PARAM(throwScope);
1118 auto& impl = castedThis->wrapped();
1119 if (UNLIKELY(state->argumentCount() < 1))
1120 return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
1121 auto* context = jsCast<JSDOMGlobalObject*>(state->lexicalGlobalObject())->scriptExecutionContext();
1122 if (UNLIKELY(!context))
1123 return JSValue::encode(jsUndefined());
1124 auto label = convert<IDLTreatNullAsEmptyAdaptor<IDLUSVString>>(*state, state->uncheckedArgument(0));
1125 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
1126 auto options = convert<IDLDictionary<RTCPeerConnection::DataChannelInit>>(*state, state->argument(1));
1127 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
1128 return JSValue::encode(toJS<IDLInterface<RTCDataChannel>>(*state, *castedThis->globalObject(), throwScope, impl.createDataChannel(*context, WTFMove(label), WTFMove(options))));
1129}
1130
1131EncodedJSValue JSC_HOST_CALL jsRTCPeerConnectionPrototypeFunctionCreateDataChannel(ExecState* state)
1132{
1133 return IDLOperation<JSRTCPeerConnection>::call<jsRTCPeerConnectionPrototypeFunctionCreateDataChannelBody>(*state, "createDataChannel");
1134}
1135
1136static inline JSC::EncodedJSValue jsRTCPeerConnectionPrototypeFunctionGetStatsBody(JSC::ExecState* state, typename IDLOperationReturningPromise<JSRTCPeerConnection>::ClassParameter castedThis, Ref<DeferredPromise>&& promise, JSC::ThrowScope& throwScope)
1137{
1138 UNUSED_PARAM(state);
1139 UNUSED_PARAM(throwScope);
1140 auto& impl = castedThis->wrapped();
1141 auto selector = convert<IDLNullable<IDLInterface<MediaStreamTrack>>>(*state, state->argument(0), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentTypeError(state, scope, 0, "selector", "RTCPeerConnection", "getStats", "MediaStreamTrack"); });
1142 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
1143 impl.getStats(WTFMove(selector), WTFMove(promise));
1144 return JSValue::encode(jsUndefined());
1145}
1146
1147EncodedJSValue JSC_HOST_CALL jsRTCPeerConnectionPrototypeFunctionGetStats(ExecState* state)
1148{
1149 return IDLOperationReturningPromise<JSRTCPeerConnection>::call<jsRTCPeerConnectionPrototypeFunctionGetStatsBody, PromiseExecutionScope::WindowOnly>(*state, "getStats");
1150}
1151
1152void JSRTCPeerConnection::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder)
1153{
1154 auto* thisObject = jsCast<JSRTCPeerConnection*>(cell);
1155 builder.setWrappedObjectForCell(cell, &thisObject->wrapped());
1156 if (thisObject->scriptExecutionContext())
1157 builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string());
1158 Base::heapSnapshot(cell, builder);
1159}
1160
1161bool JSRTCPeerConnectionOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor, const char** reason)
1162{
1163 auto* jsRTCPeerConnection = jsCast<JSRTCPeerConnection*>(handle.slot()->asCell());
1164 if (jsRTCPeerConnection->wrapped().hasPendingActivity()) {
1165 if (UNLIKELY(reason))
1166 *reason = "ActiveDOMObject with pending activity";
1167 return true;
1168 }
1169 if (jsRTCPeerConnection->wrapped().isFiringEventListeners()) {
1170 if (UNLIKELY(reason))
1171 *reason = "EventTarget firing event listeners";
1172 return true;
1173 }
1174 UNUSED_PARAM(visitor);
1175 UNUSED_PARAM(reason);
1176 return false;
1177}
1178
1179void JSRTCPeerConnectionOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
1180{
1181 auto* jsRTCPeerConnection = static_cast<JSRTCPeerConnection*>(handle.slot()->asCell());
1182 auto& world = *static_cast<DOMWrapperWorld*>(context);
1183 uncacheWrapper(world, &jsRTCPeerConnection->wrapped(), jsRTCPeerConnection);
1184}
1185
1186#if ENABLE(BINDING_INTEGRITY)
1187#if PLATFORM(WIN)
1188#pragma warning(disable: 4483)
1189extern "C" { extern void (*const __identifier("??_7RTCPeerConnection@WebCore@@6B@")[])(); }
1190#else
1191extern "C" { extern void* _ZTVN7WebCore17RTCPeerConnectionE[]; }
1192#endif
1193#endif
1194
1195JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<RTCPeerConnection>&& impl)
1196{
1197
1198#if ENABLE(BINDING_INTEGRITY)
1199 void* actualVTablePointer = *(reinterpret_cast<void**>(impl.ptr()));
1200#if PLATFORM(WIN)
1201 void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(__identifier("??_7RTCPeerConnection@WebCore@@6B@"));
1202#else
1203 void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(&_ZTVN7WebCore17RTCPeerConnectionE[2]);
1204#endif
1205
1206 // If this fails RTCPeerConnection does not have a vtable, so you need to add the
1207 // ImplementationLacksVTable attribute to the interface definition
1208 static_assert(std::is_polymorphic<RTCPeerConnection>::value, "RTCPeerConnection is not polymorphic");
1209
1210 // If you hit this assertion you either have a use after free bug, or
1211 // RTCPeerConnection has subclasses. If RTCPeerConnection has subclasses that get passed
1212 // to toJS() we currently require RTCPeerConnection you to opt out of binding hardening
1213 // by adding the SkipVTableValidation attribute to the interface IDL definition
1214 RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer);
1215#endif
1216 return createWrapper<RTCPeerConnection>(globalObject, WTFMove(impl));
1217}
1218
1219JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, RTCPeerConnection& impl)
1220{
1221 return wrap(state, globalObject, impl);
1222}
1223
1224RTCPeerConnection* JSRTCPeerConnection::toWrapped(JSC::VM& vm, JSC::JSValue value)
1225{
1226 if (auto* wrapper = jsDynamicCast<JSRTCPeerConnection*>(vm, value))
1227 return &wrapper->wrapped();
1228 return nullptr;
1229}
1230
1231}
1232
1233#endif // ENABLE(WEB_RTC)
1234