Line data Source code
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 mozilla_dom_MediaDevices_h
6 : #define mozilla_dom_MediaDevices_h
7 :
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"
14 :
15 : namespace mozilla {
16 : namespace dom {
17 :
18 : class Promise;
19 : struct MediaStreamConstraints;
20 : struct MediaTrackSupportedConstraints;
21 :
22 : #define MOZILLA_DOM_MEDIADEVICES_IMPLEMENTATION_IID \
23 : { 0x2f784d8a, 0x7485, 0x4280, \
24 : { 0x9a, 0x36, 0x74, 0xa4, 0xd6, 0x71, 0xa6, 0xc8 } }
25 :
26 : class MediaDevices final : public DOMEventTargetHelper
27 : ,public DeviceChangeCallback
28 : {
29 : public:
30 0 : explicit MediaDevices(nsPIDOMWindowInner* aWindow) :
31 0 : DOMEventTargetHelper(aWindow) {}
32 :
33 : NS_DECL_ISUPPORTS_INHERITED
34 : NS_DECLARE_STATIC_IID_ACCESSOR(MOZILLA_DOM_MEDIADEVICES_IMPLEMENTATION_IID)
35 :
36 : JSObject* WrapObject(JSContext* cx, JS::Handle<JSObject*> aGivenProto) override;
37 :
38 : // No code needed, as MediaTrackSupportedConstraints members default to true.
39 0 : void GetSupportedConstraints(MediaTrackSupportedConstraints& aResult) {};
40 :
41 : already_AddRefed<Promise>
42 : GetUserMedia(const MediaStreamConstraints& aConstraints,
43 : CallerType aCallerType, ErrorResult &aRv);
44 :
45 : already_AddRefed<Promise>
46 : EnumerateDevices(ErrorResult &aRv);
47 :
48 : virtual void OnDeviceChange() override;
49 :
50 : mozilla::dom::EventHandlerNonNull* GetOndevicechange();
51 :
52 : void SetOndevicechange(mozilla::dom::EventHandlerNonNull* aCallback);
53 :
54 : NS_IMETHOD AddEventListener(const nsAString& aType,
55 : nsIDOMEventListener* aListener,
56 : bool aUseCapture, bool aWantsUntrusted,
57 : uint8_t optional_argc) override;
58 :
59 : virtual void AddEventListener(const nsAString& aType,
60 : dom::EventListener* aListener,
61 : const dom::AddEventListenerOptionsOrBoolean& aOptions,
62 : const dom::Nullable<bool>& aWantsUntrusted,
63 : ErrorResult& aRv) override;
64 :
65 : private:
66 : class GumResolver;
67 : class EnumDevResolver;
68 : class GumRejecter;
69 :
70 : virtual ~MediaDevices();
71 : nsCOMPtr<nsITimer> mFuzzTimer;
72 : };
73 :
74 : NS_DEFINE_STATIC_IID_ACCESSOR(MediaDevices,
75 : MOZILLA_DOM_MEDIADEVICES_IMPLEMENTATION_IID)
76 :
77 : } // namespace dom
78 : } // namespace mozilla
79 :
80 : #endif // mozilla_dom_MediaDevices_h
|