diff options
author | Jochen Dolze <vdr@dolze.de> | 2011-03-25 16:07:51 +0100 |
---|---|---|
committer | Jochen Dolze <vdr@dolze.de> | 2011-03-25 16:07:51 +0100 |
commit | 6adc2d76929fb8549689080c3510d3ff926ef4d2 (patch) | |
tree | 8ac6828cf73998d79662d7814ec43c209b27cbe3 | |
parent | b0c05b03c5ddf44ea4e3d2b9382dcb9e3ed902bc (diff) | |
download | vdr-plugin-markad-6adc2d76929fb8549689080c3510d3ff926ef4d2.tar.gz vdr-plugin-markad-6adc2d76929fb8549689080c3510d3ff926ef4d2.tar.bz2 |
Fixed TS afc error which led to "demux error"
Added more error messages and stream numbers
-rw-r--r-- | command/demux.cpp | 156 | ||||
-rw-r--r-- | command/demux.h | 39 | ||||
-rw-r--r-- | command/markad-standalone.cpp | 28 | ||||
-rw-r--r-- | command/markad-standalone.h | 2 | ||||
-rw-r--r-- | command/po/de_DE.po | 4 | ||||
-rw-r--r-- | command/po/fi_FI.po | 4 | ||||
-rw-r--r-- | plugin/po/de_DE.po | 4 | ||||
-rw-r--r-- | plugin/po/es_ES.po | 4 | ||||
-rw-r--r-- | plugin/po/it_IT.po | 4 | ||||
-rw-r--r-- | version.h | 2 |
10 files changed, 177 insertions, 70 deletions
diff --git a/command/demux.cpp b/command/demux.cpp index 88f3048..1b89895 100644 --- a/command/demux.cpp +++ b/command/demux.cpp @@ -34,16 +34,18 @@ cPaketQueue::cPaketQueue(const char *Name, int Size) memset(&pktinfo,0,sizeof(pktinfo)); percent=-1; mpercent=0; + inptr=outptr=0; + skipped=0; Clear(); } void cPaketQueue::Clear() { + skipped+=(inptr-outptr); inptr=outptr=0; pktinfo.pkthdr=-1; scanner=0xFFFFFFFF; scannerstart=-1; - skipped=0; } cPaketQueue::~cPaketQueue() @@ -451,7 +453,6 @@ uchar *cPaketQueue::GetPacket(int *Size, int Type) *Size=0; if (Length()<4) return NULL; - skipped=0; if (pktinfo.pkthdr==-1) { scanner=0xFFFFFFFF; @@ -480,7 +481,7 @@ uchar *cPaketQueue::GetPacket(int *Size, int Type) { if (pktinfo.pkthdr!=outptr) { - skipped=pktinfo.pkthdr-outptr; + skipped+=(pktinfo.pkthdr-outptr); } } scannerstart=pktinfo.pkthdr+pktinfo.pktsyncsize; @@ -584,21 +585,29 @@ cTS2Pkt::~cTS2Pkt() } } -void cTS2Pkt::Clear() +void cTS2Pkt::Clear(AvPacket *Pkt) { + if (!Pkt) + { + skipped=0; + noticeFILLER=false; + lasterror=ERR_INIT; + } + else + { + Pkt->Length=0; + Pkt->Type=0; + Pkt->Stream=0; + } sync=false; counter=-1; - skipped=0; - noticeFILLER=false; - noticeSEQUENCE=false; - noticeSTREAM=false; - noticeTSERR=false; if (queue) queue->Clear(); } bool cTS2Pkt::Process(uchar *TSData, int TSSize, AvPacket *Pkt) { if (!Pkt) return false; + if (!queue) return false; if (TSData) { if (TSSize!=TS_SIZE) return false; @@ -615,23 +624,30 @@ bool cTS2Pkt::Process(uchar *TSData, int TSSize, AvPacket *Pkt) { if (counter==(int) tshdr->Counter) { + if (lasterror!=ERR_DUPLICATE) + { + lasterror=ERR_DUPLICATE; + esyslog("duplicate packet, skipping (0x%04x)",pid); + } + Pkt->Length=0; + Pkt->Type=0; + Pkt->Stream=0; skipped+=TS_SIZE; - return true; // duplicate paket -> just ignore + return true; // duplicate packet -> just ignore } // sequence error - if (!noticeSEQUENCE) + if (lasterror!=ERR_SEQUENCE) { - noticeSEQUENCE=true; - isyslog("sequence error"); + lasterror=ERR_SEQUENCE; + esyslog("sequence error (0x%04x)",pid); } - if (queue) + Clear(Pkt); + skipped+=queue->Skipped(); + if (!tshdr->PayloadStart) { - skipped+=queue->Length(); - queue->Clear(); + skipped+=TS_SIZE; + return true; } - counter=-1; - sync=false; - if (!tshdr->PayloadStart) return true; } counter=tshdr->Counter; @@ -641,20 +657,33 @@ bool cTS2Pkt::Process(uchar *TSData, int TSSize, AvPacket *Pkt) } if (!sync) { - if (firstsync) skipped+=TS_SIZE; // only count skipped bytes after first sync + Clear(Pkt); + if (firstsync) + { + if (lasterror==ERR_INIT) + { + lasterror=ERR_SYNC; + esyslog("out of sync (0x%04x)",pid); + } + skipped+=TS_SIZE; // only count skipped bytes after first sync + skipped+=queue->Skipped(); + } return true; // not synced } // we just ignore the infos in the adaption field (e.g. OPCR/PCR) if ((tshdr->AFC!=1) && (tshdr->AFC!=3)) { + Pkt->Length=0; + Pkt->Type=0; + Pkt->Stream=0; return true; } - if ((tshdr->TError) && (!noticeTSERR)) + if ((tshdr->TError) && (lasterror!=ERR_HDRBIT)) { - noticeTSERR=true; - isyslog("stream error bit set"); + lasterror=ERR_HDRBIT; + esyslog("stream error bit set (0x%04x)",pid); } int buflen=TS_SIZE+1; @@ -671,7 +700,18 @@ bool cTS2Pkt::Process(uchar *TSData, int TSSize, AvPacket *Pkt) { // adaption field + payload int alen=TSData[4]+1; - if (alen>(TS_SIZE-(int) sizeof(struct TSHDR))) alen=TS_SIZE-(int) sizeof(struct TSHDR); + if (alen>(TS_SIZE-(int) sizeof(struct TSHDR))) + { + if (lasterror!=ERR_AFCLEN) + { + lasterror=ERR_AFCLEN; + esyslog("afc length error (0x%04x)",pid); + } + Clear(Pkt); + skipped+=queue->Skipped(); + skipped+=TS_SIZE; + return true; + } buflen=TS_SIZE-(sizeof(struct TSHDR)+alen); buf=&TSData[sizeof(struct TSHDR)+alen]; } @@ -686,21 +726,15 @@ bool cTS2Pkt::Process(uchar *TSData, int TSSize, AvPacket *Pkt) { if ((buf[0]!=0) && (buf[1]!=0)) { - if (!noticeSTREAM) + if (lasterror!=ERR_PAYLOAD) { - isyslog("stream error"); - noticeSTREAM=true; + lasterror=ERR_PAYLOAD; + esyslog("payload start error (0x%04x)",pid); } + Clear(Pkt); + skipped+=queue->Skipped(); skipped+=TS_SIZE; - sync=false; - if (buflen<7) return false; - // add a pseudo padding stream - buf[0]=0; - buf[1]=0; - buf[2]=1; - buf[3]=0xbe; - buf[4]=0; - buf[5]=buflen-6; + return true; } } queue->Put(buf,buflen); @@ -710,24 +744,28 @@ bool cTS2Pkt::Process(uchar *TSData, int TSSize, AvPacket *Pkt) if (Pkt->Data) { Pkt->Type=h264 ? PACKET_H264 : PACKET_H262; + Pkt->Stream=pid; if ((h264) && ((Pkt->Data[4] & 0x1F)==0x0C)) { if (!noticeFILLER) { - isyslog("H264 video stream with filler nalu"); + isyslog("H264 video stream with filler nalu (0x%04x)",pid); noticeFILLER=true; } skipped+=Pkt->Length; // thats not accurate! Pkt->Data=NULL; Pkt->Length=0; Pkt->Type=0; + Pkt->Stream=0; } } else { Pkt->Length=0; Pkt->Type=0; + Pkt->Stream=0; } + skipped+=queue->Skipped(); return true; } @@ -751,7 +789,9 @@ cPES2ES::~cPES2ES() void cPES2ES::Clear() { + stream=0; skipped=0; + lasterror=0; if (queue) queue->Clear(); } @@ -772,6 +812,11 @@ bool cPES2ES::Process(uchar *PESData, int PESSize, AvPacket *ESPkt) Length+=sizeof(PESHDR); if (Length!=PESSize) { + if (lasterror!=ERR_LENGTH) + { + esyslog("length mismatch (0x%02X)",peshdr->StreamID); + lasterror=ERR_LENGTH; + } skipped+=Length; return true; } @@ -779,7 +824,13 @@ bool cPES2ES::Process(uchar *PESData, int PESSize, AvPacket *ESPkt) if (peshdr->StreamID==0xBE) { + if (lasterror!=ERR_PADDING) + { + esyslog("found padding stream (0x%02X)",peshdr->StreamID); + lasterror=ERR_PADDING; + } queue->Clear(); + skipped+=queue->Skipped(); return true; } @@ -800,7 +851,7 @@ bool cPES2ES::Process(uchar *PESData, int PESSize, AvPacket *ESPkt) default: break; } - + stream=peshdr->StreamID; struct PESHDROPT *peshdropt=(struct PESHDROPT *) &PESData[sizeof(struct PESHDR)]; uchar *buf; @@ -834,11 +885,13 @@ bool cPES2ES::Process(uchar *PESData, int PESSize, AvPacket *ESPkt) if (ESPkt->Data) { ESPkt->Type=ptype; + ESPkt->Stream=stream; } else { ESPkt->Type=0; ESPkt->Length=0; + ESPkt->Stream=0; } skipped+=queue->Skipped(); return true; @@ -917,6 +970,7 @@ void cDemux::Clear() last_bplen=0; from_oldfile=0; stream_or_pid=0; + lasterror=ERR_INIT; } bool cDemux::isvideopes(uchar *data, int count) @@ -969,6 +1023,11 @@ int cDemux::fillqueue(uchar *data, int count, int &stream_or_pid, int &packetsiz } else { + if (lasterror!=ERR_JUNK) + { + esyslog("unusable data, skipping"); + lasterror=ERR_JUNK; + } skipped++; stream_or_pid=0; packetsize=1; @@ -981,6 +1040,11 @@ int cDemux::fillqueue(uchar *data, int count, int &stream_or_pid, int &packetsiz if (ret==-1) return -1; if (ret) { + if (lasterror!=ERR_JUNK) + { + esyslog("unusable data, skipping"); + lasterror=ERR_JUNK; + } skipped++; stream_or_pid=0; packetsize=1; @@ -1002,7 +1066,7 @@ int cDemux::fillqueue(uchar *data, int count, int &stream_or_pid, int &packetsiz } if (!TS) { - // check length of PES-paket + // check length of PES-packet qData=queue->Peek(packetsize+PEEKBUF); if (qData) { @@ -1013,6 +1077,11 @@ int cDemux::fillqueue(uchar *data, int count, int &stream_or_pid, int &packetsiz if (start>0) { // broken PES in queue, skip it + if (lasterror!=ERR_BROKEN) + { + esyslog("broken PES in queue, skipping"); + lasterror=ERR_BROKEN; + } packetsize=start; skipped+=start; stream_or_pid=0; @@ -1045,6 +1114,11 @@ int cDemux::fillqueue(uchar *data, int count, int &stream_or_pid, int &packetsiz if (start>0) { // broken TS in queue, skip it + if (lasterror!=ERR_BROKEN) + { + esyslog("broken TS in queue, skipping"); + lasterror=ERR_BROKEN; + } packetsize=start; skipped+=start; stream_or_pid=0; @@ -1259,7 +1333,7 @@ int cDemux::Process(uchar *Data, int Count, AvPacket *pkt) } else if (stream_or_pid==dpid) { - AvPacket tpkt={NULL,0,0}; + AvPacket tpkt={NULL,0,0,0}; if (!ts2pkt_dpid) ts2pkt_dpid=new cTS2Pkt(dpid,"TS2PES AC3"); if (!ts2pkt_dpid->Process(bpkt,bplen,&tpkt)) return -1; if (!pes2audioes_ac3) pes2audioes_ac3=new cPES2ES(PACKET_AC3,"PES2AC3"); @@ -1267,7 +1341,7 @@ int cDemux::Process(uchar *Data, int Count, AvPacket *pkt) } else if (stream_or_pid==apid) { - AvPacket tpkt={NULL,0,0}; + AvPacket tpkt={NULL,0,0,0}; if (!ts2pkt_apid) ts2pkt_apid=new cTS2Pkt(apid,"TS2PES MP2",16384); if (!ts2pkt_apid->Process(bpkt,bplen,&tpkt)) return -1; if (!pes2audioes_mp2) pes2audioes_mp2=new cPES2ES(PACKET_MP2,"PES2MP2",16384); diff --git a/command/demux.h b/command/demux.h index 4d53a95..72dd453 100644 --- a/command/demux.h +++ b/command/demux.h @@ -27,6 +27,7 @@ typedef struct AvPacket uchar *Data; int Length; int Type; + int Stream; } AvPacket; struct TSHDR @@ -188,7 +189,9 @@ public: void Clear(); int Skipped() { - return skipped; + int temp=skipped; + skipped=0; + return temp; } bool Put(uchar *Data, int Size); uchar *Get(int *Size); @@ -215,6 +218,17 @@ public: class cTS2Pkt { + enum + { + ERR_INIT=0, + ERR_SEQUENCE, + ERR_PAYLOAD, + ERR_HDRBIT, + ERR_AFCLEN, + ERR_DUPLICATE, + ERR_SYNC + }; + private: cPaketQueue *queue; int counter; @@ -222,15 +236,13 @@ private: bool firstsync; int skipped; int pid; + int lasterror; bool h264; bool noticeFILLER; - bool noticeSEQUENCE; - bool noticeSTREAM; - bool noticeTSERR; public: cTS2Pkt(int Pid, const char *QueueName="TS2Pkt", int QueueSize=32768, bool H264=false); ~cTS2Pkt(); - void Clear(); + void Clear(AvPacket *Pkt=NULL); int Skipped() { return skipped; @@ -257,10 +269,19 @@ public: class cPES2ES { + enum + { + ERR_INIT, + ERR_LENGTH, + ERR_PADDING + }; + private: cPaketQueue *queue; int skipped; int ptype; + int stream; + int lasterror; bool h264; public: cPES2ES(int PacketType, const char *QueueName="PES2ES", int QueueSize=32768); @@ -288,10 +309,18 @@ public: class cDemux { + enum + { + ERR_INIT=0, + ERR_JUNK, + ERR_BROKEN + }; + private: int vpid,dpid,apid; int stream_or_pid; int skipped; + int lasterror; bool h264; bool TS; uint64_t offset; diff --git a/command/markad-standalone.cpp b/command/markad-standalone.cpp index f263f04..c2dc261 100644 --- a/command/markad-standalone.cpp +++ b/command/markad-standalone.cpp @@ -942,6 +942,14 @@ bool cMarkAdStandalone::ProcessFile(int Number) { if ((macontext.Video.Info.Height) && (!noticeHEADER)) { + if ((!isTS) && (!noticeVDR_VID)) + { + isyslog("found %s-video (0x%02X)", + macontext.Info.VPid.Type==MARKAD_PIDTYPE_VIDEO_H264 ? "H264": "H262", + pkt.Stream); + noticeVDR_VID=true; + } + isyslog("%s %ix%i%c%0.f",(macontext.Video.Info.Height>576) ? "HDTV" : "SDTV", macontext.Video.Info.Width, macontext.Video.Info.Height, @@ -1009,7 +1017,7 @@ bool cMarkAdStandalone::ProcessFile(int Number) { if ((!isTS) && (!noticeVDR_AC3)) { - isyslog("found AC3"); + isyslog("found AC3 (0x%02X)",pkt.Stream); noticeVDR_AC3=true; } if ((framecnt-iframe)<=3) @@ -1210,7 +1218,7 @@ bool cMarkAdStandalone::SaveInfo() char *line=NULL; char *lline=NULL; - size_t length=0; + size_t len=0; char lang[4]=""; @@ -1235,7 +1243,7 @@ bool cMarkAdStandalone::SaveInfo() } bool err=false; - while (getline(&line,&length,r)!=-1) + while (getline(&line,&len,r)!=-1) { if (line[0]=='X') { @@ -1964,12 +1972,13 @@ cMarkAdStandalone::cMarkAdStandalone(const char *Directory, const MarkAdConfig * memset(&pkt,0,sizeof(pkt)); - noticeVDR_MP2=false; + noticeVDR_VID=false; noticeVDR_AC3=false; noticeHEADER=false; noticeFILLER=false; skipped=0; + length=0; sleepcnt=0; waittime=iwaittime=0; @@ -2111,15 +2120,10 @@ cMarkAdStandalone::cMarkAdStandalone(const char *Directory, const MarkAdConfig * { if (isTS) { - dsyslog("found %s-video (0x%04x)", + isyslog("found %s-video (0x%04x)", macontext.Info.VPid.Type==MARKAD_PIDTYPE_VIDEO_H264 ? "H264": "H262", macontext.Info.VPid.Num); } - else - { - dsyslog("found %s-video", - macontext.Info.VPid.Type==MARKAD_PIDTYPE_VIDEO_H264 ? "H264": "H262"); - } demux=new cDemux(macontext.Info.VPid.Num,macontext.Info.DPid.Num,macontext.Info.APid.Num, macontext.Info.VPid.Type==MARKAD_PIDTYPE_VIDEO_H264,true); } @@ -2131,13 +2135,13 @@ cMarkAdStandalone::cMarkAdStandalone(const char *Directory, const MarkAdConfig * if (macontext.Info.APid.Num) { if (macontext.Info.APid.Num!=-1) - dsyslog("found MP2 (0x%04x)",macontext.Info.APid.Num); + isyslog("found MP2 (0x%04x)",macontext.Info.APid.Num); } if (macontext.Info.DPid.Num) { if (macontext.Info.DPid.Num!=-1) - dsyslog("found AC3 (0x%04x)",macontext.Info.DPid.Num); + isyslog("found AC3 (0x%04x)",macontext.Info.DPid.Num); } if (!abort) diff --git a/command/markad-standalone.h b/command/markad-standalone.h index 77b9bde..b87422e 100644 --- a/command/markad-standalone.h +++ b/command/markad-standalone.h @@ -193,7 +193,7 @@ unsigned Descriptor_Length: struct timeval tv1,tv2; struct timezone tz; - bool noticeVDR_MP2; + bool noticeVDR_VID; bool noticeVDR_AC3; bool noticeHEADER; bool noticeFILLER; diff --git a/command/po/de_DE.po b/command/po/de_DE.po index 715cc09..721fbbf 100644 --- a/command/po/de_DE.po +++ b/command/po/de_DE.po @@ -4,14 +4,14 @@ msgid "" msgstr "" "Project-Id-Version: markad\n" "Report-Msgid-Bugs-To: <see README>\n" -"POT-Creation-Date: 2010-05-27 15:32+0200\n" +"POT-Creation-Date: 2011-03-21 22:31+0100\n" "PO-Revision-Date: 2010-03-31 03:07+0200\n" "Last-Translator: Jochen Dolze <vdr@dolze.de>\n" "Language-Team: German <vdr@linuxtv.org>\n" -"Language: de\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" +"Language: de\n" msgid "starting markad for" msgstr "Starte markad für" diff --git a/command/po/fi_FI.po b/command/po/fi_FI.po index 8480b84..06709cb 100644 --- a/command/po/fi_FI.po +++ b/command/po/fi_FI.po @@ -5,14 +5,14 @@ msgid "" msgstr "" "Project-Id-Version: markad\n" "Report-Msgid-Bugs-To: <see README>\n" -"POT-Creation-Date: 2011-02-27 02:27+0200\n" +"POT-Creation-Date: 2011-03-21 22:31+0100\n" "PO-Revision-Date: 2011-02-27 02:27+0200\n" "Last-Translator: Rolf Ahrenberg\n" "Language-Team: Finnish <vdr@linuxtv.org>\n" -"Language: fi\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" +"Language: fi\n" msgid "starting markad for" msgstr "markad käynnistetty:" diff --git a/plugin/po/de_DE.po b/plugin/po/de_DE.po index bd4cfae..a2bc9eb 100644 --- a/plugin/po/de_DE.po +++ b/plugin/po/de_DE.po @@ -4,14 +4,14 @@ msgid "" msgstr "" "Project-Id-Version: vdr\n" "Report-Msgid-Bugs-To: <see README>\n" -"POT-Creation-Date: 2011-02-27 02:27+0200\n" +"POT-Creation-Date: 2011-03-21 22:32+0100\n" "PO-Revision-Date: 2009-08-27 14:18+0200\n" "Last-Translator: Jochen Dolze <vdr@dolze.de>\n" "Language-Team: German <vdr@linuxtv.org>\n" -"Language: de\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" +"Language: de\n" msgid "markad still running" msgstr "markad läuft noch" diff --git a/plugin/po/es_ES.po b/plugin/po/es_ES.po index 9b919e9..f0c540e 100644 --- a/plugin/po/es_ES.po +++ b/plugin/po/es_ES.po @@ -4,14 +4,14 @@ msgid "" msgstr "" "Project-Id-Version: vdr\n" "Report-Msgid-Bugs-To: <see README>\n" -"POT-Creation-Date: 2011-02-27 02:27+0200\n" +"POT-Creation-Date: 2011-03-21 22:32+0100\n" "PO-Revision-Date: 2011-02-12 11:30+0100\n" "Last-Translator: Javier Bradineras <jbradi@hotmail.com>\n" "Language-Team: Spanish <vdr@linuxtv.org>\n" -"Language: es\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" +"Language: es\n" "X-Poedit-Language: Spanish\n" "X-Poedit-Country: SPAIN\n" "X-Poedit-SourceCharset: utf-8\n" diff --git a/plugin/po/it_IT.po b/plugin/po/it_IT.po index 6596bda..ab43e69 100644 --- a/plugin/po/it_IT.po +++ b/plugin/po/it_IT.po @@ -4,14 +4,14 @@ msgid "" msgstr "" "Project-Id-Version: vdr\n" "Report-Msgid-Bugs-To: <see README>\n" -"POT-Creation-Date: 2011-02-22 21:59+0100\n" +"POT-Creation-Date: 2011-03-21 22:32+0100\n" "PO-Revision-Date: 2011-03-05 16:11+0100\n" "Last-Translator: Diego Pierotto <vdr-italian@tiscali.it>\n" "Language-Team: Italian <vdr@linuxtv.org>\n" -"Language: it\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" +"Language: it\n" "X-Poedit-Language: Italian\n" "X-Poedit-Country: ITALY\n" "X-Poedit-SourceCharset: utf-8\n" @@ -8,6 +8,6 @@ #ifndef __version_h_ #define __version_h_ -static const char *VERSION = "0.1.1"; +static const char *VERSION = "0.1.2pre"; #endif |