/work/obj-fuzz/dist/include/mozilla/dom/MediaCapabilities.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
2 | | /* vim: set ts=8 sts=2 et sw=2 tw=80: */ |
3 | | /* This Source Code Form is subject to the terms of the Mozilla Public |
4 | | * License, v. 2.0. If a copy of the MPL was not distributed with this |
5 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
6 | | |
7 | | #ifndef mozilla_dom_MediaCapabilities_h_ |
8 | | #define mozilla_dom_MediaCapabilities_h_ |
9 | | |
10 | | #include "DecoderDoctorLogger.h" |
11 | | #include "MediaContainerType.h" |
12 | | #include "js/TypeDecls.h" |
13 | | #include "mozilla/Maybe.h" |
14 | | #include "mozilla/UniquePtr.h" |
15 | | #include "mozilla/dom/BindingUtils.h" |
16 | | #include "nsCOMPtr.h" |
17 | | #include "nsCycleCollectionNoteChild.h" |
18 | | #include "nsCycleCollectionParticipant.h" |
19 | | #include "nsIGlobalObject.h" |
20 | | #include "nsISupports.h" |
21 | | #include "nsWrapperCache.h" |
22 | | |
23 | | namespace mozilla { |
24 | | namespace layers { |
25 | | class KnowsCompositor; |
26 | | } |
27 | | namespace dom { |
28 | | class MediaCapabilities; |
29 | | } // namespace dom |
30 | | DDLoggedTypeName(dom::MediaCapabilities); |
31 | | |
32 | | namespace dom { |
33 | | |
34 | | struct MediaDecodingConfiguration; |
35 | | struct MediaEncodingConfiguration; |
36 | | struct AudioConfiguration; |
37 | | struct VideoConfiguration; |
38 | | class Promise; |
39 | | |
40 | | class MediaCapabilities final |
41 | | : public nsISupports |
42 | | , public nsWrapperCache |
43 | | { |
44 | | public: |
45 | | // Ref counting and cycle collection |
46 | | NS_DECL_CYCLE_COLLECTING_ISUPPORTS |
47 | | NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(MediaCapabilities) |
48 | | |
49 | | // WebIDL Methods |
50 | | already_AddRefed<Promise> DecodingInfo( |
51 | | const MediaDecodingConfiguration& aConfiguration, |
52 | | ErrorResult& aRv); |
53 | | already_AddRefed<Promise> EncodingInfo( |
54 | | const MediaEncodingConfiguration& aConfiguration, |
55 | | ErrorResult& aRv); |
56 | | // End WebIDL Methods |
57 | | |
58 | | explicit MediaCapabilities(nsIGlobalObject* aParent); |
59 | | |
60 | 0 | nsIGlobalObject* GetParentObject() const { return mParent; } |
61 | | JSObject* WrapObject(JSContext* aCx, |
62 | | JS::Handle<JSObject*> aGivenProto) override; |
63 | | |
64 | | static bool Enabled(JSContext* aCx, JSObject* aGlobal); |
65 | | |
66 | | private: |
67 | | virtual ~MediaCapabilities() = default; |
68 | | Maybe<MediaContainerType> CheckVideoConfiguration( |
69 | | const VideoConfiguration& aConfig) const; |
70 | | Maybe<MediaContainerType> CheckAudioConfiguration( |
71 | | const AudioConfiguration& aConfig) const; |
72 | | bool CheckTypeForMediaSource(const nsAString& aType); |
73 | | bool CheckTypeForFile(const nsAString& aType); |
74 | | bool CheckTypeForEncoder(const nsAString& aType); |
75 | | already_AddRefed<layers::KnowsCompositor> GetCompositor(); |
76 | | nsCOMPtr<nsIGlobalObject> mParent; |
77 | | }; |
78 | | |
79 | | class MediaCapabilitiesInfo final : public NonRefcountedDOMObject |
80 | | { |
81 | | public: |
82 | | // WebIDL methods |
83 | 0 | bool Supported() const { return mSupported; } |
84 | 0 | bool Smooth() const { return mSmooth; } |
85 | 0 | bool PowerEfficient() const { return mPowerEfficient; } |
86 | | // End WebIDL methods |
87 | | |
88 | | MediaCapabilitiesInfo(bool aSupported, bool aSmooth, bool aPowerEfficient) |
89 | | : mSupported(aSupported) |
90 | | , mSmooth(aSmooth) |
91 | | , mPowerEfficient(aPowerEfficient) |
92 | | { |
93 | | } |
94 | | |
95 | | bool WrapObject(JSContext* aCx, |
96 | | JS::Handle<JSObject*> aGivenProto, |
97 | | JS::MutableHandle<JSObject*> aReflector); |
98 | | |
99 | | private: |
100 | | bool mSupported; |
101 | | bool mSmooth; |
102 | | bool mPowerEfficient; |
103 | | }; |
104 | | |
105 | | } // namespace dom |
106 | | |
107 | | } // namespace mozilla |
108 | | |
109 | | #endif /* mozilla_dom_MediaCapabilities_h_ */ |