2015-10-05 13:08:56 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim:set ts=2 sw=2 sts=2 et cindent: */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#if !defined(PDMFactory_h_)
|
|
|
|
#define PDMFactory_h_
|
|
|
|
|
|
|
|
#include "PlatformDecoderModule.h"
|
2016-05-12 11:54:35 +03:00
|
|
|
#include "mozilla/StaticMutex.h"
|
2015-10-05 13:08:56 +03:00
|
|
|
|
2015-10-06 11:56:29 +03:00
|
|
|
class CDMProxy;
|
|
|
|
|
2015-10-05 13:08:56 +03:00
|
|
|
namespace mozilla {
|
|
|
|
|
2016-04-19 10:36:19 +03:00
|
|
|
class DecoderDoctorDiagnostics;
|
2016-05-12 11:54:35 +03:00
|
|
|
class PDMFactoryImpl;
|
|
|
|
template<class T> class StaticAutoPtr;
|
2016-04-19 10:36:19 +03:00
|
|
|
|
2017-02-07 09:57:04 +03:00
|
|
|
class PDMFactory final
|
|
|
|
{
|
2015-10-05 13:08:56 +03:00
|
|
|
public:
|
2015-10-06 12:10:31 +03:00
|
|
|
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(PDMFactory)
|
|
|
|
|
2015-10-05 13:08:56 +03:00
|
|
|
PDMFactory();
|
|
|
|
|
2015-10-06 12:10:31 +03:00
|
|
|
// Factory method that creates the appropriate PlatformDecoderModule for
|
|
|
|
// the platform we're running on. Caller is responsible for deleting this
|
|
|
|
// instance. It's expected that there will be multiple
|
|
|
|
// PlatformDecoderModules alive at the same time.
|
|
|
|
// This is called on the decode task queue.
|
2015-10-05 13:08:56 +03:00
|
|
|
already_AddRefed<MediaDataDecoder>
|
2016-06-28 08:56:55 +03:00
|
|
|
CreateDecoder(const CreateDecoderParams& aParams);
|
2015-10-05 13:08:56 +03:00
|
|
|
|
2016-04-19 10:36:19 +03:00
|
|
|
bool SupportsMimeType(const nsACString& aMimeType,
|
|
|
|
DecoderDoctorDiagnostics* aDiagnostics) const;
|
2016-10-07 07:30:30 +03:00
|
|
|
bool Supports(const TrackInfo& aTrackInfo,
|
|
|
|
DecoderDoctorDiagnostics* aDiagnostics) const;
|
2015-10-05 13:08:56 +03:00
|
|
|
|
2015-10-06 11:56:29 +03:00
|
|
|
// Creates a PlatformDecoderModule that uses a CDMProxy to decrypt or
|
|
|
|
// decrypt-and-decode EME encrypted content. If the CDM only decrypts and
|
|
|
|
// does not decode, we create a PDM and use that to create MediaDataDecoders
|
|
|
|
// that we use on on aTaskQueue to decode the decrypted stream.
|
|
|
|
// This is called on the decode task queue.
|
|
|
|
void SetCDMProxy(CDMProxy* aProxy);
|
|
|
|
|
2016-08-19 13:14:28 +03:00
|
|
|
static constexpr int kYUV400 = 0;
|
|
|
|
static constexpr int kYUV420 = 1;
|
|
|
|
static constexpr int kYUV422 = 2;
|
|
|
|
static constexpr int kYUV444 = 3;
|
|
|
|
|
2015-10-05 13:08:56 +03:00
|
|
|
private:
|
2015-10-06 12:10:31 +03:00
|
|
|
virtual ~PDMFactory();
|
2015-10-06 01:08:03 +03:00
|
|
|
void CreatePDMs();
|
2017-03-09 12:12:02 +03:00
|
|
|
void CreateNullPDM();
|
2015-10-06 01:08:03 +03:00
|
|
|
// Startup the provided PDM and add it to our list if successful.
|
2017-03-22 09:14:09 +03:00
|
|
|
bool StartupPDM(PlatformDecoderModule* aPDM, bool aInsertAtBeginning = false);
|
2015-10-06 01:08:03 +03:00
|
|
|
// Returns the first PDM in our list supporting the mimetype.
|
2015-11-04 18:01:51 +03:00
|
|
|
already_AddRefed<PlatformDecoderModule>
|
2016-10-07 07:30:30 +03:00
|
|
|
GetDecoder(const TrackInfo& aTrackInfo,
|
2016-04-19 10:36:19 +03:00
|
|
|
DecoderDoctorDiagnostics* aDiagnostics) const;
|
2015-11-04 18:01:51 +03:00
|
|
|
|
2015-10-28 16:46:30 +03:00
|
|
|
already_AddRefed<MediaDataDecoder>
|
|
|
|
CreateDecoderWithPDM(PlatformDecoderModule* aPDM,
|
2016-06-28 08:56:55 +03:00
|
|
|
const CreateDecoderParams& aParams);
|
2015-10-05 13:08:56 +03:00
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
nsTArray<RefPtr<PlatformDecoderModule>> mCurrentPDMs;
|
|
|
|
RefPtr<PlatformDecoderModule> mEMEPDM;
|
2017-03-09 12:12:02 +03:00
|
|
|
RefPtr<PlatformDecoderModule> mNullPDM;
|
2016-04-19 10:36:20 +03:00
|
|
|
|
2016-04-22 06:42:11 +03:00
|
|
|
bool mWMFFailedToLoad = false;
|
2016-04-19 10:36:20 +03:00
|
|
|
bool mFFmpegFailedToLoad = false;
|
2016-04-22 06:42:11 +03:00
|
|
|
bool mGMPPDMFailedToStartup = false;
|
2016-05-12 11:54:35 +03:00
|
|
|
|
|
|
|
void EnsureInit() const;
|
|
|
|
template<class T> friend class StaticAutoPtr;
|
|
|
|
static StaticAutoPtr<PDMFactoryImpl> sInstance;
|
|
|
|
static StaticMutex sMonitor;
|
2015-10-05 13:08:56 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif /* PDMFactory_h_ */
|