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 if [ -z "$HAS_VIDEO_AUX" ]; then HAS_VIDEO=false; else HAS_VIDEO=true; fi
SIZE=$(echo $INFO | jq '.format.size | tonumber') SIZE=$(echo $INFO | jq '.format.size | tonumber')
DURATION=$(echo $INFO | jq '.format.duration | tonumber') DURATION=$(echo $INFO | jq '.format.duration | tonumber')
if [[ "$HAS_AUDIO" == false && "$HAS_VIDEO" == false ]]
then
STATUS="failed"
else
STATUS="stopped" 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 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 ### ### Generate video thumbnail ###

View File

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