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 GMPVideoEncoderChild_h_
|
|
|
|
#define GMPVideoEncoderChild_h_
|
|
|
|
|
|
|
|
#include "nsString.h"
|
|
|
|
#include "mozilla/gmp/PGMPVideoEncoderChild.h"
|
|
|
|
#include "gmp-video-encode.h"
|
|
|
|
#include "GMPSharedMemManager.h"
|
|
|
|
#include "GMPVideoHost.h"
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace gmp {
|
|
|
|
|
|
|
|
class GMPChild;
|
|
|
|
|
|
|
|
class GMPVideoEncoderChild : public PGMPVideoEncoderChild,
|
2014-07-10 20:35:56 -07:00
|
|
|
public GMPVideoEncoderCallback,
|
2014-05-17 20:05:46 -07:00
|
|
|
public GMPSharedMemManager
|
|
|
|
{
|
|
|
|
public:
|
2014-08-31 20:50:23 -07:00
|
|
|
explicit GMPVideoEncoderChild(GMPChild* aPlugin);
|
2014-05-17 20:05:46 -07:00
|
|
|
virtual ~GMPVideoEncoderChild();
|
|
|
|
|
|
|
|
void Init(GMPVideoEncoder* aEncoder);
|
|
|
|
GMPVideoHostImpl& Host();
|
|
|
|
|
2014-07-10 20:35:56 -07:00
|
|
|
// GMPVideoEncoderCallback
|
2014-05-17 20:05:46 -07:00
|
|
|
virtual void Encoded(GMPVideoEncodedFrame* aEncodedFrame,
|
2014-07-10 20:36:21 -07:00
|
|
|
const uint8_t* aCodecSpecificInfo,
|
|
|
|
uint32_t aCodecSpecificInfoLength) MOZ_OVERRIDE;
|
2014-07-23 14:35:01 -07:00
|
|
|
virtual void Error(GMPErr aError) MOZ_OVERRIDE;
|
2014-05-17 20:05:46 -07:00
|
|
|
|
|
|
|
// GMPSharedMemManager
|
2014-07-28 08:44:20 -07:00
|
|
|
virtual bool Alloc(size_t aSize, Shmem::SharedMemory::SharedMemoryType aType, Shmem* aMem) MOZ_OVERRIDE
|
2014-07-01 19:26:35 -07:00
|
|
|
{
|
|
|
|
#ifndef SHMEM_ALLOC_IN_CHILD
|
|
|
|
return CallNeedShmem(aSize, aMem);
|
|
|
|
#else
|
|
|
|
#ifdef GMP_SAFE_SHMEM
|
|
|
|
return AllocShmem(aSize, aType, aMem);
|
|
|
|
#else
|
|
|
|
return AllocUnsafeShmem(aSize, aType, aMem);
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
}
|
2014-07-28 08:44:20 -07:00
|
|
|
virtual void Dealloc(Shmem& aMem) MOZ_OVERRIDE
|
2014-07-01 19:26:35 -07:00
|
|
|
{
|
|
|
|
#ifndef SHMEM_ALLOC_IN_CHILD
|
|
|
|
SendParentShmemForPool(aMem);
|
|
|
|
#else
|
|
|
|
DeallocShmem(aMem);
|
|
|
|
#endif
|
|
|
|
}
|
2014-05-17 20:05:46 -07:00
|
|
|
|
|
|
|
private:
|
|
|
|
// PGMPVideoEncoderChild
|
|
|
|
virtual bool RecvInitEncode(const GMPVideoCodec& aCodecSettings,
|
2014-07-10 20:35:56 -07:00
|
|
|
const nsTArray<uint8_t>& aCodecSpecific,
|
2014-05-17 20:05:46 -07:00
|
|
|
const int32_t& aNumberOfCores,
|
|
|
|
const uint32_t& aMaxPayloadSize) MOZ_OVERRIDE;
|
|
|
|
virtual bool RecvEncode(const GMPVideoi420FrameData& aInputFrame,
|
2014-07-10 20:36:21 -07:00
|
|
|
const nsTArray<uint8_t>& aCodecSpecificInfo,
|
2014-07-10 20:35:56 -07:00
|
|
|
const nsTArray<GMPVideoFrameType>& aFrameTypes) MOZ_OVERRIDE;
|
2014-07-01 19:26:35 -07:00
|
|
|
virtual bool RecvChildShmemForPool(Shmem& aEncodedBuffer) MOZ_OVERRIDE;
|
2014-05-17 20:05:46 -07:00
|
|
|
virtual bool RecvSetChannelParameters(const uint32_t& aPacketLoss,
|
|
|
|
const uint32_t& aRTT) MOZ_OVERRIDE;
|
|
|
|
virtual bool RecvSetRates(const uint32_t& aNewBitRate,
|
|
|
|
const uint32_t& aFrameRate) MOZ_OVERRIDE;
|
|
|
|
virtual bool RecvSetPeriodicKeyFrames(const bool& aEnable) MOZ_OVERRIDE;
|
|
|
|
virtual bool RecvEncodingComplete() MOZ_OVERRIDE;
|
|
|
|
|
|
|
|
GMPChild* mPlugin;
|
|
|
|
GMPVideoEncoder* mVideoEncoder;
|
|
|
|
GMPVideoHostImpl mVideoHost;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace gmp
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // GMPVideoEncoderChild_h_
|