- Main Page
- Classes
- Files

# 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
    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();
    00100     AP4_UI16 GetSampleSize() { return m_SampleSize;     }
    00101     AP4_UI16 GetChannelCount();
    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_UI16 m_QtVersion;       // 0, 1 or 2
    00121     AP4_UI16 m_QtRevision;      // 0
    00122     AP4_UI32 m_QtVendor;        // 0
    00123     AP4_UI16 m_ChannelCount;
    00124     AP4_UI16 m_SampleSize;
    00125     AP4_UI16 m_QtCompressionId; // 0 or -2
    00126     AP4_UI16 m_QtPacketSize;    // always 0
    00127     AP4_UI32 m_SampleRate;      // 16.16 fixed point
    00128
    00129     AP4_UI32 m_QtV1SamplesPerPacket;
    00130     AP4_UI32 m_QtV1BytesPerPacket;
    00131     AP4_UI32 m_QtV1BytesPerFrame;
    00132     AP4_UI32 m_QtV1BytesPerSample;
    00133
    00134     AP4_UI32 m_QtV2StructSize;
    00135     double   m_QtV2SampleRate64;
    00136     AP4_UI32 m_QtV2ChannelCount;
    00137     AP4_UI32 m_QtV2Reserved;
    00138     AP4_UI32 m_QtV2BitsPerChannel;
    00139     AP4_UI32 m_QtV2FormatSpecificFlags;
    00140     AP4_UI32 m_QtV2BytesPerAudioPacket;
    00141     AP4_UI32 m_QtV2LPCMFramesPerAudioPacket;
    00142     AP4_DataBuffer m_QtV2Extension;
    00143 };
    00144
    00145 /*----------------------------------------------------------------------
    00146 |   AP4_VisualSampleEntry
    00147 +---------------------------------------------------------------------*/
    00148 class AP4_VisualSampleEntry : public AP4_SampleEntry
    00149 {
    00150 public:
    00151     // methods
    00152     AP4_VisualSampleEntry(AP4_Atom::Type    format,
    00153                           AP4_UI16          width,
    00154                           AP4_UI16          height,
    00155                           AP4_UI16          depth,
    00156                           const char*       compressor_name);
    00157     AP4_VisualSampleEntry(AP4_Atom::Type   format,
    00158                           AP4_Size         size,
    00159                           AP4_ByteStream&  stream,
    00160                           AP4_AtomFactory& atom_factory);
    00161
    00162     // accessors
    00163     AP4_UI16    GetWidth()          { return m_Width;  }
    00164     AP4_UI16    GetHeight()         { return m_Height; }
    00165     AP4_UI16    GetHorizResolution(){ return m_HorizResolution;  }
    00166     AP4_UI16    GetVertResolution() { return m_VertResolution; }
    00167     AP4_UI16    GetDepth()          { return m_Depth;  }
    00168     const char* GetCompressorName() { return m_CompressorName.GetChars(); }
    00169
    00170     // methods
    00171     AP4_SampleDescription* ToSampleDescription();
    00172
    00173     // this method is used as a factory by the ISMACryp classes
    00174     // NOTE: this should be named ToSampleDescription, but C++ has a
    00175     // problem with that because the base class does not have this
    00176     // overloaded method, but has another other one by that name
    00177     virtual AP4_SampleDescription* ToTargetSampleDescription(AP4_UI32 format);
    00178
    00179 protected:
    00180     // methods
    00181     virtual AP4_Size   GetFieldsSize();
    00182     virtual AP4_Result ReadFields(AP4_ByteStream& stream);
    00183     virtual AP4_Result WriteFields(AP4_ByteStream& stream);
    00184     virtual AP4_Result InspectFields(AP4_AtomInspector& inspector);
    00185
    00186     //members
    00187     AP4_UI16   m_Predefined1;     // = 0
    00188     AP4_UI16   m_Reserved2;       // = 0
    00189     AP4_UI08   m_Predefined2[12]; // = 0
    00190     AP4_UI16   m_Width;
    00191     AP4_UI16   m_Height;
    00192     AP4_UI32   m_HorizResolution; // = 0x00480000 (72 dpi)
    00193     AP4_UI32   m_VertResolution;  // = 0x00480000 (72 dpi)
    00194     AP4_UI32   m_Reserved3;       // = 0
    00195     AP4_UI16   m_FrameCount;      // = 1
    00196     AP4_String m_CompressorName;
    00197     AP4_UI16   m_Depth;           // = 0x0018
    00198     AP4_UI16   m_Predefined3;     // = 0xFFFF
    00199 };
    00200
    00201 /*----------------------------------------------------------------------
    00202 |   AP4_MpegSystemSampleEntry
    00203 +---------------------------------------------------------------------*/
    00204 class AP4_MpegSystemSampleEntry : public AP4_SampleEntry
    00205 {
    00206 public:
    00207     // constructors
    00208     AP4_MpegSystemSampleEntry(AP4_UI32          type,
    00209                               AP4_EsDescriptor* descriptor);
    00210     AP4_MpegSystemSampleEntry(AP4_UI32         type,
    00211                               AP4_Size         size,
    00212                               AP4_ByteStream&  stream,
    00213                               AP4_AtomFactory& atom_factory);
    00214
    00215     // methods
    00216     AP4_SampleDescription* ToSampleDescription();
    00217 };
    00218
    00219 /*----------------------------------------------------------------------
    00220 |   AP4_MpegAudioSampleEntry
    00221 +---------------------------------------------------------------------*/
    00222 class AP4_MpegAudioSampleEntry : public AP4_AudioSampleEntry
    00223 {
    00224 public:
    00225     // constructors
    00226     AP4_MpegAudioSampleEntry(AP4_UI32          type,
    00227                              AP4_UI32          sample_rate,
    00228                              AP4_UI16          sample_size,
    00229                              AP4_UI16          channel_count,
    00230                              AP4_EsDescriptor* descriptor);
    00231     AP4_MpegAudioSampleEntry(AP4_UI32         type,
    00232                              AP4_Size         size,
    00233                              AP4_ByteStream&  stream,
    00234                              AP4_AtomFactory& atom_factory);
    00235
    00236     // methods
    00237     AP4_SampleDescription* ToSampleDescription();
    00238 };
    00239
    00240 /*----------------------------------------------------------------------
    00241 |   AP4_MpegVideoSampleEntry
    00242 +---------------------------------------------------------------------*/
    00243 class AP4_MpegVideoSampleEntry : public AP4_VisualSampleEntry
    00244 {
    00245 public:
    00246     // constructors
    00247     AP4_MpegVideoSampleEntry(AP4_UI32          type,
    00248                              AP4_UI16          width,
    00249                              AP4_UI16          height,
    00250                              AP4_UI16          depth,
    00251                              const char*       compressor_name,
    00252                              AP4_EsDescriptor* descriptor);
    00253     AP4_MpegVideoSampleEntry(AP4_UI32         type,
    00254                              AP4_Size         size,
    00255                              AP4_ByteStream&  stream,
    00256                              AP4_AtomFactory& atom_factory);
    00257
    00258     // methods
    00259     AP4_SampleDescription* ToSampleDescription();
    00260 };
    00261
    00262 /*----------------------------------------------------------------------
    00263 |   AP4_Mp4sSampleEntry
    00264 +---------------------------------------------------------------------*/
    00265 class AP4_Mp4sSampleEntry : public AP4_MpegSystemSampleEntry
    00266 {
    00267  public:
    00268     // constructors
    00269     AP4_Mp4sSampleEntry(AP4_Size         size,
    00270                         AP4_ByteStream&  stream,
    00271                         AP4_AtomFactory& atom_factory);
    00272     AP4_Mp4sSampleEntry(AP4_EsDescriptor* descriptor);
    00273
    00274     // methods
    00275     AP4_SampleDescription* ToSampleDescription();
    00276 };
    00277
    00278 /*----------------------------------------------------------------------
    00279 |   AP4_Mp4aSampleEntry
    00280 +---------------------------------------------------------------------*/
    00281 class AP4_Mp4aSampleEntry : public AP4_MpegAudioSampleEntry
    00282 {
    00283  public:
    00284     // constructors
    00285     AP4_Mp4aSampleEntry(AP4_Size         size,
    00286                         AP4_ByteStream&  stream,
    00287                         AP4_AtomFactory& atom_factory);
    00288     AP4_Mp4aSampleEntry(AP4_UI32          sample_rate,
    00289                         AP4_UI16          sample_size,
    00290                         AP4_UI16          channel_count,
    00291                         AP4_EsDescriptor* descriptor);
    00292 };
    00293
    00294 /*----------------------------------------------------------------------
    00295 |   AP4_Mp4vSampleEntry
    00296 +---------------------------------------------------------------------*/
    00297 class AP4_Mp4vSampleEntry : public AP4_MpegVideoSampleEntry
    00298 {
    00299  public:
    00300     // constructors
    00301     AP4_Mp4vSampleEntry(AP4_Size         size,
    00302                         AP4_ByteStream&  stream,
    00303                         AP4_AtomFactory& atom_factory);
    00304     AP4_Mp4vSampleEntry(AP4_UI16          width,
    00305                         AP4_UI16          height,
    00306                         AP4_UI16          depth,
    00307                         const char*       compressor_name,
    00308                         AP4_EsDescriptor* descriptor);
    00309 };
    00310
    00311 /*----------------------------------------------------------------------
    00312 |   AP4_Avc1SampleEntry
    00313 +---------------------------------------------------------------------*/
    00314 class AP4_Avc1SampleEntry : public AP4_VisualSampleEntry
    00315 {
    00316 public:
    00317     // constructors
    00318     AP4_Avc1SampleEntry(AP4_Size         size,
    00319                         AP4_ByteStream&  stream,
    00320                         AP4_AtomFactory& atom_factory);
    00321     AP4_Avc1SampleEntry(AP4_UI16    width,
    00322                         AP4_UI16    height,
    00323                         AP4_UI16    depth,
    00324                         const char* compressor_name);
    00325 };
    00326
    00327 /*----------------------------------------------------------------------
    00328 |   AP4_RtpHintSampleEntry
    00329 +---------------------------------------------------------------------*/
    00330 class AP4_RtpHintSampleEntry : public AP4_SampleEntry
    00331 {
    00332 public:
    00333     // methods
    00334     AP4_RtpHintSampleEntry(AP4_UI16 hint_track_version,
    00335                            AP4_UI16 highest_compatible_version,
    00336                            AP4_UI32 max_packet_size,
    00337                            AP4_UI32 timescale);
    00338     AP4_RtpHintSampleEntry(AP4_Size         size,
    00339                            AP4_ByteStream&  stream,
    00340                            AP4_AtomFactory& atom_factory);
    00341     virtual ~AP4_RtpHintSampleEntry();
    00342
    00343 protected:
    00344     // methods
    00345     virtual AP4_Size   GetFieldsSize();
    00346     virtual AP4_Result ReadFields(AP4_ByteStream& stream);
    00347     virtual AP4_Result WriteFields(AP4_ByteStream& stream);
    00348     virtual AP4_Result InspectFields(AP4_AtomInspector& inspector);
    00349
    00350     // members
    00351     AP4_UI16 m_HintTrackVersion;
    00352     AP4_UI16 m_HighestCompatibleVersion;
    00353     AP4_UI32 m_MaxPacketSize;
    00354 };
    00355
    00356 #endif // _AP4_SAMPLE_ENTRY_H_