liveMedia/include/ByteStreamMemoryBufferSource.hh

Go to the documentation of this file.
00001 /**********
00002 This library is free software; you can redistribute it and/or modify it under
00003 the terms of the GNU Lesser General Public License as published by the
00004 Free Software Foundation; either version 2.1 of the License, or (at your
00005 option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
00006 
00007 This library is distributed in the hope that it will be useful, but WITHOUT
00008 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00009 FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for
00010 more details.
00011 
00012 You should have received a copy of the GNU Lesser General Public License
00013 along with this library; if not, write to the Free Software Foundation, Inc.,
00014 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
00015 **********/
00016 // "liveMedia"
00017 // Copyright (c) 1996-2012 Live Networks, Inc.  All rights reserved.
00018 // A class for streaming data from a (static) memory buffer, as if it were a file.
00019 // C++ header
00020 
00021 #ifndef _BYTE_STREAM_MEMORY_BUFFER_SOURCE_HH
00022 #define _BYTE_STREAM_MEMORY_BUFFER_SOURCE_HH
00023 
00024 #ifndef _FRAMED_SOURCE_HH
00025 #include "FramedSource.hh"
00026 #endif
00027 
00028 class ByteStreamMemoryBufferSource: public FramedSource {
00029 public:
00030   static ByteStreamMemoryBufferSource* createNew(UsageEnvironment& env,
00031                                                  u_int8_t* buffer, u_int64_t bufferSize,
00032                                                  Boolean deleteBufferOnClose = True,
00033                                                  unsigned preferredFrameSize = 0,
00034                                                  unsigned playTimePerFrame = 0);
00035       // "preferredFrameSize" == 0 means 'no preference'
00036       // "playTimePerFrame" is in microseconds
00037 
00038   u_int64_t bufferSize() const { return fBufferSize; }
00039 
00040   void seekToByteAbsolute(u_int64_t byteNumber, u_int64_t numBytesToStream = 0);
00041     // if "numBytesToStream" is >0, then we limit the stream to that number of bytes, before treating it as EOF
00042   void seekToByteRelative(int64_t offset);
00043 
00044 protected:
00045   ByteStreamMemoryBufferSource(UsageEnvironment& env,
00046                                u_int8_t* buffer, u_int64_t bufferSize,
00047                                Boolean deleteBufferOnClose,
00048                                unsigned preferredFrameSize,
00049                                unsigned playTimePerFrame);
00050         // called only by createNew()
00051 
00052   virtual ~ByteStreamMemoryBufferSource();
00053 
00054 private:
00055   // redefined virtual functions:
00056   virtual void doGetNextFrame();
00057 
00058 private:
00059   u_int8_t* fBuffer;
00060   u_int64_t fBufferSize;
00061   u_int64_t fCurIndex;
00062   Boolean fDeleteBufferOnClose;
00063   unsigned fPreferredFrameSize;
00064   unsigned fPlayTimePerFrame;
00065   unsigned fLastPlayTime;
00066   Boolean fLimitNumBytesToStream;
00067   u_int64_t fNumBytesToStream; // used iff "fLimitNumBytesToStream" is True
00068 };
00069 
00070 #endif

Generated on Thu May 17 07:11:45 2012 for live by  doxygen 1.5.2