From a146b558035a752cc93a0e94634fdf22c5b0c07f Mon Sep 17 00:00:00 2001 From: pabloFuente Date: Mon, 7 Sep 2020 13:47:28 +0200 Subject: [PATCH] openvidu-java-client/openvidu-node-client: "record" on TokenOptions --- .../java/io/openvidu/java/client/Session.java | 19 +++++++++-- .../io/openvidu/java/client/TokenOptions.java | 32 ++++++++++++++++--- openvidu-node-client/src/Session.ts | 7 ++-- openvidu-node-client/src/TokenOptions.ts | 9 ++++++ 4 files changed, 58 insertions(+), 9 deletions(-) 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 c2e3bcc4..7feb4adb 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 @@ -37,6 +37,7 @@ import org.slf4j.LoggerFactory; import com.google.gson.Gson; import com.google.gson.JsonArray; +import com.google.gson.JsonNull; import com.google.gson.JsonObject; import com.google.gson.JsonSyntaxException; @@ -120,8 +121,22 @@ public class Session { JsonObject json = new JsonObject(); json.addProperty("session", this.sessionId); - json.addProperty("role", tokenOptions.getRole().name()); - json.addProperty("data", tokenOptions.getData()); + + if (tokenOptions.getData() != null) { + json.addProperty("data", tokenOptions.getData()); + } else { + json.add("data", JsonNull.INSTANCE); + } + if (tokenOptions.getRole() != null) { + json.addProperty("role", tokenOptions.getRole().name()); + } else { + json.add("role", JsonNull.INSTANCE); + } + if (tokenOptions.record() != null) { + json.addProperty("record", tokenOptions.record()); + } else { + json.add("record", JsonNull.INSTANCE); + } if (tokenOptions.getKurentoOptions() != null) { JsonObject kurentoOptions = new JsonObject(); if (tokenOptions.getKurentoOptions().getVideoMaxRecvBandwidth() != null) { 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 96c39fd6..41ba60af 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 @@ -24,6 +24,7 @@ public class TokenOptions { private String data; private OpenViduRole role; + private Boolean record; private KurentoOptions kurentoOptions; /** @@ -33,15 +34,16 @@ public class TokenOptions { */ public static class Builder { - private String data = ""; - private OpenViduRole role = OpenViduRole.PUBLISHER; + private String data; + private OpenViduRole role; + private Boolean record; private KurentoOptions kurentoOptions; /** * Builder for {@link io.openvidu.java.client.TokenOptions} */ public TokenOptions build() { - return new TokenOptions(this.data, this.role, this.kurentoOptions); + return new TokenOptions(this.data, this.role, this.record, this.kurentoOptions); } /** @@ -79,6 +81,17 @@ public class TokenOptions { return this; } + /** + * Call this method to flag the streams published by the participant + * owning this token to be recorded or not. This only affects INDIVIDUAL recording. If not set by default will be true + */ + public Builder record(boolean record) { + this.record = record; + return this; + } + /** * Call this method to set a {@link io.openvidu.java.client.KurentoOptions} * object for this token @@ -90,9 +103,10 @@ public class TokenOptions { } - private TokenOptions(String data, OpenViduRole role, KurentoOptions kurentoOptions) { + private TokenOptions(String data, OpenViduRole role, Boolean record, KurentoOptions kurentoOptions) { this.data = data; this.role = role; + this.record = record; this.kurentoOptions = kurentoOptions; } @@ -110,6 +124,16 @@ public class TokenOptions { return this.role; } + /** + * Whether the streams published by the participant owning this token will be + * recorded or not. This only affects INDIVIDUAL recording + */ + public Boolean record() { + return this.record; + } + /** * Returns the Kurento options assigned to this token */ diff --git a/openvidu-node-client/src/Session.ts b/openvidu-node-client/src/Session.ts index a9fead7b..6b87a53f 100644 --- a/openvidu-node-client/src/Session.ts +++ b/openvidu-node-client/src/Session.ts @@ -102,9 +102,10 @@ export class Session { const data = JSON.stringify({ session: this.sessionId, - role: (!!tokenOptions && !!tokenOptions.role) ? tokenOptions.role : OpenViduRole.PUBLISHER, - data: (!!tokenOptions && !!tokenOptions.data) ? tokenOptions.data : '', - kurentoOptions: (!!tokenOptions && !!tokenOptions.kurentoOptions) ? tokenOptions.kurentoOptions : {}, + data: (!!tokenOptions && !!tokenOptions.data) ? tokenOptions.data : null, + role: (!!tokenOptions && !!tokenOptions.role) ? tokenOptions.role : null, + record: !!tokenOptions ? tokenOptions.record : null, + kurentoOptions: (!!tokenOptions && !!tokenOptions.kurentoOptions) ? tokenOptions.kurentoOptions : null }); axios.post( diff --git a/openvidu-node-client/src/TokenOptions.ts b/openvidu-node-client/src/TokenOptions.ts index 910cd657..99a42b2d 100644 --- a/openvidu-node-client/src/TokenOptions.ts +++ b/openvidu-node-client/src/TokenOptions.ts @@ -32,9 +32,18 @@ export interface TokenOptions { /** * The role assigned to this token + * + * @default PUBLISHER */ role?: OpenViduRole; + /** + * Whether to record the streams published by the participant owning this token or not. This only affects [INDIVIDUAL recording](/en/stable/advanced-features/recording#selecting-streams-to-be-recorded) + * + * @default true + */ + record?: boolean; + /** * **WARNING**: experimental option. This interface may change in the near future *