- Main Page
- Classes
- Files

# Ap4Track.h

Go to the documentation of this file.

    00001 /*****************************************************************
    00002 |
    00003 |    AP4 - Track Objects
    00004 |
    00005 |    Copyright 2002-2006 Gilles Boccon-Gibod & Julien Boeuf
    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 "Ap4Types.h"
    00036 #include "Ap4Array.h"
    00037
    00038 /*----------------------------------------------------------------------
    00039 |   forward declarations
    00040 +---------------------------------------------------------------------*/
    00041 class AP4_StblAtom;
    00042 class AP4_ByteStream;
    00043 class AP4_Sample;
    00044 class AP4_DataBuffer;
    00045 class AP4_TrakAtom;
    00046 class AP4_MoovAtom;
    00047 class AP4_SampleDescription;
    00048 class AP4_SampleTable;
    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_SYSTEM,
    00066         TYPE_HINT,
    00067         TYPE_TEXT,
    00068         TYPE_JPEG,
    00069         TYPE_RTP
    00070     } Type;
    00071
    00072     // methods
    00073     AP4_Track(Type             type,
    00074               AP4_SampleTable* sample_table,
    00075               AP4_UI32         track_id,
    00076               AP4_UI32         movie_time_scale, // 0 = use default
    00077               AP4_UI32         media_time_scale,
    00078               AP4_UI32         media_duration,
    00079               const char*      language,
    00080               AP4_UI32         width,
    00081               AP4_UI32         height);
    00082     AP4_Track(AP4_TrakAtom&   atom,
    00083               AP4_ByteStream& sample_stream,
    00084               AP4_UI32        movie_time_scale);
    00085     virtual ~AP4_Track();
    00086     AP4_Track::Type GetType() { return m_Type; }
    00087     AP4_UI32     GetHandlerType();
    00088     AP4_UI32     GetDuration();
    00089     AP4_Duration GetDurationMs();
    00090     AP4_Cardinal GetSampleCount();
    00091     AP4_Result   GetSample(AP4_Ordinal index, AP4_Sample& sample);
    00092     AP4_Result   ReadSample(AP4_Ordinal     index,
    00093                             AP4_Sample&     sample,
    00094                             AP4_DataBuffer& data);
    00095     AP4_Result   GetSampleIndexForTimeStampMs(AP4_TimeStamp ts,
    00096                                               AP4_Ordinal&  index);
    00097     AP4_SampleDescription* GetSampleDescription(AP4_Ordinal index);
    00098     AP4_SampleTable*       GetSampleTable() { return m_SampleTable; }
    00099     AP4_UI32      GetId();
    00100     AP4_Result    SetId(AP4_UI32 track_id);
    00101     AP4_TrakAtom* GetTrakAtom() { return m_TrakAtom; }
    00102     AP4_Result    SetMovieTimeScale(AP4_UI32 time_scale);
    00103     AP4_UI32      GetMediaTimeScale();
    00104     const char*   GetTrackName();
    00105     const char*   GetTrackLanguage();
    00106     AP4_Result    Attach(AP4_MoovAtom* moov);
    00107
    00108  protected:
    00109     // members
    00110     AP4_TrakAtom*    m_TrakAtom;
    00111     bool             m_TrakAtomIsOwned;
    00112     Type             m_Type;
    00113     AP4_SampleTable* m_SampleTable;
    00114     bool             m_SampleTableIsOwned;
    00115     AP4_UI32         m_MovieTimeScale;
    00116     AP4_UI32         m_MediaTimeScale;
    00117 };
    00118
    00119 #endif // _AP4_TRAK_H_