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

多媒体编程

开发平台:

Visual C++

  1. /*****************************************************************
  2. |
  3. |    AP4 - FileByteStream 
  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 "Ap4ByteStream.h"
  33. #ifndef _AP4_FILE_BYTE_STREAM_H_
  34. #define _AP4_FILE_BYTE_STREAM_H_
  35. /*----------------------------------------------------------------------
  36. |       AP4_FileByteStream
  37. +---------------------------------------------------------------------*/
  38. class AP4_FileByteStream: public AP4_ByteStream
  39. {
  40. public:
  41.     // types
  42.     typedef enum {
  43.         STREAM_MODE_READ,
  44.         STREAM_MODE_WRITE
  45.     } Mode;
  46.     // methods
  47.     AP4_FileByteStream(const char* name, Mode mode);
  48.     // AP4_ByteStream methods
  49.     AP4_Result Read(void*    buffer, 
  50.                    AP4_Size  bytesToRead, 
  51.                    AP4_Size* bytesRead) {
  52.         return m_Delegate->Read(buffer, bytesToRead, bytesRead);
  53.     }
  54.     AP4_Result Write(const void* buffer, 
  55.                     AP4_Size     bytesToWrite, 
  56.                     AP4_Size*    bytesWritten) {
  57.         return m_Delegate->Write(buffer, bytesToWrite, bytesWritten);
  58.     }
  59.     AP4_Result Seek(AP4_Offset offset)  { return m_Delegate->Seek(offset); }
  60.     AP4_Result Tell(AP4_Offset& offset) { return m_Delegate->Tell(offset); }
  61.     AP4_Result GetSize(AP4_Size& size)  { return m_Delegate->GetSize(size);}
  62.     // AP4_Referenceable methods
  63.     void AddReference() { m_Delegate->AddReference(); }
  64.     void Release()      { m_Delegate->Release();      }
  65. protected:
  66.     // methods
  67.     virtual ~AP4_FileByteStream() {
  68.         delete m_Delegate;
  69.     }
  70.     // members
  71.     AP4_ByteStream* m_Delegate;
  72. };
  73. #endif // _AP4_FILE_BYTE_STREAM_H_