use of co.videofirst.vft.capture.exception.InvalidStateException in project vft-capture by videofirst.
the class DefaultCaptureService method record.
@Override
public CaptureStatus record() {
if (captureStatus.getState() != CaptureState.started) {
throw new InvalidStateException("Current state is '" + captureStatus.getState() + "' - " + "video can only be recoded when state is 'started'.");
}
DisplayUpdate displayUpdate = getDisplayUpdate();
captureStatus = captureStatus.record(displayUpdate.getCapture());
videoRecorder.record(getVideoRecord());
refreshDisplay();
return status();
}
use of co.videofirst.vft.capture.exception.InvalidStateException in project vft-capture by videofirst.
the class DefaultUploadService method upload.
// Methods from `UploadService`
@Override
public void upload(String captureId) {
if (!uploadConfig.isEnable()) {
throw new VideoUploadException("Please enable upload configuration (i.e. set `vft_config.upload.enable` property to `true`)");
}
Capture capture = getCapture(captureId);
// Check capture is finished i.e. the `finished` timestamp is set.
if (capture.getFinished() == null) {
throw new InvalidStateException("You can only upload a capture which is finished. Please try again later.");
}
// Mark capture that it's scheduled for upload
Upload upload = Upload.schedule(uploadConfig.getUrl());
capture.setUpload(upload);
captureDao.save(capture);
uploads.put(captureId, capture);
queue.add(capture);
}
Aggregations