Add getCurrentlyRecording to recorder
This method returns the models, which are currently recorded. It is implemented as default method, so that LocalRecorder and RemoteRecorder don't have to implement the same logic.
This commit is contained in:
parent
76f4583ebc
commit
097fb251cb
|
@ -254,8 +254,8 @@ public class CamrecApplication extends Application {
|
||||||
public void handleEvent(Event evt) {
|
public void handleEvent(Event evt) {
|
||||||
if(evt.getType() == Event.Type.MODEL_ONLINE || evt.getType() == Event.Type.MODEL_STATUS_CHANGED || evt.getType() == Event.Type.RECORDING_STATUS_CHANGED) {
|
if(evt.getType() == Event.Type.MODEL_ONLINE || evt.getType() == Event.Type.MODEL_STATUS_CHANGED || evt.getType() == Event.Type.RECORDING_STATUS_CHANGED) {
|
||||||
try {
|
try {
|
||||||
List<Model> models = recorder.getOnlineModels();
|
List<Model> models = recorder.getCurrentlyRecording();
|
||||||
long count = models.stream().filter(m -> !recorder.isSuspended(m)).count();
|
long count = models.size();
|
||||||
String _title = count > 0 ? "(" + count + ") " + title : title;
|
String _title = count > 0 ? "(" + count + ") " + title : title;
|
||||||
Platform.runLater(() -> primaryStage.setTitle(_title));
|
Platform.runLater(() -> primaryStage.setTitle(_title));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
|
@ -4,6 +4,7 @@ import java.io.IOException;
|
||||||
import java.security.InvalidKeyException;
|
import java.security.InvalidKeyException;
|
||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import ctbrec.Model;
|
import ctbrec.Model;
|
||||||
import ctbrec.Recording;
|
import ctbrec.Recording;
|
||||||
|
@ -41,11 +42,31 @@ public interface Recorder {
|
||||||
public boolean isSuspended(Model model);
|
public boolean isSuspended(Model model);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns only the models from getModelsRecording(), which are online
|
* Returns only the models from getModels(), which are online
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public List<Model> getOnlineModels();
|
public List<Model> getOnlineModels();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns only the models from getModels(), which are actually recorded right now
|
||||||
|
* @return
|
||||||
|
* @throws IOException
|
||||||
|
* @throws IllegalStateException
|
||||||
|
* @throws NoSuchAlgorithmException
|
||||||
|
* @throws InvalidKeyException
|
||||||
|
*/
|
||||||
|
public default List<Model> getCurrentlyRecording() throws InvalidKeyException, NoSuchAlgorithmException, IllegalStateException, IOException {
|
||||||
|
List<Recording> recordings = getRecordings();
|
||||||
|
return getModels().stream().filter(m -> {
|
||||||
|
for (Recording recording : recordings) {
|
||||||
|
if (recording.getStatus() == Recording.State.RECORDING && recording.getModelName().equals(m.getName())) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
public HttpClient getHttpClient();
|
public HttpClient getHttpClient();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -72,4 +93,5 @@ public interface Recorder {
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
public void regeneratePlaylist(Recording recording) throws IOException, InvalidKeyException, NoSuchAlgorithmException, IllegalStateException;
|
public void regeneratePlaylist(Recording recording) throws IOException, InvalidKeyException, NoSuchAlgorithmException, IllegalStateException;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue