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(MEDIA_STREAM)
24
25#include "JSMediaRecorder.h"
26
27#include "Document.h"
28#include "EventNames.h"
29#include "JSDOMAttribute.h"
30#include "JSDOMBinding.h"
31#include "JSDOMConstructor.h"
32#include "JSDOMConvertInterface.h"
33#include "JSDOMConvertNumbers.h"
34#include "JSDOMConvertStrings.h"
35#include "JSDOMExceptionHandling.h"
36#include "JSDOMOperation.h"
37#include "JSDOMWrapperCache.h"
38#include "JSEventListener.h"
39#include "ScriptExecutionContext.h"
40#include <JavaScriptCore/HeapSnapshotBuilder.h>
41#include <JavaScriptCore/JSCInlines.h>
42#include <JavaScriptCore/JSString.h>
43#include <wtf/GetPtr.h>
44#include <wtf/PointerPreparations.h>
45#include <wtf/URL.h>
46
47#if ENABLE(MEDIA_STREAM)
48#include "JSMediaStream.h"
49#endif
50
51
52namespace WebCore {
53using namespace JSC;
54
55String convertEnumerationToString(MediaRecorder::RecordingState enumerationValue)
56{
57 static const NeverDestroyed<String> values[] = {
58 MAKE_STATIC_STRING_IMPL("inactive"),
59 MAKE_STATIC_STRING_IMPL("recording"),
60 MAKE_STATIC_STRING_IMPL("paused"),
61 };
62 static_assert(static_cast<size_t>(MediaRecorder::RecordingState::Inactive) == 0, "MediaRecorder::RecordingState::Inactive is not 0 as expected");
63 static_assert(static_cast<size_t>(MediaRecorder::RecordingState::Recording) == 1, "MediaRecorder::RecordingState::Recording is not 1 as expected");
64 static_assert(static_cast<size_t>(MediaRecorder::RecordingState::Paused) == 2, "MediaRecorder::RecordingState::Paused is not 2 as expected");
65 ASSERT(static_cast<size_t>(enumerationValue) < WTF_ARRAY_LENGTH(values));
66 return values[static_cast<size_t>(enumerationValue)];
67}
68
69template<> JSString* convertEnumerationToJS(ExecState& state, MediaRecorder::RecordingState enumerationValue)
70{
71 return jsStringWithCache(&state, convertEnumerationToString(enumerationValue));
72}
73
74template<> Optional<MediaRecorder::RecordingState> parseEnumeration<MediaRecorder::RecordingState>(ExecState& state, JSValue value)
75{
76 auto stringValue = value.toWTFString(&state);
77 if (stringValue == "inactive")
78 return MediaRecorder::RecordingState::Inactive;
79 if (stringValue == "recording")
80 return MediaRecorder::RecordingState::Recording;
81 if (stringValue == "paused")
82 return MediaRecorder::RecordingState::Paused;
83 return WTF::nullopt;
84}
85
86template<> const char* expectedEnumerationValues<MediaRecorder::RecordingState>()
87{
88 return "\"inactive\", \"recording\", \"paused\"";
89}
90
91template<> MediaRecorder::Options convertDictionary<MediaRecorder::Options>(ExecState& state, JSValue value)
92{
93 VM& vm = state.vm();
94 auto throwScope = DECLARE_THROW_SCOPE(vm);
95 bool isNullOrUndefined = value.isUndefinedOrNull();
96 auto* object = isNullOrUndefined ? nullptr : value.getObject();
97 if (UNLIKELY(!isNullOrUndefined && !object)) {
98 throwTypeError(&state, throwScope);
99 return { };
100 }
101 MediaRecorder::Options result;
102 JSValue audioBitsPerSecondValue;
103 if (isNullOrUndefined)
104 audioBitsPerSecondValue = jsUndefined();
105 else {
106 audioBitsPerSecondValue = object->get(&state, Identifier::fromString(&state, "audioBitsPerSecond"));
107 RETURN_IF_EXCEPTION(throwScope, { });
108 }
109 if (!audioBitsPerSecondValue.isUndefined()) {
110 result.audioBitsPerSecond = convert<IDLUnsignedLong>(state, audioBitsPerSecondValue);
111 RETURN_IF_EXCEPTION(throwScope, { });
112 }
113 JSValue bitsPerSecondValue;
114 if (isNullOrUndefined)
115 bitsPerSecondValue = jsUndefined();
116 else {
117 bitsPerSecondValue = object->get(&state, Identifier::fromString(&state, "bitsPerSecond"));
118 RETURN_IF_EXCEPTION(throwScope, { });
119 }
120 if (!bitsPerSecondValue.isUndefined()) {
121 result.bitsPerSecond = convert<IDLUnsignedLong>(state, bitsPerSecondValue);
122 RETURN_IF_EXCEPTION(throwScope, { });
123 }
124 JSValue mimeTypeValue;
125 if (isNullOrUndefined)
126 mimeTypeValue = jsUndefined();
127 else {
128 mimeTypeValue = object->get(&state, Identifier::fromString(&state, "mimeType"));
129 RETURN_IF_EXCEPTION(throwScope, { });
130 }
131 if (!mimeTypeValue.isUndefined()) {
132 result.mimeType = convert<IDLDOMString>(state, mimeTypeValue);
133 RETURN_IF_EXCEPTION(throwScope, { });
134 }
135 JSValue videoBitsPerSecondValue;
136 if (isNullOrUndefined)
137 videoBitsPerSecondValue = jsUndefined();
138 else {
139 videoBitsPerSecondValue = object->get(&state, Identifier::fromString(&state, "videoBitsPerSecond"));
140 RETURN_IF_EXCEPTION(throwScope, { });
141 }
142 if (!videoBitsPerSecondValue.isUndefined()) {
143 result.videoBitsPerSecond = convert<IDLUnsignedLong>(state, videoBitsPerSecondValue);
144 RETURN_IF_EXCEPTION(throwScope, { });
145 }
146 return result;
147}
148
149// Functions
150
151JSC::EncodedJSValue JSC_HOST_CALL jsMediaRecorderPrototypeFunctionStart(JSC::ExecState*);
152JSC::EncodedJSValue JSC_HOST_CALL jsMediaRecorderPrototypeFunctionStop(JSC::ExecState*);
153
154// Attributes
155
156JSC::EncodedJSValue jsMediaRecorderConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
157bool setJSMediaRecorderConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
158JSC::EncodedJSValue jsMediaRecorderState(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
159JSC::EncodedJSValue jsMediaRecorderOnstop(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
160bool setJSMediaRecorderOnstop(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
161JSC::EncodedJSValue jsMediaRecorderOndataavailable(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
162bool setJSMediaRecorderOndataavailable(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
163JSC::EncodedJSValue jsMediaRecorderOnerror(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
164bool setJSMediaRecorderOnerror(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
165
166class JSMediaRecorderPrototype : public JSC::JSNonFinalObject {
167public:
168 using Base = JSC::JSNonFinalObject;
169 static JSMediaRecorderPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure)
170 {
171 JSMediaRecorderPrototype* ptr = new (NotNull, JSC::allocateCell<JSMediaRecorderPrototype>(vm.heap)) JSMediaRecorderPrototype(vm, globalObject, structure);
172 ptr->finishCreation(vm);
173 return ptr;
174 }
175
176 DECLARE_INFO;
177 static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
178 {
179 return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
180 }
181
182private:
183 JSMediaRecorderPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
184 : JSC::JSNonFinalObject(vm, structure)
185 {
186 }
187
188 void finishCreation(JSC::VM&);
189};
190
191using JSMediaRecorderConstructor = JSDOMConstructor<JSMediaRecorder>;
192
193template<> EncodedJSValue JSC_HOST_CALL JSMediaRecorderConstructor::construct(ExecState* state)
194{
195 VM& vm = state->vm();
196 auto throwScope = DECLARE_THROW_SCOPE(vm);
197 UNUSED_PARAM(throwScope);
198 auto* castedThis = jsCast<JSMediaRecorderConstructor*>(state->jsCallee());
199 ASSERT(castedThis);
200 if (UNLIKELY(state->argumentCount() < 1))
201 return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
202 auto* context = castedThis->scriptExecutionContext();
203 if (UNLIKELY(!context))
204 return throwConstructorScriptExecutionContextUnavailableError(*state, throwScope, "MediaRecorder");
205 ASSERT(context->isDocument());
206 auto& document = downcast<Document>(*context);
207 auto stream = convert<IDLInterface<MediaStream>>(*state, state->uncheckedArgument(0), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentTypeError(state, scope, 0, "stream", "MediaRecorder", nullptr, "MediaStream"); });
208 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
209 auto options = convert<IDLDictionary<MediaRecorder::Options>>(*state, state->argument(1));
210 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
211 auto object = MediaRecorder::create(document, *stream, WTFMove(options));
212 return JSValue::encode(toJSNewlyCreated<IDLInterface<MediaRecorder>>(*state, *castedThis->globalObject(), throwScope, WTFMove(object)));
213}
214
215template<> JSValue JSMediaRecorderConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
216{
217 return JSEventTarget::getConstructor(vm, &globalObject);
218}
219
220template<> void JSMediaRecorderConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
221{
222 putDirect(vm, vm.propertyNames->prototype, JSMediaRecorder::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
223 putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("MediaRecorder"_s)), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
224 putDirect(vm, vm.propertyNames->length, jsNumber(1), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
225}
226
227template<> const ClassInfo JSMediaRecorderConstructor::s_info = { "MediaRecorder", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSMediaRecorderConstructor) };
228
229/* Hash table for prototype */
230
231static const HashTableValue JSMediaRecorderPrototypeTableValues[] =
232{
233 { "constructor", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMediaRecorderConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSMediaRecorderConstructor) } },
234 { "state", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMediaRecorderState), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
235 { "onstop", static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMediaRecorderOnstop), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSMediaRecorderOnstop) } },
236 { "ondataavailable", static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMediaRecorderOndataavailable), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSMediaRecorderOndataavailable) } },
237 { "onerror", static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMediaRecorderOnerror), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSMediaRecorderOnerror) } },
238 { "start", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsMediaRecorderPrototypeFunctionStart), (intptr_t) (0) } },
239 { "stop", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsMediaRecorderPrototypeFunctionStop), (intptr_t) (0) } },
240};
241
242const ClassInfo JSMediaRecorderPrototype::s_info = { "MediaRecorderPrototype", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSMediaRecorderPrototype) };
243
244void JSMediaRecorderPrototype::finishCreation(VM& vm)
245{
246 Base::finishCreation(vm);
247 reifyStaticProperties(vm, JSMediaRecorder::info(), JSMediaRecorderPrototypeTableValues, *this);
248}
249
250const ClassInfo JSMediaRecorder::s_info = { "MediaRecorder", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSMediaRecorder) };
251
252JSMediaRecorder::JSMediaRecorder(Structure* structure, JSDOMGlobalObject& globalObject, Ref<MediaRecorder>&& impl)
253 : JSEventTarget(structure, globalObject, WTFMove(impl))
254{
255}
256
257void JSMediaRecorder::finishCreation(VM& vm)
258{
259 Base::finishCreation(vm);
260 ASSERT(inherits(vm, info()));
261
262}
263
264JSObject* JSMediaRecorder::createPrototype(VM& vm, JSDOMGlobalObject& globalObject)
265{
266 return JSMediaRecorderPrototype::create(vm, &globalObject, JSMediaRecorderPrototype::createStructure(vm, &globalObject, JSEventTarget::prototype(vm, globalObject)));
267}
268
269JSObject* JSMediaRecorder::prototype(VM& vm, JSDOMGlobalObject& globalObject)
270{
271 return getDOMPrototype<JSMediaRecorder>(vm, globalObject);
272}
273
274JSValue JSMediaRecorder::getConstructor(VM& vm, const JSGlobalObject* globalObject)
275{
276 return getDOMConstructor<JSMediaRecorderConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
277}
278
279template<> inline JSMediaRecorder* IDLAttribute<JSMediaRecorder>::cast(ExecState& state, EncodedJSValue thisValue)
280{
281 return jsDynamicCast<JSMediaRecorder*>(state.vm(), JSValue::decode(thisValue));
282}
283
284template<> inline JSMediaRecorder* IDLOperation<JSMediaRecorder>::cast(ExecState& state)
285{
286 return jsDynamicCast<JSMediaRecorder*>(state.vm(), state.thisValue());
287}
288
289EncodedJSValue jsMediaRecorderConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName)
290{
291 VM& vm = state->vm();
292 auto throwScope = DECLARE_THROW_SCOPE(vm);
293 auto* prototype = jsDynamicCast<JSMediaRecorderPrototype*>(vm, JSValue::decode(thisValue));
294 if (UNLIKELY(!prototype))
295 return throwVMTypeError(state, throwScope);
296 return JSValue::encode(JSMediaRecorder::getConstructor(state->vm(), prototype->globalObject()));
297}
298
299bool setJSMediaRecorderConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
300{
301 VM& vm = state->vm();
302 auto throwScope = DECLARE_THROW_SCOPE(vm);
303 auto* prototype = jsDynamicCast<JSMediaRecorderPrototype*>(vm, JSValue::decode(thisValue));
304 if (UNLIKELY(!prototype)) {
305 throwVMTypeError(state, throwScope);
306 return false;
307 }
308 // Shadowing a built-in constructor
309 return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue));
310}
311
312static inline JSValue jsMediaRecorderStateGetter(ExecState& state, JSMediaRecorder& thisObject, ThrowScope& throwScope)
313{
314 UNUSED_PARAM(throwScope);
315 UNUSED_PARAM(state);
316 auto& impl = thisObject.wrapped();
317 JSValue result = toJS<IDLEnumeration<MediaRecorder::RecordingState>>(state, throwScope, impl.state());
318 return result;
319}
320
321EncodedJSValue jsMediaRecorderState(ExecState* state, EncodedJSValue thisValue, PropertyName)
322{
323 return IDLAttribute<JSMediaRecorder>::get<jsMediaRecorderStateGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "state");
324}
325
326static inline JSValue jsMediaRecorderOnstopGetter(ExecState& state, JSMediaRecorder& thisObject, ThrowScope& throwScope)
327{
328 UNUSED_PARAM(throwScope);
329 UNUSED_PARAM(state);
330 return eventHandlerAttribute(thisObject.wrapped(), eventNames().stopEvent, worldForDOMObject(thisObject));
331}
332
333EncodedJSValue jsMediaRecorderOnstop(ExecState* state, EncodedJSValue thisValue, PropertyName)
334{
335 return IDLAttribute<JSMediaRecorder>::get<jsMediaRecorderOnstopGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "onstop");
336}
337
338static inline bool setJSMediaRecorderOnstopSetter(ExecState& state, JSMediaRecorder& thisObject, JSValue value, ThrowScope& throwScope)
339{
340 UNUSED_PARAM(throwScope);
341 setEventHandlerAttribute(state, thisObject, thisObject.wrapped(), eventNames().stopEvent, value);
342 return true;
343}
344
345bool setJSMediaRecorderOnstop(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
346{
347 return IDLAttribute<JSMediaRecorder>::set<setJSMediaRecorderOnstopSetter>(*state, thisValue, encodedValue, "onstop");
348}
349
350static inline JSValue jsMediaRecorderOndataavailableGetter(ExecState& state, JSMediaRecorder& thisObject, ThrowScope& throwScope)
351{
352 UNUSED_PARAM(throwScope);
353 UNUSED_PARAM(state);
354 return eventHandlerAttribute(thisObject.wrapped(), eventNames().dataavailableEvent, worldForDOMObject(thisObject));
355}
356
357EncodedJSValue jsMediaRecorderOndataavailable(ExecState* state, EncodedJSValue thisValue, PropertyName)
358{
359 return IDLAttribute<JSMediaRecorder>::get<jsMediaRecorderOndataavailableGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "ondataavailable");
360}
361
362static inline bool setJSMediaRecorderOndataavailableSetter(ExecState& state, JSMediaRecorder& thisObject, JSValue value, ThrowScope& throwScope)
363{
364 UNUSED_PARAM(throwScope);
365 setEventHandlerAttribute(state, thisObject, thisObject.wrapped(), eventNames().dataavailableEvent, value);
366 return true;
367}
368
369bool setJSMediaRecorderOndataavailable(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
370{
371 return IDLAttribute<JSMediaRecorder>::set<setJSMediaRecorderOndataavailableSetter>(*state, thisValue, encodedValue, "ondataavailable");
372}
373
374static inline JSValue jsMediaRecorderOnerrorGetter(ExecState& state, JSMediaRecorder& thisObject, ThrowScope& throwScope)
375{
376 UNUSED_PARAM(throwScope);
377 UNUSED_PARAM(state);
378 return eventHandlerAttribute(thisObject.wrapped(), eventNames().errorEvent, worldForDOMObject(thisObject));
379}
380
381EncodedJSValue jsMediaRecorderOnerror(ExecState* state, EncodedJSValue thisValue, PropertyName)
382{
383 return IDLAttribute<JSMediaRecorder>::get<jsMediaRecorderOnerrorGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "onerror");
384}
385
386static inline bool setJSMediaRecorderOnerrorSetter(ExecState& state, JSMediaRecorder& thisObject, JSValue value, ThrowScope& throwScope)
387{
388 UNUSED_PARAM(throwScope);
389 setEventHandlerAttribute(state, thisObject, thisObject.wrapped(), eventNames().errorEvent, value);
390 return true;
391}
392
393bool setJSMediaRecorderOnerror(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
394{
395 return IDLAttribute<JSMediaRecorder>::set<setJSMediaRecorderOnerrorSetter>(*state, thisValue, encodedValue, "onerror");
396}
397
398static inline JSC::EncodedJSValue jsMediaRecorderPrototypeFunctionStartBody(JSC::ExecState* state, typename IDLOperation<JSMediaRecorder>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
399{
400 UNUSED_PARAM(state);
401 UNUSED_PARAM(throwScope);
402 auto& impl = castedThis->wrapped();
403 auto timeslice = state->argument(0).isUndefined() ? Optional<Converter<IDLLong>::ReturnType>() : Optional<Converter<IDLLong>::ReturnType>(convert<IDLLong>(*state, state->uncheckedArgument(0)));
404 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
405 propagateException(*state, throwScope, impl.startRecording(WTFMove(timeslice)));
406 return JSValue::encode(jsUndefined());
407}
408
409EncodedJSValue JSC_HOST_CALL jsMediaRecorderPrototypeFunctionStart(ExecState* state)
410{
411 return IDLOperation<JSMediaRecorder>::call<jsMediaRecorderPrototypeFunctionStartBody>(*state, "start");
412}
413
414static inline JSC::EncodedJSValue jsMediaRecorderPrototypeFunctionStopBody(JSC::ExecState* state, typename IDLOperation<JSMediaRecorder>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
415{
416 UNUSED_PARAM(state);
417 UNUSED_PARAM(throwScope);
418 auto& impl = castedThis->wrapped();
419 impl.stopRecording();
420 return JSValue::encode(jsUndefined());
421}
422
423EncodedJSValue JSC_HOST_CALL jsMediaRecorderPrototypeFunctionStop(ExecState* state)
424{
425 return IDLOperation<JSMediaRecorder>::call<jsMediaRecorderPrototypeFunctionStopBody>(*state, "stop");
426}
427
428void JSMediaRecorder::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder)
429{
430 auto* thisObject = jsCast<JSMediaRecorder*>(cell);
431 builder.setWrappedObjectForCell(cell, &thisObject->wrapped());
432 if (thisObject->scriptExecutionContext())
433 builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string());
434 Base::heapSnapshot(cell, builder);
435}
436
437bool JSMediaRecorderOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor, const char** reason)
438{
439 auto* jsMediaRecorder = jsCast<JSMediaRecorder*>(handle.slot()->asCell());
440 if (jsMediaRecorder->wrapped().hasPendingActivity()) {
441 if (UNLIKELY(reason))
442 *reason = "ActiveDOMObject with pending activity";
443 return true;
444 }
445 if (jsMediaRecorder->wrapped().isFiringEventListeners()) {
446 if (UNLIKELY(reason))
447 *reason = "EventTarget firing event listeners";
448 return true;
449 }
450 UNUSED_PARAM(visitor);
451 UNUSED_PARAM(reason);
452 return false;
453}
454
455void JSMediaRecorderOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
456{
457 auto* jsMediaRecorder = static_cast<JSMediaRecorder*>(handle.slot()->asCell());
458 auto& world = *static_cast<DOMWrapperWorld*>(context);
459 uncacheWrapper(world, &jsMediaRecorder->wrapped(), jsMediaRecorder);
460}
461
462#if ENABLE(BINDING_INTEGRITY)
463#if PLATFORM(WIN)
464#pragma warning(disable: 4483)
465extern "C" { extern void (*const __identifier("??_7MediaRecorder@WebCore@@6B@")[])(); }
466#else
467extern "C" { extern void* _ZTVN7WebCore13MediaRecorderE[]; }
468#endif
469#endif
470
471JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<MediaRecorder>&& impl)
472{
473
474#if ENABLE(BINDING_INTEGRITY)
475 void* actualVTablePointer = *(reinterpret_cast<void**>(impl.ptr()));
476#if PLATFORM(WIN)
477 void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(__identifier("??_7MediaRecorder@WebCore@@6B@"));
478#else
479 void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(&_ZTVN7WebCore13MediaRecorderE[2]);
480#endif
481
482 // If this fails MediaRecorder does not have a vtable, so you need to add the
483 // ImplementationLacksVTable attribute to the interface definition
484 static_assert(std::is_polymorphic<MediaRecorder>::value, "MediaRecorder is not polymorphic");
485
486 // If you hit this assertion you either have a use after free bug, or
487 // MediaRecorder has subclasses. If MediaRecorder has subclasses that get passed
488 // to toJS() we currently require MediaRecorder you to opt out of binding hardening
489 // by adding the SkipVTableValidation attribute to the interface IDL definition
490 RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer);
491#endif
492 return createWrapper<MediaRecorder>(globalObject, WTFMove(impl));
493}
494
495JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, MediaRecorder& impl)
496{
497 return wrap(state, globalObject, impl);
498}
499
500MediaRecorder* JSMediaRecorder::toWrapped(JSC::VM& vm, JSC::JSValue value)
501{
502 if (auto* wrapper = jsDynamicCast<JSMediaRecorder*>(vm, value))
503 return &wrapper->wrapped();
504 return nullptr;
505}
506
507}
508
509#endif // ENABLE(MEDIA_STREAM)
510