openvidu-server: minor POST /api/recordings/start refactoring

pull/508/head
pabloFuente 2020-07-01 18:57:23 +02:00
parent 8302571924
commit 9729ef94e3
1 changed files with 7 additions and 9 deletions

View File

@ -484,17 +484,17 @@ public class SessionRestController {
HttpStatus.BAD_REQUEST); HttpStatus.BAD_REQUEST);
} }
io.openvidu.java.client.Recording.OutputMode finalOutputMode = OutputMode.COMPOSED; OutputMode finalOutputMode = OutputMode.COMPOSED;
RecordingLayout recordingLayout = null; RecordingLayout recordingLayout = null;
if (outputModeString != null && !outputModeString.isEmpty()) { if (outputModeString != null && !outputModeString.isEmpty()) {
try { try {
finalOutputMode = io.openvidu.java.client.Recording.OutputMode.valueOf(outputModeString); finalOutputMode = OutputMode.valueOf(outputModeString);
} catch (Exception e) { } catch (Exception e) {
return this.generateErrorResponse("Type error in some parameter", "/api/recordings/start", return this.generateErrorResponse("Type error in some parameter", "/api/recordings/start",
HttpStatus.BAD_REQUEST); HttpStatus.BAD_REQUEST);
} }
} }
if (io.openvidu.java.client.Recording.OutputMode.COMPOSED.equals(finalOutputMode)) { if (OutputMode.COMPOSED.equals(finalOutputMode)) {
if (resolution != null && !sessionManager.formatChecker.isAcceptableRecordingResolution(resolution)) { if (resolution != null && !sessionManager.formatChecker.isAcceptableRecordingResolution(resolution)) {
return this.generateErrorResponse( return this.generateErrorResponse(
"Wrong \"resolution\" parameter. Acceptable values from 100 to 1999 for both width and height", "Wrong \"resolution\" parameter. Acceptable values from 100 to 1999 for both width and height",
@ -544,17 +544,15 @@ public class SessionRestController {
// If outputMode is COMPOSED when defaultOutputMode is COMPOSED_QUICK_START, // If outputMode is COMPOSED when defaultOutputMode is COMPOSED_QUICK_START,
// change outputMode to COMPOSED_QUICK_START // change outputMode to COMPOSED_QUICK_START
io.openvidu.java.client.Recording.OutputMode defaultOutputMode = session.getSessionProperties().defaultOutputMode(); OutputMode defaultOutputMode = session.getSessionProperties().defaultOutputMode();
io.openvidu.java.client.Recording.OutputMode propertiesOutputMode = finalOutputMode; if (OutputMode.COMPOSED_QUICK_START.equals(defaultOutputMode) && OutputMode.COMPOSED.equals(finalOutputMode)) {
if(defaultOutputMode.equals(io.openvidu.java.client.Recording.OutputMode.COMPOSED_QUICK_START) finalOutputMode = OutputMode.COMPOSED_QUICK_START;
&& propertiesOutputMode.equals(io.openvidu.java.client.Recording.OutputMode.COMPOSED)) {
finalOutputMode = io.openvidu.java.client.Recording.OutputMode.COMPOSED_QUICK_START;
} }
RecordingProperties.Builder builder = new RecordingProperties.Builder(); RecordingProperties.Builder builder = new RecordingProperties.Builder();
builder.outputMode( builder.outputMode(
finalOutputMode == null ? session.getSessionProperties().defaultOutputMode() : finalOutputMode); finalOutputMode == null ? session.getSessionProperties().defaultOutputMode() : finalOutputMode);
if (io.openvidu.java.client.Recording.OutputMode.COMPOSED.equals(finalOutputMode)) { if (finalOutputMode.equals(OutputMode.COMPOSED)) {
if (resolution != null) { if (resolution != null) {
builder.resolution(resolution); builder.resolution(resolution);
} }