2014-05-18 07:05:46 +04: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 GMPVideoDecoderParent_h_
|
|
|
|
#define GMPVideoDecoderParent_h_
|
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
#include "mozilla/RefPtr.h"
|
2014-05-18 07:05:46 +04:00
|
|
|
#include "gmp-video-decode.h"
|
|
|
|
#include "mozilla/gmp/PGMPVideoDecoderParent.h"
|
|
|
|
#include "GMPMessageUtils.h"
|
|
|
|
#include "GMPSharedMemManager.h"
|
2015-01-20 08:39:00 +03:00
|
|
|
#include "GMPUtils.h"
|
2014-05-18 07:05:46 +04:00
|
|
|
#include "GMPVideoHost.h"
|
2014-07-11 07:35:56 +04:00
|
|
|
#include "GMPVideoDecoderProxy.h"
|
2015-09-29 03:06:14 +03:00
|
|
|
#include "VideoUtils.h"
|
2016-06-29 02:42:00 +03:00
|
|
|
#include "GMPCrashHelperHolder.h"
|
2014-05-18 07:05:46 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace gmp {
|
|
|
|
|
2015-02-10 13:48:42 +03:00
|
|
|
class GMPContentParent;
|
2014-05-18 07:05:46 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
class GMPVideoDecoderParent final : public PGMPVideoDecoderParent
|
2015-03-27 21:52:19 +03:00
|
|
|
, public GMPVideoDecoderProxy
|
|
|
|
, public GMPSharedMemManager
|
2016-06-29 02:42:00 +03:00
|
|
|
, public GMPCrashHelperHolder
|
2014-05-18 07:05:46 +04:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_INLINE_DECL_REFCOUNTING(GMPVideoDecoderParent)
|
|
|
|
|
2015-02-10 13:48:42 +03:00
|
|
|
explicit GMPVideoDecoderParent(GMPContentParent *aPlugin);
|
2014-05-18 07:05:46 +04:00
|
|
|
|
|
|
|
GMPVideoHostImpl& Host();
|
2014-07-25 05:47:40 +04:00
|
|
|
nsresult Shutdown();
|
2014-05-18 07:05:46 +04:00
|
|
|
|
2014-07-11 05:43:04 +04:00
|
|
|
// GMPVideoDecoder
|
2016-01-18 06:40:49 +03:00
|
|
|
void Close() override;
|
|
|
|
nsresult InitDecode(const GMPVideoCodec& aCodecSettings,
|
|
|
|
const nsTArray<uint8_t>& aCodecSpecific,
|
|
|
|
GMPVideoDecoderCallbackProxy* aCallback,
|
|
|
|
int32_t aCoreCount) override;
|
|
|
|
nsresult Decode(GMPUniquePtr<GMPVideoEncodedFrame> aInputFrame,
|
|
|
|
bool aMissingFrames,
|
|
|
|
const nsTArray<uint8_t>& aCodecSpecificInfo,
|
|
|
|
int64_t aRenderTimeMs = -1) override;
|
|
|
|
nsresult Reset() override;
|
|
|
|
nsresult Drain() override;
|
|
|
|
uint32_t GetPluginId() const override { return mPluginId; }
|
|
|
|
const nsCString& GetDisplayName() const override;
|
2014-07-02 06:26:35 +04:00
|
|
|
|
2014-07-02 06:26:35 +04:00
|
|
|
// GMPSharedMemManager
|
2016-01-18 06:40:49 +03:00
|
|
|
bool Alloc(size_t aSize, Shmem::SharedMemory::SharedMemoryType aType, Shmem* aMem) override
|
2014-07-02 06:26:35 +04:00
|
|
|
{
|
|
|
|
#ifdef GMP_SAFE_SHMEM
|
|
|
|
return AllocShmem(aSize, aType, aMem);
|
|
|
|
#else
|
|
|
|
return AllocUnsafeShmem(aSize, aType, aMem);
|
|
|
|
#endif
|
|
|
|
}
|
2016-01-18 06:40:49 +03:00
|
|
|
void Dealloc(Shmem& aMem) override
|
2014-07-02 06:26:35 +04:00
|
|
|
{
|
|
|
|
DeallocShmem(aMem);
|
|
|
|
}
|
|
|
|
|
2014-05-18 07:05:46 +04:00
|
|
|
private:
|
|
|
|
~GMPVideoDecoderParent();
|
|
|
|
|
|
|
|
// PGMPVideoDecoderParent
|
2016-01-18 06:40:49 +03:00
|
|
|
void ActorDestroy(ActorDestroyReason aWhy) override;
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult RecvDecoded(const GMPVideoi420FrameData& aDecodedFrame) override;
|
|
|
|
mozilla::ipc::IPCResult RecvReceivedDecodedReferenceFrame(const uint64_t& aPictureId) override;
|
|
|
|
mozilla::ipc::IPCResult RecvReceivedDecodedFrame(const uint64_t& aPictureId) override;
|
|
|
|
mozilla::ipc::IPCResult RecvInputDataExhausted() override;
|
|
|
|
mozilla::ipc::IPCResult RecvDrainComplete() override;
|
|
|
|
mozilla::ipc::IPCResult RecvResetComplete() override;
|
|
|
|
mozilla::ipc::IPCResult RecvError(const GMPErr& aError) override;
|
|
|
|
mozilla::ipc::IPCResult RecvShutdown() override;
|
|
|
|
mozilla::ipc::IPCResult RecvParentShmemForPool(Shmem&& aEncodedBuffer) override;
|
|
|
|
mozilla::ipc::IPCResult AnswerNeedShmem(const uint32_t& aFrameBufferSize,
|
|
|
|
Shmem* aMem) override;
|
|
|
|
mozilla::ipc::IPCResult Recv__delete__() override;
|
2014-05-18 07:05:46 +04:00
|
|
|
|
2015-07-27 02:52:16 +03:00
|
|
|
void UnblockResetAndDrain();
|
2015-09-29 03:06:14 +03:00
|
|
|
void CancelResetCompleteTimeout();
|
2015-07-27 02:52:16 +03:00
|
|
|
|
2014-07-25 05:47:40 +04:00
|
|
|
bool mIsOpen;
|
2014-10-14 02:04:59 +04:00
|
|
|
bool mShuttingDown;
|
2015-04-21 07:32:15 +03:00
|
|
|
bool mActorDestroyed;
|
2015-07-27 02:52:16 +03:00
|
|
|
bool mIsAwaitingResetComplete;
|
|
|
|
bool mIsAwaitingDrainComplete;
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<GMPContentParent> mPlugin;
|
2014-07-25 05:47:40 +04:00
|
|
|
GMPVideoDecoderCallbackProxy* mCallback;
|
2014-05-18 07:05:46 +04:00
|
|
|
GMPVideoHostImpl mVideoHost;
|
2015-06-05 12:55:51 +03:00
|
|
|
const uint32_t mPluginId;
|
2015-09-29 03:06:14 +03:00
|
|
|
int32_t mFrameCount;
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<SimpleTimer> mResetCompleteTimeout;
|
2014-05-18 07:05:46 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace gmp
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // GMPVideoDecoderParent_h_
|