- Main Page
- Classes
- Files

# Ap4SampleDescription.h

Go to the documentation of this file.

    00001 /*****************************************************************
    00002 |
    00003 |    AP4 - Sample Descriptions
    00004 |
    00005 |    Copyright 2002-2005 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_DESCRIPTION_H_
    00030 #define _AP4_SAMPLE_DESCRIPTION_H_
    00031
    00032 /*----------------------------------------------------------------------
    00033 |   includes
    00034 +---------------------------------------------------------------------*/
    00035 #include "Ap4Types.h"
    00036 #include "Ap4Atom.h"
    00037 #include "Ap4EsDescriptor.h"
    00038 #include "Ap4EsdsAtom.h"
    00039
    00040 /*----------------------------------------------------------------------
    00041 |   class references
    00042 +---------------------------------------------------------------------*/
    00043 class AP4_SampleEntry;
    00044 class AP4_DataBuffer;
    00045
    00046 /*----------------------------------------------------------------------
    00047 |   constants
    00048 +---------------------------------------------------------------------*/
    00049 #define AP4_SAMPLE_FORMAT_MP4A AP4_ATOM_TYPE_MP4A
    00050 #define AP4_SAMPLE_FORMAT_MP4V AP4_ATOM_TYPE_MP4V
    00051 #define AP4_SAMPLE_FORMAT_AVC1 AP4_ATOM_TYPE_AVC1
    00052 #define AP4_SAMPLE_FORMAT_ALAC AP4_ATOM_TYPE_ALAC
    00053
    00054 /*----------------------------------------------------------------------
    00055 |   AP4_SampleDescription
    00056 +---------------------------------------------------------------------*/
    00057 class AP4_SampleDescription
    00058 {
    00059  public:
    00060     // type constants of the sample description
    00061     enum Type {
    00062         TYPE_UNKNOWN   = 0x00,
    00063         TYPE_MPEG      = 0x01,
    00064         TYPE_PROTECTED = 0x02
    00065     };
    00066
    00067     // constructors & destructor
    00068     AP4_SampleDescription(Type            type,
    00069                           AP4_UI32        format,
    00070                           AP4_AtomParent* details);
    00071     virtual ~AP4_SampleDescription() {}
    00072
    00073     // accessors
    00074     Type GetType()       const { return m_Type;   }
    00075     AP4_UI32 GetFormat() const { return m_Format; }
    00076     AP4_AtomParent& GetDetails() { return m_Details; }
    00077
    00078     // factories
    00079     virtual AP4_Atom* ToAtom() const;
    00080
    00081  protected:
    00082     Type           m_Type;
    00083     AP4_UI32       m_Format;
    00084     AP4_AtomParent m_Details;
    00085 };
    00086
    00087 /*----------------------------------------------------------------------
    00088 |   AP4_AudioSampleDescription  // MIXIN class
    00089 +---------------------------------------------------------------------*/
    00090 class AP4_AudioSampleDescription
    00091 {
    00092 public:
    00093     // constructor
    00094     AP4_AudioSampleDescription(unsigned int sample_rate,
    00095                                unsigned int sample_size,
    00096                                unsigned int channel_count) :
    00097     m_SampleRate(sample_rate),
    00098     m_SampleSize(sample_size),
    00099     m_ChannelCount(channel_count) {}
    00100
    00101     // accessors
    00102     AP4_UI32 GetSampleRate()   { return m_SampleRate;   }
    00103     AP4_UI16 GetSampleSize()   { return m_SampleSize;   }
    00104     AP4_UI16 GetChannelCount() { return m_ChannelCount; }
    00105
    00106 protected:
    00107     // members
    00108     AP4_UI32 m_SampleRate;
    00109     AP4_UI16 m_SampleSize;
    00110     AP4_UI16 m_ChannelCount;
    00111 };
    00112
    00113 /*----------------------------------------------------------------------
    00114 |   AP4_VideoSampleDescription  // MIXIN class
    00115 +---------------------------------------------------------------------*/
    00116 class AP4_VideoSampleDescription
    00117 {
    00118 public:
    00119     // constructor
    00120     AP4_VideoSampleDescription(AP4_UI16    width,
    00121                                AP4_UI16    height,
    00122                                AP4_UI16    depth,
    00123                                const char* compressor_name) :
    00124     m_Width(width),
    00125     m_Height(height),
    00126     m_Depth(depth),
    00127     m_CompressorName(compressor_name) {}
    00128
    00129     // accessors
    00130     AP4_UI32    GetWidth()          { return m_Width;   }
    00131     AP4_UI16    GetHeight()         { return m_Height;   }
    00132     AP4_UI16    GetDepth()          { return m_Depth; }
    00133     const char* GetCompressorName() { return m_CompressorName.GetChars(); }
    00134
    00135 protected:
    00136     // members
    00137     AP4_UI16   m_Width;
    00138     AP4_UI16   m_Height;
    00139     AP4_UI16   m_Depth;
    00140     AP4_String m_CompressorName;
    00141 };
    00142
    00143 /*----------------------------------------------------------------------
    00144 |   AP4_GenericAudioSampleDescription
    00145 +---------------------------------------------------------------------*/
    00146 class AP4_GenericAudioSampleDescription : public AP4_SampleDescription,
    00147                                           public AP4_AudioSampleDescription
    00148 {
    00149 public:
    00150     // constructors
    00151     AP4_GenericAudioSampleDescription(AP4_UI32        format,
    00152                                       unsigned int    sample_rate,
    00153                                       unsigned int    sample_size,
    00154                                       unsigned int    channel_count,
    00155                                       AP4_AtomParent* details) :
    00156         AP4_SampleDescription(TYPE_UNKNOWN, format, details),
    00157         AP4_AudioSampleDescription(sample_rate, sample_size, channel_count) {}
    00158 };
    00159
    00160 /*----------------------------------------------------------------------
    00161 |   AP4_GenericVideoSampleDescription
    00162 +---------------------------------------------------------------------*/
    00163 class AP4_GenericVideoSampleDescription : public AP4_SampleDescription,
    00164                                           public AP4_VideoSampleDescription
    00165 {
    00166 public:
    00167     // constructor
    00168     AP4_GenericVideoSampleDescription(AP4_UI32        format,
    00169                                       AP4_UI16        width,
    00170                                       AP4_UI16        height,
    00171                                       AP4_UI16        depth,
    00172                                       const char*     compressor_name,
    00173                                       AP4_AtomParent* details) :
    00174     AP4_SampleDescription(TYPE_UNKNOWN, format, details),
    00175     AP4_VideoSampleDescription(width, height, depth, compressor_name) {}
    00176 };
    00177
    00178 /*----------------------------------------------------------------------
    00179 |   AP4_MpegSampleDescription
    00180 +---------------------------------------------------------------------*/
    00181 class AP4_MpegSampleDescription : public AP4_SampleDescription
    00182 {
    00183  public:
    00184     // types
    00185     typedef AP4_UI08 StreamType;
    00186     typedef AP4_UI08 OTI;
    00187
    00188     // class methods
    00189     static const char* GetStreamTypeString(StreamType type);
    00190     static const char* GetObjectTypeString(OTI oti);
    00191
    00192     // constructors & destructor
    00193     AP4_MpegSampleDescription(AP4_UI32      format,
    00194                               AP4_EsdsAtom* esds);
    00195     AP4_MpegSampleDescription(AP4_UI32              format,
    00196                               StreamType            stream_type,
    00197                               OTI                   oti,
    00198                               const AP4_DataBuffer* decoder_info,
    00199                               AP4_UI32              buffer_size,
    00200                               AP4_UI32              max_bitrate,
    00201                               AP4_UI32              avg_bitrate);
    00202
    00203     // accessors
    00204     AP4_Byte GetStreamType() const { return m_StreamType; }
    00205     AP4_Byte GetObjectTypeId() const { return m_ObjectTypeId; }
    00206     AP4_UI32 GetBufferSize() const { return m_BufferSize; }
    00207     AP4_UI32 GetMaxBitrate() const { return m_MaxBitrate; }
    00208     AP4_UI32 GetAvgBitrate() const { return m_AvgBitrate; }
    00209     const AP4_DataBuffer& GetDecoderInfo() const { return m_DecoderInfo; }
    00210
    00211
    00212     // methods
    00213     AP4_EsDescriptor* CreateEsDescriptor() const;
    00214
    00215  protected:
    00216     // members
    00217     AP4_UI32       m_Format;
    00218     StreamType     m_StreamType;
    00219     OTI            m_ObjectTypeId;
    00220     AP4_UI32       m_BufferSize;
    00221     AP4_UI32       m_MaxBitrate;
    00222     AP4_UI32       m_AvgBitrate;
    00223     AP4_DataBuffer m_DecoderInfo;
    00224 };
    00225
    00226 /*----------------------------------------------------------------------
    00227 |   AP4_MpegSystemSampleDescription
    00228 +---------------------------------------------------------------------*/
    00229 class AP4_MpegSystemSampleDescription : public AP4_MpegSampleDescription
    00230 {
    00231 public:
    00232     // constructor
    00233     AP4_MpegSystemSampleDescription(AP4_EsdsAtom* esds);
    00234     AP4_MpegSystemSampleDescription(StreamType            stream_type,
    00235                                     OTI                   oti,
    00236                                     const AP4_DataBuffer* decoder_info,
    00237                                     AP4_UI32              buffer_size,
    00238                                     AP4_UI32              max_bitrate,
    00239                                     AP4_UI32              avg_bitrate);
    00240
    00241     // methods
    00242     AP4_Atom* ToAtom() const;
    00243 };
    00244
    00245 /*----------------------------------------------------------------------
    00246 |   AP4_MpegAudioSampleDescription
    00247 +---------------------------------------------------------------------*/
    00248 class AP4_MpegAudioSampleDescription : public AP4_MpegSampleDescription,
    00249                                        public AP4_AudioSampleDescription
    00250 {
    00251 public:
    00252     // types
    00253     typedef AP4_UI08 Mpeg4AudioObjectType;
    00254
    00255     // class methods
    00256     static const char* GetMpeg4AudioObjectTypeString(Mpeg4AudioObjectType type);
    00257
    00258     // constructor
    00259     AP4_MpegAudioSampleDescription(AP4_EsdsAtom* esds,
    00260                                    unsigned int  sample_rate,
    00261                                    unsigned int  sample_size,
    00262                                    unsigned int  channel_count);
    00263     AP4_MpegAudioSampleDescription(OTI                   oti,
    00264                                    unsigned int          sample_rate,
    00265                                    unsigned int          sample_size,
    00266                                    unsigned int          channel_count,
    00267                                    const AP4_DataBuffer* decoder_info,
    00268                                    AP4_UI32              buffer_size,
    00269                                    AP4_UI32              max_bitrate,
    00270                                    AP4_UI32              avg_bitrate);
    00271
    00272     // methods
    00273     AP4_Atom* ToAtom() const;
    00274
    00280     Mpeg4AudioObjectType GetMpeg4AudioObjectType() const;
    00281 };
    00282
    00283 /*----------------------------------------------------------------------
    00284 |   AP4_MpegVideoSampleDescription
    00285 +---------------------------------------------------------------------*/
    00286 class AP4_MpegVideoSampleDescription : public AP4_MpegSampleDescription,
    00287                                        public AP4_VideoSampleDescription
    00288 {
    00289 public:
    00290     // constructor
    00291     AP4_MpegVideoSampleDescription(AP4_EsdsAtom* esds,
    00292                                    AP4_UI16      width,
    00293                                    AP4_UI16      height,
    00294                                    AP4_UI16      depth,
    00295                                    const char*   compressor_name);
    00296     AP4_MpegVideoSampleDescription(OTI                   oti,
    00297                                    AP4_UI16              width,
    00298                                    AP4_UI16              height,
    00299                                    AP4_UI16              depth,
    00300                                    const char*           compressor_name,
    00301                                    const AP4_DataBuffer* decoder_info,
    00302                                    AP4_UI32              buffer_size,
    00303                                    AP4_UI32              max_bitrate,
    00304                                    AP4_UI32              avg_bitrate);
    00305
    00306     // methods
    00307     AP4_Atom* ToAtom() const;
    00308 };
    00309
    00310 /*----------------------------------------------------------------------
    00311 |   constants
    00312 +---------------------------------------------------------------------*/
    00313 const AP4_MpegSampleDescription::StreamType AP4_STREAM_TYPE_FORBIDDEN = 0x00;
    00314 const AP4_MpegSampleDescription::StreamType AP4_STREAM_TYPE_OD        = 0x01;
    00315 const AP4_MpegSampleDescription::StreamType AP4_STREAM_TYPE_CR        = 0x02;
    00316 const AP4_MpegSampleDescription::StreamType AP4_STREAM_TYPE_BIFS      = 0x03;
    00317 const AP4_MpegSampleDescription::StreamType AP4_STREAM_TYPE_VISUAL    = 0x04;
    00318 const AP4_MpegSampleDescription::StreamType AP4_STREAM_TYPE_AUDIO     = 0x05;
    00319 const AP4_MpegSampleDescription::StreamType AP4_STREAM_TYPE_MPEG7     = 0x06;
    00320 const AP4_MpegSampleDescription::StreamType AP4_STREAM_TYPE_IPMP      = 0x07;
    00321 const AP4_MpegSampleDescription::StreamType AP4_STREAM_TYPE_OCI       = 0x08;
    00322 const AP4_MpegSampleDescription::StreamType AP4_STREAM_TYPE_MPEGJ     = 0x09;
    00323 const AP4_MpegSampleDescription::StreamType AP4_STREAM_TYPE_TEXT      = 0x0D;
    00324
    00325 const AP4_MpegSampleDescription::OTI AP4_OTI_MPEG4_SYSTEM         = 0x01;
    00326 const AP4_MpegSampleDescription::OTI AP4_OTI_MPEG4_SYSTEM_COR     = 0x02;
    00327 const AP4_MpegSampleDescription::OTI AP4_OTI_MPEG4_TEXT           = 0x08;
    00328 const AP4_MpegSampleDescription::OTI AP4_OTI_MPEG4_VISUAL         = 0x20;
    00329 const AP4_MpegSampleDescription::OTI AP4_OTI_MPEG4_AUDIO          = 0x40;
    00330 const AP4_MpegSampleDescription::OTI AP4_OTI_MPEG2_VISUAL_SIMPLE  = 0x60;
    00331 const AP4_MpegSampleDescription::OTI AP4_OTI_MPEG2_VISUAL_MAIN    = 0x61;
    00332 const AP4_MpegSampleDescription::OTI AP4_OTI_MPEG2_VISUAL_SNR     = 0x62;
    00333 const AP4_MpegSampleDescription::OTI AP4_OTI_MPEG2_VISUAL_SPATIAL = 0x63;
    00334 const AP4_MpegSampleDescription::OTI AP4_OTI_MPEG2_VISUAL_HIGH    = 0x64;
    00335 const AP4_MpegSampleDescription::OTI AP4_OTI_MPEG2_VISUAL_422     = 0x65;
    00336 const AP4_MpegSampleDescription::OTI AP4_OTI_MPEG2_AAC_AUDIO_MAIN = 0x66;
    00337 const AP4_MpegSampleDescription::OTI AP4_OTI_MPEG2_AAC_AUDIO_LC   = 0x67;
    00338 const AP4_MpegSampleDescription::OTI AP4_OTI_MPEG2_AAC_AUDIO_SSRP = 0x68;
    00339 const AP4_MpegSampleDescription::OTI AP4_OTI_MPEG2_PART3_AUDIO    = 0x69;
    00340 const AP4_MpegSampleDescription::OTI AP4_OTI_MPEG1_VISUAL         = 0x6A;
    00341 const AP4_MpegSampleDescription::OTI AP4_OTI_MPEG1_AUDIO          = 0x6B;
    00342 const AP4_MpegSampleDescription::OTI AP4_OTI_JPEG                 = 0x6C;
    00343
    00344 const AP4_MpegAudioSampleDescription::Mpeg4AudioObjectType AP4_MPEG4_AUDIO_OBJECT_TYPE_AAC_MAIN        = 1;
    00345 const AP4_MpegAudioSampleDescription::Mpeg4AudioObjectType AP4_MPEG4_AUDIO_OBJECT_TYPE_AAC_LC          = 2;
    00346 const AP4_MpegAudioSampleDescription::Mpeg4AudioObjectType AP4_MPEG4_AUDIO_OBJECT_TYPE_AAC_SSR         = 3;
    00347 const AP4_MpegAudioSampleDescription::Mpeg4AudioObjectType AP4_MPEG4_AUDIO_OBJECT_TYPE_AAC_LTP         = 4;
    00348 const AP4_MpegAudioSampleDescription::Mpeg4AudioObjectType AP4_MPEG4_AUDIO_OBJECT_TYPE_SBR             = 5;
    00349 const AP4_MpegAudioSampleDescription::Mpeg4AudioObjectType AP4_MPEG4_AUDIO_OBJECT_TYPE_AAC_SCALABLE    = 6;
    00350 const AP4_MpegAudioSampleDescription::Mpeg4AudioObjectType AP4_MPEG4_AUDIO_OBJECT_TYPE_TWINVQ          = 7;
    00351 const AP4_MpegAudioSampleDescription::Mpeg4AudioObjectType AP4_MPEG4_AUDIO_OBJECT_TYPE_ER_AAC_LC       = 17;
    00352 const AP4_MpegAudioSampleDescription::Mpeg4AudioObjectType AP4_MPEG4_AUDIO_OBJECT_TYPE_ER_AAC_LTP      = 19;
    00353 const AP4_MpegAudioSampleDescription::Mpeg4AudioObjectType AP4_MPEG4_AUDIO_OBJECT_TYPE_ER_AAC_SCALABLE = 20;
    00354 const AP4_MpegAudioSampleDescription::Mpeg4AudioObjectType AP4_MPEG4_AUDIO_OBJECT_TYPE_ER_TWINVQ       = 21;
    00355 const AP4_MpegAudioSampleDescription::Mpeg4AudioObjectType AP4_MPEG4_AUDIO_OBJECT_TYPE_ER_BSAC         = 22;
    00356 const AP4_MpegAudioSampleDescription::Mpeg4AudioObjectType AP4_MPEG4_AUDIO_OBJECT_TYPE_ER_AAC_LD       = 23;
    00357 const AP4_MpegAudioSampleDescription::Mpeg4AudioObjectType AP4_MPEG4_AUDIO_OBJECT_TYPE_LAYER_1         = 32;
    00358 const AP4_MpegAudioSampleDescription::Mpeg4AudioObjectType AP4_MPEG4_AUDIO_OBJECT_TYPE_LAYER_2         = 33;
    00359 const AP4_MpegAudioSampleDescription::Mpeg4AudioObjectType AP4_MPEG4_AUDIO_OBJECT_TYPE_LAYER_3         = 34;
    00361 #endif // _AP4_SAMPLE_DESCRIPTION_H_
    00362