Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/dom/media/gmp/ChromiumCDMAdapter.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 ChromiumAdapter_h_
7
#define ChromiumAdapter_h_
8
9
#include "GMPLoader.h"
10
#include "prlink.h"
11
#include "GMPUtils.h"
12
#include "nsTArray.h"
13
#include "content_decryption_module_ext.h"
14
#include "nsString.h"
15
#include "mozilla/Pair.h"
16
17
struct GMPPlatformAPI;
18
19
namespace mozilla {
20
21
#if defined(XP_WIN)
22
typedef nsString HostFileString;
23
#else
24
typedef nsCString HostFileString;
25
#endif
26
27
class HostFile
28
{
29
public:
30
  explicit HostFile(const nsCString& aPath);
31
  HostFile(HostFile&& aOther);
32
  ~HostFile();
33
34
0
  const HostFileString& Path() const { return mPath; }
35
  cdm::PlatformFile TakePlatformFile();
36
37
private:
38
  const HostFileString mPath;
39
  cdm::PlatformFile mFile = cdm::kInvalidPlatformFile;
40
};
41
42
struct HostFileData
43
{
44
  HostFileData(HostFile&& aBinary, HostFile&& aSig)
45
    : mBinary(std::move(aBinary))
46
    , mSig(std::move(aSig))
47
0
  {
48
0
  }
49
50
  HostFileData(HostFileData&& aOther)
51
    : mBinary(std::move(aOther.mBinary))
52
    , mSig(std::move(aOther.mSig))
53
0
  {
54
0
  }
55
56
0
  ~HostFileData() {}
57
58
  HostFile mBinary;
59
  HostFile mSig;
60
};
61
62
class ChromiumCDMAdapter : public gmp::GMPAdapter
63
{
64
public:
65
  explicit ChromiumCDMAdapter(nsTArray<Pair<nsCString, nsCString>>&& aHostPathPairs);
66
67
  void SetAdaptee(PRLibrary* aLib) override;
68
69
  // These are called in place of the corresponding GMP API functions.
70
  GMPErr GMPInit(const GMPPlatformAPI* aPlatformAPI) override;
71
  GMPErr GMPGetAPI(const char* aAPIName,
72
                   void* aHostAPI,
73
                   void** aPluginAPI,
74
                   uint32_t aDecryptorId) override;
75
  void GMPShutdown() override;
76
77
  static bool Supports(int32_t aModuleVersion,
78
                       int32_t aInterfaceVersion,
79
                       int32_t aHostVersion);
80
81
private:
82
  void PopulateHostFiles(nsTArray<Pair<nsCString, nsCString>>&& aHostFilePaths);
83
84
  PRLibrary* mLib = nullptr;
85
  nsTArray<HostFileData> mHostFiles;
86
};
87
88
} // namespace mozilla
89
90
#endif // ChromiumAdapter_h_