1 | /********** |
2 | This library is free software; you can redistribute it and/or modify it under |
3 | the terms of the GNU Lesser General Public License as published by the |
4 | Free Software Foundation; either version 3 of the License, or (at your |
5 | option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.) |
6 | |
7 | This library is distributed in the hope that it will be useful, but WITHOUT |
8 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
9 | FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for |
10 | more details. |
11 | |
12 | You should have received a copy of the GNU Lesser General Public License |
13 | along with this library; if not, write to the Free Software Foundation, Inc., |
14 | 51 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 | |
34 | class MPEG2TransportStreamFramer: public FramedFilter { |
35 | public: |
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 | |
47 | protected: |
48 | MPEG2TransportStreamFramer(UsageEnvironment& env, FramedSource* inputSource); |
49 | // called only by createNew() |
50 | virtual ~MPEG2TransportStreamFramer(); |
51 | |
52 | private: |
53 | // Redefined virtual functions: |
54 | virtual void doGetNextFrame(); |
55 | virtual void doStopGettingFrames(); |
56 | |
57 | private: |
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 | |
67 | private: |
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 | |