liveMedia/include/FileSink.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-2013 Live Networks, Inc.  All rights reserved.
00018 // File Sinks
00019 // C++ header
00020 
00021 #ifndef _FILE_SINK_HH
00022 #define _FILE_SINK_HH
00023 
00024 #ifndef _MEDIA_SINK_HH
00025 #include "MediaSink.hh"
00026 #endif
00027 
00028 class FileSink: public MediaSink {
00029 public:
00030   static FileSink* createNew(UsageEnvironment& env, char const* fileName,
00031                              unsigned bufferSize = 20000,
00032                              Boolean oneFilePerFrame = False);
00033   // "bufferSize" should be at least as large as the largest expected
00034   //   input frame.
00035   // "oneFilePerFrame" - if True - specifies that each input frame will
00036   //   be written to a separate file (using the presentation time as a
00037   //   file name suffix).  The default behavior ("oneFilePerFrame" == False)
00038   //   is to output all incoming data into a single file.
00039 
00040   void addData(unsigned char const* data, unsigned dataSize,
00041                struct timeval presentationTime);
00042   // (Available in case a client wants to add extra data to the output file)
00043 
00044 protected:
00045   FileSink(UsageEnvironment& env, FILE* fid, unsigned bufferSize,
00046            char const* perFrameFileNamePrefix);
00047       // called only by createNew()
00048   virtual ~FileSink();
00049 
00050 protected: // redefined virtual functions:
00051   virtual Boolean continuePlaying();
00052 
00053 protected:
00054   static void afterGettingFrame(void* clientData, unsigned frameSize,
00055                                 unsigned numTruncatedBytes,
00056                                 struct timeval presentationTime,
00057                                 unsigned durationInMicroseconds);
00058   virtual void afterGettingFrame(unsigned frameSize,
00059                                  unsigned numTruncatedBytes,
00060                                  struct timeval presentationTime);
00061 
00062   FILE* fOutFid;
00063   unsigned char* fBuffer;
00064   unsigned fBufferSize;
00065   char* fPerFrameFileNamePrefix; // used if "oneFilePerFrame" is True
00066   char* fPerFrameFileNameBuffer; // used if "oneFilePerFrame" is True
00067 };
00068 
00069 
00070 #endif

Generated on Mon Apr 29 13:28:01 2013 for live by  doxygen 1.5.2