mirror of https://github.com/OpenVidu/openvidu.git
openvidu-server: parameterized shmSize on POST /api/recordings/start
parent
a4fcf90745
commit
37c05cb82a
|
@ -32,6 +32,7 @@ public class RecordingProperties {
|
|||
private String resolution;
|
||||
private boolean hasAudio;
|
||||
private boolean hasVideo;
|
||||
private long shmSize; // For COMPOSED recording
|
||||
|
||||
/**
|
||||
* Builder for {@link io.openvidu.java.client.RecordingProperties}
|
||||
|
@ -45,6 +46,7 @@ public class RecordingProperties {
|
|||
private String resolution;
|
||||
private boolean hasAudio = true;
|
||||
private boolean hasVideo = true;
|
||||
private long shmSize = 536870912L;
|
||||
|
||||
/**
|
||||
* Builder for {@link io.openvidu.java.client.RecordingProperties}
|
||||
|
@ -58,7 +60,7 @@ public class RecordingProperties {
|
|||
}
|
||||
}
|
||||
return new RecordingProperties(this.name, this.outputMode, this.recordingLayout, this.customLayout,
|
||||
this.resolution, this.hasAudio, this.hasVideo);
|
||||
this.resolution, this.hasAudio, this.hasVideo, this.shmSize);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -145,10 +147,20 @@ public class RecordingProperties {
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* If COMPOSED recording, call this method to specify the amount of shared
|
||||
* memory reserved for the recording process in bytes. Minimum 134217728 (128
|
||||
* MB). Property ignored if INDIVIDUAL recording
|
||||
*/
|
||||
public RecordingProperties.Builder shmSize(long shmSize) {
|
||||
this.shmSize = shmSize;
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected RecordingProperties(String name, Recording.OutputMode outputMode, RecordingLayout layout,
|
||||
String customLayout, String resolution, boolean hasAudio, boolean hasVideo) {
|
||||
String customLayout, String resolution, boolean hasAudio, boolean hasVideo, long shmSize) {
|
||||
this.name = name;
|
||||
this.outputMode = outputMode;
|
||||
this.recordingLayout = layout;
|
||||
|
@ -156,6 +168,7 @@ public class RecordingProperties {
|
|||
this.resolution = resolution;
|
||||
this.hasAudio = hasAudio;
|
||||
this.hasVideo = hasVideo;
|
||||
this.shmSize = shmSize;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -242,4 +255,16 @@ public class RecordingProperties {
|
|||
return this.hasVideo;
|
||||
}
|
||||
|
||||
/**
|
||||
* If COMPOSED recording, the amount of shared memory reserved for the recording
|
||||
* process in bytes. Minimum 134217728 (128MB). Property ignored if INDIVIDUAL
|
||||
* recording<br>
|
||||
* <br>
|
||||
*
|
||||
* Default to 536870912 (512 MB)
|
||||
*/
|
||||
public long shmSize() {
|
||||
return this.shmSize;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -175,7 +175,7 @@ public class ComposedRecordingService extends RecordingService {
|
|||
List<Bind> binds = new ArrayList<>();
|
||||
binds.add(bind1);
|
||||
containerId = dockerManager.runContainer(container, containerName, null, volumes, binds, "host", envs, null,
|
||||
536870912L, false, null);
|
||||
properties.shmSize(), false, null);
|
||||
containers.put(containerId, containerName);
|
||||
} catch (Exception e) {
|
||||
this.cleanRecordingMaps(recording);
|
||||
|
|
|
@ -149,6 +149,7 @@ public abstract class RecordingService {
|
|||
if (RecordingLayout.CUSTOM.equals(properties.recordingLayout())) {
|
||||
builder.customLayout(properties.customLayout());
|
||||
}
|
||||
builder.shmSize(properties.shmSize());
|
||||
}
|
||||
properties = builder.build();
|
||||
}
|
||||
|
|
|
@ -460,6 +460,7 @@ public class SessionRestController {
|
|||
Boolean hasVideo;
|
||||
String recordingLayoutString;
|
||||
String customLayout;
|
||||
Long shmSize;
|
||||
try {
|
||||
sessionId = (String) params.get("session");
|
||||
name = (String) params.get("name");
|
||||
|
@ -469,7 +470,8 @@ public class SessionRestController {
|
|||
hasVideo = (Boolean) params.get("hasVideo");
|
||||
recordingLayoutString = (String) params.get("recordingLayout");
|
||||
customLayout = (String) params.get("customLayout");
|
||||
} catch (ClassCastException e) {
|
||||
shmSize = new Long(params.get("shmSize").toString());
|
||||
} catch (ClassCastException | NumberFormatException e) {
|
||||
return this.generateErrorResponse("Type error in some parameter", "/api/recordings/start",
|
||||
HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
|
@ -480,7 +482,7 @@ public class SessionRestController {
|
|||
HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
|
||||
io.openvidu.java.client.Recording.OutputMode finalOutputMode = null;
|
||||
io.openvidu.java.client.Recording.OutputMode finalOutputMode = OutputMode.COMPOSED;
|
||||
RecordingLayout recordingLayout = null;
|
||||
if (outputModeString != null && !outputModeString.isEmpty()) {
|
||||
try {
|
||||
|
@ -551,6 +553,13 @@ public class SessionRestController {
|
|||
builder.customLayout(
|
||||
customLayout == null ? session.getSessionProperties().defaultCustomLayout() : customLayout);
|
||||
}
|
||||
if (shmSize != null) {
|
||||
if (shmSize < 134217728L) {
|
||||
return this.generateErrorResponse("Wrong \"shmSize\" parameter. Must be 134217728 (128 MB) minimum",
|
||||
"/api/recordings/start", HttpStatus.UNPROCESSABLE_ENTITY);
|
||||
}
|
||||
builder.shmSize(shmSize);
|
||||
}
|
||||
}
|
||||
builder.name(name).hasAudio(hasAudio != null ? hasAudio : true).hasVideo(hasVideo != null ? hasVideo : true);
|
||||
|
||||
|
|
Loading…
Reference in New Issue