openvidu-java-client/openvidu-node-client: "record" on TokenOptions

pull/533/head
pabloFuente 2020-09-07 13:47:28 +02:00
parent 7a9c6271dd
commit a146b55803
4 changed files with 58 additions and 9 deletions

View File

@ -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());
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) {

View File

@ -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 <a href=
* "https://docs.openvidu.io/en/stable/advanced-features/recording#selecting-streams-to-be-recorded"
* target="_blank">INDIVIDUAL recording</a>. 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 <a href=
* "https://docs.openvidu.io/en/stable/advanced-features/recording#selecting-streams-to-be-recorded"
* target="_blank">INDIVIDUAL recording</a>
*/
public Boolean record() {
return this.record;
}
/**
* Returns the Kurento options assigned to this token
*/

View File

@ -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(

View File

@ -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
*