mirror of https://github.com/OpenVidu/openvidu.git
openvidu-java-client JavaDoc
parent
9ef4ed9242
commit
0db5498a0b
|
@ -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/)
|
||||
|
||||
|
|
|
@ -97,9 +97,9 @@
|
|||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>2.10.4</version>
|
||||
<version>3.0.0</version>
|
||||
<configuration>
|
||||
|
||||
<show>public</show>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
|
@ -131,7 +131,10 @@
|
|||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>2.10.4</version>
|
||||
<version>3.0.0</version>
|
||||
<configuration>
|
||||
<show>public</show>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-javadocs</id>
|
||||
|
|
|
@ -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
|
||||
/**
|
||||
* <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
|
||||
}
|
||||
|
|
|
@ -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<Recording> 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<Recording> 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()));
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
||||
/**
|
||||
* <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;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
* <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;
|
||||
|
@ -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
|
||||
* (<code>recordingStarted</code>, <code>recordingStopped</code>)
|
||||
*/
|
||||
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
|
||||
* <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() {
|
||||
return url;
|
||||
}
|
||||
|
||||
/**
|
||||
* <code>true</code> if the recording has an audio track, <code>false</code>
|
||||
* otherwise (currently fixed to true)
|
||||
*/
|
||||
public boolean hasAudio() {
|
||||
return hasAudio;
|
||||
}
|
||||
|
||||
/**
|
||||
* <code>true</code> if the recording has a video track, <code>false</code>
|
||||
* otherwise (currently fixed to true)
|
||||
*/
|
||||
public boolean hasVideo() {
|
||||
return hasVideo;
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
||||
/**
|
||||
* <i>(not available yet)</i>
|
||||
*/
|
||||
PICTURE_IN_PICTURE,
|
||||
|
||||
/**
|
||||
* <i>(not available yet)</i>
|
||||
*/
|
||||
VERTICAL_PRESENTATION,
|
||||
|
||||
/**
|
||||
* <i>(not available yet)</i>
|
||||
*/
|
||||
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
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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 (<code>recordingStarted</code>,
|
||||
* <code>recordingStopped</code>)
|
||||
*/
|
||||
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 <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) {
|
||||
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 (<code>recordingStarted</code>,
|
||||
* <code>recordingStopped</code>)
|
||||
*/
|
||||
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
|
||||
* <a href=
|
||||
* "http://openvidu.io/docs/advanced-features/recording#custom-recording-layouts"
|
||||
* target="_blank">Custom recording layouts</a> to learn more
|
||||
*/
|
||||
public String customLayout() {
|
||||
return this.customLayout;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
@ -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 <code>sessionId</code> yet or
|
||||
* simply returns the existing value if it has already been retrieved
|
||||
*
|
||||
* @return The sessionId
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public String getSessionId() throws OpenViduException {
|
||||
|
||||
|
@ -75,7 +87,7 @@ public class Session {
|
|||
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
|
||||
* <code>tokenOptions</code>. This always translates into a new request to
|
||||
* OpenVidu Server
|
||||
*
|
||||
* @returns The generated token
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public String generateToken(TokenOptions tokenOptions) throws OpenViduException {
|
||||
|
||||
|
@ -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()));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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
|
||||
* (<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) {
|
||||
this.mediaMode = mediaMode;
|
||||
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) {
|
||||
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 <code>RecordingLayout.BEST_FIT</code>
|
||||
*/
|
||||
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
|
||||
* (<code>RecordingMode.ALWAYS</code>) or not
|
||||
* (<code>RecordingMode.MANUAL</code>)
|
||||
*/
|
||||
public RecordingMode 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() {
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -22,36 +22,75 @@ 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
|
||||
* <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>"CLIENT_DATA%/%SERVER_DATA"</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;
|
||||
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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue