content/media/omx/MPAPI.h

Fri, 16 Jan 2015 18:13:44 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Fri, 16 Jan 2015 18:13:44 +0100
branch
TOR_BUG_9701
changeset 14
925c144e1f1f
permissions
-rw-r--r--

Integrate suggestion from review to improve consistency with existing code.

michael@0 1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* vim:set ts=2 sw=2 sts=2 et cindent: */
michael@0 3 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 4 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
michael@0 5 * You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 6 #if !defined(MPAPI_h_)
michael@0 7 #define MPAPI_h_
michael@0 8
michael@0 9 #include <stdint.h>
michael@0 10 #include "mozilla/layers/TextureClient.h"
michael@0 11
michael@0 12 namespace MPAPI {
michael@0 13
michael@0 14 struct VideoPlane {
michael@0 15 VideoPlane() :
michael@0 16 mData(nullptr),
michael@0 17 mStride(0),
michael@0 18 mWidth(0),
michael@0 19 mHeight(0),
michael@0 20 mOffset(0),
michael@0 21 mSkip(0)
michael@0 22 {}
michael@0 23
michael@0 24 void *mData;
michael@0 25 int32_t mStride;
michael@0 26 int32_t mWidth;
michael@0 27 int32_t mHeight;
michael@0 28 int32_t mOffset;
michael@0 29 int32_t mSkip;
michael@0 30 };
michael@0 31
michael@0 32 struct VideoFrame {
michael@0 33 int64_t mTimeUs;
michael@0 34 bool mKeyFrame;
michael@0 35 bool mShouldSkip;
michael@0 36 void *mData;
michael@0 37 size_t mSize;
michael@0 38 int32_t mStride;
michael@0 39 int32_t mSliceHeight;
michael@0 40 int32_t mRotation;
michael@0 41 VideoPlane Y;
michael@0 42 VideoPlane Cb;
michael@0 43 VideoPlane Cr;
michael@0 44 mozilla::RefPtr<mozilla::layers::TextureClient> mGraphicBuffer;
michael@0 45
michael@0 46 VideoFrame() :
michael@0 47 mTimeUs(0),
michael@0 48 mKeyFrame(false),
michael@0 49 mShouldSkip(false),
michael@0 50 mData(nullptr),
michael@0 51 mSize(0),
michael@0 52 mStride(0),
michael@0 53 mSliceHeight(0),
michael@0 54 mRotation(0)
michael@0 55 {}
michael@0 56
michael@0 57 void Set(int64_t aTimeUs, bool aKeyFrame,
michael@0 58 void *aData, size_t aSize, int32_t aStride, int32_t aSliceHeight, int32_t aRotation,
michael@0 59 void *aYData, int32_t aYStride, int32_t aYWidth, int32_t aYHeight, int32_t aYOffset, int32_t aYSkip,
michael@0 60 void *aCbData, int32_t aCbStride, int32_t aCbWidth, int32_t aCbHeight, int32_t aCbOffset, int32_t aCbSkip,
michael@0 61 void *aCrData, int32_t aCrStride, int32_t aCrWidth, int32_t aCrHeight, int32_t aCrOffset, int32_t aCrSkip)
michael@0 62 {
michael@0 63 mTimeUs = aTimeUs;
michael@0 64 mKeyFrame = aKeyFrame;
michael@0 65 mData = aData;
michael@0 66 mSize = aSize;
michael@0 67 mStride = aStride;
michael@0 68 mSliceHeight = aSliceHeight;
michael@0 69 mRotation = aRotation;
michael@0 70 mGraphicBuffer = nullptr;
michael@0 71 Y.mData = aYData;
michael@0 72 Y.mStride = aYStride;
michael@0 73 Y.mWidth = aYWidth;
michael@0 74 Y.mHeight = aYHeight;
michael@0 75 Y.mOffset = aYOffset;
michael@0 76 Y.mSkip = aYSkip;
michael@0 77 Cb.mData = aCbData;
michael@0 78 Cb.mStride = aCbStride;
michael@0 79 Cb.mWidth = aCbWidth;
michael@0 80 Cb.mHeight = aCbHeight;
michael@0 81 Cb.mOffset = aCbOffset;
michael@0 82 Cb.mSkip = aCbSkip;
michael@0 83 Cr.mData = aCrData;
michael@0 84 Cr.mStride = aCrStride;
michael@0 85 Cr.mWidth = aCrWidth;
michael@0 86 Cr.mHeight = aCrHeight;
michael@0 87 Cr.mOffset = aCrOffset;
michael@0 88 Cr.mSkip = aCrSkip;
michael@0 89 }
michael@0 90 };
michael@0 91
michael@0 92 struct AudioFrame {
michael@0 93 int64_t mTimeUs;
michael@0 94 void *mData; // 16PCM interleaved
michael@0 95 size_t mSize; // Size of mData in bytes
michael@0 96 int32_t mAudioChannels;
michael@0 97 int32_t mAudioSampleRate;
michael@0 98
michael@0 99 AudioFrame() :
michael@0 100 mTimeUs(0),
michael@0 101 mData(0),
michael@0 102 mSize(0),
michael@0 103 mAudioChannels(0),
michael@0 104 mAudioSampleRate(0)
michael@0 105 {
michael@0 106 }
michael@0 107
michael@0 108 void Set(int64_t aTimeUs,
michael@0 109 void *aData, size_t aSize,
michael@0 110 int32_t aAudioChannels, int32_t aAudioSampleRate)
michael@0 111 {
michael@0 112 mTimeUs = aTimeUs;
michael@0 113 mData = aData;
michael@0 114 mSize = aSize;
michael@0 115 mAudioChannels = aAudioChannels;
michael@0 116 mAudioSampleRate = aAudioSampleRate;
michael@0 117 }
michael@0 118 };
michael@0 119
michael@0 120 struct Decoder;
michael@0 121
michael@0 122 struct PluginHost {
michael@0 123 bool (*Read)(Decoder *aDecoder, char *aBuffer, int64_t aOffset, uint32_t aCount, uint32_t* aBytes);
michael@0 124 uint64_t (*GetLength)(Decoder *aDecoder);
michael@0 125 void (*SetMetaDataReadMode)(Decoder *aDecoder);
michael@0 126 void (*SetPlaybackReadMode)(Decoder *aDecoder);
michael@0 127 };
michael@0 128
michael@0 129 struct Decoder {
michael@0 130 void *mResource;
michael@0 131 void *mPrivate;
michael@0 132
michael@0 133 Decoder();
michael@0 134
michael@0 135 void (*GetDuration)(Decoder *aDecoder, int64_t *durationUs);
michael@0 136 void (*GetVideoParameters)(Decoder *aDecoder, int32_t *aWidth, int32_t *aHeight);
michael@0 137 void (*GetAudioParameters)(Decoder *aDecoder, int32_t *aNumChannels, int32_t *aSampleRate);
michael@0 138 bool (*HasVideo)(Decoder *aDecoder);
michael@0 139 bool (*HasAudio)(Decoder *aDecoder);
michael@0 140 bool (*ReadVideo)(Decoder *aDecoder, VideoFrame *aFrame, int64_t aSeekTimeUs);
michael@0 141 bool (*ReadAudio)(Decoder *aDecoder, AudioFrame *aFrame, int64_t aSeekTimeUs);
michael@0 142 void (*DestroyDecoder)(Decoder *);
michael@0 143 };
michael@0 144
michael@0 145 struct Manifest {
michael@0 146 bool (*CanDecode)(const char *aMimeChars, size_t aMimeLen, const char* const**aCodecs);
michael@0 147 bool (*CreateDecoder)(PluginHost *aPluginHost, Decoder *aDecoder,
michael@0 148 const char *aMimeChars, size_t aMimeLen);
michael@0 149 };
michael@0 150
michael@0 151 }
michael@0 152
michael@0 153 #endif

mercurial