live
HLSSegmenter.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 media sink that takes - as input - a MPEG Transport Stream, and outputs a series
19// of MPEG Transport Stream files, each representing a segment of the input stream,
20// suitable for HLS (Apple's "HTTP Live Streaming").
21// C++ header
22
23#ifndef _HLS_SEGMENTER_HH
24#define _HLS_SEGMENTER_HH
25
26#ifndef _MEDIA_SINK_HH
27#include "MediaSink.hh"
28#endif
29
30class HLSSegmenter: public MediaSink {
31public:
32 typedef void (onEndOfSegmentFunc)(void* clientData,
33 char const* segmentFileName, double segmentDuration);
35 unsigned segmentationDuration, char const* fileNamePrefix,
37 void* onEndOfSegmentClientData = NULL);
38
39private:
40 HLSSegmenter(UsageEnvironment& env, unsigned segmentationDuration, char const* fileNamePrefix,
41 onEndOfSegmentFunc* onEndOfSegmentFunc, void* onEndOfSegmentClientData);
42 // called only by createNew()
43 virtual ~HLSSegmenter();
44
45 static void ourEndOfSegmentHandler(void* clientData, double segmentDuration);
46 void ourEndOfSegmentHandler(double segmentDuration);
47
49
50 static void afterGettingFrame(void* clientData, unsigned frameSize,
51 unsigned numTruncatedBytes,
52 struct timeval presentationTime,
53 unsigned durationInMicroseconds);
54 virtual void afterGettingFrame(unsigned frameSize,
55 unsigned numTruncatedBytes);
56
57 static void ourOnSourceClosure(void* clientData);
59
60private: // redefined virtual functions:
63
64private:
66 char const* fFileNamePrefix;
72 FILE* fOutFid;
73 unsigned char* fOutputFileBuffer;
74};
75
76#endif
unsigned char Boolean
Definition: Boolean.hh:25
#define NULL
virtual void afterGettingFrame(unsigned frameSize, unsigned numTruncatedBytes)
unsigned fCurrentSegmentCounter
Definition: HLSSegmenter.hh:70
static void afterGettingFrame(void *clientData, unsigned frameSize, unsigned numTruncatedBytes, struct timeval presentationTime, unsigned durationInMicroseconds)
Boolean fHaveConfiguredUpstreamSource
Definition: HLSSegmenter.hh:69
void * fOnEndOfSegmentClientData
Definition: HLSSegmenter.hh:68
unsigned fSegmentationDuration
Definition: HLSSegmenter.hh:65
void ourEndOfSegmentHandler(double segmentDuration)
static void ourEndOfSegmentHandler(void *clientData, double segmentDuration)
virtual ~HLSSegmenter()
void ourOnSourceClosure()
HLSSegmenter(UsageEnvironment &env, unsigned segmentationDuration, char const *fileNamePrefix, onEndOfSegmentFunc *onEndOfSegmentFunc, void *onEndOfSegmentClientData)
char const * fFileNamePrefix
Definition: HLSSegmenter.hh:66
void() onEndOfSegmentFunc(void *clientData, char const *segmentFileName, double segmentDuration)
Definition: HLSSegmenter.hh:32
Boolean openNextOutputSegment()
char * fOutputSegmentFileName
Definition: HLSSegmenter.hh:71
FILE * fOutFid
Definition: HLSSegmenter.hh:72
onEndOfSegmentFunc * fOnEndOfSegmentFunc
Definition: HLSSegmenter.hh:67
static HLSSegmenter * createNew(UsageEnvironment &env, unsigned segmentationDuration, char const *fileNamePrefix, onEndOfSegmentFunc *onEndOfSegmentFunc=NULL, void *onEndOfSegmentClientData=NULL)
virtual Boolean continuePlaying()
virtual Boolean sourceIsCompatibleWithUs(MediaSource &source)
static void ourOnSourceClosure(void *clientData)
unsigned char * fOutputFileBuffer
Definition: HLSSegmenter.hh:73
FramedSource * source() const
Definition: MediaSink.hh:42