Ap4SampleEntry.h

00001 /*****************************************************************
00002 |
00003 |    AP4 - sample entries
00004 |
00005 |    Copyright 2002 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 "Ap4.h"
00036 #include "Ap4ByteStream.h"
00037 #include "Ap4List.h"
00038 #include "Ap4Atom.h"
00039 #include "Ap4EsdsAtom.h"
00040 #include "Ap4AtomFactory.h"
00041 #include "Ap4ContainerAtom.h"
00042 
00043 /*----------------------------------------------------------------------
00044 |       class references
00045 +---------------------------------------------------------------------*/
00046 class AP4_SampleDescription;
00047 
00048 /*----------------------------------------------------------------------
00049 |       AP4_SampleEntry
00050 +---------------------------------------------------------------------*/
00051 class AP4_SampleEntry : public AP4_ContainerAtom
00052 {
00053  public: 
00054     // methods
00055     AP4_SampleEntry(AP4_Atom::Type format, AP4_UI16 data_ref_index = 1);
00056     AP4_SampleEntry(AP4_Atom::Type   format, 
00057                     AP4_Size         size,
00058                     AP4_ByteStream&  stream,
00059                     AP4_AtomFactory& atom_factory);
00060     AP4_UI16           GetDataReferenceIndex() { return m_DataReferenceIndex; }
00061     virtual AP4_Result Write(AP4_ByteStream& stream);
00062     virtual AP4_Result Inspect(AP4_AtomInspector& inspector);
00063     virtual AP4_SampleDescription* ToSampleDescription();
00064 
00065     // AP4_AtomParent methods
00066     virtual void OnChildChanged(AP4_Atom* child);
00067 
00068  protected:
00069     // constructor
00070     AP4_SampleEntry(AP4_Atom::Type format, AP4_Size size);
00071 
00072     // methods
00073     virtual AP4_Size   GetFieldsSize();
00074     virtual AP4_Result ReadFields(AP4_ByteStream& stream);
00075     virtual AP4_Result WriteFields(AP4_ByteStream& stream);
00076     virtual AP4_Result InspectFields(AP4_AtomInspector& inspector);
00077 
00078     // members
00079     AP4_UI08 m_Reserved1[6];         // = 0
00080     AP4_UI16 m_DataReferenceIndex;
00081 };
00082 
00083 /*----------------------------------------------------------------------
00084 |       AP4_MpegSampleEntry
00085 +---------------------------------------------------------------------*/
00086 class AP4_MpegSampleEntry : public AP4_SampleEntry
00087 {
00088 protected:
00089     // constructor
00090     AP4_MpegSampleEntry(AP4_Atom::Type format);
00091     AP4_MpegSampleEntry(AP4_Atom::Type format, AP4_Size size);
00092     AP4_MpegSampleEntry(AP4_Atom::Type    format, 
00093                         AP4_EsDescriptor* descriptor);
00094     AP4_MpegSampleEntry(AP4_Atom::Type   format,
00095                         AP4_Size         size,
00096                         AP4_ByteStream&  stream,
00097                         AP4_AtomFactory& atom_factory);
00098 
00099     // methods
00100     const AP4_DecoderConfigDescriptor* GetDecoderConfigDescriptor();
00101 };
00102 
00103 /*----------------------------------------------------------------------
00104 |       AP4_Mp4sSampleEntry
00105 +---------------------------------------------------------------------*/
00106 class AP4_Mp4sSampleEntry : public AP4_MpegSampleEntry
00107 {
00108  public:
00109     // constructors
00110     AP4_Mp4sSampleEntry(AP4_Size         size,
00111                         AP4_ByteStream&  stream,
00112                         AP4_AtomFactory& atom_factory);
00113     AP4_Mp4sSampleEntry(AP4_EsDescriptor* descriptor);
00114 
00115     // methods
00116     AP4_SampleDescription* ToSampleDescription();
00117 };
00118 
00119 /*----------------------------------------------------------------------
00120 |       AP4_AudioSampleEntry
00121 +---------------------------------------------------------------------*/
00122 class AP4_AudioSampleEntry : public AP4_MpegSampleEntry
00123 {
00124  public:
00125     // methods
00126     AP4_AudioSampleEntry(AP4_Atom::Type    format,
00127                          AP4_EsDescriptor* descriptor,
00128                          AP4_UI32          sample_rate,
00129                          AP4_UI16          sample_size,
00130                          AP4_UI16          channel_count);
00131     AP4_AudioSampleEntry(AP4_Atom::Type    format,
00132                          AP4_Size          size,
00133                          AP4_ByteStream&   stream,
00134                          AP4_AtomFactory&  atom_factory);
00135     
00136     // accessors
00137     AP4_UI32 GetSampleRate()   { return m_SampleRate>>16; }
00138     AP4_UI16 GetSampleSize()   { return m_SampleSize;     }
00139     AP4_UI16 GetChannelCount() { return m_ChannelCount;   }
00140 
00141     // methods
00142     AP4_SampleDescription* ToSampleDescription();
00143 
00144 protected:
00145     // methods
00146     virtual AP4_Size   GetFieldsSize();
00147     virtual AP4_Result ReadFields(AP4_ByteStream& stream);
00148     virtual AP4_Result WriteFields(AP4_ByteStream& stream);
00149     virtual AP4_Result InspectFields(AP4_AtomInspector& inspector);
00150 
00151     // members
00152     AP4_UI08 m_Reserved2[8]; // = 0
00153     AP4_UI32 m_SampleRate;           
00154     AP4_UI16 m_ChannelCount; // = 2
00155     AP4_UI16 m_SampleSize;   // = 16
00156     AP4_UI16 m_Predefined1;  // = 0
00157     AP4_UI16 m_Reserved3;    // = 0
00158 };
00159 
00160 /*----------------------------------------------------------------------
00161 |       AP4_Mp4aSampleEntry
00162 +---------------------------------------------------------------------*/
00163 class AP4_Mp4aSampleEntry : public AP4_AudioSampleEntry
00164 {
00165  public:
00166     // constructors
00167     AP4_Mp4aSampleEntry(AP4_Size         size,
00168                         AP4_ByteStream&  stream,
00169                         AP4_AtomFactory& atom_factory);
00170     AP4_Mp4aSampleEntry(AP4_UI32          sample_rate, 
00171                         AP4_UI16          sample_size,
00172                         AP4_UI16          channel_count,
00173                         AP4_EsDescriptor* descriptor);
00174 };
00175 
00176 /*----------------------------------------------------------------------
00177 |       AP4_VisualSampleEntry
00178 +---------------------------------------------------------------------*/
00179 class AP4_VisualSampleEntry : public AP4_MpegSampleEntry
00180 {
00181  public:
00182     // methods
00183     AP4_VisualSampleEntry(AP4_Atom::Type    format, 
00184                           AP4_EsDescriptor* descriptor,
00185                           AP4_UI16          width,
00186                           AP4_UI16          height,
00187                           AP4_UI16          depth,
00188                           const char*       compressor_name);
00189     AP4_VisualSampleEntry(AP4_Atom::Type   format,
00190                           AP4_Size         size,
00191                           AP4_ByteStream&  stream,
00192                           AP4_AtomFactory& atom_factory);
00193 
00194     // accessors
00195     AP4_UI16    GetWidth()          { return m_Width;  }
00196     AP4_UI16    GetHeight()         { return m_Height; }
00197     AP4_UI16    GetHorizResolution(){ return m_HorizResolution;  }
00198     AP4_UI16    GetVertResolution() { return m_VertResolution; }
00199     AP4_UI16    GetDepth()          { return m_Depth;  }
00200     const char* GetCompressorName() { return m_CompressorName.c_str(); }
00201 
00202     // methods
00203     AP4_SampleDescription* ToSampleDescription();
00204 
00205 protected:
00206     // methods
00207     virtual AP4_Size   GetFieldsSize();
00208     virtual AP4_Result ReadFields(AP4_ByteStream& stream);
00209     virtual AP4_Result WriteFields(AP4_ByteStream& stream);
00210     virtual AP4_Result InspectFields(AP4_AtomInspector& inspector);
00211 
00212     //members
00213     AP4_UI16   m_Predefined1;     // = 0
00214         AP4_UI16   m_Reserved2;       // = 0
00215         AP4_UI08   m_Predefined2[12]; // = 0
00216         AP4_UI16   m_Width;
00217         AP4_UI16   m_Height;
00218         AP4_UI32   m_HorizResolution; // = 0x00480000 (72 dpi)
00219         AP4_UI32   m_VertResolution;  // = 0x00480000 (72 dpi)
00220         AP4_UI32   m_Reserved3;       // = 0
00221         AP4_UI16   m_FrameCount;      // = 1
00222         AP4_String m_CompressorName;       
00223         AP4_UI16   m_Depth;           // = 0x0018
00224         AP4_UI16   m_Predefined3;     // = 0xFFFF
00225 };
00226 
00227 /*----------------------------------------------------------------------
00228 |       AP4_Mp4vSampleEntry
00229 +---------------------------------------------------------------------*/
00230 class AP4_Mp4vSampleEntry : public AP4_VisualSampleEntry
00231 {
00232  public:
00233     // constructors
00234     AP4_Mp4vSampleEntry(AP4_Size         size,
00235                         AP4_ByteStream&  stream,
00236                         AP4_AtomFactory& atom_factory);
00237     AP4_Mp4vSampleEntry(AP4_UI16          width,
00238                         AP4_UI16          height,
00239                         AP4_UI16          depth,
00240                         const char*       compressor_name,
00241                         AP4_EsDescriptor* descriptor);
00242 };
00243 
00244 /*----------------------------------------------------------------------
00245 |       AP4_Avc1SampleEntry
00246 +---------------------------------------------------------------------*/
00247 class AP4_Avc1SampleEntry : public AP4_VisualSampleEntry
00248 {
00249 public:
00250     // constructors
00251     AP4_Avc1SampleEntry(AP4_Size         size,
00252                         AP4_ByteStream&  stream,
00253                         AP4_AtomFactory& atom_factory);
00254     AP4_Avc1SampleEntry(AP4_UI16          width,
00255                         AP4_UI16          height,
00256                         AP4_UI16          depth,
00257                         const char*       compressor_name,
00258                         AP4_EsDescriptor* descriptor);
00259 };
00260 
00261 /*----------------------------------------------------------------------
00262 |       AP4_RtpHintSampleEntry
00263 +---------------------------------------------------------------------*/
00264 class AP4_RtpHintSampleEntry : public AP4_SampleEntry
00265 {
00266 public:
00267     // methods
00268     AP4_RtpHintSampleEntry(AP4_UI16 hint_track_version,
00269                            AP4_UI16 highest_compatible_version,
00270                            AP4_UI32 max_packet_size,
00271                            AP4_UI32 timescale);
00272     AP4_RtpHintSampleEntry(AP4_Size         size,
00273                            AP4_ByteStream&  stream,
00274                            AP4_AtomFactory& atom_factory);
00275     virtual ~AP4_RtpHintSampleEntry();
00276     
00277 protected:
00278     // methods
00279     virtual AP4_Size   GetFieldsSize();
00280     virtual AP4_Result ReadFields(AP4_ByteStream& stream);
00281     virtual AP4_Result WriteFields(AP4_ByteStream& stream);
00282     virtual AP4_Result InspectFields(AP4_AtomInspector& inspector);
00283 
00284     // members
00285     AP4_UI16 m_HintTrackVersion;
00286     AP4_UI16 m_HighestCompatibleVersion;
00287     AP4_UI32 m_MaxPacketSize;
00288 };
00289 
00290 /*----------------------------------------------------------------------
00291 |       AP4_TextSampleEntry
00292 +---------------------------------------------------------------------*/
00293 class AP4_TextSampleEntry : public AP4_SampleEntry
00294 {
00295 public:
00296     // methods
00297     AP4_TextSampleEntry(AP4_Size         size,
00298                            AP4_ByteStream&  stream,
00299                            AP4_AtomFactory& atom_factory);
00300     virtual ~AP4_TextSampleEntry();
00301     
00302         struct AP4_TextDescription
00303         {
00304                 AP4_UI32 DisplayFlags;
00305                 AP4_UI32 TextJustification;
00306                 AP4_UI32 BackgroundColor;
00307                 struct {AP4_UI16 Top, Left, Bottom, Right;} TextBox;
00308                 struct {AP4_UI16 StartChar, EndChar, Ascent; struct {AP4_UI16 Id; AP4_UI08 Face, Size; AP4_UI32 Color;} Font;} Style;
00309                 AP4_String DefaultFontName;
00310         };
00311 
00312         const AP4_TextDescription& GetDescription() const { return m_Description; };
00313 
00314 protected:
00315     // methods
00316     virtual AP4_Result ReadFields(AP4_ByteStream& stream);
00317     virtual AP4_Result WriteFields(AP4_ByteStream& stream);
00318     virtual AP4_Result InspectFields(AP4_AtomInspector& inspector);
00319 
00320     // members
00321         AP4_TextDescription m_Description;
00322 };
00323 
00324 /*----------------------------------------------------------------------
00325 |       AP4_Tx3gSampleEntry
00326 +---------------------------------------------------------------------*/
00327 class AP4_Tx3gSampleEntry : public AP4_SampleEntry
00328 {
00329 public:
00330     // methods
00331     AP4_Tx3gSampleEntry(AP4_Size         size,
00332                            AP4_ByteStream&  stream,
00333                            AP4_AtomFactory& atom_factory);
00334     virtual ~AP4_Tx3gSampleEntry();
00335     
00336         struct AP4_Tx3gDescription
00337         {
00338             AP4_UI32 DisplayFlags;
00339                 AP4_UI08 HorizontalJustification;
00340                 AP4_UI08 VerticalJustification;
00341                 AP4_UI32 BackgroundColor;
00342                 struct {AP4_UI16 Top, Left, Bottom, Right;} TextBox;
00343                 struct {AP4_UI16 StartChar, EndChar; struct {AP4_UI16 Id; AP4_UI08 Face, Size; AP4_UI32 Color;} Font;} Style;
00344         };
00345 
00346         const AP4_Tx3gDescription& GetDescription() const { return m_Description; };
00347 
00348         AP4_Result GetFontNameById(AP4_Ordinal Id, AP4_String& Name);
00349 
00350 protected:
00351     // methods
00352     virtual AP4_Size   GetFieldsSize();
00353     virtual AP4_Result ReadFields(AP4_ByteStream& stream);
00354     virtual AP4_Result WriteFields(AP4_ByteStream& stream);
00355     virtual AP4_Result InspectFields(AP4_AtomInspector& inspector);
00356 
00357     // members
00358         AP4_Tx3gDescription m_Description;
00359 };
00360 
00361 #endif // _AP4_SAMPLE_ENTRY_H_

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