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 #ifndef __TrackFragmentAtom_H__ 19 #define __TrackFragmentAtom_H__ 20 21 #include "atom.h" 22 #include "a_atomdefs.h" 23 #include "atomutils.h" 24 25 #include "trackfragmentheaderatom.h" 26 #include "trackfragmentrunatom.h" 27 28 #include "oscl_byte_order.h" 29 #include "oscl_bin_stream.h" 30 typedef Oscl_Vector<uint32, OsclMemAllocator> uint32VecType; 31 typedef Oscl_Vector<uint8, OsclMemAllocator> uint8VecType; 32 33 34 class PVA_FF_TrackFragmentAtom : public PVA_FF_Atom 35 { 36 37 public: 38 PVA_FF_TrackFragmentAtom(uint32 mediaType, uint32 codecType, uint32 trackId, 39 uint32 interleaveDuration, uint32 timescale); 40 41 virtual ~PVA_FF_TrackFragmentAtom(); 42 43 PVA_FF_TrackFragmentRunAtom* addTrackRun(); 44 45 void addSampleToFragment(uint32 size, uint32 ts, uint8 flags, 46 uint32 baseOffset, bool otrunStart); 47 48 uint32 getTrackId(); 49 50 uint32 getFragmentDuration(); 51 52 uint32 getTrunNumber(); 53 54 void setTrackFragmentHeaderData(uint32 flags); 55 56 void setTrackFragmentBaseDataOffset(uint64 offset); 57 58 void updateLastTSEntry(uint32 ts); 59 60 virtual bool renderToFileStream(MP4_AUTHOR_FF_FILE_IO_WRAP* fp); 61 62 uint32 getSampleCount() const 63 { 64 uint32 lSampleCount = 0; 65 for (uint32 ii = 0; ii < _pTrunList->size(); ii++) 66 { 67 lSampleCount += ((*_pTrunList)[ii])->getSampleCount(); 68 } 69 return lSampleCount; 70 } 71 72 private: 73 74 PVA_FF_TrackFragmentHeaderAtom *_pTfhdAtom; 75 Oscl_Vector <PVA_FF_TrackFragmentRunAtom*, OsclMemAllocator> *_pTrunList; // list of TRUNs in this fragment 76 77 int32 _codecType; 78 int32 _mediaType; 79 80 uint32 _timescale; 81 bool _firstEntry; 82 uint32 _prevTS; 83 uint32 _interleaveDuration; // determines duration of each TRUN 84 uint32 _fragmentDuration; // determines the duration of samples in this fragment 85 bool _ofirstTrun; 86 87 virtual void recomputeSize(); 88 89 }; 90 91 #endif 92