Ap4SampleEntry.h

Go to the documentation of this file.
00001 /*****************************************************************
00002 |
00003 |    AP4 - sample entries
00004 |
00005 |    Copyright 2002-2006 Gilles Boccon-Gibod & Julien Boeuf & 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_SAMPLE_ENTRY_H_
00030 #define _AP4_SAMPLE_ENTRY_H_
00031 
00032 /*----------------------------------------------------------------------
00033 |   includes
00034 +---------------------------------------------------------------------*/
00035 #include "Ap4Types.h"
00036 #include "Ap4List.h"
00037 #include "Ap4Atom.h"
00038 #include "Ap4EsdsAtom.h"
00039 #include "Ap4AtomFactory.h"
00040 #include "Ap4ContainerAtom.h"
00041 
00042 /*----------------------------------------------------------------------
00043 |   class references
00044 +---------------------------------------------------------------------*/
00045 class AP4_SampleDescription;
00046 
00047 /*----------------------------------------------------------------------
00048 |   AP4_SampleEntry
00049 +---------------------------------------------------------------------*/
00050 class AP4_SampleEntry : public AP4_ContainerAtom
00051 {
00052  public: 
00053     // methods
00054     AP4_SampleEntry(AP4_Atom::Type format, AP4_UI16 data_ref_index = 1);
00055     AP4_SampleEntry(AP4_Atom::Type   format, 
00056                     AP4_Size         size,
00057                     AP4_ByteStream&  stream,
00058                     AP4_AtomFactory& atom_factory);
00059     AP4_UI16           GetDataReferenceIndex() { return m_DataReferenceIndex; }
00060     virtual AP4_Result Write(AP4_ByteStream& stream);
00061     virtual AP4_Result Inspect(AP4_AtomInspector& inspector);
00062     virtual AP4_SampleDescription* ToSampleDescription();
00063 
00064     // AP4_AtomParent methods
00065     virtual void OnChildChanged(AP4_Atom* child);
00066 
00067  protected:
00068     // constructor
00069     AP4_SampleEntry(AP4_Atom::Type format, AP4_Size size);
00070 
00071     // methods
00072     virtual AP4_Size   GetFieldsSize();
00073     virtual AP4_Result ReadFields(AP4_ByteStream& stream);
00074     virtual AP4_Result WriteFields(AP4_ByteStream& stream);
00075     virtual AP4_Result InspectFields(AP4_AtomInspector& inspector);
00076 
00077     // members
00078     AP4_UI08 m_Reserved1[6];         // = 0
00079     AP4_UI16 m_DataReferenceIndex;
00080 };
00081 
00082 /*----------------------------------------------------------------------
00083 |   AP4_AudioSampleEntry
00084 +---------------------------------------------------------------------*/
00085 class AP4_AudioSampleEntry : public AP4_SampleEntry
00086 {
00087 public:
00088     // methods
00089     AP4_AudioSampleEntry(AP4_Atom::Type   format,
00090                          AP4_UI32         sample_rate,
00091                          AP4_UI16         sample_size,
00092                          AP4_UI16         channel_count);
00093     AP4_AudioSampleEntry(AP4_Atom::Type   format,
00094                          AP4_Size         size,
00095                          AP4_ByteStream&  stream,
00096                          AP4_AtomFactory& atom_factory);
00097 
00098     // accessors
00099     AP4_UI32 GetSampleRate()   { return m_SampleRate>>16; }
00100     AP4_UI16 GetSampleSize()   { return m_SampleSize;     }
00101     AP4_UI16 GetChannelCount() { return m_ChannelCount;   }
00102 
00103     // methods
00104     AP4_SampleDescription* ToSampleDescription();
00105 
00106     // this method is used as a factory by the ISMACryp classes
00107     // NOTE: this should be named ToSampleDescription, but C++ has a 
00108     // problem with that because the base class does not have this
00109     // overloaded method, but has another other one by that name
00110     virtual AP4_SampleDescription* ToTargetSampleDescription(AP4_UI32 format);
00111 
00112 protected:
00113     // methods
00114     virtual AP4_Size   GetFieldsSize();
00115     virtual AP4_Result ReadFields(AP4_ByteStream& stream);
00116     virtual AP4_Result WriteFields(AP4_ByteStream& stream);
00117     virtual AP4_Result InspectFields(AP4_AtomInspector& inspector);
00118 
00119     // members
00120     AP4_UI08 m_Reserved2[8]; // = 0
00121     AP4_UI32 m_SampleRate;           
00122     AP4_UI16 m_ChannelCount; // = 2
00123     AP4_UI16 m_SampleSize;   // = 16
00124     AP4_UI16 m_Predefined1;  // = 0
00125     AP4_UI16 m_Reserved3;    // = 0
00126 };
00127 
00128 /*----------------------------------------------------------------------
00129 |   AP4_VisualSampleEntry
00130 +---------------------------------------------------------------------*/
00131 class AP4_VisualSampleEntry : public AP4_SampleEntry
00132 {
00133 public:
00134     // methods
00135     AP4_VisualSampleEntry(AP4_Atom::Type    format, 
00136                           AP4_UI16          width,
00137                           AP4_UI16          height,
00138                           AP4_UI16          depth,
00139                           const char*       compressor_name);
00140     AP4_VisualSampleEntry(AP4_Atom::Type   format,
00141                           AP4_Size         size,
00142                           AP4_ByteStream&  stream,
00143                           AP4_AtomFactory& atom_factory);
00144 
00145     // accessors
00146     AP4_UI16    GetWidth()          { return m_Width;  }
00147     AP4_UI16    GetHeight()         { return m_Height; }
00148     AP4_UI16    GetHorizResolution(){ return m_HorizResolution;  }
00149     AP4_UI16    GetVertResolution() { return m_VertResolution; }
00150     AP4_UI16    GetDepth()          { return m_Depth;  }
00151     const char* GetCompressorName() { return m_CompressorName.GetChars(); }
00152 
00153     // methods
00154     AP4_SampleDescription* ToSampleDescription();
00155 
00156     // this method is used as a factory by the ISMACryp classes
00157     // NOTE: this should be named ToSampleDescription, but C++ has a 
00158     // problem with that because the base class does not have this
00159     // overloaded method, but has another other one by that name
00160     virtual AP4_SampleDescription* ToTargetSampleDescription(AP4_UI32 format);
00161 
00162 protected:
00163     // methods
00164     virtual AP4_Size   GetFieldsSize();
00165     virtual AP4_Result ReadFields(AP4_ByteStream& stream);
00166     virtual AP4_Result WriteFields(AP4_ByteStream& stream);
00167     virtual AP4_Result InspectFields(AP4_AtomInspector& inspector);
00168 
00169     //members
00170     AP4_UI16   m_Predefined1;     // = 0
00171     AP4_UI16   m_Reserved2;       // = 0
00172     AP4_UI08   m_Predefined2[12]; // = 0
00173     AP4_UI16   m_Width;
00174     AP4_UI16   m_Height;
00175     AP4_UI32   m_HorizResolution; // = 0x00480000 (72 dpi)
00176     AP4_UI32   m_VertResolution;  // = 0x00480000 (72 dpi)
00177     AP4_UI32   m_Reserved3;       // = 0
00178     AP4_UI16   m_FrameCount;      // = 1
00179     AP4_String m_CompressorName;       
00180     AP4_UI16   m_Depth;           // = 0x0018
00181     AP4_UI16   m_Predefined3;     // = 0xFFFF
00182 };
00183 
00184 /*----------------------------------------------------------------------
00185 |   AP4_MpegSystemSampleEntry
00186 +---------------------------------------------------------------------*/
00187 class AP4_MpegSystemSampleEntry : public AP4_SampleEntry
00188 {
00189 public:
00190     // constructors
00191     AP4_MpegSystemSampleEntry(AP4_UI32          type,
00192                               AP4_EsDescriptor* descriptor);
00193     AP4_MpegSystemSampleEntry(AP4_UI32         type,
00194                               AP4_Size         size,
00195                               AP4_ByteStream&  stream,
00196                               AP4_AtomFactory& atom_factory);
00197 
00198     // methods
00199     AP4_SampleDescription* ToSampleDescription();
00200 };
00201 
00202 /*----------------------------------------------------------------------
00203 |   AP4_MpegAudioSampleEntry
00204 +---------------------------------------------------------------------*/
00205 class AP4_MpegAudioSampleEntry : public AP4_AudioSampleEntry
00206 {
00207 public:
00208     // constructors
00209     AP4_MpegAudioSampleEntry(AP4_UI32          type,
00210                              AP4_UI32          sample_rate, 
00211                              AP4_UI16          sample_size,
00212                              AP4_UI16          channel_count,
00213                              AP4_EsDescriptor* descriptor);
00214     AP4_MpegAudioSampleEntry(AP4_UI32         type,
00215                              AP4_Size         size,
00216                              AP4_ByteStream&  stream,
00217                              AP4_AtomFactory& atom_factory);
00218 
00219     // methods
00220     AP4_SampleDescription* ToSampleDescription();
00221 };
00222 
00223 /*----------------------------------------------------------------------
00224 |   AP4_MpegVideoSampleEntry
00225 +---------------------------------------------------------------------*/
00226 class AP4_MpegVideoSampleEntry : public AP4_VisualSampleEntry
00227 {
00228 public:
00229     // constructors
00230     AP4_MpegVideoSampleEntry(AP4_UI32          type,
00231                              AP4_UI16          width,
00232                              AP4_UI16          height,
00233                              AP4_UI16          depth,
00234                              const char*       compressor_name,
00235                              AP4_EsDescriptor* descriptor);
00236     AP4_MpegVideoSampleEntry(AP4_UI32         type,
00237                              AP4_Size         size,
00238                              AP4_ByteStream&  stream,
00239                              AP4_AtomFactory& atom_factory);
00240 
00241     // methods
00242     AP4_SampleDescription* ToSampleDescription();
00243 };
00244 
00245 /*----------------------------------------------------------------------
00246 |   AP4_Mp4sSampleEntry
00247 +---------------------------------------------------------------------*/
00248 class AP4_Mp4sSampleEntry : public AP4_MpegSystemSampleEntry
00249 {
00250  public:
00251     // constructors
00252     AP4_Mp4sSampleEntry(AP4_Size         size,
00253                         AP4_ByteStream&  stream,
00254                         AP4_AtomFactory& atom_factory);
00255     AP4_Mp4sSampleEntry(AP4_EsDescriptor* descriptor);
00256 
00257     // methods
00258     AP4_SampleDescription* ToSampleDescription();
00259 };
00260 
00261 /*----------------------------------------------------------------------
00262 |   AP4_Mp4aSampleEntry
00263 +---------------------------------------------------------------------*/
00264 class AP4_Mp4aSampleEntry : public AP4_MpegAudioSampleEntry
00265 {
00266  public:
00267     // constructors
00268     AP4_Mp4aSampleEntry(AP4_Size         size,
00269                         AP4_ByteStream&  stream,
00270                         AP4_AtomFactory& atom_factory);
00271     AP4_Mp4aSampleEntry(AP4_UI32          sample_rate, 
00272                         AP4_UI16          sample_size,
00273                         AP4_UI16          channel_count,
00274                         AP4_EsDescriptor* descriptor);
00275 };
00276 
00277 /*----------------------------------------------------------------------
00278 |   AP4_Mp4vSampleEntry
00279 +---------------------------------------------------------------------*/
00280 class AP4_Mp4vSampleEntry : public AP4_MpegVideoSampleEntry
00281 {
00282  public:
00283     // constructors
00284     AP4_Mp4vSampleEntry(AP4_Size         size,
00285                         AP4_ByteStream&  stream,
00286                         AP4_AtomFactory& atom_factory);
00287     AP4_Mp4vSampleEntry(AP4_UI16          width,
00288                         AP4_UI16          height,
00289                         AP4_UI16          depth,
00290                         const char*       compressor_name,
00291                         AP4_EsDescriptor* descriptor);
00292 };
00293 
00294 /*----------------------------------------------------------------------
00295 |   AP4_Avc1SampleEntry
00296 +---------------------------------------------------------------------*/
00297 class AP4_Avc1SampleEntry : public AP4_VisualSampleEntry
00298 {
00299 public:
00300     // constructors
00301     AP4_Avc1SampleEntry(AP4_Size         size,
00302                         AP4_ByteStream&  stream,
00303                         AP4_AtomFactory& atom_factory);
00304     AP4_Avc1SampleEntry(AP4_UI16    width,
00305                         AP4_UI16    height,
00306                         AP4_UI16    depth,
00307                         const char* compressor_name);
00308 };
00309 
00310 /*----------------------------------------------------------------------
00311 |   AP4_RtpHintSampleEntry
00312 +---------------------------------------------------------------------*/
00313 class AP4_RtpHintSampleEntry : public AP4_SampleEntry
00314 {
00315 public:
00316     // methods
00317     AP4_RtpHintSampleEntry(AP4_UI16 hint_track_version,
00318                            AP4_UI16 highest_compatible_version,
00319                            AP4_UI32 max_packet_size,
00320                            AP4_UI32 timescale);
00321     AP4_RtpHintSampleEntry(AP4_Size         size,
00322                            AP4_ByteStream&  stream,
00323                            AP4_AtomFactory& atom_factory);
00324     virtual ~AP4_RtpHintSampleEntry();
00325     
00326 protected:
00327     // methods
00328     virtual AP4_Size   GetFieldsSize();
00329     virtual AP4_Result ReadFields(AP4_ByteStream& stream);
00330     virtual AP4_Result WriteFields(AP4_ByteStream& stream);
00331     virtual AP4_Result InspectFields(AP4_AtomInspector& inspector);
00332 
00333     // members
00334     AP4_UI16 m_HintTrackVersion;
00335     AP4_UI16 m_HighestCompatibleVersion;
00336     AP4_UI32 m_MaxPacketSize;
00337 };
00338 
00339 #endif // _AP4_SAMPLE_ENTRY_H_

Generated on Thu Mar 15 16:06:12 2007 for Bento4 MP4 SDK by  doxygen 1.5.1-p1