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

多媒体编程

开发平台:

Visual C++

  1. /*****************************************************************
  2. |
  3. |    AP4 - DecoderSpecificInfo Descriptors
  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 "Ap4DecoderSpecificInfoDescriptor.h"
  33. #include "Ap4DescriptorFactory.h"
  34. #include "Ap4Utils.h"
  35. /*----------------------------------------------------------------------
  36. |       AP4_DecoderSpecificInfoDescriptor::AP4_DecoderSpecificInfoDescriptor
  37. +---------------------------------------------------------------------*/
  38. AP4_DecoderSpecificInfoDescriptor::AP4_DecoderSpecificInfoDescriptor(
  39.     const AP4_DataBuffer& data) :
  40.     AP4_Descriptor(AP4_DESCRIPTOR_TAG_DECODER_SPECIFIC_INFO, 
  41.                    MinHeaderSize(data.GetDataSize()), 
  42.                    data.GetDataSize()),
  43.     m_Info(data)
  44. {
  45. }
  46. /*----------------------------------------------------------------------
  47. |       AP4_DecoderSpecificInfoDescriptor::AP4_DecoderSpecificInfoDescriptor
  48. +---------------------------------------------------------------------*/
  49. AP4_DecoderSpecificInfoDescriptor::AP4_DecoderSpecificInfoDescriptor(
  50.     AP4_ByteStream& stream, AP4_Size header_size, AP4_Size payload_size) :
  51.     AP4_Descriptor(AP4_DESCRIPTOR_TAG_DECODER_SPECIFIC_INFO, 
  52.                    header_size, payload_size)
  53. {
  54.     m_Info.SetDataSize(payload_size);
  55. stream.Read(m_Info.UseData(), payload_size);
  56. }
  57. /*----------------------------------------------------------------------
  58. |       AP4_DecoderSpecificInfoDescriptor::~AP4_DecoderSpecificInfoDescriptor
  59. +---------------------------------------------------------------------*/
  60. AP4_DecoderSpecificInfoDescriptor::~AP4_DecoderSpecificInfoDescriptor()
  61. {
  62. }
  63. /*----------------------------------------------------------------------
  64. |       AP4_DecoderSpecificInfoDescriptor::WriteFields
  65. +---------------------------------------------------------------------*/
  66. AP4_Result
  67. AP4_DecoderSpecificInfoDescriptor::WriteFields(AP4_ByteStream& stream)
  68. {
  69.     // write the info buffer
  70.     if (m_PayloadSize && m_Info.GetDataSize()) {
  71.         stream.Write(m_Info.GetData(), m_Info.GetDataSize());
  72.     }
  73.     return AP4_SUCCESS;
  74. }
  75. /*----------------------------------------------------------------------
  76. |       AP4_DecoderSpecificInfoDescriptor::Inspect
  77. +---------------------------------------------------------------------*/
  78. AP4_Result
  79. AP4_DecoderSpecificInfoDescriptor::Inspect(AP4_AtomInspector& inspector)
  80. {
  81.     char* info = new char[m_Info.GetDataSize()*3+1];
  82.     for (unsigned int i=0; i<m_Info.GetDataSize(); i++) {
  83. AP4_StringFormat(&info[i*3], 3, "%02x ", m_Info.UseData()[i]);
  84. }
  85.     info[m_Info.GetDataSize()*3] = '';
  86.     inspector.AddField("#[DecoderSpecificInfo]", info);
  87.     delete[] info;
  88.     return AP4_SUCCESS;
  89. }