liveMedia/include/ByteStreamFileSource.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-2008 Live Networks, Inc.  All rights reserved.
00018 // A file source that is a plain byte stream (rather than frames)
00019 // C++ header
00020 
00021 #ifndef _BYTE_STREAM_FILE_SOURCE_HH
00022 #define _BYTE_STREAM_FILE_SOURCE_HH
00023 
00024 #ifndef _FRAMED_FILE_SOURCE_HH
00025 #include "FramedFileSource.hh"
00026 #endif
00027 
00028 class ByteStreamFileSource: public FramedFileSource {
00029 public:
00030   static ByteStreamFileSource* createNew(UsageEnvironment& env,
00031                                          char const* fileName,
00032                                          unsigned preferredFrameSize = 0,
00033                                          unsigned playTimePerFrame = 0);
00034   // "preferredFrameSize" == 0 means 'no preference'
00035   // "playTimePerFrame" is in microseconds
00036 
00037   static ByteStreamFileSource* createNew(UsageEnvironment& env,
00038                                          FILE* fid,
00039                                          Boolean deleteFidOnClose = False,
00040                                          unsigned preferredFrameSize = 0,
00041                                          unsigned playTimePerFrame = 0);
00042       // an alternative version of "createNew()" that's used if you already have
00043       // an open file.
00044 
00045   u_int64_t fileSize() const { return fFileSize; }
00046       // 0 means zero-length, unbounded, or unknown
00047 
00048   void seekToByteAbsolute(u_int64_t byteNumber);
00049   void seekToByteRelative(int64_t offset);
00050 
00051 protected:
00052   ByteStreamFileSource(UsageEnvironment& env,
00053                        FILE* fid, Boolean deleteFidOnClose,
00054                        unsigned preferredFrameSize,
00055                        unsigned playTimePerFrame);
00056         // called only by createNew()
00057 
00058   virtual ~ByteStreamFileSource();
00059 
00060   static void fileReadableHandler(ByteStreamFileSource* source, int mask);
00061   void doReadFromFile();
00062 
00063 private:
00064   // redefined virtual functions:
00065   virtual void doGetNextFrame();
00066   virtual void doStopGettingFrames();
00067 
00068 private:
00069   unsigned fPreferredFrameSize;
00070   unsigned fPlayTimePerFrame;
00071   unsigned fLastPlayTime;
00072   u_int64_t fFileSize;
00073   Boolean fDeleteFidOnClose;
00074   Boolean fHaveStartedReading;
00075 };
00076 
00077 #endif

Generated on Fri Dec 19 21:58:18 2008 for live by  doxygen 1.5.2