Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dist/include/GMPUtils.h
Line
Count
Source (jump to first uncovered line)
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 "nsStringFwd.h"
13
#include "nsTArray.h"
14
#include "nsCOMPtr.h"
15
#include "nsClassHashtable.h"
16
17
#define CHROMIUM_CDM_API_BACKWARD_COMPAT "chromium-cdm9-host4"
18
// TODO: The following should be used as we switch to cdm10
19
#define CHROMIUM_CDM_API "chromium-cdm10-host4"
20
21
class nsIFile;
22
class nsIDirectoryEnumerator;
23
24
namespace mozilla {
25
26
template<typename T>
27
struct DestroyPolicy
28
{
29
0
  void operator()(T* aGMPObject) const {
30
0
    aGMPObject->Destroy();
31
0
  }
Unexecuted instantiation: mozilla::DestroyPolicy<GMPVideoi420Frame>::operator()(GMPVideoi420Frame*) const
Unexecuted instantiation: mozilla::DestroyPolicy<GMPVideoEncodedFrame>::operator()(GMPVideoEncodedFrame*) const
32
};
33
34
template<typename T>
35
using GMPUniquePtr = mozilla::UniquePtr<T, DestroyPolicy<T>>;
36
37
void
38
SplitAt(const char* aDelims,
39
        const nsACString& aInput,
40
        nsTArray<nsCString>& aOutTokens);
41
42
nsCString
43
ToHexString(const nsTArray<uint8_t>& aBytes);
44
45
nsCString
46
ToHexString(const uint8_t* aBytes, uint32_t aLength);
47
48
bool
49
FileExists(nsIFile* aFile);
50
51
// Enumerate directory entries for a specified path.
52
class DirectoryEnumerator {
53
public:
54
55
  enum Mode {
56
    DirsOnly, // Enumeration only includes directories.
57
    FilesAndDirs // Enumeration includes directories and non-directory files.
58
  };
59
60
  DirectoryEnumerator(nsIFile* aPath, Mode aMode);
61
62
  already_AddRefed<nsIFile> Next();
63
64
private:
65
  Mode mMode;
66
  nsCOMPtr<nsIDirectoryEnumerator> mIter;
67
};
68
69
class GMPInfoFileParser {
70
public:
71
  bool Init(nsIFile* aFile);
72
  bool Contains(const nsCString& aKey) const;
73
  nsCString Get(const nsCString& aKey) const;
74
private:
75
  nsClassHashtable<nsCStringHashKey, nsCString> mValues;
76
};
77
78
bool
79
ReadIntoString(nsIFile* aFile,
80
               nsCString& aOutDst,
81
               size_t aMaxLength);
82
83
bool
84
HaveGMPFor(const nsCString& aAPI,
85
           nsTArray<nsCString>&& aTags);
86
87
void
88
LogToConsole(const nsAString& aMsg);
89
90
RefPtr<AbstractThread>
91
GetGMPAbstractThread();
92
93
// Returns the number of bytes required to store an aWidth x aHeight image in
94
// I420 format, padded so that the width and height are multiples of 16.
95
size_t
96
I420FrameBufferSizePadded(int32_t aWidth, int32_t aHeight);
97
98
} // namespace mozilla
99
100
#endif