2014-05-18 07:05:46 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* Copyright (c) 2014, Mozilla Corporation
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
*
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
*
|
|
|
|
* 2. Redistributions in binary form must reproduce the above
|
|
|
|
* copyright notice, this list of conditions and the following
|
|
|
|
* disclaimer in the documentation and/or other materials provided
|
|
|
|
* with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
|
|
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
|
|
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
|
|
|
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
|
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
|
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
|
|
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
|
|
|
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef GMPVideoEncodedFrameImpl_h_
|
|
|
|
#define GMPVideoEncodedFrameImpl_h_
|
|
|
|
|
2014-07-11 07:35:56 +04:00
|
|
|
#include "gmp-errors.h"
|
2014-05-18 07:05:46 +04:00
|
|
|
#include "gmp-video-frame.h"
|
|
|
|
#include "gmp-video-frame-encoded.h"
|
2014-07-11 07:35:56 +04:00
|
|
|
#include "gmp-decryption.h"
|
2014-05-18 07:05:46 +04:00
|
|
|
#include "mozilla/ipc/Shmem.h"
|
|
|
|
|
|
|
|
namespace mozilla {
|
2015-04-09 14:14:55 +03:00
|
|
|
class CryptoSample;
|
|
|
|
|
2014-05-18 07:05:46 +04:00
|
|
|
namespace gmp {
|
|
|
|
|
|
|
|
class GMPVideoHostImpl;
|
|
|
|
class GMPVideoEncodedFrameData;
|
2014-08-03 01:29:18 +04:00
|
|
|
class GMPEncryptedBufferDataImpl;
|
2014-05-18 07:05:46 +04:00
|
|
|
|
|
|
|
class GMPVideoEncodedFrameImpl: public GMPVideoEncodedFrame
|
|
|
|
{
|
|
|
|
friend struct IPC::ParamTraits<mozilla::gmp::GMPVideoEncodedFrameImpl>;
|
|
|
|
public:
|
2014-09-01 07:50:23 +04:00
|
|
|
explicit GMPVideoEncodedFrameImpl(GMPVideoHostImpl* aHost);
|
2014-05-18 07:05:46 +04:00
|
|
|
GMPVideoEncodedFrameImpl(const GMPVideoEncodedFrameData& aFrameData, GMPVideoHostImpl* aHost);
|
|
|
|
virtual ~GMPVideoEncodedFrameImpl();
|
|
|
|
|
2015-04-09 14:14:55 +03:00
|
|
|
void InitCrypto(const CryptoSample& aCrypto);
|
2014-08-03 01:29:18 +04:00
|
|
|
|
2014-05-18 07:05:46 +04:00
|
|
|
// This is called during a normal destroy sequence, which is
|
|
|
|
// when a consumer is finished or during XPCOM shutdown.
|
|
|
|
void DoneWithAPI();
|
|
|
|
// Does not attempt to release Shmem, as the Shmem has already been released.
|
|
|
|
void ActorDestroyed();
|
|
|
|
|
|
|
|
bool RelinquishFrameData(GMPVideoEncodedFrameData& aFrameData);
|
|
|
|
|
|
|
|
// GMPVideoFrame
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual GMPVideoFrameFormat GetFrameFormat() override;
|
|
|
|
virtual void Destroy() override;
|
2014-05-18 07:05:46 +04:00
|
|
|
|
|
|
|
// GMPVideoEncodedFrame
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual GMPErr CreateEmptyFrame(uint32_t aSize) override;
|
|
|
|
virtual GMPErr CopyFrame(const GMPVideoEncodedFrame& aFrame) override;
|
|
|
|
virtual void SetEncodedWidth(uint32_t aEncodedWidth) override;
|
|
|
|
virtual uint32_t EncodedWidth() override;
|
|
|
|
virtual void SetEncodedHeight(uint32_t aEncodedHeight) override;
|
|
|
|
virtual uint32_t EncodedHeight() override;
|
2014-07-11 07:35:56 +04:00
|
|
|
// Microseconds
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void SetTimeStamp(uint64_t aTimeStamp) override;
|
|
|
|
virtual uint64_t TimeStamp() override;
|
2014-07-11 07:35:56 +04:00
|
|
|
// Set frame duration (microseconds)
|
|
|
|
// NOTE: next-frame's Timestamp() != this-frame's TimeStamp()+Duration()
|
|
|
|
// depending on rounding to avoid having to track roundoff errors
|
|
|
|
// and dropped/missing frames(!) (which may leave a large gap)
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void SetDuration(uint64_t aDuration) override;
|
|
|
|
virtual uint64_t Duration() const override;
|
|
|
|
virtual void SetFrameType(GMPVideoFrameType aFrameType) override;
|
|
|
|
virtual GMPVideoFrameType FrameType() override;
|
|
|
|
virtual void SetAllocatedSize(uint32_t aNewSize) override;
|
|
|
|
virtual uint32_t AllocatedSize() override;
|
|
|
|
virtual void SetSize(uint32_t aSize) override;
|
|
|
|
virtual uint32_t Size() override;
|
|
|
|
virtual void SetCompleteFrame(bool aCompleteFrame) override;
|
|
|
|
virtual bool CompleteFrame() override;
|
|
|
|
virtual const uint8_t* Buffer() const override;
|
|
|
|
virtual uint8_t* Buffer() override;
|
|
|
|
virtual GMPBufferType BufferType() const override;
|
|
|
|
virtual void SetBufferType(GMPBufferType aBufferType) override;
|
|
|
|
virtual const GMPEncryptedBufferMetadata* GetDecryptionData() const override;
|
2014-05-18 07:05:46 +04:00
|
|
|
|
|
|
|
private:
|
|
|
|
void DestroyBuffer();
|
|
|
|
|
|
|
|
uint32_t mEncodedWidth;
|
|
|
|
uint32_t mEncodedHeight;
|
2014-07-11 07:35:56 +04:00
|
|
|
uint64_t mTimeStamp;
|
|
|
|
uint64_t mDuration;
|
2014-05-18 07:05:46 +04:00
|
|
|
GMPVideoFrameType mFrameType;
|
|
|
|
uint32_t mSize;
|
|
|
|
bool mCompleteFrame;
|
|
|
|
GMPVideoHostImpl* mHost;
|
|
|
|
ipc::Shmem mBuffer;
|
2014-07-11 18:39:10 +04:00
|
|
|
GMPBufferType mBufferType;
|
2014-08-03 01:29:18 +04:00
|
|
|
nsAutoPtr<GMPEncryptedBufferDataImpl> mCrypto;
|
2014-05-18 07:05:46 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace gmp
|
2014-08-18 21:11:11 +04:00
|
|
|
|
2014-05-18 07:05:46 +04:00
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // GMPVideoEncodedFrameImpl_h_
|