1 | /* |
2 | * Copyright (C) 2019 Igalia S.L |
3 | * |
4 | * This library is free software; you can redistribute it and/or |
5 | * modify it under the terms of the GNU Library General Public |
6 | * License as published by the Free Software Foundation; either |
7 | * version 2 of the License, or (at your option) any later version. |
8 | * |
9 | * This library is distributed in the hope that it will be useful, |
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 | * Library General Public License for more details. |
13 | * |
14 | * You should have received a copy of the GNU Library General Public License |
15 | * aint with this library; see the file COPYING.LIB. If not, write to |
16 | * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
17 | * Boston, MA 02110-1301, USA. |
18 | */ |
19 | |
20 | #pragma once |
21 | |
22 | #if USE(GSTREAMER) |
23 | |
24 | #include "MediaConfiguration.h" |
25 | |
26 | #include <wtf/Forward.h> |
27 | #include <wtf/HashMap.h> |
28 | #include <wtf/HashSet.h> |
29 | #include <wtf/text/AtomicString.h> |
30 | #include <wtf/text/AtomicStringHash.h> |
31 | #include <wtf/text/StringHash.h> |
32 | |
33 | namespace WebCore { |
34 | class ContentType; |
35 | |
36 | class GStreamerRegistryScanner { |
37 | friend NeverDestroyed<GStreamerRegistryScanner>; |
38 | public: |
39 | static GStreamerRegistryScanner& singleton(); |
40 | |
41 | HashSet<String, ASCIICaseInsensitiveHash>& mimeTypeSet() { return m_mimeTypeSet; } |
42 | |
43 | bool isContainerTypeSupported(String containerType) const { return m_mimeTypeSet.contains(containerType); } |
44 | |
45 | struct RegistryLookupResult { |
46 | bool isSupported; |
47 | bool isUsingHardware; |
48 | |
49 | operator bool() const { return isSupported; } |
50 | }; |
51 | RegistryLookupResult isDecodingSupported(MediaConfiguration&) const; |
52 | |
53 | bool isCodecSupported(String codec, bool usingHardware = false) const; |
54 | bool areAllCodecsSupported(const Vector<String>& codecs, bool shouldCheckForHardwareUse = false) const; |
55 | |
56 | protected: |
57 | GStreamerRegistryScanner(bool isMediaSource = false); |
58 | ~GStreamerRegistryScanner(); |
59 | |
60 | void initialize(); |
61 | |
62 | enum ElementType { |
63 | AudioDecoder = 0, |
64 | VideoDecoder, |
65 | Demuxer |
66 | }; |
67 | struct GstCapsWebKitMapping { |
68 | ElementType elementType; |
69 | const char* capsString; |
70 | Vector<AtomicString> webkitMimeTypes; |
71 | Vector<AtomicString> webkitCodecPatterns; |
72 | }; |
73 | void fillMimeTypeSetFromCapsMapping(Vector<GstCapsWebKitMapping>&); |
74 | |
75 | RegistryLookupResult hasElementForMediaType(GList* elementFactories, const char* capsString, bool shouldCheckHardwareClassifier = false); |
76 | |
77 | private: |
78 | bool m_isMediaSource; |
79 | GList* m_audioDecoderFactories; |
80 | GList* m_audioParserFactories; |
81 | GList* m_videoDecoderFactories; |
82 | GList* m_videoParserFactories; |
83 | GList* m_demuxerFactories; |
84 | HashSet<String, ASCIICaseInsensitiveHash> m_mimeTypeSet; |
85 | HashMap<AtomicString, bool> m_codecMap; |
86 | }; |
87 | |
88 | } // namespace WebCore |
89 | |
90 | #endif // USE(GSTREAMER) |
91 | |