2015-02-02 11:49:00 +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(GMPVideoDecoder_h_)
|
|
|
|
#define GMPVideoDecoder_h_
|
|
|
|
|
|
|
|
#include "GMPVideoDecoderProxy.h"
|
|
|
|
#include "ImageContainer.h"
|
|
|
|
#include "MediaDataDecoderProxy.h"
|
2017-02-15 21:09:29 +03:00
|
|
|
#include "MediaInfo.h"
|
2015-02-02 11:49:00 +03:00
|
|
|
#include "PlatformDecoderModule.h"
|
|
|
|
#include "mozIGeckoMediaPluginService.h"
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
2017-01-26 15:56:46 +03:00
|
|
|
struct GMPVideoDecoderParams
|
|
|
|
{
|
2016-06-28 08:56:56 +03:00
|
|
|
explicit GMPVideoDecoderParams(const CreateDecoderParams& aParams);
|
|
|
|
|
|
|
|
const VideoInfo& mConfig;
|
|
|
|
TaskQueue* mTaskQueue;
|
|
|
|
layers::ImageContainer* mImageContainer;
|
|
|
|
layers::LayersBackend mLayersBackend;
|
2016-06-29 02:42:07 +03:00
|
|
|
RefPtr<GMPCrashHelper> mCrashHelper;
|
2016-06-28 08:56:56 +03:00
|
|
|
};
|
|
|
|
|
2017-01-26 15:56:46 +03:00
|
|
|
class GMPVideoDecoder : public MediaDataDecoder,
|
|
|
|
public GMPVideoDecoderCallbackProxy
|
|
|
|
{
|
2016-06-28 08:56:56 +03:00
|
|
|
public:
|
|
|
|
explicit GMPVideoDecoder(const GMPVideoDecoderParams& aParams);
|
2015-02-02 11:49:00 +03:00
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<InitPromise> Init() override;
|
2017-01-26 15:56:46 +03:00
|
|
|
RefPtr<DecodePromise> Decode(MediaRawData* aSample) override;
|
|
|
|
RefPtr<DecodePromise> Drain() override;
|
|
|
|
RefPtr<FlushPromise> Flush() override;
|
|
|
|
RefPtr<ShutdownPromise> Shutdown() override;
|
2016-01-22 04:29:51 +03:00
|
|
|
const char* GetDescriptionName() const override
|
|
|
|
{
|
|
|
|
return "GMP video decoder";
|
|
|
|
}
|
2017-02-18 00:19:55 +03:00
|
|
|
ConversionRequired NeedsConversion() const override
|
|
|
|
{
|
2017-02-23 01:00:28 +03:00
|
|
|
return mConvertToAnnexB ? ConversionRequired::kNeedAnnexB
|
|
|
|
: ConversionRequired::kNeedAVCC;
|
2017-02-18 00:19:55 +03:00
|
|
|
}
|
2015-02-02 11:49:00 +03:00
|
|
|
|
2017-01-26 15:56:46 +03:00
|
|
|
// GMPVideoDecoderCallbackProxy
|
|
|
|
// All those methods are called on the GMP thread.
|
|
|
|
void Decoded(GMPVideoi420Frame* aDecodedFrame) override;
|
|
|
|
void ReceivedDecodedReferenceFrame(const uint64_t aPictureId) override;
|
|
|
|
void ReceivedDecodedFrame(const uint64_t aPictureId) override;
|
|
|
|
void InputDataExhausted() override;
|
|
|
|
void DrainComplete() override;
|
|
|
|
void ResetComplete() override;
|
|
|
|
void Error(GMPErr aErr) override;
|
|
|
|
void Terminated() override;
|
|
|
|
|
2015-02-02 11:49:00 +03:00
|
|
|
protected:
|
|
|
|
virtual void InitTags(nsTArray<nsCString>& aTags);
|
|
|
|
virtual nsCString GetNodeId();
|
2016-11-14 01:07:02 +03:00
|
|
|
virtual uint32_t DecryptorId() const { return 0; }
|
2015-04-17 19:43:18 +03:00
|
|
|
virtual GMPUniquePtr<GMPVideoEncodedFrame> CreateFrame(MediaRawData* aSample);
|
2016-07-29 06:53:22 +03:00
|
|
|
virtual const VideoInfo& GetConfig() const;
|
2015-02-02 11:49:00 +03:00
|
|
|
|
|
|
|
private:
|
2015-02-10 13:49:03 +03:00
|
|
|
|
2015-02-10 13:48:29 +03:00
|
|
|
class GMPInitDoneCallback : public GetGMPVideoDecoderCallback
|
|
|
|
{
|
|
|
|
public:
|
2015-10-08 10:38:59 +03:00
|
|
|
explicit GMPInitDoneCallback(GMPVideoDecoder* aDecoder)
|
2015-02-10 13:48:29 +03:00
|
|
|
: mDecoder(aDecoder)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2015-09-21 07:35:18 +03:00
|
|
|
void Done(GMPVideoDecoderProxy* aGMP, GMPVideoHost* aHost) override
|
2015-02-10 13:48:29 +03:00
|
|
|
{
|
2015-10-08 10:38:59 +03:00
|
|
|
mDecoder->GMPInitDone(aGMP, aHost);
|
2015-02-10 13:48:29 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<GMPVideoDecoder> mDecoder;
|
2015-02-10 13:48:29 +03:00
|
|
|
};
|
|
|
|
void GMPInitDone(GMPVideoDecoderProxy* aGMP, GMPVideoHost* aHost);
|
|
|
|
|
2016-03-16 08:49:26 +03:00
|
|
|
const VideoInfo mConfig;
|
2015-02-02 11:49:00 +03:00
|
|
|
nsCOMPtr<mozIGeckoMediaPluginService> mMPS;
|
|
|
|
GMPVideoDecoderProxy* mGMP;
|
|
|
|
GMPVideoHost* mHost;
|
2015-03-20 07:52:10 +03:00
|
|
|
bool mConvertNALUnitLengths;
|
2015-10-08 10:38:59 +03:00
|
|
|
MozPromiseHolder<InitPromise> mInitPromise;
|
2016-06-29 02:42:07 +03:00
|
|
|
RefPtr<GMPCrashHelper> mCrashHelper;
|
2017-01-26 15:56:46 +03:00
|
|
|
|
|
|
|
int64_t mLastStreamOffset = 0;
|
|
|
|
RefPtr<layers::ImageContainer> mImageContainer;
|
|
|
|
|
|
|
|
MozPromiseHolder<DecodePromise> mDecodePromise;
|
|
|
|
MozPromiseHolder<DecodePromise> mDrainPromise;
|
|
|
|
MozPromiseHolder<FlushPromise> mFlushPromise;
|
|
|
|
DecodedData mDecodedData;
|
2017-02-23 01:00:28 +03:00
|
|
|
bool mConvertToAnnexB = false;
|
2015-02-02 11:49:00 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // GMPVideoDecoder_h_
|