00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
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;
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
00047 virtual ~MPEG2IFrameIndexFromTransportStream();
00048
00049 private:
00050
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;
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
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