• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 /*     -------------------------------------------------------------------       */
20 /*                            MPEG-4 Track Fragment Atom Class                             */
21 /*     -------------------------------------------------------------------       */
22 /*********************************************************************************/
23 /*
24 */
25 
26 
27 #ifndef TRACKFRAGMENTATOM_H_INCLUDED
28 #define TRACKFRAGMENTATOM_H_INCLUDED
29 
30 #ifndef ATOM_H_INCLUDED
31 #include "atom.h"
32 #endif
33 
34 #ifndef TRACKFRAGMENTHEADERATOM_H_INCLUDED
35 #include "trackfragmentheaderatom.h"
36 #endif
37 
38 #ifndef TRACKFRAGMENTRUNATOM_H_INCLUDED
39 #include "trackfragmentrunatom.h"
40 #endif
41 
42 #ifndef PV_GAU_H_INCLUDED
43 #include "pv_gau.h"
44 #endif
45 
46 #ifndef TRACKEXTENDSATOM_H_INCLUDED
47 #include "trackextendsatom.h"
48 #endif
49 
50 #ifndef OSCL_MEM_H_INCLUDED
51 #include "oscl_mem.h"
52 #endif
53 
54 class TrackDurationInfo : public HeapBase
55 {
56     public:
TrackDurationInfo(uint32 td,uint32 id)57         TrackDurationInfo(uint32 td, uint32 id)
58         {
59             trackDuration = td;
60             trackId = id;
61         }
62 
~TrackDurationInfo()63         ~TrackDurationInfo() {}
64         uint32 trackDuration;
65         uint32 trackId;
66     private:
67 };
68 
69 class TrackDurationContainer : public HeapBase
70 {
71 
72     public:
TrackDurationContainer()73         TrackDurationContainer()
74         {
75             _pTrackdurationInfoVec = NULL;
76         }
~TrackDurationContainer()77         ~TrackDurationContainer() {};
78 
getNumTrackInfoVec()79         int32 getNumTrackInfoVec()
80         {
81             if (_pTrackdurationInfoVec != NULL)
82                 return _pTrackdurationInfoVec->size();
83             return 0;
84         }
getTrackdurationInfoAt(int32 index)85         TrackDurationInfo *getTrackdurationInfoAt(int32 index)
86         {
87             if (index >= 0 && index < (int32)_pTrackdurationInfoVec->size())
88                 return (*_pTrackdurationInfoVec)[index];
89             else
90                 return NULL;
91         }
92 
93         void updateTrackDurationForTrackId(int32 id, uint32 duration);
94 
95         Oscl_Vector<TrackDurationInfo*, OsclMemAllocator> *_pTrackdurationInfoVec;
96 
97     private:
98 
99 };
100 
101 class TrackFragmentAtom : public Atom
102 {
103 
104     public:
105 
106         TrackFragmentAtom(MP4_FF_FILE *fp,
107                           uint32 &size,
108                           uint32 type,
109                           uint32 movieFragmentCurrentOffset,
110                           uint32 movieFragmentBaseOffset,
111                           uint32 moof_size,
112                           TrackDurationContainer *trackDurationContainer,
113                           Oscl_Vector<TrackExtendsAtom*, OsclMemAllocator> *trackExtendAtomVec,
114                           bool &parseTrafCompletely,
115                           bool &trafParsingCompleted,
116                           uint32 &countOfTrunsParsed);
117 
118         virtual ~TrackFragmentAtom();
119 
120         void ParseTrafAtom(MP4_FF_FILE *fp,
121                            uint32 &size,
122                            uint32 type,
123                            uint32 movieFragmentCurrentOffset,
124                            uint32 movieFragmentBaseOffset,
125                            uint32 moofSize,
126                            TrackDurationContainer *trackDurationContainer,
127                            Oscl_Vector<TrackExtendsAtom*, OsclMemAllocator> *trackExtendAtomVec,
128                            bool &trafParsingCompleted,
129                            uint32 &countOfTrunsParsed);
130 
getTrackId()131         uint32 getTrackId()
132         {
133             if (_pTrackFragmentHeaderAtom != NULL)
134             {
135                 return _pTrackFragmentHeaderAtom->getTrackId();
136             }
137             return 0;
138         }
139         uint32 getSampleCount();
140         Oscl_Vector<TFrunSampleTable*, OsclMemAllocator>* getSampleTable();
141         uint64 getBaseDataOffset();
142         uint32 getSampleDescriptionIndex();
143         uint32 getDefaultSampleDuration();
144         uint32 getDefaultSampleSize();
145         uint32 getDefaultSampleFlags();
146         TrackFragmentRunAtom *getTrackFragmentRunForSampleNum(uint32 samplenum, uint32 &samplecount);
147         int32 getNextNSamples(uint32 startSampleNum, uint32 *n, uint32 totalSampleRead, GAU    *pgau);
148         int32 getNextBundledAccessUnits(uint32 *n, uint32 totalSampleRead, GAU *pgau);
149         int32 peekNextNSamples(uint32 startSampleNum, uint32 *n, uint32 totalSampleRead, MediaMetaInfo *mInfo);
150         int32 peekNextBundledAccessUnits(uint32 *n, uint32 totalSampleRead, MediaMetaInfo *mInfo);
151         uint32 getTotalNumSampleInTraf();
152         uint32 _trackFragmentEndOffset;
153         int32 resetPlayback(uint32 time, uint32 trun_number, uint32 sample_num);
154         void resetPlayback();
155         uint32 getSampleNumberFromTimestamp(uint32 time);
156         uint32 getTimestampForSampleNumber(uint32 sampleNumber);
157         uint32 getCurrentTrafDuration();
158         int32 getOffsetByTime(uint32 id, uint32 ts, int32* sampleFileOffset);
159         int32 resetPlayback(uint32 time);
160 
161 
162     private:
163 
164         TrackFragmentHeaderAtom * _pTrackFragmentHeaderAtom;
165         TrackFragmentRunAtom *_pTrackFragmentRunAtom;
166         Oscl_Vector<TrackFragmentRunAtom*, OsclMemAllocator> *_pTrackFragmentRunAtomVec;
167         uint32 _currentPlaybackSampleTimestamp;
168         uint32 _currentTrackFragmentRunSampleNumber;
169         uint32 _peekPlaybackSampleNumber;
170         MP4_FF_FILE *_pinput;
171         MP4_FF_FILE *_commonFilePtr;
172         uint32 _startTrackFragmentTSOffset;
173         uint32 _fileSize;
174         uint32 _movieFragmentOffset;
175         uint32 _prevSampleOffset;
176         PVLogger *iLogger, *iStateVarLogger, *iParsedDataLogger;
177         uint64 _trackEndDuration;
178         Oscl_Vector<uint32, OsclMemAllocator> *_pFragmentptrOffsetVec;
179         uint32 _cnt;
180         uint32 _default_duration;
181         bool _use_default_duratoin;
182         TrackDurationContainer *_pTrackDurationContainer;
183         uint32 trackId;
184         uint32 tf_flags;
185         uint32 trun_offset;
186         bool trunParsingCompleted;
187 
188 };
189 
190 #endif
191 
192 
193