2014-05-17 20:05:46 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* 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/. */
|
|
|
|
|
|
|
|
#ifndef GMPParent_h_
|
|
|
|
#define GMPParent_h_
|
|
|
|
|
|
|
|
#include "GMPProcessParent.h"
|
2014-07-28 08:42:55 -07:00
|
|
|
#include "GMPService.h"
|
2014-08-02 14:29:26 -07:00
|
|
|
#include "GMPAudioDecoderParent.h"
|
2014-07-27 16:20:34 -07:00
|
|
|
#include "GMPDecryptorParent.h"
|
2014-05-17 20:05:46 -07:00
|
|
|
#include "GMPVideoDecoderParent.h"
|
|
|
|
#include "GMPVideoEncoderParent.h"
|
2014-08-05 00:56:05 -07:00
|
|
|
#include "GMPTimerParent.h"
|
2014-08-19 01:56:33 -07:00
|
|
|
#include "GMPStorageParent.h"
|
2014-05-17 20:05:46 -07:00
|
|
|
#include "mozilla/gmp/PGMPParent.h"
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nscore.h"
|
|
|
|
#include "nsISupports.h"
|
|
|
|
#include "nsString.h"
|
|
|
|
#include "nsTArray.h"
|
2014-07-10 11:48:11 -07:00
|
|
|
#include "nsIFile.h"
|
2014-07-10 20:36:38 -07:00
|
|
|
#include "ThreadSafeRefcountingWithMainThreadDestruction.h"
|
2014-05-17 20:05:46 -07:00
|
|
|
|
|
|
|
class nsILineInputStream;
|
|
|
|
class nsIThread;
|
|
|
|
|
2014-07-18 10:35:44 -07:00
|
|
|
#ifdef MOZ_CRASHREPORTER
|
|
|
|
#include "nsExceptionHandler.h"
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
class PCrashReporterParent;
|
|
|
|
class CrashReporterParent;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2014-05-17 20:05:46 -07:00
|
|
|
namespace mozilla {
|
|
|
|
namespace gmp {
|
|
|
|
|
|
|
|
class GMPCapability
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
nsCString mAPIName;
|
|
|
|
nsTArray<nsCString> mAPITags;
|
|
|
|
};
|
|
|
|
|
|
|
|
enum GMPState {
|
|
|
|
GMPStateNotLoaded,
|
2014-07-18 10:37:06 -07:00
|
|
|
GMPStateLoaded,
|
2014-07-19 16:14:03 -07:00
|
|
|
GMPStateUnloading,
|
2014-07-18 10:37:06 -07:00
|
|
|
GMPStateClosing
|
2014-05-17 20:05:46 -07:00
|
|
|
};
|
|
|
|
|
2014-07-28 08:44:20 -07:00
|
|
|
class GMPParent MOZ_FINAL : public PGMPParent,
|
|
|
|
public GMPSharedMem
|
2014-05-17 20:05:46 -07:00
|
|
|
{
|
|
|
|
public:
|
2014-07-10 20:36:38 -07:00
|
|
|
NS_INLINE_DECL_THREADSAFE_REFCOUNTING_WITH_MAIN_THREAD_DESTRUCTION(GMPParent)
|
2014-05-17 20:05:46 -07:00
|
|
|
|
|
|
|
GMPParent();
|
|
|
|
|
2014-07-28 08:42:55 -07:00
|
|
|
nsresult Init(GeckoMediaPluginService *aService, nsIFile* aPluginDir);
|
|
|
|
nsresult CloneFrom(const GMPParent* aOther);
|
|
|
|
|
2014-07-30 14:40:43 -07:00
|
|
|
void Crash();
|
|
|
|
|
2014-05-17 20:05:46 -07:00
|
|
|
nsresult LoadProcess();
|
2014-07-18 10:37:06 -07:00
|
|
|
|
|
|
|
// Called internally to close this if we don't need it
|
|
|
|
void CloseIfUnused();
|
|
|
|
|
|
|
|
// Notify all active de/encoders that we are closing, either because of
|
|
|
|
// normal shutdown or unexpected shutdown/crash.
|
2014-07-24 18:47:41 -07:00
|
|
|
void CloseActive(bool aDieWhenUnloaded);
|
2014-07-18 10:37:06 -07:00
|
|
|
|
|
|
|
// Called by the GMPService to forcibly close active de/encoders at shutdown
|
|
|
|
void Shutdown();
|
|
|
|
|
|
|
|
// This must not be called while we're in the middle of abnormal ActorDestroy
|
|
|
|
void DeleteProcess();
|
|
|
|
|
2014-05-17 20:05:46 -07:00
|
|
|
bool SupportsAPI(const nsCString& aAPI, const nsCString& aTag);
|
2014-07-27 16:20:34 -07:00
|
|
|
|
2014-05-17 20:05:46 -07:00
|
|
|
nsresult GetGMPVideoDecoder(GMPVideoDecoderParent** aGMPVD);
|
|
|
|
void VideoDecoderDestroyed(GMPVideoDecoderParent* aDecoder);
|
2014-07-27 16:20:34 -07:00
|
|
|
|
2014-05-17 20:05:46 -07:00
|
|
|
nsresult GetGMPVideoEncoder(GMPVideoEncoderParent** aGMPVE);
|
|
|
|
void VideoEncoderDestroyed(GMPVideoEncoderParent* aEncoder);
|
2014-07-27 16:20:34 -07:00
|
|
|
|
|
|
|
nsresult GetGMPDecryptor(GMPDecryptorParent** aGMPKS);
|
|
|
|
void DecryptorDestroyed(GMPDecryptorParent* aSession);
|
|
|
|
|
2014-08-02 14:29:26 -07:00
|
|
|
nsresult GetGMPAudioDecoder(GMPAudioDecoderParent** aGMPAD);
|
|
|
|
void AudioDecoderDestroyed(GMPAudioDecoderParent* aDecoder);
|
|
|
|
|
2014-05-17 20:05:46 -07:00
|
|
|
GMPState State() const;
|
|
|
|
nsIThread* GMPThread();
|
|
|
|
|
2014-10-12 15:53:43 -07:00
|
|
|
// A GMP can either be a single instance shared across all NodeIds (like
|
2014-06-29 16:02:39 -07:00
|
|
|
// in the OpenH264 case), or we can require a new plugin instance for every
|
2014-10-12 15:53:43 -07:00
|
|
|
// NodeIds running the plugin (as in the EME plugin case).
|
2014-06-29 16:02:39 -07:00
|
|
|
//
|
2014-10-12 15:53:43 -07:00
|
|
|
// A NodeId is a hash of the ($urlBarOrigin, $ownerDocOrigin) pair.
|
|
|
|
//
|
|
|
|
// Plugins are associated with an NodeIds by calling SetNodeId() before
|
2014-06-29 16:02:39 -07:00
|
|
|
// loading.
|
|
|
|
//
|
2014-10-12 15:53:43 -07:00
|
|
|
// If a plugin has no NodeId specified and it is loaded, it is assumed to
|
|
|
|
// be shared across NodeIds.
|
2014-06-29 16:02:39 -07:00
|
|
|
|
2014-10-12 15:53:43 -07:00
|
|
|
// Specifies that a GMP can only work with the specified NodeIds.
|
|
|
|
void SetNodeId(const nsACString& aNodeId);
|
2014-06-29 16:02:39 -07:00
|
|
|
|
2014-10-12 15:53:43 -07:00
|
|
|
// Returns true if a plugin can be or is being used across multiple NodeIds.
|
|
|
|
bool CanBeSharedCrossNodeIds() const;
|
2014-06-29 16:02:39 -07:00
|
|
|
|
2014-10-12 15:53:43 -07:00
|
|
|
// A GMP can be used from a NodeId if it's already been set to work with
|
|
|
|
// that NodeId, or if it's not been set to work with any NodeId and has
|
|
|
|
// not yet been loaded (i.e. it's not shared across NodeIds).
|
|
|
|
bool CanBeUsedFrom(const nsACString& aNodeId) const;
|
2014-06-29 16:02:39 -07:00
|
|
|
|
2014-07-10 11:48:11 -07:00
|
|
|
already_AddRefed<nsIFile> GetDirectory() {
|
|
|
|
return nsCOMPtr<nsIFile>(mDirectory).forget();
|
|
|
|
}
|
|
|
|
|
2014-07-28 08:44:20 -07:00
|
|
|
// GMPSharedMem
|
|
|
|
virtual void CheckThread() MOZ_OVERRIDE;
|
|
|
|
|
2014-08-17 14:41:56 -07:00
|
|
|
void AbortAsyncShutdown();
|
|
|
|
|
2014-10-20 18:53:30 -07:00
|
|
|
bool HasAccessedStorage() const;
|
|
|
|
|
2014-05-17 20:05:46 -07:00
|
|
|
private:
|
|
|
|
~GMPParent();
|
2014-07-28 08:42:55 -07:00
|
|
|
nsRefPtr<GeckoMediaPluginService> mService;
|
2014-05-17 20:05:46 -07:00
|
|
|
bool EnsureProcessLoaded();
|
|
|
|
nsresult ReadGMPMetaData();
|
2014-07-18 10:35:44 -07:00
|
|
|
#ifdef MOZ_CRASHREPORTER
|
|
|
|
void WriteExtraDataForMinidump(CrashReporter::AnnotationTable& notes);
|
|
|
|
void GetCrashID(nsString& aResult);
|
|
|
|
#endif
|
2014-05-17 20:05:46 -07:00
|
|
|
virtual void ActorDestroy(ActorDestroyReason aWhy) MOZ_OVERRIDE;
|
2014-07-18 10:35:44 -07:00
|
|
|
|
|
|
|
virtual PCrashReporterParent* AllocPCrashReporterParent(const NativeThreadId& aThread) MOZ_OVERRIDE;
|
|
|
|
virtual bool DeallocPCrashReporterParent(PCrashReporterParent* aCrashReporter) MOZ_OVERRIDE;
|
2014-07-27 16:20:34 -07:00
|
|
|
|
2014-05-17 20:05:46 -07:00
|
|
|
virtual PGMPVideoDecoderParent* AllocPGMPVideoDecoderParent() MOZ_OVERRIDE;
|
|
|
|
virtual bool DeallocPGMPVideoDecoderParent(PGMPVideoDecoderParent* aActor) MOZ_OVERRIDE;
|
2014-08-05 00:56:05 -07:00
|
|
|
|
2014-05-17 20:05:46 -07:00
|
|
|
virtual PGMPVideoEncoderParent* AllocPGMPVideoEncoderParent() MOZ_OVERRIDE;
|
|
|
|
virtual bool DeallocPGMPVideoEncoderParent(PGMPVideoEncoderParent* aActor) MOZ_OVERRIDE;
|
|
|
|
|
2014-07-27 16:20:34 -07:00
|
|
|
virtual PGMPDecryptorParent* AllocPGMPDecryptorParent() MOZ_OVERRIDE;
|
|
|
|
virtual bool DeallocPGMPDecryptorParent(PGMPDecryptorParent* aActor) MOZ_OVERRIDE;
|
|
|
|
|
2014-08-02 14:29:26 -07:00
|
|
|
virtual PGMPAudioDecoderParent* AllocPGMPAudioDecoderParent() MOZ_OVERRIDE;
|
|
|
|
virtual bool DeallocPGMPAudioDecoderParent(PGMPAudioDecoderParent* aActor) MOZ_OVERRIDE;
|
|
|
|
|
2014-08-19 01:56:33 -07:00
|
|
|
virtual bool RecvPGMPStorageConstructor(PGMPStorageParent* actor) MOZ_OVERRIDE;
|
|
|
|
virtual PGMPStorageParent* AllocPGMPStorageParent() MOZ_OVERRIDE;
|
|
|
|
virtual bool DeallocPGMPStorageParent(PGMPStorageParent* aActor) MOZ_OVERRIDE;
|
|
|
|
|
2014-08-05 00:56:05 -07:00
|
|
|
virtual bool RecvPGMPTimerConstructor(PGMPTimerParent* actor) MOZ_OVERRIDE;
|
|
|
|
virtual PGMPTimerParent* AllocPGMPTimerParent() MOZ_OVERRIDE;
|
|
|
|
virtual bool DeallocPGMPTimerParent(PGMPTimerParent* aActor) MOZ_OVERRIDE;
|
|
|
|
|
2014-08-17 14:41:56 -07:00
|
|
|
virtual bool RecvAsyncShutdownComplete() MOZ_OVERRIDE;
|
|
|
|
virtual bool RecvAsyncShutdownRequired() MOZ_OVERRIDE;
|
|
|
|
|
2014-10-21 13:45:18 -07:00
|
|
|
nsresult EnsureAsyncShutdownTimeoutSet();
|
|
|
|
|
2014-05-17 20:05:46 -07:00
|
|
|
GMPState mState;
|
|
|
|
nsCOMPtr<nsIFile> mDirectory; // plugin directory on disk
|
|
|
|
nsString mName; // base name of plugin on disk, UTF-16 because used for paths
|
|
|
|
nsCString mDisplayName; // name of plugin displayed to users
|
|
|
|
nsCString mDescription; // description of plugin for display to users
|
|
|
|
nsCString mVersion;
|
|
|
|
nsTArray<nsAutoPtr<GMPCapability>> mCapabilities;
|
|
|
|
GMPProcessParent* mProcess;
|
2014-07-28 08:42:55 -07:00
|
|
|
bool mDeleteProcessOnlyOnUnload;
|
|
|
|
bool mAbnormalShutdownInProgress;
|
2014-05-17 20:05:46 -07:00
|
|
|
|
|
|
|
nsTArray<nsRefPtr<GMPVideoDecoderParent>> mVideoDecoders;
|
|
|
|
nsTArray<nsRefPtr<GMPVideoEncoderParent>> mVideoEncoders;
|
2014-07-27 16:20:34 -07:00
|
|
|
nsTArray<nsRefPtr<GMPDecryptorParent>> mDecryptors;
|
2014-08-02 14:29:26 -07:00
|
|
|
nsTArray<nsRefPtr<GMPAudioDecoderParent>> mAudioDecoders;
|
2014-08-17 14:41:56 -07:00
|
|
|
nsTArray<nsRefPtr<GMPTimerParent>> mTimers;
|
2014-08-19 01:56:33 -07:00
|
|
|
nsTArray<nsRefPtr<GMPStorageParent>> mStorage;
|
2014-05-17 20:05:46 -07:00
|
|
|
nsCOMPtr<nsIThread> mGMPThread;
|
2014-10-21 13:45:18 -07:00
|
|
|
nsCOMPtr<nsITimer> mAsyncShutdownTimeout; // GMP Thread only.
|
2014-10-12 15:53:43 -07:00
|
|
|
// NodeId the plugin is assigned to, or empty if the the plugin is not
|
|
|
|
// assigned to a NodeId.
|
|
|
|
nsAutoCString mNodeId;
|
2014-08-17 14:41:56 -07:00
|
|
|
|
|
|
|
bool mAsyncShutdownRequired;
|
|
|
|
bool mAsyncShutdownInProgress;
|
2014-10-20 18:53:30 -07:00
|
|
|
bool mHasAccessedStorage;
|
2014-05-17 20:05:46 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace gmp
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // GMPParent_h_
|