From 253ba9e80fcd574a2f08f29bbc3d473af10ae19c Mon Sep 17 00:00:00 2001 From: cruizba Date: Tue, 8 Sep 2020 21:04:33 +0200 Subject: [PATCH] Minor fix to load default codecs from .env --- .../java/io/openvidu/java/client/Session.java | 18 +++++++++++++----- .../java/client/SessionProperties.java | 15 +++++++-------- openvidu-node-client/src/Session.ts | 12 ++++++------ .../test/e2e/OpenViduTestAppE2eTest.java | 9 ++++++--- .../openvidu-instance.component.ts | 4 ++-- 5 files changed, 34 insertions(+), 24 deletions(-) diff --git a/openvidu-java-client/src/main/java/io/openvidu/java/client/Session.java b/openvidu-java-client/src/main/java/io/openvidu/java/client/Session.java index 8b7da5d8..a5d0574f 100644 --- a/openvidu-java-client/src/main/java/io/openvidu/java/client/Session.java +++ b/openvidu-java-client/src/main/java/io/openvidu/java/client/Session.java @@ -458,8 +458,13 @@ public class Session { json.addProperty("defaultRecordingLayout", properties.defaultRecordingLayout().name()); json.addProperty("defaultCustomLayout", properties.defaultCustomLayout()); json.addProperty("customSessionId", properties.customSessionId()); - json.addProperty("forcedVideoCodec", properties.forcedVideoCodec().name()); - json.addProperty("allowTranscoding", properties.isTranscodingAllowed()); + if (properties.forcedVideoCodec() != null) { + json.addProperty("forcedVideoCodec", properties.forcedVideoCodec().name()); + } + if (properties.isTranscodingAllowed() != null) { + json.addProperty("allowTranscoding", properties.isTranscodingAllowed()); + } + StringEntity params = null; try { params = new StringEntity(json.toString()); @@ -580,9 +585,12 @@ public class Session { json.addProperty("defaultOutputMode", this.properties.defaultOutputMode().name()); json.addProperty("defaultRecordingLayout", this.properties.defaultRecordingLayout().name()); json.addProperty("defaultCustomLayout", this.properties.defaultCustomLayout()); - json.addProperty("forcedVideoCodec", this.properties.forcedVideoCodec().name()); - json.addProperty("allowTranscoding", this.properties.isTranscodingAllowed()); - + if(this.properties.forcedVideoCodec() != null) { + json.addProperty("forcedVideoCodec", this.properties.forcedVideoCodec().name()); + } + if (this.properties.isTranscodingAllowed() != null) { + json.addProperty("allowTranscoding", this.properties.isTranscodingAllowed()); + } JsonObject connections = new JsonObject(); connections.addProperty("numberOfElements", this.getActiveConnections().size()); JsonArray jsonArrayConnections = new JsonArray(); diff --git a/openvidu-java-client/src/main/java/io/openvidu/java/client/SessionProperties.java b/openvidu-java-client/src/main/java/io/openvidu/java/client/SessionProperties.java index 0f5ae90f..ef50557f 100644 --- a/openvidu-java-client/src/main/java/io/openvidu/java/client/SessionProperties.java +++ b/openvidu-java-client/src/main/java/io/openvidu/java/client/SessionProperties.java @@ -31,7 +31,7 @@ public class SessionProperties { private String defaultCustomLayout; private String customSessionId; private VideoCodec forcedVideoCodec; - private boolean allowTranscoding; + private Boolean allowTranscoding; /** * Builder for {@link io.openvidu.java.client.SessionProperties} @@ -44,8 +44,8 @@ public class SessionProperties { private RecordingLayout defaultRecordingLayout = RecordingLayout.BEST_FIT; private String defaultCustomLayout = ""; private String customSessionId = ""; - private VideoCodec forcedVideoCodec = VideoCodec.VP8; - private boolean allowTranscoding = false; + private VideoCodec forcedVideoCodec; + private Boolean allowTranscoding; /** * Returns the {@link io.openvidu.java.client.SessionProperties} object properly @@ -146,7 +146,7 @@ public class SessionProperties { /** * Call this method to define which video codec do you want to be forcibly used for this session. * This allows browsers/clients to use the same codec avoiding transcoding in the media server. - * If the browser/client is not compatible with the specified codec and {@link #allowTranscoding(boolean)} + * If the browser/client is not compatible with the specified codec and {@link #allowTranscoding(Boolean)} * is false and exception will occur. * * If forcedVideoCodec is set to NONE, no codec will be forced. @@ -160,7 +160,7 @@ public class SessionProperties { * Call this method to define if you want to allow transcoding in the media server or not * when {@link #forcedVideoCodec(VideoCodec)} is not compatible with the browser/client. */ - public SessionProperties.Builder allowTranscoding(boolean allowTranscoding) { + public SessionProperties.Builder allowTranscoding(Boolean allowTranscoding) { this.allowTranscoding = allowTranscoding; return this; } @@ -174,13 +174,12 @@ public class SessionProperties { this.defaultRecordingLayout = RecordingLayout.BEST_FIT; this.defaultCustomLayout = ""; this.customSessionId = ""; - this.forcedVideoCodec = VideoCodec.VP8; this.allowTranscoding = false; } private SessionProperties(MediaMode mediaMode, RecordingMode recordingMode, OutputMode outputMode, RecordingLayout layout, String defaultCustomLayout, String customSessionId, - VideoCodec forcedVideoCodec, boolean allowTranscoding) { + VideoCodec forcedVideoCodec, Boolean allowTranscoding) { this.mediaMode = mediaMode; this.recordingMode = recordingMode; this.defaultOutputMode = outputMode; @@ -274,7 +273,7 @@ public class SessionProperties { * Defines if transcoding is allowed or not when {@link #forcedVideoCodec} * is not a compatible codec with the browser/client. */ - public boolean isTranscodingAllowed() { + public Boolean isTranscodingAllowed() { return this.allowTranscoding; } diff --git a/openvidu-node-client/src/Session.ts b/openvidu-node-client/src/Session.ts index 3b5b4486..7435b5f4 100644 --- a/openvidu-node-client/src/Session.ts +++ b/openvidu-node-client/src/Session.ts @@ -84,8 +84,8 @@ export class Session { this.properties.recordingMode = !!this.properties.recordingMode ? this.properties.recordingMode : RecordingMode.MANUAL; this.properties.defaultOutputMode = !!this.properties.defaultOutputMode ? this.properties.defaultOutputMode : Recording.OutputMode.COMPOSED; this.properties.defaultRecordingLayout = !!this.properties.defaultRecordingLayout ? this.properties.defaultRecordingLayout : RecordingLayout.BEST_FIT; - this.properties.allowTranscoding = !!this.properties.allowTranscoding ? this.properties.allowTranscoding : false; - this.properties.forcedVideoCodec = !!this.properties.forcedVideoCodec ? this.properties.forcedVideoCodec : VideoCodec.VP8; + this.properties.allowTranscoding = !!this.properties.allowTranscoding ? this.properties.allowTranscoding : null; + this.properties.forcedVideoCodec = !!this.properties.forcedVideoCodec ? this.properties.forcedVideoCodec : null; } /** @@ -405,8 +405,8 @@ export class Session { defaultRecordingLayout: !!this.properties.defaultRecordingLayout ? this.properties.defaultRecordingLayout : RecordingLayout.BEST_FIT, defaultCustomLayout: !!this.properties.defaultCustomLayout ? this.properties.defaultCustomLayout : '', customSessionId: !!this.properties.customSessionId ? this.properties.customSessionId : '', - forcedVideoCodec: !!this.properties.forcedVideoCodec ? this.properties.forcedVideoCodec : VideoCodec.VP8, - allowTranscoding: !!this.properties.allowTranscoding ? this.properties.allowTranscoding : false + forcedVideoCodec: !!this.properties.forcedVideoCodec ? this.properties.forcedVideoCodec : null, + allowTranscoding: !!this.properties.allowTranscoding ? this.properties.allowTranscoding : null }); @@ -473,8 +473,8 @@ export class Session { recordingMode: json.recordingMode, defaultOutputMode: json.defaultOutputMode, defaultRecordingLayout: json.defaultRecordingLayout, - forcedVideoCodec: !!json.forcedVideoCodec ? json.forcedVideoCodec : VideoCodec.VP8, - allowTranscoding: !!json.allowTranscoding ? json.allowTranscoding : false + forcedVideoCodec: !!json.forcedVideoCodec ? json.forcedVideoCodec : null, + allowTranscoding: !!json.allowTranscoding ? json.allowTranscoding : null }; if (!!customSessionId) { this.properties.customSessionId = customSessionId; diff --git a/openvidu-test-e2e/src/test/java/io/openvidu/test/e2e/OpenViduTestAppE2eTest.java b/openvidu-test-e2e/src/test/java/io/openvidu/test/e2e/OpenViduTestAppE2eTest.java index 36bc9dbd..7f838043 100644 --- a/openvidu-test-e2e/src/test/java/io/openvidu/test/e2e/OpenViduTestAppE2eTest.java +++ b/openvidu-test-e2e/src/test/java/io/openvidu/test/e2e/OpenViduTestAppE2eTest.java @@ -2162,10 +2162,13 @@ public class OpenViduTestAppE2eTest { SessionProperties properties = new SessionProperties.Builder().customSessionId(customSessionId) .mediaMode(MediaMode.ROUTED).recordingMode(RecordingMode.ALWAYS) - .defaultOutputMode(OutputMode.INDIVIDUAL).build(); + .defaultOutputMode(OutputMode.INDIVIDUAL) + .forcedVideoCodec(VideoCodec.VP8) + .allowTranscoding(false) + .build(); Session session = OV.createSession(properties); - Assert.assertFalse("Session.fetch() should return false after OpenVidu.createSession()", session.fetch()); + Assert.assertFalse("Session.fetch() should return true after OpenVidu.createSession() because some default properties are created in the server", session.fetch()); Assert.assertFalse("OpenVidu.fetch() should return false after OpenVidu.createSession()", OV.fetch()); sessions = OV.getActiveSessions(); Assert.assertEquals("Expected 1 active session but found " + sessions.size(), 1, sessions.size()); @@ -2354,7 +2357,7 @@ public class OpenViduTestAppE2eTest { Assert.assertEquals("Wrong HTTP status on OpenVidu.startRecording()", 404, e.getStatus()); } Session sessionAux = OV.createSession(); - Assert.assertFalse("OpenVidu.fetch() should return false", OV.fetch()); + Assert.assertTrue("OpenVidu.fetch() should return true", OV.fetch()); try { OV.startRecording(sessionAux.getSessionId()); } catch (OpenViduHttpException e) { diff --git a/openvidu-testapp/src/app/components/openvidu-instance/openvidu-instance.component.ts b/openvidu-testapp/src/app/components/openvidu-instance/openvidu-instance.component.ts index fc324f9f..d5a4b454 100644 --- a/openvidu-testapp/src/app/components/openvidu-instance/openvidu-instance.component.ts +++ b/openvidu-testapp/src/app/components/openvidu-instance/openvidu-instance.component.ts @@ -94,8 +94,8 @@ export class OpenviduInstanceComponent implements OnInit, OnChanges, OnDestroy { defaultRecordingLayout: RecordingLayout.BEST_FIT, defaultCustomLayout: '', customSessionId: '', - forcedVideoCodec: VideoCodec.VP8, - allowTranscoding: false + forcedVideoCodec: null, + allowTranscoding: null }; publisherProperties: PublisherProperties = {