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 // 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* 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: 00051 static void afterGettingFrame(void* clientData, unsigned frameSize, 00052 unsigned numTruncatedBytes, 00053 struct timeval presentationTime, 00054 unsigned durationInMicroseconds); 00055 virtual void afterGettingFrame1(unsigned frameSize, 00056 struct timeval presentationTime); 00057 00058 FILE* fOutFid; 00059 unsigned char* fBuffer; 00060 unsigned fBufferSize; 00061 char* fPerFrameFileNamePrefix; // used if "oneFilePerFrame" is True 00062 char* fPerFrameFileNameBuffer; // used if "oneFilePerFrame" is True 00063 00064 private: // redefined virtual functions: 00065 virtual Boolean continuePlaying(); 00066 }; 00067 00068 00069 #endif
1.5.2