1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
3 * You can obtain one at http://mozilla.org/MPL/2.0/. */
5 #ifndef GetUserMediaRequest_h__
6 #define GetUserMediaRequest_h__
9 #include "js/TypeDecls.h"
10 #include "mozilla/Assertions.h"
11 #include "mozilla/UniquePtr.h"
12 #include "nsCycleCollectionParticipant.h"
13 #include "nsISupports.h"
15 #include "nsWrapperCache.h"
18 class nsPIDOMWindowInner
;
22 class LocalMediaDevice
;
31 struct AudioOutputOptions
;
32 struct MediaStreamConstraints
;
33 enum class GetUserMediaRequestType
: uint8_t;
35 class GetUserMediaRequest
: public nsISupports
, public nsWrapperCache
{
37 using LocalMediaDeviceSetRefCnt
=
38 media::Refcountable
<nsTArray
<RefPtr
<LocalMediaDevice
>>>;
40 // For getUserMedia "getUserMedia:request"
41 GetUserMediaRequest(nsPIDOMWindowInner
* aInnerWindow
,
42 const nsAString
& aCallID
,
43 RefPtr
<LocalMediaDeviceSetRefCnt
> aMediaDeviceSet
,
44 const MediaStreamConstraints
& aConstraints
,
45 bool aIsSecure
, bool aIsHandlingUserInput
);
46 // For selectAudioOutput "getUserMedia:request"
47 GetUserMediaRequest(nsPIDOMWindowInner
* aInnerWindow
,
48 const nsAString
& aCallID
,
49 RefPtr
<LocalMediaDeviceSetRefCnt
> aMediaDeviceSet
,
50 const AudioOutputOptions
& aAudioOutputOptions
,
51 bool aIsSecure
, bool aIsHandlingUserInput
);
52 // For "recording-device-stopped"
53 GetUserMediaRequest(nsPIDOMWindowInner
* aInnerWindow
, const nsAString
& aRawId
,
54 const nsAString
& aMediaSource
, bool aIsHandlingUserInput
);
56 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
57 NS_DECL_CYCLE_COLLECTION_WRAPPERCACHE_CLASS(GetUserMediaRequest
)
59 JSObject
* WrapObject(JSContext
* cx
,
60 JS::Handle
<JSObject
*> aGivenProto
) override
;
61 nsISupports
* GetParentObject();
63 GetUserMediaRequestType
Type();
65 uint64_t InnerWindowID();
67 bool IsHandlingUserInput() const;
68 void GetCallID(nsString
& retval
);
69 void GetRawID(nsString
& retval
);
70 void GetMediaSource(nsString
& retval
);
71 void GetDevices(nsTArray
<RefPtr
<nsIMediaDevice
>>& retval
) const;
72 void GetConstraints(MediaStreamConstraints
& result
);
73 void GetAudioOutputOptions(AudioOutputOptions
& result
);
76 virtual ~GetUserMediaRequest();
78 uint64_t mInnerWindowID
, mOuterWindowID
;
79 const nsString mCallID
;
80 const nsString mRawID
;
81 const nsString mMediaSource
;
82 const RefPtr
<LocalMediaDeviceSetRefCnt
> mMediaDeviceSet
;
83 UniquePtr
<MediaStreamConstraints
> mConstraints
;
84 UniquePtr
<AudioOutputOptions
> mAudioOutputOptions
;
85 GetUserMediaRequestType mType
;
87 bool mIsHandlingUserInput
;
91 } // namespace mozilla
93 #endif // GetUserMediaRequest_h__