From f1da7245332ed9042f2b2a81cb63186894a83d1b Mon Sep 17 00:00:00 2001 From: pabloFuente Date: Tue, 11 May 2021 12:28:41 +0200 Subject: [PATCH] New RecordingProperty ignoreFailedStreams --- .../java/client/RecordingProperties.java | 75 +++++++++++++++++-- .../recording/service/RecordingManager.java | 3 +- .../service/SingleStreamRecordingService.java | 13 +++- .../e2e/AbstractOpenViduTestAppE2eTest.java | 2 +- 4 files changed, 80 insertions(+), 13 deletions(-) diff --git a/openvidu-java-client/src/main/java/io/openvidu/java/client/RecordingProperties.java b/openvidu-java-client/src/main/java/io/openvidu/java/client/RecordingProperties.java index 85138180..8ec22466 100644 --- a/openvidu-java-client/src/main/java/io/openvidu/java/client/RecordingProperties.java +++ b/openvidu-java-client/src/main/java/io/openvidu/java/client/RecordingProperties.java @@ -35,6 +35,7 @@ public class RecordingProperties { public static final String resolution = "1280x720"; public static final Integer frameRate = 25; public static final Long shmSize = 536870912L; + public static final Boolean ignoreFailedStreams = false; } // For all @@ -49,6 +50,8 @@ public class RecordingProperties { private Long shmSize; // For COMPOSED/COMPOSED_QUICK_START + hasVideo + RecordingLayout.CUSTOM private String customLayout; + // For INDIVIDUAL + private Boolean ignoreFailedStreams; // For OpenVidu Pro private String mediaNode; @@ -58,14 +61,15 @@ public class RecordingProperties { public static class Builder { private String name = ""; - private Boolean hasAudio = true; - private Boolean hasVideo = true; - private Recording.OutputMode outputMode = Recording.OutputMode.COMPOSED; + private Boolean hasAudio = DefaultValues.hasAudio; + private Boolean hasVideo = DefaultValues.hasVideo; + private Recording.OutputMode outputMode = DefaultValues.outputMode; private RecordingLayout recordingLayout; private String resolution; private Integer frameRate; private Long shmSize; private String customLayout; + private Boolean ignoreFailedStreams = DefaultValues.ignoreFailedStreams; private String mediaNode; public Builder() { @@ -81,6 +85,7 @@ public class RecordingProperties { this.frameRate = props.frameRate(); this.shmSize = props.shmSize(); this.customLayout = props.customLayout(); + this.ignoreFailedStreams = props.ignoreFailedStreams(); this.mediaNode = props.mediaNode(); } @@ -90,7 +95,7 @@ public class RecordingProperties { public RecordingProperties build() { return new RecordingProperties(this.name, this.hasAudio, this.hasVideo, this.outputMode, this.recordingLayout, this.resolution, this.frameRate, this.shmSize, this.customLayout, - this.mediaNode); + this.ignoreFailedStreams, this.mediaNode); } /** @@ -206,6 +211,27 @@ public class RecordingProperties { return this; } + /** + * Call this method to specify whether to ignore failed streams or not when + * starting the recording. This property only applies to + * {@link io.openvidu.java.client.Recording.OutputMode#INDIVIDUAL} recordings. + * For this type of recordings, when calling + * {@link io.openvidu.java.client.OpenVidu#startRecording} by default all the + * streams available at the moment the recording process starts must be healthy + * and properly sending media. If some stream that should be sending media is + * broken, then the recording process fails after a 10s timeout. In this way + * your application is notified that some stream is not being recorded, so it + * can retry the process again. But you can disable this rollback behavior and + * simply ignore any failed stream, which will be susceptible to be recorded in + * the future if media starts flowing as expected at any point. The downside of + * this behavior is that you will have no guarantee that all streams present at + * the beginning of a recording are actually being recorded. + */ + public RecordingProperties.Builder ignoreFailedStreams(boolean ignoreFailedStreams) { + this.ignoreFailedStreams = ignoreFailedStreams; + return this; + } + /** * PRO Call this method to force the recording to be hosted in * the Media Node with identifier mediaNodeId. This property only - * applies to COMPOSED or COMPOSED_QUICK_START recordings with - * {@link RecordingProperties#hasVideo()} to true and is ignored for INDIVIDUAL + * applies to {@link io.openvidu.java.client.Recording.OutputMode#COMPOSED} or + * {@link io.openvidu.java.client.Recording.OutputMode#COMPOSED_QUICK_START} + * recordings with {@link RecordingProperties#hasVideo()} to true and is ignored + * for {@link io.openvidu.java.client.Recording.OutputMode#INDIVIDUAL} * recordings and audio-only recordings, that are always hosted in the same * Media Node hosting its Session */ @@ -227,7 +255,7 @@ public class RecordingProperties { protected RecordingProperties(String name, Boolean hasAudio, Boolean hasVideo, Recording.OutputMode outputMode, RecordingLayout layout, String resolution, Integer frameRate, Long shmSize, String customLayout, - String mediaNode) { + Boolean ignoreFailedStreams, String mediaNode) { this.name = name != null ? name : ""; this.hasAudio = hasAudio != null ? hasAudio : DefaultValues.hasAudio; this.hasVideo = hasVideo != null ? hasVideo : DefaultValues.hasVideo; @@ -242,6 +270,9 @@ public class RecordingProperties { this.customLayout = customLayout; } } + if (OutputMode.INDIVIDUAL.equals(this.outputMode)) { + this.ignoreFailedStreams = ignoreFailedStreams; + } this.mediaNode = mediaNode; } @@ -366,6 +397,29 @@ public class RecordingProperties { return this.customLayout; } + /** + * Defines whether to ignore failed streams or not when starting the recording. + * This property only applies to + * {@link io.openvidu.java.client.Recording.OutputMode#INDIVIDUAL} recordings. + * For this type of recordings, when calling + * {@link io.openvidu.java.client.OpenVidu#startRecording} by default all the + * streams available at the moment the recording process starts must be healthy + * and properly sending media. If some stream that should be sending media is + * broken, then the recording process fails after a 10s timeout. In this way + * your application is notified that some stream is not being recorded, so it + * can retry the process again. But you can disable this rollback behavior and + * simply ignore any failed stream, which will be susceptible to be recorded in + * the future if media starts flowing as expected at any point. The downside of + * this behavior is that you will have no guarantee that all streams present at + * the beginning of a recording are actually being recorded.
+ *
+ * + * Default to false + */ + public Boolean ignoreFailedStreams() { + return this.ignoreFailedStreams; + } + /** *