1 /***************************************************************** 2 | 3 | AP4 - stts Atoms 4 | 5 | Copyright 2002-2008 Axiomatic Systems, LLC 6 | 7 | 8 | This file is part of Bento4/AP4 (MP4 Atom Processing Library). 9 | 10 | Unless you have obtained Bento4 under a difference license, 11 | this version of Bento4 is Bento4|GPL. 12 | Bento4|GPL is free software; you can redistribute it and/or modify 13 | it under the terms of the GNU General Public License as published by 14 | the Free Software Foundation; either version 2, or (at your option) 15 | any later version. 16 | 17 | Bento4|GPL is distributed in the hope that it will be useful, 18 | but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | GNU General Public License for more details. 21 | 22 | You should have received a copy of the GNU General Public License 23 | along with Bento4|GPL; see the file COPYING. If not, write to the 24 | Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 25 | 02111-1307, USA. 26 | 27 ****************************************************************/ 28 29 #ifndef _AP4_STTS_ATOM_H_ 30 #define _AP4_STTS_ATOM_H_ 31 32 /*---------------------------------------------------------------------- 33 | includes 34 +---------------------------------------------------------------------*/ 35 #include "Ap4Array.h" 36 #include "Ap4Atom.h" 37 38 /*---------------------------------------------------------------------- 39 | AP4_SttsTableEntry 40 +---------------------------------------------------------------------*/ 41 class AP4_SttsTableEntry { 42 public: AP4_SttsTableEntry()43 AP4_SttsTableEntry() : 44 m_SampleCount(0), 45 m_SampleDuration(0) {} AP4_SttsTableEntry(AP4_UI32 sample_count,AP4_UI32 sample_duration)46 AP4_SttsTableEntry(AP4_UI32 sample_count, 47 AP4_UI32 sample_duration) : 48 m_SampleCount(sample_count), 49 m_SampleDuration(sample_duration) {} 50 51 AP4_UI32 m_SampleCount; 52 AP4_UI32 m_SampleDuration; 53 }; 54 55 /*---------------------------------------------------------------------- 56 | AP4_SttsAtom 57 +---------------------------------------------------------------------*/ 58 class AP4_SttsAtom : public AP4_Atom 59 { 60 public: 61 AP4_IMPLEMENT_DYNAMIC_CAST_D(AP4_SttsAtom, AP4_Atom) 62 63 // class methods 64 static AP4_SttsAtom* Create(AP4_Size size, AP4_ByteStream& stream); 65 66 // methods 67 AP4_SttsAtom(); 68 virtual AP4_Result InspectFields(AP4_AtomInspector& inspector); 69 virtual AP4_Result GetDts(AP4_Ordinal sample, AP4_UI64& dts, AP4_UI32* duration = NULL); 70 virtual AP4_Result AddEntry(AP4_UI32 sample_count, AP4_UI32 sample_duration); 71 virtual AP4_Result GetSampleIndexForTimeStamp(AP4_UI64 ts, 72 AP4_Ordinal& sample_index); 73 virtual AP4_Result WriteFields(AP4_ByteStream& stream); 74 75 private: 76 // methods 77 AP4_SttsAtom(AP4_UI32 size, 78 AP4_UI08 version, 79 AP4_UI32 flags, 80 AP4_ByteStream& stream); 81 82 // members 83 AP4_Array<AP4_SttsTableEntry> m_Entries; 84 struct { 85 AP4_Ordinal entry_index; 86 AP4_Ordinal sample; 87 AP4_UI64 dts; 88 } m_LookupCache; 89 }; 90 91 #endif // _AP4_STTS_ATOM_H_ 92