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/. */ 4 5 #ifndef GetUserMediaRequest_h__ 6 #define GetUserMediaRequest_h__ 7 8 #include <cstdint> 9 #include "js/TypeDecls.h" 10 #include "mozilla/Assertions.h" 11 #include "mozilla/UniquePtr.h" 12 #include "nsCycleCollectionParticipant.h" 13 #include "nsISupports.h" 14 #include "nsString.h" 15 #include "nsWrapperCache.h" 16 17 class nsIMediaDevice; 18 class nsPIDOMWindowInner; 19 20 namespace mozilla { 21 22 class LocalMediaDevice; 23 24 namespace media { 25 template <typename T> 26 class Refcountable; 27 } 28 29 namespace dom { 30 31 struct AudioOutputOptions; 32 struct MediaStreamConstraints; 33 enum class GetUserMediaRequestType : uint8_t; 34 35 class GetUserMediaRequest : public nsISupports, public nsWrapperCache { 36 public: 37 using LocalMediaDeviceSetRefCnt = 38 media::Refcountable<nsTArray<RefPtr<LocalMediaDevice>>>; 39 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); 55 56 NS_DECL_CYCLE_COLLECTING_ISUPPORTS 57 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(GetUserMediaRequest) 58 59 JSObject* WrapObject(JSContext* cx, 60 JS::Handle<JSObject*> aGivenProto) override; 61 nsISupports* GetParentObject(); 62 63 GetUserMediaRequestType Type(); 64 uint64_t WindowID(); 65 uint64_t InnerWindowID(); 66 bool IsSecure(); 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); 74 75 private: 76 virtual ~GetUserMediaRequest(); 77 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; 86 bool mIsSecure; 87 bool mIsHandlingUserInput; 88 }; 89 90 } // namespace dom 91 } // namespace mozilla 92 93 #endif // GetUserMediaRequest_h__ 94