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

多媒体编程

开发平台:

Visual C++

  1. /*****************************************************************
  2. |
  3. |    AP4 - Atom Factory
  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_ATOM_FACTORY_H_
  29. #define _AP4_ATOM_FACTORY_H_
  30. /*----------------------------------------------------------------------
  31. |       includes
  32. +---------------------------------------------------------------------*/
  33. #include "Ap4Types.h"
  34. #include "Ap4Atom.h"
  35. /*----------------------------------------------------------------------
  36. |       class references
  37. +---------------------------------------------------------------------*/
  38. class AP4_ByteStream;
  39. /*----------------------------------------------------------------------
  40. |       AP4_AtomFactory
  41. +---------------------------------------------------------------------*/
  42. class AP4_AtomFactory {
  43.  public:
  44.     // types
  45.      class TypeHandler {
  46.      public:
  47.          virtual ~TypeHandler() {};
  48.          virtual AP4_Result CreateAtom(AP4_Atom::Type   type,
  49.                                        AP4_Size         size,
  50.                                        AP4_ByteStream&  stream,
  51.                                        AP4_Atom*&       atom) = 0;
  52.     };
  53.     // class members
  54.     static AP4_AtomFactory DefaultFactory;
  55.     // constructor
  56.     AP4_AtomFactory() : m_Context(0) {}
  57.     // methods
  58.     AP4_Result AddTypeHandler(TypeHandler* handler);
  59.     AP4_Result RemoveTypeHandler(TypeHandler* handler);
  60.     AP4_Result CreateAtomFromStream(AP4_ByteStream&  stream,
  61.                                     AP4_Size&        bytes_available,
  62.                                     AP4_Atom*&       atom);
  63.     AP4_Result CreateAtomFromStream(AP4_ByteStream&  stream,
  64.                                     AP4_Atom*&       atom);
  65.     // context
  66.     void SetContext(AP4_Atom::Type context) { m_Context = context; }
  67.     AP4_Atom::Type GetContext() const { return m_Context; }
  68. private:
  69.     // members
  70.     AP4_Atom::Type        m_Context;
  71.     AP4_List<TypeHandler> m_TypeHandlers;
  72. };
  73. #endif // _AP4_ATOM_FACTORY_H_