LCOV - code coverage report
Current view: top level - media/libstagefright/frameworks/av/include/media/stagefright - MetaData.h (source / functions) Hit Total Coverage
Test: output.info Lines: 0 6 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 3 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :  * Copyright (C) 2009 The Android Open Source Project
       3             :  *
       4             :  * Licensed under the Apache License, Version 2.0 (the "License");
       5             :  * you may not use this file except in compliance with the License.
       6             :  * You may obtain a copy of the License at
       7             :  *
       8             :  *      http://www.apache.org/licenses/LICENSE-2.0
       9             :  *
      10             :  * Unless required by applicable law or agreed to in writing, software
      11             :  * distributed under the License is distributed on an "AS IS" BASIS,
      12             :  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      13             :  * See the License for the specific language governing permissions and
      14             :  * limitations under the License.
      15             :  */
      16             : 
      17             : #ifndef META_DATA_H_
      18             : 
      19             : #define META_DATA_H_
      20             : 
      21             : #include <sys/types.h>
      22             : 
      23             : #include <stdint.h>
      24             : 
      25             : #include <utils/RefBase.h>
      26             : #include <utils/KeyedVector.h>
      27             : #include <utils/String8.h>
      28             : 
      29             : namespace stagefright {
      30             : 
      31             : // The following keys map to int32_t data unless indicated otherwise.
      32             : enum {
      33             :     kKeyMIMEType          = 'mime',  // cstring
      34             :     kKeyWidth             = 'widt',  // int32_t, image pixel
      35             :     kKeyHeight            = 'heig',  // int32_t, image pixel
      36             :     kKeyDisplayWidth      = 'dWid',  // int32_t, display/presentation
      37             :     kKeyDisplayHeight     = 'dHgt',  // int32_t, display/presentation
      38             :     kKeySARWidth          = 'sarW',  // int32_t, sampleAspectRatio width
      39             :     kKeySARHeight         = 'sarH',  // int32_t, sampleAspectRatio height
      40             : 
      41             :     // a rectangle, if absent assumed to be (0, 0, width - 1, height - 1)
      42             :     kKeyCropRect          = 'crop',
      43             : 
      44             :     kKeyRotation          = 'rotA',  // int32_t (angle in degrees)
      45             :     kKeyIFramesInterval   = 'ifiv',  // int32_t
      46             :     kKeyStride            = 'strd',  // int32_t
      47             :     kKeySliceHeight       = 'slht',  // int32_t
      48             :     kKeyChannelCount      = '#chn',  // int32_t
      49             :     kKeyChannelMask       = 'chnm',  // int32_t
      50             :     kKeySampleRate        = 'srte',  // int32_t (audio sampling rate Hz)
      51             :     kKeySampleSize        = 'ssiz',  // int32_t (sample size in bits)
      52             :     kKeyFrameRate         = 'frmR',  // int32_t (video frame rate fps)
      53             :     kKeyBitRate           = 'brte',  // int32_t (bps)
      54             :     kKeyESDS              = 'esds',  // raw data
      55             :     kKeyAACProfile        = 'aacp',  // int32_t
      56             :     kKeyAVCC              = 'avcc',  // raw data
      57             :     kKeyD263              = 'd263',  // raw data
      58             :     kKeyVorbisInfo        = 'vinf',  // raw data
      59             :     kKeyVorbisBooks       = 'vboo',  // raw data
      60             :     kKeyWantsNALFragments = 'NALf',
      61             :     kKeyIsSyncFrame       = 'sync',  // int32_t (bool)
      62             :     kKeyIsCodecConfig     = 'conf',  // int32_t (bool)
      63             :     kKeyTime              = 'time',  // int64_t (usecs)
      64             :     kKeyDecodingTime      = 'decT',  // int64_t (decoding timestamp in usecs)
      65             :     kKeyNTPTime           = 'ntpT',  // uint64_t (ntp-timestamp)
      66             :     kKeyTargetTime        = 'tarT',  // int64_t (usecs)
      67             :     kKeyDriftTime         = 'dftT',  // int64_t (usecs)
      68             :     kKeyAnchorTime        = 'ancT',  // int64_t (usecs)
      69             :     kKeyDuration          = 'dura',  // int64_t (usecs)
      70             :     kKeyMovieDuration     = 'mdur',  // int64_t (usecs)
      71             :     kKeyColorFormat       = 'colf',
      72             :     kKeyPlatformPrivate   = 'priv',  // pointer
      73             :     kKeyDecoderComponent  = 'decC',  // cstring
      74             :     kKeyBufferID          = 'bfID',
      75             :     kKeyMaxInputSize      = 'inpS',
      76             :     kKeyThumbnailTime     = 'thbT',  // int64_t (usecs)
      77             :     kKeyTrackID           = 'trID',
      78             :     kKeyIsDRM             = 'idrm',  // int32_t (bool)
      79             :     kKeyEncoderDelay      = 'encd',  // int32_t (frames)
      80             :     kKeyEncoderPadding    = 'encp',  // int32_t (frames)
      81             :     kKeyMediaTime         = 'mtme',  // int64_t (usecs)
      82             : 
      83             :     kKeyAlbum             = 'albu',  // cstring
      84             :     kKeyArtist            = 'arti',  // cstring
      85             :     kKeyAlbumArtist       = 'aart',  // cstring
      86             :     kKeyComposer          = 'comp',  // cstring
      87             :     kKeyGenre             = 'genr',  // cstring
      88             :     kKeyTitle             = 'titl',  // cstring
      89             :     kKeyYear              = 'year',  // cstring
      90             :     kKeyAlbumArt          = 'albA',  // compressed image data
      91             :     kKeyAlbumArtMIME      = 'alAM',  // cstring
      92             :     kKeyAuthor            = 'auth',  // cstring
      93             :     kKeyCDTrackNumber     = 'cdtr',  // cstring
      94             :     kKeyDiscNumber        = 'dnum',  // cstring
      95             :     kKeyDate              = 'date',  // cstring
      96             :     kKeyWriter            = 'writ',  // cstring
      97             :     kKeyCompilation       = 'cpil',  // cstring
      98             :     kKeyLocation          = 'loc ',  // cstring
      99             :     kKeyTimeScale         = 'tmsl',  // int32_t
     100             : 
     101             :     // video profile and level
     102             :     kKeyVideoProfile      = 'vprf',  // int32_t
     103             :     kKeyVideoLevel        = 'vlev',  // int32_t
     104             : 
     105             :     // Set this key to enable authoring files in 64-bit offset
     106             :     kKey64BitFileOffset   = 'fobt',  // int32_t (bool)
     107             :     kKey2ByteNalLength    = '2NAL',  // int32_t (bool)
     108             : 
     109             :     // Identify the file output format for authoring
     110             :     // Please see <media/mediarecorder.h> for the supported
     111             :     // file output formats.
     112             :     kKeyFileType          = 'ftyp',  // int32_t
     113             : 
     114             :     // Track authoring progress status
     115             :     // kKeyTrackTimeStatus is used to track progress in elapsed time
     116             :     kKeyTrackTimeStatus   = 'tktm',  // int64_t
     117             : 
     118             :     kKeyRealTimeRecording = 'rtrc',  // bool (int32_t)
     119             :     kKeyNumBuffers        = 'nbbf',  // int32_t
     120             : 
     121             :     // Ogg files can be tagged to be automatically looping...
     122             :     kKeyAutoLoop          = 'autL',  // bool (int32_t)
     123             : 
     124             :     kKeyValidSamples      = 'valD',  // int32_t
     125             : 
     126             :     kKeyIsUnreadable      = 'unre',  // bool (int32_t)
     127             : 
     128             :     // An indication that a video buffer has been rendered.
     129             :     kKeyRendered          = 'rend',  // bool (int32_t)
     130             : 
     131             :     // The language code for this media
     132             :     kKeyMediaLanguage     = 'lang',  // cstring
     133             : 
     134             :     // To store the timed text format data
     135             :     kKeyTextFormatData    = 'text',  // raw data
     136             : 
     137             :     kKeyRequiresSecureBuffers = 'secu',  // bool (int32_t)
     138             : 
     139             :     kKeyIsADTS            = 'adts',  // bool (int32_t)
     140             :     kKeyAACAOT            = 'aaot',  // int32_t
     141             : 
     142             :     // If a MediaBuffer's data represents (at least partially) encrypted
     143             :     // data, the following fields aid in decryption.
     144             :     // The data can be thought of as pairs of plain and encrypted data
     145             :     // fragments, i.e. plain and encrypted data alternate.
     146             :     // The first fragment is by convention plain data (if that's not the
     147             :     // case, simply specify plain fragment size of 0).
     148             :     // kKeyEncryptedSizes and kKeyPlainSizes each map to an array of
     149             :     // size_t values. The sum total of all size_t values of both arrays
     150             :     // must equal the amount of data (i.e. MediaBuffer's range_length()).
     151             :     // If both arrays are present, they must be of the same size.
     152             :     // If only encrypted sizes are present it is assumed that all
     153             :     // plain sizes are 0, i.e. all fragments are encrypted.
     154             :     // To programmatically set these array, use the MetaData::setData API, i.e.
     155             :     // const size_t encSizes[];
     156             :     // meta->setData(
     157             :     //  kKeyEncryptedSizes, 0 /* type */, encSizes, sizeof(encSizes));
     158             :     // A plain sizes array by itself makes no sense.
     159             :     kKeyEncryptedSizes    = 'encr',  // size_t[]
     160             :     kKeyPlainSizes        = 'plai',  // size_t[]
     161             :     kKeyCryptoKey         = 'cryK',  // uint8_t[16]
     162             :     kKeyCryptoIV          = 'cryI',  // uint8_t[16]
     163             :     kKeyCryptoMode        = 'cryM',  // int32_t
     164             : 
     165             :     kKeyCryptoDefaultIVSize = 'cryS',  // int32_t
     166             : 
     167             :     kKeyPssh              = 'pssh',  // raw data
     168             : };
     169             : 
     170             : enum {
     171             :     kTypeESDS        = 'esds',
     172             :     kTypeAVCC        = 'avcc',
     173             :     kTypeD263        = 'd263',
     174             : };
     175             : 
     176             : class MetaData : public RefBase {
     177             : public:
     178             :     MetaData();
     179             :     MetaData(const MetaData &from);
     180             : 
     181             :     enum Type {
     182             :         TYPE_NONE     = 'none',
     183             :         TYPE_C_STRING = 'cstr',
     184             :         TYPE_INT32    = 'in32',
     185             :         TYPE_INT64    = 'in64',
     186             :         TYPE_FLOAT    = 'floa',
     187             :         TYPE_POINTER  = 'ptr ',
     188             :         TYPE_RECT     = 'rect',
     189             :     };
     190             : 
     191             :     void clear();
     192             :     bool remove(uint32_t key);
     193             : 
     194             :     bool setCString(uint32_t key, const char *value);
     195             :     bool setInt32(uint32_t key, int32_t value);
     196             :     bool setInt64(uint32_t key, int64_t value);
     197             :     bool setFloat(uint32_t key, float value);
     198             :     bool setPointer(uint32_t key, void *value);
     199             : 
     200             :     bool setRect(
     201             :             uint32_t key,
     202             :             int32_t left, int32_t top,
     203             :             int32_t right, int32_t bottom);
     204             : 
     205             :     bool findCString(uint32_t key, const char **value) const;
     206             :     bool findInt32(uint32_t key, int32_t *value) const;
     207             :     bool findInt64(uint32_t key, int64_t *value) const;
     208             :     bool findFloat(uint32_t key, float *value) const;
     209             :     bool findPointer(uint32_t key, void **value) const;
     210             : 
     211             :     bool findRect(
     212             :             uint32_t key,
     213             :             int32_t *left, int32_t *top,
     214             :             int32_t *right, int32_t *bottom) const;
     215             : 
     216             :     bool setData(uint32_t key, uint32_t type, const void *data, size_t size);
     217             : 
     218             :     bool findData(uint32_t key, uint32_t *type,
     219             :                   const void **data, size_t *size) const;
     220             : 
     221             :     void dumpToLog() const;
     222             : 
     223             : protected:
     224             :     virtual ~MetaData();
     225             : 
     226             : private:
     227             :     struct typed_data {
     228             :         typed_data();
     229             :         ~typed_data();
     230             : 
     231             :         typed_data(const MetaData::typed_data &);
     232             :         typed_data &operator=(const MetaData::typed_data &);
     233             : 
     234             :         void clear();
     235             :         void setData(uint32_t type, const void *data, size_t size);
     236             :         void getData(uint32_t *type, const void **data, size_t *size) const;
     237             :         String8 asString() const;
     238             : 
     239             :     private:
     240             :         uint32_t mType;
     241             :         size_t mSize;
     242             : 
     243             :         union {
     244             :             void *ext_data;
     245             :             float reservoir;
     246             :         } u;
     247             : 
     248           0 :         bool usesReservoir() const {
     249           0 :             return mSize <= sizeof(u.reservoir);
     250             :         }
     251             : 
     252             :         bool allocateStorage(size_t size);
     253             :         void freeStorage();
     254             : 
     255           0 :         void *storage() {
     256           0 :             return usesReservoir() ? &u.reservoir : u.ext_data;
     257             :         }
     258             : 
     259           0 :         const void *storage() const {
     260           0 :             return usesReservoir() ? &u.reservoir : u.ext_data;
     261             :         }
     262             :     };
     263             : 
     264             :     struct Rect {
     265             :         int32_t mLeft, mTop, mRight, mBottom;
     266             :     };
     267             : 
     268             :     KeyedVector<uint32_t, typed_data> mItems;
     269             : 
     270             :     // MetaData &operator=(const MetaData &);
     271             : };
     272             : 
     273             : }  // namespace stagefright
     274             : 
     275             : #endif  // META_DATA_H_

Generated by: LCOV version 1.13