liveMedia/include/MPEG2TransportStreamTrickModeFilter.hh

Go to the documentation of this file.
00001 /**********
00002 This library is free software; you can redistribute it and/or modify it under
00003 the terms of the GNU Lesser General Public License as published by the
00004 Free Software Foundation; either version 2.1 of the License, or (at your
00005 option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
00006 
00007 This library is distributed in the hope that it will be useful, but WITHOUT
00008 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00009 FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for
00010 more details.
00011 
00012 You should have received a copy of the GNU Lesser General Public License
00013 along with this library; if not, write to the Free Software Foundation, Inc.,
00014 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
00015 **********/
00016 // "liveMedia"
00017 // Copyright (c) 1996-2013 Live Networks, Inc.  All rights reserved.// A filter that converts a MPEG Transport Stream file - with corresponding index file
00018 // - to a corresponding Video Elementary Stream.  It also uses a "scale" parameter
00019 // to implement 'trick mode' (fast forward or reverse play, using I-frames) on
00020 // the video stream.
00021 // C++ header
00022 
00023 #ifndef _MPEG2_TRANSPORT_STREAM_TRICK_MODE_FILTER_HH
00024 #define _MPEG2_TRANSPORT_STREAM_TRICK_MODE_FILTER_HH
00025 
00026 #ifndef _FRAMED_FILTER_HH
00027 #include "FramedFilter.hh"
00028 #endif
00029 
00030 #ifndef _MPEG2_TRANSPORT_STREAM_INDEX_FILE_HH
00031 #include "MPEG2TransportStreamIndexFile.hh"
00032 #endif
00033 
00034 #ifndef TRANSPORT_PACKET_SIZE
00035 #define TRANSPORT_PACKET_SIZE 188
00036 #endif
00037 
00038 class MPEG2TransportStreamTrickModeFilter: public FramedFilter {
00039 public:
00040   static MPEG2TransportStreamTrickModeFilter*
00041   createNew(UsageEnvironment& env, FramedSource* inputSource,
00042             MPEG2TransportStreamIndexFile* indexFile, int scale);
00043 
00044   Boolean seekTo(unsigned long tsPacketNumber, unsigned long indexRecordNumber);
00045 
00046   unsigned long nextIndexRecordNum() const { return fNextIndexRecordNum; }
00047 
00048   void forgetInputSource() { fInputSource = NULL; }
00049       // this lets us delete this without also deleting the input Transport Stream
00050 
00051 protected:
00052   MPEG2TransportStreamTrickModeFilter(UsageEnvironment& env, FramedSource* inputSource,
00053                                       MPEG2TransportStreamIndexFile* indexFile, int scale);
00054       // called only by createNew()
00055   virtual ~MPEG2TransportStreamTrickModeFilter();
00056 
00057 private:
00058   // Redefined virtual functions:
00059   virtual void doGetNextFrame();
00060   virtual void doStopGettingFrames();
00061 
00062 private:
00063   void attemptDeliveryToClient();
00064   void seekToTransportPacket(unsigned long tsPacketNum);
00065   void readTransportPacket(unsigned long tsPacketNum); // asynchronously
00066 
00067   static void afterGettingFrame(void* clientData, unsigned frameSize,
00068                                 unsigned numTruncatedBytes,
00069                                 struct timeval presentationTime,
00070                                 unsigned durationInMicroseconds);
00071   void afterGettingFrame1(unsigned frameSize);
00072 
00073   static void onSourceClosure(void* clientData);
00074   void onSourceClosure1();
00075 
00076 private:
00077   Boolean fHaveStarted;
00078   MPEG2TransportStreamIndexFile* fIndexFile;
00079   int fScale; // absolute value
00080   int fDirection; // 1 => forward; -1 => reverse
00081   enum {
00082     SKIPPING_FRAME,
00083     DELIVERING_SAVED_FRAME,
00084     SAVING_AND_DELIVERING_FRAME
00085   } fState;
00086   unsigned fFrameCount;
00087   unsigned long fNextIndexRecordNum; // next to be read from the index file
00088   unsigned long fNextTSPacketNum; // next to be read from the transport stream file
00089   unsigned char fInputBuffer[TRANSPORT_PACKET_SIZE];
00090   unsigned long fCurrentTSPacketNum; // corresponding to data currently in the buffer
00091   unsigned long fDesiredTSPacketNum;
00092   u_int8_t fDesiredDataOffset, fDesiredDataSize;
00093   float fDesiredDataPCR, fFirstPCR;
00094   unsigned long fSavedFrameIndexRecordStart;
00095   unsigned long fSavedSequentialIndexRecordNum;
00096   Boolean fUseSavedFrameNextTime;
00097 };
00098 
00099 #endif

Generated on Mon Apr 29 13:28:01 2013 for live by  doxygen 1.5.2