forked from j62/ctbrec
1
0
Fork 0

Add setting to limit the number of concurrent active recordings

This commit is contained in:
0xboobface 2019-02-05 14:41:31 +01:00
parent 39679f3162
commit 2dd8100a97
2 changed files with 11 additions and 0 deletions

View File

@ -80,6 +80,7 @@ public class Settings {
public boolean requireAuthentication = false; public boolean requireAuthentication = false;
public boolean chooseStreamQuality = false; public boolean chooseStreamQuality = false;
public int maximumResolution = 0; public int maximumResolution = 0;
public int concurrentRecordings = 0;
public byte[] key = null; public byte[] key = null;
public ProxyType proxyType = ProxyType.DIRECT; public ProxyType proxyType = ProxyType.DIRECT;
public String proxyHost; public String proxyHost;

View File

@ -191,6 +191,11 @@ public class LocalRecorder implements Recorder {
return; return;
} }
if(!downloadSlotAvailable()) {
LOG.info("The number of downloads is maxed out, not starting recording for {}", model);
return;
}
LOG.debug("Starting recording for model {}", model.getName()); LOG.debug("Starting recording for model {}", model.getName());
Download download = model.createDownload(); Download download = model.createDownload();
LOG.debug("Downloading with {}", download.getClass().getSimpleName()); LOG.debug("Downloading with {}", download.getClass().getSimpleName());
@ -207,6 +212,11 @@ public class LocalRecorder implements Recorder {
}.start(); }.start();
} }
private boolean downloadSlotAvailable() {
int concurrentRecordings = Config.getInstance().getSettings().concurrentRecordings;
return concurrentRecordings > 0 && recordingProcesses.size() < concurrentRecordings;
}
private void stopRecordingProcess(Model model) { private void stopRecordingProcess(Model model) {
Download download = recordingProcesses.get(model); Download download = recordingProcesses.get(model);
recordingProcesses.remove(model); recordingProcesses.remove(model);