Home | History | Annotate | Download | only in include
      1 /* ------------------------------------------------------------------
      2  * Copyright (C) 1998-2009 PacketVideo
      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
     13  * express or implied.
     14  * See the License for the specific language governing permissions
     15  * and limitations under the License.
     16  * -------------------------------------------------------------------
     17  */
     18 /*
     19     This PVA_FF_MovieAtom Class is the main atom class in the MPEG-4 File that stores
     20     all the meta data about the MPEG-4 presentation.
     21 */
     22 
     23 
     24 #ifndef __MovieAtom_H__
     25 #define __MovieAtom_H__
     26 
     27 #define PV_ERROR -1
     28 
     29 #include "atom.h"
     30 #include "a_isucceedfail.h"
     31 
     32 #include "pv_mp4ffcomposer_config.h"
     33 
     34 #include "movieheaderatom.h"
     35 #include "trackatom.h"
     36 
     37 #include "userdataatom.h"
     38 
     39 
     40 #include "assetinfoatoms.h"
     41 
     42 // movie fragment
     43 #include "movieextendsatom.h"
     44 #include "moviefragmentatom.h"
     45 #include "moviefragmentrandomaccessatom.h"
     46 #ifndef PVMI_KVP_H_INCLUDED
     47 #include "pvmi_kvp.h"
     48 #endif
     49 
     50 
     51 class PVA_FF_MovieAtom : public PVA_FF_Atom, public PVA_FF_ISucceedFail
     52 {
     53 
     54     public:
     55         PVA_FF_MovieAtom(uint32 fileAuthoringFlags); // Constructor
     56 
     57         virtual ~PVA_FF_MovieAtom();
     58 
     59         // Get the duration of the movie
     60         uint32 getDuration()
     61         {
     62             return _pmovieHeaderAtom->getDuration();
     63         }
     64 
     65         int32 getScalability() const
     66         {
     67             return _scalability;
     68         }
     69         int32 getFileType() const
     70         {
     71             return _fileType;
     72         }
     73 
     74         // Member gets and sets
     75         const PVA_FF_MovieHeaderAtom &getMovieHeaderAtom()
     76         {
     77             return *_pmovieHeaderAtom;
     78         }
     79         PVA_FF_MovieHeaderAtom &getMutableMovieHeaderAtom()
     80         {
     81             return *_pmovieHeaderAtom;
     82         }
     83         void setMovieHeaderAtom(PVA_FF_MovieHeaderAtom *header)
     84         {
     85             _pmovieHeaderAtom = header;
     86         }
     87 
     88         // Track gets and adds
     89         void addTrackAtom(PVA_FF_TrackAtom *a); // Adds to appropriate vector
     90 
     91         const Oscl_Vector<PVA_FF_TrackAtom*, OsclMemAllocator>& getMpeg4TrackVec()
     92         {
     93             return *_pmpeg4TrackVec;
     94         }
     95         PVA_FF_TrackAtom *getMpeg4Track(int32 index);
     96 
     97         // Return a pointer to a track with ES_ID value of esid
     98         //PVA_FF_TrackAtom *getTrackWithESID(uint32 esid) const;
     99 
    100         // Sets the timescale of the mp4 movie - gets reflected in the movieHeader
    101         // and is used for the duration computation in the track headers
    102         void setTimeScale(uint32 ts);
    103 
    104         // Gets the timescale of the mp4 movie
    105         uint32 getTimeScale() const;
    106 
    107         // Rendering the PVA_FF_Atom in proper format (bitlengths, etc.) to an ostream
    108         virtual bool renderToFileStream(MP4_AUTHOR_FF_FILE_IO_WRAP *fp);
    109 
    110         // Getting and setting the Mpeg4 VOL header
    111         void addDecoderSpecificInfo(PVA_FF_DecoderSpecificInfo *pinfo, int32 trackID);
    112 
    113         // Getting and setting the Mpeg4 VOL header for timed text
    114         void addTextDecoderSpecificInfo(PVA_FF_TextSampleDescInfo *pinfo, int32 trackID);
    115 
    116         PVA_FF_TrackAtom *getMediaTrack(uint32 trackID);
    117         void addSampleToTrack(uint32 trackID, uint8 *psample,
    118                               uint32 size, uint32 ts, uint8 flags,
    119                               uint32 baseOffset = 0, bool _oChunkStart = false);
    120 
    121         void addTextSampleToTrack(uint32 trackID, uint8 *psample,
    122                                   uint32 size, uint32 ts, uint8 flags, int32 index,
    123                                   uint32 baseOffset = 0, bool _oChunkStart = false);
    124 
    125         void addSampleToTrack(uint32 trackID,
    126                               Oscl_Vector <OsclMemoryFragment, OsclMemAllocator>& fragmentList,
    127                               uint32 size, uint32 ts, uint8 flags,
    128                               uint32 baseOffset = 0, bool _oChunkStart = false);
    129         void addTextSampleToTrack(uint32 trackID,
    130                                   Oscl_Vector <OsclMemoryFragment, OsclMemAllocator>& fragmentList,
    131                                   uint32 size, uint32 ts, uint8 flags, int32 index,
    132                                   uint32 baseOffset = 0, bool _oChunkStart = false);
    133 
    134         bool reAuthorFirstSampleInTrack(uint32 trackID,
    135                                         uint32 size,
    136                                         uint32 baseOffset);
    137 
    138         void setTargetBitrate(uint32 trackID, uint32 avgBitRate, uint32 maxBitRate, uint32 bufferSizeDB);
    139         void setTimeScale(uint32 trackID, uint32 rate);
    140         int32 getCodecType(uint32 trackID);
    141 
    142         void setMaxBufferSizeDB(uint32 trackID, uint32 max);
    143 
    144         void prepareToRender();
    145 
    146         void populateCommonMetadataAtoms();
    147 
    148 
    149         void createAssetInfoAtoms();
    150 
    151 
    152         void setLanguage(uint32 language)
    153         {
    154             if (_pMediaTrackVec != NULL)
    155             {
    156                 for (uint32 i = 0; i < _pMediaTrackVec->size(); i++)
    157                 {
    158                     (*_pMediaTrackVec)[i]->setLanguage(language);
    159                 }
    160             }
    161         }
    162 
    163         bool setCopyRightInfo(PVA_FF_UNICODE_STRING_PARAM cprt, uint16 langCode)
    164         {
    165             if (_pAssetInfoCopyRightAtom != NULL)
    166             {
    167                 _pAssetInfoCopyRightAtom->setCopyRightLangCode(langCode);
    168                 _pAssetInfoCopyRightAtom->setCopyRightString(cprt);
    169                 setLanguage(langCode);
    170                 return true;
    171             }
    172 
    173             return false;
    174         }
    175 
    176         bool setAuthorInfo(PVA_FF_UNICODE_STRING_PARAM author, uint16 langCode)
    177         {
    178             if (_pAssetInfoAuthorAtom != NULL)
    179             {
    180                 _pAssetInfoAuthorAtom->setAuthorLangCode(langCode);
    181                 _pAssetInfoAuthorAtom->setAuthorNotice(author);
    182                 setLanguage(langCode);
    183                 return true;
    184             }
    185 
    186             return false;
    187         }
    188 
    189         bool setTitleInfo(PVA_FF_UNICODE_STRING_PARAM title, uint16 langCode)
    190         {
    191             if (_pAssetInfoTitleAtom != NULL)
    192             {
    193                 _pAssetInfoTitleAtom->setTitleLangCode(langCode);
    194                 _pAssetInfoTitleAtom->setTitleNotice(title);
    195                 setLanguage(langCode);
    196                 return true;
    197             }
    198 
    199             return false;
    200         }
    201 
    202         bool setDescription(PVA_FF_UNICODE_STRING_PARAM desc, uint16 langCode)
    203         {
    204             if (_pAssetInfoDescAtom != NULL)
    205             {
    206                 _pAssetInfoDescAtom->setDescLangCode(langCode);
    207                 _pAssetInfoDescAtom->setDescNotice(desc);
    208                 setLanguage(langCode);
    209                 return true;
    210             }
    211 
    212             return false;
    213         }
    214 
    215 
    216         bool setPerformerInfo(PVA_FF_UNICODE_STRING_PARAM performer, uint16 langCode)
    217         {
    218             if (_pAssetInfoPerformerAtom != NULL)
    219             {
    220                 _pAssetInfoPerformerAtom->setPerfLangCode(langCode);
    221                 _pAssetInfoPerformerAtom->setPerfNotice(performer);
    222                 setLanguage(langCode);
    223                 return true;
    224             }
    225 
    226             return false;
    227         }
    228 
    229 
    230         bool setGenreInfo(PVA_FF_UNICODE_STRING_PARAM genre, uint16 langCode)
    231         {
    232             if (_pAssetInfoGenreAtom != NULL)
    233             {
    234                 _pAssetInfoGenreAtom->setGenreLangCode(langCode);
    235                 _pAssetInfoGenreAtom->setGenreNotice(genre);
    236                 setLanguage(langCode);
    237                 return true;
    238             }
    239 
    240             return false;
    241         }
    242 
    243         bool setRatingInfo(PVA_FF_UNICODE_STRING_PARAM ratingInfo, uint32 ratingEntity,
    244                            uint32 ratingCriteria, uint16 langCode)
    245         {
    246             if (_pAssetInfoRatingAtom != NULL)
    247             {
    248                 _pAssetInfoRatingAtom->setRatingLangCode(langCode);
    249                 _pAssetInfoRatingAtom->setRatingEntity(ratingEntity);
    250                 _pAssetInfoRatingAtom->setRatingCriteria(ratingCriteria);
    251                 _pAssetInfoRatingAtom->setRatingInfoNotice(ratingInfo);
    252                 setLanguage(langCode);
    253                 return true;
    254             }
    255 
    256             return false;
    257         }
    258 
    259 
    260         bool setClassificationInfo(PVA_FF_UNICODE_STRING_PARAM classificationInfo,
    261                                    uint32 classificationEntity,
    262                                    uint16 classificationTable, uint16 langCode)
    263         {
    264             if (_pAssetInfoClassificationAtom != NULL)
    265             {
    266                 _pAssetInfoClassificationAtom->setClassificationLangCode(langCode);
    267                 _pAssetInfoClassificationAtom->setClassificationEntity(classificationEntity);
    268                 _pAssetInfoClassificationAtom->setClassificationTable(classificationTable);
    269                 _pAssetInfoClassificationAtom->setClassificationInfoNotice(classificationInfo);
    270                 setLanguage(langCode);
    271                 return true;
    272             }
    273 
    274             return false;
    275         }
    276 
    277         bool setKeyWordsInfo(uint8 keyWordSize, PVA_FF_UNICODE_HEAP_STRING keyWordInfo,
    278                              uint16 langCode)
    279         {
    280             if (_pAssetInfoKeyWordsAtom != NULL)
    281             {
    282                 _pAssetInfoKeyWordsAtom->setKeyWordsLangCode(langCode);
    283                 _pAssetInfoKeyWordsAtom->setKeyWord(keyWordSize, keyWordInfo);
    284                 setLanguage(langCode);
    285                 return true;
    286             }
    287 
    288             return false;
    289         }
    290 
    291         bool setLocationInfo(PvmfAssetInfo3GPPLocationStruct *ptr_loc_struct)
    292         {
    293             if (_pAssetInfoLocationInfoAtom != NULL)
    294             {
    295                 _pAssetInfoLocationInfoAtom->setLocationInfoLangCode(ptr_loc_struct->_langCode);
    296                 _pAssetInfoLocationInfoAtom->setLocationInfoRole(ptr_loc_struct->_role);
    297                 _pAssetInfoLocationInfoAtom->setLocationInfoLongitude(ptr_loc_struct->_longitude);
    298                 _pAssetInfoLocationInfoAtom->setLocationInfoLatitude(ptr_loc_struct->_latitude);
    299                 _pAssetInfoLocationInfoAtom->setLocationInfoAltitude(ptr_loc_struct->_altitude);
    300 
    301                 _pAssetInfoLocationInfoAtom->setLocationInfoName(ptr_loc_struct->_location_name);
    302                 _pAssetInfoLocationInfoAtom->setLocationInfoAstrBody(ptr_loc_struct->_astronomical_body);
    303                 _pAssetInfoLocationInfoAtom->setLocationInfoAddNotes(ptr_loc_struct->_additional_notes);
    304                 setLanguage(ptr_loc_struct->_langCode);
    305                 return true;
    306             }
    307 
    308             return false;
    309         }
    310 
    311         bool setAlbumInfo(PVA_FF_UNICODE_STRING_PARAM albumtitle, uint16 langCode)
    312         {
    313             if (_pAssetInfoKeyAlbumAtom != NULL)
    314             {
    315                 _pAssetInfoKeyAlbumAtom->setAlbumLangCode(langCode);
    316                 _pAssetInfoKeyAlbumAtom->setAlbumInfo(albumtitle);
    317                 setLanguage(langCode);
    318                 return true;
    319             }
    320 
    321             return false;
    322         }
    323 
    324         bool setAlbumTrackNumber(uint8 trackNumber)
    325         {
    326             if (_pAssetInfoKeyAlbumAtom != NULL)
    327             {
    328                 _pAssetInfoKeyAlbumAtom->setAlbumTrackNumber(trackNumber);
    329                 return true;
    330             }
    331             return false;
    332         }
    333 
    334         bool setRecordingYearInfo(uint16 recordingYear)
    335         {
    336             if (_pAssetInfoKeyRecordingYearAtom != NULL)
    337             {
    338                 _pAssetInfoKeyRecordingYearAtom->setRecordingYear(recordingYear);
    339                 return true;
    340             }
    341 
    342             return false;
    343         }
    344 
    345         // Movie Fragment : add movie extend atom usage APIs
    346         void    setMovieFragmentDuration();
    347         void    updateMovieFragmentDuration(uint32 trackID, uint32 ts);
    348         void    writeMovieFragmentDuration(MP4_AUTHOR_FF_FILE_IO_WRAP* fp);
    349         void    SetMaxSampleSize(uint32, uint32);
    350         void    writeMaxSampleSize(MP4_AUTHOR_FF_FILE_IO_WRAP*);
    351     private:
    352         virtual void recomputeSize();
    353 
    354         PVA_FF_MovieHeaderAtom *_pmovieHeaderAtom;
    355 
    356         Oscl_Vector<PVA_FF_TrackAtom*, OsclMemAllocator> *_pmpeg4TrackVec;
    357 
    358         PVA_FF_UserDataAtom *_puserDataAtom;
    359         Oscl_Vector<PVA_FF_TrackAtom*, OsclMemAllocator> *_pMediaTrackVec; // Vector of tracks
    360         int32 _scalability;
    361         int32 _fileType;
    362 
    363 
    364         PVA_FF_AssetInfoTitleAtom           *_pAssetInfoTitleAtom;
    365         PVA_FF_AssetInfoDescAtom            *_pAssetInfoDescAtom;
    366         PVA_FF_AssetInfoCopyRightAtom       *_pAssetInfoCopyRightAtom;
    367         PVA_FF_AssetInfoPerformerAtom       *_pAssetInfoPerformerAtom;
    368         PVA_FF_AssetInfoAuthorAtom          *_pAssetInfoAuthorAtom;
    369         PVA_FF_AssetInfoGenreAtom           *_pAssetInfoGenreAtom;
    370         PVA_FF_AssetInfoRatingAtom          *_pAssetInfoRatingAtom;
    371         PVA_FF_AssetInfoClassificationAtom  *_pAssetInfoClassificationAtom;
    372         PVA_FF_AssetInfoKeyWordsAtom        *_pAssetInfoKeyWordsAtom;
    373         PVA_FF_AssetInfoLocationInfoAtom    *_pAssetInfoLocationInfoAtom;
    374         PVA_FF_AssetInfoAlbumAtom           *_pAssetInfoKeyAlbumAtom;
    375         PVA_FF_AssetInfoRecordingYearAtom   *_pAssetInfoKeyRecordingYearAtom;
    376 
    377         // Movie Fragment : Atoms needed in movie fragment mode
    378         PVA_FF_MovieExtendsAtom             *_pMovieExtendsAtom;
    379         bool                                _oMovieFragmentEnabled;
    380 };
    381 
    382 
    383 
    384 #endif
    385 
    386