Changed input boot sequence to allow for finer control

This commit is contained in:
Thulinma 2017-05-12 12:47:15 +02:00
parent c56b72dbca
commit 260894468e

View file

@ -93,7 +93,17 @@ namespace Mist {
/// Starts checks the SEM_INPUT lock, starts an angel process and then /// Starts checks the SEM_INPUT lock, starts an angel process and then
int Input::boot(int argc, char * argv[]){ int Input::boot(int argc, char * argv[]){
if (!(config->parseArgs(argc, argv))){return 1;} if (!(config->parseArgs(argc, argv))){return 1;}
streamName = config->getString("streamname"); streamName = nProxy.streamName = config->getString("streamname");
if (config->getBool("json")) {
std::cout << capa.toString() << std::endl;
return 0;
}
if (!setup()) {
FAIL_MSG("Setup failed - exiting");
return 0;
}
IPC::semaphore playerLock; IPC::semaphore playerLock;
if (needsLock() && streamName.size()){ if (needsLock() && streamName.size()){
@ -152,18 +162,6 @@ namespace Mist {
} }
int Input::run() { int Input::run() {
if (config->getBool("json")) {
std::cout << capa.toString() << std::endl;
return 0;
}
nProxy.streamName = streamName;
if (!setup()){
std::cerr << config->getString("cmd") << " setup failed." << std::endl;
return 0;
}
checkHeaderTimes(config->getString("input")); checkHeaderTimes(config->getString("input"));
if (!readHeader()){ if (!readHeader()){
std::cerr << "Reading header for " << config->getString("input") << " failed." << std::endl; std::cerr << "Reading header for " << config->getString("input") << " failed." << std::endl;
@ -291,16 +289,19 @@ namespace Mist {
pullLock.close(); pullLock.close();
return; return;
} }
if (Util::streamAlive(streamName)){ if (Util::streamAlive(streamName)){
pullLock.post(); pullLock.post();
pullLock.close(); pullLock.close();
pullLock.unlink(); pullLock.unlink();
WARN_MSG("Stream already online, cancelling");
return; return;
} }
if (!Util::startInput(streamName, "push://INTERNAL_ONLY:"+config->getString("input"))) {//manually override stream url to start the buffer if (!Util::startInput(streamName, "push://INTERNAL_ONLY:"+config->getString("input"))) {//manually override stream url to start the buffer
pullLock.post(); pullLock.post();
pullLock.close(); pullLock.close();
pullLock.unlink(); pullLock.unlink();
WARN_MSG("Could not start buffer, cancelling");
return; return;
} }
@ -324,6 +325,7 @@ namespace Mist {
pullLock.post(); pullLock.post();
pullLock.close(); pullLock.close();
pullLock.unlink(); pullLock.unlink();
WARN_MSG("No tracks found, cancelling");
return; return;
} }
nProxy.userClient.countAsViewer = false; nProxy.userClient.countAsViewer = false;
@ -561,7 +563,7 @@ namespace Mist {
if ((int)myMeta.tracks[track].keys.size() > keyNum - 1 + nProxy.pagesByTrack[track][keyNum].keyNum) { if ((int)myMeta.tracks[track].keys.size() > keyNum - 1 + nProxy.pagesByTrack[track][keyNum].keyNum) {
stopTime = myMeta.tracks[track].keys[keyNum - 1 + nProxy.pagesByTrack[track][keyNum].keyNum].getTime(); stopTime = myMeta.tracks[track].keys[keyNum - 1 + nProxy.pagesByTrack[track][keyNum].keyNum].getTime();
} }
DEBUG_MSG(DLVL_HIGH, "Playing from %llu to %llu", myMeta.tracks[track].keys[keyNum - 1].getTime(), stopTime); HIGH_MSG("Playing from %llu to %llu", myMeta.tracks[track].keys[keyNum - 1].getTime(), stopTime);
getNext(); getNext();
//in case earlier seeking was inprecise, seek to the exact point //in case earlier seeking was inprecise, seek to the exact point
while (thisPacket && thisPacket.getTime() < (unsigned long long)myMeta.tracks[track].keys[keyNum - 1].getTime()){ while (thisPacket && thisPacket.getTime() < (unsigned long long)myMeta.tracks[track].keys[keyNum - 1].getTime()){