From 1ad1beeef8b3ebbeba4d01b553539f33b1e1bd9f Mon Sep 17 00:00:00 2001 From: Mark Calderbank Date: Sat, 25 Nov 2006 00:42:04 +0000 Subject: [PATCH] Demuxer: Audio packet counting for radio navigation --- demuxer.h | 2 ++ demuxervdr.cc | 20 ++++++++++++++++++++ demuxervdr.h | 6 ++++-- 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/demuxer.h b/demuxer.h index eb5881c..ffbbf77 100644 --- a/demuxer.h +++ b/demuxer.h @@ -83,7 +83,9 @@ protected: virtual int findPTS(UCHAR* buf, int len, ULLONG* dest) = 0; virtual int put(UCHAR* buf, int len) = 0; virtual void setFrameNum(ULONG frame) {} + virtual void setPacketNum(ULONG packet) {} virtual ULONG getFrameNumFromPTS(ULLONG pts) {return 0;} + virtual ULONG getPacketNum() {return 0;} bool* getmpAudioChannels(); //Maybe virtual ? int getselAudioChannel(); diff --git a/demuxervdr.cc b/demuxervdr.cc index f37ab6b..44e87a7 100644 --- a/demuxervdr.cc +++ b/demuxervdr.cc @@ -52,11 +52,13 @@ static ULLONG PTSDifference(ULLONG pts1, ULLONG pts2) DemuxerVDR::DemuxerVDR() { frameCounting = false; + packetCounting = false; } void DemuxerVDR::reset() { frameCounting = false; + packetCounting = false; pts_map.clear(); Demuxer::reset(); } @@ -141,6 +143,13 @@ void DemuxerVDR::setFrameNum(ULONG frame) Log::getInstance()->log("Demuxer", Log::DEBUG, "setFrameNum %d", frame); } +void DemuxerVDR::setPacketNum(ULONG npacket) +{ + packetCounting = true; + packetNumber = npacket; + Log::getInstance()->log("Demuxer", Log::DEBUG, "setPacketNum %d", npacket); +} + int DemuxerVDR::put(UCHAR* buf, int len) { int ret = 0; // return number of bytes consumed @@ -237,6 +246,11 @@ int DemuxerVDR::put(UCHAR* buf, int len) return ret; } +ULONG DemuxerVDR::getPacketNum() +{ + return packetNumber; +} + ULONG DemuxerVDR::getFrameNumFromPTS(ULLONG pts) { ULLONG difference = (1LL<<33); @@ -288,6 +302,12 @@ void DemuxerVDR::PESPacketVDR::parseDetails() DemuxerVDR* dx = (DemuxerVDR*)(DemuxerVDR::getInstance()); PESPacket::parseDetails(); + if (dx->packetCounting && + packetType >= PESTYPE_AUD0 && packetType <= PESTYPE_AUDMAX) + { + dx->packetNumber++; + } + if (dx->frameCounting && findPictureHeader() && packetType >= PESTYPE_VID0 && packetType <= PESTYPE_VIDMAX) { diff --git a/demuxervdr.h b/demuxervdr.h index 7c7a36e..cdfa914 100644 --- a/demuxervdr.h +++ b/demuxervdr.h @@ -42,7 +42,9 @@ class DemuxerVDR : public Demuxer int findPTS(UCHAR* buf, int len, ULLONG* dest); int put(UCHAR* buf, int len); void setFrameNum(ULONG frame); + void setPacketNum(ULONG npacket); ULONG getFrameNumFromPTS(ULLONG pts); + ULONG getPacketNum(); private: int state; @@ -50,8 +52,8 @@ class DemuxerVDR : public Demuxer int packetLength; PESPacketVDR packet; - ULONG frameNumber; - bool frameCounting; + ULONG frameNumber, packetNumber; + bool frameCounting, packetCounting; typedef struct { ULLONG pts; ULONG frame; } PTSMapEntry; typedef std::deque PTSMap; PTSMap pts_map; -- 2.39.5