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

多媒体编程

开发平台:

Visual C++

  1. /*****************************************************************
  2. |
  3. |    AP4 - hmhd 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. /*----------------------------------------------------------------------
  29. |       includes
  30. +---------------------------------------------------------------------*/
  31. #include "Ap4.h"
  32. #include "Ap4HmhdAtom.h"
  33. #include "Ap4AtomFactory.h"
  34. #include "Ap4Utils.h"
  35. /*----------------------------------------------------------------------
  36. |       AP4_HmhdAtom::AP4_HmhdAtom
  37. +---------------------------------------------------------------------*/
  38. AP4_HmhdAtom::AP4_HmhdAtom(AP4_Size size, AP4_ByteStream& stream) :
  39.     AP4_Atom(AP4_ATOM_TYPE_HMHD, size, true, stream)
  40. {
  41.     stream.ReadUI16(m_MaxPduSize);
  42.     stream.ReadUI16(m_AvgPduSize);
  43.     stream.ReadUI32(m_MaxBitrate);
  44.     stream.ReadUI32(m_AvgBitrate);
  45.     stream.ReadUI32(m_Reserved);
  46. }
  47. /*----------------------------------------------------------------------
  48. |       AP4_HmhdAtom::WriteFields
  49. +---------------------------------------------------------------------*/
  50. AP4_Result
  51. AP4_HmhdAtom::WriteFields(AP4_ByteStream& stream)
  52. {
  53.     AP4_Result result;
  54.     // max pdu size
  55.     result = stream.WriteUI16(m_MaxPduSize);
  56.     if (AP4_FAILED(result)) return result;
  57.     // avg pdu size
  58.     result = stream.WriteUI16(m_AvgPduSize);
  59.     if (AP4_FAILED(result)) return result;
  60.     // max bitrate
  61.     result = stream.WriteUI32(m_MaxBitrate);
  62.     if (AP4_FAILED(result)) return result;
  63.     // avg bitrate
  64.     result = stream.WriteUI32(m_AvgBitrate);
  65.     if (AP4_FAILED(result)) return result;
  66.     // reserved
  67.     result = stream.WriteUI32(m_Reserved);
  68.     if (AP4_FAILED(result)) return result;
  69.     return AP4_SUCCESS;
  70. }
  71. /*----------------------------------------------------------------------
  72. |       AP4_HmhdAtom::InspectFields
  73. +---------------------------------------------------------------------*/
  74. AP4_Result
  75. AP4_HmhdAtom::InspectFields(AP4_AtomInspector& inspector)
  76. {
  77.     inspector.AddField("max_pdu_size", m_MaxPduSize);
  78.     inspector.AddField("avg_pdu_size", m_AvgPduSize);
  79.     inspector.AddField("max_bitrate",  m_MaxBitrate);
  80.     inspector.AddField("avg_bitrate",  m_AvgBitrate);
  81.     return AP4_SUCCESS;
  82. }