openvidu-java-client JavaDoc

pull/73/head
pabloFuente 2018-04-25 11:07:52 +02:00
parent 9ef4ed9242
commit 0db5498a0b
12 changed files with 423 additions and 52 deletions

View File

@ -7,7 +7,7 @@
openvidu-java-client 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/) - **Docs**: [openvidu-java-client API](http://openvidu.io/docs/reference-docs/openvidu-java-client/)

View File

@ -97,9 +97,9 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId> <artifactId>maven-javadoc-plugin</artifactId>
<version>2.10.4</version> <version>3.0.0</version>
<configuration> <configuration>
<show>public</show>
</configuration> </configuration>
</plugin> </plugin>
</plugins> </plugins>
@ -131,7 +131,10 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId> <artifactId>maven-javadoc-plugin</artifactId>
<version>2.10.4</version> <version>3.0.0</version>
<configuration>
<show>public</show>
</configuration>
<executions> <executions>
<execution> <execution>
<id>attach-javadocs</id> <id>attach-javadocs</id>

View File

@ -18,6 +18,14 @@
package io.openvidu.java.client; package io.openvidu.java.client;
public enum MediaMode { public enum MediaMode {
RELAYED, // The session will attempt to transmit streams directly between clients /**
ROUTED // The session will transmit streams using OpenVidu Media Server * <i>(not available yet)</i> The session will attempt to transmit streams
* directly between clients
*/
RELAYED,
/**
* The session will transmit streams using OpenVidu Media Server
*/
ROUTED
} }

View File

@ -61,6 +61,13 @@ public class OpenVidu {
final static String API_RECORDINGS_START = "/start"; final static String API_RECORDINGS_START = "/start";
final static String API_RECORDINGS_STOP = "/stop"; 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) { public OpenVidu(String urlOpenViduServer, String secret) {
this.urlOpenViduServer = urlOpenViduServer; this.urlOpenViduServer = urlOpenViduServer;
@ -105,6 +112,20 @@ public class OpenVidu {
return s; 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") @SuppressWarnings("unchecked")
public Recording startRecording(String sessionId, RecordingProperties properties) throws OpenViduException { public Recording startRecording(String sessionId, RecordingProperties properties) throws OpenViduException {
try { try {
@ -115,8 +136,7 @@ public class OpenVidu {
json.put("name", properties.name()); json.put("name", properties.name());
json.put("recordingLayout", json.put("recordingLayout",
(properties.recordingLayout() != null) ? properties.recordingLayout().name() : ""); (properties.recordingLayout() != null) ? properties.recordingLayout().name() : "");
json.put("customLayout", json.put("customLayout", (properties.customLayout() != null) ? properties.customLayout() : "");
(properties.customLayout() != null) ? properties.customLayout() : "");
StringEntity params = new StringEntity(json.toString()); StringEntity params = new StringEntity(json.toString());
request.setHeader(HttpHeaders.CONTENT_TYPE, "application/json"); request.setHeader(HttpHeaders.CONTENT_TYPE, "application/json");
@ -126,7 +146,7 @@ public class OpenVidu {
int statusCode = response.getStatusLine().getStatusCode(); int statusCode = response.getStatusLine().getStatusCode();
if ((statusCode == org.apache.http.HttpStatus.SC_OK)) { if ((statusCode == org.apache.http.HttpStatus.SC_OK)) {
return new Recording(OpenVidu.httpResponseToJson(response)); return new Recording(httpResponseToJson(response));
} else { } else {
throw new OpenViduException(Code.RECORDING_START_ERROR_CODE, Integer.toString(statusCode)); 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 { public Recording startRecording(String sessionId, String name) throws OpenViduException {
if (name == null) { if (name == null) {
name = ""; name = "";
@ -143,10 +177,28 @@ public class OpenVidu {
return this.startRecording(sessionId, new RecordingProperties.Builder().name(name).build()); 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 { public Recording startRecording(String sessionId) throws OpenViduException {
return this.startRecording(sessionId, ""); 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 { public Recording stopRecording(String recordingId) throws OpenViduException {
try { try {
HttpPost request = new HttpPost( HttpPost request = new HttpPost(
@ -155,7 +207,7 @@ public class OpenVidu {
int statusCode = response.getStatusLine().getStatusCode(); int statusCode = response.getStatusLine().getStatusCode();
if ((statusCode == org.apache.http.HttpStatus.SC_OK)) { if ((statusCode == org.apache.http.HttpStatus.SC_OK)) {
return new Recording(OpenVidu.httpResponseToJson(response)); return new Recording(httpResponseToJson(response));
} else { } else {
throw new OpenViduException(Code.RECORDING_STOP_ERROR_CODE, Integer.toString(statusCode)); 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 { public Recording getRecording(String recordingId) throws OpenViduException {
try { try {
HttpGet request = new HttpGet(this.urlOpenViduServer + API_RECORDINGS + "/" + recordingId); HttpGet request = new HttpGet(this.urlOpenViduServer + API_RECORDINGS + "/" + recordingId);
@ -172,7 +230,7 @@ public class OpenVidu {
int statusCode = response.getStatusLine().getStatusCode(); int statusCode = response.getStatusLine().getStatusCode();
if ((statusCode == org.apache.http.HttpStatus.SC_OK)) { if ((statusCode == org.apache.http.HttpStatus.SC_OK)) {
return new Recording(OpenVidu.httpResponseToJson(response)); return new Recording(httpResponseToJson(response));
} else { } else {
throw new OpenViduException(Code.RECORDING_LIST_ERROR_CODE, Integer.toString(statusCode)); 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") @SuppressWarnings("unchecked")
public List<Recording> listRecordings() throws OpenViduException { public List<Recording> listRecordings() throws OpenViduException {
try { try {
@ -191,7 +254,7 @@ public class OpenVidu {
int statusCode = response.getStatusLine().getStatusCode(); int statusCode = response.getStatusLine().getStatusCode();
if ((statusCode == org.apache.http.HttpStatus.SC_OK)) { if ((statusCode == org.apache.http.HttpStatus.SC_OK)) {
List<Recording> recordings = new ArrayList<>(); List<Recording> recordings = new ArrayList<>();
JSONObject json = OpenVidu.httpResponseToJson(response); JSONObject json = httpResponseToJson(response);
JSONArray array = (JSONArray) json.get("items"); JSONArray array = (JSONArray) json.get("items");
array.forEach(item -> { array.forEach(item -> {
recordings.add(new Recording((JSONObject) 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 { public void deleteRecording(String recordingId) throws OpenViduException {
try { try {
HttpDelete request = new HttpDelete(this.urlOpenViduServer + API_RECORDINGS + "/" + recordingId); 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(); JSONParser parser = new JSONParser();
return (JSONObject) parser.parse(EntityUtils.toString(response.getEntity())); return (JSONObject) parser.parse(EntityUtils.toString(response.getEntity()));
} }

View File

@ -18,7 +18,21 @@
package io.openvidu.java.client; package io.openvidu.java.client;
public enum OpenViduRole { 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,
/**
* <i>(not available yet)</i> SUBSCRIBER and PUBLIHSER permissions + can force
* <code>unpublish()</code> and <code>disconnect()</code> over a third-party
* stream or user
*/
MODERATOR;
} }

View File

@ -22,12 +22,35 @@ import org.json.simple.JSONObject;
public class Recording { public class Recording {
public enum Status { 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 * The recording is starting (cannot be stopped)
available, // The recording is available for downloading. This status is reached for all */
// stopped recordings if property 'openvidu.recording.free-access' is true starting,
failed; // The recording has failed
/**
* 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
* <a href="http://openvidu.io/docs/reference-docs/openvidu-server-params/"
* target="_blank">OpenVidu Server configuration</a> property
* <code>openvidu.recording.free-access</code> is true
*/
available,
/**
* The recording has failed
*/
failed;
} }
private Recording.Status status; private Recording.Status status;
@ -53,49 +76,90 @@ public class Recording {
this.hasVideo = (boolean) json.get("hasVideo"); this.hasVideo = (boolean) json.get("hasVideo");
this.status = Recording.Status.valueOf((String) json.get("status")); this.status = Recording.Status.valueOf((String) json.get("status"));
this.recordingProperties = new RecordingProperties.Builder().name((String) json.get("name")) 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() { public Recording.Status getStatus() {
return status; return status;
} }
/**
* Recording unique identifier
*/
public String getId() { public String getId() {
return id; 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
* (<code>recordingStarted</code>, <code>recordingStopped</code>)
*/
public String getName() { public String getName() {
return this.recordingProperties.name(); return this.recordingProperties.name();
} }
public RecordingLayout getLayout() { /**
* The layout used in this recording
*/
public RecordingLayout getRecordingLayout() {
return this.recordingProperties.recordingLayout(); return this.recordingProperties.recordingLayout();
} }
/**
* Session associated to the recording
*/
public String getSessionId() { public String getSessionId() {
return sessionId; return sessionId;
} }
/**
* Time when the recording started in UTC milliseconds
*/
public long getCreatedAt() { public long getCreatedAt() {
return createdAt; return createdAt;
} }
/**
* Size of the recording in bytes (0 until the recording is stopped)
*/
public long getSize() { public long getSize() {
return size; return size;
} }
/**
* Duration of the recording in seconds (0 until the recording is stopped)
*/
public double getDuration() { public double getDuration() {
return duration; return duration;
} }
/**
* URL of the recording. You can access the file from there. It is
* <code>null</code> until recording is stopped or if
* <a href="http://openvidu.io/docs/reference-docs/openvidu-server-params/"
* target="_blank">OpenVidu Server configuration</a> property
* <code>openvidu.recording.public-access</code> is false
*/
public String getUrl() { public String getUrl() {
return url; return url;
} }
/**
* <code>true</code> if the recording has an audio track, <code>false</code>
* otherwise (currently fixed to true)
*/
public boolean hasAudio() { public boolean hasAudio() {
return hasAudio; return hasAudio;
} }
/**
* <code>true</code> if the recording has a video track, <code>false</code>
* otherwise (currently fixed to true)
*/
public boolean hasVideo() { public boolean hasVideo() {
return hasVideo; return hasVideo;
} }

View File

@ -18,9 +18,31 @@
package io.openvidu.java.client; package io.openvidu.java.client;
public enum RecordingLayout { 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,
/**
* <i>(not available yet)</i>
*/
PICTURE_IN_PICTURE, PICTURE_IN_PICTURE,
/**
* <i>(not available yet)</i>
*/
VERTICAL_PRESENTATION, VERTICAL_PRESENTATION,
/**
* <i>(not available yet)</i>
*/
HORIZONTAL_PRESENTATION, HORIZONTAL_PRESENTATION,
/**
* Use your own custom recording layout. See <a href=
* "http://openvidu.io/docs/advanced-features/recording#custom-recording-layouts"
* target="_blank">Custom recording layouts</a> to learn more
*/
CUSTOM CUSTOM
} }

View File

@ -18,6 +18,20 @@
package io.openvidu.java.client; package io.openvidu.java.client;
public enum RecordingMode { 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;
} }

View File

@ -29,20 +29,40 @@ public class RecordingProperties {
private RecordingLayout recordingLayout; private RecordingLayout recordingLayout;
private String customLayout; private String customLayout;
/**
* Builder for {@link io.openvidu.java.client.RecordingProperties}
*/
public RecordingProperties build() { public RecordingProperties build() {
return new RecordingProperties(this.name, this.recordingLayout, this.customLayout); 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 (<code>recordingStarted</code>,
* <code>recordingStopped</code>)
*/
public RecordingProperties.Builder name(String name) { public RecordingProperties.Builder name(String name) {
this.name = name; this.name = name;
return this; return this;
} }
/**
* Call this method to set the layout to be used in the recording
*/
public RecordingProperties.Builder recordingLayout(RecordingLayout layout) { public RecordingProperties.Builder recordingLayout(RecordingLayout layout) {
this.recordingLayout = layout; this.recordingLayout = layout;
return this; 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 <a href=
* "http://openvidu.io/docs/advanced-features/recording#custom-recording-layouts"
* target="_blank">Custom recording layouts</a> to learn more
*/
public RecordingProperties.Builder customLayout(String path) { public RecordingProperties.Builder customLayout(String path) {
this.customLayout = path; this.customLayout = path;
return this; return this;
@ -56,14 +76,30 @@ public class RecordingProperties {
this.customLayout = customLayout; 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 (<code>recordingStarted</code>,
* <code>recordingStopped</code>)
*/
public String name() { public String name() {
return this.name; return this.name;
} }
/**
* Defines the layout to be used in the recording
*/
public RecordingLayout recordingLayout() { public RecordingLayout recordingLayout() {
return this.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
* <a href=
* "http://openvidu.io/docs/advanced-features/recording#custom-recording-layouts"
* target="_blank">Custom recording layouts</a> to learn more
*/
public String customLayout() { public String customLayout() {
return this.customLayout; return this.customLayout;
} }

View File

@ -17,12 +17,17 @@
package io.openvidu.java.client; package io.openvidu.java.client;
import java.io.IOException;
import org.apache.http.HttpHeaders; import org.apache.http.HttpHeaders;
import org.apache.http.HttpResponse; import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient; import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost; import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity; import org.apache.http.entity.StringEntity;
import org.apache.http.util.EntityUtils;
import org.json.simple.JSONObject; import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException;
import io.openvidu.java.client.OpenViduException.Code; import io.openvidu.java.client.OpenViduException.Code;
@ -50,6 +55,13 @@ public class Session {
this.sessionId = this.getSessionId(); 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 <code>sessionId</code> yet or
* simply returns the existing value if it has already been retrieved
*
* @return The sessionId
*/
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public String getSessionId() throws OpenViduException { public String getSessionId() throws OpenViduException {
@ -75,7 +87,7 @@ public class Session {
if ((statusCode == org.apache.http.HttpStatus.SC_OK)) { if ((statusCode == org.apache.http.HttpStatus.SC_OK)) {
System.out.println("Returning a SESSIONID"); System.out.println("Returning a SESSIONID");
String id = ""; String id = "";
id = (String) OpenVidu.httpResponseToJson(response).get("id"); id = (String) httpResponseToJson(response).get("id");
this.sessionId = id; this.sessionId = id;
return id; return id;
} else { } 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 { public String generateToken() throws OpenViduException {
return this.generateToken(new TokenOptions.Builder().role(OpenViduRole.PUBLISHER).build()); return this.generateToken(new TokenOptions.Builder().role(OpenViduRole.PUBLISHER).build());
} }
/**
* Gets a new token associated to Session object configured with
* <code>tokenOptions</code>. This always translates into a new request to
* OpenVidu Server
*
* @returns The generated token
*/
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public String generateToken(TokenOptions tokenOptions) throws OpenViduException { public String generateToken(TokenOptions tokenOptions) throws OpenViduException {
@ -116,7 +142,7 @@ public class Session {
int statusCode = response.getStatusLine().getStatusCode(); int statusCode = response.getStatusLine().getStatusCode();
if ((statusCode == org.apache.http.HttpStatus.SC_OK)) { if ((statusCode == org.apache.http.HttpStatus.SC_OK)) {
System.out.println("Returning a TOKEN"); System.out.println("Returning a TOKEN");
return (String) OpenVidu.httpResponseToJson(response).get("id"); return (String) httpResponseToJson(response).get("id");
} else { } else {
throw new OpenViduException(Code.TOKEN_CANNOT_BE_CREATED_ERROR_CODE, Integer.toString(statusCode)); 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() { public SessionProperties getProperties() {
return this.properties; return this.properties;
} }
@ -140,4 +169,9 @@ public class Session {
return (this.sessionId != null && !this.sessionId.isEmpty()); 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()));
}
} }

View File

@ -24,6 +24,9 @@ public class SessionProperties {
private RecordingLayout defaultRecordingLayout; private RecordingLayout defaultRecordingLayout;
private String defaultCustomLayout; private String defaultCustomLayout;
/**
* Builder for {@link io.openvidu.java.client.SessionProperties}
*/
public static class Builder { public static class Builder {
private MediaMode mediaMode = MediaMode.ROUTED; private MediaMode mediaMode = MediaMode.ROUTED;
@ -31,26 +34,63 @@ public class SessionProperties {
private RecordingLayout defaultRecordingLayout = RecordingLayout.BEST_FIT; private RecordingLayout defaultRecordingLayout = RecordingLayout.BEST_FIT;
private String defaultCustomLayout = ""; private String defaultCustomLayout = "";
/**
* Returns the {@link io.openvidu.java.client.SessionProperties} object properly
* configured
*/
public SessionProperties build() { public SessionProperties build() {
return new SessionProperties(this.mediaMode, this.recordingMode, this.defaultRecordingLayout, return new SessionProperties(this.mediaMode, this.recordingMode, this.defaultRecordingLayout,
this.defaultCustomLayout); this.defaultCustomLayout);
} }
/**
* Call this method to set how the media streams will be sent and received by
* your clients: routed through OpenVidu Media Server
* (<code>MediaMode.ROUTED</code>) or attempting direct p2p connections
* (<code>MediaMode.RELAYED</code>, <i>not available yet</i>)
*
* Default value is <code>MediaMode.ROUTED</code>
*/
public SessionProperties.Builder mediaMode(MediaMode mediaMode) { public SessionProperties.Builder mediaMode(MediaMode mediaMode) {
this.mediaMode = mediaMode; this.mediaMode = mediaMode;
return this; return this;
} }
/**
* Call this method to set whether the Session will be automatically recorded
* (<code>RecordingMode.ALWAYS</code>) or not
* (<code>RecordingMode.MANUAL</code>)
*
* Default value is <code>RecordingMode.MANUAL</code>
*/
public SessionProperties.Builder recordingMode(RecordingMode recordingMode) { public SessionProperties.Builder recordingMode(RecordingMode recordingMode) {
this.recordingMode = recordingMode; this.recordingMode = recordingMode;
return this; 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 <code>RecordingLayout.BEST_FIT</code>
*/
public SessionProperties.Builder defaultRecordingLayout(RecordingLayout layout) { public SessionProperties.Builder defaultRecordingLayout(RecordingLayout layout) {
this.defaultRecordingLayout = layout; this.defaultRecordingLayout = layout;
return this; 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) { public SessionProperties.Builder defaultCustomLayout(String path) {
this.defaultCustomLayout = path; this.defaultCustomLayout = path;
return this; return this;
@ -73,18 +113,45 @@ public class SessionProperties {
this.defaultCustomLayout = defaultCustomLayout; this.defaultCustomLayout = defaultCustomLayout;
} }
/**
* Defines whether the Session will be automatically recorded
* (<code>RecordingMode.ALWAYS</code>) or not
* (<code>RecordingMode.MANUAL</code>)
*/
public RecordingMode recordingMode() { public RecordingMode recordingMode() {
return this.recordingMode; return this.recordingMode;
} }
/**
* Defines how the media streams will be sent and received by your clients:
* routed through OpenVidu Media Server (<code>MediaMode.ROUTED</code>) or
* attempting direct p2p connections (<code>MediaMode.RELAYED</code>, <i>not
* available yet</i>)
*/
public MediaMode mediaMode() { public MediaMode mediaMode() {
return this.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() { public RecordingLayout defaultRecordingLayout() {
return this.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() { public String defaultCustomLayout() {
return this.defaultCustomLayout; return this.defaultCustomLayout;
} }

View File

@ -22,36 +22,75 @@ public class TokenOptions {
private String data; private String data;
private OpenViduRole role; private OpenViduRole role;
/**
*
* Builder for {@link io.openvidu.java.client.TokenOptions}
*
*/
public static class Builder { public static class Builder {
private String data = ""; private String data = "";
private OpenViduRole role = OpenViduRole.PUBLISHER; private OpenViduRole role = OpenViduRole.PUBLISHER;
/**
* Builder for {@link io.openvidu.java.client.TokenOptions}
*/
public TokenOptions build() { public TokenOptions build() {
return new TokenOptions(this.data, this.role); 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
* <code>Connection.data</code>. Object <code>Connection</code> can be retrieved
* by subscribing to event <code>connectionCreated</code> of Session object in
* your clients.
* <ul>
* <li>If you have provided no data in your clients when calling method
* <code>Session.connect(TOKEN, DATA)</code> (<code>DATA</code> not defined),
* then <code>Connection.data</code> will only have this
* {@link io.openvidu.java.client.TokenOptions.Builder#data(String)}
* property.</li>
* <li>If you have provided some data when calling
* <code>Session.connect(TOKEN, DATA)</code> (<code>DATA</code> defined), then
* <code>Connection.data</code> will have the following structure:
* <code>&quot;CLIENT_DATA%/%SERVER_DATA&quot;</code>, being
* <code>CLIENT_DATA</code> the second parameter passed in OpenVidu Browser in
* method <code>Session.connect</code> and <code>SERVER_DATA</code> this
* {@link io.openvidu.java.client.TokenOptions.Builder#data(String)}
* property.</li>
* </ul>
*/
public Builder data(String data) {
this.data = data; this.data = data;
return this; 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; this.role = role;
return this; return this;
} }
} }
private TokenOptions(String data, OpenViduRole role){ private TokenOptions(String data, OpenViduRole role) {
this.data = data; this.data = data;
this.role = role; this.role = role;
} }
/**
* Returns the secure (server-side) metadata assigned to this token
*/
public String getData() { public String getData() {
return this.data; return this.data;
} }
/**
* Returns the role assigned to this token
*/
public OpenViduRole getRole() { public OpenViduRole getRole() {
return this.role; return this.role;
} }