/work/obj-fuzz/dist/include/mozilla/dom/RTCPeerConnectionBinding.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* THIS FILE IS AUTOGENERATED FROM RTCPeerConnection.webidl BY Codegen.py - DO NOT EDIT */ |
2 | | |
3 | | #ifndef mozilla_dom_RTCPeerConnectionBinding_h |
4 | | #define mozilla_dom_RTCPeerConnectionBinding_h |
5 | | |
6 | | #include "GeckoProfiler.h" |
7 | | #include "RTCIceCandidateBinding.h" |
8 | | #include "RTCPeerConnectionBinding.h" |
9 | | #include "js/RootingAPI.h" |
10 | | #include "jspubtd.h" |
11 | | #include "mozilla/DOMEventTargetHelper.h" |
12 | | #include "mozilla/ErrorResult.h" |
13 | | #include "mozilla/dom/BindingDeclarations.h" |
14 | | #include "mozilla/dom/CallbackFunction.h" |
15 | | #include "mozilla/dom/CallbackInterface.h" |
16 | | #include "mozilla/dom/FakeString.h" |
17 | | #include "mozilla/dom/Nullable.h" |
18 | | #include "mozilla/dom/PrototypeList.h" |
19 | | #include "mozilla/dom/ToJSValue.h" |
20 | | #include "mozilla/dom/TypedArray.h" |
21 | | #include "mozilla/dom/UnionMember.h" |
22 | | #include "nsWeakReference.h" |
23 | | |
24 | | class nsDOMDataChannel; |
25 | | |
26 | | namespace mozilla { |
27 | | |
28 | | class DOMMediaStream; |
29 | | |
30 | | namespace dom { |
31 | | |
32 | | class DOMException; |
33 | | class EventHandlerNonNull; |
34 | | class MediaStreamTrack; |
35 | | class MediaStreamTrackOrString; |
36 | | struct NativePropertyHooks; |
37 | | class ObjectOrString; |
38 | | class OwningMediaStreamTrackOrString; |
39 | | class OwningObjectOrString; |
40 | | class OwningRTCIceCandidateInitOrRTCIceCandidate; |
41 | | class Promise; |
42 | | class ProtoAndIfaceCache; |
43 | | struct RTCAnswerOptions; |
44 | | struct RTCConfiguration; |
45 | | struct RTCDataChannelInit; |
46 | | struct RTCDataChannelInitAtoms; |
47 | | class RTCIceCandidate; |
48 | | class RTCIceCandidateInitOrRTCIceCandidate; |
49 | | struct RTCIdentityProviderOptions; |
50 | | struct RTCOfferOptions; |
51 | | struct RTCOfferOptionsAtoms; |
52 | | class RTCPeerConnection; |
53 | | struct RTCPeerConnectionAtoms; |
54 | | class RTCPeerConnectionErrorCallback; |
55 | | class RTCRtpReceiver; |
56 | | class RTCRtpSender; |
57 | | class RTCRtpTransceiver; |
58 | | struct RTCRtpTransceiverInit; |
59 | | class RTCSessionDescription; |
60 | | class RTCSessionDescriptionCallback; |
61 | | struct RTCSessionDescriptionInit; |
62 | | class RTCStatsCallback; |
63 | | class RTCStatsReport; |
64 | | class VoidFunction; |
65 | | class mozPacketCallback; |
66 | | |
67 | | } // namespace dom |
68 | | |
69 | | } // namespace mozilla |
70 | | |
71 | | namespace mozilla { |
72 | | namespace dom { |
73 | | |
74 | | enum class RTCSignalingState : uint8_t { |
75 | | Stable, |
76 | | Have_local_offer, |
77 | | Have_remote_offer, |
78 | | Have_local_pranswer, |
79 | | Have_remote_pranswer, |
80 | | Closed, |
81 | | EndGuard_ |
82 | | }; |
83 | | |
84 | | namespace RTCSignalingStateValues { |
85 | | extern const EnumEntry strings[7]; |
86 | | } // namespace RTCSignalingStateValues |
87 | | |
88 | | bool |
89 | | ToJSValue(JSContext* aCx, RTCSignalingState aArgument, JS::MutableHandle<JS::Value> aValue); |
90 | | |
91 | | |
92 | | enum class RTCIceGatheringState : uint8_t { |
93 | | New, |
94 | | Gathering, |
95 | | Complete, |
96 | | EndGuard_ |
97 | | }; |
98 | | |
99 | | namespace RTCIceGatheringStateValues { |
100 | | extern const EnumEntry strings[4]; |
101 | | } // namespace RTCIceGatheringStateValues |
102 | | |
103 | | bool |
104 | | ToJSValue(JSContext* aCx, RTCIceGatheringState aArgument, JS::MutableHandle<JS::Value> aValue); |
105 | | |
106 | | |
107 | | enum class RTCIceConnectionState : uint8_t { |
108 | | New, |
109 | | Checking, |
110 | | Connected, |
111 | | Completed, |
112 | | Failed, |
113 | | Disconnected, |
114 | | Closed, |
115 | | EndGuard_ |
116 | | }; |
117 | | |
118 | | namespace RTCIceConnectionStateValues { |
119 | | extern const EnumEntry strings[8]; |
120 | | } // namespace RTCIceConnectionStateValues |
121 | | |
122 | | bool |
123 | | ToJSValue(JSContext* aCx, RTCIceConnectionState aArgument, JS::MutableHandle<JS::Value> aValue); |
124 | | |
125 | | |
126 | | enum class mozPacketDumpType : uint8_t { |
127 | | Rtp, |
128 | | Srtp, |
129 | | Rtcp, |
130 | | Srtcp, |
131 | | EndGuard_ |
132 | | }; |
133 | | |
134 | | namespace mozPacketDumpTypeValues { |
135 | | extern const EnumEntry strings[5]; |
136 | | } // namespace mozPacketDumpTypeValues |
137 | | |
138 | | bool |
139 | | ToJSValue(JSContext* aCx, mozPacketDumpType aArgument, JS::MutableHandle<JS::Value> aValue); |
140 | | |
141 | | |
142 | | void |
143 | | ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback, OwningMediaStreamTrackOrString& aUnion, const char* aName, uint32_t aFlags = 0); |
144 | | |
145 | | |
146 | | void |
147 | | ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback, OwningRTCIceCandidateInitOrRTCIceCandidate& aUnion, const char* aName, uint32_t aFlags = 0); |
148 | | |
149 | | |
150 | | void |
151 | | ImplCycleCollectionUnlink(OwningMediaStreamTrackOrString& aUnion); |
152 | | |
153 | | |
154 | | void |
155 | | ImplCycleCollectionUnlink(OwningRTCIceCandidateInitOrRTCIceCandidate& aUnion); |
156 | | |
157 | | |
158 | | class MediaStreamTrackOrString |
159 | | { |
160 | | friend class MediaStreamTrackOrStringArgument; |
161 | | enum Type |
162 | | { |
163 | | eUninitialized, |
164 | | eMediaStreamTrack, |
165 | | eString |
166 | | }; |
167 | | |
168 | | union Value |
169 | | { |
170 | | UnionMember<NonNull<mozilla::dom::MediaStreamTrack> > mMediaStreamTrack; |
171 | | UnionMember<binding_detail::FakeString > mString; |
172 | | |
173 | | }; |
174 | | |
175 | | Type mType; |
176 | | Value mValue; |
177 | | |
178 | | MediaStreamTrackOrString(const MediaStreamTrackOrString&) = delete; |
179 | | MediaStreamTrackOrString& operator=(const MediaStreamTrackOrString&) = delete; |
180 | | public: |
181 | | explicit inline MediaStreamTrackOrString() |
182 | | : mType(eUninitialized) |
183 | 0 | { |
184 | 0 | } |
185 | | |
186 | | inline ~MediaStreamTrackOrString() |
187 | 0 | { |
188 | 0 | Uninit(); |
189 | 0 | } |
190 | | |
191 | | inline NonNull<mozilla::dom::MediaStreamTrack>& |
192 | | RawSetAsMediaStreamTrack() |
193 | 0 | { |
194 | 0 | if (mType == eMediaStreamTrack) { |
195 | 0 | return mValue.mMediaStreamTrack.Value(); |
196 | 0 | } |
197 | 0 | MOZ_ASSERT(mType == eUninitialized); |
198 | 0 | mType = eMediaStreamTrack; |
199 | 0 | return mValue.mMediaStreamTrack.SetValue(); |
200 | 0 | } |
201 | | |
202 | | inline NonNull<mozilla::dom::MediaStreamTrack>& |
203 | | SetAsMediaStreamTrack() |
204 | 0 | { |
205 | 0 | if (mType == eMediaStreamTrack) { |
206 | 0 | return mValue.mMediaStreamTrack.Value(); |
207 | 0 | } |
208 | 0 | Uninit(); |
209 | 0 | mType = eMediaStreamTrack; |
210 | 0 | return mValue.mMediaStreamTrack.SetValue(); |
211 | 0 | } |
212 | | |
213 | | inline bool |
214 | | IsMediaStreamTrack() const |
215 | 0 | { |
216 | 0 | return mType == eMediaStreamTrack; |
217 | 0 | } |
218 | | |
219 | | inline NonNull<mozilla::dom::MediaStreamTrack>& |
220 | | GetAsMediaStreamTrack() |
221 | 0 | { |
222 | 0 | MOZ_ASSERT(IsMediaStreamTrack(), "Wrong type!"); |
223 | 0 | return mValue.mMediaStreamTrack.Value(); |
224 | 0 | } |
225 | | |
226 | | inline mozilla::dom::MediaStreamTrack& |
227 | | GetAsMediaStreamTrack() const |
228 | 0 | { |
229 | 0 | MOZ_ASSERT(IsMediaStreamTrack(), "Wrong type!"); |
230 | 0 | return mValue.mMediaStreamTrack.Value(); |
231 | 0 | } |
232 | | |
233 | | inline binding_detail::FakeString& |
234 | | RawSetAsString() |
235 | 0 | { |
236 | 0 | if (mType == eString) { |
237 | 0 | return mValue.mString.Value(); |
238 | 0 | } |
239 | 0 | MOZ_ASSERT(mType == eUninitialized); |
240 | 0 | mType = eString; |
241 | 0 | return mValue.mString.SetValue(); |
242 | 0 | } |
243 | | |
244 | | inline binding_detail::FakeString& |
245 | | SetAsString() |
246 | 0 | { |
247 | 0 | if (mType == eString) { |
248 | 0 | return mValue.mString.Value(); |
249 | 0 | } |
250 | 0 | Uninit(); |
251 | 0 | mType = eString; |
252 | 0 | return mValue.mString.SetValue(); |
253 | 0 | } |
254 | | |
255 | | inline bool |
256 | | IsString() const |
257 | 0 | { |
258 | 0 | return mType == eString; |
259 | 0 | } |
260 | | |
261 | | inline binding_detail::FakeString& |
262 | | GetAsString() |
263 | 0 | { |
264 | 0 | MOZ_ASSERT(IsString(), "Wrong type!"); |
265 | 0 | return mValue.mString.Value(); |
266 | 0 | } |
267 | | |
268 | | inline const nsAString& |
269 | | GetAsString() const |
270 | 0 | { |
271 | 0 | MOZ_ASSERT(IsString(), "Wrong type!"); |
272 | 0 | return mValue.mString.Value(); |
273 | 0 | } |
274 | | |
275 | | inline void |
276 | | Uninit() |
277 | | { |
278 | | switch (mType) { |
279 | | case eUninitialized: { |
280 | | break; |
281 | | } |
282 | | case eMediaStreamTrack: { |
283 | | DestroyMediaStreamTrack(); |
284 | | break; |
285 | | } |
286 | | case eString: { |
287 | | DestroyString(); |
288 | | break; |
289 | | } |
290 | | } |
291 | | } |
292 | | |
293 | | bool |
294 | | ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const; |
295 | | |
296 | | private: |
297 | | inline void |
298 | | DestroyMediaStreamTrack() |
299 | 0 | { |
300 | 0 | MOZ_ASSERT(IsMediaStreamTrack(), "Wrong type!"); |
301 | 0 | mValue.mMediaStreamTrack.Destroy(); |
302 | 0 | mType = eUninitialized; |
303 | 0 | } |
304 | | |
305 | | inline void |
306 | | DestroyString() |
307 | 0 | { |
308 | 0 | MOZ_ASSERT(IsString(), "Wrong type!"); |
309 | 0 | mValue.mString.Destroy(); |
310 | 0 | mType = eUninitialized; |
311 | 0 | } |
312 | | }; |
313 | | |
314 | | |
315 | | class OwningMediaStreamTrackOrString : public AllOwningUnionBase |
316 | | { |
317 | | friend void ImplCycleCollectionUnlink(OwningMediaStreamTrackOrString& aUnion); |
318 | | enum Type |
319 | | { |
320 | | eUninitialized, |
321 | | eMediaStreamTrack, |
322 | | eString |
323 | | }; |
324 | | |
325 | | union Value |
326 | | { |
327 | | UnionMember<OwningNonNull<mozilla::dom::MediaStreamTrack> > mMediaStreamTrack; |
328 | | UnionMember<nsString > mString; |
329 | | |
330 | | }; |
331 | | |
332 | | Type mType; |
333 | | Value mValue; |
334 | | |
335 | | public: |
336 | | explicit inline OwningMediaStreamTrackOrString() |
337 | | : mType(eUninitialized) |
338 | 0 | { |
339 | 0 | } |
340 | | |
341 | | explicit inline OwningMediaStreamTrackOrString(const OwningMediaStreamTrackOrString& aOther) |
342 | | : mType(eUninitialized) |
343 | 0 | { |
344 | 0 | *this = aOther; |
345 | 0 | } |
346 | | |
347 | | inline ~OwningMediaStreamTrackOrString() |
348 | 0 | { |
349 | 0 | Uninit(); |
350 | 0 | } |
351 | | |
352 | | OwningNonNull<mozilla::dom::MediaStreamTrack>& |
353 | | RawSetAsMediaStreamTrack(); |
354 | | |
355 | | OwningNonNull<mozilla::dom::MediaStreamTrack>& |
356 | | SetAsMediaStreamTrack(); |
357 | | |
358 | | bool |
359 | | TrySetToMediaStreamTrack(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false); |
360 | | |
361 | | inline bool |
362 | | IsMediaStreamTrack() const |
363 | 0 | { |
364 | 0 | return mType == eMediaStreamTrack; |
365 | 0 | } |
366 | | |
367 | | inline OwningNonNull<mozilla::dom::MediaStreamTrack>& |
368 | | GetAsMediaStreamTrack() |
369 | 0 | { |
370 | 0 | MOZ_ASSERT(IsMediaStreamTrack(), "Wrong type!"); |
371 | 0 | return mValue.mMediaStreamTrack.Value(); |
372 | 0 | } |
373 | | |
374 | | inline OwningNonNull<mozilla::dom::MediaStreamTrack> const & |
375 | | GetAsMediaStreamTrack() const |
376 | 0 | { |
377 | 0 | MOZ_ASSERT(IsMediaStreamTrack(), "Wrong type!"); |
378 | 0 | return mValue.mMediaStreamTrack.Value(); |
379 | 0 | } |
380 | | |
381 | | nsString& |
382 | | RawSetAsString(); |
383 | | |
384 | | nsString& |
385 | | SetAsString(); |
386 | | |
387 | | bool |
388 | | TrySetToString(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false); |
389 | | |
390 | | inline void |
391 | | SetStringData(const nsString::char_type* aData, nsString::size_type aLength) |
392 | 0 | { |
393 | 0 | RawSetAsString().Assign(aData, aLength); |
394 | 0 | } |
395 | | |
396 | | inline bool |
397 | | IsString() const |
398 | 0 | { |
399 | 0 | return mType == eString; |
400 | 0 | } |
401 | | |
402 | | inline nsString& |
403 | | GetAsString() |
404 | 0 | { |
405 | 0 | MOZ_ASSERT(IsString(), "Wrong type!"); |
406 | 0 | return mValue.mString.Value(); |
407 | 0 | } |
408 | | |
409 | | inline nsString const & |
410 | | GetAsString() const |
411 | 0 | { |
412 | 0 | MOZ_ASSERT(IsString(), "Wrong type!"); |
413 | 0 | return mValue.mString.Value(); |
414 | 0 | } |
415 | | |
416 | | void |
417 | | Uninit(); |
418 | | |
419 | | bool |
420 | | ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const; |
421 | | |
422 | | void |
423 | | TraceUnion(JSTracer* trc); |
424 | | |
425 | | OwningMediaStreamTrackOrString& |
426 | | operator=(const OwningMediaStreamTrackOrString& aOther); |
427 | | |
428 | | private: |
429 | | void |
430 | | DestroyMediaStreamTrack(); |
431 | | |
432 | | void |
433 | | DestroyString(); |
434 | | }; |
435 | | |
436 | | |
437 | | struct RTCDataChannelInit : public DictionaryBase |
438 | | { |
439 | | MOZ_INIT_OUTSIDE_CTOR Optional<uint16_t> mId; |
440 | | MOZ_INIT_OUTSIDE_CTOR Optional<uint16_t> mMaxPacketLifeTime; |
441 | | MOZ_INIT_OUTSIDE_CTOR Optional<uint16_t> mMaxRetransmitTime; |
442 | | MOZ_INIT_OUTSIDE_CTOR Optional<uint16_t> mMaxRetransmits; |
443 | | MOZ_INIT_OUTSIDE_CTOR bool mNegotiated; |
444 | | MOZ_INIT_OUTSIDE_CTOR bool mOrdered; |
445 | | MOZ_INIT_OUTSIDE_CTOR nsString mProtocol; |
446 | | |
447 | | RTCDataChannelInit(); |
448 | | |
449 | | explicit inline RTCDataChannelInit(const FastDictionaryInitializer& ) |
450 | 0 | { |
451 | 0 | // Do nothing here; this is used by our "Fast" subclass |
452 | 0 | } |
453 | | |
454 | | explicit inline RTCDataChannelInit(const RTCDataChannelInit& aOther) |
455 | 0 | { |
456 | 0 | *this = aOther; |
457 | 0 | } |
458 | | |
459 | | bool |
460 | | Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false); |
461 | | |
462 | | bool |
463 | | Init(const nsAString& aJSON); |
464 | | |
465 | | bool |
466 | | ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const; |
467 | | |
468 | | bool |
469 | | ToJSON(nsAString& aJSON) const; |
470 | | |
471 | | void |
472 | | TraceDictionary(JSTracer* trc); |
473 | | |
474 | | RTCDataChannelInit& |
475 | | operator=(const RTCDataChannelInit& aOther); |
476 | | |
477 | | private: |
478 | | static bool |
479 | | InitIds(JSContext* cx, RTCDataChannelInitAtoms* atomsCache); |
480 | | }; |
481 | | |
482 | | namespace binding_detail { |
483 | | struct FastRTCDataChannelInit : public RTCDataChannelInit |
484 | | { |
485 | | inline FastRTCDataChannelInit() |
486 | | : RTCDataChannelInit(FastDictionaryInitializer()) |
487 | 0 | { |
488 | 0 | // Doesn't matter what int we pass to the parent constructor |
489 | 0 | } |
490 | | }; |
491 | | } // namespace binding_detail |
492 | | |
493 | | |
494 | | class RTCIceCandidateInitOrRTCIceCandidate |
495 | | { |
496 | | friend class RTCIceCandidateInitOrRTCIceCandidateArgument; |
497 | | enum Type |
498 | | { |
499 | | eUninitialized, |
500 | | eRTCIceCandidateInit, |
501 | | eRTCIceCandidate |
502 | | }; |
503 | | |
504 | | union Value |
505 | | { |
506 | | UnionMember<binding_detail::FastRTCIceCandidateInit > mRTCIceCandidateInit; |
507 | | UnionMember<NonNull<mozilla::dom::RTCIceCandidate> > mRTCIceCandidate; |
508 | | |
509 | | }; |
510 | | |
511 | | Type mType; |
512 | | Value mValue; |
513 | | |
514 | | RTCIceCandidateInitOrRTCIceCandidate(const RTCIceCandidateInitOrRTCIceCandidate&) = delete; |
515 | | RTCIceCandidateInitOrRTCIceCandidate& operator=(const RTCIceCandidateInitOrRTCIceCandidate&) = delete; |
516 | | public: |
517 | | explicit inline RTCIceCandidateInitOrRTCIceCandidate() |
518 | | : mType(eUninitialized) |
519 | 0 | { |
520 | 0 | } |
521 | | |
522 | | inline ~RTCIceCandidateInitOrRTCIceCandidate() |
523 | 0 | { |
524 | 0 | Uninit(); |
525 | 0 | } |
526 | | |
527 | | inline binding_detail::FastRTCIceCandidateInit& |
528 | | RawSetAsRTCIceCandidateInit() |
529 | 0 | { |
530 | 0 | if (mType == eRTCIceCandidateInit) { |
531 | 0 | return mValue.mRTCIceCandidateInit.Value(); |
532 | 0 | } |
533 | 0 | MOZ_ASSERT(mType == eUninitialized); |
534 | 0 | mType = eRTCIceCandidateInit; |
535 | 0 | return mValue.mRTCIceCandidateInit.SetValue(); |
536 | 0 | } |
537 | | |
538 | | inline binding_detail::FastRTCIceCandidateInit& |
539 | | SetAsRTCIceCandidateInit() |
540 | 0 | { |
541 | 0 | if (mType == eRTCIceCandidateInit) { |
542 | 0 | return mValue.mRTCIceCandidateInit.Value(); |
543 | 0 | } |
544 | 0 | Uninit(); |
545 | 0 | mType = eRTCIceCandidateInit; |
546 | 0 | return mValue.mRTCIceCandidateInit.SetValue(); |
547 | 0 | } |
548 | | |
549 | | inline bool |
550 | | IsRTCIceCandidateInit() const |
551 | 0 | { |
552 | 0 | return mType == eRTCIceCandidateInit; |
553 | 0 | } |
554 | | |
555 | | inline binding_detail::FastRTCIceCandidateInit& |
556 | | GetAsRTCIceCandidateInit() |
557 | 0 | { |
558 | 0 | MOZ_ASSERT(IsRTCIceCandidateInit(), "Wrong type!"); |
559 | 0 | return mValue.mRTCIceCandidateInit.Value(); |
560 | 0 | } |
561 | | |
562 | | inline const RTCIceCandidateInit& |
563 | | GetAsRTCIceCandidateInit() const |
564 | 0 | { |
565 | 0 | MOZ_ASSERT(IsRTCIceCandidateInit(), "Wrong type!"); |
566 | 0 | return mValue.mRTCIceCandidateInit.Value(); |
567 | 0 | } |
568 | | |
569 | | inline NonNull<mozilla::dom::RTCIceCandidate>& |
570 | | RawSetAsRTCIceCandidate() |
571 | 0 | { |
572 | 0 | if (mType == eRTCIceCandidate) { |
573 | 0 | return mValue.mRTCIceCandidate.Value(); |
574 | 0 | } |
575 | 0 | MOZ_ASSERT(mType == eUninitialized); |
576 | 0 | mType = eRTCIceCandidate; |
577 | 0 | return mValue.mRTCIceCandidate.SetValue(); |
578 | 0 | } |
579 | | |
580 | | inline NonNull<mozilla::dom::RTCIceCandidate>& |
581 | | SetAsRTCIceCandidate() |
582 | 0 | { |
583 | 0 | if (mType == eRTCIceCandidate) { |
584 | 0 | return mValue.mRTCIceCandidate.Value(); |
585 | 0 | } |
586 | 0 | Uninit(); |
587 | 0 | mType = eRTCIceCandidate; |
588 | 0 | return mValue.mRTCIceCandidate.SetValue(); |
589 | 0 | } |
590 | | |
591 | | inline bool |
592 | | IsRTCIceCandidate() const |
593 | 0 | { |
594 | 0 | return mType == eRTCIceCandidate; |
595 | 0 | } |
596 | | |
597 | | inline NonNull<mozilla::dom::RTCIceCandidate>& |
598 | | GetAsRTCIceCandidate() |
599 | 0 | { |
600 | 0 | MOZ_ASSERT(IsRTCIceCandidate(), "Wrong type!"); |
601 | 0 | return mValue.mRTCIceCandidate.Value(); |
602 | 0 | } |
603 | | |
604 | | inline mozilla::dom::RTCIceCandidate& |
605 | | GetAsRTCIceCandidate() const |
606 | 0 | { |
607 | 0 | MOZ_ASSERT(IsRTCIceCandidate(), "Wrong type!"); |
608 | 0 | return mValue.mRTCIceCandidate.Value(); |
609 | 0 | } |
610 | | |
611 | | inline void |
612 | | Uninit() |
613 | | { |
614 | | switch (mType) { |
615 | | case eUninitialized: { |
616 | | break; |
617 | | } |
618 | | case eRTCIceCandidateInit: { |
619 | | DestroyRTCIceCandidateInit(); |
620 | | break; |
621 | | } |
622 | | case eRTCIceCandidate: { |
623 | | DestroyRTCIceCandidate(); |
624 | | break; |
625 | | } |
626 | | } |
627 | | } |
628 | | |
629 | | bool |
630 | | ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const; |
631 | | |
632 | | private: |
633 | | inline void |
634 | | DestroyRTCIceCandidateInit() |
635 | 0 | { |
636 | 0 | MOZ_ASSERT(IsRTCIceCandidateInit(), "Wrong type!"); |
637 | 0 | mValue.mRTCIceCandidateInit.Destroy(); |
638 | 0 | mType = eUninitialized; |
639 | 0 | } |
640 | | |
641 | | inline void |
642 | | DestroyRTCIceCandidate() |
643 | 0 | { |
644 | 0 | MOZ_ASSERT(IsRTCIceCandidate(), "Wrong type!"); |
645 | 0 | mValue.mRTCIceCandidate.Destroy(); |
646 | 0 | mType = eUninitialized; |
647 | 0 | } |
648 | | }; |
649 | | |
650 | | |
651 | | class OwningRTCIceCandidateInitOrRTCIceCandidate : public AllOwningUnionBase |
652 | | { |
653 | | friend void ImplCycleCollectionUnlink(OwningRTCIceCandidateInitOrRTCIceCandidate& aUnion); |
654 | | enum Type |
655 | | { |
656 | | eUninitialized, |
657 | | eRTCIceCandidateInit, |
658 | | eRTCIceCandidate |
659 | | }; |
660 | | |
661 | | union Value |
662 | | { |
663 | | UnionMember<RTCIceCandidateInit > mRTCIceCandidateInit; |
664 | | UnionMember<OwningNonNull<mozilla::dom::RTCIceCandidate> > mRTCIceCandidate; |
665 | | |
666 | | }; |
667 | | |
668 | | Type mType; |
669 | | Value mValue; |
670 | | |
671 | | public: |
672 | | explicit inline OwningRTCIceCandidateInitOrRTCIceCandidate() |
673 | | : mType(eUninitialized) |
674 | 0 | { |
675 | 0 | } |
676 | | |
677 | | explicit inline OwningRTCIceCandidateInitOrRTCIceCandidate(const OwningRTCIceCandidateInitOrRTCIceCandidate& aOther) |
678 | | : mType(eUninitialized) |
679 | 0 | { |
680 | 0 | *this = aOther; |
681 | 0 | } |
682 | | |
683 | | inline ~OwningRTCIceCandidateInitOrRTCIceCandidate() |
684 | 0 | { |
685 | 0 | Uninit(); |
686 | 0 | } |
687 | | |
688 | | RTCIceCandidateInit& |
689 | | RawSetAsRTCIceCandidateInit(); |
690 | | |
691 | | RTCIceCandidateInit& |
692 | | SetAsRTCIceCandidateInit(); |
693 | | |
694 | | bool |
695 | | TrySetToRTCIceCandidateInit(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false); |
696 | | |
697 | | inline bool |
698 | | IsRTCIceCandidateInit() const |
699 | 0 | { |
700 | 0 | return mType == eRTCIceCandidateInit; |
701 | 0 | } |
702 | | |
703 | | inline RTCIceCandidateInit& |
704 | | GetAsRTCIceCandidateInit() |
705 | 0 | { |
706 | 0 | MOZ_ASSERT(IsRTCIceCandidateInit(), "Wrong type!"); |
707 | 0 | return mValue.mRTCIceCandidateInit.Value(); |
708 | 0 | } |
709 | | |
710 | | inline RTCIceCandidateInit const & |
711 | | GetAsRTCIceCandidateInit() const |
712 | 0 | { |
713 | 0 | MOZ_ASSERT(IsRTCIceCandidateInit(), "Wrong type!"); |
714 | 0 | return mValue.mRTCIceCandidateInit.Value(); |
715 | 0 | } |
716 | | |
717 | | OwningNonNull<mozilla::dom::RTCIceCandidate>& |
718 | | RawSetAsRTCIceCandidate(); |
719 | | |
720 | | OwningNonNull<mozilla::dom::RTCIceCandidate>& |
721 | | SetAsRTCIceCandidate(); |
722 | | |
723 | | bool |
724 | | TrySetToRTCIceCandidate(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false); |
725 | | |
726 | | inline bool |
727 | | IsRTCIceCandidate() const |
728 | 0 | { |
729 | 0 | return mType == eRTCIceCandidate; |
730 | 0 | } |
731 | | |
732 | | inline OwningNonNull<mozilla::dom::RTCIceCandidate>& |
733 | | GetAsRTCIceCandidate() |
734 | 0 | { |
735 | 0 | MOZ_ASSERT(IsRTCIceCandidate(), "Wrong type!"); |
736 | 0 | return mValue.mRTCIceCandidate.Value(); |
737 | 0 | } |
738 | | |
739 | | inline OwningNonNull<mozilla::dom::RTCIceCandidate> const & |
740 | | GetAsRTCIceCandidate() const |
741 | 0 | { |
742 | 0 | MOZ_ASSERT(IsRTCIceCandidate(), "Wrong type!"); |
743 | 0 | return mValue.mRTCIceCandidate.Value(); |
744 | 0 | } |
745 | | |
746 | | void |
747 | | Uninit(); |
748 | | |
749 | | bool |
750 | | ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const; |
751 | | |
752 | | void |
753 | | TraceUnion(JSTracer* trc); |
754 | | |
755 | | OwningRTCIceCandidateInitOrRTCIceCandidate& |
756 | | operator=(const OwningRTCIceCandidateInitOrRTCIceCandidate& aOther); |
757 | | |
758 | | private: |
759 | | void |
760 | | DestroyRTCIceCandidateInit(); |
761 | | |
762 | | void |
763 | | DestroyRTCIceCandidate(); |
764 | | }; |
765 | | |
766 | | |
767 | | struct RTCOfferAnswerOptions : public DictionaryBase |
768 | | { |
769 | | RTCOfferAnswerOptions(); |
770 | | |
771 | | explicit inline RTCOfferAnswerOptions(const FastDictionaryInitializer& ) |
772 | 0 | { |
773 | 0 | // Do nothing here; this is used by our "Fast" subclass |
774 | 0 | } |
775 | | |
776 | | explicit inline RTCOfferAnswerOptions(const RTCOfferAnswerOptions& aOther) |
777 | 0 | { |
778 | 0 | *this = aOther; |
779 | 0 | } |
780 | | |
781 | | bool |
782 | | Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false); |
783 | | |
784 | | bool |
785 | | Init(const nsAString& aJSON); |
786 | | |
787 | | bool |
788 | | ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const; |
789 | | |
790 | | bool |
791 | | ToJSON(nsAString& aJSON) const; |
792 | | |
793 | | void |
794 | | TraceDictionary(JSTracer* trc); |
795 | | |
796 | | RTCOfferAnswerOptions& |
797 | | operator=(const RTCOfferAnswerOptions& aOther); |
798 | | }; |
799 | | |
800 | | namespace binding_detail { |
801 | | struct FastRTCOfferAnswerOptions : public RTCOfferAnswerOptions |
802 | | { |
803 | | inline FastRTCOfferAnswerOptions() |
804 | | : RTCOfferAnswerOptions(FastDictionaryInitializer()) |
805 | 0 | { |
806 | 0 | // Doesn't matter what int we pass to the parent constructor |
807 | 0 | } |
808 | | }; |
809 | | } // namespace binding_detail |
810 | | |
811 | | |
812 | | struct RTCAnswerOptions : public RTCOfferAnswerOptions |
813 | | { |
814 | | RTCAnswerOptions(); |
815 | | |
816 | | explicit inline RTCAnswerOptions(const FastDictionaryInitializer& ) |
817 | | : RTCOfferAnswerOptions(FastDictionaryInitializer()) |
818 | 0 | { |
819 | 0 | // Do nothing here; this is used by our "Fast" subclass |
820 | 0 | } |
821 | | |
822 | | explicit inline RTCAnswerOptions(const RTCAnswerOptions& aOther) |
823 | 0 | { |
824 | 0 | *this = aOther; |
825 | 0 | } |
826 | | |
827 | | bool |
828 | | Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false); |
829 | | |
830 | | bool |
831 | | Init(const nsAString& aJSON); |
832 | | |
833 | | bool |
834 | | ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const; |
835 | | |
836 | | bool |
837 | | ToJSON(nsAString& aJSON) const; |
838 | | |
839 | | void |
840 | | TraceDictionary(JSTracer* trc); |
841 | | |
842 | | RTCAnswerOptions& |
843 | | operator=(const RTCAnswerOptions& aOther); |
844 | | }; |
845 | | |
846 | | namespace binding_detail { |
847 | | struct FastRTCAnswerOptions : public RTCAnswerOptions |
848 | | { |
849 | | inline FastRTCAnswerOptions() |
850 | | : RTCAnswerOptions(FastDictionaryInitializer()) |
851 | 0 | { |
852 | 0 | // Doesn't matter what int we pass to the parent constructor |
853 | 0 | } |
854 | | }; |
855 | | } // namespace binding_detail |
856 | | |
857 | | |
858 | | struct RTCOfferOptions : public RTCOfferAnswerOptions |
859 | | { |
860 | | MOZ_INIT_OUTSIDE_CTOR bool mIceRestart; |
861 | | MOZ_INIT_OUTSIDE_CTOR Optional<bool> mOfferToReceiveAudio; |
862 | | MOZ_INIT_OUTSIDE_CTOR Optional<bool> mOfferToReceiveVideo; |
863 | | |
864 | | RTCOfferOptions(); |
865 | | |
866 | | explicit inline RTCOfferOptions(const FastDictionaryInitializer& ) |
867 | | : RTCOfferAnswerOptions(FastDictionaryInitializer()) |
868 | 0 | { |
869 | 0 | // Do nothing here; this is used by our "Fast" subclass |
870 | 0 | } |
871 | | |
872 | | explicit inline RTCOfferOptions(const RTCOfferOptions& aOther) |
873 | 0 | { |
874 | 0 | *this = aOther; |
875 | 0 | } |
876 | | |
877 | | bool |
878 | | Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false); |
879 | | |
880 | | bool |
881 | | Init(const nsAString& aJSON); |
882 | | |
883 | | bool |
884 | | ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const; |
885 | | |
886 | | bool |
887 | | ToJSON(nsAString& aJSON) const; |
888 | | |
889 | | void |
890 | | TraceDictionary(JSTracer* trc); |
891 | | |
892 | | RTCOfferOptions& |
893 | | operator=(const RTCOfferOptions& aOther); |
894 | | |
895 | | private: |
896 | | static bool |
897 | | InitIds(JSContext* cx, RTCOfferOptionsAtoms* atomsCache); |
898 | | }; |
899 | | |
900 | | namespace binding_detail { |
901 | | struct FastRTCOfferOptions : public RTCOfferOptions |
902 | | { |
903 | | inline FastRTCOfferOptions() |
904 | | : RTCOfferOptions(FastDictionaryInitializer()) |
905 | 0 | { |
906 | 0 | // Doesn't matter what int we pass to the parent constructor |
907 | 0 | } |
908 | | }; |
909 | | } // namespace binding_detail |
910 | | |
911 | | |
912 | | class RTCSessionDescriptionCallback : public CallbackFunction |
913 | | { |
914 | | public: |
915 | | explicit inline RTCSessionDescriptionCallback(JSContext* aCx, JS::Handle<JSObject*> aCallback, JS::Handle<JSObject*> aCallbackGlobal, nsIGlobalObject* aIncumbentGlobal) |
916 | | : CallbackFunction(aCx, aCallback, aCallbackGlobal, aIncumbentGlobal) |
917 | 0 | { |
918 | 0 | MOZ_ASSERT(JS::IsCallable(mCallback)); |
919 | 0 | } |
920 | | |
921 | | explicit inline RTCSessionDescriptionCallback(JSObject* aCallback, JSObject* aCallbackGlobal, const FastCallbackConstructor& ) |
922 | | : CallbackFunction(aCallback, aCallbackGlobal, FastCallbackConstructor()) |
923 | 0 | { |
924 | 0 | MOZ_ASSERT(JS::IsCallable(mCallback)); |
925 | 0 | } |
926 | | |
927 | | explicit inline RTCSessionDescriptionCallback(JSObject* aCallback, JSObject* aCallbackGlobal, JSObject* aAsyncStack, nsIGlobalObject* aIncumbentGlobal) |
928 | | : CallbackFunction(aCallback, aCallbackGlobal, aAsyncStack, aIncumbentGlobal) |
929 | 0 | { |
930 | 0 | MOZ_ASSERT(JS::IsCallable(mCallback)); |
931 | 0 | } |
932 | | |
933 | | explicit inline RTCSessionDescriptionCallback(CallbackFunction* aOther) |
934 | | : CallbackFunction(aOther) |
935 | 0 | { |
936 | 0 | } |
937 | | |
938 | | template <typename T> |
939 | | inline void |
940 | | Call(const T& thisVal, const RTCSessionDescriptionInit& description, ErrorResult& aRv, const char* aExecutionReason = nullptr, ExceptionHandling aExceptionHandling = eReportExceptions, JS::Realm* aRealm = nullptr) |
941 | | { |
942 | | MOZ_ASSERT(!aRv.Failed(), "Don't pass an already-failed ErrorResult to a callback!"); |
943 | | if (!aExecutionReason) { |
944 | | aExecutionReason = "RTCSessionDescriptionCallback"; |
945 | | } |
946 | | CallSetup s(this, aRv, aExecutionReason, aExceptionHandling, aRealm); |
947 | | if (!s.GetContext()) { |
948 | | MOZ_ASSERT(aRv.Failed()); |
949 | | return; |
950 | | } |
951 | | JS::Rooted<JS::Value> thisValJS(s.GetContext()); |
952 | | if (!ToJSValue(s.GetContext(), thisVal, &thisValJS)) { |
953 | | aRv.Throw(NS_ERROR_FAILURE); |
954 | | return; |
955 | | } |
956 | | return Call(s.GetContext(), thisValJS, description, aRv); |
957 | | } |
958 | | |
959 | | inline void |
960 | | Call(const RTCSessionDescriptionInit& description, ErrorResult& aRv, const char* aExecutionReason = nullptr, ExceptionHandling aExceptionHandling = eReportExceptions, JS::Realm* aRealm = nullptr) |
961 | 0 | { |
962 | 0 | MOZ_ASSERT(!aRv.Failed(), "Don't pass an already-failed ErrorResult to a callback!"); |
963 | 0 | if (!aExecutionReason) { |
964 | 0 | aExecutionReason = "RTCSessionDescriptionCallback"; |
965 | 0 | } |
966 | 0 | CallSetup s(this, aRv, aExecutionReason, aExceptionHandling, aRealm); |
967 | 0 | if (!s.GetContext()) { |
968 | 0 | MOZ_ASSERT(aRv.Failed()); |
969 | 0 | return; |
970 | 0 | } |
971 | 0 | return Call(s.GetContext(), JS::UndefinedHandleValue, description, aRv); |
972 | 0 | } |
973 | | |
974 | | template <typename T> |
975 | | inline void |
976 | | Call(const T& thisVal, const RTCSessionDescriptionInit& description, const char* aExecutionReason = nullptr) |
977 | | { |
978 | | return Call(thisVal, description, IgnoreErrors(), aExecutionReason); |
979 | | } |
980 | | |
981 | | inline void |
982 | | Call(const RTCSessionDescriptionInit& description, const char* aExecutionReason = nullptr) |
983 | 0 | { |
984 | 0 | return Call(description, IgnoreErrors(), aExecutionReason, eReportExceptions, nullptr); |
985 | 0 | } |
986 | | |
987 | | inline bool |
988 | | operator==(const RTCSessionDescriptionCallback& aOther) const |
989 | 0 | { |
990 | 0 | return CallbackFunction::operator==(aOther); |
991 | 0 | } |
992 | | |
993 | | private: |
994 | | void Call(JSContext* cx, JS::Handle<JS::Value> aThisVal, const RTCSessionDescriptionInit& description, ErrorResult& aRv); |
995 | | }; |
996 | | |
997 | | |
998 | | class RTCPeerConnectionErrorCallback : public CallbackFunction |
999 | | { |
1000 | | public: |
1001 | | explicit inline RTCPeerConnectionErrorCallback(JSContext* aCx, JS::Handle<JSObject*> aCallback, JS::Handle<JSObject*> aCallbackGlobal, nsIGlobalObject* aIncumbentGlobal) |
1002 | | : CallbackFunction(aCx, aCallback, aCallbackGlobal, aIncumbentGlobal) |
1003 | 0 | { |
1004 | 0 | MOZ_ASSERT(JS::IsCallable(mCallback)); |
1005 | 0 | } |
1006 | | |
1007 | | explicit inline RTCPeerConnectionErrorCallback(JSObject* aCallback, JSObject* aCallbackGlobal, const FastCallbackConstructor& ) |
1008 | | : CallbackFunction(aCallback, aCallbackGlobal, FastCallbackConstructor()) |
1009 | 0 | { |
1010 | 0 | MOZ_ASSERT(JS::IsCallable(mCallback)); |
1011 | 0 | } |
1012 | | |
1013 | | explicit inline RTCPeerConnectionErrorCallback(JSObject* aCallback, JSObject* aCallbackGlobal, JSObject* aAsyncStack, nsIGlobalObject* aIncumbentGlobal) |
1014 | | : CallbackFunction(aCallback, aCallbackGlobal, aAsyncStack, aIncumbentGlobal) |
1015 | 0 | { |
1016 | 0 | MOZ_ASSERT(JS::IsCallable(mCallback)); |
1017 | 0 | } |
1018 | | |
1019 | | explicit inline RTCPeerConnectionErrorCallback(CallbackFunction* aOther) |
1020 | | : CallbackFunction(aOther) |
1021 | 0 | { |
1022 | 0 | } |
1023 | | |
1024 | | template <typename T> |
1025 | | inline void |
1026 | | Call(const T& thisVal, DOMException& error, ErrorResult& aRv, const char* aExecutionReason = nullptr, ExceptionHandling aExceptionHandling = eReportExceptions, JS::Realm* aRealm = nullptr) |
1027 | | { |
1028 | | MOZ_ASSERT(!aRv.Failed(), "Don't pass an already-failed ErrorResult to a callback!"); |
1029 | | if (!aExecutionReason) { |
1030 | | aExecutionReason = "RTCPeerConnectionErrorCallback"; |
1031 | | } |
1032 | | CallSetup s(this, aRv, aExecutionReason, aExceptionHandling, aRealm); |
1033 | | if (!s.GetContext()) { |
1034 | | MOZ_ASSERT(aRv.Failed()); |
1035 | | return; |
1036 | | } |
1037 | | JS::Rooted<JS::Value> thisValJS(s.GetContext()); |
1038 | | if (!ToJSValue(s.GetContext(), thisVal, &thisValJS)) { |
1039 | | aRv.Throw(NS_ERROR_FAILURE); |
1040 | | return; |
1041 | | } |
1042 | | return Call(s.GetContext(), thisValJS, error, aRv); |
1043 | | } |
1044 | | |
1045 | | inline void |
1046 | | Call(DOMException& error, ErrorResult& aRv, const char* aExecutionReason = nullptr, ExceptionHandling aExceptionHandling = eReportExceptions, JS::Realm* aRealm = nullptr) |
1047 | 0 | { |
1048 | 0 | MOZ_ASSERT(!aRv.Failed(), "Don't pass an already-failed ErrorResult to a callback!"); |
1049 | 0 | if (!aExecutionReason) { |
1050 | 0 | aExecutionReason = "RTCPeerConnectionErrorCallback"; |
1051 | 0 | } |
1052 | 0 | CallSetup s(this, aRv, aExecutionReason, aExceptionHandling, aRealm); |
1053 | 0 | if (!s.GetContext()) { |
1054 | 0 | MOZ_ASSERT(aRv.Failed()); |
1055 | 0 | return; |
1056 | 0 | } |
1057 | 0 | return Call(s.GetContext(), JS::UndefinedHandleValue, error, aRv); |
1058 | 0 | } |
1059 | | |
1060 | | template <typename T> |
1061 | | inline void |
1062 | | Call(const T& thisVal, DOMException& error, const char* aExecutionReason = nullptr) |
1063 | | { |
1064 | | return Call(thisVal, error, IgnoreErrors(), aExecutionReason); |
1065 | | } |
1066 | | |
1067 | | inline void |
1068 | | Call(DOMException& error, const char* aExecutionReason = nullptr) |
1069 | 0 | { |
1070 | 0 | return Call(error, IgnoreErrors(), aExecutionReason, eReportExceptions, nullptr); |
1071 | 0 | } |
1072 | | |
1073 | | inline bool |
1074 | | operator==(const RTCPeerConnectionErrorCallback& aOther) const |
1075 | 0 | { |
1076 | 0 | return CallbackFunction::operator==(aOther); |
1077 | 0 | } |
1078 | | |
1079 | | private: |
1080 | | void Call(JSContext* cx, JS::Handle<JS::Value> aThisVal, DOMException& error, ErrorResult& aRv); |
1081 | | }; |
1082 | | |
1083 | | |
1084 | | class RTCStatsCallback : public CallbackFunction |
1085 | | { |
1086 | | public: |
1087 | | explicit inline RTCStatsCallback(JSContext* aCx, JS::Handle<JSObject*> aCallback, JS::Handle<JSObject*> aCallbackGlobal, nsIGlobalObject* aIncumbentGlobal) |
1088 | | : CallbackFunction(aCx, aCallback, aCallbackGlobal, aIncumbentGlobal) |
1089 | 0 | { |
1090 | 0 | MOZ_ASSERT(JS::IsCallable(mCallback)); |
1091 | 0 | } |
1092 | | |
1093 | | explicit inline RTCStatsCallback(JSObject* aCallback, JSObject* aCallbackGlobal, const FastCallbackConstructor& ) |
1094 | | : CallbackFunction(aCallback, aCallbackGlobal, FastCallbackConstructor()) |
1095 | 0 | { |
1096 | 0 | MOZ_ASSERT(JS::IsCallable(mCallback)); |
1097 | 0 | } |
1098 | | |
1099 | | explicit inline RTCStatsCallback(JSObject* aCallback, JSObject* aCallbackGlobal, JSObject* aAsyncStack, nsIGlobalObject* aIncumbentGlobal) |
1100 | | : CallbackFunction(aCallback, aCallbackGlobal, aAsyncStack, aIncumbentGlobal) |
1101 | 0 | { |
1102 | 0 | MOZ_ASSERT(JS::IsCallable(mCallback)); |
1103 | 0 | } |
1104 | | |
1105 | | explicit inline RTCStatsCallback(CallbackFunction* aOther) |
1106 | | : CallbackFunction(aOther) |
1107 | 0 | { |
1108 | 0 | } |
1109 | | |
1110 | | template <typename T> |
1111 | | inline void |
1112 | | Call(const T& thisVal, RTCStatsReport& report, ErrorResult& aRv, const char* aExecutionReason = nullptr, ExceptionHandling aExceptionHandling = eReportExceptions, JS::Realm* aRealm = nullptr) |
1113 | | { |
1114 | | MOZ_ASSERT(!aRv.Failed(), "Don't pass an already-failed ErrorResult to a callback!"); |
1115 | | if (!aExecutionReason) { |
1116 | | aExecutionReason = "RTCStatsCallback"; |
1117 | | } |
1118 | | CallSetup s(this, aRv, aExecutionReason, aExceptionHandling, aRealm); |
1119 | | if (!s.GetContext()) { |
1120 | | MOZ_ASSERT(aRv.Failed()); |
1121 | | return; |
1122 | | } |
1123 | | JS::Rooted<JS::Value> thisValJS(s.GetContext()); |
1124 | | if (!ToJSValue(s.GetContext(), thisVal, &thisValJS)) { |
1125 | | aRv.Throw(NS_ERROR_FAILURE); |
1126 | | return; |
1127 | | } |
1128 | | return Call(s.GetContext(), thisValJS, report, aRv); |
1129 | | } |
1130 | | |
1131 | | inline void |
1132 | | Call(RTCStatsReport& report, ErrorResult& aRv, const char* aExecutionReason = nullptr, ExceptionHandling aExceptionHandling = eReportExceptions, JS::Realm* aRealm = nullptr) |
1133 | 0 | { |
1134 | 0 | MOZ_ASSERT(!aRv.Failed(), "Don't pass an already-failed ErrorResult to a callback!"); |
1135 | 0 | if (!aExecutionReason) { |
1136 | 0 | aExecutionReason = "RTCStatsCallback"; |
1137 | 0 | } |
1138 | 0 | CallSetup s(this, aRv, aExecutionReason, aExceptionHandling, aRealm); |
1139 | 0 | if (!s.GetContext()) { |
1140 | 0 | MOZ_ASSERT(aRv.Failed()); |
1141 | 0 | return; |
1142 | 0 | } |
1143 | 0 | return Call(s.GetContext(), JS::UndefinedHandleValue, report, aRv); |
1144 | 0 | } |
1145 | | |
1146 | | template <typename T> |
1147 | | inline void |
1148 | | Call(const T& thisVal, RTCStatsReport& report, const char* aExecutionReason = nullptr) |
1149 | | { |
1150 | | return Call(thisVal, report, IgnoreErrors(), aExecutionReason); |
1151 | | } |
1152 | | |
1153 | | inline void |
1154 | | Call(RTCStatsReport& report, const char* aExecutionReason = nullptr) |
1155 | 0 | { |
1156 | 0 | return Call(report, IgnoreErrors(), aExecutionReason, eReportExceptions, nullptr); |
1157 | 0 | } |
1158 | | |
1159 | | inline bool |
1160 | | operator==(const RTCStatsCallback& aOther) const |
1161 | 0 | { |
1162 | 0 | return CallbackFunction::operator==(aOther); |
1163 | 0 | } |
1164 | | |
1165 | | private: |
1166 | | void Call(JSContext* cx, JS::Handle<JS::Value> aThisVal, RTCStatsReport& report, ErrorResult& aRv); |
1167 | | }; |
1168 | | |
1169 | | |
1170 | | class mozPacketCallback : public CallbackFunction |
1171 | | { |
1172 | | public: |
1173 | | explicit inline mozPacketCallback(JSContext* aCx, JS::Handle<JSObject*> aCallback, JS::Handle<JSObject*> aCallbackGlobal, nsIGlobalObject* aIncumbentGlobal) |
1174 | | : CallbackFunction(aCx, aCallback, aCallbackGlobal, aIncumbentGlobal) |
1175 | 0 | { |
1176 | 0 | MOZ_ASSERT(JS::IsCallable(mCallback)); |
1177 | 0 | } |
1178 | | |
1179 | | explicit inline mozPacketCallback(JSObject* aCallback, JSObject* aCallbackGlobal, const FastCallbackConstructor& ) |
1180 | | : CallbackFunction(aCallback, aCallbackGlobal, FastCallbackConstructor()) |
1181 | 0 | { |
1182 | 0 | MOZ_ASSERT(JS::IsCallable(mCallback)); |
1183 | 0 | } |
1184 | | |
1185 | | explicit inline mozPacketCallback(JSObject* aCallback, JSObject* aCallbackGlobal, JSObject* aAsyncStack, nsIGlobalObject* aIncumbentGlobal) |
1186 | | : CallbackFunction(aCallback, aCallbackGlobal, aAsyncStack, aIncumbentGlobal) |
1187 | 0 | { |
1188 | 0 | MOZ_ASSERT(JS::IsCallable(mCallback)); |
1189 | 0 | } |
1190 | | |
1191 | | explicit inline mozPacketCallback(CallbackFunction* aOther) |
1192 | | : CallbackFunction(aOther) |
1193 | 0 | { |
1194 | 0 | } |
1195 | | |
1196 | | template <typename T> |
1197 | | inline void |
1198 | | Call(const T& thisVal, uint32_t level, mozPacketDumpType type, bool sending, JS::Handle<JSObject*> packet, ErrorResult& aRv, const char* aExecutionReason = nullptr, ExceptionHandling aExceptionHandling = eReportExceptions, JS::Realm* aRealm = nullptr) |
1199 | | { |
1200 | | MOZ_ASSERT(!aRv.Failed(), "Don't pass an already-failed ErrorResult to a callback!"); |
1201 | | if (!aExecutionReason) { |
1202 | | aExecutionReason = "mozPacketCallback"; |
1203 | | } |
1204 | | CallSetup s(this, aRv, aExecutionReason, aExceptionHandling, aRealm); |
1205 | | if (!s.GetContext()) { |
1206 | | MOZ_ASSERT(aRv.Failed()); |
1207 | | return; |
1208 | | } |
1209 | | JS::Rooted<JS::Value> thisValJS(s.GetContext()); |
1210 | | if (!ToJSValue(s.GetContext(), thisVal, &thisValJS)) { |
1211 | | aRv.Throw(NS_ERROR_FAILURE); |
1212 | | return; |
1213 | | } |
1214 | | return Call(s.GetContext(), thisValJS, level, type, sending, packet, aRv); |
1215 | | } |
1216 | | |
1217 | | inline void |
1218 | | Call(uint32_t level, mozPacketDumpType type, bool sending, JS::Handle<JSObject*> packet, ErrorResult& aRv, const char* aExecutionReason = nullptr, ExceptionHandling aExceptionHandling = eReportExceptions, JS::Realm* aRealm = nullptr) |
1219 | 0 | { |
1220 | 0 | MOZ_ASSERT(!aRv.Failed(), "Don't pass an already-failed ErrorResult to a callback!"); |
1221 | 0 | if (!aExecutionReason) { |
1222 | 0 | aExecutionReason = "mozPacketCallback"; |
1223 | 0 | } |
1224 | 0 | CallSetup s(this, aRv, aExecutionReason, aExceptionHandling, aRealm); |
1225 | 0 | if (!s.GetContext()) { |
1226 | 0 | MOZ_ASSERT(aRv.Failed()); |
1227 | 0 | return; |
1228 | 0 | } |
1229 | 0 | return Call(s.GetContext(), JS::UndefinedHandleValue, level, type, sending, packet, aRv); |
1230 | 0 | } |
1231 | | |
1232 | | template <typename T> |
1233 | | inline void |
1234 | | Call(const T& thisVal, uint32_t level, mozPacketDumpType type, bool sending, JS::Handle<JSObject*> packet, const char* aExecutionReason = nullptr) |
1235 | | { |
1236 | | return Call(thisVal, level, type, sending, packet, IgnoreErrors(), aExecutionReason); |
1237 | | } |
1238 | | |
1239 | | inline void |
1240 | | Call(uint32_t level, mozPacketDumpType type, bool sending, JS::Handle<JSObject*> packet, const char* aExecutionReason = nullptr) |
1241 | 0 | { |
1242 | 0 | return Call(level, type, sending, packet, IgnoreErrors(), aExecutionReason, eReportExceptions, nullptr); |
1243 | 0 | } |
1244 | | |
1245 | | inline bool |
1246 | | operator==(const mozPacketCallback& aOther) const |
1247 | 0 | { |
1248 | 0 | return CallbackFunction::operator==(aOther); |
1249 | 0 | } |
1250 | | |
1251 | | private: |
1252 | | void Call(JSContext* cx, JS::Handle<JS::Value> aThisVal, uint32_t level, mozPacketDumpType type, bool sending, JS::Handle<JSObject*> packet, ErrorResult& aRv); |
1253 | | }; |
1254 | | |
1255 | | |
1256 | | namespace binding_detail { |
1257 | | class FastRTCSessionDescriptionCallback : public RTCSessionDescriptionCallback |
1258 | | { |
1259 | | public: |
1260 | | explicit inline FastRTCSessionDescriptionCallback(JSObject* aCallback, JSObject* aCallbackGlobal) |
1261 | | : RTCSessionDescriptionCallback(aCallback, aCallbackGlobal, FastCallbackConstructor()) |
1262 | 0 | { |
1263 | 0 | } |
1264 | | |
1265 | | inline void |
1266 | | Trace(JSTracer* aTracer) |
1267 | 0 | { |
1268 | 0 | RTCSessionDescriptionCallback::Trace(aTracer); |
1269 | 0 | } |
1270 | | |
1271 | | inline void |
1272 | | FinishSlowJSInitIfMoreThanOneOwner(JSContext* aCx) |
1273 | 0 | { |
1274 | 0 | RTCSessionDescriptionCallback::FinishSlowJSInitIfMoreThanOneOwner(aCx); |
1275 | 0 | } |
1276 | | }; |
1277 | | } // namespace binding_detail |
1278 | | |
1279 | | |
1280 | | namespace binding_detail { |
1281 | | class FastRTCPeerConnectionErrorCallback : public RTCPeerConnectionErrorCallback |
1282 | | { |
1283 | | public: |
1284 | | explicit inline FastRTCPeerConnectionErrorCallback(JSObject* aCallback, JSObject* aCallbackGlobal) |
1285 | | : RTCPeerConnectionErrorCallback(aCallback, aCallbackGlobal, FastCallbackConstructor()) |
1286 | 0 | { |
1287 | 0 | } |
1288 | | |
1289 | | inline void |
1290 | | Trace(JSTracer* aTracer) |
1291 | 0 | { |
1292 | 0 | RTCPeerConnectionErrorCallback::Trace(aTracer); |
1293 | 0 | } |
1294 | | |
1295 | | inline void |
1296 | | FinishSlowJSInitIfMoreThanOneOwner(JSContext* aCx) |
1297 | 0 | { |
1298 | 0 | RTCPeerConnectionErrorCallback::FinishSlowJSInitIfMoreThanOneOwner(aCx); |
1299 | 0 | } |
1300 | | }; |
1301 | | } // namespace binding_detail |
1302 | | |
1303 | | |
1304 | | namespace binding_detail { |
1305 | | class FastRTCStatsCallback : public RTCStatsCallback |
1306 | | { |
1307 | | public: |
1308 | | explicit inline FastRTCStatsCallback(JSObject* aCallback, JSObject* aCallbackGlobal) |
1309 | | : RTCStatsCallback(aCallback, aCallbackGlobal, FastCallbackConstructor()) |
1310 | 0 | { |
1311 | 0 | } |
1312 | | |
1313 | | inline void |
1314 | | Trace(JSTracer* aTracer) |
1315 | 0 | { |
1316 | 0 | RTCStatsCallback::Trace(aTracer); |
1317 | 0 | } |
1318 | | |
1319 | | inline void |
1320 | | FinishSlowJSInitIfMoreThanOneOwner(JSContext* aCx) |
1321 | 0 | { |
1322 | 0 | RTCStatsCallback::FinishSlowJSInitIfMoreThanOneOwner(aCx); |
1323 | 0 | } |
1324 | | }; |
1325 | | } // namespace binding_detail |
1326 | | |
1327 | | |
1328 | | namespace binding_detail { |
1329 | | class FastmozPacketCallback : public mozPacketCallback |
1330 | | { |
1331 | | public: |
1332 | | explicit inline FastmozPacketCallback(JSObject* aCallback, JSObject* aCallbackGlobal) |
1333 | | : mozPacketCallback(aCallback, aCallbackGlobal, FastCallbackConstructor()) |
1334 | 0 | { |
1335 | 0 | } |
1336 | | |
1337 | | inline void |
1338 | | Trace(JSTracer* aTracer) |
1339 | 0 | { |
1340 | 0 | mozPacketCallback::Trace(aTracer); |
1341 | 0 | } |
1342 | | |
1343 | | inline void |
1344 | | FinishSlowJSInitIfMoreThanOneOwner(JSContext* aCx) |
1345 | 0 | { |
1346 | 0 | mozPacketCallback::FinishSlowJSInitIfMoreThanOneOwner(aCx); |
1347 | 0 | } |
1348 | | }; |
1349 | | } // namespace binding_detail |
1350 | | |
1351 | | |
1352 | | namespace RTCPeerConnection_Binding { |
1353 | | |
1354 | | typedef mozilla::dom::RTCPeerConnection NativeType; |
1355 | | |
1356 | | bool |
1357 | | ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj); |
1358 | | |
1359 | | const JSClass* |
1360 | | GetJSClass(); |
1361 | | |
1362 | | bool |
1363 | | Wrap(JSContext* aCx, mozilla::dom::RTCPeerConnection* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector); |
1364 | | |
1365 | | template <class T> |
1366 | | inline JSObject* Wrap(JSContext* aCx, T* aObject, JS::Handle<JSObject*> aGivenProto) |
1367 | 0 | { |
1368 | 0 | JS::Rooted<JSObject*> reflector(aCx); |
1369 | 0 | return Wrap(aCx, aObject, aObject, aGivenProto, &reflector) ? reflector.get() : nullptr; |
1370 | 0 | } |
1371 | | |
1372 | | // We declare this as an array so that retrieving a pointer to this |
1373 | | // binding's property hooks only requires compile/link-time resolvable |
1374 | | // address arithmetic. Declaring it as a pointer instead would require |
1375 | | // doing a run-time load to fetch a pointer to this binding's property |
1376 | | // hooks. And then structures which embedded a pointer to this structure |
1377 | | // would require a run-time load for proper initialization, which would |
1378 | | // then induce static constructors. Lots of static constructors. |
1379 | | extern const NativePropertyHooks sNativePropertyHooks[]; |
1380 | | |
1381 | | void |
1382 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal); |
1383 | | |
1384 | | inline JS::Handle<JSObject*> GetProtoObjectHandle(JSContext* aCx) |
1385 | 0 | { |
1386 | 0 | /* Get the interface prototype object for this class. This will create the |
1387 | 0 | object as needed. */ |
1388 | 0 | return GetPerInterfaceObjectHandle(aCx, prototypes::id::RTCPeerConnection, |
1389 | 0 | &CreateInterfaceObjects, |
1390 | 0 | /* aDefineOnGlobal = */ true); |
1391 | 0 |
|
1392 | 0 | } |
1393 | | |
1394 | | JSObject* |
1395 | | GetProtoObject(JSContext* aCx); |
1396 | | |
1397 | | inline JS::Handle<JSObject*> GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal = true) |
1398 | 0 | { |
1399 | 0 | /* Get the interface object for this class. This will create the object as |
1400 | 0 | needed. */ |
1401 | 0 |
|
1402 | 0 | return GetPerInterfaceObjectHandle(aCx, constructors::id::RTCPeerConnection, |
1403 | 0 | &CreateInterfaceObjects, |
1404 | 0 | aDefineOnGlobal); |
1405 | 0 | } |
1406 | | |
1407 | | JSObject* |
1408 | | GetConstructorObject(JSContext* aCx); |
1409 | | |
1410 | | } // namespace RTCPeerConnection_Binding |
1411 | | |
1412 | | |
1413 | | |
1414 | | class RTCPeerConnectionJSImpl : public CallbackInterface |
1415 | | { |
1416 | | public: |
1417 | | explicit inline RTCPeerConnectionJSImpl(JSContext* aCx, JS::Handle<JSObject*> aCallback, JS::Handle<JSObject*> aCallbackGlobal, nsIGlobalObject* aIncumbentGlobal) |
1418 | | : CallbackInterface(aCx, aCallback, aCallbackGlobal, aIncumbentGlobal) |
1419 | 0 | { |
1420 | 0 | } |
1421 | | |
1422 | | explicit inline RTCPeerConnectionJSImpl(JSObject* aCallback, JSObject* aCallbackGlobal, const FastCallbackConstructor& ) |
1423 | | : CallbackInterface(aCallback, aCallbackGlobal, FastCallbackConstructor()) |
1424 | 0 | { |
1425 | 0 | } |
1426 | | |
1427 | | explicit inline RTCPeerConnectionJSImpl(JSObject* aCallback, JSObject* aCallbackGlobal, JSObject* aAsyncStack, nsIGlobalObject* aIncumbentGlobal) |
1428 | | : CallbackInterface(aCallback, aCallbackGlobal, aAsyncStack, aIncumbentGlobal) |
1429 | 0 | { |
1430 | 0 | } |
1431 | | |
1432 | | void SetIdentityProvider(const nsAString& provider, const RTCIdentityProviderOptions& options, ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
1433 | | |
1434 | | already_AddRefed<Promise> GetIdentityAssertion(ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
1435 | | |
1436 | | already_AddRefed<Promise> CreateOffer(const RTCOfferOptions& options, ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
1437 | | |
1438 | | already_AddRefed<Promise> CreateOffer(RTCSessionDescriptionCallback& successCallback, RTCPeerConnectionErrorCallback& failureCallback, const RTCOfferOptions& options, ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
1439 | | |
1440 | | already_AddRefed<Promise> CreateAnswer(const RTCAnswerOptions& options, ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
1441 | | |
1442 | | already_AddRefed<Promise> CreateAnswer(RTCSessionDescriptionCallback& successCallback, RTCPeerConnectionErrorCallback& failureCallback, ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
1443 | | |
1444 | | already_AddRefed<Promise> SetLocalDescription(const RTCSessionDescriptionInit& description, ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
1445 | | |
1446 | | already_AddRefed<Promise> SetLocalDescription(const RTCSessionDescriptionInit& description, VoidFunction& successCallback, RTCPeerConnectionErrorCallback& failureCallback, ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
1447 | | |
1448 | | already_AddRefed<Promise> SetRemoteDescription(const RTCSessionDescriptionInit& description, ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
1449 | | |
1450 | | already_AddRefed<Promise> SetRemoteDescription(const RTCSessionDescriptionInit& description, VoidFunction& successCallback, RTCPeerConnectionErrorCallback& failureCallback, ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
1451 | | |
1452 | | already_AddRefed<Promise> AddIceCandidate(const Nullable<RTCIceCandidateInitOrRTCIceCandidate>& candidate, ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
1453 | | |
1454 | | already_AddRefed<Promise> AddIceCandidate(RTCIceCandidate& candidate, VoidFunction& successCallback, RTCPeerConnectionErrorCallback& failureCallback, ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
1455 | | |
1456 | | void GetConfiguration(RTCConfiguration& aRetVal, ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
1457 | | |
1458 | | void GetLocalStreams(nsTArray<RefPtr<DOMMediaStream>>& aRetVal, ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
1459 | | |
1460 | | void GetRemoteStreams(nsTArray<RefPtr<DOMMediaStream>>& aRetVal, ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
1461 | | |
1462 | | void AddStream(DOMMediaStream& stream, ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
1463 | | |
1464 | | already_AddRefed<RTCRtpSender> AddTrack(MediaStreamTrack& track, DOMMediaStream& stream, const nsTArray<OwningNonNull<DOMMediaStream>>& moreStreams, ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
1465 | | |
1466 | | void RemoveTrack(RTCRtpSender& sender, ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
1467 | | |
1468 | | already_AddRefed<RTCRtpTransceiver> AddTransceiver(const MediaStreamTrackOrString& trackOrKind, const RTCRtpTransceiverInit& init, ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
1469 | | |
1470 | | void GetSenders(nsTArray<RefPtr<RTCRtpSender>>& aRetVal, ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
1471 | | |
1472 | | void GetReceivers(nsTArray<RefPtr<RTCRtpReceiver>>& aRetVal, ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
1473 | | |
1474 | | void GetTransceivers(nsTArray<RefPtr<RTCRtpTransceiver>>& aRetVal, ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
1475 | | |
1476 | | double MozGetNowInRtpSourceReferenceTime(ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
1477 | | |
1478 | | void MozInsertAudioLevelForContributingSource(RTCRtpReceiver& receiver, uint32_t source, double timestamp, bool hasLevel, int8_t level, ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
1479 | | |
1480 | | void MozAddRIDExtension(RTCRtpReceiver& receiver, uint16_t extensionId, ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
1481 | | |
1482 | | void MozAddRIDFilter(RTCRtpReceiver& receiver, const nsAString& rid, ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
1483 | | |
1484 | | void MozSetPacketCallback(mozPacketCallback& callback, ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
1485 | | |
1486 | | void MozEnablePacketDump(uint32_t level, mozPacketDumpType type, bool sending, ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
1487 | | |
1488 | | void MozDisablePacketDump(uint32_t level, mozPacketDumpType type, bool sending, ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
1489 | | |
1490 | | void Close(ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
1491 | | |
1492 | | already_AddRefed<Promise> GetStats(const Optional<MediaStreamTrack*>& selector, ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
1493 | | |
1494 | | already_AddRefed<Promise> GetStats(MediaStreamTrack* selector, RTCStatsCallback& successCallback, RTCPeerConnectionErrorCallback& failureCallback, ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
1495 | | |
1496 | | already_AddRefed<nsDOMDataChannel> CreateDataChannel(const nsAString& label, const RTCDataChannelInit& dataChannelDict, ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
1497 | | |
1498 | | void __Init(const RTCConfiguration& configuration, const Optional<JS::Handle<JSObject*>>& constraints, ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
1499 | | |
1500 | | inline bool |
1501 | | operator==(const RTCPeerConnectionJSImpl& aOther) const |
1502 | 0 | { |
1503 | 0 | return CallbackInterface::operator==(aOther); |
1504 | 0 | } |
1505 | | |
1506 | | already_AddRefed<RTCSessionDescription> GetLocalDescription(ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
1507 | | |
1508 | | already_AddRefed<RTCSessionDescription> GetCurrentLocalDescription(ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
1509 | | |
1510 | | already_AddRefed<RTCSessionDescription> GetPendingLocalDescription(ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
1511 | | |
1512 | | already_AddRefed<RTCSessionDescription> GetRemoteDescription(ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
1513 | | |
1514 | | already_AddRefed<RTCSessionDescription> GetCurrentRemoteDescription(ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
1515 | | |
1516 | | already_AddRefed<RTCSessionDescription> GetPendingRemoteDescription(ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
1517 | | |
1518 | | RTCSignalingState GetSignalingState(ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
1519 | | |
1520 | | Nullable<bool> GetCanTrickleIceCandidates(ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
1521 | | |
1522 | | RTCIceGatheringState GetIceGatheringState(ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
1523 | | |
1524 | | RTCIceConnectionState GetIceConnectionState(ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
1525 | | |
1526 | | already_AddRefed<Promise> GetPeerIdentity(ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
1527 | | |
1528 | | void GetIdpLoginUrl(nsString& aRetVal, ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
1529 | | |
1530 | | void GetId(nsString& aRetVal, ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
1531 | | |
1532 | | already_AddRefed<EventHandlerNonNull> GetOnnegotiationneeded(ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
1533 | | |
1534 | | already_AddRefed<EventHandlerNonNull> GetOnicecandidate(ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
1535 | | |
1536 | | already_AddRefed<EventHandlerNonNull> GetOnsignalingstatechange(ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
1537 | | |
1538 | | already_AddRefed<EventHandlerNonNull> GetOnaddstream(ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
1539 | | |
1540 | | already_AddRefed<EventHandlerNonNull> GetOnaddtrack(ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
1541 | | |
1542 | | already_AddRefed<EventHandlerNonNull> GetOntrack(ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
1543 | | |
1544 | | already_AddRefed<EventHandlerNonNull> GetOnremovestream(ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
1545 | | |
1546 | | already_AddRefed<EventHandlerNonNull> GetOniceconnectionstatechange(ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
1547 | | |
1548 | | already_AddRefed<EventHandlerNonNull> GetOnicegatheringstatechange(ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
1549 | | |
1550 | | already_AddRefed<EventHandlerNonNull> GetOndatachannel(ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
1551 | | |
1552 | | void SetId(const nsAString& arg, ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
1553 | | |
1554 | | void SetOnnegotiationneeded(EventHandlerNonNull* arg, ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
1555 | | |
1556 | | void SetOnicecandidate(EventHandlerNonNull* arg, ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
1557 | | |
1558 | | void SetOnsignalingstatechange(EventHandlerNonNull* arg, ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
1559 | | |
1560 | | void SetOnaddstream(EventHandlerNonNull* arg, ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
1561 | | |
1562 | | void SetOnaddtrack(EventHandlerNonNull* arg, ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
1563 | | |
1564 | | void SetOntrack(EventHandlerNonNull* arg, ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
1565 | | |
1566 | | void SetOnremovestream(EventHandlerNonNull* arg, ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
1567 | | |
1568 | | void SetOniceconnectionstatechange(EventHandlerNonNull* arg, ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
1569 | | |
1570 | | void SetOnicegatheringstatechange(EventHandlerNonNull* arg, ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
1571 | | |
1572 | | void SetOndatachannel(EventHandlerNonNull* arg, ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
1573 | | |
1574 | | private: |
1575 | | static bool |
1576 | | InitIds(JSContext* cx, RTCPeerConnectionAtoms* atomsCache); |
1577 | | }; |
1578 | | |
1579 | | |
1580 | | class RTCPeerConnection : public mozilla::DOMEventTargetHelper |
1581 | | { |
1582 | | public: |
1583 | | NS_DECL_ISUPPORTS_INHERITED |
1584 | | NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(RTCPeerConnection, mozilla::DOMEventTargetHelper) |
1585 | | |
1586 | | private: |
1587 | | RefPtr<RTCPeerConnectionJSImpl> mImpl; |
1588 | | nsCOMPtr<nsIGlobalObject> mParent; |
1589 | | |
1590 | | public: |
1591 | | RTCPeerConnection(JS::Handle<JSObject*> aJSImplObject, JS::Handle<JSObject*> aJSImplGlobal, nsIGlobalObject* aParent); |
1592 | | |
1593 | | protected: |
1594 | | virtual ~RTCPeerConnection(); |
1595 | | |
1596 | | public: |
1597 | | nsISupports* GetParentObject() const; |
1598 | | |
1599 | | virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override; |
1600 | | |
1601 | | static already_AddRefed<RTCPeerConnection> Constructor(const GlobalObject& global, JSContext* cx, const RTCConfiguration& configuration, const Optional<JS::Handle<JSObject*>>& constraints, ErrorResult& aRv, JS::Handle<JSObject*> aGivenProto = nullptr); |
1602 | | |
1603 | | void SetIdentityProvider(const nsAString& provider, const RTCIdentityProviderOptions& options, ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
1604 | | |
1605 | | // Return a raw pointer here to avoid refcounting, but make sure it's safe (the object should be kept alive by the callee). |
1606 | | already_AddRefed<Promise> GetIdentityAssertion(ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
1607 | | |
1608 | | // Return a raw pointer here to avoid refcounting, but make sure it's safe (the object should be kept alive by the callee). |
1609 | | already_AddRefed<Promise> CreateOffer(const RTCOfferOptions& options, ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
1610 | | // Return a raw pointer here to avoid refcounting, but make sure it's safe (the object should be kept alive by the callee). |
1611 | | already_AddRefed<Promise> CreateOffer(RTCSessionDescriptionCallback& successCallback, RTCPeerConnectionErrorCallback& failureCallback, const RTCOfferOptions& options, ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
1612 | | |
1613 | | // Return a raw pointer here to avoid refcounting, but make sure it's safe (the object should be kept alive by the callee). |
1614 | | already_AddRefed<Promise> CreateAnswer(const RTCAnswerOptions& options, ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
1615 | | // Return a raw pointer here to avoid refcounting, but make sure it's safe (the object should be kept alive by the callee). |
1616 | | already_AddRefed<Promise> CreateAnswer(RTCSessionDescriptionCallback& successCallback, RTCPeerConnectionErrorCallback& failureCallback, ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
1617 | | |
1618 | | // Return a raw pointer here to avoid refcounting, but make sure it's safe (the object should be kept alive by the callee). |
1619 | | already_AddRefed<Promise> SetLocalDescription(const RTCSessionDescriptionInit& description, ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
1620 | | // Return a raw pointer here to avoid refcounting, but make sure it's safe (the object should be kept alive by the callee). |
1621 | | already_AddRefed<Promise> SetLocalDescription(const RTCSessionDescriptionInit& description, VoidFunction& successCallback, RTCPeerConnectionErrorCallback& failureCallback, ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
1622 | | |
1623 | | // Return a raw pointer here to avoid refcounting, but make sure it's safe (the object should be kept alive by the callee). |
1624 | | already_AddRefed<Promise> SetRemoteDescription(const RTCSessionDescriptionInit& description, ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
1625 | | // Return a raw pointer here to avoid refcounting, but make sure it's safe (the object should be kept alive by the callee). |
1626 | | already_AddRefed<Promise> SetRemoteDescription(const RTCSessionDescriptionInit& description, VoidFunction& successCallback, RTCPeerConnectionErrorCallback& failureCallback, ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
1627 | | |
1628 | | // Return a raw pointer here to avoid refcounting, but make sure it's safe (the object should be kept alive by the callee). |
1629 | | already_AddRefed<RTCSessionDescription> GetLocalDescription(ErrorResult& aRv, JS::Realm* aRealm = nullptr) const; |
1630 | | |
1631 | | // Return a raw pointer here to avoid refcounting, but make sure it's safe (the object should be kept alive by the callee). |
1632 | | already_AddRefed<RTCSessionDescription> GetCurrentLocalDescription(ErrorResult& aRv, JS::Realm* aRealm = nullptr) const; |
1633 | | |
1634 | | // Return a raw pointer here to avoid refcounting, but make sure it's safe (the object should be kept alive by the callee). |
1635 | | already_AddRefed<RTCSessionDescription> GetPendingLocalDescription(ErrorResult& aRv, JS::Realm* aRealm = nullptr) const; |
1636 | | |
1637 | | // Return a raw pointer here to avoid refcounting, but make sure it's safe (the object should be kept alive by the callee). |
1638 | | already_AddRefed<RTCSessionDescription> GetRemoteDescription(ErrorResult& aRv, JS::Realm* aRealm = nullptr) const; |
1639 | | |
1640 | | // Return a raw pointer here to avoid refcounting, but make sure it's safe (the object should be kept alive by the callee). |
1641 | | already_AddRefed<RTCSessionDescription> GetCurrentRemoteDescription(ErrorResult& aRv, JS::Realm* aRealm = nullptr) const; |
1642 | | |
1643 | | // Return a raw pointer here to avoid refcounting, but make sure it's safe (the object should be kept alive by the callee). |
1644 | | already_AddRefed<RTCSessionDescription> GetPendingRemoteDescription(ErrorResult& aRv, JS::Realm* aRealm = nullptr) const; |
1645 | | |
1646 | | RTCSignalingState GetSignalingState(ErrorResult& aRv, JS::Realm* aRealm = nullptr) const; |
1647 | | |
1648 | | // Return a raw pointer here to avoid refcounting, but make sure it's safe (the object should be kept alive by the callee). |
1649 | | already_AddRefed<Promise> AddIceCandidate(const Nullable<RTCIceCandidateInitOrRTCIceCandidate>& candidate, ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
1650 | | // Return a raw pointer here to avoid refcounting, but make sure it's safe (the object should be kept alive by the callee). |
1651 | | already_AddRefed<Promise> AddIceCandidate(RTCIceCandidate& candidate, VoidFunction& successCallback, RTCPeerConnectionErrorCallback& failureCallback, ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
1652 | | |
1653 | | Nullable<bool> GetCanTrickleIceCandidates(ErrorResult& aRv, JS::Realm* aRealm = nullptr) const; |
1654 | | |
1655 | | RTCIceGatheringState GetIceGatheringState(ErrorResult& aRv, JS::Realm* aRealm = nullptr) const; |
1656 | | |
1657 | | RTCIceConnectionState GetIceConnectionState(ErrorResult& aRv, JS::Realm* aRealm = nullptr) const; |
1658 | | |
1659 | | // Return a raw pointer here to avoid refcounting, but make sure it's safe (the object should be kept alive by the callee). |
1660 | | already_AddRefed<Promise> GetPeerIdentity(ErrorResult& aRv, JS::Realm* aRealm = nullptr) const; |
1661 | | |
1662 | | void GetIdpLoginUrl(nsString& aRetVal, ErrorResult& aRv, JS::Realm* aRealm = nullptr) const; |
1663 | | |
1664 | | void GetId(nsString& aRetVal, ErrorResult& aRv, JS::Realm* aRealm = nullptr) const; |
1665 | | |
1666 | | void SetId(const nsAString& arg, ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
1667 | | |
1668 | | void GetConfiguration(RTCConfiguration& aRetVal, ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
1669 | | |
1670 | | void GetLocalStreams(nsTArray<RefPtr<DOMMediaStream>>& aRetVal, ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
1671 | | |
1672 | | void GetRemoteStreams(nsTArray<RefPtr<DOMMediaStream>>& aRetVal, ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
1673 | | |
1674 | | void AddStream(DOMMediaStream& stream, ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
1675 | | |
1676 | | // Return a raw pointer here to avoid refcounting, but make sure it's safe (the object should be kept alive by the callee). |
1677 | | already_AddRefed<RTCRtpSender> AddTrack(MediaStreamTrack& track, DOMMediaStream& stream, const Sequence<OwningNonNull<DOMMediaStream>>& moreStreams, ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
1678 | | |
1679 | | void RemoveTrack(RTCRtpSender& sender, ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
1680 | | |
1681 | | // Return a raw pointer here to avoid refcounting, but make sure it's safe (the object should be kept alive by the callee). |
1682 | | already_AddRefed<RTCRtpTransceiver> AddTransceiver(const MediaStreamTrackOrString& trackOrKind, const RTCRtpTransceiverInit& init, ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
1683 | | |
1684 | | void GetSenders(nsTArray<RefPtr<RTCRtpSender>>& aRetVal, ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
1685 | | |
1686 | | void GetReceivers(nsTArray<RefPtr<RTCRtpReceiver>>& aRetVal, ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
1687 | | |
1688 | | void GetTransceivers(nsTArray<RefPtr<RTCRtpTransceiver>>& aRetVal, ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
1689 | | |
1690 | | double MozGetNowInRtpSourceReferenceTime(ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
1691 | | |
1692 | | void MozInsertAudioLevelForContributingSource(RTCRtpReceiver& receiver, uint32_t source, double timestamp, bool hasLevel, int8_t level, ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
1693 | | |
1694 | | void MozAddRIDExtension(RTCRtpReceiver& receiver, uint16_t extensionId, ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
1695 | | |
1696 | | void MozAddRIDFilter(RTCRtpReceiver& receiver, const nsAString& rid, ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
1697 | | |
1698 | | void MozSetPacketCallback(mozPacketCallback& callback, ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
1699 | | |
1700 | | void MozEnablePacketDump(uint32_t level, mozPacketDumpType type, bool sending, ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
1701 | | |
1702 | | void MozDisablePacketDump(uint32_t level, mozPacketDumpType type, bool sending, ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
1703 | | |
1704 | | void Close(ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
1705 | | |
1706 | | already_AddRefed<EventHandlerNonNull> GetOnnegotiationneeded(ErrorResult& aRv, JS::Realm* aRealm = nullptr) const; |
1707 | | |
1708 | | void SetOnnegotiationneeded(EventHandlerNonNull* arg, ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
1709 | | |
1710 | | already_AddRefed<EventHandlerNonNull> GetOnicecandidate(ErrorResult& aRv, JS::Realm* aRealm = nullptr) const; |
1711 | | |
1712 | | void SetOnicecandidate(EventHandlerNonNull* arg, ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
1713 | | |
1714 | | already_AddRefed<EventHandlerNonNull> GetOnsignalingstatechange(ErrorResult& aRv, JS::Realm* aRealm = nullptr) const; |
1715 | | |
1716 | | void SetOnsignalingstatechange(EventHandlerNonNull* arg, ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
1717 | | |
1718 | | already_AddRefed<EventHandlerNonNull> GetOnaddstream(ErrorResult& aRv, JS::Realm* aRealm = nullptr) const; |
1719 | | |
1720 | | void SetOnaddstream(EventHandlerNonNull* arg, ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
1721 | | |
1722 | | already_AddRefed<EventHandlerNonNull> GetOnaddtrack(ErrorResult& aRv, JS::Realm* aRealm = nullptr) const; |
1723 | | |
1724 | | void SetOnaddtrack(EventHandlerNonNull* arg, ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
1725 | | |
1726 | | already_AddRefed<EventHandlerNonNull> GetOntrack(ErrorResult& aRv, JS::Realm* aRealm = nullptr) const; |
1727 | | |
1728 | | void SetOntrack(EventHandlerNonNull* arg, ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
1729 | | |
1730 | | already_AddRefed<EventHandlerNonNull> GetOnremovestream(ErrorResult& aRv, JS::Realm* aRealm = nullptr) const; |
1731 | | |
1732 | | void SetOnremovestream(EventHandlerNonNull* arg, ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
1733 | | |
1734 | | already_AddRefed<EventHandlerNonNull> GetOniceconnectionstatechange(ErrorResult& aRv, JS::Realm* aRealm = nullptr) const; |
1735 | | |
1736 | | void SetOniceconnectionstatechange(EventHandlerNonNull* arg, ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
1737 | | |
1738 | | already_AddRefed<EventHandlerNonNull> GetOnicegatheringstatechange(ErrorResult& aRv, JS::Realm* aRealm = nullptr) const; |
1739 | | |
1740 | | void SetOnicegatheringstatechange(EventHandlerNonNull* arg, ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
1741 | | |
1742 | | // Return a raw pointer here to avoid refcounting, but make sure it's safe (the object should be kept alive by the callee). |
1743 | | already_AddRefed<Promise> GetStats(const Optional<MediaStreamTrack*>& selector, ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
1744 | | // Return a raw pointer here to avoid refcounting, but make sure it's safe (the object should be kept alive by the callee). |
1745 | | already_AddRefed<Promise> GetStats(MediaStreamTrack* selector, RTCStatsCallback& successCallback, RTCPeerConnectionErrorCallback& failureCallback, ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
1746 | | |
1747 | | // Return a raw pointer here to avoid refcounting, but make sure it's safe (the object should be kept alive by the callee). |
1748 | | already_AddRefed<nsDOMDataChannel> CreateDataChannel(const nsAString& label, const RTCDataChannelInit& dataChannelDict, ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
1749 | | |
1750 | | already_AddRefed<EventHandlerNonNull> GetOndatachannel(ErrorResult& aRv, JS::Realm* aRealm = nullptr) const; |
1751 | | |
1752 | | void SetOndatachannel(EventHandlerNonNull* arg, ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
1753 | | |
1754 | | static bool |
1755 | | _Create(JSContext* cx, unsigned argc, JS::Value* vp); |
1756 | | }; |
1757 | | |
1758 | | |
1759 | | } // namespace dom |
1760 | | } // namespace mozilla |
1761 | | |
1762 | | #endif // mozilla_dom_RTCPeerConnectionBinding_h |