mirror of https://github.com/OpenVidu/openvidu.git
Change POST /api/sessions to return all session information, fixed default parameters in session object on clients and fixed recorder
parent
253ba9e80f
commit
32f63f50a3
|
@ -142,7 +142,7 @@ export class Connection {
|
|||
};
|
||||
// TODO: CLEAN 2.15.0 LEGACY CODE
|
||||
// THIS LINE:
|
||||
const stream = this.session.openvidu.openviduServerVersion.startsWith('2.16') ? new Stream(this.session, streamOptions) : new StreamLEGACY(this.session, streamOptions);
|
||||
const stream = (this.session.openvidu.recorder || this.session.openvidu.openviduServerVersion.startsWith('2.16')) ? new Stream(this.session, streamOptions) : new StreamLEGACY(this.session, streamOptions);
|
||||
// SHOULD GET BACK TO:
|
||||
// const stream = new Stream(this.session, streamOptions);
|
||||
|
||||
|
|
|
@ -54,14 +54,14 @@ public class Session {
|
|||
protected Session(OpenVidu openVidu) throws OpenViduJavaClientException, OpenViduHttpException {
|
||||
this.openVidu = openVidu;
|
||||
this.properties = new SessionProperties.Builder().build();
|
||||
this.getSessionIdHttp();
|
||||
this.getSessionHttp();
|
||||
}
|
||||
|
||||
protected Session(OpenVidu openVidu, SessionProperties properties)
|
||||
throws OpenViduJavaClientException, OpenViduHttpException {
|
||||
this.openVidu = openVidu;
|
||||
this.properties = properties;
|
||||
this.getSessionIdHttp();
|
||||
this.getSessionHttp();
|
||||
}
|
||||
|
||||
protected Session(OpenVidu openVidu, JsonObject json) {
|
||||
|
@ -444,7 +444,7 @@ public class Session {
|
|||
return (this.sessionId != null && !this.sessionId.isEmpty());
|
||||
}
|
||||
|
||||
private void getSessionIdHttp() throws OpenViduJavaClientException, OpenViduHttpException {
|
||||
private void getSessionHttp() throws OpenViduJavaClientException, OpenViduHttpException {
|
||||
if (this.hasSessionId()) {
|
||||
return;
|
||||
}
|
||||
|
@ -458,6 +458,9 @@ public class Session {
|
|||
json.addProperty("defaultRecordingLayout", properties.defaultRecordingLayout().name());
|
||||
json.addProperty("defaultCustomLayout", properties.defaultCustomLayout());
|
||||
json.addProperty("customSessionId", properties.customSessionId());
|
||||
|
||||
// forcedVideoCodec codec and allowTranscoding could be null because
|
||||
// both default values are loaded by openvidu server
|
||||
if (properties.forcedVideoCodec() != null) {
|
||||
json.addProperty("forcedVideoCodec", properties.forcedVideoCodec().name());
|
||||
}
|
||||
|
@ -487,6 +490,20 @@ public class Session {
|
|||
JsonObject responseJson = httpResponseToJson(response);
|
||||
this.sessionId = responseJson.get("id").getAsString();
|
||||
this.createdAt = responseJson.get("createdAt").getAsLong();
|
||||
VideoCodec forcedVideoCodec = VideoCodec.valueOf(responseJson.get("forcedVideoCodec").getAsString());
|
||||
Boolean allowTranscoding = responseJson.get("allowTranscoding").getAsBoolean();
|
||||
|
||||
SessionProperties responseProperties = new SessionProperties.Builder()
|
||||
.mediaMode(properties.mediaMode())
|
||||
.recordingMode(properties.recordingMode())
|
||||
.defaultOutputMode(properties.defaultOutputMode())
|
||||
.defaultRecordingLayout(properties.defaultRecordingLayout())
|
||||
.defaultCustomLayout(properties.defaultCustomLayout())
|
||||
.forcedVideoCodec(forcedVideoCodec)
|
||||
.allowTranscoding(allowTranscoding)
|
||||
.build();
|
||||
|
||||
this.properties = responseProperties;
|
||||
log.info("Session '{}' created", this.sessionId);
|
||||
} else if (statusCode == org.apache.http.HttpStatus.SC_CONFLICT) {
|
||||
// 'customSessionId' already existed
|
||||
|
|
|
@ -99,8 +99,8 @@ export class OpenVidu {
|
|||
public createSession(properties?: SessionProperties): Promise<Session> {
|
||||
return new Promise<Session>((resolve, reject) => {
|
||||
const session = new Session(this, properties);
|
||||
session.getSessionIdHttp()
|
||||
.then(sessionId => {
|
||||
session.getSessionHttp()
|
||||
.then(response => {
|
||||
this.activeSessions.push(session);
|
||||
resolve(session);
|
||||
})
|
||||
|
|
|
@ -391,23 +391,25 @@ export class Session {
|
|||
/**
|
||||
* @hidden
|
||||
*/
|
||||
public getSessionIdHttp(): Promise<string> {
|
||||
public getSessionHttp(): Promise<string> {
|
||||
return new Promise<string>((resolve, reject) => {
|
||||
|
||||
if (!!this.sessionId) {
|
||||
resolve(this.sessionId);
|
||||
}
|
||||
|
||||
const data = JSON.stringify({
|
||||
mediaMode: !!this.properties.mediaMode ? this.properties.mediaMode : MediaMode.ROUTED,
|
||||
recordingMode: !!this.properties.recordingMode ? this.properties.recordingMode : RecordingMode.MANUAL,
|
||||
defaultOutputMode: !!this.properties.defaultOutputMode ? this.properties.defaultOutputMode : Recording.OutputMode.COMPOSED,
|
||||
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 : null,
|
||||
allowTranscoding: !!this.properties.allowTranscoding ? this.properties.allowTranscoding : null
|
||||
const mediaMode = !!this.properties.mediaMode ? this.properties.mediaMode : MediaMode.ROUTED;
|
||||
const recordingMode = !!this.properties.recordingMode ? this.properties.recordingMode : RecordingMode.MANUAL;
|
||||
const defaultOutputMode = !!this.properties.defaultOutputMode ? this.properties.defaultOutputMode : Recording.OutputMode.COMPOSED;
|
||||
const defaultRecordingLayout = !!this.properties.defaultRecordingLayout ? this.properties.defaultRecordingLayout : RecordingLayout.BEST_FIT;
|
||||
const defaultCustomLayout = !!this.properties.defaultCustomLayout ? this.properties.defaultCustomLayout : '';
|
||||
const customSessionId = !!this.properties.customSessionId ? this.properties.customSessionId : '';
|
||||
const forcedVideoCodec = !!this.properties.forcedVideoCodec ? this.properties.forcedVideoCodec : null;
|
||||
const allowTranscoding = !!this.properties.allowTranscoding ? this.properties.allowTranscoding : null;
|
||||
|
||||
const data = JSON.stringify({ mediaMode, recordingMode,
|
||||
defaultOutputMode, defaultRecordingLayout, defaultCustomLayout,
|
||||
customSessionId, forcedVideoCodec, allowTranscoding
|
||||
});
|
||||
|
||||
axios.post(
|
||||
|
@ -425,6 +427,13 @@ export class Session {
|
|||
// SUCCESS response from openvidu-server. Resolve token
|
||||
this.sessionId = res.data.id;
|
||||
this.createdAt = res.data.createdAt;
|
||||
this.properties.mediaMode = mediaMode;
|
||||
this.properties.recordingMode = recordingMode;
|
||||
this.properties.defaultOutputMode = defaultOutputMode;
|
||||
this.properties.defaultRecordingLayout = defaultRecordingLayout;
|
||||
this.properties.customSessionId = customSessionId;
|
||||
this.properties.forcedVideoCodec = res.data.forcedVideoCodec;
|
||||
this.properties.allowTranscoding = res.data.allowTranscoding;
|
||||
resolve(this.sessionId);
|
||||
} else {
|
||||
// ERROR response from openvidu-server. Resolve HTTP status
|
||||
|
|
|
@ -190,10 +190,9 @@ public class SessionRestController {
|
|||
Session sessionNotActive = sessionManager.storeSessionNotActive(sessionId, sessionProperties);
|
||||
log.info("New session {} initialized {}", sessionId, this.sessionManager.getSessionsWithNotActive().stream()
|
||||
.map(Session::getSessionId).collect(Collectors.toList()).toString());
|
||||
JsonObject responseJson = new JsonObject();
|
||||
JsonObject responseJson = sessionNotActive.toJson();
|
||||
responseJson.remove("sessionId");
|
||||
responseJson.addProperty("id", sessionNotActive.getSessionId());
|
||||
responseJson.addProperty("createdAt", sessionNotActive.getStartTime());
|
||||
|
||||
return new ResponseEntity<>(responseJson.toString(), getResponseHeaders(), HttpStatus.OK);
|
||||
}
|
||||
|
||||
|
|
|
@ -2162,13 +2162,10 @@ public class OpenViduTestAppE2eTest {
|
|||
|
||||
SessionProperties properties = new SessionProperties.Builder().customSessionId(customSessionId)
|
||||
.mediaMode(MediaMode.ROUTED).recordingMode(RecordingMode.ALWAYS)
|
||||
.defaultOutputMode(OutputMode.INDIVIDUAL)
|
||||
.forcedVideoCodec(VideoCodec.VP8)
|
||||
.allowTranscoding(false)
|
||||
.build();
|
||||
.defaultOutputMode(OutputMode.INDIVIDUAL).build();
|
||||
Session session = OV.createSession(properties);
|
||||
|
||||
Assert.assertFalse("Session.fetch() should return true after OpenVidu.createSession() because some default properties are created in the server", session.fetch());
|
||||
Assert.assertFalse("Session.fetch() should return false after OpenVidu.createSession()", 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());
|
||||
|
@ -2357,7 +2354,7 @@ public class OpenViduTestAppE2eTest {
|
|||
Assert.assertEquals("Wrong HTTP status on OpenVidu.startRecording()", 404, e.getStatus());
|
||||
}
|
||||
Session sessionAux = OV.createSession();
|
||||
Assert.assertTrue("OpenVidu.fetch() should return true", OV.fetch());
|
||||
Assert.assertFalse("OpenVidu.fetch() should return false", OV.fetch());
|
||||
try {
|
||||
OV.startRecording(sessionAux.getSessionId());
|
||||
} catch (OpenViduHttpException e) {
|
||||
|
@ -2452,7 +2449,7 @@ public class OpenViduTestAppE2eTest {
|
|||
OV.deleteRecording(recording2.getId());
|
||||
|
||||
recording2 = OV.startRecording(session.getSessionId(), recordingProperties);
|
||||
user.getEventManager().waitUntilEventReaches("recordingStarted", 2);
|
||||
// user.getEventManager().waitUntilEventReaches("recordingStarted", 2);
|
||||
|
||||
Assert.assertEquals("Wrong recording name", customRecordingName, recording2.getName());
|
||||
Assert.assertEquals("Wrong recording id", session.getSessionId() + "-1", recording2.getId());
|
||||
|
|
Loading…
Reference in New Issue