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 "JSMediaStreamTrack.h"
26
27#include "EventNames.h"
28#include "JSDOMAttribute.h"
29#include "JSDOMBinding.h"
30#include "JSDOMConstructorNotConstructable.h"
31#include "JSDOMConvertBoolean.h"
32#include "JSDOMConvertInterface.h"
33#include "JSDOMConvertNumbers.h"
34#include "JSDOMConvertSequences.h"
35#include "JSDOMConvertStrings.h"
36#include "JSDOMExceptionHandling.h"
37#include "JSDOMGlobalObject.h"
38#include "JSDOMOperation.h"
39#include "JSDOMOperationReturningPromise.h"
40#include "JSDOMWrapperCache.h"
41#include "JSDoubleRange.h"
42#include "JSEventListener.h"
43#include "JSLongRange.h"
44#include "JSMediaStreamTrack.h"
45#include "JSMediaTrackConstraints.h"
46#include "ScriptExecutionContext.h"
47#include <JavaScriptCore/HeapSnapshotBuilder.h>
48#include <JavaScriptCore/JSArray.h>
49#include <JavaScriptCore/JSCInlines.h>
50#include <JavaScriptCore/JSString.h>
51#include <JavaScriptCore/ObjectConstructor.h>
52#include <wtf/GetPtr.h>
53#include <wtf/PointerPreparations.h>
54#include <wtf/URL.h>
55
56
57namespace WebCore {
58using namespace JSC;
59
60String convertEnumerationToString(MediaStreamTrack::State enumerationValue)
61{
62 static const NeverDestroyed<String> values[] = {
63 MAKE_STATIC_STRING_IMPL("live"),
64 MAKE_STATIC_STRING_IMPL("ended"),
65 };
66 static_assert(static_cast<size_t>(MediaStreamTrack::State::Live) == 0, "MediaStreamTrack::State::Live is not 0 as expected");
67 static_assert(static_cast<size_t>(MediaStreamTrack::State::Ended) == 1, "MediaStreamTrack::State::Ended is not 1 as expected");
68 ASSERT(static_cast<size_t>(enumerationValue) < WTF_ARRAY_LENGTH(values));
69 return values[static_cast<size_t>(enumerationValue)];
70}
71
72template<> JSString* convertEnumerationToJS(ExecState& state, MediaStreamTrack::State enumerationValue)
73{
74 return jsStringWithCache(&state, convertEnumerationToString(enumerationValue));
75}
76
77template<> Optional<MediaStreamTrack::State> parseEnumeration<MediaStreamTrack::State>(ExecState& state, JSValue value)
78{
79 auto stringValue = value.toWTFString(&state);
80 if (stringValue == "live")
81 return MediaStreamTrack::State::Live;
82 if (stringValue == "ended")
83 return MediaStreamTrack::State::Ended;
84 return WTF::nullopt;
85}
86
87template<> const char* expectedEnumerationValues<MediaStreamTrack::State>()
88{
89 return "\"live\", \"ended\"";
90}
91
92#if ENABLE(MEDIA_STREAM)
93
94template<> MediaStreamTrack::TrackCapabilities convertDictionary<MediaStreamTrack::TrackCapabilities>(ExecState& state, JSValue value)
95{
96 VM& vm = state.vm();
97 auto throwScope = DECLARE_THROW_SCOPE(vm);
98 bool isNullOrUndefined = value.isUndefinedOrNull();
99 auto* object = isNullOrUndefined ? nullptr : value.getObject();
100 if (UNLIKELY(!isNullOrUndefined && !object)) {
101 throwTypeError(&state, throwScope);
102 return { };
103 }
104 MediaStreamTrack::TrackCapabilities result;
105 JSValue aspectRatioValue;
106 if (isNullOrUndefined)
107 aspectRatioValue = jsUndefined();
108 else {
109 aspectRatioValue = object->get(&state, Identifier::fromString(&state, "aspectRatio"));
110 RETURN_IF_EXCEPTION(throwScope, { });
111 }
112 if (!aspectRatioValue.isUndefined()) {
113 result.aspectRatio = convert<IDLDictionary<DoubleRange>>(state, aspectRatioValue);
114 RETURN_IF_EXCEPTION(throwScope, { });
115 }
116 JSValue deviceIdValue;
117 if (isNullOrUndefined)
118 deviceIdValue = jsUndefined();
119 else {
120 deviceIdValue = object->get(&state, Identifier::fromString(&state, "deviceId"));
121 RETURN_IF_EXCEPTION(throwScope, { });
122 }
123 if (!deviceIdValue.isUndefined()) {
124 result.deviceId = convert<IDLDOMString>(state, deviceIdValue);
125 RETURN_IF_EXCEPTION(throwScope, { });
126 }
127 JSValue echoCancellationValue;
128 if (isNullOrUndefined)
129 echoCancellationValue = jsUndefined();
130 else {
131 echoCancellationValue = object->get(&state, Identifier::fromString(&state, "echoCancellation"));
132 RETURN_IF_EXCEPTION(throwScope, { });
133 }
134 if (!echoCancellationValue.isUndefined()) {
135 result.echoCancellation = convert<IDLSequence<IDLBoolean>>(state, echoCancellationValue);
136 RETURN_IF_EXCEPTION(throwScope, { });
137 }
138 JSValue facingModeValue;
139 if (isNullOrUndefined)
140 facingModeValue = jsUndefined();
141 else {
142 facingModeValue = object->get(&state, Identifier::fromString(&state, "facingMode"));
143 RETURN_IF_EXCEPTION(throwScope, { });
144 }
145 if (!facingModeValue.isUndefined()) {
146 result.facingMode = convert<IDLSequence<IDLDOMString>>(state, facingModeValue);
147 RETURN_IF_EXCEPTION(throwScope, { });
148 }
149 JSValue frameRateValue;
150 if (isNullOrUndefined)
151 frameRateValue = jsUndefined();
152 else {
153 frameRateValue = object->get(&state, Identifier::fromString(&state, "frameRate"));
154 RETURN_IF_EXCEPTION(throwScope, { });
155 }
156 if (!frameRateValue.isUndefined()) {
157 result.frameRate = convert<IDLDictionary<DoubleRange>>(state, frameRateValue);
158 RETURN_IF_EXCEPTION(throwScope, { });
159 }
160 JSValue groupIdValue;
161 if (isNullOrUndefined)
162 groupIdValue = jsUndefined();
163 else {
164 groupIdValue = object->get(&state, Identifier::fromString(&state, "groupId"));
165 RETURN_IF_EXCEPTION(throwScope, { });
166 }
167 if (!groupIdValue.isUndefined()) {
168 result.groupId = convert<IDLDOMString>(state, groupIdValue);
169 RETURN_IF_EXCEPTION(throwScope, { });
170 }
171 JSValue heightValue;
172 if (isNullOrUndefined)
173 heightValue = jsUndefined();
174 else {
175 heightValue = object->get(&state, Identifier::fromString(&state, "height"));
176 RETURN_IF_EXCEPTION(throwScope, { });
177 }
178 if (!heightValue.isUndefined()) {
179 result.height = convert<IDLDictionary<LongRange>>(state, heightValue);
180 RETURN_IF_EXCEPTION(throwScope, { });
181 }
182 JSValue sampleRateValue;
183 if (isNullOrUndefined)
184 sampleRateValue = jsUndefined();
185 else {
186 sampleRateValue = object->get(&state, Identifier::fromString(&state, "sampleRate"));
187 RETURN_IF_EXCEPTION(throwScope, { });
188 }
189 if (!sampleRateValue.isUndefined()) {
190 result.sampleRate = convert<IDLDictionary<LongRange>>(state, sampleRateValue);
191 RETURN_IF_EXCEPTION(throwScope, { });
192 }
193 JSValue sampleSizeValue;
194 if (isNullOrUndefined)
195 sampleSizeValue = jsUndefined();
196 else {
197 sampleSizeValue = object->get(&state, Identifier::fromString(&state, "sampleSize"));
198 RETURN_IF_EXCEPTION(throwScope, { });
199 }
200 if (!sampleSizeValue.isUndefined()) {
201 result.sampleSize = convert<IDLDictionary<LongRange>>(state, sampleSizeValue);
202 RETURN_IF_EXCEPTION(throwScope, { });
203 }
204 JSValue volumeValue;
205 if (isNullOrUndefined)
206 volumeValue = jsUndefined();
207 else {
208 volumeValue = object->get(&state, Identifier::fromString(&state, "volume"));
209 RETURN_IF_EXCEPTION(throwScope, { });
210 }
211 if (!volumeValue.isUndefined()) {
212 result.volume = convert<IDLDictionary<DoubleRange>>(state, volumeValue);
213 RETURN_IF_EXCEPTION(throwScope, { });
214 }
215 JSValue widthValue;
216 if (isNullOrUndefined)
217 widthValue = jsUndefined();
218 else {
219 widthValue = object->get(&state, Identifier::fromString(&state, "width"));
220 RETURN_IF_EXCEPTION(throwScope, { });
221 }
222 if (!widthValue.isUndefined()) {
223 result.width = convert<IDLDictionary<LongRange>>(state, widthValue);
224 RETURN_IF_EXCEPTION(throwScope, { });
225 }
226 return result;
227}
228
229JSC::JSObject* convertDictionaryToJS(JSC::ExecState& state, JSDOMGlobalObject& globalObject, const MediaStreamTrack::TrackCapabilities& dictionary)
230{
231 auto& vm = state.vm();
232
233 auto result = constructEmptyObject(&state, globalObject.objectPrototype());
234
235 if (!IDLDictionary<DoubleRange>::isNullValue(dictionary.aspectRatio)) {
236 auto aspectRatioValue = toJS<IDLDictionary<DoubleRange>>(state, globalObject, IDLDictionary<DoubleRange>::extractValueFromNullable(dictionary.aspectRatio));
237 result->putDirect(vm, JSC::Identifier::fromString(&vm, "aspectRatio"), aspectRatioValue);
238 }
239 if (!IDLDOMString::isNullValue(dictionary.deviceId)) {
240 auto deviceIdValue = toJS<IDLDOMString>(state, IDLDOMString::extractValueFromNullable(dictionary.deviceId));
241 result->putDirect(vm, JSC::Identifier::fromString(&vm, "deviceId"), deviceIdValue);
242 }
243 if (!IDLSequence<IDLBoolean>::isNullValue(dictionary.echoCancellation)) {
244 auto echoCancellationValue = toJS<IDLSequence<IDLBoolean>>(state, globalObject, IDLSequence<IDLBoolean>::extractValueFromNullable(dictionary.echoCancellation));
245 result->putDirect(vm, JSC::Identifier::fromString(&vm, "echoCancellation"), echoCancellationValue);
246 }
247 if (!IDLSequence<IDLDOMString>::isNullValue(dictionary.facingMode)) {
248 auto facingModeValue = toJS<IDLSequence<IDLDOMString>>(state, globalObject, IDLSequence<IDLDOMString>::extractValueFromNullable(dictionary.facingMode));
249 result->putDirect(vm, JSC::Identifier::fromString(&vm, "facingMode"), facingModeValue);
250 }
251 if (!IDLDictionary<DoubleRange>::isNullValue(dictionary.frameRate)) {
252 auto frameRateValue = toJS<IDLDictionary<DoubleRange>>(state, globalObject, IDLDictionary<DoubleRange>::extractValueFromNullable(dictionary.frameRate));
253 result->putDirect(vm, JSC::Identifier::fromString(&vm, "frameRate"), frameRateValue);
254 }
255 if (!IDLDOMString::isNullValue(dictionary.groupId)) {
256 auto groupIdValue = toJS<IDLDOMString>(state, IDLDOMString::extractValueFromNullable(dictionary.groupId));
257 result->putDirect(vm, JSC::Identifier::fromString(&vm, "groupId"), groupIdValue);
258 }
259 if (!IDLDictionary<LongRange>::isNullValue(dictionary.height)) {
260 auto heightValue = toJS<IDLDictionary<LongRange>>(state, globalObject, IDLDictionary<LongRange>::extractValueFromNullable(dictionary.height));
261 result->putDirect(vm, JSC::Identifier::fromString(&vm, "height"), heightValue);
262 }
263 if (!IDLDictionary<LongRange>::isNullValue(dictionary.sampleRate)) {
264 auto sampleRateValue = toJS<IDLDictionary<LongRange>>(state, globalObject, IDLDictionary<LongRange>::extractValueFromNullable(dictionary.sampleRate));
265 result->putDirect(vm, JSC::Identifier::fromString(&vm, "sampleRate"), sampleRateValue);
266 }
267 if (!IDLDictionary<LongRange>::isNullValue(dictionary.sampleSize)) {
268 auto sampleSizeValue = toJS<IDLDictionary<LongRange>>(state, globalObject, IDLDictionary<LongRange>::extractValueFromNullable(dictionary.sampleSize));
269 result->putDirect(vm, JSC::Identifier::fromString(&vm, "sampleSize"), sampleSizeValue);
270 }
271 if (!IDLDictionary<DoubleRange>::isNullValue(dictionary.volume)) {
272 auto volumeValue = toJS<IDLDictionary<DoubleRange>>(state, globalObject, IDLDictionary<DoubleRange>::extractValueFromNullable(dictionary.volume));
273 result->putDirect(vm, JSC::Identifier::fromString(&vm, "volume"), volumeValue);
274 }
275 if (!IDLDictionary<LongRange>::isNullValue(dictionary.width)) {
276 auto widthValue = toJS<IDLDictionary<LongRange>>(state, globalObject, IDLDictionary<LongRange>::extractValueFromNullable(dictionary.width));
277 result->putDirect(vm, JSC::Identifier::fromString(&vm, "width"), widthValue);
278 }
279 return result;
280}
281
282#endif
283
284#if ENABLE(MEDIA_STREAM)
285
286template<> MediaStreamTrack::TrackSettings convertDictionary<MediaStreamTrack::TrackSettings>(ExecState& state, JSValue value)
287{
288 VM& vm = state.vm();
289 auto throwScope = DECLARE_THROW_SCOPE(vm);
290 bool isNullOrUndefined = value.isUndefinedOrNull();
291 auto* object = isNullOrUndefined ? nullptr : value.getObject();
292 if (UNLIKELY(!isNullOrUndefined && !object)) {
293 throwTypeError(&state, throwScope);
294 return { };
295 }
296 MediaStreamTrack::TrackSettings result;
297 JSValue aspectRatioValue;
298 if (isNullOrUndefined)
299 aspectRatioValue = jsUndefined();
300 else {
301 aspectRatioValue = object->get(&state, Identifier::fromString(&state, "aspectRatio"));
302 RETURN_IF_EXCEPTION(throwScope, { });
303 }
304 if (!aspectRatioValue.isUndefined()) {
305 result.aspectRatio = convert<IDLDouble>(state, aspectRatioValue);
306 RETURN_IF_EXCEPTION(throwScope, { });
307 }
308 JSValue deviceIdValue;
309 if (isNullOrUndefined)
310 deviceIdValue = jsUndefined();
311 else {
312 deviceIdValue = object->get(&state, Identifier::fromString(&state, "deviceId"));
313 RETURN_IF_EXCEPTION(throwScope, { });
314 }
315 if (!deviceIdValue.isUndefined()) {
316 result.deviceId = convert<IDLDOMString>(state, deviceIdValue);
317 RETURN_IF_EXCEPTION(throwScope, { });
318 }
319 JSValue echoCancellationValue;
320 if (isNullOrUndefined)
321 echoCancellationValue = jsUndefined();
322 else {
323 echoCancellationValue = object->get(&state, Identifier::fromString(&state, "echoCancellation"));
324 RETURN_IF_EXCEPTION(throwScope, { });
325 }
326 if (!echoCancellationValue.isUndefined()) {
327 result.echoCancellation = convert<IDLBoolean>(state, echoCancellationValue);
328 RETURN_IF_EXCEPTION(throwScope, { });
329 }
330 JSValue facingModeValue;
331 if (isNullOrUndefined)
332 facingModeValue = jsUndefined();
333 else {
334 facingModeValue = object->get(&state, Identifier::fromString(&state, "facingMode"));
335 RETURN_IF_EXCEPTION(throwScope, { });
336 }
337 if (!facingModeValue.isUndefined()) {
338 result.facingMode = convert<IDLDOMString>(state, facingModeValue);
339 RETURN_IF_EXCEPTION(throwScope, { });
340 }
341 JSValue frameRateValue;
342 if (isNullOrUndefined)
343 frameRateValue = jsUndefined();
344 else {
345 frameRateValue = object->get(&state, Identifier::fromString(&state, "frameRate"));
346 RETURN_IF_EXCEPTION(throwScope, { });
347 }
348 if (!frameRateValue.isUndefined()) {
349 result.frameRate = convert<IDLDouble>(state, frameRateValue);
350 RETURN_IF_EXCEPTION(throwScope, { });
351 }
352 JSValue groupIdValue;
353 if (isNullOrUndefined)
354 groupIdValue = jsUndefined();
355 else {
356 groupIdValue = object->get(&state, Identifier::fromString(&state, "groupId"));
357 RETURN_IF_EXCEPTION(throwScope, { });
358 }
359 if (!groupIdValue.isUndefined()) {
360 result.groupId = convert<IDLDOMString>(state, groupIdValue);
361 RETURN_IF_EXCEPTION(throwScope, { });
362 }
363 JSValue heightValue;
364 if (isNullOrUndefined)
365 heightValue = jsUndefined();
366 else {
367 heightValue = object->get(&state, Identifier::fromString(&state, "height"));
368 RETURN_IF_EXCEPTION(throwScope, { });
369 }
370 if (!heightValue.isUndefined()) {
371 result.height = convert<IDLLong>(state, heightValue);
372 RETURN_IF_EXCEPTION(throwScope, { });
373 }
374 JSValue sampleRateValue;
375 if (isNullOrUndefined)
376 sampleRateValue = jsUndefined();
377 else {
378 sampleRateValue = object->get(&state, Identifier::fromString(&state, "sampleRate"));
379 RETURN_IF_EXCEPTION(throwScope, { });
380 }
381 if (!sampleRateValue.isUndefined()) {
382 result.sampleRate = convert<IDLLong>(state, sampleRateValue);
383 RETURN_IF_EXCEPTION(throwScope, { });
384 }
385 JSValue sampleSizeValue;
386 if (isNullOrUndefined)
387 sampleSizeValue = jsUndefined();
388 else {
389 sampleSizeValue = object->get(&state, Identifier::fromString(&state, "sampleSize"));
390 RETURN_IF_EXCEPTION(throwScope, { });
391 }
392 if (!sampleSizeValue.isUndefined()) {
393 result.sampleSize = convert<IDLLong>(state, sampleSizeValue);
394 RETURN_IF_EXCEPTION(throwScope, { });
395 }
396 JSValue volumeValue;
397 if (isNullOrUndefined)
398 volumeValue = jsUndefined();
399 else {
400 volumeValue = object->get(&state, Identifier::fromString(&state, "volume"));
401 RETURN_IF_EXCEPTION(throwScope, { });
402 }
403 if (!volumeValue.isUndefined()) {
404 result.volume = convert<IDLDouble>(state, volumeValue);
405 RETURN_IF_EXCEPTION(throwScope, { });
406 }
407 JSValue widthValue;
408 if (isNullOrUndefined)
409 widthValue = jsUndefined();
410 else {
411 widthValue = object->get(&state, Identifier::fromString(&state, "width"));
412 RETURN_IF_EXCEPTION(throwScope, { });
413 }
414 if (!widthValue.isUndefined()) {
415 result.width = convert<IDLLong>(state, widthValue);
416 RETURN_IF_EXCEPTION(throwScope, { });
417 }
418 return result;
419}
420
421JSC::JSObject* convertDictionaryToJS(JSC::ExecState& state, JSDOMGlobalObject& globalObject, const MediaStreamTrack::TrackSettings& dictionary)
422{
423 auto& vm = state.vm();
424
425 auto result = constructEmptyObject(&state, globalObject.objectPrototype());
426
427 if (!IDLDouble::isNullValue(dictionary.aspectRatio)) {
428 auto aspectRatioValue = toJS<IDLDouble>(IDLDouble::extractValueFromNullable(dictionary.aspectRatio));
429 result->putDirect(vm, JSC::Identifier::fromString(&vm, "aspectRatio"), aspectRatioValue);
430 }
431 if (!IDLDOMString::isNullValue(dictionary.deviceId)) {
432 auto deviceIdValue = toJS<IDLDOMString>(state, IDLDOMString::extractValueFromNullable(dictionary.deviceId));
433 result->putDirect(vm, JSC::Identifier::fromString(&vm, "deviceId"), deviceIdValue);
434 }
435 if (!IDLBoolean::isNullValue(dictionary.echoCancellation)) {
436 auto echoCancellationValue = toJS<IDLBoolean>(IDLBoolean::extractValueFromNullable(dictionary.echoCancellation));
437 result->putDirect(vm, JSC::Identifier::fromString(&vm, "echoCancellation"), echoCancellationValue);
438 }
439 if (!IDLDOMString::isNullValue(dictionary.facingMode)) {
440 auto facingModeValue = toJS<IDLDOMString>(state, IDLDOMString::extractValueFromNullable(dictionary.facingMode));
441 result->putDirect(vm, JSC::Identifier::fromString(&vm, "facingMode"), facingModeValue);
442 }
443 if (!IDLDouble::isNullValue(dictionary.frameRate)) {
444 auto frameRateValue = toJS<IDLDouble>(IDLDouble::extractValueFromNullable(dictionary.frameRate));
445 result->putDirect(vm, JSC::Identifier::fromString(&vm, "frameRate"), frameRateValue);
446 }
447 if (!IDLDOMString::isNullValue(dictionary.groupId)) {
448 auto groupIdValue = toJS<IDLDOMString>(state, IDLDOMString::extractValueFromNullable(dictionary.groupId));
449 result->putDirect(vm, JSC::Identifier::fromString(&vm, "groupId"), groupIdValue);
450 }
451 if (!IDLLong::isNullValue(dictionary.height)) {
452 auto heightValue = toJS<IDLLong>(IDLLong::extractValueFromNullable(dictionary.height));
453 result->putDirect(vm, JSC::Identifier::fromString(&vm, "height"), heightValue);
454 }
455 if (!IDLLong::isNullValue(dictionary.sampleRate)) {
456 auto sampleRateValue = toJS<IDLLong>(IDLLong::extractValueFromNullable(dictionary.sampleRate));
457 result->putDirect(vm, JSC::Identifier::fromString(&vm, "sampleRate"), sampleRateValue);
458 }
459 if (!IDLLong::isNullValue(dictionary.sampleSize)) {
460 auto sampleSizeValue = toJS<IDLLong>(IDLLong::extractValueFromNullable(dictionary.sampleSize));
461 result->putDirect(vm, JSC::Identifier::fromString(&vm, "sampleSize"), sampleSizeValue);
462 }
463 if (!IDLDouble::isNullValue(dictionary.volume)) {
464 auto volumeValue = toJS<IDLDouble>(IDLDouble::extractValueFromNullable(dictionary.volume));
465 result->putDirect(vm, JSC::Identifier::fromString(&vm, "volume"), volumeValue);
466 }
467 if (!IDLLong::isNullValue(dictionary.width)) {
468 auto widthValue = toJS<IDLLong>(IDLLong::extractValueFromNullable(dictionary.width));
469 result->putDirect(vm, JSC::Identifier::fromString(&vm, "width"), widthValue);
470 }
471 return result;
472}
473
474#endif
475
476// Functions
477
478JSC::EncodedJSValue JSC_HOST_CALL jsMediaStreamTrackPrototypeFunctionClone(JSC::ExecState*);
479JSC::EncodedJSValue JSC_HOST_CALL jsMediaStreamTrackPrototypeFunctionStop(JSC::ExecState*);
480JSC::EncodedJSValue JSC_HOST_CALL jsMediaStreamTrackPrototypeFunctionGetCapabilities(JSC::ExecState*);
481JSC::EncodedJSValue JSC_HOST_CALL jsMediaStreamTrackPrototypeFunctionGetConstraints(JSC::ExecState*);
482JSC::EncodedJSValue JSC_HOST_CALL jsMediaStreamTrackPrototypeFunctionGetSettings(JSC::ExecState*);
483JSC::EncodedJSValue JSC_HOST_CALL jsMediaStreamTrackPrototypeFunctionApplyConstraints(JSC::ExecState*);
484
485// Attributes
486
487JSC::EncodedJSValue jsMediaStreamTrackConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
488bool setJSMediaStreamTrackConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
489JSC::EncodedJSValue jsMediaStreamTrackKind(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
490JSC::EncodedJSValue jsMediaStreamTrackId(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
491JSC::EncodedJSValue jsMediaStreamTrackLabel(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
492JSC::EncodedJSValue jsMediaStreamTrackEnabled(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
493bool setJSMediaStreamTrackEnabled(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
494JSC::EncodedJSValue jsMediaStreamTrackContentHint(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
495bool setJSMediaStreamTrackContentHint(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
496JSC::EncodedJSValue jsMediaStreamTrackMuted(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
497JSC::EncodedJSValue jsMediaStreamTrackOnmute(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
498bool setJSMediaStreamTrackOnmute(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
499JSC::EncodedJSValue jsMediaStreamTrackOnunmute(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
500bool setJSMediaStreamTrackOnunmute(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
501JSC::EncodedJSValue jsMediaStreamTrackReadyState(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
502JSC::EncodedJSValue jsMediaStreamTrackOnended(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
503bool setJSMediaStreamTrackOnended(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
504JSC::EncodedJSValue jsMediaStreamTrackOnoverconstrained(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
505bool setJSMediaStreamTrackOnoverconstrained(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
506
507class JSMediaStreamTrackPrototype : public JSC::JSNonFinalObject {
508public:
509 using Base = JSC::JSNonFinalObject;
510 static JSMediaStreamTrackPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure)
511 {
512 JSMediaStreamTrackPrototype* ptr = new (NotNull, JSC::allocateCell<JSMediaStreamTrackPrototype>(vm.heap)) JSMediaStreamTrackPrototype(vm, globalObject, structure);
513 ptr->finishCreation(vm);
514 return ptr;
515 }
516
517 DECLARE_INFO;
518 static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
519 {
520 return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
521 }
522
523private:
524 JSMediaStreamTrackPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
525 : JSC::JSNonFinalObject(vm, structure)
526 {
527 }
528
529 void finishCreation(JSC::VM&);
530};
531
532using JSMediaStreamTrackConstructor = JSDOMConstructorNotConstructable<JSMediaStreamTrack>;
533
534template<> JSValue JSMediaStreamTrackConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
535{
536 return JSEventTarget::getConstructor(vm, &globalObject);
537}
538
539template<> void JSMediaStreamTrackConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
540{
541 putDirect(vm, vm.propertyNames->prototype, JSMediaStreamTrack::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
542 putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("MediaStreamTrack"_s)), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
543 putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
544}
545
546template<> const ClassInfo JSMediaStreamTrackConstructor::s_info = { "MediaStreamTrack", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSMediaStreamTrackConstructor) };
547
548/* Hash table for prototype */
549
550static const HashTableValue JSMediaStreamTrackPrototypeTableValues[] =
551{
552 { "constructor", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMediaStreamTrackConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSMediaStreamTrackConstructor) } },
553 { "kind", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMediaStreamTrackKind), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
554 { "id", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMediaStreamTrackId), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
555 { "label", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMediaStreamTrackLabel), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
556 { "enabled", static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMediaStreamTrackEnabled), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSMediaStreamTrackEnabled) } },
557 { "contentHint", static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMediaStreamTrackContentHint), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSMediaStreamTrackContentHint) } },
558 { "muted", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMediaStreamTrackMuted), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
559 { "onmute", static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMediaStreamTrackOnmute), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSMediaStreamTrackOnmute) } },
560 { "onunmute", static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMediaStreamTrackOnunmute), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSMediaStreamTrackOnunmute) } },
561 { "readyState", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMediaStreamTrackReadyState), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
562 { "onended", static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMediaStreamTrackOnended), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSMediaStreamTrackOnended) } },
563 { "onoverconstrained", static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMediaStreamTrackOnoverconstrained), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSMediaStreamTrackOnoverconstrained) } },
564 { "clone", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsMediaStreamTrackPrototypeFunctionClone), (intptr_t) (0) } },
565 { "stop", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsMediaStreamTrackPrototypeFunctionStop), (intptr_t) (0) } },
566 { "getCapabilities", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsMediaStreamTrackPrototypeFunctionGetCapabilities), (intptr_t) (0) } },
567 { "getConstraints", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsMediaStreamTrackPrototypeFunctionGetConstraints), (intptr_t) (0) } },
568 { "getSettings", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsMediaStreamTrackPrototypeFunctionGetSettings), (intptr_t) (0) } },
569 { "applyConstraints", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsMediaStreamTrackPrototypeFunctionApplyConstraints), (intptr_t) (0) } },
570};
571
572const ClassInfo JSMediaStreamTrackPrototype::s_info = { "MediaStreamTrackPrototype", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSMediaStreamTrackPrototype) };
573
574void JSMediaStreamTrackPrototype::finishCreation(VM& vm)
575{
576 Base::finishCreation(vm);
577 reifyStaticProperties(vm, JSMediaStreamTrack::info(), JSMediaStreamTrackPrototypeTableValues, *this);
578}
579
580const ClassInfo JSMediaStreamTrack::s_info = { "MediaStreamTrack", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSMediaStreamTrack) };
581
582JSMediaStreamTrack::JSMediaStreamTrack(Structure* structure, JSDOMGlobalObject& globalObject, Ref<MediaStreamTrack>&& impl)
583 : JSEventTarget(structure, globalObject, WTFMove(impl))
584{
585}
586
587void JSMediaStreamTrack::finishCreation(VM& vm)
588{
589 Base::finishCreation(vm);
590 ASSERT(inherits(vm, info()));
591
592}
593
594JSObject* JSMediaStreamTrack::createPrototype(VM& vm, JSDOMGlobalObject& globalObject)
595{
596 return JSMediaStreamTrackPrototype::create(vm, &globalObject, JSMediaStreamTrackPrototype::createStructure(vm, &globalObject, JSEventTarget::prototype(vm, globalObject)));
597}
598
599JSObject* JSMediaStreamTrack::prototype(VM& vm, JSDOMGlobalObject& globalObject)
600{
601 return getDOMPrototype<JSMediaStreamTrack>(vm, globalObject);
602}
603
604JSValue JSMediaStreamTrack::getConstructor(VM& vm, const JSGlobalObject* globalObject)
605{
606 return getDOMConstructor<JSMediaStreamTrackConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
607}
608
609template<> inline JSMediaStreamTrack* IDLAttribute<JSMediaStreamTrack>::cast(ExecState& state, EncodedJSValue thisValue)
610{
611 return jsDynamicCast<JSMediaStreamTrack*>(state.vm(), JSValue::decode(thisValue));
612}
613
614template<> inline JSMediaStreamTrack* IDLOperation<JSMediaStreamTrack>::cast(ExecState& state)
615{
616 return jsDynamicCast<JSMediaStreamTrack*>(state.vm(), state.thisValue());
617}
618
619EncodedJSValue jsMediaStreamTrackConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName)
620{
621 VM& vm = state->vm();
622 auto throwScope = DECLARE_THROW_SCOPE(vm);
623 auto* prototype = jsDynamicCast<JSMediaStreamTrackPrototype*>(vm, JSValue::decode(thisValue));
624 if (UNLIKELY(!prototype))
625 return throwVMTypeError(state, throwScope);
626 return JSValue::encode(JSMediaStreamTrack::getConstructor(state->vm(), prototype->globalObject()));
627}
628
629bool setJSMediaStreamTrackConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
630{
631 VM& vm = state->vm();
632 auto throwScope = DECLARE_THROW_SCOPE(vm);
633 auto* prototype = jsDynamicCast<JSMediaStreamTrackPrototype*>(vm, JSValue::decode(thisValue));
634 if (UNLIKELY(!prototype)) {
635 throwVMTypeError(state, throwScope);
636 return false;
637 }
638 // Shadowing a built-in constructor
639 return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue));
640}
641
642static inline JSValue jsMediaStreamTrackKindGetter(ExecState& state, JSMediaStreamTrack& thisObject, ThrowScope& throwScope)
643{
644 UNUSED_PARAM(throwScope);
645 UNUSED_PARAM(state);
646 auto& impl = thisObject.wrapped();
647 JSValue result = toJS<IDLDOMString>(state, throwScope, impl.kind());
648 return result;
649}
650
651EncodedJSValue jsMediaStreamTrackKind(ExecState* state, EncodedJSValue thisValue, PropertyName)
652{
653 return IDLAttribute<JSMediaStreamTrack>::get<jsMediaStreamTrackKindGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "kind");
654}
655
656static inline JSValue jsMediaStreamTrackIdGetter(ExecState& state, JSMediaStreamTrack& thisObject, ThrowScope& throwScope)
657{
658 UNUSED_PARAM(throwScope);
659 UNUSED_PARAM(state);
660 auto& impl = thisObject.wrapped();
661 JSValue result = toJS<IDLDOMString>(state, throwScope, impl.id());
662 return result;
663}
664
665EncodedJSValue jsMediaStreamTrackId(ExecState* state, EncodedJSValue thisValue, PropertyName)
666{
667 return IDLAttribute<JSMediaStreamTrack>::get<jsMediaStreamTrackIdGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "id");
668}
669
670static inline JSValue jsMediaStreamTrackLabelGetter(ExecState& state, JSMediaStreamTrack& thisObject, ThrowScope& throwScope)
671{
672 UNUSED_PARAM(throwScope);
673 UNUSED_PARAM(state);
674 auto& impl = thisObject.wrapped();
675 JSValue result = toJS<IDLDOMString>(state, throwScope, impl.label());
676 return result;
677}
678
679EncodedJSValue jsMediaStreamTrackLabel(ExecState* state, EncodedJSValue thisValue, PropertyName)
680{
681 return IDLAttribute<JSMediaStreamTrack>::get<jsMediaStreamTrackLabelGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "label");
682}
683
684static inline JSValue jsMediaStreamTrackEnabledGetter(ExecState& state, JSMediaStreamTrack& thisObject, ThrowScope& throwScope)
685{
686 UNUSED_PARAM(throwScope);
687 UNUSED_PARAM(state);
688 auto& impl = thisObject.wrapped();
689 JSValue result = toJS<IDLBoolean>(state, throwScope, impl.enabled());
690 return result;
691}
692
693EncodedJSValue jsMediaStreamTrackEnabled(ExecState* state, EncodedJSValue thisValue, PropertyName)
694{
695 return IDLAttribute<JSMediaStreamTrack>::get<jsMediaStreamTrackEnabledGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "enabled");
696}
697
698static inline bool setJSMediaStreamTrackEnabledSetter(ExecState& state, JSMediaStreamTrack& thisObject, JSValue value, ThrowScope& throwScope)
699{
700 UNUSED_PARAM(throwScope);
701 auto& impl = thisObject.wrapped();
702 auto nativeValue = convert<IDLBoolean>(state, value);
703 RETURN_IF_EXCEPTION(throwScope, false);
704 AttributeSetter::call(state, throwScope, [&] {
705 return impl.setEnabled(WTFMove(nativeValue));
706 });
707 return true;
708}
709
710bool setJSMediaStreamTrackEnabled(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
711{
712 return IDLAttribute<JSMediaStreamTrack>::set<setJSMediaStreamTrackEnabledSetter>(*state, thisValue, encodedValue, "enabled");
713}
714
715static inline JSValue jsMediaStreamTrackContentHintGetter(ExecState& state, JSMediaStreamTrack& thisObject, ThrowScope& throwScope)
716{
717 UNUSED_PARAM(throwScope);
718 UNUSED_PARAM(state);
719 auto& impl = thisObject.wrapped();
720 JSValue result = toJS<IDLDOMString>(state, throwScope, impl.contentHint());
721 return result;
722}
723
724EncodedJSValue jsMediaStreamTrackContentHint(ExecState* state, EncodedJSValue thisValue, PropertyName)
725{
726 return IDLAttribute<JSMediaStreamTrack>::get<jsMediaStreamTrackContentHintGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "contentHint");
727}
728
729static inline bool setJSMediaStreamTrackContentHintSetter(ExecState& state, JSMediaStreamTrack& thisObject, JSValue value, ThrowScope& throwScope)
730{
731 UNUSED_PARAM(throwScope);
732 auto& impl = thisObject.wrapped();
733 auto nativeValue = convert<IDLDOMString>(state, value);
734 RETURN_IF_EXCEPTION(throwScope, false);
735 AttributeSetter::call(state, throwScope, [&] {
736 return impl.setContentHint(WTFMove(nativeValue));
737 });
738 return true;
739}
740
741bool setJSMediaStreamTrackContentHint(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
742{
743 return IDLAttribute<JSMediaStreamTrack>::set<setJSMediaStreamTrackContentHintSetter>(*state, thisValue, encodedValue, "contentHint");
744}
745
746static inline JSValue jsMediaStreamTrackMutedGetter(ExecState& state, JSMediaStreamTrack& thisObject, ThrowScope& throwScope)
747{
748 UNUSED_PARAM(throwScope);
749 UNUSED_PARAM(state);
750 auto& impl = thisObject.wrapped();
751 JSValue result = toJS<IDLBoolean>(state, throwScope, impl.muted());
752 return result;
753}
754
755EncodedJSValue jsMediaStreamTrackMuted(ExecState* state, EncodedJSValue thisValue, PropertyName)
756{
757 return IDLAttribute<JSMediaStreamTrack>::get<jsMediaStreamTrackMutedGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "muted");
758}
759
760static inline JSValue jsMediaStreamTrackOnmuteGetter(ExecState& state, JSMediaStreamTrack& thisObject, ThrowScope& throwScope)
761{
762 UNUSED_PARAM(throwScope);
763 UNUSED_PARAM(state);
764 return eventHandlerAttribute(thisObject.wrapped(), eventNames().muteEvent, worldForDOMObject(thisObject));
765}
766
767EncodedJSValue jsMediaStreamTrackOnmute(ExecState* state, EncodedJSValue thisValue, PropertyName)
768{
769 return IDLAttribute<JSMediaStreamTrack>::get<jsMediaStreamTrackOnmuteGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "onmute");
770}
771
772static inline bool setJSMediaStreamTrackOnmuteSetter(ExecState& state, JSMediaStreamTrack& thisObject, JSValue value, ThrowScope& throwScope)
773{
774 UNUSED_PARAM(throwScope);
775 setEventHandlerAttribute(state, thisObject, thisObject.wrapped(), eventNames().muteEvent, value);
776 return true;
777}
778
779bool setJSMediaStreamTrackOnmute(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
780{
781 return IDLAttribute<JSMediaStreamTrack>::set<setJSMediaStreamTrackOnmuteSetter>(*state, thisValue, encodedValue, "onmute");
782}
783
784static inline JSValue jsMediaStreamTrackOnunmuteGetter(ExecState& state, JSMediaStreamTrack& thisObject, ThrowScope& throwScope)
785{
786 UNUSED_PARAM(throwScope);
787 UNUSED_PARAM(state);
788 return eventHandlerAttribute(thisObject.wrapped(), eventNames().unmuteEvent, worldForDOMObject(thisObject));
789}
790
791EncodedJSValue jsMediaStreamTrackOnunmute(ExecState* state, EncodedJSValue thisValue, PropertyName)
792{
793 return IDLAttribute<JSMediaStreamTrack>::get<jsMediaStreamTrackOnunmuteGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "onunmute");
794}
795
796static inline bool setJSMediaStreamTrackOnunmuteSetter(ExecState& state, JSMediaStreamTrack& thisObject, JSValue value, ThrowScope& throwScope)
797{
798 UNUSED_PARAM(throwScope);
799 setEventHandlerAttribute(state, thisObject, thisObject.wrapped(), eventNames().unmuteEvent, value);
800 return true;
801}
802
803bool setJSMediaStreamTrackOnunmute(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
804{
805 return IDLAttribute<JSMediaStreamTrack>::set<setJSMediaStreamTrackOnunmuteSetter>(*state, thisValue, encodedValue, "onunmute");
806}
807
808static inline JSValue jsMediaStreamTrackReadyStateGetter(ExecState& state, JSMediaStreamTrack& thisObject, ThrowScope& throwScope)
809{
810 UNUSED_PARAM(throwScope);
811 UNUSED_PARAM(state);
812 auto& impl = thisObject.wrapped();
813 JSValue result = toJS<IDLEnumeration<MediaStreamTrack::State>>(state, throwScope, impl.readyState());
814 return result;
815}
816
817EncodedJSValue jsMediaStreamTrackReadyState(ExecState* state, EncodedJSValue thisValue, PropertyName)
818{
819 return IDLAttribute<JSMediaStreamTrack>::get<jsMediaStreamTrackReadyStateGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "readyState");
820}
821
822static inline JSValue jsMediaStreamTrackOnendedGetter(ExecState& state, JSMediaStreamTrack& thisObject, ThrowScope& throwScope)
823{
824 UNUSED_PARAM(throwScope);
825 UNUSED_PARAM(state);
826 return eventHandlerAttribute(thisObject.wrapped(), eventNames().endedEvent, worldForDOMObject(thisObject));
827}
828
829EncodedJSValue jsMediaStreamTrackOnended(ExecState* state, EncodedJSValue thisValue, PropertyName)
830{
831 return IDLAttribute<JSMediaStreamTrack>::get<jsMediaStreamTrackOnendedGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "onended");
832}
833
834static inline bool setJSMediaStreamTrackOnendedSetter(ExecState& state, JSMediaStreamTrack& thisObject, JSValue value, ThrowScope& throwScope)
835{
836 UNUSED_PARAM(throwScope);
837 setEventHandlerAttribute(state, thisObject, thisObject.wrapped(), eventNames().endedEvent, value);
838 return true;
839}
840
841bool setJSMediaStreamTrackOnended(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
842{
843 return IDLAttribute<JSMediaStreamTrack>::set<setJSMediaStreamTrackOnendedSetter>(*state, thisValue, encodedValue, "onended");
844}
845
846static inline JSValue jsMediaStreamTrackOnoverconstrainedGetter(ExecState& state, JSMediaStreamTrack& thisObject, ThrowScope& throwScope)
847{
848 UNUSED_PARAM(throwScope);
849 UNUSED_PARAM(state);
850 return eventHandlerAttribute(thisObject.wrapped(), eventNames().overconstrainedEvent, worldForDOMObject(thisObject));
851}
852
853EncodedJSValue jsMediaStreamTrackOnoverconstrained(ExecState* state, EncodedJSValue thisValue, PropertyName)
854{
855 return IDLAttribute<JSMediaStreamTrack>::get<jsMediaStreamTrackOnoverconstrainedGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "onoverconstrained");
856}
857
858static inline bool setJSMediaStreamTrackOnoverconstrainedSetter(ExecState& state, JSMediaStreamTrack& thisObject, JSValue value, ThrowScope& throwScope)
859{
860 UNUSED_PARAM(throwScope);
861 setEventHandlerAttribute(state, thisObject, thisObject.wrapped(), eventNames().overconstrainedEvent, value);
862 return true;
863}
864
865bool setJSMediaStreamTrackOnoverconstrained(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
866{
867 return IDLAttribute<JSMediaStreamTrack>::set<setJSMediaStreamTrackOnoverconstrainedSetter>(*state, thisValue, encodedValue, "onoverconstrained");
868}
869
870static inline JSC::EncodedJSValue jsMediaStreamTrackPrototypeFunctionCloneBody(JSC::ExecState* state, typename IDLOperation<JSMediaStreamTrack>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
871{
872 UNUSED_PARAM(state);
873 UNUSED_PARAM(throwScope);
874 auto& impl = castedThis->wrapped();
875 return JSValue::encode(toJS<IDLInterface<MediaStreamTrack>>(*state, *castedThis->globalObject(), impl.clone()));
876}
877
878EncodedJSValue JSC_HOST_CALL jsMediaStreamTrackPrototypeFunctionClone(ExecState* state)
879{
880 return IDLOperation<JSMediaStreamTrack>::call<jsMediaStreamTrackPrototypeFunctionCloneBody>(*state, "clone");
881}
882
883static inline JSC::EncodedJSValue jsMediaStreamTrackPrototypeFunctionStopBody(JSC::ExecState* state, typename IDLOperation<JSMediaStreamTrack>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
884{
885 UNUSED_PARAM(state);
886 UNUSED_PARAM(throwScope);
887 auto& impl = castedThis->wrapped();
888 impl.stopTrack();
889 return JSValue::encode(jsUndefined());
890}
891
892EncodedJSValue JSC_HOST_CALL jsMediaStreamTrackPrototypeFunctionStop(ExecState* state)
893{
894 return IDLOperation<JSMediaStreamTrack>::call<jsMediaStreamTrackPrototypeFunctionStopBody>(*state, "stop");
895}
896
897static inline JSC::EncodedJSValue jsMediaStreamTrackPrototypeFunctionGetCapabilitiesBody(JSC::ExecState* state, typename IDLOperation<JSMediaStreamTrack>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
898{
899 UNUSED_PARAM(state);
900 UNUSED_PARAM(throwScope);
901 auto& impl = castedThis->wrapped();
902 return JSValue::encode(toJS<IDLDictionary<MediaStreamTrack::TrackCapabilities>>(*state, *castedThis->globalObject(), impl.getCapabilities()));
903}
904
905EncodedJSValue JSC_HOST_CALL jsMediaStreamTrackPrototypeFunctionGetCapabilities(ExecState* state)
906{
907 return IDLOperation<JSMediaStreamTrack>::call<jsMediaStreamTrackPrototypeFunctionGetCapabilitiesBody>(*state, "getCapabilities");
908}
909
910static inline JSC::EncodedJSValue jsMediaStreamTrackPrototypeFunctionGetConstraintsBody(JSC::ExecState* state, typename IDLOperation<JSMediaStreamTrack>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
911{
912 UNUSED_PARAM(state);
913 UNUSED_PARAM(throwScope);
914 auto& impl = castedThis->wrapped();
915 return JSValue::encode(toJS<IDLDictionary<MediaTrackConstraints>>(*state, *castedThis->globalObject(), impl.getConstraints()));
916}
917
918EncodedJSValue JSC_HOST_CALL jsMediaStreamTrackPrototypeFunctionGetConstraints(ExecState* state)
919{
920 return IDLOperation<JSMediaStreamTrack>::call<jsMediaStreamTrackPrototypeFunctionGetConstraintsBody>(*state, "getConstraints");
921}
922
923static inline JSC::EncodedJSValue jsMediaStreamTrackPrototypeFunctionGetSettingsBody(JSC::ExecState* state, typename IDLOperation<JSMediaStreamTrack>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
924{
925 UNUSED_PARAM(state);
926 UNUSED_PARAM(throwScope);
927 auto& impl = castedThis->wrapped();
928 return JSValue::encode(toJS<IDLDictionary<MediaStreamTrack::TrackSettings>>(*state, *castedThis->globalObject(), impl.getSettings()));
929}
930
931EncodedJSValue JSC_HOST_CALL jsMediaStreamTrackPrototypeFunctionGetSettings(ExecState* state)
932{
933 return IDLOperation<JSMediaStreamTrack>::call<jsMediaStreamTrackPrototypeFunctionGetSettingsBody>(*state, "getSettings");
934}
935
936static inline JSC::EncodedJSValue jsMediaStreamTrackPrototypeFunctionApplyConstraintsBody(JSC::ExecState* state, typename IDLOperationReturningPromise<JSMediaStreamTrack>::ClassParameter castedThis, Ref<DeferredPromise>&& promise, JSC::ThrowScope& throwScope)
937{
938 UNUSED_PARAM(state);
939 UNUSED_PARAM(throwScope);
940 auto& impl = castedThis->wrapped();
941 auto constraints = convert<IDLDictionary<MediaTrackConstraints>>(*state, state->argument(0));
942 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
943 impl.applyConstraints(WTFMove(constraints), WTFMove(promise));
944 return JSValue::encode(jsUndefined());
945}
946
947EncodedJSValue JSC_HOST_CALL jsMediaStreamTrackPrototypeFunctionApplyConstraints(ExecState* state)
948{
949 return IDLOperationReturningPromise<JSMediaStreamTrack>::call<jsMediaStreamTrackPrototypeFunctionApplyConstraintsBody, PromiseExecutionScope::WindowOnly>(*state, "applyConstraints");
950}
951
952void JSMediaStreamTrack::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder)
953{
954 auto* thisObject = jsCast<JSMediaStreamTrack*>(cell);
955 builder.setWrappedObjectForCell(cell, &thisObject->wrapped());
956 if (thisObject->scriptExecutionContext())
957 builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string());
958 Base::heapSnapshot(cell, builder);
959}
960
961bool JSMediaStreamTrackOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor, const char** reason)
962{
963 auto* jsMediaStreamTrack = jsCast<JSMediaStreamTrack*>(handle.slot()->asCell());
964 if (jsMediaStreamTrack->wrapped().hasPendingActivity()) {
965 if (UNLIKELY(reason))
966 *reason = "ActiveDOMObject with pending activity";
967 return true;
968 }
969 if (jsMediaStreamTrack->wrapped().isFiringEventListeners()) {
970 if (UNLIKELY(reason))
971 *reason = "EventTarget firing event listeners";
972 return true;
973 }
974 UNUSED_PARAM(visitor);
975 UNUSED_PARAM(reason);
976 return false;
977}
978
979void JSMediaStreamTrackOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
980{
981 auto* jsMediaStreamTrack = static_cast<JSMediaStreamTrack*>(handle.slot()->asCell());
982 auto& world = *static_cast<DOMWrapperWorld*>(context);
983 uncacheWrapper(world, &jsMediaStreamTrack->wrapped(), jsMediaStreamTrack);
984}
985
986MediaStreamTrack* JSMediaStreamTrack::toWrapped(JSC::VM& vm, JSC::JSValue value)
987{
988 if (auto* wrapper = jsDynamicCast<JSMediaStreamTrack*>(vm, value))
989 return &wrapper->wrapped();
990 return nullptr;
991}
992
993}
994
995#endif // ENABLE(MEDIA_STREAM)
996