Skip to content

Commit

Permalink
Reset stale timeout only if number of frames changed
Browse files Browse the repository at this point in the history
  • Loading branch information
ioppermann committed Jan 1, 2019
1 parent b680058 commit 5c36bdb
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions src/classes/Restreamer.js
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,9 @@ class Restreamer {
}, config.ffmpeg.monitor.restart_wait);
}

// current number of processed frames for stale detection
let nFrames = -1;

// after adding outputs, define events on the new FFmpeg stream
probePromise.then((option) => {
Restreamer.addStreamOptions(command, option);
Expand Down Expand Up @@ -607,14 +610,23 @@ class Restreamer {
Restreamer.updateState(streamType, 'connected');
}

// compare the current number of frames
let nFramesChanged = false;
if(nFrames != progress.frames) {
nFrames = progress.frames;
nFramesChanged = true;
}

Restreamer.data.progresses[streamType] = progress;
Restreamer.updateProgressOnGui();

// add a stale timeout
Restreamer.setTimeout(streamType, 'stale', () => {
logger.info('Stale connection', streamType);
Restreamer.stopStream(streamType);
}, config.ffmpeg.monitor.stale_wait);
// add/reset a stale timeout if the number of frames changed
if(nFramesChanged == true) {
Restreamer.setTimeout(streamType, 'stale', () => {
logger.info('Stale connection', streamType);
Restreamer.stopStream(streamType);
}, config.ffmpeg.monitor.stale_wait);
}
});

command.exec();
Expand Down

0 comments on commit 5c36bdb

Please sign in to comment.