openvidu recording container: set status failed if no media tracks

pull/203/head
pabloFuente 2019-02-06 16:10:57 +01:00
parent c332612b7d
commit a719b73e5e
2 changed files with 17 additions and 10 deletions

View File

@ -88,7 +88,14 @@ HAS_VIDEO_AUX=$(echo $INFO | jq '.streams[] | select(.codec_type == "video")')
if [ -z "$HAS_VIDEO_AUX" ]; then HAS_VIDEO=false; else HAS_VIDEO=true; fi
SIZE=$(echo $INFO | jq '.format.size | tonumber')
DURATION=$(echo $INFO | jq '.format.duration | tonumber')
STATUS="stopped"
if [[ "$HAS_AUDIO" == false && "$HAS_VIDEO" == false ]]
then
STATUS="failed"
else
STATUS="stopped"
fi
jq -c -r ".hasAudio=$HAS_AUDIO | .hasVideo=$HAS_VIDEO | .duration=$DURATION | .size=$SIZE | .status=\"$STATUS\"" "/recordings/$VIDEO_ID/.recording.$VIDEO_ID" > $TMP && mv $TMP /recordings/$VIDEO_ID/.recording.$VIDEO_ID
### Generate video thumbnail ###

View File

@ -284,14 +284,14 @@ public class ComposedRecordingService extends RecordingService {
try {
stopped = latch.await(60, TimeUnit.SECONDS);
} catch (InterruptedException e) {
recording.setStatus(io.openvidu.java.client.Recording.Status.failed);
failRecordingCompletion(containerId, new OpenViduException(Code.RECORDING_COMPLETION_ERROR_CODE,
"The recording completion process has been unexpectedly interrupted"));
failRecordingCompletion(recording, containerId,
new OpenViduException(Code.RECORDING_COMPLETION_ERROR_CODE,
"The recording completion process has been unexpectedly interrupted"));
}
if (!stopped) {
recording.setStatus(io.openvidu.java.client.Recording.Status.failed);
failRecordingCompletion(containerId, new OpenViduException(Code.RECORDING_COMPLETION_ERROR_CODE,
"The recording completion process couldn't finish in 60 seconds"));
failRecordingCompletion(recording, containerId,
new OpenViduException(Code.RECORDING_COMPLETION_ERROR_CODE,
"The recording completion process couldn't finish in 60 seconds"));
}
// Remove container
@ -305,8 +305,6 @@ public class ComposedRecordingService extends RecordingService {
if (!infoUtils.hasVideo()) {
log.error("COMPOSED recording {} with hasVideo=true has not video track", recordingId);
recording.setStatus(io.openvidu.java.client.Recording.Status.failed);
recording.setHasAudio(false);
recording.setHasVideo(false);
} else {
recording.setStatus(io.openvidu.java.client.Recording.Status.stopped);
recording.setDuration(infoUtils.getDurationInSeconds());
@ -441,7 +439,9 @@ public class ComposedRecordingService extends RecordingService {
}
}
private void failRecordingCompletion(String containerId, OpenViduException e) throws OpenViduException {
private void failRecordingCompletion(Recording recording, String containerId, OpenViduException e)
throws OpenViduException {
recording.setStatus(io.openvidu.java.client.Recording.Status.failed);
this.stopDockerContainer(containerId);
this.removeDockerContainer(containerId);
throw e;