Line data Source code
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(PDMFactory_h_)
8 : #define PDMFactory_h_
9 :
10 : #include "PlatformDecoderModule.h"
11 : #include "mozilla/StaticMutex.h"
12 :
13 : class CDMProxy;
14 :
15 : namespace mozilla {
16 :
17 : class DecoderDoctorDiagnostics;
18 : class PDMFactoryImpl;
19 : template<class T> class StaticAutoPtr;
20 :
21 : class PDMFactory final
22 : {
23 : public:
24 0 : NS_INLINE_DECL_THREADSAFE_REFCOUNTING(PDMFactory)
25 :
26 : PDMFactory();
27 :
28 : // Factory method that creates the appropriate PlatformDecoderModule for
29 : // the platform we're running on. Caller is responsible for deleting this
30 : // instance. It's expected that there will be multiple
31 : // PlatformDecoderModules alive at the same time.
32 : // This is called on the decode task queue.
33 : already_AddRefed<MediaDataDecoder>
34 : CreateDecoder(const CreateDecoderParams& aParams);
35 :
36 : bool SupportsMimeType(const nsACString& aMimeType,
37 : DecoderDoctorDiagnostics* aDiagnostics) const;
38 : bool Supports(const TrackInfo& aTrackInfo,
39 : DecoderDoctorDiagnostics* aDiagnostics) const;
40 :
41 : // Creates a PlatformDecoderModule that uses a CDMProxy to decrypt or
42 : // decrypt-and-decode EME encrypted content. If the CDM only decrypts and
43 : // does not decode, we create a PDM and use that to create MediaDataDecoders
44 : // that we use on on aTaskQueue to decode the decrypted stream.
45 : // This is called on the decode task queue.
46 : void SetCDMProxy(CDMProxy* aProxy);
47 :
48 : static constexpr int kYUV400 = 0;
49 : static constexpr int kYUV420 = 1;
50 : static constexpr int kYUV422 = 2;
51 : static constexpr int kYUV444 = 3;
52 :
53 : private:
54 : virtual ~PDMFactory();
55 : void CreatePDMs();
56 : void CreateNullPDM();
57 : // Startup the provided PDM and add it to our list if successful.
58 : bool StartupPDM(PlatformDecoderModule* aPDM, bool aInsertAtBeginning = false);
59 : // Returns the first PDM in our list supporting the mimetype.
60 : already_AddRefed<PlatformDecoderModule>
61 : GetDecoder(const TrackInfo& aTrackInfo,
62 : DecoderDoctorDiagnostics* aDiagnostics) const;
63 :
64 : already_AddRefed<MediaDataDecoder>
65 : CreateDecoderWithPDM(PlatformDecoderModule* aPDM,
66 : const CreateDecoderParams& aParams);
67 :
68 : nsTArray<RefPtr<PlatformDecoderModule>> mCurrentPDMs;
69 : RefPtr<PlatformDecoderModule> mEMEPDM;
70 : RefPtr<PlatformDecoderModule> mNullPDM;
71 :
72 : bool mWMFFailedToLoad = false;
73 : bool mFFmpegFailedToLoad = false;
74 : bool mGMPPDMFailedToStartup = false;
75 :
76 : void EnsureInit() const;
77 : template<class T> friend class StaticAutoPtr;
78 : static StaticAutoPtr<PDMFactoryImpl> sInstance;
79 : static StaticMutex sMonitor;
80 : };
81 :
82 : } // namespace mozilla
83 :
84 : #endif /* PDMFactory_h_ */
|