diff --git a/dom/media/GetUserMediaRequest.cpp b/dom/media/GetUserMediaRequest.cpp index 3c8589328571..d5760a87299d 100644 --- a/dom/media/GetUserMediaRequest.cpp +++ b/dom/media/GetUserMediaRequest.cpp @@ -5,6 +5,7 @@ #include "GetUserMediaRequest.h" #include "base/basictypes.h" +#include "mozilla/dom/MediaDevicesBinding.h" #include "mozilla/dom/MediaStreamBinding.h" #include "mozilla/dom/GetUserMediaRequestBinding.h" #include "nsIScriptGlobalObject.h" @@ -20,6 +21,19 @@ GetUserMediaRequest::GetUserMediaRequest( mOuterWindowID(aInnerWindow->GetOuterWindow()->WindowID()), mCallID(aCallID), mConstraints(new MediaStreamConstraints(aConstraints)), + mType(GetUserMediaRequestType::Getusermedia), + mIsSecure(aIsSecure), + mIsHandlingUserInput(aIsHandlingUserInput) {} + +GetUserMediaRequest::GetUserMediaRequest( + nsPIDOMWindowInner* aInnerWindow, const nsAString& aCallID, + const AudioOutputOptions& aAudioOutputOptions, bool aIsSecure, + bool aIsHandlingUserInput) + : mInnerWindowID(aInnerWindow->WindowID()), + mOuterWindowID(aInnerWindow->GetOuterWindow()->WindowID()), + mCallID(aCallID), + mAudioOutputOptions(new AudioOutputOptions(aAudioOutputOptions)), + mType(GetUserMediaRequestType::Selectaudiooutput), mIsSecure(aIsSecure), mIsHandlingUserInput(aIsHandlingUserInput) {} @@ -31,6 +45,7 @@ GetUserMediaRequest::GetUserMediaRequest(nsPIDOMWindowInner* aInnerWindow, mOuterWindowID(0), mRawID(aRawId), mMediaSource(aMediaSource), + mType(GetUserMediaRequestType::Recording_device_stopped), mIsSecure(false), mIsHandlingUserInput(aIsHandlingUserInput) { if (aInnerWindow && aInnerWindow->GetOuterWindow()) { @@ -53,6 +68,8 @@ JSObject* GetUserMediaRequest::WrapObject(JSContext* aCx, nsISupports* GetUserMediaRequest::GetParentObject() { return nullptr; } +GetUserMediaRequestType GetUserMediaRequest::Type() { return mType; } + void GetUserMediaRequest::GetCallID(nsString& retval) { retval = mCallID; } void GetUserMediaRequest::GetRawID(nsString& retval) { retval = mRawID; } @@ -80,4 +97,12 @@ void GetUserMediaRequest::GetConstraints(MediaStreamConstraints& result) { } } +void GetUserMediaRequest::GetAudioOutputOptions(AudioOutputOptions& result) { + MOZ_ASSERT(result.mDeviceId.IsEmpty(), + "result should be default initialized"); + if (mAudioOutputOptions) { + result = *mAudioOutputOptions; + } +} + } // namespace mozilla::dom diff --git a/dom/media/GetUserMediaRequest.h b/dom/media/GetUserMediaRequest.h index 79ff770c0068..0b9ab6df9095 100644 --- a/dom/media/GetUserMediaRequest.h +++ b/dom/media/GetUserMediaRequest.h @@ -19,15 +19,22 @@ class nsPIDOMWindowInner; namespace mozilla { namespace dom { +struct AudioOutputOptions; struct MediaStreamConstraints; +enum class GetUserMediaRequestType : uint8_t; class GetUserMediaRequest : public nsISupports, public nsWrapperCache { public: - // For "getUserMedia:request" + // For getUserMedia "getUserMedia:request" GetUserMediaRequest(nsPIDOMWindowInner* aInnerWindow, const nsAString& aCallID, const MediaStreamConstraints& aConstraints, bool aIsSecure, bool aIsHandlingUserInput); + // For selectAudioOutput "getUserMedia:request" + GetUserMediaRequest(nsPIDOMWindowInner* aInnerWindow, + const nsAString& aCallID, + const AudioOutputOptions& aAudioOutputOptions, + bool aIsSecure, bool aIsHandlingUserInput); // For "recording-device-stopped" GetUserMediaRequest(nsPIDOMWindowInner* aInnerWindow, const nsAString& aRawId, const nsAString& aMediaSource, bool aIsHandlingUserInput); @@ -39,6 +46,7 @@ class GetUserMediaRequest : public nsISupports, public nsWrapperCache { JS::Handle aGivenProto) override; nsISupports* GetParentObject(); + GetUserMediaRequestType Type(); uint64_t WindowID(); uint64_t InnerWindowID(); bool IsSecure(); @@ -47,6 +55,7 @@ class GetUserMediaRequest : public nsISupports, public nsWrapperCache { void GetRawID(nsString& retval); void GetMediaSource(nsString& retval); void GetConstraints(MediaStreamConstraints& result); + void GetAudioOutputOptions(AudioOutputOptions& result); private: virtual ~GetUserMediaRequest() = default; @@ -56,6 +65,8 @@ class GetUserMediaRequest : public nsISupports, public nsWrapperCache { const nsString mRawID; const nsString mMediaSource; UniquePtr mConstraints; + UniquePtr mAudioOutputOptions; + GetUserMediaRequestType mType; bool mIsSecure; bool mIsHandlingUserInput; }; diff --git a/dom/webidl/GetUserMediaRequest.webidl b/dom/webidl/GetUserMediaRequest.webidl index 6762f571a6c1..01855743d11f 100644 --- a/dom/webidl/GetUserMediaRequest.webidl +++ b/dom/webidl/GetUserMediaRequest.webidl @@ -6,22 +6,32 @@ * This is an internal IDL file */ -// for gUM request start (getUserMedia:request) notification, -// rawID and mediaSource won't be set. -// for gUM request stop (recording-device-stopped) notification due to page reload, -// only windowID will be set. -// for gUM request stop (recording-device-stopped) notification due to track stop, -// only windowID, rawID and mediaSource will be set +// For gUM request start (getUserMedia:request) notification, +// rawID, mediaSource and audioOutputOptions won't be set. +// For selectAudioOutput request start (getUserMedia:request) notification, +// rawID, mediaSource and constraints won't be set. +// For gUM request stop (recording-device-stopped) notification due to page +// reload, only windowID will be set. +// For gUM request stop (recording-device-stopped) notification due to track +// stop, only type, windowID, rawID and mediaSource will be set + +enum GetUserMediaRequestType { + "getusermedia", + "selectaudiooutput", + "recording-device-stopped" +}; [NoInterfaceObject, Exposed=Window] interface GetUserMediaRequest { + readonly attribute GetUserMediaRequestType type; readonly attribute unsigned long long windowID; readonly attribute unsigned long long innerWindowID; readonly attribute DOMString callID; readonly attribute DOMString rawID; readonly attribute DOMString mediaSource; MediaStreamConstraints getConstraints(); + AudioOutputOptions getAudioOutputOptions(); readonly attribute boolean isSecure; readonly attribute boolean isHandlingUserInput; };