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 "JSRTCRtpSender.h" |
26 | |
27 | #include "JSDOMAttribute.h" |
28 | #include "JSDOMBinding.h" |
29 | #include "JSDOMConstructorNotConstructable.h" |
30 | #include "JSDOMConvertDictionary.h" |
31 | #include "JSDOMConvertInterface.h" |
32 | #include "JSDOMConvertNullable.h" |
33 | #include "JSDOMConvertStrings.h" |
34 | #include "JSDOMExceptionHandling.h" |
35 | #include "JSDOMGlobalObject.h" |
36 | #include "JSDOMOperation.h" |
37 | #include "JSDOMOperationReturningPromise.h" |
38 | #include "JSDOMWrapperCache.h" |
39 | #include "JSMediaStreamTrack.h" |
40 | #include "JSRTCRtpCapabilities.h" |
41 | #include "JSRTCRtpSendParameters.h" |
42 | #include "ScriptExecutionContext.h" |
43 | #include <JavaScriptCore/FunctionPrototype.h> |
44 | #include <JavaScriptCore/HeapSnapshotBuilder.h> |
45 | #include <JavaScriptCore/JSCInlines.h> |
46 | #include <wtf/GetPtr.h> |
47 | #include <wtf/PointerPreparations.h> |
48 | #include <wtf/URL.h> |
49 | |
50 | |
51 | namespace WebCore { |
52 | using namespace JSC; |
53 | |
54 | // Functions |
55 | |
56 | JSC::EncodedJSValue JSC_HOST_CALL jsRTCRtpSenderConstructorFunctionGetCapabilities(JSC::ExecState*); |
57 | JSC::EncodedJSValue JSC_HOST_CALL jsRTCRtpSenderPrototypeFunctionGetParameters(JSC::ExecState*); |
58 | JSC::EncodedJSValue JSC_HOST_CALL jsRTCRtpSenderPrototypeFunctionSetParameters(JSC::ExecState*); |
59 | JSC::EncodedJSValue JSC_HOST_CALL jsRTCRtpSenderPrototypeFunctionReplaceTrack(JSC::ExecState*); |
60 | JSC::EncodedJSValue JSC_HOST_CALL jsRTCRtpSenderPrototypeFunctionGetStats(JSC::ExecState*); |
61 | |
62 | // Attributes |
63 | |
64 | JSC::EncodedJSValue jsRTCRtpSenderConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
65 | bool setJSRTCRtpSenderConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
66 | JSC::EncodedJSValue jsRTCRtpSenderTrack(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
67 | |
68 | class JSRTCRtpSenderPrototype : public JSC::JSNonFinalObject { |
69 | public: |
70 | using Base = JSC::JSNonFinalObject; |
71 | static JSRTCRtpSenderPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure) |
72 | { |
73 | JSRTCRtpSenderPrototype* ptr = new (NotNull, JSC::allocateCell<JSRTCRtpSenderPrototype>(vm.heap)) JSRTCRtpSenderPrototype(vm, globalObject, structure); |
74 | ptr->finishCreation(vm); |
75 | return ptr; |
76 | } |
77 | |
78 | DECLARE_INFO; |
79 | static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) |
80 | { |
81 | return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); |
82 | } |
83 | |
84 | private: |
85 | JSRTCRtpSenderPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
86 | : JSC::JSNonFinalObject(vm, structure) |
87 | { |
88 | } |
89 | |
90 | void finishCreation(JSC::VM&); |
91 | }; |
92 | |
93 | using JSRTCRtpSenderConstructor = JSDOMConstructorNotConstructable<JSRTCRtpSender>; |
94 | |
95 | /* Hash table for constructor */ |
96 | |
97 | static const HashTableValue JSRTCRtpSenderConstructorTableValues[] = |
98 | { |
99 | { "getCapabilities" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsRTCRtpSenderConstructorFunctionGetCapabilities), (intptr_t) (1) } }, |
100 | }; |
101 | |
102 | template<> JSValue JSRTCRtpSenderConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
103 | { |
104 | UNUSED_PARAM(vm); |
105 | return globalObject.functionPrototype(); |
106 | } |
107 | |
108 | template<> void JSRTCRtpSenderConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
109 | { |
110 | putDirect(vm, vm.propertyNames->prototype, JSRTCRtpSender::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
111 | putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("RTCRtpSender"_s )), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
112 | putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
113 | reifyStaticProperties(vm, JSRTCRtpSender::info(), JSRTCRtpSenderConstructorTableValues, *this); |
114 | } |
115 | |
116 | template<> const ClassInfo JSRTCRtpSenderConstructor::s_info = { "RTCRtpSender" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSRTCRtpSenderConstructor) }; |
117 | |
118 | /* Hash table for prototype */ |
119 | |
120 | static const HashTableValue JSRTCRtpSenderPrototypeTableValues[] = |
121 | { |
122 | { "constructor" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRTCRtpSenderConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSRTCRtpSenderConstructor) } }, |
123 | { "track" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRTCRtpSenderTrack), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
124 | { "getParameters" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsRTCRtpSenderPrototypeFunctionGetParameters), (intptr_t) (0) } }, |
125 | { "setParameters" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsRTCRtpSenderPrototypeFunctionSetParameters), (intptr_t) (1) } }, |
126 | { "replaceTrack" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsRTCRtpSenderPrototypeFunctionReplaceTrack), (intptr_t) (1) } }, |
127 | { "getStats" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsRTCRtpSenderPrototypeFunctionGetStats), (intptr_t) (0) } }, |
128 | }; |
129 | |
130 | const ClassInfo JSRTCRtpSenderPrototype::s_info = { "RTCRtpSenderPrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSRTCRtpSenderPrototype) }; |
131 | |
132 | void JSRTCRtpSenderPrototype::finishCreation(VM& vm) |
133 | { |
134 | Base::finishCreation(vm); |
135 | reifyStaticProperties(vm, JSRTCRtpSender::info(), JSRTCRtpSenderPrototypeTableValues, *this); |
136 | } |
137 | |
138 | const ClassInfo JSRTCRtpSender::s_info = { "RTCRtpSender" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSRTCRtpSender) }; |
139 | |
140 | JSRTCRtpSender::JSRTCRtpSender(Structure* structure, JSDOMGlobalObject& globalObject, Ref<RTCRtpSender>&& impl) |
141 | : JSDOMWrapper<RTCRtpSender>(structure, globalObject, WTFMove(impl)) |
142 | { |
143 | } |
144 | |
145 | void JSRTCRtpSender::finishCreation(VM& vm) |
146 | { |
147 | Base::finishCreation(vm); |
148 | ASSERT(inherits(vm, info())); |
149 | |
150 | } |
151 | |
152 | JSObject* JSRTCRtpSender::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
153 | { |
154 | return JSRTCRtpSenderPrototype::create(vm, &globalObject, JSRTCRtpSenderPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype())); |
155 | } |
156 | |
157 | JSObject* JSRTCRtpSender::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
158 | { |
159 | return getDOMPrototype<JSRTCRtpSender>(vm, globalObject); |
160 | } |
161 | |
162 | JSValue JSRTCRtpSender::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
163 | { |
164 | return getDOMConstructor<JSRTCRtpSenderConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
165 | } |
166 | |
167 | void JSRTCRtpSender::destroy(JSC::JSCell* cell) |
168 | { |
169 | JSRTCRtpSender* thisObject = static_cast<JSRTCRtpSender*>(cell); |
170 | thisObject->JSRTCRtpSender::~JSRTCRtpSender(); |
171 | } |
172 | |
173 | template<> inline JSRTCRtpSender* IDLAttribute<JSRTCRtpSender>::cast(ExecState& state, EncodedJSValue thisValue) |
174 | { |
175 | return jsDynamicCast<JSRTCRtpSender*>(state.vm(), JSValue::decode(thisValue)); |
176 | } |
177 | |
178 | template<> inline JSRTCRtpSender* IDLOperation<JSRTCRtpSender>::cast(ExecState& state) |
179 | { |
180 | return jsDynamicCast<JSRTCRtpSender*>(state.vm(), state.thisValue()); |
181 | } |
182 | |
183 | EncodedJSValue jsRTCRtpSenderConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
184 | { |
185 | VM& vm = state->vm(); |
186 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
187 | auto* prototype = jsDynamicCast<JSRTCRtpSenderPrototype*>(vm, JSValue::decode(thisValue)); |
188 | if (UNLIKELY(!prototype)) |
189 | return throwVMTypeError(state, throwScope); |
190 | return JSValue::encode(JSRTCRtpSender::getConstructor(state->vm(), prototype->globalObject())); |
191 | } |
192 | |
193 | bool setJSRTCRtpSenderConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
194 | { |
195 | VM& vm = state->vm(); |
196 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
197 | auto* prototype = jsDynamicCast<JSRTCRtpSenderPrototype*>(vm, JSValue::decode(thisValue)); |
198 | if (UNLIKELY(!prototype)) { |
199 | throwVMTypeError(state, throwScope); |
200 | return false; |
201 | } |
202 | // Shadowing a built-in constructor |
203 | return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue)); |
204 | } |
205 | |
206 | static inline JSValue jsRTCRtpSenderTrackGetter(ExecState& state, JSRTCRtpSender& thisObject, ThrowScope& throwScope) |
207 | { |
208 | UNUSED_PARAM(throwScope); |
209 | UNUSED_PARAM(state); |
210 | auto& impl = thisObject.wrapped(); |
211 | JSValue result = toJS<IDLNullable<IDLInterface<MediaStreamTrack>>>(state, *thisObject.globalObject(), throwScope, impl.track()); |
212 | return result; |
213 | } |
214 | |
215 | EncodedJSValue jsRTCRtpSenderTrack(ExecState* state, EncodedJSValue thisValue, PropertyName) |
216 | { |
217 | return IDLAttribute<JSRTCRtpSender>::get<jsRTCRtpSenderTrackGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "track" ); |
218 | } |
219 | |
220 | static inline JSC::EncodedJSValue jsRTCRtpSenderConstructorFunctionGetCapabilitiesBody(JSC::ExecState* state, JSC::ThrowScope& throwScope) |
221 | { |
222 | UNUSED_PARAM(state); |
223 | UNUSED_PARAM(throwScope); |
224 | if (UNLIKELY(state->argumentCount() < 1)) |
225 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
226 | auto* context = jsCast<JSDOMGlobalObject*>(state->lexicalGlobalObject())->scriptExecutionContext(); |
227 | if (UNLIKELY(!context)) |
228 | return JSValue::encode(jsUndefined()); |
229 | auto kind = convert<IDLDOMString>(*state, state->uncheckedArgument(0)); |
230 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
231 | return JSValue::encode(toJS<IDLNullable<IDLDictionary<RTCRtpCapabilities>>>(*state, *jsCast<JSDOMGlobalObject*>(state->lexicalGlobalObject()), RTCRtpSender::getCapabilities(*context, WTFMove(kind)))); |
232 | } |
233 | |
234 | EncodedJSValue JSC_HOST_CALL jsRTCRtpSenderConstructorFunctionGetCapabilities(ExecState* state) |
235 | { |
236 | return IDLOperation<JSRTCRtpSender>::callStatic<jsRTCRtpSenderConstructorFunctionGetCapabilitiesBody>(*state, "getCapabilities" ); |
237 | } |
238 | |
239 | static inline JSC::EncodedJSValue jsRTCRtpSenderPrototypeFunctionGetParametersBody(JSC::ExecState* state, typename IDLOperation<JSRTCRtpSender>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
240 | { |
241 | UNUSED_PARAM(state); |
242 | UNUSED_PARAM(throwScope); |
243 | auto& impl = castedThis->wrapped(); |
244 | return JSValue::encode(toJS<IDLDictionary<RTCRtpSendParameters>>(*state, *castedThis->globalObject(), impl.getParameters())); |
245 | } |
246 | |
247 | EncodedJSValue JSC_HOST_CALL jsRTCRtpSenderPrototypeFunctionGetParameters(ExecState* state) |
248 | { |
249 | return IDLOperation<JSRTCRtpSender>::call<jsRTCRtpSenderPrototypeFunctionGetParametersBody>(*state, "getParameters" ); |
250 | } |
251 | |
252 | static inline JSC::EncodedJSValue jsRTCRtpSenderPrototypeFunctionSetParametersBody(JSC::ExecState* state, typename IDLOperationReturningPromise<JSRTCRtpSender>::ClassParameter castedThis, Ref<DeferredPromise>&& promise, JSC::ThrowScope& throwScope) |
253 | { |
254 | UNUSED_PARAM(state); |
255 | UNUSED_PARAM(throwScope); |
256 | auto& impl = castedThis->wrapped(); |
257 | if (UNLIKELY(state->argumentCount() < 1)) |
258 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
259 | auto parameters = convert<IDLDictionary<RTCRtpSendParameters>>(*state, state->uncheckedArgument(0)); |
260 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
261 | impl.setParameters(WTFMove(parameters), WTFMove(promise)); |
262 | return JSValue::encode(jsUndefined()); |
263 | } |
264 | |
265 | EncodedJSValue JSC_HOST_CALL jsRTCRtpSenderPrototypeFunctionSetParameters(ExecState* state) |
266 | { |
267 | return IDLOperationReturningPromise<JSRTCRtpSender>::call<jsRTCRtpSenderPrototypeFunctionSetParametersBody, PromiseExecutionScope::WindowOnly>(*state, "setParameters" ); |
268 | } |
269 | |
270 | static inline JSC::EncodedJSValue jsRTCRtpSenderPrototypeFunctionReplaceTrackBody(JSC::ExecState* state, typename IDLOperationReturningPromise<JSRTCRtpSender>::ClassParameter castedThis, Ref<DeferredPromise>&& promise, JSC::ThrowScope& throwScope) |
271 | { |
272 | UNUSED_PARAM(state); |
273 | UNUSED_PARAM(throwScope); |
274 | auto& impl = castedThis->wrapped(); |
275 | if (UNLIKELY(state->argumentCount() < 1)) |
276 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
277 | auto* context = jsCast<JSDOMGlobalObject*>(state->lexicalGlobalObject())->scriptExecutionContext(); |
278 | if (UNLIKELY(!context)) |
279 | return JSValue::encode(jsUndefined()); |
280 | auto withTrack = convert<IDLNullable<IDLInterface<MediaStreamTrack>>>(*state, state->uncheckedArgument(0), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentTypeError(state, scope, 0, "withTrack" , "RTCRtpSender" , "replaceTrack" , "MediaStreamTrack" ); }); |
281 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
282 | impl.replaceTrack(*context, WTFMove(withTrack), WTFMove(promise)); |
283 | return JSValue::encode(jsUndefined()); |
284 | } |
285 | |
286 | EncodedJSValue JSC_HOST_CALL jsRTCRtpSenderPrototypeFunctionReplaceTrack(ExecState* state) |
287 | { |
288 | return IDLOperationReturningPromise<JSRTCRtpSender>::call<jsRTCRtpSenderPrototypeFunctionReplaceTrackBody, PromiseExecutionScope::WindowOnly>(*state, "replaceTrack" ); |
289 | } |
290 | |
291 | static inline JSC::EncodedJSValue jsRTCRtpSenderPrototypeFunctionGetStatsBody(JSC::ExecState* state, typename IDLOperationReturningPromise<JSRTCRtpSender>::ClassParameter castedThis, Ref<DeferredPromise>&& promise, JSC::ThrowScope& throwScope) |
292 | { |
293 | UNUSED_PARAM(state); |
294 | UNUSED_PARAM(throwScope); |
295 | auto& impl = castedThis->wrapped(); |
296 | impl.getStats(WTFMove(promise)); |
297 | return JSValue::encode(jsUndefined()); |
298 | } |
299 | |
300 | EncodedJSValue JSC_HOST_CALL jsRTCRtpSenderPrototypeFunctionGetStats(ExecState* state) |
301 | { |
302 | return IDLOperationReturningPromise<JSRTCRtpSender>::call<jsRTCRtpSenderPrototypeFunctionGetStatsBody, PromiseExecutionScope::WindowOnly>(*state, "getStats" ); |
303 | } |
304 | |
305 | void JSRTCRtpSender::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder) |
306 | { |
307 | auto* thisObject = jsCast<JSRTCRtpSender*>(cell); |
308 | builder.setWrappedObjectForCell(cell, &thisObject->wrapped()); |
309 | if (thisObject->scriptExecutionContext()) |
310 | builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); |
311 | Base::heapSnapshot(cell, builder); |
312 | } |
313 | |
314 | bool JSRTCRtpSenderOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor, const char** reason) |
315 | { |
316 | UNUSED_PARAM(handle); |
317 | UNUSED_PARAM(visitor); |
318 | UNUSED_PARAM(reason); |
319 | return false; |
320 | } |
321 | |
322 | void JSRTCRtpSenderOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context) |
323 | { |
324 | auto* jsRTCRtpSender = static_cast<JSRTCRtpSender*>(handle.slot()->asCell()); |
325 | auto& world = *static_cast<DOMWrapperWorld*>(context); |
326 | uncacheWrapper(world, &jsRTCRtpSender->wrapped(), jsRTCRtpSender); |
327 | } |
328 | |
329 | JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<RTCRtpSender>&& impl) |
330 | { |
331 | // If you hit this failure the interface definition has the ImplementationLacksVTable |
332 | // attribute. You should remove that attribute. If the class has subclasses |
333 | // that may be passed through this toJS() function you should use the SkipVTableValidation |
334 | // attribute to RTCRtpSender. |
335 | static_assert(!std::is_polymorphic<RTCRtpSender>::value, "RTCRtpSender is polymorphic but the IDL claims it is not" ); |
336 | return createWrapper<RTCRtpSender>(globalObject, WTFMove(impl)); |
337 | } |
338 | |
339 | JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, RTCRtpSender& impl) |
340 | { |
341 | return wrap(state, globalObject, impl); |
342 | } |
343 | |
344 | RTCRtpSender* JSRTCRtpSender::toWrapped(JSC::VM& vm, JSC::JSValue value) |
345 | { |
346 | if (auto* wrapper = jsDynamicCast<JSRTCRtpSender*>(vm, value)) |
347 | return &wrapper->wrapped(); |
348 | return nullptr; |
349 | } |
350 | |
351 | } |
352 | |
353 | #endif // ENABLE(WEB_RTC) |
354 | |