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-2026 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)
unsigned fNumBytesWritten
friend class AVISubsessionIOState
void afterPlayingFunc(void *clientData)
void completeOutputFile()
unsigned addHalfWord(unsigned short halfWord)
class AVIIndexRecord * fIndexRecordsHead
void * fAfterClientData
class AVISubsessionIOState * fCurrentIOState
unsigned fMoviSizePosition
unsigned fAVIHMaxBytesPerSecondPosition
void addIndexRecord(class AVIIndexRecord *newIndexRecord)
unsigned add4ByteString(char const *str)
Boolean fAreCurrentlyBeingPlayed
unsigned fNumIndexRecords
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
unsigned fRIFFSizeValue
unsigned fRIFFSizePosition
unsigned fNumSubsessions
unsigned short fMovieWidth
unsigned numActiveSubsessions() const
unsigned fAVIHFrameCountPosition
MediaSession & fInputSession
Boolean fHaveCompletedOutputFile
unsigned short fMovieHeight
Boolean continuePlaying()
struct timeval fStartTime
unsigned addWord(unsigned word)
Boolean startPlaying(afterPlayingFunc *afterFunc, void *afterClientData)
virtual ~AVIFileSink()
void setWord(unsigned filePosn, unsigned size)
FILE * fOutFid
static void onSourceClosure(void *clientData)
unsigned fMoviSizeValue
unsigned fBufferSize
static void onRTCPBye(void *clientData)
unsigned fJunkNumber
afterPlayingFunc * fAfterFunc
class AVIIndexRecord * fIndexRecordsTail
Boolean fPacketLossCompensate
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)
Medium(UsageEnvironment &env)