diff --git a/openvidu-java-client/README.md b/openvidu-java-client/README.md index 74ff3366..88a70673 100644 --- a/openvidu-java-client/README.md +++ b/openvidu-java-client/README.md @@ -7,7 +7,7 @@ openvidu-java-client === -- **Description**: Library for your JAVA server. It makes easier the retrieval of the necessary params from OpenVidu Server for securing your application (_sessionId_'s and _token_'s). It is a simple alternative to the REST API. +- **Description**: Library for your JAVA server. It is a fully compatible and simple alternative to the REST API exposed by OpenVidu Server. - **Docs**: [openvidu-java-client API](http://openvidu.io/docs/reference-docs/openvidu-java-client/) diff --git a/openvidu-java-client/pom.xml b/openvidu-java-client/pom.xml index b0907f30..97bd6bb9 100644 --- a/openvidu-java-client/pom.xml +++ b/openvidu-java-client/pom.xml @@ -97,9 +97,9 @@ org.apache.maven.plugins maven-javadoc-plugin - 2.10.4 + 3.0.0 - + public @@ -131,7 +131,10 @@ org.apache.maven.plugins maven-javadoc-plugin - 2.10.4 + 3.0.0 + + public + attach-javadocs @@ -161,10 +164,10 @@ 1.6.8 true - ossrh - https://oss.sonatype.org/ - true - + ossrh + https://oss.sonatype.org/ + true + maven-resources-plugin diff --git a/openvidu-java-client/src/main/java/io/openvidu/java/client/MediaMode.java b/openvidu-java-client/src/main/java/io/openvidu/java/client/MediaMode.java index ca0ce726..70cf8e81 100644 --- a/openvidu-java-client/src/main/java/io/openvidu/java/client/MediaMode.java +++ b/openvidu-java-client/src/main/java/io/openvidu/java/client/MediaMode.java @@ -18,6 +18,14 @@ package io.openvidu.java.client; public enum MediaMode { - RELAYED, // The session will attempt to transmit streams directly between clients - ROUTED // The session will transmit streams using OpenVidu Media Server + /** + * (not available yet) The session will attempt to transmit streams + * directly between clients + */ + RELAYED, + + /** + * The session will transmit streams using OpenVidu Media Server + */ + ROUTED } diff --git a/openvidu-java-client/src/main/java/io/openvidu/java/client/OpenVidu.java b/openvidu-java-client/src/main/java/io/openvidu/java/client/OpenVidu.java index f55d802f..988c46ce 100644 --- a/openvidu-java-client/src/main/java/io/openvidu/java/client/OpenVidu.java +++ b/openvidu-java-client/src/main/java/io/openvidu/java/client/OpenVidu.java @@ -61,6 +61,13 @@ public class OpenVidu { final static String API_RECORDINGS_START = "/start"; final static String API_RECORDINGS_STOP = "/stop"; + /** + * @param urlOpenViduServer + * Public accessible IP where your instance of OpenVidu Server is up + * an running + * @param secret + * Secret used on OpenVidu Server initialization + */ public OpenVidu(String urlOpenViduServer, String secret) { this.urlOpenViduServer = urlOpenViduServer; @@ -105,6 +112,20 @@ public class OpenVidu { return s; } + /** + * Starts the recording of a {@link io.openvidu.java.client.Session} + * + * @param sessionId + * 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 this + * same value in your clients on recording events (recordingStarted, + * recordingStopped) + * @param properties + * The configuration for this recording + * + * @return The new created session + */ @SuppressWarnings("unchecked") public Recording startRecording(String sessionId, RecordingProperties properties) throws OpenViduException { try { @@ -115,8 +136,7 @@ public class OpenVidu { json.put("name", properties.name()); json.put("recordingLayout", (properties.recordingLayout() != null) ? properties.recordingLayout().name() : ""); - json.put("customLayout", - (properties.customLayout() != null) ? properties.customLayout() : ""); + json.put("customLayout", (properties.customLayout() != null) ? properties.customLayout() : ""); StringEntity params = new StringEntity(json.toString()); request.setHeader(HttpHeaders.CONTENT_TYPE, "application/json"); @@ -126,7 +146,7 @@ public class OpenVidu { int statusCode = response.getStatusLine().getStatusCode(); if ((statusCode == org.apache.http.HttpStatus.SC_OK)) { - return new Recording(OpenVidu.httpResponseToJson(response)); + return new Recording(httpResponseToJson(response)); } else { throw new OpenViduException(Code.RECORDING_START_ERROR_CODE, Integer.toString(statusCode)); } @@ -136,6 +156,20 @@ public class OpenVidu { } } + /** + * Starts the recording of a {@link io.openvidu.java.client.Session} + * + * @param sessionId + * 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 this + * same value in your clients on recording events (recordingStarted, + * recordingStopped) + * + * @return The started recording. If this method successfully returns the + * Recording object it means that the recording can be stopped with + * guarantees + */ public Recording startRecording(String sessionId, String name) throws OpenViduException { if (name == null) { name = ""; @@ -143,10 +177,28 @@ public class OpenVidu { return this.startRecording(sessionId, new RecordingProperties.Builder().name(name).build()); } + /** + * Starts the recording of a {@link io.openvidu.java.client.Session} + * + * @param sessionId + * The sessionId of the session you want to start recording + * + * @return The started recording. If this method successfully returns the + * Recording object it means that the recording can be stopped with + * guarantees + */ public Recording startRecording(String sessionId) throws OpenViduException { return this.startRecording(sessionId, ""); } + /** + * Stops the recording of a {@link io.openvidu.java.client.Session} + * + * @param recordingId + * The id property of the recording you want to stop + * + * @return The stopped recording + */ public Recording stopRecording(String recordingId) throws OpenViduException { try { HttpPost request = new HttpPost( @@ -155,7 +207,7 @@ public class OpenVidu { int statusCode = response.getStatusLine().getStatusCode(); if ((statusCode == org.apache.http.HttpStatus.SC_OK)) { - return new Recording(OpenVidu.httpResponseToJson(response)); + return new Recording(httpResponseToJson(response)); } else { throw new OpenViduException(Code.RECORDING_STOP_ERROR_CODE, Integer.toString(statusCode)); } @@ -165,6 +217,12 @@ public class OpenVidu { } } + /** + * Gets an existing recording + * + * @param recordingId + * The id property of the recording you want to retrieve + */ public Recording getRecording(String recordingId) throws OpenViduException { try { HttpGet request = new HttpGet(this.urlOpenViduServer + API_RECORDINGS + "/" + recordingId); @@ -172,7 +230,7 @@ public class OpenVidu { int statusCode = response.getStatusLine().getStatusCode(); if ((statusCode == org.apache.http.HttpStatus.SC_OK)) { - return new Recording(OpenVidu.httpResponseToJson(response)); + return new Recording(httpResponseToJson(response)); } else { throw new OpenViduException(Code.RECORDING_LIST_ERROR_CODE, Integer.toString(statusCode)); } @@ -182,6 +240,11 @@ public class OpenVidu { } } + /** + * Lists all existing recordings + * + * @return A {@link java.util.List} with all existing recordings + */ @SuppressWarnings("unchecked") public List listRecordings() throws OpenViduException { try { @@ -191,7 +254,7 @@ public class OpenVidu { int statusCode = response.getStatusLine().getStatusCode(); if ((statusCode == org.apache.http.HttpStatus.SC_OK)) { List recordings = new ArrayList<>(); - JSONObject json = OpenVidu.httpResponseToJson(response); + JSONObject json = httpResponseToJson(response); JSONArray array = (JSONArray) json.get("items"); array.forEach(item -> { recordings.add(new Recording((JSONObject) item)); @@ -205,6 +268,13 @@ public class OpenVidu { } } + /** + * Deletes a recording. The recording must have status + * {@link io.openvidu.java.client.Recording.Status#stopped} or + * {@link io.openvidu.java.client.Recording.Status#available} + * + * @param recordingId + */ public void deleteRecording(String recordingId) throws OpenViduException { try { HttpDelete request = new HttpDelete(this.urlOpenViduServer + API_RECORDINGS + "/" + recordingId); @@ -220,7 +290,7 @@ public class OpenVidu { } } - public static JSONObject httpResponseToJson(HttpResponse response) throws ParseException, IOException { + private JSONObject httpResponseToJson(HttpResponse response) throws ParseException, IOException { JSONParser parser = new JSONParser(); return (JSONObject) parser.parse(EntityUtils.toString(response.getEntity())); } diff --git a/openvidu-java-client/src/main/java/io/openvidu/java/client/OpenViduRole.java b/openvidu-java-client/src/main/java/io/openvidu/java/client/OpenViduRole.java index e180fcec..360a672b 100644 --- a/openvidu-java-client/src/main/java/io/openvidu/java/client/OpenViduRole.java +++ b/openvidu-java-client/src/main/java/io/openvidu/java/client/OpenViduRole.java @@ -18,7 +18,21 @@ package io.openvidu.java.client; public enum OpenViduRole { - SUBSCRIBER, // Can subscribe to published streams of other users - PUBLISHER, // SUBSCRIBER permissions + can subscribe to published streams of other users and publish their own streams - MODERATOR; // SUBSCRIBER + PUBLIHSER permissions + can force unpublish() and disconnect() over a third-party stream or user + + /** + * Can subscribe to published streams of other users + */ + SUBSCRIBER, + + /** + * SUBSCRIBER permissions + can publish their own streams + */ + PUBLISHER, + + /** + * (not available yet) SUBSCRIBER and PUBLIHSER permissions + can force + * unpublish() and disconnect() over a third-party + * stream or user + */ + MODERATOR; } diff --git a/openvidu-java-client/src/main/java/io/openvidu/java/client/Recording.java b/openvidu-java-client/src/main/java/io/openvidu/java/client/Recording.java index 9d04be07..3f0c88a6 100644 --- a/openvidu-java-client/src/main/java/io/openvidu/java/client/Recording.java +++ b/openvidu-java-client/src/main/java/io/openvidu/java/client/Recording.java @@ -22,12 +22,35 @@ import org.json.simple.JSONObject; public class Recording { public enum Status { - starting, // The recording is starting (cannot be stopped) - started, // The recording has started and is going on - stopped, // The recording has finished OK - available, // The recording is available for downloading. This status is reached for all - // stopped recordings if property 'openvidu.recording.free-access' is true - failed; // The recording has failed + + /** + * The recording is starting (cannot be stopped) + */ + starting, + + /** + * The recording has started and is going on + */ + started, + + /** + * The recording has finished OK + */ + stopped, + + /** + * The recording is available for downloading. This status is reached for all + * stopped recordings if + * OpenVidu Server configuration property + * openvidu.recording.free-access is true + */ + available, + + /** + * The recording has failed + */ + failed; } private Recording.Status status; @@ -53,49 +76,90 @@ public class Recording { this.hasVideo = (boolean) json.get("hasVideo"); this.status = Recording.Status.valueOf((String) json.get("status")); this.recordingProperties = new RecordingProperties.Builder().name((String) json.get("name")) - .recordingLayout(RecordingLayout.valueOf((String) json.get("layout"))).build(); + .recordingLayout(RecordingLayout.valueOf((String) json.get("recordingLayout"))).build(); } + /** + * Status of the recording + */ public Recording.Status getStatus() { return status; } + /** + * Recording unique identifier + */ public String getId() { return id; } + /** + * Name of the recording. The video file will be named after this property. You + * can access this same value in your clients on recording events + * (recordingStarted, recordingStopped) + */ public String getName() { return this.recordingProperties.name(); } - public RecordingLayout getLayout() { + /** + * The layout used in this recording + */ + public RecordingLayout getRecordingLayout() { return this.recordingProperties.recordingLayout(); } + /** + * Session associated to the recording + */ public String getSessionId() { return sessionId; } + /** + * Time when the recording started in UTC milliseconds + */ public long getCreatedAt() { return createdAt; } + /** + * Size of the recording in bytes (0 until the recording is stopped) + */ public long getSize() { return size; } + /** + * Duration of the recording in seconds (0 until the recording is stopped) + */ public double getDuration() { return duration; } + /** + * URL of the recording. You can access the file from there. It is + * null until recording is stopped or if + * OpenVidu Server configuration property + * openvidu.recording.public-access is false + */ public String getUrl() { return url; } + /** + * true if the recording has an audio track, false + * otherwise (currently fixed to true) + */ public boolean hasAudio() { return hasAudio; } + /** + * true if the recording has a video track, false + * otherwise (currently fixed to true) + */ public boolean hasVideo() { return hasVideo; } diff --git a/openvidu-java-client/src/main/java/io/openvidu/java/client/RecordingLayout.java b/openvidu-java-client/src/main/java/io/openvidu/java/client/RecordingLayout.java index 5cf95dd6..a9d34545 100644 --- a/openvidu-java-client/src/main/java/io/openvidu/java/client/RecordingLayout.java +++ b/openvidu-java-client/src/main/java/io/openvidu/java/client/RecordingLayout.java @@ -18,9 +18,31 @@ package io.openvidu.java.client; public enum RecordingLayout { - BEST_FIT, // All the videos are evenly distributed, taking up as much space as possible + + /** + * All the videos are evenly distributed, taking up as much space as possible + */ + BEST_FIT, + + /** + * (not available yet) + */ PICTURE_IN_PICTURE, + + /** + * (not available yet) + */ VERTICAL_PRESENTATION, + + /** + * (not available yet) + */ HORIZONTAL_PRESENTATION, + + /** + * Use your own custom recording layout. See Custom recording layouts to learn more + */ CUSTOM } diff --git a/openvidu-java-client/src/main/java/io/openvidu/java/client/RecordingMode.java b/openvidu-java-client/src/main/java/io/openvidu/java/client/RecordingMode.java index 1b2e5a7f..3aa1d46e 100644 --- a/openvidu-java-client/src/main/java/io/openvidu/java/client/RecordingMode.java +++ b/openvidu-java-client/src/main/java/io/openvidu/java/client/RecordingMode.java @@ -18,6 +18,20 @@ package io.openvidu.java.client; public enum RecordingMode { - ALWAYS, // The session is recorded automatically (as soon as there are clients publishing streams to the session) - MANUAL; // The session is not recorded automatically. To record the session, you can call the OpenVidu.startRecording() method + + /** + * The session is recorded automatically as soon as the first client publishes a + * stream to the session. It is automatically stopped after last user leaves the + * session (or until you call + * {@link io.openvidu.java.client.OpenVidu#stopRecording(String)}). + */ + ALWAYS, + + /** + * The session is not recorded automatically. To record the session, you must + * call {@link io.openvidu.java.client.OpenVidu#startRecording(String)} method. + * To stop the recording, you must call + * {@link io.openvidu.java.client.OpenVidu#stopRecording(String)}. + */ + MANUAL; } diff --git a/openvidu-java-client/src/main/java/io/openvidu/java/client/RecordingProperties.java b/openvidu-java-client/src/main/java/io/openvidu/java/client/RecordingProperties.java index 04fd61d5..aa7d5f30 100644 --- a/openvidu-java-client/src/main/java/io/openvidu/java/client/RecordingProperties.java +++ b/openvidu-java-client/src/main/java/io/openvidu/java/client/RecordingProperties.java @@ -29,20 +29,40 @@ public class RecordingProperties { private RecordingLayout recordingLayout; private String customLayout; + /** + * Builder for {@link io.openvidu.java.client.RecordingProperties} + */ public RecordingProperties build() { return new RecordingProperties(this.name, this.recordingLayout, this.customLayout); } + /** + * Call this method to set the name of the video file. You can access this same + * value in your clients on recording events (recordingStarted, + * recordingStopped) + */ public RecordingProperties.Builder name(String name) { this.name = name; return this; } + /** + * Call this method to set the layout to be used in the recording + */ public RecordingProperties.Builder recordingLayout(RecordingLayout layout) { this.recordingLayout = layout; return this; } + /** + * If setting + * {@link io.openvidu.java.client.RecordingProperties.Builder#recordingLayout(RecordingLayout)} + * to {@link io.openvidu.java.client.RecordingLayout#CUSTOM} you can call this + * method to set the relative path to the specific custom layout you want to + * use. See Custom recording layouts to learn more + */ public RecordingProperties.Builder customLayout(String path) { this.customLayout = path; return this; @@ -56,14 +76,30 @@ public class RecordingProperties { this.customLayout = customLayout; } + /** + * Defines the name you want to give to the video file. You can access this same + * value in your clients on recording events (recordingStarted, + * recordingStopped) + */ public String name() { return this.name; } + /** + * Defines the layout to be used in the recording + */ public RecordingLayout recordingLayout() { return this.recordingLayout; } + /** + * If {@link io.openvidu.java.client.RecordingProperties#recordingLayout()} is + * set to {@link io.openvidu.java.client.RecordingLayout#CUSTOM}, this property + * defines the relative path to the specific custom layout you want to use. See + * Custom recording layouts to learn more + */ public String customLayout() { return this.customLayout; } diff --git a/openvidu-java-client/src/main/java/io/openvidu/java/client/Session.java b/openvidu-java-client/src/main/java/io/openvidu/java/client/Session.java index 920d9877..2db5b713 100644 --- a/openvidu-java-client/src/main/java/io/openvidu/java/client/Session.java +++ b/openvidu-java-client/src/main/java/io/openvidu/java/client/Session.java @@ -17,12 +17,17 @@ package io.openvidu.java.client; +import java.io.IOException; + import org.apache.http.HttpHeaders; import org.apache.http.HttpResponse; import org.apache.http.client.HttpClient; import org.apache.http.client.methods.HttpPost; import org.apache.http.entity.StringEntity; +import org.apache.http.util.EntityUtils; import org.json.simple.JSONObject; +import org.json.simple.parser.JSONParser; +import org.json.simple.parser.ParseException; import io.openvidu.java.client.OpenViduException.Code; @@ -32,7 +37,7 @@ public class Session { private String urlOpenViduServer; private String sessionId; private SessionProperties properties; - + final static String API_SESSIONS = "api/sessions"; final static String API_TOKENS = "api/tokens"; @@ -50,6 +55,13 @@ public class Session { this.sessionId = this.getSessionId(); } + /** + * Gets the unique identifier of the Session. This translates into a new request + * to OpenVidu Server if this Session has no sessionId yet or + * simply returns the existing value if it has already been retrieved + * + * @return The sessionId + */ @SuppressWarnings("unchecked") public String getSessionId() throws OpenViduException { @@ -59,23 +71,23 @@ public class Session { try { HttpPost request = new HttpPost(this.urlOpenViduServer + API_SESSIONS); - + JSONObject json = new JSONObject(); json.put("mediaMode", properties.mediaMode().name()); json.put("recordingMode", properties.recordingMode().name()); json.put("defaultRecordingLayout", properties.defaultRecordingLayout().name()); json.put("defaultCustomLayout", properties.defaultCustomLayout()); StringEntity params = new StringEntity(json.toString()); - + request.setHeader(HttpHeaders.CONTENT_TYPE, "application/json"); request.setEntity(params); - + HttpResponse response = httpClient.execute(request); int statusCode = response.getStatusLine().getStatusCode(); if ((statusCode == org.apache.http.HttpStatus.SC_OK)) { System.out.println("Returning a SESSIONID"); String id = ""; - id = (String) OpenVidu.httpResponseToJson(response).get("id"); + id = (String) httpResponseToJson(response).get("id"); this.sessionId = id; return id; } else { @@ -88,10 +100,24 @@ public class Session { } + /** + * Gets a new token associated to Session object with default values for + * {@link io.openvidu.java.client.TokenOptions}. This always translates into a + * new request to OpenVidu Server + * + * @returns The generated token + */ public String generateToken() throws OpenViduException { return this.generateToken(new TokenOptions.Builder().role(OpenViduRole.PUBLISHER).build()); } + /** + * Gets a new token associated to Session object configured with + * tokenOptions. This always translates into a new request to + * OpenVidu Server + * + * @returns The generated token + */ @SuppressWarnings("unchecked") public String generateToken(TokenOptions tokenOptions) throws OpenViduException { @@ -101,13 +127,13 @@ public class Session { try { HttpPost request = new HttpPost(this.urlOpenViduServer + API_TOKENS); - + JSONObject json = new JSONObject(); json.put("session", this.sessionId); json.put("role", tokenOptions.getRole().name()); json.put("data", tokenOptions.getData()); StringEntity params = new StringEntity(json.toString()); - + request.setHeader(HttpHeaders.CONTENT_TYPE, "application/json"); request.setEntity(params); @@ -116,7 +142,7 @@ public class Session { int statusCode = response.getStatusLine().getStatusCode(); if ((statusCode == org.apache.http.HttpStatus.SC_OK)) { System.out.println("Returning a TOKEN"); - return (String) OpenVidu.httpResponseToJson(response).get("id"); + return (String) httpResponseToJson(response).get("id"); } else { throw new OpenViduException(Code.TOKEN_CANNOT_BE_CREATED_ERROR_CODE, Integer.toString(statusCode)); } @@ -127,6 +153,9 @@ public class Session { } } + /** + * Returns the properties defining the session + */ public SessionProperties getProperties() { return this.properties; } @@ -140,4 +169,9 @@ public class Session { return (this.sessionId != null && !this.sessionId.isEmpty()); } + private JSONObject httpResponseToJson(HttpResponse response) throws ParseException, IOException { + JSONParser parser = new JSONParser(); + return (JSONObject) parser.parse(EntityUtils.toString(response.getEntity())); + } + } diff --git a/openvidu-java-client/src/main/java/io/openvidu/java/client/SessionProperties.java b/openvidu-java-client/src/main/java/io/openvidu/java/client/SessionProperties.java index 41872513..5702be17 100644 --- a/openvidu-java-client/src/main/java/io/openvidu/java/client/SessionProperties.java +++ b/openvidu-java-client/src/main/java/io/openvidu/java/client/SessionProperties.java @@ -24,6 +24,9 @@ public class SessionProperties { private RecordingLayout defaultRecordingLayout; private String defaultCustomLayout; + /** + * Builder for {@link io.openvidu.java.client.SessionProperties} + */ public static class Builder { private MediaMode mediaMode = MediaMode.ROUTED; @@ -31,26 +34,63 @@ public class SessionProperties { private RecordingLayout defaultRecordingLayout = RecordingLayout.BEST_FIT; private String defaultCustomLayout = ""; + /** + * Returns the {@link io.openvidu.java.client.SessionProperties} object properly + * configured + */ public SessionProperties build() { return new SessionProperties(this.mediaMode, this.recordingMode, this.defaultRecordingLayout, this.defaultCustomLayout); } + /** + * Call this method to set how the media streams will be sent and received by + * your clients: routed through OpenVidu Media Server + * (MediaMode.ROUTED) or attempting direct p2p connections + * (MediaMode.RELAYED, not available yet) + * + * Default value is MediaMode.ROUTED + */ public SessionProperties.Builder mediaMode(MediaMode mediaMode) { this.mediaMode = mediaMode; return this; } + /** + * Call this method to set whether the Session will be automatically recorded + * (RecordingMode.ALWAYS) or not + * (RecordingMode.MANUAL) + * + * Default value is RecordingMode.MANUAL + */ public SessionProperties.Builder recordingMode(RecordingMode recordingMode) { this.recordingMode = recordingMode; return this; } + /** + * Call this method to set the the default value used to initialize property + * {@link io.openvidu.java.client.RecordingProperties#recordingLayout()} of + * every recording of this session. You can easily override this value later + * when initializing a {@link io.openvidu.java.client.Recording} by calling + * {@link io.openvidu.java.client.RecordingProperties.Builder#recordingLayout(RecordingLayout)} + * with any other value + * + * Default value is RecordingLayout.BEST_FIT + */ public SessionProperties.Builder defaultRecordingLayout(RecordingLayout layout) { this.defaultRecordingLayout = layout; return this; } + /** + * Call this method to set the default value used to initialize property + * {@link io.openvidu.java.client.RecordingProperties#customLayout()} of every + * recording of this session. You can easily override this value later when + * initializing a {@link io.openvidu.java.client.Recording} by calling + * {@link io.openvidu.java.client.RecordingProperties.Builder#customLayout(String)} + * with any other value + */ public SessionProperties.Builder defaultCustomLayout(String path) { this.defaultCustomLayout = path; return this; @@ -73,18 +113,45 @@ public class SessionProperties { this.defaultCustomLayout = defaultCustomLayout; } + /** + * Defines whether the Session will be automatically recorded + * (RecordingMode.ALWAYS) or not + * (RecordingMode.MANUAL) + */ public RecordingMode recordingMode() { return this.recordingMode; } + /** + * Defines how the media streams will be sent and received by your clients: + * routed through OpenVidu Media Server (MediaMode.ROUTED) or + * attempting direct p2p connections (MediaMode.RELAYED, not + * available yet) + */ public MediaMode mediaMode() { return this.mediaMode; } + /** + * Defines the default value used to initialize property + * {@link io.openvidu.java.client.RecordingProperties#recordingLayout()} of + * every recording of this session. You can easily override this value later + * when initializing a {@link io.openvidu.java.client.Recording} by calling + * {@link io.openvidu.java.client.RecordingProperties.Builder#recordingLayout(RecordingLayout)} + * with any other value + */ public RecordingLayout defaultRecordingLayout() { return this.defaultRecordingLayout; } + /** + * Defines the default value used to initialize property + * {@link io.openvidu.java.client.RecordingProperties#customLayout()} of every + * recording of this session. You can easily override this value later when + * initializing a {@link io.openvidu.java.client.Recording} by calling + * {@link io.openvidu.java.client.RecordingProperties.Builder#customLayout(String)} + * with any other value + */ public String defaultCustomLayout() { return this.defaultCustomLayout; } diff --git a/openvidu-java-client/src/main/java/io/openvidu/java/client/TokenOptions.java b/openvidu-java-client/src/main/java/io/openvidu/java/client/TokenOptions.java index be7cb01f..13b9067e 100644 --- a/openvidu-java-client/src/main/java/io/openvidu/java/client/TokenOptions.java +++ b/openvidu-java-client/src/main/java/io/openvidu/java/client/TokenOptions.java @@ -18,40 +18,79 @@ package io.openvidu.java.client; public class TokenOptions { - + private String data; private OpenViduRole role; - + + /** + * + * Builder for {@link io.openvidu.java.client.TokenOptions} + * + */ public static class Builder { - + private String data = ""; private OpenViduRole role = OpenViduRole.PUBLISHER; - + + /** + * Builder for {@link io.openvidu.java.client.TokenOptions} + */ public TokenOptions build() { return new TokenOptions(this.data, this.role); } - - public Builder data(String data){ + + /** + * Call this method to set the secure (server-side) data associated to this + * token. Every client will receive this data in property + * Connection.data. Object Connection can be retrieved + * by subscribing to event connectionCreated of Session object in + * your clients. + *
    + *
  • If you have provided no data in your clients when calling method + * Session.connect(TOKEN, DATA) (DATA not defined), + * then Connection.data will only have this + * {@link io.openvidu.java.client.TokenOptions.Builder#data(String)} + * property.
  • + *
  • If you have provided some data when calling + * Session.connect(TOKEN, DATA) (DATA defined), then + * Connection.data will have the following structure: + * "CLIENT_DATA%/%SERVER_DATA", being + * CLIENT_DATA the second parameter passed in OpenVidu Browser in + * method Session.connect and SERVER_DATA this + * {@link io.openvidu.java.client.TokenOptions.Builder#data(String)} + * property.
  • + *
+ */ + public Builder data(String data) { this.data = data; return this; } - - public Builder role(OpenViduRole role){ + + /** + * Call this method to set the role assigned to this token + */ + public Builder role(OpenViduRole role) { this.role = role; return this; } - + } - - private TokenOptions(String data, OpenViduRole role){ + + private TokenOptions(String data, OpenViduRole role) { this.data = data; this.role = role; } - + + /** + * Returns the secure (server-side) metadata assigned to this token + */ public String getData() { return this.data; } - + + /** + * Returns the role assigned to this token + */ public OpenViduRole getRole() { return this.role; }