Copy as Markdown
Other Tools
/* THIS FILE IS AUTOGENERATED FROM MediaStream.webidl BY Codegen.py - DO NOT EDIT */
#ifndef DOM_MEDIASTREAMBINDING_H_
#define DOM_MEDIASTREAMBINDING_H_
#include "MediaStreamTrackBinding.h"
#include "js/CallAndConstruct.h"
#include "js/RootingAPI.h"
#include "js/TypeDecls.h"
#include "mozilla/dom/BindingDeclarations.h"
#include "mozilla/dom/FakeString.h"
#include "mozilla/dom/Nullable.h"
#include "mozilla/dom/PrototypeList.h"
#include "mozilla/dom/UnionMember.h"
namespace mozilla {
class DOMMediaStream;
namespace dom {
class BooleanOrMediaTrackConstraints;
struct DisplayMediaStreamConstraintsAtoms;
struct MediaStreamConstraintsAtoms;
struct NativePropertyHooks;
class OwningBooleanOrMediaTrackConstraints;
class ProtoAndIfaceCache;
} // namespace dom
} // namespace mozilla
namespace mozilla::dom {
class BooleanOrMediaTrackConstraints : public AllUnionBase
{
enum TypeOrUninit
{
eUninitialized,
eBoolean,
eMediaTrackConstraints
};
public:
enum class Type
{
eBoolean = TypeOrUninit::eBoolean,
eMediaTrackConstraints = TypeOrUninit::eMediaTrackConstraints
};
private:
union Value
{
UnionMember<bool > mBoolean;
UnionMember<binding_detail::FastMediaTrackConstraints > mMediaTrackConstraints;
};
TypeOrUninit mType;
Value mValue;
BooleanOrMediaTrackConstraints(const BooleanOrMediaTrackConstraints&) = delete;
BooleanOrMediaTrackConstraints& operator=(const BooleanOrMediaTrackConstraints&) = delete;
public:
explicit inline BooleanOrMediaTrackConstraints()
: mType(eUninitialized)
{
}
inline ~BooleanOrMediaTrackConstraints()
{
Uninit();
}
[[nodiscard]] inline bool&
RawSetAsBoolean()
{
if (mType == eBoolean) {
return mValue.mBoolean.Value();
}
MOZ_ASSERT(mType == eUninitialized);
mType = eBoolean;
return mValue.mBoolean.SetValue();
}
[[nodiscard]] inline bool&
SetAsBoolean()
{
if (mType == eBoolean) {
return mValue.mBoolean.Value();
}
Uninit();
mType = eBoolean;
return mValue.mBoolean.SetValue();
}
inline bool
IsBoolean() const
{
return mType == eBoolean;
}
inline bool&
GetAsBoolean()
{
MOZ_RELEASE_ASSERT(IsBoolean(), "Wrong type!");
return mValue.mBoolean.Value();
}
inline bool
GetAsBoolean() const
{
MOZ_RELEASE_ASSERT(IsBoolean(), "Wrong type!");
return mValue.mBoolean.Value();
}
[[nodiscard]] inline binding_detail::FastMediaTrackConstraints&
RawSetAsMediaTrackConstraints()
{
if (mType == eMediaTrackConstraints) {
return mValue.mMediaTrackConstraints.Value();
}
MOZ_ASSERT(mType == eUninitialized);
mType = eMediaTrackConstraints;
return mValue.mMediaTrackConstraints.SetValue();
}
[[nodiscard]] inline binding_detail::FastMediaTrackConstraints&
SetAsMediaTrackConstraints()
{
if (mType == eMediaTrackConstraints) {
return mValue.mMediaTrackConstraints.Value();
}
Uninit();
mType = eMediaTrackConstraints;
return mValue.mMediaTrackConstraints.SetValue();
}
inline bool
IsMediaTrackConstraints() const
{
return mType == eMediaTrackConstraints;
}
inline binding_detail::FastMediaTrackConstraints&
GetAsMediaTrackConstraints()
{
MOZ_RELEASE_ASSERT(IsMediaTrackConstraints(), "Wrong type!");
return mValue.mMediaTrackConstraints.Value();
}
inline const MediaTrackConstraints&
GetAsMediaTrackConstraints() const
{
MOZ_RELEASE_ASSERT(IsMediaTrackConstraints(), "Wrong type!");
return mValue.mMediaTrackConstraints.Value();
}
bool
Init(BindingCallContext& cx, JS::Handle<JS::Value> value, const char* sourceDescription = "Value", bool passedToJSImpl = false);
bool
Init(JSContext* cx_, JS::Handle<JS::Value> value, const char* sourceDescription = "Value", bool passedToJSImpl = false);
inline void
Uninit()
{
switch (mType) {
case eUninitialized: {
break;
}
case eBoolean: {
DestroyBoolean();
break;
}
case eMediaTrackConstraints: {
DestroyMediaTrackConstraints();
break;
}
}
}
bool
ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
private:
bool
TrySetToBoolean(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
inline void
DestroyBoolean()
{
MOZ_RELEASE_ASSERT(IsBoolean(), "Wrong type!");
mValue.mBoolean.Destroy();
mType = eUninitialized;
}
bool
TrySetToMediaTrackConstraints(BindingCallContext& cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
bool
TrySetToMediaTrackConstraints(JSContext* cx_, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
inline void
DestroyMediaTrackConstraints()
{
MOZ_RELEASE_ASSERT(IsMediaTrackConstraints(), "Wrong type!");
mValue.mMediaTrackConstraints.Destroy();
mType = eUninitialized;
}
};
class OwningBooleanOrMediaTrackConstraints : public AllOwningUnionBase
{
enum TypeOrUninit
{
eUninitialized,
eBoolean,
eMediaTrackConstraints
};
public:
enum class Type
{
eBoolean = TypeOrUninit::eBoolean,
eMediaTrackConstraints = TypeOrUninit::eMediaTrackConstraints
};
private:
union Value
{
UnionMember<bool > mBoolean;
UnionMember<MediaTrackConstraints > mMediaTrackConstraints;
};
TypeOrUninit mType;
Value mValue;
public:
explicit inline OwningBooleanOrMediaTrackConstraints()
: mType(eUninitialized)
{
}
OwningBooleanOrMediaTrackConstraints(OwningBooleanOrMediaTrackConstraints&& aOther);
explicit inline OwningBooleanOrMediaTrackConstraints(const OwningBooleanOrMediaTrackConstraints& aOther)
: mType(eUninitialized)
{
*this = aOther;
}
inline ~OwningBooleanOrMediaTrackConstraints()
{
Uninit();
}
[[nodiscard]] bool&
RawSetAsBoolean();
[[nodiscard]] bool&
SetAsBoolean();
inline bool
IsBoolean() const
{
return mType == eBoolean;
}
inline bool&
GetAsBoolean()
{
MOZ_RELEASE_ASSERT(IsBoolean(), "Wrong type!");
return mValue.mBoolean.Value();
}
inline bool const &
GetAsBoolean() const
{
MOZ_RELEASE_ASSERT(IsBoolean(), "Wrong type!");
return mValue.mBoolean.Value();
}
[[nodiscard]] MediaTrackConstraints&
RawSetAsMediaTrackConstraints();
[[nodiscard]] MediaTrackConstraints&
SetAsMediaTrackConstraints();
inline bool
IsMediaTrackConstraints() const
{
return mType == eMediaTrackConstraints;
}
inline MediaTrackConstraints&
GetAsMediaTrackConstraints()
{
MOZ_RELEASE_ASSERT(IsMediaTrackConstraints(), "Wrong type!");
return mValue.mMediaTrackConstraints.Value();
}
inline MediaTrackConstraints const &
GetAsMediaTrackConstraints() const
{
MOZ_RELEASE_ASSERT(IsMediaTrackConstraints(), "Wrong type!");
return mValue.mMediaTrackConstraints.Value();
}
bool
Init(BindingCallContext& cx, JS::Handle<JS::Value> value, const char* sourceDescription = "Value", bool passedToJSImpl = false);
bool
Init(JSContext* cx_, JS::Handle<JS::Value> value, const char* sourceDescription = "Value", bool passedToJSImpl = false);
void
Uninit();
bool
ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
OwningBooleanOrMediaTrackConstraints&
operator=(OwningBooleanOrMediaTrackConstraints&& aOther);
inline Type
GetType() const
{
MOZ_RELEASE_ASSERT(mType != eUninitialized);
return static_cast<Type>(mType);
}
OwningBooleanOrMediaTrackConstraints&
operator=(const OwningBooleanOrMediaTrackConstraints& aOther);
private:
bool
TrySetToBoolean(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
void
DestroyBoolean();
bool
TrySetToMediaTrackConstraints(BindingCallContext& cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
bool
TrySetToMediaTrackConstraints(JSContext* cx_, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
void
DestroyMediaTrackConstraints();
};
struct DisplayMediaStreamConstraints : public DictionaryBase
{
MOZ_INIT_OUTSIDE_CTOR OwningBooleanOrMediaTrackConstraints mAudio;
MOZ_INIT_OUTSIDE_CTOR OwningBooleanOrMediaTrackConstraints mVideo;
DisplayMediaStreamConstraints();
explicit inline DisplayMediaStreamConstraints(const FastDictionaryInitializer& )
{
// Do nothing here; this is used by our "Fast" subclass
}
DisplayMediaStreamConstraints(DisplayMediaStreamConstraints&& aOther) = default;
explicit inline DisplayMediaStreamConstraints(const DisplayMediaStreamConstraints& aOther)
{
*this = aOther;
}
bool
Init(BindingCallContext& cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false);
bool
Init(JSContext* cx_, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false);
void
TraceDictionary(JSTracer* trc);
DisplayMediaStreamConstraints&
operator=(const DisplayMediaStreamConstraints& aOther);
private:
static bool
InitIds(JSContext* cx, DisplayMediaStreamConstraintsAtoms* atomsCache);
};
namespace binding_detail {
struct FastDisplayMediaStreamConstraints : public DisplayMediaStreamConstraints
{
inline FastDisplayMediaStreamConstraints()
: DisplayMediaStreamConstraints(FastDictionaryInitializer())
{
// Doesn't matter what int we pass to the parent constructor
}
};
} // namespace binding_detail
struct MediaStreamConstraints : public DictionaryBase
{
MOZ_INIT_OUTSIDE_CTOR OwningBooleanOrMediaTrackConstraints mAudio;
MOZ_INIT_OUTSIDE_CTOR Optional<bool> mFake;
MOZ_INIT_OUTSIDE_CTOR nsString mPeerIdentity;
MOZ_INIT_OUTSIDE_CTOR bool mPicture;
MOZ_INIT_OUTSIDE_CTOR OwningBooleanOrMediaTrackConstraints mVideo;
MediaStreamConstraints();
explicit inline MediaStreamConstraints(const FastDictionaryInitializer& )
{
// Do nothing here; this is used by our "Fast" subclass
}
MediaStreamConstraints(MediaStreamConstraints&& aOther) = default;
explicit inline MediaStreamConstraints(const MediaStreamConstraints& aOther)
{
*this = aOther;
}
bool
Init(BindingCallContext& cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false);
bool
Init(JSContext* cx_, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false);
bool
ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const;
void
TraceDictionary(JSTracer* trc);
MediaStreamConstraints&
operator=(const MediaStreamConstraints& aOther);
private:
static bool
InitIds(JSContext* cx, MediaStreamConstraintsAtoms* atomsCache);
};
namespace binding_detail {
struct FastMediaStreamConstraints : public MediaStreamConstraints
{
inline FastMediaStreamConstraints()
: MediaStreamConstraints(FastDictionaryInitializer())
{
// Doesn't matter what int we pass to the parent constructor
}
};
} // namespace binding_detail
namespace MediaStream_Binding {
typedef mozilla::DOMMediaStream NativeType;
bool
Wrap(JSContext* aCx, mozilla::DOMMediaStream* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector);
template <class T>
inline JSObject* Wrap(JSContext* aCx, T* aObject, JS::Handle<JSObject*> aGivenProto)
{
JS::Rooted<JSObject*> reflector(aCx);
return Wrap(aCx, aObject, aObject, aGivenProto, &reflector) ? reflector.get() : nullptr;
}
void
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, DefineInterfaceProperty aDefineOnGlobal);
JS::Handle<JSObject*>
GetProtoObjectHandle(JSContext* aCx);
JSObject*
GetProtoObject(JSContext* aCx);
JS::Handle<JSObject*>
GetConstructorObjectHandle(JSContext* aCx);
inline bool CreateAndDefineOnGlobal(JSContext* aCx)
{
// Get the interface or namespace object for this class. This will
// create the object as needed and always define the properties for
// it on the global. The caller should make sure the interface or
// namespace is exposed on the global before calling this.
return GetPerInterfaceObjectHandle(aCx, constructors::id::MediaStream,
&CreateInterfaceObjects,
DefineInterfaceProperty::Always);
}
} // namespace MediaStream_Binding
} // namespace mozilla::dom
#endif // DOM_MEDIASTREAMBINDING_H_