Ap4Track.h

00001 /*****************************************************************
00002 |
00003 |    AP4 - Track Objects
00004 |
00005 |    Copyright 2002 Gilles Boccon-Gibod
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_TRAK_H_
00030 #define _AP4_TRAK_H_
00031 
00032 /*----------------------------------------------------------------------
00033 |       includes
00034 +---------------------------------------------------------------------*/
00035 #include "Ap4.h"
00036 #include "Ap4Array.h"
00037 #include "Ap4SampleDescription.h"
00038 #include "Ap4SampleTable.h"
00039 
00040 /*----------------------------------------------------------------------
00041 |       forward declarations
00042 +---------------------------------------------------------------------*/
00043 class AP4_StblAtom;
00044 class AP4_ByteStream;
00045 class AP4_Sample;
00046 class AP4_DataBuffer;
00047 class AP4_TrakAtom;
00048 class AP4_MoovAtom;
00049 
00050 /*----------------------------------------------------------------------
00051 |       constants
00052 +---------------------------------------------------------------------*/
00053 const AP4_UI32 AP4_TRACK_DEFAULT_MOVIE_TIMESCALE = 1000;
00054 
00055 /*----------------------------------------------------------------------
00056 |       AP4_Track
00057 +---------------------------------------------------------------------*/
00058 class AP4_Track {
00059  public:
00060     // types
00061     typedef enum {
00062         TYPE_UNKNOWN,
00063         TYPE_AUDIO,
00064         TYPE_VIDEO,
00065         TYPE_TEXT,
00066         TYPE_HINT
00067     } Type;
00068 
00069     // methods
00070     AP4_Track(Type             type,
00071               AP4_SampleTable* sample_table,
00072               AP4_UI32         track_id, 
00073               AP4_UI32         movie_time_scale, // 0 = use default
00074               AP4_UI32         media_time_scale,
00075               AP4_UI32         media_duration,
00076               const char*      language,
00077               AP4_UI32         width,
00078               AP4_UI32         height);
00079     AP4_Track(AP4_TrakAtom&   atom, 
00080               AP4_ByteStream& sample_stream,
00081               AP4_UI32        movie_time_scale);
00082     virtual ~AP4_Track();
00083     AP4_Track::Type GetType() { return m_Type; }
00084     AP4_UI32     GetDuration();
00085     AP4_Duration GetDurationMs();
00086     AP4_Cardinal GetSampleCount();
00087         AP4_Result   GetSample(AP4_Ordinal index, AP4_Sample& sample);
00088         AP4_Result   ReadSample(AP4_Ordinal     index, 
00089                             AP4_Sample&     sample,
00090                             AP4_DataBuffer& data);
00091     AP4_Result   GetSampleIndexForTimeStampMs(AP4_TimeStamp ts, 
00092                                               AP4_Ordinal& index);
00093     AP4_SampleDescription* GetSampleDescription(AP4_Ordinal index);
00094     AP4_UI32      GetId();
00095     AP4_Result    SetId(AP4_UI32 track_id);
00096     AP4_TrakAtom* GetTrakAtom() { return m_TrakAtom; }
00097     AP4_Result    SetMovieTimeScale(AP4_UI32 time_scale);
00098     AP4_UI32      GetMediaTimeScale();
00099 
00100         AP4_String    GetTrackName();
00101         AP4_String    GetTrackLanguage();
00102 
00103  protected:
00104     // members
00105     AP4_TrakAtom*    m_TrakAtom;
00106     bool             m_TrakAtomIsOwned;
00107     Type             m_Type;
00108     AP4_SampleTable* m_SampleTable;
00109     bool             m_SampleTableIsOwned;
00110     AP4_UI32         m_MovieTimeScale;
00111     AP4_UI32         m_MediaTimeScale;
00112 };
00113 
00114 #endif // _AP4_TRAK_H_

Generated on Tue Dec 13 14:47:20 2005 for guliverkli by  doxygen 1.4.5