live
FileSink.hh
Go to the documentation of this file.
1/**********
2This library is free software; you can redistribute it and/or modify it under
3the terms of the GNU Lesser General Public License as published by the
4Free Software Foundation; either version 3 of the License, or (at your
5option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
6
7This library is distributed in the hope that it will be useful, but WITHOUT
8ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
9FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
10more details.
11
12You should have received a copy of the GNU Lesser General Public License
13along with this library; if not, write to the Free Software Foundation, Inc.,
1451 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
15**********/
16// "liveMedia"
17// Copyright (c) 1996-2024 Live Networks, Inc. All rights reserved.
18// File Sinks
19// C++ header
20
21#ifndef _FILE_SINK_HH
22#define _FILE_SINK_HH
23
24#ifndef _MEDIA_SINK_HH
25#include "MediaSink.hh"
26#endif
27
28class FileSink: public MediaSink {
29public:
30 static FileSink* createNew(UsageEnvironment& env, char const* fileName,
31 unsigned bufferSize = 20000,
32 Boolean oneFilePerFrame = False);
33 // "bufferSize" should be at least as large as the largest expected
34 // input frame.
35 // "oneFilePerFrame" - if True - specifies that each input frame will
36 // be written to a separate file (using the presentation time as a
37 // file name suffix). The default behavior ("oneFilePerFrame" == False)
38 // is to output all incoming data into a single file.
39
40 virtual void addData(unsigned char const* data, unsigned dataSize,
41 struct timeval presentationTime);
42 // (Available in case a client wants to add extra data to the output file)
43
44protected:
45 FileSink(UsageEnvironment& env, FILE* fid, unsigned bufferSize,
46 char const* perFrameFileNamePrefix);
47 // called only by createNew()
48 virtual ~FileSink();
49
50protected: // redefined virtual functions:
52
53protected:
54 static void afterGettingFrame(void* clientData, unsigned frameSize,
55 unsigned numTruncatedBytes,
56 struct timeval presentationTime,
57 unsigned durationInMicroseconds);
58 virtual void afterGettingFrame(unsigned frameSize,
59 unsigned numTruncatedBytes,
60 struct timeval presentationTime);
61
62 FILE* fOutFid;
63 unsigned char* fBuffer;
64 unsigned fBufferSize;
65 char* fPerFrameFileNamePrefix; // used if "oneFilePerFrame" is True
66 char* fPerFrameFileNameBuffer; // used if "oneFilePerFrame" is True
67 struct timeval fPrevPresentationTime;
69};
70
71#endif
const Boolean False
Definition: Boolean.hh:28
unsigned char Boolean
Definition: Boolean.hh:25
unsigned fBufferSize
Definition: FileSink.hh:64
virtual void afterGettingFrame(unsigned frameSize, unsigned numTruncatedBytes, struct timeval presentationTime)
virtual ~FileSink()
char * fPerFrameFileNamePrefix
Definition: FileSink.hh:65
unsigned fSamePresentationTimeCounter
Definition: FileSink.hh:68
virtual Boolean continuePlaying()
char * fPerFrameFileNameBuffer
Definition: FileSink.hh:66
FILE * fOutFid
Definition: FileSink.hh:62
static void afterGettingFrame(void *clientData, unsigned frameSize, unsigned numTruncatedBytes, struct timeval presentationTime, unsigned durationInMicroseconds)
struct timeval fPrevPresentationTime
Definition: FileSink.hh:67
FileSink(UsageEnvironment &env, FILE *fid, unsigned bufferSize, char const *perFrameFileNamePrefix)
static FileSink * createNew(UsageEnvironment &env, char const *fileName, unsigned bufferSize=20000, Boolean oneFilePerFrame=False)
unsigned char * fBuffer
Definition: FileSink.hh:63
virtual void addData(unsigned char const *data, unsigned dataSize, struct timeval presentationTime)