From 492dcd03f50184162e2fbd497f23e5db99360ba5 Mon Sep 17 00:00:00 2001 From: Thulinma Date: Fri, 12 May 2017 17:04:03 +0200 Subject: [PATCH] Fixed TS live input --- lib/ts_stream.cpp | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/lib/ts_stream.cpp b/lib/ts_stream.cpp index 376ee280..589c49d5 100644 --- a/lib/ts_stream.cpp +++ b/lib/ts_stream.cpp @@ -229,20 +229,21 @@ namespace TS{ bool parsePes = false; int packNum = 1; + // Usually we append a packet at a time, so the start code is expected to show up at the end. std::deque &inStream = pesStreams[tid]; - if (!inStream.rbegin()->getUnitStart()){ - if (threaded){globalSem.post();} - return; - } - std::deque::iterator lastPack = inStream.end(); - std::deque::iterator curPack = inStream.begin(); - curPack++; - while (curPack != lastPack && !curPack->getUnitStart()){ + if (inStream.rbegin()->getUnitStart()){ + parsePes = true; + }else{ + //But, sometimes (e.g. live) we do multiples, and need to check all of it... + std::deque::iterator lastPack = inStream.end(); + std::deque::iterator curPack = inStream.begin(); curPack++; - packNum++; + while (curPack != lastPack && !curPack->getUnitStart()){ + curPack++; + packNum++; + } + if (curPack != lastPack){parsePes = true;} } - if (curPack != lastPack){parsePes = true;} - if (threaded){globalSem.post();} if (parsePes){parsePES(tid);} @@ -697,7 +698,7 @@ namespace TS{ if (threaded){globalSem.post();} if (!packetReady){ - ERROR_MSG("Obtaining a packet on track %lu failed", tid); + ERROR_MSG("Track %lu: PES without valid packets?", tid); return; }