live
AVIFileSink.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// A sink that generates an AVI file from a composite media session
19// C++ header
20
21#ifndef _AVI_FILE_SINK_HH
22#define _AVI_FILE_SINK_HH
23
24#ifndef _MEDIA_SESSION_HH
25#include "MediaSession.hh"
26#endif
27
28class AVIFileSink: public Medium {
29public:
31 MediaSession& inputSession,
32 char const* outputFileName,
33 unsigned bufferSize = 20000,
34 unsigned short movieWidth = 240,
35 unsigned short movieHeight = 180,
36 unsigned movieFPS = 15,
37 Boolean packetLossCompensate = False);
38
39 typedef void (afterPlayingFunc)(void* clientData);
41 void* afterClientData);
42
43 unsigned numActiveSubsessions() const { return fNumSubsessions; }
44
45private:
47 char const* outputFileName, unsigned bufferSize,
48 unsigned short movieWidth, unsigned short movieHeight,
49 unsigned movieFPS, Boolean packetLossCompensate);
50 // called only by createNew()
51 virtual ~AVIFileSink();
52
54 static void afterGettingFrame(void* clientData, unsigned frameSize,
55 unsigned numTruncatedBytes,
56 struct timeval presentationTime,
57 unsigned durationInMicroseconds);
58 static void onSourceClosure(void* clientData);
60 static void onRTCPBye(void* clientData);
61 void addIndexRecord(class AVIIndexRecord* newIndexRecord);
63
64private:
67 FILE* fOutFid;
68 class AVIIndexRecord *fIndexRecordsHead, *fIndexRecordsTail;
70 unsigned fBufferSize;
77 struct timeval fStartTime;
79
80private:
82
83 unsigned addWord(unsigned word); // outputs "word" in little-endian order
84 unsigned addHalfWord(unsigned short halfWord);
85 unsigned addByte(unsigned char byte) {
86 putc(byte, fOutFid);
87 return 1;
88 }
89 unsigned addZeroWords(unsigned numWords);
90 unsigned add4ByteString(char const* str);
91 void setWord(unsigned filePosn, unsigned size);
92
93 // Define member functions for outputting various types of file header:
94#define _header(name) unsigned addFileHeader_##name()
95 _header(AVI);
96 _header(hdrl);
97 _header(avih);
98 _header(strl);
99 _header(strh);
100 _header(strf);
101 _header(JUNK);
102// _header(JUNK);
103 _header(movi);
104private:
105 unsigned short fMovieWidth, fMovieHeight;
106 unsigned fMovieFPS;
112 unsigned fJunkNumber;
113};
114
115#endif
const Boolean False
Definition: Boolean.hh:28
unsigned char Boolean
Definition: Boolean.hh:25
unsigned addByte(unsigned char byte)
Definition: AVIFileSink.hh:85
unsigned fNumBytesWritten
Definition: AVIFileSink.hh:76
friend class AVISubsessionIOState
Definition: AVIFileSink.hh:65
void completeOutputFile()
unsigned addHalfWord(unsigned short halfWord)
class AVIIndexRecord * fIndexRecordsHead
Definition: AVIFileSink.hh:68
void * fAfterClientData
Definition: AVIFileSink.hh:74
class AVISubsessionIOState * fCurrentIOState
Definition: AVIFileSink.hh:111
unsigned fMoviSizePosition
Definition: AVIFileSink.hh:110
unsigned fAVIHMaxBytesPerSecondPosition
Definition: AVIFileSink.hh:108
void addIndexRecord(class AVIIndexRecord *newIndexRecord)
unsigned add4ByteString(char const *str)
Boolean fAreCurrentlyBeingPlayed
Definition: AVIFileSink.hh:72
unsigned fNumIndexRecords
Definition: AVIFileSink.hh:69
static AVIFileSink * createNew(UsageEnvironment &env, MediaSession &inputSession, char const *outputFileName, unsigned bufferSize=20000, unsigned short movieWidth=240, unsigned short movieHeight=180, unsigned movieFPS=15, Boolean packetLossCompensate=False)
unsigned fMovieFPS
Definition: AVIFileSink.hh:106
unsigned fRIFFSizeValue
Definition: AVIFileSink.hh:107
unsigned fRIFFSizePosition
Definition: AVIFileSink.hh:107
unsigned fNumSubsessions
Definition: AVIFileSink.hh:75
unsigned short fMovieWidth
Definition: AVIFileSink.hh:105
unsigned numActiveSubsessions() const
Definition: AVIFileSink.hh:43
void() afterPlayingFunc(void *clientData)
Definition: AVIFileSink.hh:39
unsigned fAVIHFrameCountPosition
Definition: AVIFileSink.hh:109
MediaSession & fInputSession
Definition: AVIFileSink.hh:66
Boolean fHaveCompletedOutputFile
Definition: AVIFileSink.hh:78
unsigned short fMovieHeight
Definition: AVIFileSink.hh:105
Boolean continuePlaying()
struct timeval fStartTime
Definition: AVIFileSink.hh:77
unsigned addWord(unsigned word)
Boolean startPlaying(afterPlayingFunc *afterFunc, void *afterClientData)
virtual ~AVIFileSink()
void setWord(unsigned filePosn, unsigned size)
FILE * fOutFid
Definition: AVIFileSink.hh:67
static void onSourceClosure(void *clientData)
unsigned fMoviSizeValue
Definition: AVIFileSink.hh:110
unsigned fBufferSize
Definition: AVIFileSink.hh:70
static void onRTCPBye(void *clientData)
unsigned fJunkNumber
Definition: AVIFileSink.hh:112
afterPlayingFunc * fAfterFunc
Definition: AVIFileSink.hh:73
class AVIIndexRecord * fIndexRecordsTail
Definition: AVIFileSink.hh:68
Boolean fPacketLossCompensate
Definition: AVIFileSink.hh:71
void onSourceClosure1()
unsigned addZeroWords(unsigned numWords)
AVIFileSink(UsageEnvironment &env, MediaSession &inputSession, char const *outputFileName, unsigned bufferSize, unsigned short movieWidth, unsigned short movieHeight, unsigned movieFPS, Boolean packetLossCompensate)
static void afterGettingFrame(void *clientData, unsigned frameSize, unsigned numTruncatedBytes, struct timeval presentationTime, unsigned durationInMicroseconds)
Definition: Media.hh:50