live
MPEG2IndexFromTransportStream.hh
Go to the documentation of this file.
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-2021 Live Networks, Inc. All rights reserved.
18 // A filter that produces a sequence of I-frame indices from a MPEG-2 Transport Stream
19 // C++ header
20 
21 #ifndef _MPEG2_IFRAME_INDEX_FROM_TRANSPORT_STREAM_HH
22 #define _MPEG2_IFRAME_INDEX_FROM_TRANSPORT_STREAM_HH
23 
24 #ifndef _FRAMED_FILTER_HH
25 #include "FramedFilter.hh"
26 #endif
27 
28 #ifndef TRANSPORT_PACKET_SIZE
29 #define TRANSPORT_PACKET_SIZE 188
30 #endif
31 
32 #ifndef MAX_PES_PACKET_SIZE
33 #define MAX_PES_PACKET_SIZE 65536
34 #endif
35 
36 class IndexRecord; // forward
37 
39 public:
42 
43 protected:
46  // called only by createNew()
48 
49 private:
50  // Redefined virtual functions:
51  virtual void doGetNextFrame();
52 
53 private:
54  static void afterGettingFrame(void* clientData, unsigned frameSize,
55  unsigned numTruncatedBytes,
56  struct timeval presentationTime,
57  unsigned durationInMicroseconds);
58  void afterGettingFrame1(unsigned frameSize,
59  unsigned numTruncatedBytes,
60  struct timeval presentationTime,
61  unsigned durationInMicroseconds);
62 
63  static void handleInputClosure(void* clientData);
65 
66  void analyzePAT(unsigned char* pkt, unsigned size);
67  void analyzePMT(unsigned char* pkt, unsigned size);
68 
71  Boolean parseToNextCode(unsigned char& nextCode);
73  void addToTail(IndexRecord* newIndexRecord);
74 
75 private:
76  Boolean fIsH264; // True iff the video is H.264 (encapsulated in a Transport Stream)
77  Boolean fIsH265; // True iff the video is H.265 (encapsulated in a Transport Stream)
79  unsigned fClosureNumber;
83  u_int16_t fPMT_PID, fVideo_PID;
84  // Note: We assume: 1 program per Transport Stream; 1 video stream per program
86  unsigned char* fParseBuffer;
87  unsigned fParseBufferSize;
91  IndexRecord* fHeadIndexRecord;
92  IndexRecord* fTailIndexRecord;
93 };
94 
95 #endif
unsigned char Boolean
Definition: Boolean.hh:25
#define TRANSPORT_PACKET_SIZE
FramedSource * inputSource() const
Definition: FramedFilter.hh:30
Boolean parseToNextCode(unsigned char &nextCode)
MPEG2IFrameIndexFromTransportStream(UsageEnvironment &env, FramedSource *inputSource)
static void afterGettingFrame(void *clientData, unsigned frameSize, unsigned numTruncatedBytes, struct timeval presentationTime, unsigned durationInMicroseconds)
void analyzePAT(unsigned char *pkt, unsigned size)
void analyzePMT(unsigned char *pkt, unsigned size)
unsigned char fInputBuffer[TRANSPORT_PACKET_SIZE]
void afterGettingFrame1(unsigned frameSize, unsigned numTruncatedBytes, struct timeval presentationTime, unsigned durationInMicroseconds)
void addToTail(IndexRecord *newIndexRecord)
static void handleInputClosure(void *clientData)
static MPEG2IFrameIndexFromTransportStream * createNew(UsageEnvironment &env, FramedSource *inputSource)