1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim:set ts=2 sw=2 sts=2 et cindent: */
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 #if !defined(GMPDecoderModule_h_)
8 #define GMPDecoderModule_h_
9 
10 #include "PlatformDecoderModule.h"
11 #include "mozilla/Maybe.h"
12 
13 // The special NodeId we use when doing unencrypted decoding using the GMP's
14 // decoder. This ensures that each GMP MediaDataDecoder we create doesn't
15 // require spinning up a new process, but instead we run all instances of
16 // GMP decoders in the one process, to reduce overhead.
17 //
18 // Note: GMP storage is isolated by NodeId, and non persistent for this
19 // special NodeId, and the only way a GMP can communicate with the outside
20 // world is through the EME GMP APIs, and we never run EME with this NodeID
21 // (because NodeIds are random strings which can't contain the '-' character),
22 // so there's no way a malicious GMP can harvest, store, and then report any
23 // privacy sensitive data about what users are watching.
24 #define SHARED_GMP_DECODING_NODE_ID NS_LITERAL_CSTRING("gmp-shared-decoding")
25 
26 namespace mozilla {
27 
28 class GMPDecoderModule : public PlatformDecoderModule {
29  public:
30   GMPDecoderModule();
31 
32   // Decode thread.
33   already_AddRefed<MediaDataDecoder> CreateVideoDecoder(
34       const CreateDecoderParams& aParams) override;
35 
36   // Decode thread.
37   already_AddRefed<MediaDataDecoder> CreateAudioDecoder(
38       const CreateDecoderParams& aParams) override;
39 
40   bool SupportsMimeType(const nsACString& aMimeType,
41                         DecoderDoctorDiagnostics* aDiagnostics) const override;
42 
43   static bool SupportsMimeType(const nsACString& aMimeType,
44                                const Maybe<nsCString>& aGMP);
45 
46  private:
47   virtual ~GMPDecoderModule();
48 };
49 
50 }  // namespace mozilla
51 
52 #endif  // GMPDecoderModule_h_
53