openvidu-server: update SessionRestController#initializeConnection

pull/553/head
pabloFuente 2020-10-23 11:51:47 +02:00
parent c17265a9b0
commit cf5d1f7cdf
3 changed files with 20 additions and 14 deletions

View File

@ -56,7 +56,8 @@ public class ConnectionProperties {
* have effect:
* <ul>
* <li>{@link io.openvidu.java.client.ConnectionType#WEBRTC}:
* {@link io.openvidu.java.client.ConnectionProperties.Builder#data(String) data},
* {@link io.openvidu.java.client.ConnectionProperties.Builder#data(String)
* data},
* {@link io.openvidu.java.client.ConnectionProperties.Builder#record(boolean)
* record},
* {@link io.openvidu.java.client.ConnectionProperties.Builder#role(OpenViduRole)
@ -64,7 +65,8 @@ public class ConnectionProperties {
* {@link io.openvidu.java.client.ConnectionProperties.Builder#kurentoOptions(KurentoOptions)
* kurentoOptions}</li>
* <li>{@link io.openvidu.java.client.ConnectionType#IPCAM}:
* {@link io.openvidu.java.client.ConnectionProperties.Builder#data(String) data},
* {@link io.openvidu.java.client.ConnectionProperties.Builder#data(String)
* data},
* {@link io.openvidu.java.client.ConnectionProperties.Builder#record(boolean)
* record},
* {@link io.openvidu.java.client.ConnectionProperties.Builder#rtspUri(String)
@ -248,8 +250,12 @@ public class ConnectionProperties {
}
/**
* Whether the streams published by this Connection will be recorded or not.
* This only affects <a href=
* <a href="https://docs.openvidu.io/en/stable/openvidu-pro/" target="_blank"
* style="display: inline-block; background-color: rgb(0, 136, 170); color:
* white; font-weight: bold; padding: 0px 5px; margin-right: 5px; border-radius:
* 3px; font-size: 13px; line-height:21px; font-family: Montserrat,
* sans-serif">PRO</a> Whether the streams published by this Connection will be
* recorded or not. This only affects <a href=
* "https://docs.openvidu.io/en/stable/advanced-features/recording#selecting-streams-to-be-recorded"
* target="_blank">INDIVIDUAL recording</a>.
*/

View File

@ -39,6 +39,8 @@ export interface ConnectionProperties {
data?: string;
/**
* **This feature is part of OpenVidu Pro tier** <a href="https://docs.openvidu.io/en/stable/openvidu-pro/" target="_blank" style="display: inline-block; background-color: rgb(0, 136, 170); color: white; font-weight: bold; padding: 0px 5px; margin-right: 5px; border-radius: 3px; font-size: 13px; line-height:21px; font-family: Montserrat, sans-serif">PRO</a>
*
* Whether to record the streams published by this Connection or not. This only affects [INDIVIDUAL recording](/en/stable/advanced-features/recording#selecting-streams-to-be-recorded)
*
* @default true

View File

@ -284,7 +284,7 @@ public class SessionRestController {
ConnectionProperties connectionProperties;
try {
connectionProperties = getConnectionPropertiesFromParams(params);
connectionProperties = getConnectionPropertiesFromParams(params).build();
} catch (Exception e) {
return this.generateErrorResponse(e.getMessage(), "/sessions/" + sessionId + "/connection",
HttpStatus.BAD_REQUEST);
@ -660,7 +660,7 @@ public class SessionRestController {
ConnectionProperties connectionProperties;
params.remove("record");
try {
connectionProperties = getConnectionPropertiesFromParams(params);
connectionProperties = getConnectionPropertiesFromParams(params).build();
} catch (Exception e) {
return this.generateErrorResponse(e.getMessage(), "/sessions/" + sessionId + "/connection",
HttpStatus.BAD_REQUEST);
@ -787,8 +787,9 @@ public class SessionRestController {
// While closing a session tokens can't be generated
if (session.closingLock.readLock().tryLock()) {
try {
Token token = sessionManager.newToken(session, connectionProperties.getRole(), connectionProperties.getData(),
connectionProperties.record(), connectionProperties.getKurentoOptions());
Token token = sessionManager.newToken(session, connectionProperties.getRole(),
connectionProperties.getData(), connectionProperties.record(),
connectionProperties.getKurentoOptions());
return new ResponseEntity<>(token.toJsonAsParticipant().toString(), RestUtils.getResponseHeaders(),
HttpStatus.OK);
} catch (Exception e) {
@ -858,17 +859,15 @@ public class SessionRestController {
return token;
}
protected ConnectionProperties getConnectionPropertiesFromParams(Map<?, ?> params) throws Exception {
protected ConnectionProperties.Builder getConnectionPropertiesFromParams(Map<?, ?> params) throws Exception {
ConnectionProperties.Builder builder = new ConnectionProperties.Builder();
String typeString;
String data;
Boolean record;
try {
typeString = (String) params.get("type");
data = (String) params.get("data");
record = (Boolean) params.get("record");
} catch (ClassCastException e) {
throw new Exception("Type error in some parameter: " + e.getMessage());
}
@ -884,10 +883,9 @@ public class SessionRestController {
throw new Exception("Parameter 'type' " + typeString + " is not defined");
}
data = data != null ? data : "";
record = record != null ? record : true;
// Build COMMON options
builder.type(type).data(data).record(record);
builder.type(type).data(data).record(true);
OpenViduRole role = null;
KurentoOptions kurentoOptions = null;
@ -974,7 +972,7 @@ public class SessionRestController {
.onlyPlayWithSubscribers(onlyPlayWithSubscribers).networkCache(networkCache).build();
}
return builder.build();
return builder;
}
protected ResponseEntity<String> generateErrorResponse(String errorMessage, String path, HttpStatus status) {