content/media/omx/MPAPI.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/content/media/omx/MPAPI.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,153 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* vim:set ts=2 sw=2 sts=2 et cindent: */
     1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this file,
     1.8 + * You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.9 +#if !defined(MPAPI_h_)
    1.10 +#define MPAPI_h_
    1.11 +
    1.12 +#include <stdint.h>
    1.13 +#include "mozilla/layers/TextureClient.h"
    1.14 +
    1.15 +namespace MPAPI {
    1.16 +
    1.17 +struct VideoPlane {
    1.18 +  VideoPlane() :
    1.19 +    mData(nullptr),
    1.20 +    mStride(0),
    1.21 +    mWidth(0),
    1.22 +    mHeight(0),
    1.23 +    mOffset(0),
    1.24 +    mSkip(0)
    1.25 +  {}
    1.26 +
    1.27 +  void *mData;
    1.28 +  int32_t mStride;
    1.29 +  int32_t mWidth;
    1.30 +  int32_t mHeight;
    1.31 +  int32_t mOffset;
    1.32 +  int32_t mSkip;
    1.33 +};
    1.34 +
    1.35 +struct VideoFrame {
    1.36 +  int64_t mTimeUs;
    1.37 +  bool mKeyFrame;
    1.38 +  bool mShouldSkip;
    1.39 +  void *mData;
    1.40 +  size_t mSize;
    1.41 +  int32_t mStride;
    1.42 +  int32_t mSliceHeight;
    1.43 +  int32_t mRotation;
    1.44 +  VideoPlane Y;
    1.45 +  VideoPlane Cb;
    1.46 +  VideoPlane Cr;
    1.47 +  mozilla::RefPtr<mozilla::layers::TextureClient> mGraphicBuffer;
    1.48 +
    1.49 +  VideoFrame() :
    1.50 +    mTimeUs(0),
    1.51 +    mKeyFrame(false),
    1.52 +    mShouldSkip(false),
    1.53 +    mData(nullptr),
    1.54 +    mSize(0),
    1.55 +    mStride(0),
    1.56 +    mSliceHeight(0),
    1.57 +    mRotation(0)
    1.58 +  {}
    1.59 +
    1.60 +  void Set(int64_t aTimeUs, bool aKeyFrame,
    1.61 +           void *aData, size_t aSize, int32_t aStride, int32_t aSliceHeight, int32_t aRotation,
    1.62 +           void *aYData, int32_t aYStride, int32_t aYWidth, int32_t aYHeight, int32_t aYOffset, int32_t aYSkip,
    1.63 +           void *aCbData, int32_t aCbStride, int32_t aCbWidth, int32_t aCbHeight, int32_t aCbOffset, int32_t aCbSkip,
    1.64 +           void *aCrData, int32_t aCrStride, int32_t aCrWidth, int32_t aCrHeight, int32_t aCrOffset, int32_t aCrSkip)
    1.65 +  {
    1.66 +    mTimeUs = aTimeUs;
    1.67 +    mKeyFrame = aKeyFrame;
    1.68 +    mData = aData;
    1.69 +    mSize = aSize;
    1.70 +    mStride = aStride;
    1.71 +    mSliceHeight = aSliceHeight;
    1.72 +    mRotation = aRotation;
    1.73 +    mGraphicBuffer = nullptr;
    1.74 +    Y.mData = aYData;
    1.75 +    Y.mStride = aYStride;
    1.76 +    Y.mWidth = aYWidth;
    1.77 +    Y.mHeight = aYHeight;
    1.78 +    Y.mOffset = aYOffset;
    1.79 +    Y.mSkip = aYSkip;
    1.80 +    Cb.mData = aCbData;
    1.81 +    Cb.mStride = aCbStride;
    1.82 +    Cb.mWidth = aCbWidth;
    1.83 +    Cb.mHeight = aCbHeight;
    1.84 +    Cb.mOffset = aCbOffset;
    1.85 +    Cb.mSkip = aCbSkip;
    1.86 +    Cr.mData = aCrData;
    1.87 +    Cr.mStride = aCrStride;
    1.88 +    Cr.mWidth = aCrWidth;
    1.89 +    Cr.mHeight = aCrHeight;
    1.90 +    Cr.mOffset = aCrOffset;
    1.91 +    Cr.mSkip = aCrSkip;
    1.92 +  }
    1.93 +};
    1.94 +
    1.95 +struct AudioFrame {
    1.96 +  int64_t mTimeUs;
    1.97 +  void *mData; // 16PCM interleaved
    1.98 +  size_t mSize; // Size of mData in bytes
    1.99 +  int32_t mAudioChannels;
   1.100 +  int32_t mAudioSampleRate;
   1.101 +
   1.102 +  AudioFrame() :
   1.103 +    mTimeUs(0),
   1.104 +    mData(0),
   1.105 +    mSize(0),
   1.106 +    mAudioChannels(0),
   1.107 +    mAudioSampleRate(0)
   1.108 +  {
   1.109 +  }
   1.110 +
   1.111 +  void Set(int64_t aTimeUs,
   1.112 +           void *aData, size_t aSize,
   1.113 +           int32_t aAudioChannels, int32_t aAudioSampleRate)
   1.114 +  {
   1.115 +    mTimeUs = aTimeUs;
   1.116 +    mData = aData;
   1.117 +    mSize = aSize;
   1.118 +    mAudioChannels = aAudioChannels;
   1.119 +    mAudioSampleRate = aAudioSampleRate;
   1.120 +  }
   1.121 +};
   1.122 +
   1.123 +struct Decoder;
   1.124 +
   1.125 +struct PluginHost {
   1.126 +  bool (*Read)(Decoder *aDecoder, char *aBuffer, int64_t aOffset, uint32_t aCount, uint32_t* aBytes);
   1.127 +  uint64_t (*GetLength)(Decoder *aDecoder);
   1.128 +  void (*SetMetaDataReadMode)(Decoder *aDecoder);
   1.129 +  void (*SetPlaybackReadMode)(Decoder *aDecoder);
   1.130 +};
   1.131 +
   1.132 +struct Decoder {
   1.133 +  void *mResource;
   1.134 +  void *mPrivate;
   1.135 +
   1.136 +  Decoder();
   1.137 +
   1.138 +  void (*GetDuration)(Decoder *aDecoder, int64_t *durationUs);
   1.139 +  void (*GetVideoParameters)(Decoder *aDecoder, int32_t *aWidth, int32_t *aHeight);
   1.140 +  void (*GetAudioParameters)(Decoder *aDecoder, int32_t *aNumChannels, int32_t *aSampleRate);
   1.141 +  bool (*HasVideo)(Decoder *aDecoder);
   1.142 +  bool (*HasAudio)(Decoder *aDecoder);
   1.143 +  bool (*ReadVideo)(Decoder *aDecoder, VideoFrame *aFrame, int64_t aSeekTimeUs);
   1.144 +  bool (*ReadAudio)(Decoder *aDecoder, AudioFrame *aFrame, int64_t aSeekTimeUs);
   1.145 +  void (*DestroyDecoder)(Decoder *);
   1.146 +};
   1.147 +
   1.148 +struct Manifest {
   1.149 +  bool (*CanDecode)(const char *aMimeChars, size_t aMimeLen, const char* const**aCodecs);
   1.150 +  bool (*CreateDecoder)(PluginHost *aPluginHost, Decoder *aDecoder,
   1.151 +                        const char *aMimeChars, size_t aMimeLen);
   1.152 +};
   1.153 +
   1.154 +}
   1.155 +
   1.156 +#endif

mercurial