Minor fix to load default codecs from .env

pull/600/head
cruizba 2020-09-08 21:04:33 +02:00
parent daf80c0412
commit 253ba9e80f
5 changed files with 34 additions and 24 deletions

View File

@ -458,8 +458,13 @@ public class Session {
json.addProperty("defaultRecordingLayout", properties.defaultRecordingLayout().name()); json.addProperty("defaultRecordingLayout", properties.defaultRecordingLayout().name());
json.addProperty("defaultCustomLayout", properties.defaultCustomLayout()); json.addProperty("defaultCustomLayout", properties.defaultCustomLayout());
json.addProperty("customSessionId", properties.customSessionId()); json.addProperty("customSessionId", properties.customSessionId());
if (properties.forcedVideoCodec() != null) {
json.addProperty("forcedVideoCodec", properties.forcedVideoCodec().name()); json.addProperty("forcedVideoCodec", properties.forcedVideoCodec().name());
}
if (properties.isTranscodingAllowed() != null) {
json.addProperty("allowTranscoding", properties.isTranscodingAllowed()); json.addProperty("allowTranscoding", properties.isTranscodingAllowed());
}
StringEntity params = null; StringEntity params = null;
try { try {
params = new StringEntity(json.toString()); params = new StringEntity(json.toString());
@ -580,9 +585,12 @@ public class Session {
json.addProperty("defaultOutputMode", this.properties.defaultOutputMode().name()); json.addProperty("defaultOutputMode", this.properties.defaultOutputMode().name());
json.addProperty("defaultRecordingLayout", this.properties.defaultRecordingLayout().name()); json.addProperty("defaultRecordingLayout", this.properties.defaultRecordingLayout().name());
json.addProperty("defaultCustomLayout", this.properties.defaultCustomLayout()); json.addProperty("defaultCustomLayout", this.properties.defaultCustomLayout());
if(this.properties.forcedVideoCodec() != null) {
json.addProperty("forcedVideoCodec", this.properties.forcedVideoCodec().name()); json.addProperty("forcedVideoCodec", this.properties.forcedVideoCodec().name());
}
if (this.properties.isTranscodingAllowed() != null) {
json.addProperty("allowTranscoding", this.properties.isTranscodingAllowed()); json.addProperty("allowTranscoding", this.properties.isTranscodingAllowed());
}
JsonObject connections = new JsonObject(); JsonObject connections = new JsonObject();
connections.addProperty("numberOfElements", this.getActiveConnections().size()); connections.addProperty("numberOfElements", this.getActiveConnections().size());
JsonArray jsonArrayConnections = new JsonArray(); JsonArray jsonArrayConnections = new JsonArray();

View File

@ -31,7 +31,7 @@ public class SessionProperties {
private String defaultCustomLayout; private String defaultCustomLayout;
private String customSessionId; private String customSessionId;
private VideoCodec forcedVideoCodec; private VideoCodec forcedVideoCodec;
private boolean allowTranscoding; private Boolean allowTranscoding;
/** /**
* Builder for {@link io.openvidu.java.client.SessionProperties} * Builder for {@link io.openvidu.java.client.SessionProperties}
@ -44,8 +44,8 @@ public class SessionProperties {
private RecordingLayout defaultRecordingLayout = RecordingLayout.BEST_FIT; private RecordingLayout defaultRecordingLayout = RecordingLayout.BEST_FIT;
private String defaultCustomLayout = ""; private String defaultCustomLayout = "";
private String customSessionId = ""; private String customSessionId = "";
private VideoCodec forcedVideoCodec = VideoCodec.VP8; private VideoCodec forcedVideoCodec;
private boolean allowTranscoding = false; private Boolean allowTranscoding;
/** /**
* Returns the {@link io.openvidu.java.client.SessionProperties} object properly * 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. * 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. * 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 <code>false</code> and exception will occur. * is <code>false</code> and exception will occur.
* *
* If forcedVideoCodec is set to NONE, no codec will be forced. * 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 * 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. * 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; this.allowTranscoding = allowTranscoding;
return this; return this;
} }
@ -174,13 +174,12 @@ public class SessionProperties {
this.defaultRecordingLayout = RecordingLayout.BEST_FIT; this.defaultRecordingLayout = RecordingLayout.BEST_FIT;
this.defaultCustomLayout = ""; this.defaultCustomLayout = "";
this.customSessionId = ""; this.customSessionId = "";
this.forcedVideoCodec = VideoCodec.VP8;
this.allowTranscoding = false; this.allowTranscoding = false;
} }
private SessionProperties(MediaMode mediaMode, RecordingMode recordingMode, OutputMode outputMode, private SessionProperties(MediaMode mediaMode, RecordingMode recordingMode, OutputMode outputMode,
RecordingLayout layout, String defaultCustomLayout, String customSessionId, RecordingLayout layout, String defaultCustomLayout, String customSessionId,
VideoCodec forcedVideoCodec, boolean allowTranscoding) { VideoCodec forcedVideoCodec, Boolean allowTranscoding) {
this.mediaMode = mediaMode; this.mediaMode = mediaMode;
this.recordingMode = recordingMode; this.recordingMode = recordingMode;
this.defaultOutputMode = outputMode; this.defaultOutputMode = outputMode;
@ -274,7 +273,7 @@ public class SessionProperties {
* Defines if transcoding is allowed or not when {@link #forcedVideoCodec} * Defines if transcoding is allowed or not when {@link #forcedVideoCodec}
* is not a compatible codec with the browser/client. * is not a compatible codec with the browser/client.
*/ */
public boolean isTranscodingAllowed() { public Boolean isTranscodingAllowed() {
return this.allowTranscoding; return this.allowTranscoding;
} }

View File

@ -84,8 +84,8 @@ export class Session {
this.properties.recordingMode = !!this.properties.recordingMode ? this.properties.recordingMode : RecordingMode.MANUAL; 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.defaultOutputMode = !!this.properties.defaultOutputMode ? this.properties.defaultOutputMode : Recording.OutputMode.COMPOSED;
this.properties.defaultRecordingLayout = !!this.properties.defaultRecordingLayout ? this.properties.defaultRecordingLayout : RecordingLayout.BEST_FIT; this.properties.defaultRecordingLayout = !!this.properties.defaultRecordingLayout ? this.properties.defaultRecordingLayout : RecordingLayout.BEST_FIT;
this.properties.allowTranscoding = !!this.properties.allowTranscoding ? this.properties.allowTranscoding : false; this.properties.allowTranscoding = !!this.properties.allowTranscoding ? this.properties.allowTranscoding : null;
this.properties.forcedVideoCodec = !!this.properties.forcedVideoCodec ? this.properties.forcedVideoCodec : VideoCodec.VP8; 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, defaultRecordingLayout: !!this.properties.defaultRecordingLayout ? this.properties.defaultRecordingLayout : RecordingLayout.BEST_FIT,
defaultCustomLayout: !!this.properties.defaultCustomLayout ? this.properties.defaultCustomLayout : '', defaultCustomLayout: !!this.properties.defaultCustomLayout ? this.properties.defaultCustomLayout : '',
customSessionId: !!this.properties.customSessionId ? this.properties.customSessionId : '', customSessionId: !!this.properties.customSessionId ? this.properties.customSessionId : '',
forcedVideoCodec: !!this.properties.forcedVideoCodec ? this.properties.forcedVideoCodec : VideoCodec.VP8, forcedVideoCodec: !!this.properties.forcedVideoCodec ? this.properties.forcedVideoCodec : null,
allowTranscoding: !!this.properties.allowTranscoding ? this.properties.allowTranscoding : false allowTranscoding: !!this.properties.allowTranscoding ? this.properties.allowTranscoding : null
}); });
@ -473,8 +473,8 @@ export class Session {
recordingMode: json.recordingMode, recordingMode: json.recordingMode,
defaultOutputMode: json.defaultOutputMode, defaultOutputMode: json.defaultOutputMode,
defaultRecordingLayout: json.defaultRecordingLayout, defaultRecordingLayout: json.defaultRecordingLayout,
forcedVideoCodec: !!json.forcedVideoCodec ? json.forcedVideoCodec : VideoCodec.VP8, forcedVideoCodec: !!json.forcedVideoCodec ? json.forcedVideoCodec : null,
allowTranscoding: !!json.allowTranscoding ? json.allowTranscoding : false allowTranscoding: !!json.allowTranscoding ? json.allowTranscoding : null
}; };
if (!!customSessionId) { if (!!customSessionId) {
this.properties.customSessionId = customSessionId; this.properties.customSessionId = customSessionId;

View File

@ -2162,10 +2162,13 @@ public class OpenViduTestAppE2eTest {
SessionProperties properties = new SessionProperties.Builder().customSessionId(customSessionId) SessionProperties properties = new SessionProperties.Builder().customSessionId(customSessionId)
.mediaMode(MediaMode.ROUTED).recordingMode(RecordingMode.ALWAYS) .mediaMode(MediaMode.ROUTED).recordingMode(RecordingMode.ALWAYS)
.defaultOutputMode(OutputMode.INDIVIDUAL).build(); .defaultOutputMode(OutputMode.INDIVIDUAL)
.forcedVideoCodec(VideoCodec.VP8)
.allowTranscoding(false)
.build();
Session session = OV.createSession(properties); 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()); Assert.assertFalse("OpenVidu.fetch() should return false after OpenVidu.createSession()", OV.fetch());
sessions = OV.getActiveSessions(); sessions = OV.getActiveSessions();
Assert.assertEquals("Expected 1 active session but found " + sessions.size(), 1, sessions.size()); 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()); Assert.assertEquals("Wrong HTTP status on OpenVidu.startRecording()", 404, e.getStatus());
} }
Session sessionAux = OV.createSession(); Session sessionAux = OV.createSession();
Assert.assertFalse("OpenVidu.fetch() should return false", OV.fetch()); Assert.assertTrue("OpenVidu.fetch() should return true", OV.fetch());
try { try {
OV.startRecording(sessionAux.getSessionId()); OV.startRecording(sessionAux.getSessionId());
} catch (OpenViduHttpException e) { } catch (OpenViduHttpException e) {

View File

@ -94,8 +94,8 @@ export class OpenviduInstanceComponent implements OnInit, OnChanges, OnDestroy {
defaultRecordingLayout: RecordingLayout.BEST_FIT, defaultRecordingLayout: RecordingLayout.BEST_FIT,
defaultCustomLayout: '', defaultCustomLayout: '',
customSessionId: '', customSessionId: '',
forcedVideoCodec: VideoCodec.VP8, forcedVideoCodec: null,
allowTranscoding: false allowTranscoding: null
}; };
publisherProperties: PublisherProperties = { publisherProperties: PublisherProperties = {