mirror of https://github.com/OpenVidu/openvidu.git
OpenVidu SDKs: use new paths to consume REST API
parent
2d8216fb0d
commit
0e3e82d7e1
|
@ -70,15 +70,18 @@ public class OpenVidu {
|
|||
protected HttpClient httpClient;
|
||||
protected Map<String, Session> activeSessions = new ConcurrentHashMap<>();
|
||||
|
||||
protected final static String API_SESSIONS = "api/sessions";
|
||||
protected final static String API_TOKENS = "api/tokens";
|
||||
protected final static String API_RECORDINGS = "api/recordings";
|
||||
protected final static String API_RECORDINGS_START = "/start";
|
||||
protected final static String API_RECORDINGS_STOP = "/stop";
|
||||
protected final static String API_PATH = "openvidu/api";
|
||||
protected final static String API_SESSIONS = API_PATH + "/sessions";
|
||||
protected final static String API_TOKENS = API_PATH + "/tokens";
|
||||
protected final static String API_RECORDINGS = API_PATH + "/recordings";
|
||||
protected final static String API_RECORDINGS_START = API_RECORDINGS + "/start";
|
||||
protected final static String API_RECORDINGS_STOP = API_RECORDINGS + "/stop";
|
||||
|
||||
/**
|
||||
* @param urlOpenViduServer Public accessible IP where your instance of OpenVidu
|
||||
* Server is up an running
|
||||
* @param hostname URL where your instance of OpenVidu Server is up an running.
|
||||
* It must be the full URL (e.g.
|
||||
* <code>https://12.34.56.78:1234/</code>)
|
||||
*
|
||||
* @param secret Secret used on OpenVidu Server initialization
|
||||
*/
|
||||
public OpenVidu(String hostname, String secret) {
|
||||
|
@ -192,7 +195,7 @@ public class OpenVidu {
|
|||
public Recording startRecording(String sessionId, RecordingProperties properties)
|
||||
throws OpenViduJavaClientException, OpenViduHttpException {
|
||||
|
||||
HttpPost request = new HttpPost(this.hostname + API_RECORDINGS + API_RECORDINGS_START);
|
||||
HttpPost request = new HttpPost(this.hostname + API_RECORDINGS_START);
|
||||
|
||||
JsonObject json = new JsonObject();
|
||||
json.addProperty("session", sessionId);
|
||||
|
@ -201,7 +204,8 @@ public class OpenVidu {
|
|||
json.addProperty("hasAudio", properties.hasAudio());
|
||||
json.addProperty("hasVideo", properties.hasVideo());
|
||||
|
||||
if ((Recording.OutputMode.COMPOSED.equals(properties.outputMode()) || (Recording.OutputMode.COMPOSED_QUICK_START.equals(properties.outputMode())))
|
||||
if ((Recording.OutputMode.COMPOSED.equals(properties.outputMode())
|
||||
|| (Recording.OutputMode.COMPOSED_QUICK_START.equals(properties.outputMode())))
|
||||
&& properties.hasVideo()) {
|
||||
json.addProperty("resolution", properties.resolution());
|
||||
json.addProperty("recordingLayout",
|
||||
|
@ -236,8 +240,9 @@ public class OpenVidu {
|
|||
if (activeSession != null) {
|
||||
activeSession.setIsBeingRecorded(true);
|
||||
} else {
|
||||
log.warn("No active session found for sessionId '" + r.getSessionId()
|
||||
+ "'. This instance of OpenVidu Java Client didn't create this session");
|
||||
log.warn(
|
||||
"No active session found for sessionId '{}'. This instance of OpenVidu Java Client didn't create this session",
|
||||
r.getSessionId());
|
||||
}
|
||||
return r;
|
||||
} else {
|
||||
|
@ -352,7 +357,7 @@ public class OpenVidu {
|
|||
* </ul>
|
||||
*/
|
||||
public Recording stopRecording(String recordingId) throws OpenViduJavaClientException, OpenViduHttpException {
|
||||
HttpPost request = new HttpPost(this.hostname + API_RECORDINGS + API_RECORDINGS_STOP + "/" + recordingId);
|
||||
HttpPost request = new HttpPost(this.hostname + API_RECORDINGS_STOP + "/" + recordingId);
|
||||
HttpResponse response;
|
||||
try {
|
||||
response = this.httpClient.execute(request);
|
||||
|
@ -368,8 +373,9 @@ public class OpenVidu {
|
|||
if (activeSession != null) {
|
||||
activeSession.setIsBeingRecorded(false);
|
||||
} else {
|
||||
log.warn("No active session found for sessionId '" + r.getSessionId()
|
||||
+ "'. This instance of OpenVidu Java Client didn't create this session");
|
||||
log.warn(
|
||||
"No active session found for sessionId '{}'. This instance of OpenVidu Java Client didn't create this session",
|
||||
r.getSessionId());
|
||||
}
|
||||
return r;
|
||||
} else {
|
||||
|
|
|
@ -48,9 +48,8 @@ public class Recording {
|
|||
stopped,
|
||||
|
||||
/**
|
||||
* The recording has finished OK and is available for download through OpenVidu
|
||||
* Server recordings endpoint:
|
||||
* https://YOUR_OPENVIDUSERVER_IP/recordings/{RECORDING_ID}/{RECORDING_NAME}.{EXTENSION}
|
||||
* The recording has finished being processed and is available for download
|
||||
* through property {@link Recording#getUrl}
|
||||
*/
|
||||
ready,
|
||||
|
||||
|
@ -77,25 +76,23 @@ public class Recording {
|
|||
INDIVIDUAL,
|
||||
|
||||
/**
|
||||
* Works the same way as COMPOSED mode, but the necessary recorder
|
||||
* service module will start some time in advance and won't be terminated
|
||||
* once a specific session recording has ended. This module will remain
|
||||
* up and running as long as the session remains active.<br><br>
|
||||
* Works the same way as COMPOSED mode, but the necessary recorder service
|
||||
* module will start some time in advance and won't be terminated once a
|
||||
* specific session recording has ended. This module will remain up and running
|
||||
* as long as the session remains active.<br>
|
||||
* <br>
|
||||
*
|
||||
* <ul>
|
||||
* <li>
|
||||
* <strong>Pros vs COMPOSED</strong>: the process of starting the recording will be noticeably
|
||||
* faster. This can be very useful in use cases where a session needs to be
|
||||
* recorded multiple times over time, when a better response time is usually
|
||||
* desirable.
|
||||
* </li>
|
||||
* <li>
|
||||
* <strong>Cons vs COMPOSED</strong>: for every session initialized with COMPOSED_QUICK_START
|
||||
* recording output mode, extra CPU power will be required in OpenVidu Server.
|
||||
* The recording module will be continuously rendering all of the streams being
|
||||
* published to the session even when the session is not being recorded. And that
|
||||
* is for every session configured with COMPOSED_QUICK_START.
|
||||
* </li>
|
||||
* <li><strong>Pros vs COMPOSED</strong>: the process of starting the recording
|
||||
* will be noticeably faster. This can be very useful in use cases where a
|
||||
* session needs to be recorded multiple times over time, when a better response
|
||||
* time is usually desirable.</li>
|
||||
* <li><strong>Cons vs COMPOSED</strong>: for every session initialized with
|
||||
* COMPOSED_QUICK_START recording output mode, extra CPU power will be required
|
||||
* in OpenVidu Server. The recording module will be continuously rendering all
|
||||
* of the streams being published to the session even when the session is not
|
||||
* being recorded. And that is for every session configured with
|
||||
* COMPOSED_QUICK_START.</li>
|
||||
* </ul>
|
||||
*/
|
||||
COMPOSED_QUICK_START;
|
||||
|
@ -129,7 +126,8 @@ public class Recording {
|
|||
OutputMode outputMode = OutputMode.valueOf(json.get("outputMode").getAsString());
|
||||
RecordingProperties.Builder builder = new RecordingProperties.Builder().name(json.get("name").getAsString())
|
||||
.outputMode(outputMode).hasAudio(hasAudio).hasVideo(hasVideo);
|
||||
if ((OutputMode.COMPOSED.equals(outputMode) || OutputMode.COMPOSED_QUICK_START.equals(outputMode)) && hasVideo) {
|
||||
if ((OutputMode.COMPOSED.equals(outputMode) || OutputMode.COMPOSED_QUICK_START.equals(outputMode))
|
||||
&& hasVideo) {
|
||||
builder.resolution(json.get("resolution").getAsString());
|
||||
builder.recordingLayout(RecordingLayout.valueOf(json.get("recordingLayout").getAsString()));
|
||||
JsonElement customLayout = json.get("customLayout");
|
||||
|
@ -219,8 +217,8 @@ public class Recording {
|
|||
/**
|
||||
* URL of the recording. You can access the file from there. It is
|
||||
* <code>null</code> until recording reaches "ready" or "failed" status. If
|
||||
* <a href="https://docs.openvidu.io/en/stable/reference-docs/openvidu-config/" target=
|
||||
* "_blank">OpenVidu Server configuration</a> property
|
||||
* <a href="https://docs.openvidu.io/en/stable/reference-docs/openvidu-config/"
|
||||
* target= "_blank">OpenVidu Server configuration</a> property
|
||||
* <code>OPENVIDU_RECORDING_PUBLIC_ACCESS</code> is false, this path will be
|
||||
* secured with OpenVidu credentials
|
||||
*/
|
||||
|
@ -230,7 +228,8 @@ public class Recording {
|
|||
|
||||
/**
|
||||
* Resolution of the video file. Only defined if OutputMode of the Recording is
|
||||
* set to {@link io.openvidu.java.client.Recording.OutputMode#COMPOSED} or {@link io.openvidu.java.client.Recording.OutputMode#COMPOSED_QUICK_START}
|
||||
* set to {@link io.openvidu.java.client.Recording.OutputMode#COMPOSED} or
|
||||
* {@link io.openvidu.java.client.Recording.OutputMode#COMPOSED_QUICK_START}
|
||||
*/
|
||||
public String getResolution() {
|
||||
return this.recordingProperties.resolution();
|
||||
|
|
|
@ -52,7 +52,8 @@ public class RecordingProperties {
|
|||
* Builder for {@link io.openvidu.java.client.RecordingProperties}
|
||||
*/
|
||||
public RecordingProperties build() {
|
||||
if (OutputMode.COMPOSED.equals(this.outputMode) || OutputMode.COMPOSED_QUICK_START.equals(this.outputMode)) {
|
||||
if (OutputMode.COMPOSED.equals(this.outputMode)
|
||||
|| OutputMode.COMPOSED_QUICK_START.equals(this.outputMode)) {
|
||||
this.recordingLayout = this.recordingLayout != null ? this.recordingLayout : RecordingLayout.BEST_FIT;
|
||||
this.resolution = this.resolution != null ? this.resolution : "1920x1080";
|
||||
if (RecordingLayout.CUSTOM.equals(this.recordingLayout)) {
|
||||
|
@ -102,11 +103,14 @@ public class RecordingProperties {
|
|||
* method to set the relative path to the specific custom layout you want to
|
||||
* use.<br>
|
||||
* Will only have effect if
|
||||
* {@link io.openvidu.java.client.RecordingProperties.Builder#outputMode(Recording.OutputMode)}
|
||||
* has been called with value
|
||||
* {@link io.openvidu.java.client.Recording.OutputMode#COMPOSED} or
|
||||
* {@link io.openvidu.java.client.Recording.OutputMode#COMPOSED_QUICK_START}.<br>
|
||||
* See <a href="https://docs.openvidu.io/en/stable/advanced-features/recording#custom-recording-layouts"
|
||||
* {@link io.openvidu.java.client.RecordingProperties.Builder#outputMode(Recording.OutputMode)
|
||||
* Builder.outputMode()} has been called with value
|
||||
* {@link io.openvidu.java.client.Recording.OutputMode#COMPOSED
|
||||
* OutputMode.COMPOSED} or
|
||||
* {@link io.openvidu.java.client.Recording.OutputMode#COMPOSED_QUICK_START
|
||||
* OutputMode.COMPOSED_QUICK_START}.<br>
|
||||
* See <a href=
|
||||
* "https://docs.openvidu.io/en/stable/advanced-features/recording#custom-recording-layouts"
|
||||
* target="_blank">Custom recording layouts</a> to learn more
|
||||
*/
|
||||
public RecordingProperties.Builder customLayout(String path) {
|
||||
|
@ -119,13 +123,15 @@ public class RecordingProperties {
|
|||
* format "WIDTHxHEIGHT", being both WIDTH and HEIGHT the number of pixels
|
||||
* between 100 and 1999.<br>
|
||||
* Will only have effect if
|
||||
* {@link io.openvidu.java.client.RecordingProperties.Builder#outputMode(Recording.OutputMode)}
|
||||
* has been called with value
|
||||
* {@link io.openvidu.java.client.Recording.OutputMode#COMPOSED} or
|
||||
* {@link io.openvidu.java.client.Recording.OutputMode#COMPOSED_QUICK_START}. For
|
||||
* {@link io.openvidu.java.client.Recording.OutputMode#INDIVIDUAL} all
|
||||
* individual video files will have the native resolution of the published
|
||||
* stream
|
||||
* {@link io.openvidu.java.client.RecordingProperties.Builder#outputMode(Recording.OutputMode)
|
||||
* Builder.outputMode()} has been called with value
|
||||
* {@link io.openvidu.java.client.Recording.OutputMode#COMPOSED
|
||||
* OutputMode.COMPOSED} or
|
||||
* {@link io.openvidu.java.client.Recording.OutputMode#COMPOSED_QUICK_START
|
||||
* OutputMode.COMPOSED_QUICK_START}. For
|
||||
* {@link io.openvidu.java.client.Recording.OutputMode#INDIVIDUAL
|
||||
* OutputMode.INDIVIDUAL} all individual video files will have the native
|
||||
* resolution of the published stream
|
||||
*/
|
||||
public RecordingProperties.Builder resolution(String resolution) {
|
||||
this.resolution = resolution;
|
||||
|
@ -134,7 +140,8 @@ public class RecordingProperties {
|
|||
|
||||
/**
|
||||
* Call this method to specify whether to record audio or not. Cannot be set to
|
||||
* false at the same time as {@link hasVideo(boolean)}
|
||||
* false at the same time as
|
||||
* {@link RecordingProperties.Builder#hasVideo(boolean)}
|
||||
*/
|
||||
public RecordingProperties.Builder hasAudio(boolean hasAudio) {
|
||||
this.hasAudio = hasAudio;
|
||||
|
@ -143,7 +150,8 @@ public class RecordingProperties {
|
|||
|
||||
/**
|
||||
* Call this method to specify whether to record video or not. Cannot be set to
|
||||
* false at the same time as {@link hasAudio(boolean)}
|
||||
* false at the same time as
|
||||
* {@link RecordingProperties.Builder#hasAudio(boolean)}
|
||||
*/
|
||||
public RecordingProperties.Builder hasVideo(boolean hasVideo) {
|
||||
this.hasVideo = hasVideo;
|
||||
|
@ -185,12 +193,12 @@ public class RecordingProperties {
|
|||
|
||||
/**
|
||||
* Defines the mode of recording: {@link Recording.OutputMode#COMPOSED} or
|
||||
* {@link io.openvidu.java.client.Recording.OutputMode#COMPOSED_QUICK_START} for a
|
||||
* single archive in a grid layout or {@link Recording.OutputMode#INDIVIDUAL}
|
||||
* {@link io.openvidu.java.client.Recording.OutputMode#COMPOSED_QUICK_START} for
|
||||
* a single archive in a grid layout or {@link Recording.OutputMode#INDIVIDUAL}
|
||||
* for one archive for each stream.<br>
|
||||
* <br>
|
||||
*
|
||||
* Default to {@link Recording.OutputMode#COMPOSED}
|
||||
* Default to {@link Recording.OutputMode#COMPOSED OutputMode.COMPOSED}
|
||||
*/
|
||||
public Recording.OutputMode outputMode() {
|
||||
return this.outputMode;
|
||||
|
@ -199,12 +207,14 @@ public class RecordingProperties {
|
|||
/**
|
||||
* Defines the layout to be used in the recording.<br>
|
||||
* Will only have effect if
|
||||
* {@link io.openvidu.java.client.RecordingProperties.Builder#outputMode(Recording.OutputMode)}
|
||||
* has been called with value {@link Recording.OutputMode#COMPOSED} or
|
||||
* {@link io.openvidu.java.client.Recording.OutputMode#COMPOSED_QUICK_START}.<br>
|
||||
* {@link io.openvidu.java.client.RecordingProperties.Builder#outputMode(Recording.OutputMode)
|
||||
* Builder.outputMode()} has been called with value
|
||||
* {@link Recording.OutputMode#COMPOSED OutputMode.COMPOSED} or
|
||||
* {@link io.openvidu.java.client.Recording.OutputMode#COMPOSED_QUICK_START
|
||||
* OutputMode.COMPOSED_QUICK_START}.<br>
|
||||
* <br>
|
||||
*
|
||||
* Default to {@link RecordingLayout#BEST_FIT}
|
||||
* Default to {@link RecordingLayout#BEST_FIT RecordingLayout.BEST_FIT}
|
||||
*/
|
||||
public RecordingLayout recordingLayout() {
|
||||
return this.recordingLayout;
|
||||
|
@ -214,7 +224,8 @@ public class RecordingProperties {
|
|||
* 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.<br>
|
||||
* See <a href="https://docs.openvidu.io/en/stable/advanced-features/recording#custom-recording-layouts"
|
||||
* See <a href=
|
||||
* "https://docs.openvidu.io/en/stable/advanced-features/recording#custom-recording-layouts"
|
||||
* target="_blank">Custom recording layouts</a> to learn more
|
||||
*/
|
||||
public String customLayout() {
|
||||
|
@ -227,8 +238,8 @@ public class RecordingProperties {
|
|||
* {@link io.openvidu.java.client.RecordingProperties.Builder#outputMode(Recording.OutputMode)}
|
||||
* has been called with value
|
||||
* {@link io.openvidu.java.client.Recording.OutputMode#COMPOSED} or
|
||||
* {@link io.openvidu.java.client.Recording.OutputMode#COMPOSED_QUICK_START}. For
|
||||
* {@link io.openvidu.java.client.Recording.OutputMode#INDIVIDUAL} all
|
||||
* {@link io.openvidu.java.client.Recording.OutputMode#COMPOSED_QUICK_START}.
|
||||
* For {@link io.openvidu.java.client.Recording.OutputMode#INDIVIDUAL} all
|
||||
* individual video files will have the native resolution of the published
|
||||
* stream.<br>
|
||||
* <br>
|
||||
|
@ -241,7 +252,7 @@ public class RecordingProperties {
|
|||
|
||||
/**
|
||||
* Defines whether to record audio or not. Cannot be set to false at the same
|
||||
* time as {@link hasVideo()}.<br>
|
||||
* time as {@link RecordingProperties#hasVideo()}.<br>
|
||||
* <br>
|
||||
*
|
||||
* Default to true
|
||||
|
@ -252,7 +263,7 @@ public class RecordingProperties {
|
|||
|
||||
/**
|
||||
* Defines whether to record video or not. Cannot be set to false at the same
|
||||
* time as {@link hasAudio()}.<br>
|
||||
* time as {@link RecordingProperties#hasAudio()}.<br>
|
||||
* <br>
|
||||
*
|
||||
* Default to true
|
||||
|
|
|
@ -47,23 +47,29 @@ export class OpenVidu {
|
|||
/**
|
||||
* @hidden
|
||||
*/
|
||||
static readonly API_RECORDINGS: string = '/api/recordings';
|
||||
static readonly API_PATH: string = '/openvidu/api';
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
static readonly API_RECORDINGS_START: string = '/start';
|
||||
static readonly API_SESSIONS = OpenVidu.API_PATH + '/sessions';
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
static readonly API_RECORDINGS_STOP: string = '/stop';
|
||||
static readonly API_TOKENS = OpenVidu.API_PATH + '/tokens';
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
static readonly API_SESSIONS = '/api/sessions';
|
||||
static readonly API_RECORDINGS: string = OpenVidu.API_PATH + '/recordings';
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
static readonly API_TOKENS = '/api/tokens';
|
||||
static readonly API_RECORDINGS_START: string = OpenVidu.API_RECORDINGS + '/start';
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
static readonly API_RECORDINGS_STOP: string = OpenVidu.API_RECORDINGS + '/stop';
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
@ -83,7 +89,8 @@ export class OpenVidu {
|
|||
activeSessions: Session[] = [];
|
||||
|
||||
/**
|
||||
* @param urlOpenViduServer Public accessible IP where your instance of OpenVidu Server is up an running
|
||||
* @param urlOpenViduServer URL where your instance of OpenVidu Server is up an running.
|
||||
* It must be the full URL (e.g. `https://12.34.56.78:1234/`)
|
||||
* @param secret Secret used on OpenVidu Server initialization
|
||||
*/
|
||||
constructor(private urlOpenViduServer: string, secret: string) {
|
||||
|
@ -169,7 +176,7 @@ export class OpenVidu {
|
|||
}
|
||||
|
||||
axios.post(
|
||||
this.host + OpenVidu.API_RECORDINGS + OpenVidu.API_RECORDINGS_START,
|
||||
this.host + OpenVidu.API_RECORDINGS_START,
|
||||
data,
|
||||
{
|
||||
headers: {
|
||||
|
@ -223,7 +230,7 @@ export class OpenVidu {
|
|||
return new Promise<Recording>((resolve, reject) => {
|
||||
|
||||
axios.post(
|
||||
this.host + OpenVidu.API_RECORDINGS + OpenVidu.API_RECORDINGS_STOP + '/' + recordingId,
|
||||
this.host + OpenVidu.API_RECORDINGS_STOP + '/' + recordingId,
|
||||
undefined,
|
||||
{
|
||||
headers: {
|
||||
|
|
|
@ -119,9 +119,8 @@ export namespace Recording {
|
|||
stopped = 'stopped',
|
||||
|
||||
/**
|
||||
* The recording has finished OK and is available for download through OpenVidu
|
||||
* Server recordings endpoint:
|
||||
* https://YOUR_OPENVIDUSERVER_IP/recordings/{RECORDING_ID}/{RECORDING_NAME}.{EXTENSION}
|
||||
* The recording has finished being processed and is available for download through
|
||||
* property [[Recording.url]]
|
||||
*/
|
||||
ready = 'ready',
|
||||
|
||||
|
|
Loading…
Reference in New Issue