liveMedia/include/MPEG2IndexFromTransportStream.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.
00018 // A filter that produces a sequence of I-frame indices from a MPEG-2 Transport Stream
00019 // C++ header
00020 
00021 #ifndef _MPEG2_IFRAME_INDEX_FROM_TRANSPORT_STREAM_HH
00022 #define _MPEG2_IFRAME_INDEX_FROM_TRANSPORT_STREAM_HH
00023 
00024 #ifndef _FRAMED_FILTER_HH
00025 #include "FramedFilter.hh"
00026 #endif
00027 
00028 #ifndef TRANSPORT_PACKET_SIZE
00029 #define TRANSPORT_PACKET_SIZE 188
00030 #endif
00031 
00032 #ifndef MAX_PES_PACKET_SIZE
00033 #define MAX_PES_PACKET_SIZE 65536
00034 #endif
00035 
00036 class IndexRecord; // forward
00037 
00038 class MPEG2IFrameIndexFromTransportStream: public FramedFilter {
00039 public:
00040   static MPEG2IFrameIndexFromTransportStream*
00041   createNew(UsageEnvironment& env, FramedSource* inputSource);
00042 
00043 protected:
00044   MPEG2IFrameIndexFromTransportStream(UsageEnvironment& env,
00045                                       FramedSource* inputSource);
00046       // called only by createNew()
00047   virtual ~MPEG2IFrameIndexFromTransportStream();
00048 
00049 private:
00050   // Redefined virtual functions:
00051   virtual void doGetNextFrame();
00052 
00053 private:
00054   static void afterGettingFrame(void* clientData, unsigned frameSize,
00055                                 unsigned numTruncatedBytes,
00056                                 struct timeval presentationTime,
00057                                 unsigned durationInMicroseconds);
00058   void afterGettingFrame1(unsigned frameSize,
00059                           unsigned numTruncatedBytes,
00060                           struct timeval presentationTime,
00061                           unsigned durationInMicroseconds);
00062 
00063   static void handleInputClosure(void* clientData);
00064   void handleInputClosure1();
00065 
00066   void analyzePAT(unsigned char* pkt, unsigned size);
00067   void analyzePMT(unsigned char* pkt, unsigned size);
00068 
00069   Boolean deliverIndexRecord();
00070   Boolean parseFrame();
00071   Boolean parseToNextCode(unsigned char& nextCode);
00072   void compactParseBuffer();
00073   void addToTail(IndexRecord* newIndexRecord);
00074 
00075 private:
00076   Boolean fIsH264; // True iff the video is H.264 (encapsulated in a Transport Stream)
00077   unsigned long fInputTransportPacketCounter;
00078   unsigned fClosureNumber;
00079   u_int8_t fLastContinuityCounter;
00080   float fFirstPCR, fLastPCR;
00081   Boolean fHaveSeenFirstPCR;
00082   u_int16_t fPMT_PID, fVideo_PID;
00083       // Note: We assume: 1 program per Transport Stream; 1 video stream per program
00084   unsigned char fInputBuffer[TRANSPORT_PACKET_SIZE];
00085   unsigned char* fParseBuffer;
00086   unsigned fParseBufferSize;
00087   unsigned fParseBufferFrameStart;
00088   unsigned fParseBufferParseEnd;
00089   unsigned fParseBufferDataEnd;
00090   IndexRecord* fHeadIndexRecord;
00091   IndexRecord* fTailIndexRecord;
00092 };
00093 
00094 #endif

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