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("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();

View File

@ -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 <code>false</code> 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;
}

View File

@ -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;

View File

@ -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) {

View File

@ -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 = {