/***************************************************************** | | AP4 - tfra Atoms | | Copyright 2002-2008 Axiomatic Systems, LLC | | | This file is part of Bento4/AP4 (MP4 Atom Processing Library). | | Unless you have obtained Bento4 under a difference license, | this version of Bento4 is Bento4|GPL. | Bento4|GPL is free software; you can redistribute it and/or modify | it under the terms of the GNU General Public License as published by | the Free Software Foundation; either version 2, or (at your option) | any later version. | | Bento4|GPL is distributed in the hope that it will be useful, | but WITHOUT ANY WARRANTY; without even the implied warranty of | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | GNU General Public License for more details. | | You should have received a copy of the GNU General Public License | along with Bento4|GPL; see the file COPYING. If not, write to the | Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA | 02111-1307, USA. | ****************************************************************/ /*---------------------------------------------------------------------- | includes +---------------------------------------------------------------------*/ #include "Ap4TfraAtom.h" #include "Ap4AtomFactory.h" #include "Ap4Utils.h" /*---------------------------------------------------------------------- | AP4_TfraAtom Dynamic Cast Anchor +---------------------------------------------------------------------*/ AP4_DEFINE_DYNAMIC_CAST_ANCHOR(AP4_TfraAtom) /*---------------------------------------------------------------------- | AP4_TfraAtom::Create +---------------------------------------------------------------------*/ AP4_TfraAtom* AP4_TfraAtom::Create(AP4_Size size, AP4_ByteStream& stream) { AP4_UI08 version = 0; AP4_UI32 flags = 0; if (size < AP4_FULL_ATOM_HEADER_SIZE) return NULL; AP4_Result result = ReadFullHeader(stream, version, flags); if (AP4_FAILED(result)) return NULL; if (version > 1) return NULL; return new AP4_TfraAtom(size, version, flags, stream); } /*---------------------------------------------------------------------- | AP4_TfraAtom::AP4_TfraAtom +---------------------------------------------------------------------*/ AP4_TfraAtom::AP4_TfraAtom(AP4_UI32 track_id, AP4_UI08 length_size_of_traf_number, AP4_UI08 length_size_of_trun_number, AP4_UI08 length_size_of_sample_number) : AP4_Atom(AP4_ATOM_TYPE_TFRA, AP4_FULL_ATOM_HEADER_SIZE+4+4+4, 0, 0), m_TrackId(track_id), m_LengthSizeOfTrafNumber(length_size_of_traf_number), m_LengthSizeOfTrunNumber(length_size_of_trun_number), m_LengthSizeOfSampleNumber(length_size_of_sample_number) { } /*---------------------------------------------------------------------- | AP4_TfraAtom::AP4_TfraAtom +---------------------------------------------------------------------*/ AP4_TfraAtom::AP4_TfraAtom(AP4_UI32 size, AP4_UI08 version, AP4_UI32 flags, AP4_ByteStream& stream) : AP4_Atom(AP4_ATOM_TYPE_TFRA, size, version, flags) { stream.ReadUI32(m_TrackId); AP4_UI32 fields = 0; stream.ReadUI32(fields); m_LengthSizeOfTrafNumber = (fields>>4)&3; m_LengthSizeOfTrunNumber = (fields>>2)&3; m_LengthSizeOfSampleNumber = (fields )&3; AP4_UI32 entry_count = 0; stream.ReadUI32(entry_count); m_Entries.SetItemCount(entry_count); for (unsigned int i=0; i 0xFFFFFFFFULL || moof_offset > 0xFFFFFFFFULL) { m_Version = 1; } Entry entry(time, moof_offset, traf_number, trun_number, sample_number); m_Entries.Append(entry); m_Size32 = AP4_FULL_ATOM_HEADER_SIZE+4+4+4 + m_Entries.ItemCount()*((m_Version == 0 ? 8 : 16) + m_LengthSizeOfTrafNumber+1+ m_LengthSizeOfTrunNumber+1+ m_LengthSizeOfSampleNumber+1); return AP4_SUCCESS; } /*---------------------------------------------------------------------- | AP4_TfraAtom::InspectFields +---------------------------------------------------------------------*/ AP4_Result AP4_TfraAtom::InspectFields(AP4_AtomInspector& inspector) { inspector.AddField("track_ID", m_TrackId); inspector.AddField("length_size_of_traf_num", m_LengthSizeOfTrafNumber); inspector.AddField("length_size_of_trun_num", m_LengthSizeOfTrunNumber); inspector.AddField("length_size_of_sample_num", m_LengthSizeOfSampleNumber); if (inspector.GetVerbosity() >= 1) { inspector.StartArray("entries", m_Entries.ItemCount()); for (unsigned int i=0; i