Line data Source code
1 : /* THIS FILE IS AUTOGENERATED FROM RTCRtpSender.webidl BY Codegen.py - DO NOT EDIT */
2 :
3 : #ifndef mozilla_dom_RTCRtpSenderBinding_h
4 : #define mozilla_dom_RTCRtpSenderBinding_h
5 :
6 : #include "js/RootingAPI.h"
7 : #include "jspubtd.h"
8 : #include "mozilla/ErrorResult.h"
9 : #include "mozilla/dom/BindingDeclarations.h"
10 : #include "mozilla/dom/CallbackInterface.h"
11 : #include "mozilla/dom/Nullable.h"
12 : #include "mozilla/dom/ToJSValue.h"
13 : #include "nsWeakReference.h"
14 :
15 : namespace mozilla {
16 : namespace dom {
17 :
18 : class MediaStreamTrack;
19 : struct NativePropertyHooks;
20 : class Promise;
21 : class ProtoAndIfaceCache;
22 : class RTCDTMFSender;
23 : struct RTCFecParameters;
24 : struct RTCFecParametersAtoms;
25 : struct RTCRtcpParameters;
26 : struct RTCRtcpParametersAtoms;
27 : struct RTCRtpCodecParameters;
28 : struct RTCRtpCodecParametersAtoms;
29 : struct RTCRtpEncodingParameters;
30 : struct RTCRtpEncodingParametersAtoms;
31 : struct RTCRtpHeaderExtensionParameters;
32 : struct RTCRtpHeaderExtensionParametersAtoms;
33 : struct RTCRtpParameters;
34 : struct RTCRtpParametersAtoms;
35 : class RTCRtpSender;
36 : struct RTCRtpSenderAtoms;
37 : struct RTCRtxParameters;
38 : struct RTCRtxParametersAtoms;
39 :
40 : } // namespace dom
41 : } // namespace mozilla
42 :
43 : namespace mozilla {
44 : namespace dom {
45 :
46 : enum class RTCPriorityType : uint8_t {
47 : Very_low,
48 : Low,
49 : Medium,
50 : High,
51 : EndGuard_
52 : };
53 :
54 : namespace RTCPriorityTypeValues {
55 : extern const EnumEntry strings[5];
56 : } // namespace RTCPriorityTypeValues
57 :
58 : bool
59 : ToJSValue(JSContext* aCx, RTCPriorityType aArgument, JS::MutableHandle<JS::Value> aValue);
60 :
61 :
62 : enum class RTCDegradationPreference : uint8_t {
63 : Maintain_framerate,
64 : Maintain_resolution,
65 : Balanced,
66 : EndGuard_
67 : };
68 :
69 : namespace RTCDegradationPreferenceValues {
70 : extern const EnumEntry strings[4];
71 : } // namespace RTCDegradationPreferenceValues
72 :
73 : bool
74 : ToJSValue(JSContext* aCx, RTCDegradationPreference aArgument, JS::MutableHandle<JS::Value> aValue);
75 :
76 :
77 0 : struct RTCFecParameters : public DictionaryBase
78 : {
79 : MOZ_INIT_OUTSIDE_CTOR Optional<uint32_t> mSsrc;
80 :
81 : RTCFecParameters();
82 :
83 0 : explicit inline RTCFecParameters(const FastDictionaryInitializer& )
84 0 : {
85 : // Do nothing here; this is used by our "Fast" subclass
86 0 : }
87 :
88 : explicit inline RTCFecParameters(const RTCFecParameters& aOther)
89 : {
90 : *this = aOther;
91 : }
92 :
93 : bool
94 : Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false);
95 :
96 : bool
97 : Init(const nsAString& aJSON);
98 :
99 : bool
100 : ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const;
101 :
102 : bool
103 : ToJSON(nsAString& aJSON) const;
104 :
105 : void
106 : TraceDictionary(JSTracer* trc);
107 :
108 : RTCFecParameters&
109 : operator=(const RTCFecParameters& aOther);
110 :
111 : private:
112 : static bool
113 : InitIds(JSContext* cx, RTCFecParametersAtoms* atomsCache);
114 : };
115 :
116 : namespace binding_detail {
117 : struct FastRTCFecParameters : public RTCFecParameters
118 : {
119 : inline FastRTCFecParameters()
120 : : RTCFecParameters(FastDictionaryInitializer())
121 : {
122 : // Doesn't matter what int we pass to the parent constructor
123 : }
124 : };
125 : } // namespace binding_detail
126 :
127 :
128 0 : struct RTCRtcpParameters : public DictionaryBase
129 : {
130 : MOZ_INIT_OUTSIDE_CTOR Optional<nsString> mCname;
131 : MOZ_INIT_OUTSIDE_CTOR Optional<bool> mReducedSize;
132 :
133 : RTCRtcpParameters();
134 :
135 0 : explicit inline RTCRtcpParameters(const FastDictionaryInitializer& )
136 0 : {
137 : // Do nothing here; this is used by our "Fast" subclass
138 0 : }
139 :
140 : explicit inline RTCRtcpParameters(const RTCRtcpParameters& aOther)
141 : {
142 : *this = aOther;
143 : }
144 :
145 : bool
146 : Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false);
147 :
148 : bool
149 : Init(const nsAString& aJSON);
150 :
151 : bool
152 : ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const;
153 :
154 : bool
155 : ToJSON(nsAString& aJSON) const;
156 :
157 : void
158 : TraceDictionary(JSTracer* trc);
159 :
160 : RTCRtcpParameters&
161 : operator=(const RTCRtcpParameters& aOther);
162 :
163 : private:
164 : static bool
165 : InitIds(JSContext* cx, RTCRtcpParametersAtoms* atomsCache);
166 : };
167 :
168 : namespace binding_detail {
169 : struct FastRTCRtcpParameters : public RTCRtcpParameters
170 : {
171 : inline FastRTCRtcpParameters()
172 : : RTCRtcpParameters(FastDictionaryInitializer())
173 : {
174 : // Doesn't matter what int we pass to the parent constructor
175 : }
176 : };
177 : } // namespace binding_detail
178 :
179 :
180 0 : struct RTCRtpCodecParameters : public DictionaryBase
181 : {
182 : MOZ_INIT_OUTSIDE_CTOR uint16_t mChannels;
183 : MOZ_INIT_OUTSIDE_CTOR Optional<uint32_t> mClockRate;
184 : MOZ_INIT_OUTSIDE_CTOR Optional<nsString> mMimeType;
185 : MOZ_INIT_OUTSIDE_CTOR Optional<uint16_t> mPayloadType;
186 : MOZ_INIT_OUTSIDE_CTOR Optional<nsString> mSdpFmtpLine;
187 :
188 : RTCRtpCodecParameters();
189 :
190 : explicit inline RTCRtpCodecParameters(const FastDictionaryInitializer& )
191 : {
192 : // Do nothing here; this is used by our "Fast" subclass
193 : }
194 :
195 0 : explicit inline RTCRtpCodecParameters(const RTCRtpCodecParameters& aOther)
196 0 : {
197 0 : *this = aOther;
198 0 : }
199 :
200 : bool
201 : Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false);
202 :
203 : bool
204 : Init(const nsAString& aJSON);
205 :
206 : bool
207 : ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const;
208 :
209 : bool
210 : ToJSON(nsAString& aJSON) const;
211 :
212 : void
213 : TraceDictionary(JSTracer* trc);
214 :
215 : RTCRtpCodecParameters&
216 : operator=(const RTCRtpCodecParameters& aOther);
217 :
218 : private:
219 : static bool
220 : InitIds(JSContext* cx, RTCRtpCodecParametersAtoms* atomsCache);
221 : };
222 :
223 : namespace binding_detail {
224 : struct FastRTCRtpCodecParameters : public RTCRtpCodecParameters
225 : {
226 : inline FastRTCRtpCodecParameters()
227 : : RTCRtpCodecParameters(FastDictionaryInitializer())
228 : {
229 : // Doesn't matter what int we pass to the parent constructor
230 : }
231 : };
232 : } // namespace binding_detail
233 :
234 :
235 0 : struct RTCRtpHeaderExtensionParameters : public DictionaryBase
236 : {
237 : MOZ_INIT_OUTSIDE_CTOR Optional<bool> mEncrypted;
238 : MOZ_INIT_OUTSIDE_CTOR Optional<uint16_t> mId;
239 : MOZ_INIT_OUTSIDE_CTOR Optional<nsString> mUri;
240 :
241 : RTCRtpHeaderExtensionParameters();
242 :
243 : explicit inline RTCRtpHeaderExtensionParameters(const FastDictionaryInitializer& )
244 : {
245 : // Do nothing here; this is used by our "Fast" subclass
246 : }
247 :
248 0 : explicit inline RTCRtpHeaderExtensionParameters(const RTCRtpHeaderExtensionParameters& aOther)
249 0 : {
250 0 : *this = aOther;
251 0 : }
252 :
253 : bool
254 : Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false);
255 :
256 : bool
257 : Init(const nsAString& aJSON);
258 :
259 : bool
260 : ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const;
261 :
262 : bool
263 : ToJSON(nsAString& aJSON) const;
264 :
265 : void
266 : TraceDictionary(JSTracer* trc);
267 :
268 : RTCRtpHeaderExtensionParameters&
269 : operator=(const RTCRtpHeaderExtensionParameters& aOther);
270 :
271 : private:
272 : static bool
273 : InitIds(JSContext* cx, RTCRtpHeaderExtensionParametersAtoms* atomsCache);
274 : };
275 :
276 : namespace binding_detail {
277 : struct FastRTCRtpHeaderExtensionParameters : public RTCRtpHeaderExtensionParameters
278 : {
279 : inline FastRTCRtpHeaderExtensionParameters()
280 : : RTCRtpHeaderExtensionParameters(FastDictionaryInitializer())
281 : {
282 : // Doesn't matter what int we pass to the parent constructor
283 : }
284 : };
285 : } // namespace binding_detail
286 :
287 :
288 0 : struct RTCRtxParameters : public DictionaryBase
289 : {
290 : MOZ_INIT_OUTSIDE_CTOR Optional<uint32_t> mSsrc;
291 :
292 : RTCRtxParameters();
293 :
294 0 : explicit inline RTCRtxParameters(const FastDictionaryInitializer& )
295 0 : {
296 : // Do nothing here; this is used by our "Fast" subclass
297 0 : }
298 :
299 : explicit inline RTCRtxParameters(const RTCRtxParameters& aOther)
300 : {
301 : *this = aOther;
302 : }
303 :
304 : bool
305 : Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false);
306 :
307 : bool
308 : Init(const nsAString& aJSON);
309 :
310 : bool
311 : ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const;
312 :
313 : bool
314 : ToJSON(nsAString& aJSON) const;
315 :
316 : void
317 : TraceDictionary(JSTracer* trc);
318 :
319 : RTCRtxParameters&
320 : operator=(const RTCRtxParameters& aOther);
321 :
322 : private:
323 : static bool
324 : InitIds(JSContext* cx, RTCRtxParametersAtoms* atomsCache);
325 : };
326 :
327 : namespace binding_detail {
328 : struct FastRTCRtxParameters : public RTCRtxParameters
329 : {
330 : inline FastRTCRtxParameters()
331 : : RTCRtxParameters(FastDictionaryInitializer())
332 : {
333 : // Doesn't matter what int we pass to the parent constructor
334 : }
335 : };
336 : } // namespace binding_detail
337 :
338 :
339 0 : struct RTCRtpEncodingParameters : public DictionaryBase
340 : {
341 : MOZ_INIT_OUTSIDE_CTOR Optional<bool> mActive;
342 : MOZ_INIT_OUTSIDE_CTOR RTCDegradationPreference mDegradationPreference;
343 : MOZ_INIT_OUTSIDE_CTOR RTCFecParameters mFec;
344 : MOZ_INIT_OUTSIDE_CTOR Optional<uint32_t> mMaxBitrate;
345 : MOZ_INIT_OUTSIDE_CTOR Optional<RTCPriorityType> mPriority;
346 : MOZ_INIT_OUTSIDE_CTOR Optional<nsString> mRid;
347 : MOZ_INIT_OUTSIDE_CTOR RTCRtxParameters mRtx;
348 : MOZ_INIT_OUTSIDE_CTOR float mScaleResolutionDownBy;
349 : MOZ_INIT_OUTSIDE_CTOR Optional<uint32_t> mSsrc;
350 :
351 : RTCRtpEncodingParameters();
352 :
353 : explicit inline RTCRtpEncodingParameters(const FastDictionaryInitializer& )
354 : : mFec(FastDictionaryInitializer()),
355 : mRtx(FastDictionaryInitializer())
356 : {
357 : // Do nothing here; this is used by our "Fast" subclass
358 : }
359 :
360 0 : explicit inline RTCRtpEncodingParameters(const RTCRtpEncodingParameters& aOther)
361 0 : : mFec(FastDictionaryInitializer()),
362 0 : mRtx(FastDictionaryInitializer())
363 : {
364 0 : *this = aOther;
365 0 : }
366 :
367 : bool
368 : Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false);
369 :
370 : bool
371 : Init(const nsAString& aJSON);
372 :
373 : bool
374 : ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const;
375 :
376 : bool
377 : ToJSON(nsAString& aJSON) const;
378 :
379 : void
380 : TraceDictionary(JSTracer* trc);
381 :
382 : RTCRtpEncodingParameters&
383 : operator=(const RTCRtpEncodingParameters& aOther);
384 :
385 : private:
386 : static bool
387 : InitIds(JSContext* cx, RTCRtpEncodingParametersAtoms* atomsCache);
388 : };
389 :
390 : namespace binding_detail {
391 : struct FastRTCRtpEncodingParameters : public RTCRtpEncodingParameters
392 : {
393 : inline FastRTCRtpEncodingParameters()
394 : : RTCRtpEncodingParameters(FastDictionaryInitializer())
395 : {
396 : // Doesn't matter what int we pass to the parent constructor
397 : }
398 : };
399 : } // namespace binding_detail
400 :
401 :
402 0 : struct RTCRtpParameters : public DictionaryBase
403 : {
404 : MOZ_INIT_OUTSIDE_CTOR Optional<Sequence<RTCRtpCodecParameters>> mCodecs;
405 : MOZ_INIT_OUTSIDE_CTOR Optional<Sequence<RTCRtpEncodingParameters>> mEncodings;
406 : MOZ_INIT_OUTSIDE_CTOR Optional<Sequence<RTCRtpHeaderExtensionParameters>> mHeaderExtensions;
407 : MOZ_INIT_OUTSIDE_CTOR RTCRtcpParameters mRtcp;
408 :
409 : RTCRtpParameters();
410 :
411 0 : explicit inline RTCRtpParameters(const FastDictionaryInitializer& )
412 0 : : mRtcp(FastDictionaryInitializer())
413 : {
414 : // Do nothing here; this is used by our "Fast" subclass
415 0 : }
416 :
417 : explicit inline RTCRtpParameters(const RTCRtpParameters& aOther)
418 : : mRtcp(FastDictionaryInitializer())
419 : {
420 : *this = aOther;
421 : }
422 :
423 : bool
424 : Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false);
425 :
426 : bool
427 : Init(const nsAString& aJSON);
428 :
429 : bool
430 : ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const;
431 :
432 : bool
433 : ToJSON(nsAString& aJSON) const;
434 :
435 : void
436 : TraceDictionary(JSTracer* trc);
437 :
438 : RTCRtpParameters&
439 : operator=(const RTCRtpParameters& aOther);
440 :
441 : private:
442 : static bool
443 : InitIds(JSContext* cx, RTCRtpParametersAtoms* atomsCache);
444 : };
445 :
446 : namespace binding_detail {
447 0 : struct FastRTCRtpParameters : public RTCRtpParameters
448 : {
449 0 : inline FastRTCRtpParameters()
450 0 : : RTCRtpParameters(FastDictionaryInitializer())
451 : {
452 : // Doesn't matter what int we pass to the parent constructor
453 0 : }
454 : };
455 : } // namespace binding_detail
456 :
457 :
458 : namespace RTCRtpSenderBinding {
459 :
460 : typedef mozilla::dom::RTCRtpSender NativeType;
461 :
462 : bool
463 : ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj);
464 :
465 : JSObject*
466 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal);
467 :
468 : const JSClass*
469 : GetJSClass();
470 :
471 : bool
472 : Wrap(JSContext* aCx, mozilla::dom::RTCRtpSender* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector);
473 :
474 : template <class T>
475 0 : inline JSObject* Wrap(JSContext* aCx, T* aObject, JS::Handle<JSObject*> aGivenProto)
476 : {
477 0 : JS::Rooted<JSObject*> reflector(aCx);
478 0 : return Wrap(aCx, aObject, aObject, aGivenProto, &reflector) ? reflector.get() : nullptr;
479 : }
480 :
481 : // We declare this as an array so that retrieving a pointer to this
482 : // binding's property hooks only requires compile/link-time resolvable
483 : // address arithmetic. Declaring it as a pointer instead would require
484 : // doing a run-time load to fetch a pointer to this binding's property
485 : // hooks. And then structures which embedded a pointer to this structure
486 : // would require a run-time load for proper initialization, which would
487 : // then induce static constructors. Lots of static constructors.
488 : extern const NativePropertyHooks sNativePropertyHooks[];
489 :
490 : void
491 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal);
492 :
493 : JS::Handle<JSObject*>
494 : GetProtoObjectHandle(JSContext* aCx);
495 :
496 : JS::Handle<JSObject*>
497 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal = true);
498 :
499 : JSObject*
500 : GetConstructorObject(JSContext* aCx);
501 :
502 : } // namespace RTCRtpSenderBinding
503 :
504 :
505 :
506 0 : class RTCRtpSenderJSImpl : public CallbackInterface
507 : {
508 : public:
509 0 : explicit inline RTCRtpSenderJSImpl(JSContext* aCx, JS::Handle<JSObject*> aCallback, nsIGlobalObject* aIncumbentGlobal)
510 0 : : CallbackInterface(aCx, aCallback, aIncumbentGlobal)
511 : {
512 0 : }
513 :
514 : explicit inline RTCRtpSenderJSImpl(JS::Handle<JSObject*> aCallback, const FastCallbackConstructor& )
515 : : CallbackInterface(aCallback, FastCallbackConstructor())
516 : {
517 : }
518 :
519 : explicit inline RTCRtpSenderJSImpl(JS::Handle<JSObject*> aCallback, JS::Handle<JSObject*> aAsyncStack, nsIGlobalObject* aIncumbentGlobal)
520 : : CallbackInterface(aCallback, aAsyncStack, aIncumbentGlobal)
521 : {
522 : }
523 :
524 : already_AddRefed<Promise> SetParameters(const RTCRtpParameters& parameters, ErrorResult& aRv, JSCompartment* aCompartment = nullptr);
525 :
526 : void GetParameters(RTCRtpParameters& aRetVal, ErrorResult& aRv, JSCompartment* aCompartment = nullptr);
527 :
528 : already_AddRefed<Promise> ReplaceTrack(MediaStreamTrack& track, ErrorResult& aRv, JSCompartment* aCompartment = nullptr);
529 :
530 : already_AddRefed<Promise> GetStats(ErrorResult& aRv, JSCompartment* aCompartment = nullptr);
531 :
532 : inline bool
533 : operator==(const RTCRtpSenderJSImpl& aOther) const
534 : {
535 : return CallbackInterface::operator==(aOther);
536 : }
537 :
538 : already_AddRefed<MediaStreamTrack> GetTrack(ErrorResult& aRv, JSCompartment* aCompartment = nullptr);
539 :
540 : already_AddRefed<RTCDTMFSender> GetDtmf(ErrorResult& aRv, JSCompartment* aCompartment = nullptr);
541 :
542 : private:
543 : static bool
544 : InitIds(JSContext* cx, RTCRtpSenderAtoms* atomsCache);
545 : };
546 :
547 :
548 : class RTCRtpSender final : public nsSupportsWeakReference,
549 : public nsWrapperCache
550 : {
551 : public:
552 : NS_DECL_CYCLE_COLLECTING_ISUPPORTS
553 0 : NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(RTCRtpSender)
554 :
555 : private:
556 : RefPtr<RTCRtpSenderJSImpl> mImpl;
557 : nsCOMPtr<nsISupports> mParent;
558 :
559 : public:
560 : RTCRtpSender(JS::Handle<JSObject*> aJSImplObject, nsIGlobalObject* aParent);
561 :
562 : private:
563 : ~RTCRtpSender();
564 :
565 : public:
566 : nsISupports* GetParentObject() const;
567 :
568 : virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
569 :
570 : // Return a raw pointer here to avoid refcounting, but make sure it's safe (the object should be kept alive by the callee).
571 : already_AddRefed<MediaStreamTrack> GetTrack(ErrorResult& aRv, JSCompartment* aCompartment = nullptr) const;
572 :
573 : // Return a raw pointer here to avoid refcounting, but make sure it's safe (the object should be kept alive by the callee).
574 : already_AddRefed<Promise> SetParameters(const RTCRtpParameters& parameters, ErrorResult& aRv, JSCompartment* aCompartment = nullptr);
575 :
576 : void GetParameters(RTCRtpParameters& aRetVal, ErrorResult& aRv, JSCompartment* aCompartment = nullptr);
577 :
578 : // Return a raw pointer here to avoid refcounting, but make sure it's safe (the object should be kept alive by the callee).
579 : already_AddRefed<Promise> ReplaceTrack(MediaStreamTrack& track, ErrorResult& aRv, JSCompartment* aCompartment = nullptr);
580 :
581 : // Return a raw pointer here to avoid refcounting, but make sure it's safe (the object should be kept alive by the callee).
582 : already_AddRefed<Promise> GetStats(ErrorResult& aRv, JSCompartment* aCompartment = nullptr);
583 :
584 : // Return a raw pointer here to avoid refcounting, but make sure it's safe (the object should be kept alive by the callee).
585 : already_AddRefed<RTCDTMFSender> GetDtmf(ErrorResult& aRv, JSCompartment* aCompartment = nullptr) const;
586 :
587 : static bool
588 : _Create(JSContext* cx, unsigned argc, JS::Value* vp);
589 : };
590 :
591 :
592 : } // namespace dom
593 : } // namespace mozilla
594 :
595 : #endif // mozilla_dom_RTCRtpSenderBinding_h
|