Go to the documentation of this file.
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 <>.)
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.
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
16// "liveMedia"
17// Copyright (c) 1996-2024 Live Networks, Inc. All rights reserved.
18// 'Ogg' File Sink (recording a single media track only)
19// C++ header
21#ifndef _OGG_FILE_SINK_HH
22#define _OGG_FILE_SINK_HH
24#ifndef _FILE_SINK_HH
25#include "FileSink.hh"
28class OggFileSink: public FileSink {
30 static OggFileSink* createNew(UsageEnvironment& env, char const* fileName,
31 unsigned samplingFrequency = 0, // used for granule_position
32 char const* configStr = NULL,
33 // "configStr" is an optional 'SDP format' string (Base64-encoded)
34 // representing 'packed configuration headers' ("identification", "comment", "setup")
35 // to prepend to the output. (For 'Vorbis" audio and 'Theora' video.)
36 unsigned bufferSize = 100000,
37 Boolean oneFilePerFrame = False);
38 // See "FileSink.hh" for a description of these parameters.
41 OggFileSink(UsageEnvironment& env, FILE* fid, unsigned samplingFrequency, char const* configStr,
42 unsigned bufferSize, char const* perFrameFileNamePrefix);
43 // called only by createNew()
44 virtual ~OggFileSink();
46protected: // redefined virtual functions:
48 virtual void addData(unsigned char const* data, unsigned dataSize,
49 struct timeval presentationTime);
50 virtual void afterGettingFrame(unsigned frameSize, unsigned numTruncatedBytes,
51 struct timeval presentationTime);
54 static void ourOnSourceClosure(void* clientData);
59 char const* fConfigStr;
61 struct timeval fFirstPresentationTime;
63 int64_t fGranulePositionAdjustment; // used to ensure that "fGranulePosition" stays monotonic
65 u_int8_t fPageHeaderBytes[27];
66 // the header of each Ogg page, through the "number_page_segments" byte
68 // Special fields used for Theora video:
70 u_int64_t fGranuleIncrementPerFrame; // == 1 << KFGSHIFT
72 // Because the last Ogg page before EOF needs to have a special 'eos' bit set in the header,
73 // we need to defer the writing of each incoming frame. To do this, we maintain a 2nd buffer:
74 unsigned char* fAltBuffer;
76 struct timeval fAltPresentationTime;
const Boolean False
Definition: Boolean.hh:28
unsigned char Boolean
Definition: Boolean.hh:25
#define NULL
Boolean fHaveSeenEOF
Definition: OggFileSink.hh:60
int64_t fGranulePosition
Definition: OggFileSink.hh:62
struct timeval fFirstPresentationTime
Definition: OggFileSink.hh:61
unsigned char * fAltBuffer
Definition: OggFileSink.hh:74
u_int32_t fPageSequenceNumber
Definition: OggFileSink.hh:64
virtual ~OggFileSink()
unsigned fAltFrameSize
Definition: OggFileSink.hh:75
static void ourOnSourceClosure(void *clientData)
struct timeval fAltPresentationTime
Definition: OggFileSink.hh:76
Boolean fHaveWrittenFirstFrame
Definition: OggFileSink.hh:60
Boolean fIsTheora
Definition: OggFileSink.hh:69
void ourOnSourceClosure()
virtual void afterGettingFrame(unsigned frameSize, unsigned numTruncatedBytes, struct timeval presentationTime)
int64_t fGranulePositionAdjustment
Definition: OggFileSink.hh:63
OggFileSink(UsageEnvironment &env, FILE *fid, unsigned samplingFrequency, char const *configStr, unsigned bufferSize, char const *perFrameFileNamePrefix)
virtual void addData(unsigned char const *data, unsigned dataSize, struct timeval presentationTime)
unsigned fAltNumTruncatedBytes
Definition: OggFileSink.hh:75
char const * fConfigStr
Definition: OggFileSink.hh:59
static OggFileSink * createNew(UsageEnvironment &env, char const *fileName, unsigned samplingFrequency=0, char const *configStr=NULL, unsigned bufferSize=100000, Boolean oneFilePerFrame=False)
u_int64_t fGranuleIncrementPerFrame
Definition: OggFileSink.hh:70
u_int8_t fPageHeaderBytes[27]
Definition: OggFileSink.hh:65
unsigned fSamplingFrequency
Definition: OggFileSink.hh:58
virtual Boolean continuePlaying()