Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dist/include/mozilla/dom/RTCRtpTransceiverBinding.h
Line
Count
Source (jump to first uncovered line)
1
/* THIS FILE IS AUTOGENERATED FROM RTCRtpTransceiver.webidl BY Codegen.py - DO NOT EDIT */
2
3
#ifndef mozilla_dom_RTCRtpTransceiverBinding_h
4
#define mozilla_dom_RTCRtpTransceiverBinding_h
5
6
#include "DOMMediaStream.h"
7
#include "GeckoProfiler.h"
8
#include "js/RootingAPI.h"
9
#include "jspubtd.h"
10
#include "mozilla/ErrorResult.h"
11
#include "mozilla/dom/BindingDeclarations.h"
12
#include "mozilla/dom/CallbackInterface.h"
13
#include "mozilla/dom/Nullable.h"
14
#include "mozilla/dom/PrototypeList.h"
15
#include "mozilla/dom/ToJSValue.h"
16
#include "nsWeakReference.h"
17
18
namespace mozilla {
19
20
class DOMMediaStream;
21
22
namespace dom {
23
24
struct NativePropertyHooks;
25
class ProtoAndIfaceCache;
26
class RTCRtpReceiver;
27
class RTCRtpSender;
28
class RTCRtpTransceiver;
29
struct RTCRtpTransceiverAtoms;
30
struct RTCRtpTransceiverInitAtoms;
31
32
} // namespace dom
33
34
} // namespace mozilla
35
36
namespace mozilla {
37
namespace dom {
38
39
enum class RTCRtpTransceiverDirection : uint8_t {
40
  Sendrecv,
41
  Sendonly,
42
  Recvonly,
43
  Inactive,
44
  EndGuard_
45
};
46
47
namespace RTCRtpTransceiverDirectionValues {
48
extern const EnumEntry strings[5];
49
} // namespace RTCRtpTransceiverDirectionValues
50
51
bool
52
ToJSValue(JSContext* aCx, RTCRtpTransceiverDirection aArgument, JS::MutableHandle<JS::Value> aValue);
53
54
55
struct RTCRtpTransceiverInit : public DictionaryBase
56
{
57
  MOZ_INIT_OUTSIDE_CTOR RTCRtpTransceiverDirection mDirection;
58
  MOZ_INIT_OUTSIDE_CTOR Sequence<OwningNonNull<mozilla::DOMMediaStream>> mStreams;
59
60
  RTCRtpTransceiverInit();
61
62
  explicit inline RTCRtpTransceiverInit(const FastDictionaryInitializer& )
63
0
  {
64
0
    // Do nothing here; this is used by our "Fast" subclass
65
0
  }
66
67
  explicit inline RTCRtpTransceiverInit(const RTCRtpTransceiverInit& aOther)
68
0
  {
69
0
    *this = aOther;
70
0
  }
71
72
  bool
73
  Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false);
74
75
  bool
76
  ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const;
77
78
  void
79
  TraceDictionary(JSTracer* trc);
80
81
  inline void
82
  TraverseForCC(nsCycleCollectionTraversalCallback& aCallback, uint32_t aFlags)
83
0
  {
84
0
    ImplCycleCollectionTraverse(aCallback, mStreams, "mStreams", aFlags);
85
0
  }
86
87
  inline void
88
  UnlinkForCC()
89
0
  {
90
0
    ImplCycleCollectionUnlink(mStreams);
91
0
  }
92
93
  RTCRtpTransceiverInit&
94
  operator=(const RTCRtpTransceiverInit& aOther);
95
96
private:
97
  static bool
98
  InitIds(JSContext* cx, RTCRtpTransceiverInitAtoms* atomsCache);
99
};
100
101
namespace binding_detail {
102
struct FastRTCRtpTransceiverInit : public RTCRtpTransceiverInit
103
{
104
  inline FastRTCRtpTransceiverInit()
105
    : RTCRtpTransceiverInit(FastDictionaryInitializer())
106
0
  {
107
0
    // Doesn't matter what int we pass to the parent constructor
108
0
  }
109
};
110
} // namespace binding_detail
111
112
113
namespace RTCRtpTransceiver_Binding {
114
115
  typedef mozilla::dom::RTCRtpTransceiver NativeType;
116
117
  bool
118
  ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj);
119
120
  const JSClass*
121
  GetJSClass();
122
123
  bool
124
  Wrap(JSContext* aCx, mozilla::dom::RTCRtpTransceiver* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector);
125
126
  template <class T>
127
  inline JSObject* Wrap(JSContext* aCx, T* aObject, JS::Handle<JSObject*> aGivenProto)
128
0
  {
129
0
    JS::Rooted<JSObject*> reflector(aCx);
130
0
    return Wrap(aCx, aObject, aObject, aGivenProto, &reflector) ? reflector.get() : nullptr;
131
0
  }
132
133
  // We declare this as an array so that retrieving a pointer to this
134
  // binding's property hooks only requires compile/link-time resolvable
135
  // address arithmetic.  Declaring it as a pointer instead would require
136
  // doing a run-time load to fetch a pointer to this binding's property
137
  // hooks.  And then structures which embedded a pointer to this structure
138
  // would require a run-time load for proper initialization, which would
139
  // then induce static constructors.  Lots of static constructors.
140
  extern const NativePropertyHooks sNativePropertyHooks[];
141
142
  void
143
  CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal);
144
145
  inline JS::Handle<JSObject*> GetProtoObjectHandle(JSContext* aCx)
146
0
  {
147
0
    /* Get the interface prototype object for this class.  This will create the
148
0
       object as needed. */
149
0
    return GetPerInterfaceObjectHandle(aCx, prototypes::id::RTCRtpTransceiver,
150
0
                                       &CreateInterfaceObjects,
151
0
                                       /* aDefineOnGlobal = */ true);
152
0
153
0
  }
154
155
  inline JS::Handle<JSObject*> GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal = true)
156
0
  {
157
0
    /* Get the interface object for this class.  This will create the object as
158
0
       needed. */
159
0
160
0
    return GetPerInterfaceObjectHandle(aCx, constructors::id::RTCRtpTransceiver,
161
0
                                       &CreateInterfaceObjects,
162
0
                                       aDefineOnGlobal);
163
0
  }
164
165
  JSObject*
166
  GetConstructorObject(JSContext* aCx);
167
168
} // namespace RTCRtpTransceiver_Binding
169
170
171
172
class RTCRtpTransceiverJSImpl : public CallbackInterface
173
{
174
public:
175
  explicit inline RTCRtpTransceiverJSImpl(JSContext* aCx, JS::Handle<JSObject*> aCallback, JS::Handle<JSObject*> aCallbackGlobal, nsIGlobalObject* aIncumbentGlobal)
176
    : CallbackInterface(aCx, aCallback, aCallbackGlobal, aIncumbentGlobal)
177
0
  {
178
0
  }
179
180
  explicit inline RTCRtpTransceiverJSImpl(JSObject* aCallback, JSObject* aCallbackGlobal, const FastCallbackConstructor& )
181
    : CallbackInterface(aCallback, aCallbackGlobal, FastCallbackConstructor())
182
0
  {
183
0
  }
184
185
  explicit inline RTCRtpTransceiverJSImpl(JSObject* aCallback, JSObject* aCallbackGlobal, JSObject* aAsyncStack, nsIGlobalObject* aIncumbentGlobal)
186
    : CallbackInterface(aCallback, aCallbackGlobal, aAsyncStack, aIncumbentGlobal)
187
0
  {
188
0
  }
189
190
  void Stop(ErrorResult& aRv, JS::Realm* aRealm = nullptr);
191
192
  void SetRemoteTrackId(const nsAString& trackId, ErrorResult& aRv, JS::Realm* aRealm = nullptr);
193
194
  bool RemoteTrackIdIs(const nsAString& trackId, ErrorResult& aRv, JS::Realm* aRealm = nullptr);
195
196
  void GetRemoteTrackId(nsString& aRetVal, ErrorResult& aRv, JS::Realm* aRealm = nullptr);
197
198
  void SetAddTrackMagic(ErrorResult& aRv, JS::Realm* aRealm = nullptr);
199
200
  void SetCurrentDirection(RTCRtpTransceiverDirection direction, ErrorResult& aRv, JS::Realm* aRealm = nullptr);
201
202
  void SetDirectionInternal(RTCRtpTransceiverDirection direction, ErrorResult& aRv, JS::Realm* aRealm = nullptr);
203
204
  void SetMid(const nsAString& mid, ErrorResult& aRv, JS::Realm* aRealm = nullptr);
205
206
  void UnsetMid(ErrorResult& aRv, JS::Realm* aRealm = nullptr);
207
208
  void SetStopped(ErrorResult& aRv, JS::Realm* aRealm = nullptr);
209
210
  void GetKind(nsString& aRetVal, ErrorResult& aRv, JS::Realm* aRealm = nullptr);
211
212
  bool HasBeenUsedToSend(ErrorResult& aRv, JS::Realm* aRealm = nullptr);
213
214
  void Sync(ErrorResult& aRv, JS::Realm* aRealm = nullptr);
215
216
  void InsertDTMF(const nsAString& tones, uint32_t duration, uint32_t interToneGap, ErrorResult& aRv, JS::Realm* aRealm = nullptr);
217
218
  inline bool
219
  operator==(const RTCRtpTransceiverJSImpl& aOther) const
220
0
  {
221
0
    return CallbackInterface::operator==(aOther);
222
0
  }
223
224
  void GetMid(nsString& aRetVal, ErrorResult& aRv, JS::Realm* aRealm = nullptr);
225
226
  already_AddRefed<RTCRtpSender> GetSender(ErrorResult& aRv, JS::Realm* aRealm = nullptr);
227
228
  already_AddRefed<RTCRtpReceiver> GetReceiver(ErrorResult& aRv, JS::Realm* aRealm = nullptr);
229
230
  bool GetStopped(ErrorResult& aRv, JS::Realm* aRealm = nullptr);
231
232
  RTCRtpTransceiverDirection GetDirection(ErrorResult& aRv, JS::Realm* aRealm = nullptr);
233
234
  Nullable<RTCRtpTransceiverDirection> GetCurrentDirection(ErrorResult& aRv, JS::Realm* aRealm = nullptr);
235
236
  bool GetAddTrackMagic(ErrorResult& aRv, JS::Realm* aRealm = nullptr);
237
238
  bool GetShouldRemove(ErrorResult& aRv, JS::Realm* aRealm = nullptr);
239
240
  void SetDirection(RTCRtpTransceiverDirection arg, ErrorResult& aRv, JS::Realm* aRealm = nullptr);
241
242
  void SetShouldRemove(bool arg, ErrorResult& aRv, JS::Realm* aRealm = nullptr);
243
244
private:
245
  static bool
246
  InitIds(JSContext* cx, RTCRtpTransceiverAtoms* atomsCache);
247
};
248
249
250
class RTCRtpTransceiver final : public nsSupportsWeakReference,
251
                                public nsWrapperCache
252
{
253
public:
254
  NS_DECL_CYCLE_COLLECTING_ISUPPORTS
255
  NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(RTCRtpTransceiver)
256
257
private:
258
  RefPtr<RTCRtpTransceiverJSImpl> mImpl;
259
  nsCOMPtr<nsIGlobalObject> mParent;
260
261
public:
262
  RTCRtpTransceiver(JS::Handle<JSObject*> aJSImplObject, JS::Handle<JSObject*> aJSImplGlobal, nsIGlobalObject* aParent);
263
264
private:
265
  ~RTCRtpTransceiver();
266
267
public:
268
  nsISupports* GetParentObject() const;
269
270
  virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
271
272
  void GetMid(nsString& aRetVal, ErrorResult& aRv, JS::Realm* aRealm = nullptr) const;
273
274
  // Return a raw pointer here to avoid refcounting, but make sure it's safe (the object should be kept alive by the callee).
275
  already_AddRefed<RTCRtpSender> GetSender(ErrorResult& aRv, JS::Realm* aRealm = nullptr) const;
276
277
  // Return a raw pointer here to avoid refcounting, but make sure it's safe (the object should be kept alive by the callee).
278
  already_AddRefed<RTCRtpReceiver> GetReceiver(ErrorResult& aRv, JS::Realm* aRealm = nullptr) const;
279
280
  bool GetStopped(ErrorResult& aRv, JS::Realm* aRealm = nullptr) const;
281
282
  RTCRtpTransceiverDirection GetDirection(ErrorResult& aRv, JS::Realm* aRealm = nullptr) const;
283
284
  void SetDirection(RTCRtpTransceiverDirection arg, ErrorResult& aRv, JS::Realm* aRealm = nullptr);
285
286
  Nullable<RTCRtpTransceiverDirection> GetCurrentDirection(ErrorResult& aRv, JS::Realm* aRealm = nullptr) const;
287
288
  void Stop(ErrorResult& aRv, JS::Realm* aRealm = nullptr);
289
290
  void SetRemoteTrackId(const nsAString& trackId, ErrorResult& aRv, JS::Realm* aRealm = nullptr);
291
292
  bool RemoteTrackIdIs(const nsAString& trackId, ErrorResult& aRv, JS::Realm* aRealm = nullptr);
293
294
  void GetRemoteTrackId(nsString& aRetVal, ErrorResult& aRv, JS::Realm* aRealm = nullptr);
295
296
  void SetAddTrackMagic(ErrorResult& aRv, JS::Realm* aRealm = nullptr);
297
298
  bool GetAddTrackMagic(ErrorResult& aRv, JS::Realm* aRealm = nullptr) const;
299
300
  bool GetShouldRemove(ErrorResult& aRv, JS::Realm* aRealm = nullptr) const;
301
302
  void SetShouldRemove(bool arg, ErrorResult& aRv, JS::Realm* aRealm = nullptr);
303
304
  void SetCurrentDirection(RTCRtpTransceiverDirection direction, ErrorResult& aRv, JS::Realm* aRealm = nullptr);
305
306
  void SetDirectionInternal(RTCRtpTransceiverDirection direction, ErrorResult& aRv, JS::Realm* aRealm = nullptr);
307
308
  void SetMid(const nsAString& mid, ErrorResult& aRv, JS::Realm* aRealm = nullptr);
309
310
  void UnsetMid(ErrorResult& aRv, JS::Realm* aRealm = nullptr);
311
312
  void SetStopped(ErrorResult& aRv, JS::Realm* aRealm = nullptr);
313
314
  void GetKind(nsString& aRetVal, ErrorResult& aRv, JS::Realm* aRealm = nullptr);
315
316
  bool HasBeenUsedToSend(ErrorResult& aRv, JS::Realm* aRealm = nullptr);
317
318
  void Sync(ErrorResult& aRv, JS::Realm* aRealm = nullptr);
319
320
  void InsertDTMF(const nsAString& tones, uint32_t duration, uint32_t interToneGap, ErrorResult& aRv, JS::Realm* aRealm = nullptr);
321
322
  static bool
323
  _Create(JSContext* cx, unsigned argc, JS::Value* vp);
324
};
325
326
327
} // namespace dom
328
} // namespace mozilla
329
330
#endif // mozilla_dom_RTCRtpTransceiverBinding_h