blob: c9af733c222c5ce677fba80265f676324ac4e9e0 [file] [log] [blame]
/*
This file is part of the WebKit open source project.
This file has been generated by generate-bindings.pl. DO NOT MODIFY!
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "config.h"
#if ENABLE(MEDIA_STREAM)
#include "JSMediaStreamTrack.h"
#include "EventNames.h"
#include "ExceptionCode.h"
#include "JSDOMBinding.h"
#include "JSDOMConstructor.h"
#include "JSDOMConvert.h"
#include "JSDOMPromise.h"
#include "JSEventListener.h"
#include "JSMediaStreamTrack.h"
#include "MediaStreamTrack.h"
#include "URL.h"
#include <runtime/Error.h>
#include <runtime/JSString.h>
#include <wtf/GetPtr.h>
using namespace JSC;
namespace WebCore {
template<typename T> Optional<T> parse(ExecState&, JSValue);
template<typename T> const char* expectedEnumerationValues();
JSString* jsStringWithCache(ExecState*, MediaStreamTrack::State);
JSString* jsStringWithCache(ExecState* state, MediaStreamTrack::State enumerationValue)
{
static NeverDestroyed<const String> values[] = {
ASCIILiteral("new"),
ASCIILiteral("live"),
ASCIILiteral("ended"),
};
static_assert(static_cast<size_t>(MediaStreamTrack::State::New) == 0, "MediaStreamTrack::State::New is not 0 as expected");
static_assert(static_cast<size_t>(MediaStreamTrack::State::Live) == 1, "MediaStreamTrack::State::Live is not 1 as expected");
static_assert(static_cast<size_t>(MediaStreamTrack::State::Ended) == 2, "MediaStreamTrack::State::Ended is not 2 as expected");
ASSERT(static_cast<size_t>(enumerationValue) < WTF_ARRAY_LENGTH(values));
return jsStringWithCache(state, values[static_cast<size_t>(enumerationValue)]);
}
template<> struct JSValueTraits<MediaStreamTrack::State> {
static JSString* arrayJSValue(ExecState* state, JSDOMGlobalObject*, MediaStreamTrack::State value) { return jsStringWithCache(state, value); }
};
template<> Optional<MediaStreamTrack::State> parse<MediaStreamTrack::State>(ExecState& state, JSValue value)
{
auto stringValue = value.toWTFString(&state);
if (stringValue == "new")
return MediaStreamTrack::State::New;
if (stringValue == "live")
return MediaStreamTrack::State::Live;
if (stringValue == "ended")
return MediaStreamTrack::State::Ended;
return Nullopt;
}
template<> MediaStreamTrack::State convert<MediaStreamTrack::State>(ExecState& state, JSValue value)
{
VM& vm = state.vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
auto result = parse<MediaStreamTrack::State>(state, value);
if (UNLIKELY(!result)) {
throwTypeError(&state, throwScope);
return { };
}
return result.value();
}
template<> inline const char* expectedEnumerationValues<MediaStreamTrack::State>()
{
return "\"new\", \"live\", \"ended\"";
}
// Functions
JSC::EncodedJSValue JSC_HOST_CALL jsMediaStreamTrackPrototypeFunctionClone(JSC::ExecState*);
JSC::EncodedJSValue JSC_HOST_CALL jsMediaStreamTrackPrototypeFunctionStop(JSC::ExecState*);
JSC::EncodedJSValue JSC_HOST_CALL jsMediaStreamTrackPrototypeFunctionGetConstraints(JSC::ExecState*);
JSC::EncodedJSValue JSC_HOST_CALL jsMediaStreamTrackPrototypeFunctionGetSettings(JSC::ExecState*);
JSC::EncodedJSValue JSC_HOST_CALL jsMediaStreamTrackPrototypeFunctionGetCapabilities(JSC::ExecState*);
JSC::EncodedJSValue JSC_HOST_CALL jsMediaStreamTrackPrototypeFunctionApplyConstraints(JSC::ExecState*);
// Attributes
JSC::EncodedJSValue jsMediaStreamTrackKind(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
JSC::EncodedJSValue jsMediaStreamTrackId(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
JSC::EncodedJSValue jsMediaStreamTrackLabel(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
JSC::EncodedJSValue jsMediaStreamTrackEnabled(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
bool setJSMediaStreamTrackEnabled(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
JSC::EncodedJSValue jsMediaStreamTrackMuted(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
JSC::EncodedJSValue jsMediaStreamTrackOnmute(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
bool setJSMediaStreamTrackOnmute(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
JSC::EncodedJSValue jsMediaStreamTrackOnunmute(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
bool setJSMediaStreamTrackOnunmute(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
JSC::EncodedJSValue jsMediaStreamTrackReadonly(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
JSC::EncodedJSValue jsMediaStreamTrackRemote(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
JSC::EncodedJSValue jsMediaStreamTrackReadyState(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
JSC::EncodedJSValue jsMediaStreamTrackOnended(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
bool setJSMediaStreamTrackOnended(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
JSC::EncodedJSValue jsMediaStreamTrackOnoverconstrained(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
bool setJSMediaStreamTrackOnoverconstrained(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
JSC::EncodedJSValue jsMediaStreamTrackConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
bool setJSMediaStreamTrackConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
class JSMediaStreamTrackPrototype : public JSC::JSNonFinalObject {
public:
typedef JSC::JSNonFinalObject Base;
static JSMediaStreamTrackPrototype* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
{
JSMediaStreamTrackPrototype* ptr = new (NotNull, JSC::allocateCell<JSMediaStreamTrackPrototype>(vm.heap)) JSMediaStreamTrackPrototype(vm, globalObject, structure);
ptr->finishCreation(vm);
return ptr;
}
DECLARE_INFO;
static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
{
return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
}
private:
JSMediaStreamTrackPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
: JSC::JSNonFinalObject(vm, structure)
{
}
void finishCreation(JSC::VM&);
};
typedef JSDOMConstructorNotConstructable<JSMediaStreamTrack> JSMediaStreamTrackConstructor;
template<> JSValue JSMediaStreamTrackConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
{
return JSEventTarget::getConstructor(vm, &globalObject);
}
template<> void JSMediaStreamTrackConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
{
putDirect(vm, vm.propertyNames->prototype, JSMediaStreamTrack::prototype(vm, &globalObject), DontDelete | ReadOnly | DontEnum);
putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String(ASCIILiteral("MediaStreamTrack"))), ReadOnly | DontEnum);
putDirect(vm, vm.propertyNames->length, jsNumber(0), ReadOnly | DontEnum);
}
template<> const ClassInfo JSMediaStreamTrackConstructor::s_info = { "MediaStreamTrack", &Base::s_info, 0, CREATE_METHOD_TABLE(JSMediaStreamTrackConstructor) };
/* Hash table for prototype */
static const HashTableValue JSMediaStreamTrackPrototypeTableValues[] =
{
{ "constructor", DontEnum, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMediaStreamTrackConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSMediaStreamTrackConstructor) } },
{ "kind", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMediaStreamTrackKind), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
{ "id", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMediaStreamTrackId), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
{ "label", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMediaStreamTrackLabel), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
{ "enabled", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMediaStreamTrackEnabled), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSMediaStreamTrackEnabled) } },
{ "muted", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMediaStreamTrackMuted), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
{ "onmute", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMediaStreamTrackOnmute), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSMediaStreamTrackOnmute) } },
{ "onunmute", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMediaStreamTrackOnunmute), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSMediaStreamTrackOnunmute) } },
{ "readonly", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMediaStreamTrackReadonly), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
{ "remote", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMediaStreamTrackRemote), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
{ "readyState", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMediaStreamTrackReadyState), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
{ "onended", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMediaStreamTrackOnended), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSMediaStreamTrackOnended) } },
{ "onoverconstrained", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMediaStreamTrackOnoverconstrained), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSMediaStreamTrackOnoverconstrained) } },
{ "clone", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsMediaStreamTrackPrototypeFunctionClone), (intptr_t) (0) } },
{ "stop", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsMediaStreamTrackPrototypeFunctionStop), (intptr_t) (0) } },
{ "getConstraints", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsMediaStreamTrackPrototypeFunctionGetConstraints), (intptr_t) (0) } },
{ "getSettings", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsMediaStreamTrackPrototypeFunctionGetSettings), (intptr_t) (0) } },
{ "getCapabilities", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsMediaStreamTrackPrototypeFunctionGetCapabilities), (intptr_t) (0) } },
{ "applyConstraints", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsMediaStreamTrackPrototypeFunctionApplyConstraints), (intptr_t) (1) } },
};
const ClassInfo JSMediaStreamTrackPrototype::s_info = { "MediaStreamTrackPrototype", &Base::s_info, 0, CREATE_METHOD_TABLE(JSMediaStreamTrackPrototype) };
void JSMediaStreamTrackPrototype::finishCreation(VM& vm)
{
Base::finishCreation(vm);
reifyStaticProperties(vm, JSMediaStreamTrackPrototypeTableValues, *this);
}
const ClassInfo JSMediaStreamTrack::s_info = { "MediaStreamTrack", &Base::s_info, 0, CREATE_METHOD_TABLE(JSMediaStreamTrack) };
JSMediaStreamTrack::JSMediaStreamTrack(Structure* structure, JSDOMGlobalObject& globalObject, Ref<MediaStreamTrack>&& impl)
: JSEventTarget(structure, globalObject, WTFMove(impl))
{
}
JSObject* JSMediaStreamTrack::createPrototype(VM& vm, JSGlobalObject* globalObject)
{
return JSMediaStreamTrackPrototype::create(vm, globalObject, JSMediaStreamTrackPrototype::createStructure(vm, globalObject, JSEventTarget::prototype(vm, globalObject)));
}
JSObject* JSMediaStreamTrack::prototype(VM& vm, JSGlobalObject* globalObject)
{
return getDOMPrototype<JSMediaStreamTrack>(vm, globalObject);
}
EncodedJSValue jsMediaStreamTrackKind(ExecState* state, EncodedJSValue thisValue, PropertyName)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
UNUSED_PARAM(thisValue);
JSValue decodedThisValue = JSValue::decode(thisValue);
auto* castedThis = jsDynamicCast<JSMediaStreamTrack*>(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "MediaStreamTrack", "kind");
}
auto& impl = castedThis->wrapped();
JSValue result = jsStringWithCache(state, impl.kind());
return JSValue::encode(result);
}
EncodedJSValue jsMediaStreamTrackId(ExecState* state, EncodedJSValue thisValue, PropertyName)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
UNUSED_PARAM(thisValue);
JSValue decodedThisValue = JSValue::decode(thisValue);
auto* castedThis = jsDynamicCast<JSMediaStreamTrack*>(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "MediaStreamTrack", "id");
}
auto& impl = castedThis->wrapped();
JSValue result = jsStringWithCache(state, impl.id());
return JSValue::encode(result);
}
EncodedJSValue jsMediaStreamTrackLabel(ExecState* state, EncodedJSValue thisValue, PropertyName)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
UNUSED_PARAM(thisValue);
JSValue decodedThisValue = JSValue::decode(thisValue);
auto* castedThis = jsDynamicCast<JSMediaStreamTrack*>(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "MediaStreamTrack", "label");
}
auto& impl = castedThis->wrapped();
JSValue result = jsStringWithCache(state, impl.label());
return JSValue::encode(result);
}
EncodedJSValue jsMediaStreamTrackEnabled(ExecState* state, EncodedJSValue thisValue, PropertyName)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
UNUSED_PARAM(thisValue);
JSValue decodedThisValue = JSValue::decode(thisValue);
auto* castedThis = jsDynamicCast<JSMediaStreamTrack*>(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "MediaStreamTrack", "enabled");
}
auto& impl = castedThis->wrapped();
JSValue result = jsBoolean(impl.enabled());
return JSValue::encode(result);
}
EncodedJSValue jsMediaStreamTrackMuted(ExecState* state, EncodedJSValue thisValue, PropertyName)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
UNUSED_PARAM(thisValue);
JSValue decodedThisValue = JSValue::decode(thisValue);
auto* castedThis = jsDynamicCast<JSMediaStreamTrack*>(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "MediaStreamTrack", "muted");
}
auto& impl = castedThis->wrapped();
JSValue result = jsBoolean(impl.muted());
return JSValue::encode(result);
}
EncodedJSValue jsMediaStreamTrackOnmute(ExecState* state, EncodedJSValue thisValue, PropertyName)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
UNUSED_PARAM(thisValue);
JSValue decodedThisValue = JSValue::decode(thisValue);
auto* castedThis = jsDynamicCast<JSMediaStreamTrack*>(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "MediaStreamTrack", "onmute");
}
UNUSED_PARAM(state);
return JSValue::encode(eventHandlerAttribute(castedThis->wrapped(), eventNames().muteEvent));
}
EncodedJSValue jsMediaStreamTrackOnunmute(ExecState* state, EncodedJSValue thisValue, PropertyName)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
UNUSED_PARAM(thisValue);
JSValue decodedThisValue = JSValue::decode(thisValue);
auto* castedThis = jsDynamicCast<JSMediaStreamTrack*>(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "MediaStreamTrack", "onunmute");
}
UNUSED_PARAM(state);
return JSValue::encode(eventHandlerAttribute(castedThis->wrapped(), eventNames().unmuteEvent));
}
EncodedJSValue jsMediaStreamTrackReadonly(ExecState* state, EncodedJSValue thisValue, PropertyName)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
UNUSED_PARAM(thisValue);
JSValue decodedThisValue = JSValue::decode(thisValue);
auto* castedThis = jsDynamicCast<JSMediaStreamTrack*>(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "MediaStreamTrack", "readonly");
}
auto& impl = castedThis->wrapped();
JSValue result = jsBoolean(impl.readonly());
return JSValue::encode(result);
}
EncodedJSValue jsMediaStreamTrackRemote(ExecState* state, EncodedJSValue thisValue, PropertyName)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
UNUSED_PARAM(thisValue);
JSValue decodedThisValue = JSValue::decode(thisValue);
auto* castedThis = jsDynamicCast<JSMediaStreamTrack*>(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "MediaStreamTrack", "remote");
}
auto& impl = castedThis->wrapped();
JSValue result = jsBoolean(impl.remote());
return JSValue::encode(result);
}
EncodedJSValue jsMediaStreamTrackReadyState(ExecState* state, EncodedJSValue thisValue, PropertyName)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
UNUSED_PARAM(thisValue);
JSValue decodedThisValue = JSValue::decode(thisValue);
auto* castedThis = jsDynamicCast<JSMediaStreamTrack*>(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "MediaStreamTrack", "readyState");
}
auto& impl = castedThis->wrapped();
JSValue result = jsStringWithCache(state, impl.readyState());
return JSValue::encode(result);
}
EncodedJSValue jsMediaStreamTrackOnended(ExecState* state, EncodedJSValue thisValue, PropertyName)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
UNUSED_PARAM(thisValue);
JSValue decodedThisValue = JSValue::decode(thisValue);
auto* castedThis = jsDynamicCast<JSMediaStreamTrack*>(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "MediaStreamTrack", "onended");
}
UNUSED_PARAM(state);
return JSValue::encode(eventHandlerAttribute(castedThis->wrapped(), eventNames().endedEvent));
}
EncodedJSValue jsMediaStreamTrackOnoverconstrained(ExecState* state, EncodedJSValue thisValue, PropertyName)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
UNUSED_PARAM(thisValue);
JSValue decodedThisValue = JSValue::decode(thisValue);
auto* castedThis = jsDynamicCast<JSMediaStreamTrack*>(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "MediaStreamTrack", "onoverconstrained");
}
UNUSED_PARAM(state);
return JSValue::encode(eventHandlerAttribute(castedThis->wrapped(), eventNames().overconstrainedEvent));
}
EncodedJSValue jsMediaStreamTrackConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSMediaStreamTrackPrototype* domObject = jsDynamicCast<JSMediaStreamTrackPrototype*>(JSValue::decode(thisValue));
if (UNLIKELY(!domObject))
return throwVMTypeError(state, throwScope);
return JSValue::encode(JSMediaStreamTrack::getConstructor(state->vm(), domObject->globalObject()));
}
bool setJSMediaStreamTrackConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSValue value = JSValue::decode(encodedValue);
JSMediaStreamTrackPrototype* domObject = jsDynamicCast<JSMediaStreamTrackPrototype*>(JSValue::decode(thisValue));
if (UNLIKELY(!domObject)) {
throwVMTypeError(state, throwScope);
return false;
}
// Shadowing a built-in constructor
return domObject->putDirect(state->vm(), state->propertyNames().constructor, value);
}
bool setJSMediaStreamTrackEnabled(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
JSValue value = JSValue::decode(encodedValue);
UNUSED_PARAM(thisValue);
JSMediaStreamTrack* castedThis = jsDynamicCast<JSMediaStreamTrack*>(JSValue::decode(thisValue));
if (UNLIKELY(!castedThis)) {
return throwSetterTypeError(*state, throwScope, "MediaStreamTrack", "enabled");
}
auto& impl = castedThis->wrapped();
auto nativeValue = value.toBoolean(state);
RETURN_IF_EXCEPTION(throwScope, false);
impl.setEnabled(WTFMove(nativeValue));
return true;
}
bool setJSMediaStreamTrackOnmute(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
JSValue value = JSValue::decode(encodedValue);
UNUSED_PARAM(thisValue);
JSMediaStreamTrack* castedThis = jsDynamicCast<JSMediaStreamTrack*>(JSValue::decode(thisValue));
if (UNLIKELY(!castedThis)) {
return throwSetterTypeError(*state, throwScope, "MediaStreamTrack", "onmute");
}
setEventHandlerAttribute(*state, *castedThis, castedThis->wrapped(), eventNames().muteEvent, value);
return true;
}
bool setJSMediaStreamTrackOnunmute(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
JSValue value = JSValue::decode(encodedValue);
UNUSED_PARAM(thisValue);
JSMediaStreamTrack* castedThis = jsDynamicCast<JSMediaStreamTrack*>(JSValue::decode(thisValue));
if (UNLIKELY(!castedThis)) {
return throwSetterTypeError(*state, throwScope, "MediaStreamTrack", "onunmute");
}
setEventHandlerAttribute(*state, *castedThis, castedThis->wrapped(), eventNames().unmuteEvent, value);
return true;
}
bool setJSMediaStreamTrackOnended(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
JSValue value = JSValue::decode(encodedValue);
UNUSED_PARAM(thisValue);
JSMediaStreamTrack* castedThis = jsDynamicCast<JSMediaStreamTrack*>(JSValue::decode(thisValue));
if (UNLIKELY(!castedThis)) {
return throwSetterTypeError(*state, throwScope, "MediaStreamTrack", "onended");
}
setEventHandlerAttribute(*state, *castedThis, castedThis->wrapped(), eventNames().endedEvent, value);
return true;
}
bool setJSMediaStreamTrackOnoverconstrained(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
JSValue value = JSValue::decode(encodedValue);
UNUSED_PARAM(thisValue);
JSMediaStreamTrack* castedThis = jsDynamicCast<JSMediaStreamTrack*>(JSValue::decode(thisValue));
if (UNLIKELY(!castedThis)) {
return throwSetterTypeError(*state, throwScope, "MediaStreamTrack", "onoverconstrained");
}
setEventHandlerAttribute(*state, *castedThis, castedThis->wrapped(), eventNames().overconstrainedEvent, value);
return true;
}
JSValue JSMediaStreamTrack::getConstructor(VM& vm, const JSGlobalObject* globalObject)
{
return getDOMConstructor<JSMediaStreamTrackConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
}
EncodedJSValue JSC_HOST_CALL jsMediaStreamTrackPrototypeFunctionClone(ExecState* state)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
JSValue thisValue = state->thisValue();
auto castedThis = jsDynamicCast<JSMediaStreamTrack*>(thisValue);
if (UNLIKELY(!castedThis))
return throwThisTypeError(*state, throwScope, "MediaStreamTrack", "clone");
ASSERT_GC_OBJECT_INHERITS(castedThis, JSMediaStreamTrack::info());
auto& impl = castedThis->wrapped();
JSValue result = toJS(state, castedThis->globalObject(), impl.clone());
return JSValue::encode(result);
}
EncodedJSValue JSC_HOST_CALL jsMediaStreamTrackPrototypeFunctionStop(ExecState* state)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
JSValue thisValue = state->thisValue();
auto castedThis = jsDynamicCast<JSMediaStreamTrack*>(thisValue);
if (UNLIKELY(!castedThis))
return throwThisTypeError(*state, throwScope, "MediaStreamTrack", "stop");
ASSERT_GC_OBJECT_INHERITS(castedThis, JSMediaStreamTrack::info());
auto& impl = castedThis->wrapped();
impl.stopProducingData();
return JSValue::encode(jsUndefined());
}
EncodedJSValue JSC_HOST_CALL jsMediaStreamTrackPrototypeFunctionGetConstraints(ExecState* state)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
JSValue thisValue = state->thisValue();
auto castedThis = jsDynamicCast<JSMediaStreamTrack*>(thisValue);
if (UNLIKELY(!castedThis))
return throwThisTypeError(*state, throwScope, "MediaStreamTrack", "getConstraints");
ASSERT_GC_OBJECT_INHERITS(castedThis, JSMediaStreamTrack::info());
return JSValue::encode(castedThis->getConstraints(*state));
}
EncodedJSValue JSC_HOST_CALL jsMediaStreamTrackPrototypeFunctionGetSettings(ExecState* state)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
JSValue thisValue = state->thisValue();
auto castedThis = jsDynamicCast<JSMediaStreamTrack*>(thisValue);
if (UNLIKELY(!castedThis))
return throwThisTypeError(*state, throwScope, "MediaStreamTrack", "getSettings");
ASSERT_GC_OBJECT_INHERITS(castedThis, JSMediaStreamTrack::info());
return JSValue::encode(castedThis->getSettings(*state));
}
EncodedJSValue JSC_HOST_CALL jsMediaStreamTrackPrototypeFunctionGetCapabilities(ExecState* state)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
JSValue thisValue = state->thisValue();
auto castedThis = jsDynamicCast<JSMediaStreamTrack*>(thisValue);
if (UNLIKELY(!castedThis))
return throwThisTypeError(*state, throwScope, "MediaStreamTrack", "getCapabilities");
ASSERT_GC_OBJECT_INHERITS(castedThis, JSMediaStreamTrack::info());
return JSValue::encode(castedThis->getCapabilities(*state));
}
EncodedJSValue JSC_HOST_CALL jsMediaStreamTrackPrototypeFunctionApplyConstraints(ExecState* state)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
JSValue thisValue = state->thisValue();
auto castedThis = jsDynamicCast<JSMediaStreamTrack*>(thisValue);
if (UNLIKELY(!castedThis))
return createRejectedPromiseWithTypeError(*state, makeThisTypeErrorMessage("MediaStreamTrack", "applyConstraints"));
ASSERT_GC_OBJECT_INHERITS(castedThis, JSMediaStreamTrack::info());
return JSValue::encode(castedThis->applyConstraints(*state));
}
void JSMediaStreamTrack::visitChildren(JSCell* cell, SlotVisitor& visitor)
{
auto* thisObject = jsCast<JSMediaStreamTrack*>(cell);
ASSERT_GC_OBJECT_INHERITS(thisObject, info());
Base::visitChildren(thisObject, visitor);
thisObject->wrapped().visitJSEventListeners(visitor);
}
bool JSMediaStreamTrackOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor)
{
auto* jsMediaStreamTrack = jsCast<JSMediaStreamTrack*>(handle.slot()->asCell());
if (jsMediaStreamTrack->wrapped().hasPendingActivity())
return true;
if (jsMediaStreamTrack->wrapped().isFiringEventListeners())
return true;
UNUSED_PARAM(visitor);
return false;
}
void JSMediaStreamTrackOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
{
auto* jsMediaStreamTrack = jsCast<JSMediaStreamTrack*>(handle.slot()->asCell());
auto& world = *static_cast<DOMWrapperWorld*>(context);
uncacheWrapper(world, &jsMediaStreamTrack->wrapped(), jsMediaStreamTrack);
}
JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<MediaStreamTrack>&& impl)
{
return createWrapper<MediaStreamTrack>(globalObject, WTFMove(impl));
}
JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, MediaStreamTrack& impl)
{
return wrap(state, globalObject, impl);
}
MediaStreamTrack* JSMediaStreamTrack::toWrapped(JSC::JSValue value)
{
if (auto* wrapper = jsDynamicCast<JSMediaStreamTrack*>(value))
return &wrapper->wrapped();
return nullptr;
}
}
#endif // ENABLE(MEDIA_STREAM)