From a001feafca4adc8e41a00d935092e669763cadc4 Mon Sep 17 00:00:00 2001 From: Thulinma Date: Tue, 30 Dec 2014 02:08:14 +0100 Subject: [PATCH] Fixed various live issues. --- src/controller/controller_statistics.cpp | 3 ++- src/output/output.cpp | 12 +++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/controller/controller_statistics.cpp b/src/controller/controller_statistics.cpp index b941aeda..79e695de 100644 --- a/src/controller/controller_statistics.cpp +++ b/src/controller/controller_statistics.cpp @@ -421,8 +421,9 @@ void Controller::parseStatistics(char * data, size_t len, unsigned int id){ /// Returns true if this stream has at least one connected client. bool Controller::hasViewers(std::string streamName){ if (sessions.size()){ + long long currTime = Util::epoch(); for (std::map::iterator it = sessions.begin(); it != sessions.end(); it++){ - if (it->first.streamName == streamName){ + if (it->first.streamName == streamName && it->second.hasDataFor(currTime)){ return true; } } diff --git a/src/output/output.cpp b/src/output/output.cpp index 61730932..8746a896 100644 --- a/src/output/output.cpp +++ b/src/output/output.cpp @@ -390,7 +390,7 @@ namespace Mist { long amountKey = ntohl((((long long int*)indexPages[trackId].mapped)[i]) & 0xFFFFFFFF); if (amountKey == 0){continue;} long tmpKey = ntohl(((((long long int*)indexPages[trackId].mapped)[i]) >> 32) & 0xFFFFFFFF); - if (tmpKey <= keyNum && (tmpKey + amountKey) > keyNum){ + if (tmpKey <= keyNum && ((tmpKey?tmpKey:1) + amountKey) > keyNum){ return tmpKey; } } @@ -629,7 +629,7 @@ namespace Mist { buffer.insert(nxt); }else{ //after ~10 seconds, give up and drop the track. - DEBUG_MSG(DLVL_DEVEL, "Empty packet on track %u - could not reload, dropping track.", nxt.tid); + DEBUG_MSG(DLVL_DEVEL, "Empty packet on track %u @ key %lu (next=%d) - could not reload, dropping track.", nxt.tid, nxtKeyNum[nxt.tid]+1, nextPage); } //keep updating the metadata at 250ms intervals while waiting for more data Util::sleep(250); @@ -661,7 +661,13 @@ namespace Mist { if (currentPacket.getTime() != nxt.time && nxt.time){ DEBUG_MSG(DLVL_MEDIUM, "ACTUALLY Loaded track %ld (next=%lu), %llu ms", currentPacket.getTrackId(), nxtKeyNum[nxt.tid], currentPacket.getTime()); } - nxtKeyNum[nxt.tid] = getKeyForTime(nxt.tid, currentPacket.getTime()); + if (currentPacket.getFlag("keyframe")){ + if (myMeta.live){ + updateMeta(); + } + nxtKeyNum[nxt.tid] = getKeyForTime(nxt.tid, currentPacket.getTime()); + DEBUG_MSG(DLVL_VERYHIGH, "Track %u @ %llums = key %lu", nxt.tid, currentPacket.getTime(), nxtKeyNum[nxt.tid]); + } emptyCount = 0; } nxt.offset += currentPacket.getDataLen();