Fixed MP4 byte-precise seeking + tweaks to debug message verbosity.
This commit is contained in:
parent
ed773e1a19
commit
cc8ab01a44
3 changed files with 22 additions and 20 deletions
|
@ -480,10 +480,10 @@ namespace Mist {
|
|||
|
||||
|
||||
bool Input::bufferFrame(unsigned int track, unsigned int keyNum) {
|
||||
VERYHIGH_MSG("bufferFrame for stream %s, track %u, key %u", streamName.c_str(), track, keyNum);
|
||||
if (keyNum >= myMeta.tracks[track].keys.size()) {
|
||||
VERYHIGH_MSG("Buffering stream %s, track %u, key %u", streamName.c_str(), track, keyNum);
|
||||
if (keyNum > myMeta.tracks[track].keys.size()) {
|
||||
//End of movie here, returning true to avoid various error messages
|
||||
VERYHIGH_MSG("Key number is higher than total key count. Cancelling bufferFrame");
|
||||
WARN_MSG("Key %llu is higher than total (%llu). Cancelling buffering.", keyNum, myMeta.tracks[track].keys.size());
|
||||
return true;
|
||||
}
|
||||
if (keyNum < 1) {
|
||||
|
|
|
@ -370,7 +370,6 @@ namespace Mist {
|
|||
if ((*itb).size() && myMeta.tracks.size()){
|
||||
bool found = false;
|
||||
jsonForEach((*itb), itc) {
|
||||
INFO_MSG("Filling codec: '%s'", (*itc).asStringRef().c_str());
|
||||
if (found) {
|
||||
break;
|
||||
}
|
||||
|
@ -495,6 +494,7 @@ namespace Mist {
|
|||
|
||||
void Output::loadPageForKey(long unsigned int trackId, long long int keyNum){
|
||||
if (myMeta.vod && keyNum > myMeta.tracks[trackId].keys.rbegin()->getNumber()){
|
||||
INFO_MSG("Seek in track %lu to key %lld aborted, is > %lld", trackId, keyNum, myMeta.tracks[trackId].keys.rbegin()->getNumber());
|
||||
nProxy.curPage.erase(trackId);
|
||||
currKeyOpen.erase(trackId);
|
||||
return;
|
||||
|
@ -504,7 +504,7 @@ namespace Mist {
|
|||
unsigned long pageNum = pageNumForKey(trackId, keyNum);
|
||||
while (pageNum == -1){
|
||||
if (!timeout){
|
||||
DEBUG_MSG(DLVL_HIGH, "Requesting page with key %lu:%lld", trackId, keyNum);
|
||||
HIGH_MSG("Requesting page with key %lu:%lld", trackId, keyNum);
|
||||
}
|
||||
++timeout;
|
||||
//if we've been waiting for this page for 3 seconds, reconnect to the stream - something might be going wrong...
|
||||
|
@ -568,9 +568,13 @@ namespace Mist {
|
|||
}
|
||||
|
||||
bool Output::seek(unsigned int tid, unsigned long long pos, bool getNextKey){
|
||||
if (myMeta.tracks[tid].lastms < pos){
|
||||
INFO_MSG("Aborting seek to %llums in track %u: past end of track.", pos, tid);
|
||||
return false;
|
||||
}
|
||||
loadPageForKey(tid, getKeyForTime(tid, pos) + (getNextKey?1:0));
|
||||
if (!nProxy.curPage.count(tid) || !nProxy.curPage[tid].mapped){
|
||||
INFO_MSG("Aborting seek to %llums in track %u, not available.", pos, tid);
|
||||
INFO_MSG("Aborting seek to %llums in track %u: not available.", pos, tid);
|
||||
return false;
|
||||
}
|
||||
sortedPageInfo tmp;
|
||||
|
@ -591,7 +595,7 @@ namespace Mist {
|
|||
}else{
|
||||
//don't print anything for empty packets - not sign of corruption, just unfinished stream.
|
||||
if (nProxy.curPage[tid].mapped[tmp.offset] != 0){
|
||||
DEBUG_MSG(DLVL_FAIL, "Noes! Couldn't find packet on track %d because of some kind of corruption error or somesuch.", tid);
|
||||
FAIL_MSG("Noes! Couldn't find packet on track %d because of some kind of corruption error or somesuch.", tid);
|
||||
}else{
|
||||
VERYHIGH_MSG("Track %d no data (key %u @ %u) - waiting...", tid, getKeyForTime(tid, pos) + (getNextKey?1:0), tmp.offset);
|
||||
unsigned int i = 0;
|
||||
|
|
|
@ -407,7 +407,7 @@ namespace Mist {
|
|||
byteStart -= sortSet.begin()->size;
|
||||
//if that put us past the point where we wanted to be, return right now
|
||||
if (byteStart < 0) {
|
||||
INFO_MSG("Seeked to tid: %lu t: %llu ", sortSet.begin()->trackID, sortSet.begin()->time);
|
||||
INFO_MSG("We're starting at time %lld, skipping %lld bytes", seekPoint, byteStart+sortSet.begin()->size);
|
||||
return;
|
||||
}
|
||||
//otherwise, set currPos to where we are now and continue
|
||||
|
@ -692,7 +692,6 @@ namespace Mist {
|
|||
sortSet.insert(temp);
|
||||
}
|
||||
if (!myMeta.live) {
|
||||
INFO_MSG("notlive get range %s", H.GetHeader("Range").c_str());
|
||||
if (H.GetHeader("Range") != "") {
|
||||
parseRange(H.GetHeader("Range"), byteStart, byteEnd, seekPoint, headerData.size());
|
||||
rangeType = H.GetHeader("Range")[0];
|
||||
|
@ -897,6 +896,16 @@ namespace Mist {
|
|||
return;
|
||||
}
|
||||
|
||||
if (currPos >= byteStart) {
|
||||
myConn.SendNow(dataPointer, std::min(leftOver, (long long)len));
|
||||
leftOver -= len;
|
||||
} else {
|
||||
if (currPos + (long long)len > byteStart) {
|
||||
myConn.SendNow(dataPointer + (byteStart - currPos), std::min(leftOver, (long long)(len - (byteStart - currPos))));
|
||||
leftOver -= len - (byteStart - currPos);
|
||||
}
|
||||
}
|
||||
|
||||
//keep track of where we are
|
||||
if (!sortSet.empty()) {
|
||||
keyPart temp;
|
||||
|
@ -914,17 +923,6 @@ namespace Mist {
|
|||
}
|
||||
|
||||
|
||||
if (currPos >= byteStart) {
|
||||
myConn.SendNow(dataPointer, std::min(leftOver, (long long)len));
|
||||
|
||||
leftOver -= len;
|
||||
} else {
|
||||
if (currPos + (long long)len > byteStart) {
|
||||
myConn.SendNow(dataPointer + (byteStart - currPos), len - (byteStart - currPos));
|
||||
leftOver -= len - (byteStart - currPos);
|
||||
currPos = byteStart;
|
||||
}
|
||||
}
|
||||
|
||||
if (leftOver < 1) {
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue