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-2020 Live Networks, Inc. All rights reserved.
18// A filter for converting one or more MPEG Elementary Streams
19// to a MPEG-2 Transport Stream
20// C++ header
21
22#ifndef _MPEG2_TRANSPORT_STREAM_FROM_ES_SOURCE_HH
23#define _MPEG2_TRANSPORT_STREAM_FROM_ES_SOURCE_HH
24
25#ifndef _MPEG2_TRANSPORT_STREAM_MULTIPLEXOR_HH
26#include "MPEG2TransportStreamMultiplexor.hh"
27#endif
28
29class MPEG2TransportStreamFromESSource: public MPEG2TransportStreamMultiplexor {
30public:
31 static MPEG2TransportStreamFromESSource* createNew(UsageEnvironment& env);
32
33 void addNewVideoSource(FramedSource* inputSource, int mpegVersion, int16_t PID = -1);
34 // Note: For MPEG-4 video, set "mpegVersion" to 4; for H.264 video, set "mpegVersion" to 5;
35 // for H.265 video, set "mpegVersion" to 6
36 void addNewAudioSource(FramedSource* inputSource, int mpegVersion, int16_t PID = -1);
37 // Note: For Opus audio, set "mpegVersion" to 3
38
39 // Note: In these functions, if "PID" is not -1, then it (currently, just the low 8 bits)
40 // is used as the stream's PID. Otherwise (if "PID" is -1) the 'stream_id' is used as
41 // the PID.
42
43 static unsigned maxInputESFrameSize;
44
45protected:
46 MPEG2TransportStreamFromESSource(UsageEnvironment& env);
47 // called only by createNew()
48 virtual ~MPEG2TransportStreamFromESSource();
49
50 void addNewInputSource(FramedSource* inputSource,
51 u_int8_t streamId, int mpegVersion, int16_t PID = -1);
52 // used to implement addNew*Source() above
53
54private:
55 // Redefined virtual functions:
56 virtual void doStopGettingFrames();
57 virtual void awaitNewBuffer(unsigned char* oldBuffer);
58
59private:
60 friend class InputESSourceRecord;
61 class InputESSourceRecord* fInputSources;
62 unsigned fVideoSourceCounter, fAudioSourceCounter;
63 Boolean fAwaitingBackgroundDelivery;
64};
65
66#endif
67