diff --git a/src/input/input.cpp b/src/input/input.cpp index f6833e40..2a2cedc7 100644 --- a/src/input/input.cpp +++ b/src/input/input.cpp @@ -168,13 +168,20 @@ namespace Mist { } int Input::run() { + myMeta.sourceURI = config->getString("input"); if (streamStatus){streamStatus.mapped[0] = STRMSTAT_BOOT;} checkHeaderTimes(config->getString("input")); - if (!readHeader()){ - std::cerr << "Reading header for " << config->getString("input") << " failed." << std::endl; - return 0; + if (needHeader()){ + uint64_t timer = Util::bootMS(); + bool headerSuccess = readHeader(); + if (!headerSuccess) { + std::cerr << "Reading header for " << config->getString("input") << " failed." << std::endl; + return 0; + }else{ + timer = Util::bootMS() - timer; + DEBUG_MSG(DLVL_DEVEL, "Read header for '%s' in %llums", streamName.c_str(), timer); + } } - myMeta.sourceURI = config->getString("input"); if (myMeta.vod){ parseHeader(); MEDIUM_MSG("Header parsed, %lu tracks", myMeta.tracks.size()); @@ -585,7 +592,7 @@ namespace Mist { return false; } //Update keynum to point to the corresponding page - uint64_t bufferTimer = Util::getMS(); + uint64_t bufferTimer = Util::bootMS(); INFO_MSG("Loading key %u from page %lu", keyNum, (--(nProxy.pagesByTrack[track].upper_bound(keyNum)))->first); keyNum = (--(nProxy.pagesByTrack[track].upper_bound(keyNum)))->first; if (!bufferStart(track, keyNum)){ @@ -620,7 +627,7 @@ namespace Mist { getNext(); } bufferFinalize(track); - bufferTimer = Util::getMS() - bufferTimer; + bufferTimer = Util::bootMS() - bufferTimer; DEBUG_MSG(DLVL_DEVEL, "Done buffering page %d (%llu packets, %llu bytes) for track %d in %llums", keyNum, packCounter, byteCounter, track, bufferTimer); pageCounter[track][keyNum] = 15; return true; @@ -646,7 +653,6 @@ namespace Mist { playing = -1; playUntil = until; initialTime = 0; - benchMark = Util::getMS(); } void Input::playOnce(){ @@ -654,7 +660,6 @@ namespace Mist { playing = 1; } ++playing; - benchMark = Util::getMS(); } void Input::quitPlay(){ diff --git a/src/input/input.h b/src/input/input.h index e274e086..ae2c68e8 100644 --- a/src/input/input.h +++ b/src/input/input.h @@ -29,6 +29,7 @@ namespace Mist { static void callbackWrapper(char * data, size_t len, unsigned int id); virtual bool checkArguments() = 0; virtual bool readHeader() = 0; + virtual bool needHeader(){return !readExistingHeader();} virtual bool preRun(){return true;} virtual bool readExistingHeader(); virtual bool atKeyFrame(); @@ -59,7 +60,6 @@ namespace Mist { int initialTime; int playing; unsigned int playUntil; - unsigned int benchMark; bool isBuffer; uint64_t activityCounter; diff --git a/src/input/input_buffer.cpp b/src/input/input_buffer.cpp index ff6c6272..eb173e55 100644 --- a/src/input/input_buffer.cpp +++ b/src/input/input_buffer.cpp @@ -774,16 +774,5 @@ namespace Mist { return true; } - bool inputBuffer::readHeader() { - return true; - } - - void inputBuffer::getNext(bool smart) {} - - void inputBuffer::seek(int seekTime) {} - - void inputBuffer::trackSelect(std::string trackSpec) {} } - - diff --git a/src/input/input_buffer.h b/src/input/input_buffer.h index 96cc8898..26ed8496 100644 --- a/src/input/input_buffer.h +++ b/src/input/input_buffer.h @@ -19,12 +19,13 @@ namespace Mist { bool preRun(); bool checkArguments(){return true;} void updateMeta(); - bool readHeader(); - void getNext(bool smart = true); + bool readHeader(){return false;} + bool needHeader(){return false;} + void getNext(bool smart = true){} void updateTrackMeta(unsigned long tNum); void updateMetaFromPage(unsigned long tNum, unsigned long pageNum); - void seek(int seekTime); - void trackSelect(std::string trackSpec); + void seek(int seekTime){} + void trackSelect(std::string trackSpec){} bool removeKey(unsigned int tid); void removeUnused(); void eraseTrackDataPages(unsigned long tid); diff --git a/src/input/input_dtsc.cpp b/src/input/input_dtsc.cpp index 7836487e..5b96a854 100644 --- a/src/input/input_dtsc.cpp +++ b/src/input/input_dtsc.cpp @@ -208,19 +208,15 @@ namespace Mist { return true; } + bool inputDTSC::needHeader(){ + if (!needsLock()){return false;} + return Input::needHeader(); + } + bool inputDTSC::readHeader() { - if (!needsLock()) { - return true; - } if (!inFile) { return false; } - DTSC::File tmp(config->getString("input") + ".dtsh"); - if (tmp) { - myMeta = tmp.getMeta(); - DEBUG_MSG(DLVL_HIGH, "Meta read in with %lu tracks", myMeta.tracks.size()); - return true; - } if (inFile.getMeta().moreheader < 0 || inFile.getMeta().tracks.size() == 0) { DEBUG_MSG(DLVL_FAIL, "Missing external header file"); return false; diff --git a/src/input/input_dtsc.h b/src/input/input_dtsc.h index 496d6b5a..0a0704e5 100644 --- a/src/input/input_dtsc.h +++ b/src/input/input_dtsc.h @@ -13,6 +13,7 @@ namespace Mist { void parseStreamHeader(); bool checkArguments(); bool readHeader(); + bool needHeader(); void getNext(bool smart = true); void seek(int seekTime); void trackSelect(std::string trackSpec); diff --git a/src/input/input_flv.cpp b/src/input/input_flv.cpp index a60f3b60..bebb880f 100644 --- a/src/input/input_flv.cpp +++ b/src/input/input_flv.cpp @@ -78,8 +78,6 @@ namespace Mist { bool inputFLV::readHeader() { if (!inFile){return false;} - //See whether a separate header file exists. - if (readExistingHeader()){return true;} //Create header file from FLV data Util::fseek(inFile, 13, SEEK_SET); AMF::Object amf_storage; diff --git a/src/input/input_mp3.cpp b/src/input/input_mp3.cpp index ebeb89ef..c640fda5 100644 --- a/src/input/input_mp3.cpp +++ b/src/input/input_mp3.cpp @@ -51,8 +51,6 @@ namespace Mist { bool inputMP3::readHeader() { if (!inFile){return false;} - //See whether a separate header file exists. - if (readExistingHeader()){return true;} myMeta = DTSC::Meta(); myMeta.tracks[1].trackID = 1; myMeta.tracks[1].type = "audio";