michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* vim:set ts=2 sw=2 sts=2 et cindent: */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this file, michael@0: * You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: #if !defined(MPAPI_h_) michael@0: #define MPAPI_h_ michael@0: michael@0: #include michael@0: #include "mozilla/layers/TextureClient.h" michael@0: michael@0: namespace MPAPI { michael@0: michael@0: struct VideoPlane { michael@0: VideoPlane() : michael@0: mData(nullptr), michael@0: mStride(0), michael@0: mWidth(0), michael@0: mHeight(0), michael@0: mOffset(0), michael@0: mSkip(0) michael@0: {} michael@0: michael@0: void *mData; michael@0: int32_t mStride; michael@0: int32_t mWidth; michael@0: int32_t mHeight; michael@0: int32_t mOffset; michael@0: int32_t mSkip; michael@0: }; michael@0: michael@0: struct VideoFrame { michael@0: int64_t mTimeUs; michael@0: bool mKeyFrame; michael@0: bool mShouldSkip; michael@0: void *mData; michael@0: size_t mSize; michael@0: int32_t mStride; michael@0: int32_t mSliceHeight; michael@0: int32_t mRotation; michael@0: VideoPlane Y; michael@0: VideoPlane Cb; michael@0: VideoPlane Cr; michael@0: mozilla::RefPtr mGraphicBuffer; michael@0: michael@0: VideoFrame() : michael@0: mTimeUs(0), michael@0: mKeyFrame(false), michael@0: mShouldSkip(false), michael@0: mData(nullptr), michael@0: mSize(0), michael@0: mStride(0), michael@0: mSliceHeight(0), michael@0: mRotation(0) michael@0: {} michael@0: michael@0: void Set(int64_t aTimeUs, bool aKeyFrame, michael@0: void *aData, size_t aSize, int32_t aStride, int32_t aSliceHeight, int32_t aRotation, michael@0: void *aYData, int32_t aYStride, int32_t aYWidth, int32_t aYHeight, int32_t aYOffset, int32_t aYSkip, michael@0: void *aCbData, int32_t aCbStride, int32_t aCbWidth, int32_t aCbHeight, int32_t aCbOffset, int32_t aCbSkip, michael@0: void *aCrData, int32_t aCrStride, int32_t aCrWidth, int32_t aCrHeight, int32_t aCrOffset, int32_t aCrSkip) michael@0: { michael@0: mTimeUs = aTimeUs; michael@0: mKeyFrame = aKeyFrame; michael@0: mData = aData; michael@0: mSize = aSize; michael@0: mStride = aStride; michael@0: mSliceHeight = aSliceHeight; michael@0: mRotation = aRotation; michael@0: mGraphicBuffer = nullptr; michael@0: Y.mData = aYData; michael@0: Y.mStride = aYStride; michael@0: Y.mWidth = aYWidth; michael@0: Y.mHeight = aYHeight; michael@0: Y.mOffset = aYOffset; michael@0: Y.mSkip = aYSkip; michael@0: Cb.mData = aCbData; michael@0: Cb.mStride = aCbStride; michael@0: Cb.mWidth = aCbWidth; michael@0: Cb.mHeight = aCbHeight; michael@0: Cb.mOffset = aCbOffset; michael@0: Cb.mSkip = aCbSkip; michael@0: Cr.mData = aCrData; michael@0: Cr.mStride = aCrStride; michael@0: Cr.mWidth = aCrWidth; michael@0: Cr.mHeight = aCrHeight; michael@0: Cr.mOffset = aCrOffset; michael@0: Cr.mSkip = aCrSkip; michael@0: } michael@0: }; michael@0: michael@0: struct AudioFrame { michael@0: int64_t mTimeUs; michael@0: void *mData; // 16PCM interleaved michael@0: size_t mSize; // Size of mData in bytes michael@0: int32_t mAudioChannels; michael@0: int32_t mAudioSampleRate; michael@0: michael@0: AudioFrame() : michael@0: mTimeUs(0), michael@0: mData(0), michael@0: mSize(0), michael@0: mAudioChannels(0), michael@0: mAudioSampleRate(0) michael@0: { michael@0: } michael@0: michael@0: void Set(int64_t aTimeUs, michael@0: void *aData, size_t aSize, michael@0: int32_t aAudioChannels, int32_t aAudioSampleRate) michael@0: { michael@0: mTimeUs = aTimeUs; michael@0: mData = aData; michael@0: mSize = aSize; michael@0: mAudioChannels = aAudioChannels; michael@0: mAudioSampleRate = aAudioSampleRate; michael@0: } michael@0: }; michael@0: michael@0: struct Decoder; michael@0: michael@0: struct PluginHost { michael@0: bool (*Read)(Decoder *aDecoder, char *aBuffer, int64_t aOffset, uint32_t aCount, uint32_t* aBytes); michael@0: uint64_t (*GetLength)(Decoder *aDecoder); michael@0: void (*SetMetaDataReadMode)(Decoder *aDecoder); michael@0: void (*SetPlaybackReadMode)(Decoder *aDecoder); michael@0: }; michael@0: michael@0: struct Decoder { michael@0: void *mResource; michael@0: void *mPrivate; michael@0: michael@0: Decoder(); michael@0: michael@0: void (*GetDuration)(Decoder *aDecoder, int64_t *durationUs); michael@0: void (*GetVideoParameters)(Decoder *aDecoder, int32_t *aWidth, int32_t *aHeight); michael@0: void (*GetAudioParameters)(Decoder *aDecoder, int32_t *aNumChannels, int32_t *aSampleRate); michael@0: bool (*HasVideo)(Decoder *aDecoder); michael@0: bool (*HasAudio)(Decoder *aDecoder); michael@0: bool (*ReadVideo)(Decoder *aDecoder, VideoFrame *aFrame, int64_t aSeekTimeUs); michael@0: bool (*ReadAudio)(Decoder *aDecoder, AudioFrame *aFrame, int64_t aSeekTimeUs); michael@0: void (*DestroyDecoder)(Decoder *); michael@0: }; michael@0: michael@0: struct Manifest { michael@0: bool (*CanDecode)(const char *aMimeChars, size_t aMimeLen, const char* const**aCodecs); michael@0: bool (*CreateDecoder)(PluginHost *aPluginHost, Decoder *aDecoder, michael@0: const char *aMimeChars, size_t aMimeLen); michael@0: }; michael@0: michael@0: } michael@0: michael@0: #endif