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

多媒体编程

开发平台:

Visual C++

  1. /*****************************************************************
  2. |
  3. |    AP4 - Utilities
  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_UTILS_H_
  29. #define _AP4_UTILS_H_
  30. /*----------------------------------------------------------------------
  31. |       includes
  32. +---------------------------------------------------------------------*/
  33. #include "Ap4.h"
  34. #include "Ap4Config.h"
  35. #include "Ap4Atom.h"
  36. /*----------------------------------------------------------------------
  37. |       MIN & MAX
  38. +---------------------------------------------------------------------*/
  39. #define MIN(a,b) (a<b)?a:b
  40. #define MAX(a,b) (a>b)?a:b
  41. /*----------------------------------------------------------------------
  42. |       byte I/O
  43. +---------------------------------------------------------------------*/
  44. unsigned long long AP4_BytesToUInt64BE(const unsigned char* bytes);
  45. unsigned long AP4_BytesToUInt32BE(const unsigned char* bytes);
  46. unsigned long AP4_BytesToUInt24BE(const unsigned char* bytes);
  47. unsigned short AP4_BytesToUInt16BE(const unsigned char* bytes);
  48. void AP4_BytesFromUInt64BE(unsigned char* bytes, unsigned long long value);
  49. void AP4_BytesFromUInt32BE(unsigned char* bytes, unsigned long value);
  50. void AP4_BytesFromUInt24BE(unsigned char* bytes, unsigned long value);
  51. void AP4_BytesFromUInt16BE(unsigned char* bytes, unsigned short value);
  52. unsigned long AP4_DurationMsFromUnits(unsigned long units, 
  53.   unsigned long units_per_second);
  54. unsigned long AP4_ConvertTime(unsigned long time_value,
  55.                               unsigned long from_time_scale,
  56.                               unsigned long to_time_scale);
  57. /*----------------------------------------------------------------------
  58. |       string utils
  59. +---------------------------------------------------------------------*/
  60. #if defined (AP4_CONFIG_HAVE_STDIO_H)
  61. #include <stdio.h>
  62. #endif
  63. #if defined (AP4_CONFIG_HAVE_SNPRINTF)
  64. #define AP4_StringFormat snprintf
  65. #else
  66. int AP4_StringFormat(char* str, AP4_Size size, const char* format, ...);
  67. #endif
  68. void AP4_FormatFourChars(char* str, AP4_UI32 value);
  69. AP4_Result
  70. AP4_ParseHex(const char* hex, unsigned char* bytes, unsigned int count);
  71. AP4_Result
  72. AP4_SplitArgs(char* arg, char*& arg0, char*& arg1, char*& arg2);
  73. AP4_Result
  74. AP4_SplitArgs(char* arg, char*& arg0, char*& arg1);
  75. /*----------------------------------------------------------------------
  76. |       AP4_PrintInspector
  77. +---------------------------------------------------------------------*/
  78. class AP4_PrintInspector : public AP4_AtomInspector {
  79. public:
  80.     AP4_PrintInspector(AP4_ByteStream& stream);
  81.     ~AP4_PrintInspector();
  82.     // methods
  83.     void StartElement(const char* name, const char* info);
  84.     void EndElement();
  85.     void AddField(const char* name, AP4_UI32 value, FormatHint hint);
  86.     void AddField(const char* name, const char* value, FormatHint hint);
  87. private:
  88.     // members
  89.     AP4_ByteStream* m_Stream;
  90.     AP4_Cardinal    m_Indent;
  91. };
  92. #endif // _AP4_UTILS_H_