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 mozilla_dom_MediaDevices_h
6 #define mozilla_dom_MediaDevices_h
8 #include "mozilla/ErrorResult.h"
9 #include "nsISupportsImpl.h"
10 #include "mozilla/DOMEventTargetHelper.h"
11 #include "mozilla/dom/BindingUtils.h"
12 #include "nsPIDOMWindow.h"
13 #include "mozilla/media/DeviceChangeCallback.h"
19 struct MediaStreamConstraints
;
20 struct DisplayMediaStreamConstraints
;
21 struct MediaTrackSupportedConstraints
;
23 #define MOZILLA_DOM_MEDIADEVICES_IMPLEMENTATION_IID \
25 0x2f784d8a, 0x7485, 0x4280, { \
26 0x9a, 0x36, 0x74, 0xa4, 0xd6, 0x71, 0xa6, 0xc8 \
30 class MediaDevices final
: public DOMEventTargetHelper
,
31 public DeviceChangeCallback
{
33 explicit MediaDevices(nsPIDOMWindowInner
* aWindow
)
34 : DOMEventTargetHelper(aWindow
) {}
36 NS_DECL_ISUPPORTS_INHERITED
37 NS_DECLARE_STATIC_IID_ACCESSOR(MOZILLA_DOM_MEDIADEVICES_IMPLEMENTATION_IID
)
39 JSObject
* WrapObject(JSContext
* cx
,
40 JS::Handle
<JSObject
*> aGivenProto
) override
;
42 // No code needed, as MediaTrackSupportedConstraints members default to true.
43 void GetSupportedConstraints(MediaTrackSupportedConstraints
& aResult
){};
45 already_AddRefed
<Promise
> GetUserMedia(
46 const MediaStreamConstraints
& aConstraints
, CallerType aCallerType
,
49 already_AddRefed
<Promise
> EnumerateDevices(CallerType aCallerType
,
52 already_AddRefed
<Promise
> GetDisplayMedia(
53 const DisplayMediaStreamConstraints
& aConstraints
, CallerType aCallerType
,
56 virtual void OnDeviceChange() override
;
58 mozilla::dom::EventHandlerNonNull
* GetOndevicechange();
60 void SetOndevicechange(mozilla::dom::EventHandlerNonNull
* aCallback
);
62 void EventListenerAdded(nsAtom
* aType
) override
;
63 using DOMEventTargetHelper::EventListenerAdded
;
67 class EnumDevResolver
;
70 virtual ~MediaDevices();
71 nsCOMPtr
<nsITimer
> mFuzzTimer
;
74 NS_DEFINE_STATIC_IID_ACCESSOR(MediaDevices
,
75 MOZILLA_DOM_MEDIADEVICES_IMPLEMENTATION_IID
)
78 } // namespace mozilla
80 #endif // mozilla_dom_MediaDevices_h