openvidu-java-client: resolution and layout only if "hasVideo"

pull/203/head
pabloFuente 2019-01-28 16:10:12 +01:00
parent b6a200170f
commit 89af604433
2 changed files with 104 additions and 109 deletions

View File

@ -75,11 +75,9 @@ public class OpenVidu {
protected final static String API_RECORDINGS_STOP = "/stop"; protected final static String API_RECORDINGS_STOP = "/stop";
/** /**
* @param urlOpenViduServer * @param urlOpenViduServer Public accessible IP where your instance of OpenVidu
* Public accessible IP where your instance of OpenVidu Server is up * Server is up an running
* an running * @param secret Secret used on OpenVidu Server initialization
* @param secret
* Secret used on OpenVidu Server initialization
*/ */
public OpenVidu(String urlOpenViduServer, String secret) { public OpenVidu(String urlOpenViduServer, String secret) {
@ -136,20 +134,19 @@ public class OpenVidu {
/** /**
* Creates an OpenVidu session * Creates an OpenVidu session
* *
* @param properties * @param properties The specific configuration for this session
* The specific configuration for this session
* *
* @return The created session * @return The created session
* *
* @throws OpenViduJavaClientException * @throws OpenViduJavaClientException
* @throws OpenViduHttpException * @throws OpenViduHttpException Value returned from
* Value returned from * {@link io.openvidu.java.client.OpenViduHttpException#getStatus()}
* {@link io.openvidu.java.client.OpenViduHttpException#getStatus()} * <ul>
* <ul> * <li><code>409</code>: you are trying to
* <li><code>409</code>: you are trying to assign an already-in-use * assign an already-in-use custom sessionId
* custom sessionId to the session. See * to the session. See
* {@link io.openvidu.java.client.SessionProperties#customSessionId()}</li> * {@link io.openvidu.java.client.SessionProperties#customSessionId()}</li>
* </ul> * </ul>
*/ */
public Session createSession(SessionProperties properties) public Session createSession(SessionProperties properties)
throws OpenViduJavaClientException, OpenViduHttpException { throws OpenViduJavaClientException, OpenViduHttpException {
@ -161,29 +158,28 @@ public class OpenVidu {
/** /**
* Starts the recording of a {@link io.openvidu.java.client.Session} * Starts the recording of a {@link io.openvidu.java.client.Session}
* *
* @param sessionId * @param sessionId The sessionId of the session you want to start recording
* The sessionId of the session you want to start recording * @param properties The configuration for this recording
* @param properties
* The configuration for this recording
* *
* @return The new created session * @return The new created session
* *
* @throws OpenViduJavaClientException * @throws OpenViduJavaClientException
* @throws OpenViduHttpException * @throws OpenViduHttpException Value returned from
* Value returned from * {@link io.openvidu.java.client.OpenViduHttpException#getStatus()}
* {@link io.openvidu.java.client.OpenViduHttpException#getStatus()} * <ul>
* <ul> * <li><code>404</code>: no session exists
* <li><code>404</code>: no session exists for the passed * for the passed <i>sessionId</i></li>
* <i>sessionId</i></li> * <li><code>400</code>: the session has no
* <li><code>400</code>: the session has no connected * connected participants</li>
* participants</li> * <li><code>409</code>: the session is not
* <li><code>409</code>: the session is not configured for using * configured for using
* {@link io.openvidu.java.client.MediaMode#ROUTED} or it is already * {@link io.openvidu.java.client.MediaMode#ROUTED}
* being recorded</li> * or it is already being recorded</li>
* <li><code>501</code>: OpenVidu Server recording module is * <li><code>501</code>: OpenVidu Server
* disabled (<i>openvidu.recording</i> property set to * recording module is disabled
* <i>false</i>)</li> * (<i>openvidu.recording</i> property set
* </ul> * to <i>false</i>)</li>
* </ul>
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public Recording startRecording(String sessionId, RecordingProperties properties) public Recording startRecording(String sessionId, RecordingProperties properties)
@ -198,7 +194,7 @@ public class OpenVidu {
json.put("hasAudio", properties.hasAudio()); json.put("hasAudio", properties.hasAudio());
json.put("hasVideo", properties.hasVideo()); json.put("hasVideo", properties.hasVideo());
if (Recording.OutputMode.COMPOSED.equals(properties.outputMode())) { if (Recording.OutputMode.COMPOSED.equals(properties.outputMode()) && properties.hasVideo()) {
json.put("resolution", properties.resolution()); json.put("resolution", properties.resolution());
json.put("recordingLayout", json.put("recordingLayout",
(properties.recordingLayout() != null) ? properties.recordingLayout().name() : ""); (properties.recordingLayout() != null) ? properties.recordingLayout().name() : "");
@ -247,35 +243,35 @@ public class OpenVidu {
/** /**
* Starts the recording of a {@link io.openvidu.java.client.Session} * Starts the recording of a {@link io.openvidu.java.client.Session}
* *
* @param sessionId * @param sessionId The sessionId of the session you want to start recording
* The sessionId of the session you want to start recording * @param name The name you want to give to the video file. You can access
* @param name * this same value in your clients on recording events
* The name you want to give to the video file. You can access this * (recordingStarted, recordingStopped). <strong>WARNING: this
* same value in your clients on recording events (recordingStarted, * parameter follows an overwriting policy.</strong> If you
* recordingStopped). <strong>WARNING: this parameter follows an * name two recordings the same, the newest MP4 file will
* overwriting policy.</strong> If you name two recordings the same, * overwrite the oldest one
* the newest MP4 file will overwrite the oldest one
* *
* @return The started recording. If this method successfully returns the * @return The started recording. If this method successfully returns the
* Recording object it means that the recording can be stopped with * Recording object it means that the recording can be stopped with
* guarantees * guarantees
* *
* @throws OpenViduJavaClientException * @throws OpenViduJavaClientException
* @throws OpenViduHttpException * @throws OpenViduHttpException Value returned from
* Value returned from * {@link io.openvidu.java.client.OpenViduHttpException#getStatus()}
* {@link io.openvidu.java.client.OpenViduHttpException#getStatus()} * <ul>
* <ul> * <li><code>404</code>: no session exists
* <li><code>404</code>: no session exists for the passed * for the passed <i>sessionId</i></li>
* <i>sessionId</i></li> * <li><code>400</code>: the session has no
* <li><code>400</code>: the session has no connected * connected participants</li>
* participants</li> * <li><code>409</code>: the session is not
* <li><code>409</code>: the session is not configured for using * configured for using
* {@link io.openvidu.java.client.MediaMode#ROUTED} or it is already * {@link io.openvidu.java.client.MediaMode#ROUTED}
* being recorded</li> * or it is already being recorded</li>
* <li><code>501</code>: OpenVidu Server recording module is * <li><code>501</code>: OpenVidu Server
* disabled (<i>openvidu.recording</i> property set to * recording module is disabled
* <i>false</i>)</li> * (<i>openvidu.recording</i> property set
* </ul> * to <i>false</i>)</li>
* </ul>
*/ */
public Recording startRecording(String sessionId, String name) public Recording startRecording(String sessionId, String name)
throws OpenViduJavaClientException, OpenViduHttpException { throws OpenViduJavaClientException, OpenViduHttpException {
@ -288,29 +284,29 @@ public class OpenVidu {
/** /**
* Starts the recording of a {@link io.openvidu.java.client.Session} * Starts the recording of a {@link io.openvidu.java.client.Session}
* *
* @param sessionId * @param sessionId The sessionId of the session you want to start recording
* The sessionId of the session you want to start recording
* *
* @return The started recording. If this method successfully returns the * @return The started recording. If this method successfully returns the
* Recording object it means that the recording can be stopped with * Recording object it means that the recording can be stopped with
* guarantees * guarantees
* *
* @throws OpenViduJavaClientException * @throws OpenViduJavaClientException
* @throws OpenViduHttpException * @throws OpenViduHttpException Value returned from
* Value returned from * {@link io.openvidu.java.client.OpenViduHttpException#getStatus()}
* {@link io.openvidu.java.client.OpenViduHttpException#getStatus()} * <ul>
* <ul> * <li><code>404</code>: no session exists
* <li><code>404</code>: no session exists for the passed * for the passed <i>sessionId</i></li>
* <i>sessionId</i></li> * <li><code>400</code>: the session has no
* <li><code>400</code>: the session has no connected * connected participants</li>
* participants</li> * <li><code>409</code>: the session is not
* <li><code>409</code>: the session is not configured for using * configured for using
* {@link io.openvidu.java.client.MediaMode#ROUTED} or it is already * {@link io.openvidu.java.client.MediaMode#ROUTED}
* being recorded</li> * or it is already being recorded</li>
* <li><code>501</code>: OpenVidu Server recording module is * <li><code>501</code>: OpenVidu Server
* disabled (<i>openvidu.recording</i> property set to * recording module is disabled
* <i>false</i>)</li> * (<i>openvidu.recording</i> property set
* </ul> * to <i>false</i>)</li>
* </ul>
*/ */
public Recording startRecording(String sessionId) throws OpenViduJavaClientException, OpenViduHttpException { public Recording startRecording(String sessionId) throws OpenViduJavaClientException, OpenViduHttpException {
return this.startRecording(sessionId, ""); return this.startRecording(sessionId, "");
@ -319,21 +315,21 @@ public class OpenVidu {
/** /**
* Stops the recording of a {@link io.openvidu.java.client.Session} * Stops the recording of a {@link io.openvidu.java.client.Session}
* *
* @param recordingId * @param recordingId The id property of the recording you want to stop
* The id property of the recording you want to stop
* *
* @return The stopped recording * @return The stopped recording
* *
* @throws OpenViduJavaClientException * @throws OpenViduJavaClientException
* @throws OpenViduHttpException * @throws OpenViduHttpException Value returned from
* Value returned from * {@link io.openvidu.java.client.OpenViduHttpException#getStatus()}
* {@link io.openvidu.java.client.OpenViduHttpException#getStatus()} * <ul>
* <ul> * <li><code>404</code>: no recording exists
* <li><code>404</code>: no recording exists for the passed * for the passed <i>recordingId</i></li>
* <i>recordingId</i></li> * <li><code>406</code>: recording has
* <li><code>406</code>: recording has <i>starting</i> status. Wait * <i>starting</i> status. Wait until
* until <i>started</i> status before stopping the recording</li> * <i>started</i> status before stopping the
* </ul> * recording</li>
* </ul>
*/ */
public Recording stopRecording(String recordingId) throws OpenViduJavaClientException, OpenViduHttpException { public Recording stopRecording(String recordingId) throws OpenViduJavaClientException, OpenViduHttpException {
HttpPost request = new HttpPost( HttpPost request = new HttpPost(
@ -368,17 +364,15 @@ public class OpenVidu {
/** /**
* Gets an existing recording * Gets an existing recording
* *
* @param recordingId * @param recordingId The id property of the recording you want to retrieve
* The id property of the recording you want to retrieve
* *
* @throws OpenViduJavaClientException * @throws OpenViduJavaClientException
* @throws OpenViduHttpException * @throws OpenViduHttpException Value returned from
* Value returned from * {@link io.openvidu.java.client.OpenViduHttpException#getStatus()}
* {@link io.openvidu.java.client.OpenViduHttpException#getStatus()} * <ul>
* <ul> * <li><code>404</code>: no recording exists
* <li><code>404</code>: no recording exists for the passed * for the passed <i>recordingId</i></li>
* <i>recordingId</i></li> * </ul>
* </ul>
*/ */
public Recording getRecording(String recordingId) throws OpenViduJavaClientException, OpenViduHttpException { public Recording getRecording(String recordingId) throws OpenViduJavaClientException, OpenViduHttpException {
HttpGet request = new HttpGet(OpenVidu.urlOpenViduServer + API_RECORDINGS + "/" + recordingId); HttpGet request = new HttpGet(OpenVidu.urlOpenViduServer + API_RECORDINGS + "/" + recordingId);
@ -442,19 +436,18 @@ public class OpenVidu {
* {@link io.openvidu.java.client.Recording.Status#stopped} or * {@link io.openvidu.java.client.Recording.Status#stopped} or
* {@link io.openvidu.java.client.Recording.Status#available} * {@link io.openvidu.java.client.Recording.Status#available}
* *
* @param recordingId * @param recordingId The id property of the recording you want to delete
* The id property of the recording you want to delete
* *
* @throws OpenViduJavaClientException * @throws OpenViduJavaClientException
* @throws OpenViduHttpException * @throws OpenViduHttpException Value returned from
* Value returned from * {@link io.openvidu.java.client.OpenViduHttpException#getStatus()}
* {@link io.openvidu.java.client.OpenViduHttpException#getStatus()} * <ul>
* <ul> * <li><code>404</code>: no recording exists
* <li><code>404</code>: no recording exists for the passed * for the passed <i>recordingId</i></li>
* <i>recordingId</i></li> * <li><code>409</code>: the recording has
* <li><code>409</code>: the recording has <i>started</i> status. * <i>started</i> status. Stop it before
* Stop it before deletion</li> * deletion</li>
* </ul> * </ul>
*/ */
public void deleteRecording(String recordingId) throws OpenViduJavaClientException, OpenViduHttpException { public void deleteRecording(String recordingId) throws OpenViduJavaClientException, OpenViduHttpException {
HttpDelete request = new HttpDelete(OpenVidu.urlOpenViduServer + API_RECORDINGS + "/" + recordingId); HttpDelete request = new HttpDelete(OpenVidu.urlOpenViduServer + API_RECORDINGS + "/" + recordingId);

View File

@ -94,11 +94,13 @@ public class Recording {
this.url = (String) json.get("url"); this.url = (String) json.get("url");
this.status = Recording.Status.valueOf((String) json.get("status")); this.status = Recording.Status.valueOf((String) json.get("status"));
boolean hasAudio = (boolean) json.get("hasAudio");
boolean hasVideo = (boolean) json.get("hasVideo");
OutputMode outputMode = OutputMode.valueOf((String) json.get("outputMode")); OutputMode outputMode = OutputMode.valueOf((String) json.get("outputMode"));
RecordingProperties.Builder builder = new RecordingProperties.Builder().name((String) json.get("name")) RecordingProperties.Builder builder = new RecordingProperties.Builder().name((String) json.get("name"))
.outputMode(outputMode).hasAudio((boolean) json.get("hasAudio")) .outputMode(outputMode).hasAudio(hasAudio).hasVideo(hasVideo);
.hasVideo((boolean) json.get("hasVideo")); if (OutputMode.COMPOSED.equals(outputMode) && hasVideo) {
if (OutputMode.COMPOSED.equals(outputMode)) {
builder.resolution((String) json.get("resolution")); builder.resolution((String) json.get("resolution"));
builder.recordingLayout(RecordingLayout.valueOf((String) json.get("recordingLayout"))); builder.recordingLayout(RecordingLayout.valueOf((String) json.get("recordingLayout")));
String customLayout = (String) json.get("customLayout"); String customLayout = (String) json.get("customLayout");