Line data Source code
1 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* This Source Code Form is subject to the terms of the Mozilla Public
3 : * License, v. 2.0. If a copy of the MPL was not distributed with this
4 : * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 :
6 : #ifndef GMPUtils_h_
7 : #define GMPUtils_h_
8 :
9 : #include "mozilla/UniquePtr.h"
10 : #include "mozilla/RefPtr.h"
11 : #include "mozilla/AbstractThread.h"
12 : #include "nsTArray.h"
13 : #include "nsCOMPtr.h"
14 : #include "nsClassHashtable.h"
15 :
16 : #define CHROMIUM_CDM_API "chromium-cdm8-host4"
17 :
18 : class nsIFile;
19 : class nsCString;
20 : class nsISimpleEnumerator;
21 :
22 : namespace mozilla {
23 :
24 : template<typename T>
25 : struct DestroyPolicy
26 : {
27 0 : void operator()(T* aGMPObject) const {
28 0 : aGMPObject->Destroy();
29 0 : }
30 : };
31 :
32 : template<typename T>
33 : using GMPUniquePtr = mozilla::UniquePtr<T, DestroyPolicy<T>>;
34 :
35 : void
36 : SplitAt(const char* aDelims,
37 : const nsACString& aInput,
38 : nsTArray<nsCString>& aOutTokens);
39 :
40 : nsCString
41 : ToHexString(const nsTArray<uint8_t>& aBytes);
42 :
43 : nsCString
44 : ToHexString(const uint8_t* aBytes, uint32_t aLength);
45 :
46 : bool
47 : FileExists(nsIFile* aFile);
48 :
49 : // Enumerate directory entries for a specified path.
50 0 : class DirectoryEnumerator {
51 : public:
52 :
53 : enum Mode {
54 : DirsOnly, // Enumeration only includes directories.
55 : FilesAndDirs // Enumeration includes directories and non-directory files.
56 : };
57 :
58 : DirectoryEnumerator(nsIFile* aPath, Mode aMode);
59 :
60 : already_AddRefed<nsIFile> Next();
61 :
62 : private:
63 : Mode mMode;
64 : nsCOMPtr<nsISimpleEnumerator> mIter;
65 : };
66 :
67 0 : class GMPInfoFileParser {
68 : public:
69 : bool Init(nsIFile* aFile);
70 : bool Contains(const nsCString& aKey) const;
71 : nsCString Get(const nsCString& aKey) const;
72 : private:
73 : nsClassHashtable<nsCStringHashKey, nsCString> mValues;
74 : };
75 :
76 : bool
77 : ReadIntoString(nsIFile* aFile,
78 : nsCString& aOutDst,
79 : size_t aMaxLength);
80 :
81 : bool
82 : HaveGMPFor(const nsCString& aAPI,
83 : nsTArray<nsCString>&& aTags);
84 :
85 : void
86 : LogToConsole(const nsAString& aMsg);
87 :
88 : RefPtr<AbstractThread>
89 : GetGMPAbstractThread();
90 :
91 : // Returns the number of bytes required to store an aWidth x aHeight image in
92 : // I420 format, padded so that the width and height are multiples of 16.
93 : size_t
94 : I420FrameBufferSizePadded(int32_t aWidth, int32_t aHeight);
95 :
96 : } // namespace mozilla
97 :
98 : #endif
|