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_TrackHeaderAtom Class specifies the characteristics of a single MPEG-4
     20     track.
     21 */
     22 
     23 
     24 #ifndef __TrackHeaderAtom_H__
     25 #define __TrackHeaderAtom_H__
     26 
     27 #include "fullatom.h"
     28 #include "pv_mp4ffcomposer_config.h"
     29 
     30 class PVA_FF_TrackHeaderAtom : public PVA_FF_FullAtom
     31 {
     32 
     33     public:
     34         PVA_FF_TrackHeaderAtom(int32 type, uint32 trackID, uint8 version, uint32 flags, uint32 fileAuthoringFlags); // Constructor
     35         virtual ~PVA_FF_TrackHeaderAtom();
     36         void init(int32 type);
     37 
     38         void addSample(uint32 ts);
     39         void updateLastTSEntry(uint32 ts);
     40 
     41         // Media type gets adn sets
     42         int32 getTrackMediaType() const
     43         {
     44             return _mediaType;
     45         }
     46         void setTrackMediaType(int32 type)
     47         {
     48             _mediaType = type;
     49         }
     50 
     51         // Creation Time gets and sets
     52         void setCreationTime(uint32 ct)
     53         {
     54             _creationTime = ct;
     55         }
     56         uint32 getCreationTime() const
     57         {
     58             return _creationTime;
     59         }
     60 
     61         // Modification Time gets and sets
     62         void setModificationTime(uint32 mt)
     63         {
     64             _modificationTime = mt;
     65         }
     66         uint32 getModificationTime() const
     67         {
     68             return _modificationTime;
     69         }
     70 
     71         // Time Scale gets and sets
     72         void setTrackID(uint32 id)
     73         {
     74             _trackID = id;
     75         }
     76         uint32 getTrackID() const
     77         {
     78             return _trackID;
     79         }
     80 
     81         // Duration gets and sets
     82         void setDuration(uint32 d)
     83         {
     84             _duration = d;
     85         }
     86         uint32 getDuration() const
     87         {
     88             return (_duration + _deltaTS);
     89         }
     90 
     91         // TimeScale gets and sets - in terms of the MOVIE timescale
     92         void setTimeScale(uint32 ts)
     93         {
     94             _timeScale = ts;
     95         }
     96         uint32 getTimeScale() const
     97         {
     98             return _timeScale;
     99         }
    100 
    101         // Rendering the PVA_FF_Atom in proper format (bitlengths, etc.) to an ostream.
    102         virtual bool renderToFileStream(MP4_AUTHOR_FF_FILE_IO_WRAP *fp);
    103         void setVideoWidthHeight(int16 width, int16 height);
    104 
    105     private:
    106         virtual void recomputeSize();
    107         int32 _mediaType;
    108 
    109 
    110         uint32 _creationTime; // 4/8 (32/64bits) -- Will templatize later - using 32bits for now
    111         uint32 _modificationTime; // 4/8 (32/64bits) -- Will templatize later - using 32bits for now
    112         uint32 _trackID; // 4 (32bits)
    113 
    114         uint32 _reserved1; // = 0;
    115 
    116         uint32 _duration; // 4/8 (32/64bits) -- Will templatize later - using 32bits for now
    117 
    118         // Static reserved constants
    119         uint32 _reserved2[3]; // = { 0, 0, 0 };
    120         uint16 _reserved3; // = 0; // 0x0100 if audio track
    121         uint16 _reserved4; // = 0;
    122         uint32 _reserved5[9]; // = { 0x00010000, 0, 0, 0, 0x00010000, 0, 0, 0, 0x40000000 };
    123         uint32 _reserved6; // = 0; // 0x01400000 if visual track
    124         uint32 _reserved7; // = 0; // 0x00f00000 if visual track
    125 
    126         // private member NOT to be rendered - only for internal use
    127         uint32 _timeScale;
    128 
    129         uint32 _prevTS;
    130         uint32 _deltaTS;
    131         uint16 _height;
    132         uint16 _width;
    133 
    134 };
    135 
    136 
    137 
    138 #endif
    139 
    140