Hi, Kartsa wrote:
> My log is actually full of these. The attached patch adds a TS packet logger to cAudioRepacker, which stores the last 1000 TS packets that led to synchronization of cAudioRepacker into a file to /video. In your logfile you'll then find lines like the following: Feb 19 21:41:36 video vdr: [9413] cAudioRepacker(0xC1): skipped 24 bytes to sync on next audio frame Feb 19 21:41:36 video vdr: [9413] cTSLogger: dumping to file '/video/ts_9353_9413_0xC1_000_12_12.log' Please provide me some of these files which were dumped in the "middle" of a recording. If size matters, you may reduce the number of packets to 100. Bye. -- Dipl.-Inform. (FH) Reinhard Nissl mailto:[EMAIL PROTECTED]
--- ../vdr-1.4.5-orig/remux.c 2006-12-01 15:46:25.000000000 +0100 +++ remux.c 2007-02-19 21:39:41.000000000 +0100 @@ -86,6 +86,65 @@ ePesHeader AnalyzePesHeader(const uchar return phMPEG1; // MPEG 1 } +// --- cTSLogger ------------------------------------------------------------- + +class cTSLogger +{ + cMutex mutex; + uchar *buffer; + int size; + int fill; + int64_t count; + int dumps; + int cid; + +public: + cTSLogger(int Cid); + ~cTSLogger(); + void Put(const uchar *Data); + void Dump(); +}; + +cTSLogger::cTSLogger(int Cid) +{ + size = 1000; // number of TS packets to log + buffer = new uchar[size * 188]; + fill = 0; + count = 0; + dumps = 0; + cid = Cid; +} + +cTSLogger::~cTSLogger() +{ + delete [] buffer; +} + +void cTSLogger::Put(const uchar *Data) +{ + cMutexLock MutexLock(&mutex); + + memcpy(&buffer[(count++ % size) * 188], Data, 188); + if (fill < size) + fill++; +} + +void cTSLogger::Dump() +{ + cMutexLock MutexLock(&mutex); + + char name[200]; + sprintf(name, "/video/ts_%d_%d_0x%02X_%03d_%lld_%d.log", getpid(), cThread::ThreadId(), cid, dumps++, count, fill); + esyslog("cTSLogger: dumping to file '%s'", name); + + FILE *f = fopen(name, "wb"); + for (int64_t n = count - fill; n < count; n++) + fwrite(&buffer[(n % size) * 188], 188, 1, f); + fclose(f); + + fill = 0; +} + // --- cRepacker ------------------------------------------------------------- #define MIN_LOG_INTERVAL 10 // min. # of seconds between two consecutive log messages of a cRepacker @@ -110,6 +169,7 @@ public: virtual int QuerySnoopSize(void) { return 0; } void SetMaxPacketSize(int MaxPacketSize) { maxPacketSize = MaxPacketSize; } void SetSubStreamId(uint8_t SubStreamId) { subStreamId = SubStreamId; } + virtual void LogTSPacket(const uchar *Data) {} }; cRepacker::cRepacker(void) @@ -691,6 +837,8 @@ private: int frameSize; int cid; static bool IsValidAudioHeader(uint32_t Header, bool Mpeg2, int *FrameSize = NULL); + cTSLogger tsLogger; + virtual void LogTSPacket(const uchar *Data) { tsLogger.Put(Data); } public: cAudioRepacker(int Cid); virtual void Reset(void); @@ -712,6 +861,7 @@ int cAudioRepacker::bitRates[2][3][16] = }; cAudioRepacker::cAudioRepacker(int Cid) + : tsLogger(Cid) { cid = Cid; Reset(); @@ -842,8 +1302,10 @@ void cAudioRepacker::Repack(cRingBufferL if (state == syncing) { if (initiallySyncing) // omit report for the typical initial case initiallySyncing = false; - else if (skippedBytes > SkippedBytesLimit) // report that syncing dropped some bytes + else if (skippedBytes > SkippedBytesLimit) { // report that syncing dropped some bytes LOG("cAudioRepacker(0x%02X): skipped %d bytes to sync on next audio frame", cid, skippedBytes - SkippedBytesLimit); + tsLogger.Dump(); + } skippedBytes = 0; // if there is a PES header available, then use it ... if (pesHeaderBackupLen > 0) { @@ -1803,6 +2278,8 @@ void cTS2PES::instant_repack(const uint8 void cTS2PES::ts_to_pes(const uint8_t *Buf) // don't need count (=188) { + if (Buf && repacker) repacker->LogTSPacket(Buf); + if (!Buf) return;
_______________________________________________ vdr mailing list vdr@linuxtv.org http://www.linuxtv.org/cgi-bin/mailman/listinfo/vdr