Merge branch 'development' into LTS_development
# Conflicts: # src/input/input.cpp # src/output/output.cpp
This commit is contained in:
commit
3f14db4b12
12 changed files with 137 additions and 64 deletions
|
@ -97,7 +97,8 @@ namespace Mist {
|
|||
INSANE_MSG("No header exists to compare - ignoring header check");
|
||||
return;
|
||||
}
|
||||
if (bufHeader.st_mtime < bufStream.st_mtime) {
|
||||
//the same second is not enough - add a 15 second window where we consider it too old
|
||||
if (bufHeader.st_mtime < bufStream.st_mtime + 15) {
|
||||
INFO_MSG("Overwriting outdated DTSH header file: %s ", headerFile.c_str());
|
||||
remove(headerFile.c_str());
|
||||
}
|
||||
|
@ -180,12 +181,6 @@ namespace Mist {
|
|||
/// streamname
|
||||
/// input name
|
||||
/// ~~~~~~~~~~~~~~~
|
||||
/// The `"STREAM_UNLOAD"` trigger is stream-specific, and is ran right before an input shuts down and stops serving a stream. If cancelled, the shut down is delayed. Its payload is:
|
||||
/// ~~~~~~~~~~~~~~~
|
||||
/// streamname
|
||||
/// input name
|
||||
/// ~~~~~~~~~~~~~~~
|
||||
//
|
||||
void Input::serve(){
|
||||
if (!isBuffer) {
|
||||
for (std::map<unsigned int, DTSC::Track>::iterator it = myMeta.tracks.begin(); it != myMeta.tracks.end(); it++) {
|
||||
|
@ -205,11 +200,15 @@ namespace Mist {
|
|||
/*LTS-END*/
|
||||
|
||||
DEBUG_MSG(DLVL_DEVEL, "Input for stream %s started", streamName.c_str());
|
||||
|
||||
long long int activityCounter = Util::bootSecs();
|
||||
while (((Util::bootSecs() - activityCounter) < INPUT_TIMEOUT || (myMeta.live && (Util::bootSecs() - activityCounter) < myMeta.biggestFragment()/500)) && config->is_active) { //15 second timeout
|
||||
activityCounter = Util::bootSecs();
|
||||
//main serve loop
|
||||
while (keepRunning()) {
|
||||
//load pages for connected clients on request
|
||||
//through the callbackWrapper function
|
||||
userPage.parseEach(callbackWrapper);
|
||||
//unload pages that haven't been used for a while
|
||||
removeUnused();
|
||||
//If users are connected and tracks exist, reset the activity counter
|
||||
if (userPage.connectedUsers) {
|
||||
if (myMeta.tracks.size()){
|
||||
activityCounter = Util::bootSecs();
|
||||
|
@ -218,17 +217,7 @@ namespace Mist {
|
|||
} else {
|
||||
DEBUG_MSG(DLVL_INSANE, "Timer running");
|
||||
}
|
||||
/*LTS-START*/
|
||||
if ((Util::bootSecs() - activityCounter) >= INPUT_TIMEOUT || !config->is_active){//15 second timeout
|
||||
if(Triggers::shouldTrigger("STREAM_UNLOAD", config->getString("streamname"))){
|
||||
std::string payload = config->getString("streamname")+"\n" +capa["name"].asStringRef()+"\n";
|
||||
if (!Triggers::doTrigger("STREAM_UNLOAD", payload, config->getString("streamname"))){
|
||||
activityCounter = Util::bootSecs();
|
||||
config->is_active = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
/*LTS-END*/
|
||||
//if not shutting down, wait 1 second before looping
|
||||
if (config->is_active){
|
||||
Util::wait(1000);
|
||||
}
|
||||
|
@ -238,6 +227,14 @@ namespace Mist {
|
|||
//end player functionality
|
||||
}
|
||||
|
||||
bool Input::keepRunning(){
|
||||
//We keep running in serve mode if the config is still active AND either
|
||||
// - INPUT_TIMEOUT seconds haven't passed yet,
|
||||
// - this is a live stream and at least two of the biggest fragment haven't passed yet,
|
||||
bool ret = (config->is_active && ((Util::bootSecs() - activityCounter) < INPUT_TIMEOUT || (myMeta.live && (Util::bootSecs() - activityCounter) < myMeta.biggestFragment()/500)));
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// Main loop for stream-style inputs.
|
||||
/// This loop will start the buffer without resume support, and then repeatedly call ..... followed by ....
|
||||
void Input::stream(){
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue