Ap4Processor.h
Go to the documentation of this file.00001 /***************************************************************** 00002 | 00003 | AP4 - File Processor 00004 | 00005 | Copyright 2002-2008 Axiomatic Systems, LLC 00006 | 00007 | 00008 | This file is part of Bento4/AP4 (MP4 Atom Processing Library). 00009 | 00010 | Unless you have obtained Bento4 under a difference license, 00011 | this version of Bento4 is Bento4|GPL. 00012 | Bento4|GPL is free software; you can redistribute it and/or modify 00013 | it under the terms of the GNU General Public License as published by 00014 | the Free Software Foundation; either version 2, or (at your option) 00015 | any later version. 00016 | 00017 | Bento4|GPL is distributed in the hope that it will be useful, 00018 | but WITHOUT ANY WARRANTY; without even the implied warranty of 00019 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00020 | GNU General Public License for more details. 00021 | 00022 | You should have received a copy of the GNU General Public License 00023 | along with Bento4|GPL; see the file COPYING. If not, write to the 00024 | Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 00025 | 02111-1307, USA. 00026 | 00027 ****************************************************************/ 00028 00029 #ifndef _AP4_PROCESSOR_H_ 00030 #define _AP4_PROCESSOR_H_ 00031 00032 /*---------------------------------------------------------------------- 00033 | includes 00034 +---------------------------------------------------------------------*/ 00035 #include "Ap4Types.h" 00036 #include "Ap4AtomFactory.h" 00037 #include "Ap4File.h" 00038 #include "Ap4Track.h" 00039 #include "Ap4Sample.h" 00040 00041 /*---------------------------------------------------------------------- 00042 | class references 00043 +---------------------------------------------------------------------*/ 00044 class AP4_ContainerAtom; 00045 class AP4_ByteStream; 00046 class AP4_DataBuffer; 00047 class AP4_TrakAtom; 00048 struct AP4_MoofLocator; 00049 00050 /*---------------------------------------------------------------------- 00051 | AP4_Processor 00052 +---------------------------------------------------------------------*/ 00053 class AP4_Processor { 00054 public: 00060 class ProgressListener { 00061 public: 00062 virtual ~ProgressListener() {} 00063 00074 virtual AP4_Result OnProgress(unsigned int step, 00075 unsigned int total) = 0; 00076 }; 00077 00083 class TrackHandler { 00084 public: 00088 virtual ~TrackHandler() {} 00089 00094 virtual AP4_Result ProcessTrack() { return AP4_SUCCESS; } 00095 00101 virtual AP4_Size GetProcessedSampleSize(AP4_Sample& sample) { return sample.GetSize(); } 00102 00109 virtual AP4_Result ProcessSample(AP4_DataBuffer& data_in, 00110 AP4_DataBuffer& data_out) = 0; 00111 }; 00112 00118 class FragmentHandler { 00119 public: 00123 virtual ~FragmentHandler() {} 00124 00129 virtual AP4_Result ProcessFragment() { return AP4_SUCCESS; } 00130 00136 virtual AP4_Result FinishFragment() { return AP4_ERROR_NOT_SUPPORTED; } 00137 00143 virtual AP4_Size GetProcessedSampleSize(AP4_Sample& sample) { return sample.GetSize(); } 00144 00151 virtual AP4_Result ProcessSample(AP4_DataBuffer& data_in, 00152 AP4_DataBuffer& data_out) = 0; 00153 }; 00154 00158 virtual ~AP4_Processor() { m_ExternalTrackData.DeleteReferences(); } 00159 00169 AP4_Result Process(AP4_ByteStream& input, 00170 AP4_ByteStream& output, 00171 ProgressListener* listener = NULL, 00172 AP4_AtomFactory& atom_factory = 00173 AP4_DefaultAtomFactory::Instance); 00174 00184 virtual AP4_Result Initialize(AP4_AtomParent& top_level, 00185 AP4_ByteStream& stream, 00186 ProgressListener* listener = NULL); 00187 00192 virtual AP4_Result Finalize(AP4_AtomParent& top_level, 00193 ProgressListener* listener = NULL); 00194 00203 virtual TrackHandler* CreateTrackHandler(AP4_TrakAtom* /*trak*/) { return NULL; } 00204 00213 virtual FragmentHandler* CreateFragmentHandler(AP4_ContainerAtom* /*traf*/) { return NULL; } 00214 00215 protected: 00216 class ExternalTrackData { 00217 public: 00218 ExternalTrackData(unsigned int track_id, AP4_ByteStream* media_data) : 00219 m_TrackId(track_id), m_MediaData(media_data) { 00220 media_data->AddReference(); 00221 } 00222 ~ExternalTrackData() { m_MediaData->Release(); } 00223 unsigned int m_TrackId; 00224 AP4_ByteStream* m_MediaData; 00225 }; 00226 00227 AP4_Result ProcessFragments(AP4_MoovAtom* moov, 00228 AP4_List<AP4_MoofLocator>& moofs, 00229 AP4_ContainerAtom* mfra, 00230 AP4_ByteStream& input, 00231 AP4_ByteStream& output); 00232 00233 00234 AP4_List<ExternalTrackData> m_ExternalTrackData; 00235 }; 00236 00237 #endif // _AP4_PROCESSOR_H_
Generated on Thu May 13 16:36:33 2010 for Bento4 MP4 SDK by
