forked from j62/ctbrec
Add setting to limit the number of concurrent active recordings
This commit is contained in:
parent
39679f3162
commit
2dd8100a97
|
@ -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;
|
||||||
|
|
|
@ -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);
|
||||||
|
|
Loading…
Reference in New Issue