live
MPEG2TransportStreamTrickModeFilter.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.// A filter that converts a MPEG Transport Stream file - with corresponding index file
18 // - to a corresponding Video Elementary Stream. It also uses a "scale" parameter
19 // to implement 'trick mode' (fast forward or reverse play, using I-frames) on
20 // the video stream.
21 // C++ header
22 
23 #ifndef _MPEG2_TRANSPORT_STREAM_TRICK_MODE_FILTER_HH
24 #define _MPEG2_TRANSPORT_STREAM_TRICK_MODE_FILTER_HH
25 
26 #ifndef _FRAMED_FILTER_HH
27 #include "FramedFilter.hh"
28 #endif
29 
30 #ifndef _MPEG2_TRANSPORT_STREAM_INDEX_FILE_HH
32 #endif
33 
34 #ifndef TRANSPORT_PACKET_SIZE
35 #define TRANSPORT_PACKET_SIZE 188
36 #endif
37 
39 public:
42  MPEG2TransportStreamIndexFile* indexFile, int scale);
43 
44  Boolean seekTo(unsigned long tsPacketNumber, unsigned long indexRecordNumber);
45 
46  unsigned long nextIndexRecordNum() const { return fNextIndexRecordNum; }
47 
49  // this lets us delete this without also deleting the input Transport Stream
50 
51 protected:
53  MPEG2TransportStreamIndexFile* indexFile, int scale);
54  // called only by createNew()
56 
57 private:
58  // Redefined virtual functions:
59  virtual void doGetNextFrame();
60  virtual void doStopGettingFrames();
61 
62 private:
64  void seekToTransportPacket(unsigned long tsPacketNum);
65  void readTransportPacket(unsigned long tsPacketNum); // asynchronously
66 
67  static void afterGettingFrame(void* clientData, unsigned frameSize,
68  unsigned numTruncatedBytes,
69  struct timeval presentationTime,
70  unsigned durationInMicroseconds);
71  void afterGettingFrame1(unsigned frameSize);
72 
73  static void onSourceClosure(void* clientData);
75 
76 private:
79  int fScale; // absolute value
80  int fDirection; // 1 => forward; -1 => reverse
81  enum {
85  } fState;
86  unsigned fFrameCount;
87  unsigned long fNextIndexRecordNum; // next to be read from the index file
88  unsigned long fNextTSPacketNum; // next to be read from the transport stream file
90  unsigned long fCurrentTSPacketNum; // corresponding to data currently in the buffer
91  unsigned long fDesiredTSPacketNum;
97 };
98 
99 #endif
unsigned char Boolean
Definition: Boolean.hh:25
#define NULL
FramedSource * fInputSource
Definition: FramedFilter.hh:49
FramedSource * inputSource() const
Definition: FramedFilter.hh:30
static void afterGettingFrame(void *clientData, unsigned frameSize, unsigned numTruncatedBytes, struct timeval presentationTime, unsigned durationInMicroseconds)
unsigned char fInputBuffer[TRANSPORT_PACKET_SIZE]
static void onSourceClosure(void *clientData)
void seekToTransportPacket(unsigned long tsPacketNum)
void afterGettingFrame1(unsigned frameSize)
MPEG2TransportStreamTrickModeFilter(UsageEnvironment &env, FramedSource *inputSource, MPEG2TransportStreamIndexFile *indexFile, int scale)
enum MPEG2TransportStreamTrickModeFilter::@3 fState
static MPEG2TransportStreamTrickModeFilter * createNew(UsageEnvironment &env, FramedSource *inputSource, MPEG2TransportStreamIndexFile *indexFile, int scale)
void readTransportPacket(unsigned long tsPacketNum)
Boolean seekTo(unsigned long tsPacketNumber, unsigned long indexRecordNumber)