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 that passes through (unchanged) chunks that contain an integral number
19// of MPEG-2 Transport Stream packets, but returning (in "fDurationInMicroseconds")
20// an updated estimate of the time gap between chunks.
21// C++ header
22
23#ifndef _MPEG2_TRANSPORT_STREAM_FRAMER_HH
24#define _MPEG2_TRANSPORT_STREAM_FRAMER_HH
25
26#ifndef _FRAMED_FILTER_HH
27#include "FramedFilter.hh"
28#endif
29
30#ifndef _HASH_TABLE_HH
31#include "HashTable.hh"
32#endif
33
34class MPEG2TransportStreamFramer: public FramedFilter {
35public:
36 static MPEG2TransportStreamFramer*
37 createNew(UsageEnvironment& env, FramedSource* inputSource);
38
39 u_int64_t tsPacketCount() const { return fTSPacketCount; }
40
41 void changeInputSource(FramedSource* newInputSource) { fInputSource = newInputSource; }
42
43 void clearPIDStatusTable();
44 void setNumTSPacketsToStream(unsigned long numTSRecordsToStream);
45 void setPCRLimit(float pcrLimit);
46
47protected:
48 MPEG2TransportStreamFramer(UsageEnvironment& env, FramedSource* inputSource);
49 // called only by createNew()
50 virtual ~MPEG2TransportStreamFramer();
51
52private:
53 // Redefined virtual functions:
54 virtual void doGetNextFrame();
55 virtual void doStopGettingFrames();
56
57private:
58 static void afterGettingFrame(void* clientData, unsigned frameSize,
59 unsigned numTruncatedBytes,
60 struct timeval presentationTime,
61 unsigned durationInMicroseconds);
62 void afterGettingFrame1(unsigned frameSize,
63 struct timeval presentationTime);
64
65 Boolean updateTSPacketDurationEstimate(unsigned char* pkt, double timeNow);
66
67private:
68 u_int64_t fTSPacketCount;
69 double fTSPacketDurationEstimate;
70 HashTable* fPIDStatusTable;
71 u_int64_t fTSPCRCount;
72 Boolean fLimitNumTSPacketsToStream;
73 unsigned long fNumTSPacketsToStream; // used iff "fLimitNumTSPacketsToStream" is True
74 Boolean fLimitTSPacketsToStreamByPCR;
75 float fPCRLimit; // used iff "fLimitTSPacketsToStreamByPCR" is True
76};
77
78#endif
79