Ap4StscAtom.h
上传用户:xjjlds
上传日期:2015-12-05
资源大小:22823k
文件大小:4k
源码类别:

多媒体编程

开发平台:

Visual C++

  1. /*****************************************************************
  2. |
  3. |    AP4 - stsc Atoms 
  4. |
  5. |    Copyright 2002 Gilles Boccon-Gibod
  6. |
  7. |
  8. |    This file is part of Bento4/AP4 (MP4 Atom Processing Library).
  9. |
  10. |    Unless you have obtained Bento4 under a difference license,
  11. |    this version of Bento4 is Bento4|GPL.
  12. |    Bento4|GPL is free software; you can redistribute it and/or modify
  13. |    it under the terms of the GNU General Public License as published by
  14. |    the Free Software Foundation; either version 2, or (at your option)
  15. |    any later version.
  16. |
  17. |    Bento4|GPL is distributed in the hope that it will be useful,
  18. |    but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. |    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  20. |    GNU General Public License for more details.
  21. |
  22. |    You should have received a copy of the GNU General Public License
  23. |    along with Bento4|GPL; see the file COPYING.  If not, write to the
  24. |    Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
  25. |    02111-1307, USA.
  26. |
  27.  ****************************************************************/
  28. #ifndef _AP4_STSC_ATOM_H_
  29. #define _AP4_STSC_ATOM_H_
  30. /*----------------------------------------------------------------------
  31. |       includes
  32. +---------------------------------------------------------------------*/
  33. #include "Ap4.h"
  34. #include "Ap4ByteStream.h"
  35. #include "Ap4Array.h"
  36. #include "Ap4Atom.h"
  37. /*----------------------------------------------------------------------
  38. |       AP4_StscTableEntry
  39. +---------------------------------------------------------------------*/
  40. class AP4_StscTableEntry {
  41.  public:
  42.     AP4_StscTableEntry() : 
  43.         m_FirstChunk(0), 
  44.         m_FirstSample(0),
  45.         m_ChunkCount(0),
  46.         m_SamplesPerChunk(0), 
  47.         m_SampleDescriptionIndex(0) {}
  48.     AP4_StscTableEntry(AP4_Ordinal  first_chunk,
  49.                        AP4_Ordinal  first_sample,
  50.                        AP4_Cardinal samples_per_chunk,
  51.                        AP4_Ordinal  sample_description_index) :
  52.         m_FirstChunk(first_chunk),
  53.         m_FirstSample(first_sample),
  54.         m_ChunkCount(0),
  55.         m_SamplesPerChunk(samples_per_chunk),
  56.         m_SampleDescriptionIndex(sample_description_index) {}
  57.     AP4_StscTableEntry(AP4_Ordinal  first_chunk,
  58.                        AP4_Ordinal  first_sample,
  59.                        AP4_Cardinal chunk_count,
  60.                        AP4_Cardinal samples_per_chunk,
  61.                        AP4_Ordinal  sample_description_index) :
  62.         m_FirstChunk(first_chunk),
  63.         m_FirstSample(first_sample),
  64.         m_ChunkCount(chunk_count),
  65.         m_SamplesPerChunk(samples_per_chunk),
  66.         m_SampleDescriptionIndex(sample_description_index) {}
  67.     AP4_Ordinal  m_FirstChunk;
  68.     AP4_Ordinal  m_FirstSample;  // computed (not in file)
  69.     AP4_Cardinal m_ChunkCount;   // computed (not in file)
  70.     AP4_Cardinal m_SamplesPerChunk;
  71.     AP4_Ordinal  m_SampleDescriptionIndex;
  72. };
  73. /*----------------------------------------------------------------------
  74. |       AP4_StscAtom
  75. +---------------------------------------------------------------------*/
  76. class AP4_StscAtom : public AP4_Atom
  77. {
  78.  public:
  79.     // methods
  80.     AP4_StscAtom();
  81.     AP4_StscAtom(AP4_Size size, AP4_ByteStream& stream);
  82.     virtual AP4_Result InspectFields(AP4_AtomInspector& inspector);
  83.     virtual AP4_Result GetChunkForSample(AP4_Ordinal   sample,
  84.                                          AP4_Ordinal&  chunk,
  85.                                          AP4_Ordinal&  skip,
  86.                                          AP4_Ordinal&  sample_description);
  87.     virtual AP4_Result AddEntry(AP4_Cardinal chunk_count,
  88.                                 AP4_Cardinal samples_per_chunk,
  89.                                 AP4_Ordinal  sample_description_index);
  90.     virtual AP4_Result WriteFields(AP4_ByteStream& stream);
  91.  private:
  92.     // data
  93.     AP4_Array<AP4_StscTableEntry> m_Entries;
  94.     AP4_Ordinal                   m_CachedChunkGroup;
  95. };
  96. #endif // _AP4_STSC_ATOM_H_