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 "gmp-shared-decoding"_ns 25 26 namespace mozilla { 27 28 class GMPDecoderModule : public PlatformDecoderModule { 29 template <typename T, typename... Args> 30 friend already_AddRefed<T> MakeAndAddRef(Args&&...); 31 32 public: 33 static already_AddRefed<PlatformDecoderModule> Create(); 34 35 // Decode thread. 36 already_AddRefed<MediaDataDecoder> CreateVideoDecoder( 37 const CreateDecoderParams& aParams) override; 38 39 // Decode thread. 40 already_AddRefed<MediaDataDecoder> CreateAudioDecoder( 41 const CreateDecoderParams& aParams) override; 42 43 bool SupportsMimeType(const nsACString& aMimeType, 44 DecoderDoctorDiagnostics* aDiagnostics) const override; 45 46 static bool SupportsMimeType(const nsACString& aMimeType, 47 const Maybe<nsCString>& aGMP); 48 49 private: 50 GMPDecoderModule() = default; 51 virtual ~GMPDecoderModule() = default; 52 }; 53 54 } // namespace mozilla 55 56 #endif // GMPDecoderModule_h_ 57