Rename ConnectionOptions to ConnectionProperties

pull/553/head
pabloFuente 2020-10-21 22:19:01 +02:00
parent ab9725bd45
commit c5ae79b3a9
24 changed files with 254 additions and 244 deletions

View File

@ -39,7 +39,7 @@ public class Connection {
private String location; private String location;
private String platform; private String platform;
private String clientData; private String clientData;
private ConnectionOptions connectionOptions; private ConnectionProperties connectionProperties;
private String token; private String token;
protected Map<String, Publisher> publishers = new ConcurrentHashMap<>(); protected Map<String, Publisher> publishers = new ConcurrentHashMap<>();
@ -95,7 +95,7 @@ public class Connection {
* Returns the type of Connection. * Returns the type of Connection.
*/ */
public ConnectionType getType() { public ConnectionType getType() {
return this.connectionOptions.getType(); return this.connectionProperties.getType();
} }
/** /**
@ -104,7 +104,7 @@ public class Connection {
* when calling {@link io.openvidu.java.client.Session#generateToken()} * when calling {@link io.openvidu.java.client.Session#generateToken()}
*/ */
public String getServerData() { public String getServerData() {
return this.connectionOptions.getData(); return this.connectionProperties.getData();
} }
/** /**
@ -114,7 +114,7 @@ public class Connection {
* target="_blank">INDIVIDUAL recording</a>. * target="_blank">INDIVIDUAL recording</a>.
*/ */
public boolean record() { public boolean record() {
return this.connectionOptions.record(); return this.connectionProperties.record();
} }
/** /**
@ -126,7 +126,7 @@ public class Connection {
* {@link io.openvidu.java.client.ConnectionType#WEBRTC}</strong> * {@link io.openvidu.java.client.ConnectionType#WEBRTC}</strong>
*/ */
public OpenViduRole getRole() { public OpenViduRole getRole() {
return this.connectionOptions.getRole(); return this.connectionProperties.getRole();
} }
/** /**
@ -138,7 +138,7 @@ public class Connection {
* {@link io.openvidu.java.client.ConnectionType#IPCAM}</strong> * {@link io.openvidu.java.client.ConnectionType#IPCAM}</strong>
*/ */
public String getRtspUri() { public String getRtspUri() {
return this.connectionOptions.getRtspUri(); return this.connectionProperties.getRtspUri();
} }
/** /**
@ -154,7 +154,7 @@ public class Connection {
* {@link io.openvidu.java.client.ConnectionType#IPCAM}</strong> * {@link io.openvidu.java.client.ConnectionType#IPCAM}</strong>
*/ */
public boolean adaptativeBitrate() { public boolean adaptativeBitrate() {
return this.connectionOptions.adaptativeBitrate(); return this.connectionProperties.adaptativeBitrate();
} }
/** /**
@ -170,7 +170,7 @@ public class Connection {
* {@link io.openvidu.java.client.ConnectionType#IPCAM}</strong> * {@link io.openvidu.java.client.ConnectionType#IPCAM}</strong>
*/ */
public boolean onlyPlayWithSubscribers() { public boolean onlyPlayWithSubscribers() {
return this.connectionOptions.onlyPlayWithSubscribers(); return this.connectionProperties.onlyPlayWithSubscribers();
} }
/** /**
@ -186,7 +186,7 @@ public class Connection {
* {@link io.openvidu.java.client.ConnectionType#IPCAM}</strong> * {@link io.openvidu.java.client.ConnectionType#IPCAM}</strong>
*/ */
public int getNetworkCache() { public int getNetworkCache() {
return this.connectionOptions.getNetworkCache(); return this.connectionProperties.getNetworkCache();
} }
/** /**
@ -262,11 +262,11 @@ public class Connection {
json.addProperty("clientData", this.getClientData()); json.addProperty("clientData", this.getClientData());
json.addProperty("token", this.getToken()); json.addProperty("token", this.getToken());
JsonObject jsonConnectionOptions = this.connectionOptions.toJson(""); JsonObject jsonConnectionProperties = this.connectionProperties.toJson("");
jsonConnectionOptions.remove("session"); jsonConnectionProperties.remove("session");
json.addProperty("serverData", jsonConnectionOptions.get("data").getAsString()); json.addProperty("serverData", jsonConnectionProperties.get("data").getAsString());
jsonConnectionOptions.remove("data"); jsonConnectionProperties.remove("data");
jsonConnectionOptions.entrySet().forEach(entry -> { jsonConnectionProperties.entrySet().forEach(entry -> {
json.add(entry.getKey(), entry.getValue()); json.add(entry.getKey(), entry.getValue());
}); });
@ -283,33 +283,33 @@ public class Connection {
return json; return json;
} }
protected void overrideConnectionOptions(ConnectionOptions newConnectionOptions) { protected void overrideConnectionProperties(ConnectionProperties newConnectionProperties) {
ConnectionOptions.Builder builder = new ConnectionOptions.Builder(); ConnectionProperties.Builder builder = new ConnectionProperties.Builder();
// For now only properties role and record can be updated // For now only properties role and record can be updated
if (newConnectionOptions.getRole() != null) { if (newConnectionProperties.getRole() != null) {
builder.role(newConnectionOptions.getRole()); builder.role(newConnectionProperties.getRole());
} else { } else {
builder.role(this.connectionOptions.getRole()); builder.role(this.connectionProperties.getRole());
} }
if (newConnectionOptions.record() != null) { if (newConnectionProperties.record() != null) {
builder.record(newConnectionOptions.record()); builder.record(newConnectionProperties.record());
} else { } else {
builder.record(this.connectionOptions.record()); builder.record(this.connectionProperties.record());
} }
// Keep old configuration in the rest of properties // Keep old configuration in the rest of properties
builder.type(this.connectionOptions.getType()).data(this.connectionOptions.getData()) builder.type(this.connectionProperties.getType()).data(this.connectionProperties.getData())
.kurentoOptions(this.connectionOptions.getKurentoOptions()) .kurentoOptions(this.connectionProperties.getKurentoOptions())
.rtspUri(this.connectionOptions.getRtspUri()); .rtspUri(this.connectionProperties.getRtspUri());
if (this.connectionOptions.adaptativeBitrate() != null) { if (this.connectionProperties.adaptativeBitrate() != null) {
builder.adaptativeBitrate(this.connectionOptions.adaptativeBitrate()); builder.adaptativeBitrate(this.connectionProperties.adaptativeBitrate());
} }
if (this.connectionOptions.onlyPlayWithSubscribers() != null) { if (this.connectionProperties.onlyPlayWithSubscribers() != null) {
builder.onlyPlayWithSubscribers(this.connectionOptions.onlyPlayWithSubscribers()); builder.onlyPlayWithSubscribers(this.connectionProperties.onlyPlayWithSubscribers());
} }
if (this.connectionOptions.getNetworkCache() != null) { if (this.connectionProperties.getNetworkCache() != null) {
builder.networkCache(this.connectionOptions.getNetworkCache()); builder.networkCache(this.connectionProperties.getNetworkCache());
} }
this.connectionOptions = builder.build(); this.connectionProperties = builder.build();
} }
protected void setSubscribers(List<String> subscribers) { protected void setSubscribers(List<String> subscribers) {
@ -412,7 +412,7 @@ public class Connection {
Integer networkCache = (json.has("networkCache") && !json.get("networkCache").isJsonNull()) Integer networkCache = (json.has("networkCache") && !json.get("networkCache").isJsonNull())
? json.get("networkCache").getAsInt() ? json.get("networkCache").getAsInt()
: null; : null;
this.connectionOptions = new ConnectionOptions(type, data, record, role, null, rtspUri, adaptativeBitrate, this.connectionProperties = new ConnectionProperties(type, data, record, role, null, rtspUri, adaptativeBitrate,
onlyPlayWithSubscribers, networkCache); onlyPlayWithSubscribers, networkCache);
return this; return this;

View File

@ -5,9 +5,9 @@ import com.google.gson.JsonObject;
/** /**
* See * See
* {@link io.openvidu.java.client.Session#createConnection(ConnectionOptions)} * {@link io.openvidu.java.client.Session#createConnection(ConnectionProperties)}
*/ */
public class ConnectionOptions { public class ConnectionProperties {
private ConnectionType type; private ConnectionType type;
// COMMON // COMMON
@ -24,7 +24,7 @@ public class ConnectionOptions {
/** /**
* *
* Builder for {@link io.openvidu.java.client.ConnectionOptions} * Builder for {@link io.openvidu.java.client.ConnectionProperties}
* *
*/ */
public static class Builder { public static class Builder {
@ -43,10 +43,10 @@ public class ConnectionOptions {
private Integer networkCache; private Integer networkCache;
/** /**
* Builder for {@link io.openvidu.java.client.ConnectionOptions}. * Builder for {@link io.openvidu.java.client.ConnectionProperties}.
*/ */
public ConnectionOptions build() { public ConnectionProperties build() {
return new ConnectionOptions(this.type, this.data, this.record, this.role, this.kurentoOptions, return new ConnectionProperties(this.type, this.data, this.record, this.role, this.kurentoOptions,
this.rtspUri, this.adaptativeBitrate, this.onlyPlayWithSubscribers, this.networkCache); this.rtspUri, this.adaptativeBitrate, this.onlyPlayWithSubscribers, this.networkCache);
} }
@ -56,24 +56,24 @@ public class ConnectionOptions {
* have effect: * have effect:
* <ul> * <ul>
* <li>{@link io.openvidu.java.client.ConnectionType#WEBRTC}: * <li>{@link io.openvidu.java.client.ConnectionType#WEBRTC}:
* {@link io.openvidu.java.client.ConnectionOptions.Builder#data(String) data}, * {@link io.openvidu.java.client.ConnectionProperties.Builder#data(String) data},
* {@link io.openvidu.java.client.ConnectionOptions.Builder#record(boolean) * {@link io.openvidu.java.client.ConnectionProperties.Builder#record(boolean)
* record}, * record},
* {@link io.openvidu.java.client.ConnectionOptions.Builder#role(OpenViduRole) * {@link io.openvidu.java.client.ConnectionProperties.Builder#role(OpenViduRole)
* role}, * role},
* {@link io.openvidu.java.client.ConnectionOptions.Builder#kurentoOptions(KurentoOptions) * {@link io.openvidu.java.client.ConnectionProperties.Builder#kurentoOptions(KurentoOptions)
* kurentoOptions}</li> * kurentoOptions}</li>
* <li>{@link io.openvidu.java.client.ConnectionType#IPCAM}: * <li>{@link io.openvidu.java.client.ConnectionType#IPCAM}:
* {@link io.openvidu.java.client.ConnectionOptions.Builder#data(String) data}, * {@link io.openvidu.java.client.ConnectionProperties.Builder#data(String) data},
* {@link io.openvidu.java.client.ConnectionOptions.Builder#record(boolean) * {@link io.openvidu.java.client.ConnectionProperties.Builder#record(boolean)
* record}, * record},
* {@link io.openvidu.java.client.ConnectionOptions.Builder#rtspUri(String) * {@link io.openvidu.java.client.ConnectionProperties.Builder#rtspUri(String)
* rtspUri}, * rtspUri},
* {@link io.openvidu.java.client.ConnectionOptions.Builder#adaptativeBitrate(boolean) * {@link io.openvidu.java.client.ConnectionProperties.Builder#adaptativeBitrate(boolean)
* adaptativeBitrate}, * adaptativeBitrate},
* {@link io.openvidu.java.client.ConnectionOptions.Builder#onlyPlayWithSubscribers(boolean) * {@link io.openvidu.java.client.ConnectionProperties.Builder#onlyPlayWithSubscribers(boolean)
* onlyPlayWithSubscribers}, * onlyPlayWithSubscribers},
* {@link io.openvidu.java.client.ConnectionOptions.Builder#networkCache(int) * {@link io.openvidu.java.client.ConnectionProperties.Builder#networkCache(int)
* networkCache}</li> * networkCache}</li>
* </ul> * </ul>
* If not set by default will be @link * If not set by default will be @link
@ -94,7 +94,7 @@ public class ConnectionOptions {
* <li>If you have provided no data in your clients when calling method * <li>If you have provided no data in your clients when calling method
* <code>Session.connect(TOKEN, DATA)</code> (<code>DATA</code> not defined), * <code>Session.connect(TOKEN, DATA)</code> (<code>DATA</code> not defined),
* then <code>Connection.data</code> will only have this * then <code>Connection.data</code> will only have this
* {@link io.openvidu.java.client.ConnectionOptions.Builder#data(String)} * {@link io.openvidu.java.client.ConnectionProperties.Builder#data(String)}
* property.</li> * property.</li>
* <li>If you have provided some data when calling * <li>If you have provided some data when calling
* <code>Session.connect(TOKEN, DATA)</code> (<code>DATA</code> defined), then * <code>Session.connect(TOKEN, DATA)</code> (<code>DATA</code> defined), then
@ -102,7 +102,7 @@ public class ConnectionOptions {
* <code>&quot;CLIENT_DATA%/%SERVER_DATA&quot;</code>, being * <code>&quot;CLIENT_DATA%/%SERVER_DATA&quot;</code>, being
* <code>CLIENT_DATA</code> the second parameter passed in OpenVidu Browser in * <code>CLIENT_DATA</code> the second parameter passed in OpenVidu Browser in
* method <code>Session.connect</code> and <code>SERVER_DATA</code> this * method <code>Session.connect</code> and <code>SERVER_DATA</code> this
* {@link io.openvidu.java.client.ConnectionOptions.Builder#data(String)} * {@link io.openvidu.java.client.ConnectionProperties.Builder#data(String)}
* property.</li> * property.</li>
* </ul> * </ul>
*/ */
@ -219,7 +219,7 @@ public class ConnectionOptions {
} }
} }
ConnectionOptions(ConnectionType type, String data, Boolean record, OpenViduRole role, ConnectionProperties(ConnectionType type, String data, Boolean record, OpenViduRole role,
KurentoOptions kurentoOptions, String rtspUri, Boolean adaptativeBitrate, Boolean onlyPlayWithSubscribers, KurentoOptions kurentoOptions, String rtspUri, Boolean adaptativeBitrate, Boolean onlyPlayWithSubscribers,
Integer networkCache) { Integer networkCache) {
this.type = type; this.type = type;

View File

@ -105,8 +105,8 @@ public class Session {
/** /**
* @deprecated Use * @deprecated Use
* {@link Session#createConnection(io.openvidu.java.client.ConnectionOptions) * {@link Session#createConnection(io.openvidu.java.client.ConnectionProperties)
* Session.createConnection(ConnectionOptions)} instead to get a * Session.createConnection(ConnectionProperties)} instead to get a
* {@link io.openvidu.java.client.Connection} object. * {@link io.openvidu.java.client.Connection} object.
* *
* @return The generated token String * @return The generated token String
@ -155,8 +155,8 @@ public class Session {
/** /**
* Same as * Same as
* {@link io.openvidu.java.client.Session#createConnection(ConnectionOptions) * {@link io.openvidu.java.client.Session#createConnection(ConnectionProperties)
* but with default ConnectionOptions values. * but with default ConnectionProperties values.
* *
* @return The generated {@link io.openvidu.java.client.Connection Connection} * @return The generated {@link io.openvidu.java.client.Connection Connection}
* object. * object.
@ -166,12 +166,12 @@ public class Session {
*/ */
public Connection createConnection() throws OpenViduJavaClientException, OpenViduHttpException { public Connection createConnection() throws OpenViduJavaClientException, OpenViduHttpException {
return createConnection( return createConnection(
new ConnectionOptions.Builder().data("").role(OpenViduRole.PUBLISHER).record(true).build()); new ConnectionProperties.Builder().data("").role(OpenViduRole.PUBLISHER).record(true).build());
} }
/** /**
* Creates a new Connection object associated to Session object and configured * Creates a new Connection object associated to Session object and configured
* with <code>connectionOptions</code>. Each user connecting to the Session * with <code>connectionProperties</code>. Each user connecting to the Session
* requires a Connection. The token string value to send to the client side can * requires a Connection. The token string value to send to the client side can
* be retrieved with {@link io.openvidu.java.client.Connection#getToken() * be retrieved with {@link io.openvidu.java.client.Connection#getToken()
* Connection.getToken()}. * Connection.getToken()}.
@ -182,7 +182,7 @@ public class Session {
* @throws OpenViduJavaClientException * @throws OpenViduJavaClientException
* @throws OpenViduHttpException * @throws OpenViduHttpException
*/ */
public Connection createConnection(ConnectionOptions connectionOptions) public Connection createConnection(ConnectionProperties connectionProperties)
throws OpenViduJavaClientException, OpenViduHttpException { throws OpenViduJavaClientException, OpenViduHttpException {
if (!this.hasSessionId()) { if (!this.hasSessionId()) {
this.getSessionId(); this.getSessionId();
@ -193,7 +193,7 @@ public class Session {
StringEntity params; StringEntity params;
try { try {
params = new StringEntity(connectionOptions.toJson(sessionId).toString()); params = new StringEntity(connectionProperties.toJson(sessionId).toString());
} catch (UnsupportedEncodingException e1) { } catch (UnsupportedEncodingException e1) {
throw new OpenViduJavaClientException(e1.getMessage(), e1.getCause()); throw new OpenViduJavaClientException(e1.getMessage(), e1.getCause());
} }
@ -261,7 +261,7 @@ public class Session {
* those values to call * those values to call
* {@link io.openvidu.java.client.Session#forceDisconnect(Connection)}, * {@link io.openvidu.java.client.Session#forceDisconnect(Connection)},
* {@link io.openvidu.java.client.Session#forceUnpublish(Publisher)} or * {@link io.openvidu.java.client.Session#forceUnpublish(Publisher)} or
* {@link io.openvidu.java.client.Session#updateConnection(String, ConnectionOptions)}.<br> * {@link io.openvidu.java.client.Session#updateConnection(String, ConnectionProperties)}.<br>
* <br> * <br>
* *
* To update all Session objects owned by OpenVidu object at once, call * To update all Session objects owned by OpenVidu object at once, call
@ -338,7 +338,7 @@ public class Session {
/** /**
* Same as {@link io.openvidu.java.client.Session#forceDisconnect(Connection) * Same as {@link io.openvidu.java.client.Session#forceDisconnect(Connection)
* forceDisconnect(ConnectionOptions)} but providing the * forceDisconnect(ConnectionProperties)} but providing the
* {@link io.openvidu.java.client.Connection#getConnectionId() connectionId} * {@link io.openvidu.java.client.Connection#getConnectionId() connectionId}
* instead of the Connection object. * instead of the Connection object.
* *
@ -464,13 +464,13 @@ public class Session {
/** /**
* Updates the properties of a Connection with a * Updates the properties of a Connection with a
* {@link io.openvidu.java.client.ConnectionOptions} object. Only these * {@link io.openvidu.java.client.ConnectionProperties} object. Only these
* properties can be updated: * properties can be updated:
* <ul> * <ul>
* <li>{@link io.openvidu.java.client.ConnectionOptions.Builder#role(OpenViduRole) * <li>{@link io.openvidu.java.client.ConnectionProperties.Builder#role(OpenViduRole)
* ConnectionOptions.Builder.role(OpenViduRole)}</li> * ConnectionProperties.Builder.role(OpenViduRole)}</li>
* <li>{@link io.openvidu.java.client.ConnectionOptions.Builder#record(boolean) * <li>{@link io.openvidu.java.client.ConnectionProperties.Builder#record(boolean)
* ConnectionOptions.Builder.record(boolean)}</li> * ConnectionProperties.Builder.record(boolean)}</li>
* </ul> * </ul>
* <br> * <br>
* *
@ -482,7 +482,7 @@ public class Session {
* objects. * objects.
* *
* @param connectionId The Connection to modify * @param connectionId The Connection to modify
* @param connectionOptions A ConnectionOptions object with the new values to * @param connectionProperties A ConnectionProperties object with the new values to
* apply * apply
* *
* @return The updated {@link io.openvidu.java.client.Connection Connection} * @return The updated {@link io.openvidu.java.client.Connection Connection}
@ -491,7 +491,7 @@ public class Session {
* @throws OpenViduJavaClientException * @throws OpenViduJavaClientException
* @throws OpenViduHttpException * @throws OpenViduHttpException
*/ */
public Connection updateConnection(String connectionId, ConnectionOptions connectionOptions) public Connection updateConnection(String connectionId, ConnectionProperties connectionProperties)
throws OpenViduJavaClientException, OpenViduHttpException { throws OpenViduJavaClientException, OpenViduHttpException {
HttpPatch request = new HttpPatch( HttpPatch request = new HttpPatch(
@ -499,7 +499,7 @@ public class Session {
StringEntity params; StringEntity params;
try { try {
params = new StringEntity(connectionOptions.toJson(this.sessionId).toString()); params = new StringEntity(connectionProperties.toJson(this.sessionId).toString());
} catch (UnsupportedEncodingException e1) { } catch (UnsupportedEncodingException e1) {
throw new OpenViduJavaClientException(e1.getMessage(), e1.getCause()); throw new OpenViduJavaClientException(e1.getMessage(), e1.getCause());
} }
@ -534,7 +534,7 @@ public class Session {
return newConnection; return newConnection;
} else { } else {
// The updated Connection was available in local map // The updated Connection was available in local map
existingConnection.overrideConnectionOptions(connectionOptions); existingConnection.overrideConnectionProperties(connectionProperties);
return existingConnection; return existingConnection;
} }
@ -572,15 +572,15 @@ public class Session {
* called</strong>. Exceptions to this rule are: * called</strong>. Exceptions to this rule are:
* <ul> * <ul>
* <li>Calling * <li>Calling
* {@link io.openvidu.java.client.Session#createConnection(ConnectionOptions) * {@link io.openvidu.java.client.Session#createConnection(ConnectionProperties)
* createConnection(ConnectionOptions)} automatically adds the new Connection * createConnection(ConnectionProperties)} automatically adds the new Connection
* object to the local collection.</li> * object to the local collection.</li>
* <li>Calling {@link io.openvidu.java.client.Session#forceUnpublish(String)} * <li>Calling {@link io.openvidu.java.client.Session#forceUnpublish(String)}
* automatically updates each affected local Connection object.</li> * automatically updates each affected local Connection object.</li>
* <li>Calling {@link io.openvidu.java.client.Session#forceDisconnect(String)} * <li>Calling {@link io.openvidu.java.client.Session#forceDisconnect(String)}
* automatically updates each affected local Connection object.</li> * automatically updates each affected local Connection object.</li>
* <li>Calling * <li>Calling
* {@link io.openvidu.java.client.Session#updateConnection(String, ConnectionOptions)} * {@link io.openvidu.java.client.Session#updateConnection(String, ConnectionProperties)}
* automatically updates the attributes of the affected local Connection * automatically updates the attributes of the affected local Connection
* object.</li> * object.</li>
* </ul> * </ul>
@ -604,15 +604,15 @@ public class Session {
* called</strong>. Exceptions to this rule are: * called</strong>. Exceptions to this rule are:
* <ul> * <ul>
* <li>Calling * <li>Calling
* {@link io.openvidu.java.client.Session#createConnection(ConnectionOptions) * {@link io.openvidu.java.client.Session#createConnection(ConnectionProperties)
* createConnection(ConnectionOptions)} automatically adds the new Connection * createConnection(ConnectionProperties)} automatically adds the new Connection
* object to the local collection.</li> * object to the local collection.</li>
* <li>Calling {@link io.openvidu.java.client.Session#forceUnpublish(String)} * <li>Calling {@link io.openvidu.java.client.Session#forceUnpublish(String)}
* automatically updates each affected local Connection object.</li> * automatically updates each affected local Connection object.</li>
* <li>Calling {@link io.openvidu.java.client.Session#forceDisconnect(String)} * <li>Calling {@link io.openvidu.java.client.Session#forceDisconnect(String)}
* automatically updates each affected local Connection object.</li> * automatically updates each affected local Connection object.</li>
* <li>Calling * <li>Calling
* {@link io.openvidu.java.client.Session#updateConnection(String, ConnectionOptions)} * {@link io.openvidu.java.client.Session#updateConnection(String, ConnectionProperties)}
* automatically updates the attributes of the affected local Connection * automatically updates the attributes of the affected local Connection
* object.</li> * object.</li>
* </ul> * </ul>

View File

@ -21,8 +21,8 @@ import com.google.gson.JsonNull;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
/** /**
* @deprecated Use {@link io.openvidu.java.client.ConnectionOptions * @deprecated Use {@link io.openvidu.java.client.ConnectionProperties
* ConnectionOptions} instead * ConnectionProperties} instead
*/ */
public class TokenOptions { public class TokenOptions {
@ -32,8 +32,8 @@ public class TokenOptions {
private KurentoOptions kurentoOptions; private KurentoOptions kurentoOptions;
/** /**
* @deprecated Use {@link io.openvidu.java.client.ConnectionOptions.Builder * @deprecated Use {@link io.openvidu.java.client.ConnectionProperties.Builder
* ConnectionOptions.Builder} instead * ConnectionProperties.Builder} instead
*/ */
public static class Builder { public static class Builder {

View File

@ -16,7 +16,7 @@
*/ */
import { Publisher } from './Publisher'; import { Publisher } from './Publisher';
import { ConnectionOptions } from './ConnectionOptions'; import { ConnectionProperties } from './ConnectionProperties';
import { OpenViduRole } from './OpenViduRole'; import { OpenViduRole } from './OpenViduRole';
/** /**
@ -71,9 +71,9 @@ export class Connection {
clientData: string; clientData: string;
/** /**
* The [[ConnectionOptions]] assigned to the Connection * The [[ConnectionProperties]] assigned to the Connection
*/ */
connectionOptions: ConnectionOptions; connectionProperties: ConnectionProperties;
/** /**
* Token associated to the Connection * Token associated to the Connection
@ -93,11 +93,11 @@ export class Connection {
subscribers: string[] = []; subscribers: string[] = [];
/** /**
* @hidden deprecated. Inside ConnectionOptions * @hidden deprecated. Inside ConnectionProperties
*/ */
role?: OpenViduRole; role?: OpenViduRole;
/** /**
* @hidden deprecated. Inside ConnectionOptions * @hidden deprecated. Inside ConnectionProperties
*/ */
serverData?: string; serverData?: string;
@ -121,18 +121,18 @@ export class Connection {
this.platform = json.platform; this.platform = json.platform;
this.clientData = json.clientData; this.clientData = json.clientData;
this.token = json.token; this.token = json.token;
if (this.connectionOptions != null) { if (this.connectionProperties != null) {
this.connectionOptions.type = json.type; this.connectionProperties.type = json.type;
this.connectionOptions.data = json.data; this.connectionProperties.data = json.data;
this.connectionOptions.record = json.record; this.connectionProperties.record = json.record;
this.connectionOptions.role = json.role; this.connectionProperties.role = json.role;
this.connectionOptions.kurentoOptions = json.kurentoOptions; this.connectionProperties.kurentoOptions = json.kurentoOptions;
this.connectionOptions.rtspUri = json.rtspUri; this.connectionProperties.rtspUri = json.rtspUri;
this.connectionOptions.adaptativeBitrate = json.adaptativeBitrate; this.connectionProperties.adaptativeBitrate = json.adaptativeBitrate;
this.connectionOptions.onlyPlayWithSubscribers = json.onlyPlayWithSubscribers; this.connectionProperties.onlyPlayWithSubscribers = json.onlyPlayWithSubscribers;
this.connectionOptions.networkCache = json.networkCache; this.connectionProperties.networkCache = json.networkCache;
} else { } else {
this.connectionOptions = { this.connectionProperties = {
type: json.type, type: json.type,
data: json.data, data: json.data,
record: json.record, record: json.record,
@ -209,14 +209,14 @@ export class Connection {
this.status === other.status && this.status === other.status &&
this.createdAt === other.createdAt && this.createdAt === other.createdAt &&
this.activeAt === other.activeAt && this.activeAt === other.activeAt &&
this.connectionOptions.type === other.connectionOptions.type && this.connectionProperties.type === other.connectionProperties.type &&
this.connectionOptions.data === other.connectionOptions.data && this.connectionProperties.data === other.connectionProperties.data &&
this.connectionOptions.record === other.connectionOptions.record && this.connectionProperties.record === other.connectionProperties.record &&
this.connectionOptions.role === other.connectionOptions.role && this.connectionProperties.role === other.connectionProperties.role &&
this.connectionOptions.rtspUri === other.connectionOptions.rtspUri && this.connectionProperties.rtspUri === other.connectionProperties.rtspUri &&
this.connectionOptions.adaptativeBitrate === other.connectionOptions.adaptativeBitrate && this.connectionProperties.adaptativeBitrate === other.connectionProperties.adaptativeBitrate &&
this.connectionOptions.onlyPlayWithSubscribers === other.connectionOptions.onlyPlayWithSubscribers && this.connectionProperties.onlyPlayWithSubscribers === other.connectionProperties.onlyPlayWithSubscribers &&
this.connectionOptions.networkCache === other.connectionOptions.networkCache && this.connectionProperties.networkCache === other.connectionProperties.networkCache &&
this.token === other.token && this.token === other.token &&
this.location === other.location && this.location === other.location &&
this.platform === other.platform && this.platform === other.platform &&
@ -224,10 +224,10 @@ export class Connection {
this.subscribers.length === other.subscribers.length && this.subscribers.length === other.subscribers.length &&
this.publishers.length === other.publishers.length); this.publishers.length === other.publishers.length);
if (equals) { if (equals) {
if (this.connectionOptions.kurentoOptions != null) { if (this.connectionProperties.kurentoOptions != null) {
equals = JSON.stringify(this.connectionOptions.kurentoOptions) === JSON.stringify(other.connectionOptions.kurentoOptions); equals = JSON.stringify(this.connectionProperties.kurentoOptions) === JSON.stringify(other.connectionProperties.kurentoOptions);
} else { } else {
equals = (this.connectionOptions.kurentoOptions === other.connectionOptions.kurentoOptions); equals = (this.connectionProperties.kurentoOptions === other.connectionProperties.kurentoOptions);
} }
} }
if (equals) { if (equals) {
@ -250,13 +250,13 @@ export class Connection {
/** /**
* @hidden * @hidden
*/ */
overrideConnectionOptions(newConnectionOptions: ConnectionOptions): void { overrideConnectionProperties(newConnectionProperties: ConnectionProperties): void {
// For now only properties record and role // For now only properties record and role
if (newConnectionOptions.record != null) { if (newConnectionProperties.record != null) {
this.connectionOptions.record = newConnectionOptions.record; this.connectionProperties.record = newConnectionProperties.record;
} }
if (newConnectionOptions.role != null) { if (newConnectionProperties.role != null) {
this.connectionOptions.role = newConnectionOptions.role; this.connectionProperties.role = newConnectionProperties.role;
} }
} }

View File

@ -18,7 +18,7 @@
import { ConnectionType } from './ConnectionType'; import { ConnectionType } from './ConnectionType';
import { OpenViduRole } from './OpenViduRole'; import { OpenViduRole } from './OpenViduRole';
export interface ConnectionOptions { export interface ConnectionProperties {
/** /**
* Type of Connection. The [[ConnectionType]] dictates what properties will have effect: * Type of Connection. The [[ConnectionType]] dictates what properties will have effect:
@ -32,9 +32,9 @@ export interface ConnectionOptions {
/** /**
* Secure (server-side) data associated to this Connection. Every client will receive this data in property `Connection.data`. Object `Connection` can be retrieved by subscribing to event `connectionCreated` of Session object. * Secure (server-side) data associated to this Connection. Every client will receive this data in property `Connection.data`. Object `Connection` can be retrieved by subscribing to event `connectionCreated` of Session object.
* - If you have provided no data in your clients when calling method `Session.connect(TOKEN, DATA)` (`DATA` not defined), then `Connection.data` will only have this [[ConnectionOptions.data]] property. * - If you have provided no data in your clients when calling method `Session.connect(TOKEN, DATA)` (`DATA` not defined), then `Connection.data` will only have this [[ConnectionProperties.data]] property.
* - If you have provided some data when calling `Session.connect(TOKEN, DATA)` (`DATA` defined), then `Connection.data` will have the following structure: `"CLIENT_DATA%/%SERVER_DATA"`, being `CLIENT_DATA` the second * - If you have provided some data when calling `Session.connect(TOKEN, DATA)` (`DATA` defined), then `Connection.data` will have the following structure: `"CLIENT_DATA%/%SERVER_DATA"`, being `CLIENT_DATA` the second
* parameter passed in OpenVidu Browser in method `Session.connect` and `SERVER_DATA` this [[ConnectionOptions.data]] property. * parameter passed in OpenVidu Browser in method `Session.connect` and `SERVER_DATA` this [[ConnectionProperties.data]] property.
*/ */
data?: string; data?: string;

View File

@ -17,7 +17,7 @@
import axios, { AxiosError } from 'axios'; import axios, { AxiosError } from 'axios';
import { Connection } from './Connection'; import { Connection } from './Connection';
import { ConnectionOptions } from './ConnectionOptions'; import { ConnectionProperties } from './ConnectionProperties';
import { MediaMode } from './MediaMode'; import { MediaMode } from './MediaMode';
import { OpenVidu } from './OpenVidu'; import { OpenVidu } from './OpenVidu';
import { Publisher } from './Publisher'; import { Publisher } from './Publisher';
@ -143,18 +143,18 @@ export class Session {
/** /**
* Creates a new Connection object associated to Session object and configured with * Creates a new Connection object associated to Session object and configured with
* `connectionOptions`. Each user connecting to the Session requires a Connection. * `connectionProperties`. Each user connecting to the Session requires a Connection.
* The token string value to send to the client side is available at [[Connection.token]]. * The token string value to send to the client side is available at [[Connection.token]].
* *
* @returns A Promise that is resolved to the generated [[Connection]] object if success and rejected with an Error object if not * @returns A Promise that is resolved to the generated [[Connection]] object if success and rejected with an Error object if not
*/ */
public createConnection(connectionOptions?: ConnectionOptions): Promise<Connection> { public createConnection(connectionProperties?: ConnectionProperties): Promise<Connection> {
return new Promise<Connection>((resolve, reject) => { return new Promise<Connection>((resolve, reject) => {
const data = JSON.stringify({ const data = JSON.stringify({
role: (!!connectionOptions && !!connectionOptions.role) ? connectionOptions.role : null, role: (!!connectionProperties && !!connectionProperties.role) ? connectionProperties.role : null,
data: (!!connectionOptions && !!connectionOptions.data) ? connectionOptions.data : null, data: (!!connectionProperties && !!connectionProperties.data) ? connectionProperties.data : null,
record: !!connectionOptions ? connectionOptions.record : null, record: !!connectionProperties ? connectionProperties.record : null,
kurentoOptions: (!!connectionOptions && !!connectionOptions.kurentoOptions) ? connectionOptions.kurentoOptions : null kurentoOptions: (!!connectionProperties && !!connectionProperties.kurentoOptions) ? connectionProperties.kurentoOptions : null
}); });
axios.post( axios.post(
this.ov.host + OpenVidu.API_SESSIONS + '/' + this.sessionId + '/connection', this.ov.host + OpenVidu.API_SESSIONS + '/' + this.sessionId + '/connection',
@ -390,26 +390,26 @@ export class Session {
} }
/** /**
* Updates the properties of a Connection with a [[ConnectionOptions]] object. * Updates the properties of a Connection with a [[ConnectionProperties]] object.
* Only these properties can be updated: * Only these properties can be updated:
* *
* - [[ConnectionOptions.role]] * - [[ConnectionProperties.role]]
* - [[ConnectionOptions.record]] * - [[ConnectionProperties.record]]
* *
* This method automatically updates the properties of the local affected objects. This means that there is no need to call * This method automatically updates the properties of the local affected objects. This means that there is no need to call
* [[Session.fetch]] or [[OpenVidu.fetch]] to see the changes consequence of the execution of this method applied in the local objects. * [[Session.fetch]] or [[OpenVidu.fetch]] to see the changes consequence of the execution of this method applied in the local objects.
* *
* @param connectionId The [[Connection.connectionId]] of the Connection object to modify * @param connectionId The [[Connection.connectionId]] of the Connection object to modify
* @param connectionOptions A new [[ConnectionOptions]] object with the updated values to apply * @param connectionProperties A new [[ConnectionProperties]] object with the updated values to apply
* *
* @returns A Promise that is resolved to the updated [[Connection]] object if the operation was * @returns A Promise that is resolved to the updated [[Connection]] object if the operation was
* successful and rejected with an Error object if not * successful and rejected with an Error object if not
*/ */
public updateConnection(connectionId: string, connectionOptions: ConnectionOptions): Promise<Connection | undefined> { public updateConnection(connectionId: string, connectionProperties: ConnectionProperties): Promise<Connection | undefined> {
return new Promise<any>((resolve, reject) => { return new Promise<any>((resolve, reject) => {
axios.patch( axios.patch(
this.ov.host + OpenVidu.API_SESSIONS + "/" + this.sessionId + "/connection/" + connectionId, this.ov.host + OpenVidu.API_SESSIONS + "/" + this.sessionId + "/connection/" + connectionId,
connectionOptions, connectionProperties,
{ {
headers: { headers: {
'Authorization': this.ov.basicAuth, 'Authorization': this.ov.basicAuth,
@ -437,7 +437,7 @@ export class Session {
resolve(newConnection); resolve(newConnection);
} else { } else {
// The updated Connection was available in local map // The updated Connection was available in local map
existingConnection.overrideConnectionOptions(connectionOptions); existingConnection.overrideConnectionProperties(connectionProperties);
this.updateActiveConnectionsArray(); this.updateActiveConnectionsArray();
resolve(existingConnection); resolve(existingConnection);
} }

View File

@ -18,7 +18,7 @@
import { OpenViduRole } from './OpenViduRole'; import { OpenViduRole } from './OpenViduRole';
/** /**
* @deprecated Use [[ConnectionOptions]] instead * @deprecated Use [[ConnectionProperties]] instead
*/ */
export interface TokenOptions { export interface TokenOptions {

View File

@ -3,7 +3,7 @@ export * from './OpenViduRole';
export * from './Session'; export * from './Session';
export * from './SessionProperties'; export * from './SessionProperties';
export * from './TokenOptions'; export * from './TokenOptions';
export * from './ConnectionOptions'; export * from './ConnectionProperties';
export * from './ConnectionType'; export * from './ConnectionType';
export * from './MediaMode'; export * from './MediaMode';
export * from './RecordingLayout'; export * from './RecordingLayout';

View File

@ -218,11 +218,20 @@ public class Participant {
} }
public String getFullMetadata() { public String getFullMetadata() {
String fullMetadata; String fullMetadata = "";
if ((!this.clientMetadata.isEmpty()) && (!this.token.getServerMetadata().isEmpty())) { if (this.clientMetadata != null && !this.clientMetadata.isEmpty()) {
fullMetadata = this.clientMetadata + METADATA_SEPARATOR + this.token.getServerMetadata(); // Client data defined
} else { fullMetadata += this.clientMetadata;
fullMetadata = this.clientMetadata + this.token.getServerMetadata(); }
if (this.token.getServerMetadata() != null && !this.token.getServerMetadata().isEmpty()) {
// Server data defined
if (fullMetadata.isEmpty()) {
// Only server data
fullMetadata += this.token.getServerMetadata();
} else {
// Both client data and server data
fullMetadata += METADATA_SEPARATOR + this.token.getServerMetadata();
}
} }
return fullMetadata; return fullMetadata;
} }
@ -305,9 +314,9 @@ public class Participant {
} else { } else {
json.add("token", null); json.add("token", null);
} }
// Add all ConnectionOptions // Add all ConnectionProperties
JsonObject connectionOptionsJson = this.token.getConnectionOptionsWithFinalJsonFormat(); JsonObject connectionPropertiesJson = this.token.getConnectionPropertiesWithFinalJsonFormat();
connectionOptionsJson.entrySet().forEach(entry -> { connectionPropertiesJson.entrySet().forEach(entry -> {
json.add(entry.getKey(), entry.getValue()); json.add(entry.getKey(), entry.getValue());
}); });
json.addProperty("clientData", this.clientMetadata); json.addProperty("clientData", this.clientMetadata);

View File

@ -45,7 +45,7 @@ import com.google.gson.JsonSyntaxException;
import io.openvidu.client.OpenViduException; import io.openvidu.client.OpenViduException;
import io.openvidu.client.OpenViduException.Code; import io.openvidu.client.OpenViduException.Code;
import io.openvidu.client.internal.ProtocolElements; import io.openvidu.client.internal.ProtocolElements;
import io.openvidu.java.client.ConnectionOptions; import io.openvidu.java.client.ConnectionProperties;
import io.openvidu.java.client.ConnectionType; import io.openvidu.java.client.ConnectionType;
import io.openvidu.java.client.KurentoOptions; import io.openvidu.java.client.KurentoOptions;
import io.openvidu.java.client.OpenViduRole; import io.openvidu.java.client.OpenViduRole;
@ -162,7 +162,7 @@ public abstract class SessionManager {
String eventType); String eventType);
public abstract Participant publishIpcam(Session session, MediaOptions mediaOptions, public abstract Participant publishIpcam(Session session, MediaOptions mediaOptions,
ConnectionOptions connectionOptions) throws Exception; ConnectionProperties connectionProperties) throws Exception;
public abstract void reconnectStream(Participant participant, String streamId, String sdpOffer, public abstract void reconnectStream(Participant participant, String streamId, String sdpOffer,
Integer transactionId); Integer transactionId);
@ -314,9 +314,9 @@ public abstract class SessionManager {
return tokenObj; return tokenObj;
} }
public Token newTokenForInsecureUser(Session session, String token, ConnectionOptions connectionOptions) public Token newTokenForInsecureUser(Session session, String token, ConnectionProperties connectionProperties)
throws Exception { throws Exception {
Token tokenObj = new Token(token, session.getSessionId(), connectionOptions, Token tokenObj = new Token(token, session.getSessionId(), connectionProperties,
this.openviduConfig.isTurnadminAvailable() ? this.coturnCredentialsService.createUser() : null); this.openviduConfig.isTurnadminAvailable() ? this.coturnCredentialsService.createUser() : null);
session.storeToken(tokenObj); session.storeToken(tokenObj);
session.showTokens("Token created for insecure user"); session.showTokens("Token created for insecure user");

View File

@ -21,7 +21,7 @@ import org.apache.commons.lang3.RandomStringUtils;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import io.openvidu.java.client.ConnectionOptions; import io.openvidu.java.client.ConnectionProperties;
import io.openvidu.java.client.ConnectionType; import io.openvidu.java.client.ConnectionType;
import io.openvidu.java.client.KurentoOptions; import io.openvidu.java.client.KurentoOptions;
import io.openvidu.java.client.OpenViduRole; import io.openvidu.java.client.OpenViduRole;
@ -33,22 +33,22 @@ public class Token {
private String token; private String token;
private String sessionId; private String sessionId;
private Long createdAt; private Long createdAt;
private ConnectionOptions connectionOptions; private ConnectionProperties connectionProperties;
private TurnCredentials turnCredentials; private TurnCredentials turnCredentials;
private final String connectionId = IdentifierPrefixes.PARTICIPANT_PUBLIC_ID private final String connectionId = IdentifierPrefixes.PARTICIPANT_PUBLIC_ID
+ RandomStringUtils.randomAlphabetic(1).toUpperCase() + RandomStringUtils.randomAlphanumeric(9); + RandomStringUtils.randomAlphabetic(1).toUpperCase() + RandomStringUtils.randomAlphanumeric(9);
public Token(String token, String sessionId, ConnectionOptions connectionOptions, TurnCredentials turnCredentials) { public Token(String token, String sessionId, ConnectionProperties connectionProperties, TurnCredentials turnCredentials) {
this.token = token; this.token = token;
this.sessionId = sessionId; this.sessionId = sessionId;
this.createdAt = System.currentTimeMillis(); this.createdAt = System.currentTimeMillis();
this.connectionOptions = connectionOptions; this.connectionProperties = connectionProperties;
this.turnCredentials = turnCredentials; this.turnCredentials = turnCredentials;
} }
public ConnectionType getType() { public ConnectionType getType() {
return this.connectionOptions.getType(); return this.connectionProperties.getType();
} }
public String getToken() { public String getToken() {
@ -64,49 +64,49 @@ public class Token {
} }
public String getServerMetadata() { public String getServerMetadata() {
return this.connectionOptions.getData(); return this.connectionProperties.getData();
} }
public boolean record() { public boolean record() {
return this.connectionOptions.record(); return this.connectionProperties.record();
} }
public void setRecord(boolean newRecord) { public void setRecord(boolean newRecord) {
this.updateConnectionOptions(connectionOptions.getType(), connectionOptions.getData(), newRecord, this.updateConnectionProperties(connectionProperties.getType(), connectionProperties.getData(), newRecord,
connectionOptions.getRole(), connectionOptions.getKurentoOptions(), connectionOptions.getRtspUri(), connectionProperties.getRole(), connectionProperties.getKurentoOptions(), connectionProperties.getRtspUri(),
connectionOptions.adaptativeBitrate(), connectionOptions.onlyPlayWithSubscribers(), connectionProperties.adaptativeBitrate(), connectionProperties.onlyPlayWithSubscribers(),
connectionOptions.getNetworkCache()); connectionProperties.getNetworkCache());
} }
public OpenViduRole getRole() { public OpenViduRole getRole() {
return this.connectionOptions.getRole(); return this.connectionProperties.getRole();
} }
public void setRole(OpenViduRole newRole) { public void setRole(OpenViduRole newRole) {
this.updateConnectionOptions(connectionOptions.getType(), connectionOptions.getData(), this.updateConnectionProperties(connectionProperties.getType(), connectionProperties.getData(),
connectionOptions.record(), newRole, connectionOptions.getKurentoOptions(), connectionProperties.record(), newRole, connectionProperties.getKurentoOptions(),
connectionOptions.getRtspUri(), connectionOptions.adaptativeBitrate(), connectionProperties.getRtspUri(), connectionProperties.adaptativeBitrate(),
connectionOptions.onlyPlayWithSubscribers(), connectionOptions.getNetworkCache()); connectionProperties.onlyPlayWithSubscribers(), connectionProperties.getNetworkCache());
} }
public KurentoOptions getKurentoOptions() { public KurentoOptions getKurentoOptions() {
return this.connectionOptions.getKurentoOptions(); return this.connectionProperties.getKurentoOptions();
} }
public String getRtspUri() { public String getRtspUri() {
return this.connectionOptions.getRtspUri(); return this.connectionProperties.getRtspUri();
} }
public Boolean adaptativeBitrate() { public Boolean adaptativeBitrate() {
return this.connectionOptions.adaptativeBitrate(); return this.connectionProperties.adaptativeBitrate();
} }
public Boolean onlyPlayWithSubscribers() { public Boolean onlyPlayWithSubscribers() {
return this.connectionOptions.onlyPlayWithSubscribers(); return this.connectionProperties.onlyPlayWithSubscribers();
} }
public Integer getNetworkCache() { public Integer getNetworkCache() {
return this.connectionOptions.getNetworkCache(); return this.connectionProperties.getNetworkCache();
} }
public TurnCredentials getTurnCredentials() { public TurnCredentials getTurnCredentials() {
@ -141,9 +141,9 @@ public class Token {
json.addProperty("sessionId", this.sessionId); json.addProperty("sessionId", this.sessionId);
json.addProperty("createdAt", this.createdAt); json.addProperty("createdAt", this.createdAt);
// Add all ConnectionOptions // Add all ConnectionProperties
JsonObject connectionOptionsJson = this.getConnectionOptionsWithFinalJsonFormat(); JsonObject connectionPropertiesJson = this.getConnectionPropertiesWithFinalJsonFormat();
connectionOptionsJson.entrySet().forEach(entry -> { connectionPropertiesJson.entrySet().forEach(entry -> {
json.add(entry.getKey(), entry.getValue()); json.add(entry.getKey(), entry.getValue());
}); });
@ -157,18 +157,18 @@ public class Token {
return json; return json;
} }
protected JsonObject getConnectionOptionsWithFinalJsonFormat() { protected JsonObject getConnectionPropertiesWithFinalJsonFormat() {
JsonObject json = this.connectionOptions.toJson(this.sessionId); JsonObject json = this.connectionProperties.toJson(this.sessionId);
json.remove("session"); json.remove("session");
json.addProperty("serverData", json.get("data").getAsString()); json.addProperty("serverData", json.get("data").getAsString());
json.remove("data"); json.remove("data");
return json; return json;
} }
private void updateConnectionOptions(ConnectionType type, String data, Boolean record, OpenViduRole role, private void updateConnectionProperties(ConnectionType type, String data, Boolean record, OpenViduRole role,
KurentoOptions kurentoOptions, String rtspUri, Boolean adaptativeBitrate, Boolean onlyPlayWithSubscribers, KurentoOptions kurentoOptions, String rtspUri, Boolean adaptativeBitrate, Boolean onlyPlayWithSubscribers,
Integer networkCache) { Integer networkCache) {
ConnectionOptions.Builder builder = new ConnectionOptions.Builder(); ConnectionProperties.Builder builder = new ConnectionProperties.Builder();
if (type != null) { if (type != null) {
builder.type(type); builder.type(type);
} }
@ -196,13 +196,13 @@ public class Token {
if (networkCache != null) { if (networkCache != null) {
builder.networkCache(networkCache); builder.networkCache(networkCache);
} }
this.connectionOptions = builder.build(); this.connectionProperties = builder.build();
} }
@Override @Override
public String toString() { public String toString() {
if (this.connectionOptions.getRole() != null) if (this.connectionProperties.getRole() != null)
return this.connectionOptions.getRole().name(); return this.connectionProperties.getRole().name();
else else
return this.token; return this.token;
} }

View File

@ -20,7 +20,7 @@ package io.openvidu.server.core;
import org.apache.commons.lang3.RandomStringUtils; import org.apache.commons.lang3.RandomStringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import io.openvidu.java.client.ConnectionOptions; import io.openvidu.java.client.ConnectionProperties;
import io.openvidu.java.client.ConnectionType; import io.openvidu.java.client.ConnectionType;
import io.openvidu.java.client.KurentoOptions; import io.openvidu.java.client.KurentoOptions;
import io.openvidu.java.client.OpenViduRole; import io.openvidu.java.client.OpenViduRole;
@ -58,8 +58,8 @@ public class TokenGenerator {
token += "&turnCredential=" + turnCredentials.getCredential(); token += "&turnCredential=" + turnCredentials.getCredential();
} }
} }
ConnectionOptions connectionOptions = new ConnectionOptions.Builder().type(ConnectionType.WEBRTC) ConnectionProperties connectionProperties = new ConnectionProperties.Builder().type(ConnectionType.WEBRTC)
.data(serverMetadata).record(record).role(role).kurentoOptions(kurentoOptions).build(); .data(serverMetadata).record(record).role(role).kurentoOptions(kurentoOptions).build();
return new Token(token, sessionId, connectionOptions, turnCredentials); return new Token(token, sessionId, connectionProperties, turnCredentials);
} }
} }

View File

@ -48,7 +48,7 @@ import com.google.gson.JsonObject;
import io.openvidu.client.OpenViduException; import io.openvidu.client.OpenViduException;
import io.openvidu.client.OpenViduException.Code; import io.openvidu.client.OpenViduException.Code;
import io.openvidu.client.internal.ProtocolElements; import io.openvidu.client.internal.ProtocolElements;
import io.openvidu.java.client.ConnectionOptions; import io.openvidu.java.client.ConnectionProperties;
import io.openvidu.java.client.KurentoOptions; import io.openvidu.java.client.KurentoOptions;
import io.openvidu.java.client.MediaMode; import io.openvidu.java.client.MediaMode;
import io.openvidu.java.client.Recording; import io.openvidu.java.client.Recording;
@ -992,7 +992,7 @@ public class KurentoSessionManager extends SessionManager {
@Override @Override
/* Protected by Session.closingLock.readLock */ /* Protected by Session.closingLock.readLock */
public Participant publishIpcam(Session session, MediaOptions mediaOptions, ConnectionOptions connectionOptions) public Participant publishIpcam(Session session, MediaOptions mediaOptions, ConnectionProperties connectionProperties)
throws Exception { throws Exception {
final String sessionId = session.getSessionId(); final String sessionId = session.getSessionId();
final KurentoMediaOptions kMediaOptions = (KurentoMediaOptions) mediaOptions; final KurentoMediaOptions kMediaOptions = (KurentoMediaOptions) mediaOptions;
@ -1035,7 +1035,7 @@ public class KurentoSessionManager extends SessionManager {
String token = IdentifierPrefixes.TOKEN_ID + RandomStringUtils.randomAlphabetic(1).toUpperCase() String token = IdentifierPrefixes.TOKEN_ID + RandomStringUtils.randomAlphabetic(1).toUpperCase()
+ RandomStringUtils.randomAlphanumeric(15); + RandomStringUtils.randomAlphanumeric(15);
this.newTokenForInsecureUser(session, token, connectionOptions); this.newTokenForInsecureUser(session, token, connectionProperties);
final Token tokenObj = session.consumeToken(token); final Token tokenObj = session.consumeToken(token);
Participant ipcamParticipant = this.newIpcamParticipant(sessionId, rtspConnectionId, tokenObj, location, Participant ipcamParticipant = this.newIpcamParticipant(sessionId, rtspConnectionId, tokenObj, location,

View File

@ -50,7 +50,7 @@ import com.google.gson.JsonParser;
import io.openvidu.client.OpenViduException; import io.openvidu.client.OpenViduException;
import io.openvidu.client.internal.ProtocolElements; import io.openvidu.client.internal.ProtocolElements;
import io.openvidu.java.client.ConnectionOptions; import io.openvidu.java.client.ConnectionProperties;
import io.openvidu.java.client.ConnectionType; import io.openvidu.java.client.ConnectionType;
import io.openvidu.java.client.KurentoOptions; import io.openvidu.java.client.KurentoOptions;
import io.openvidu.java.client.MediaMode; import io.openvidu.java.client.MediaMode;
@ -282,18 +282,18 @@ public class SessionRestController {
return new ResponseEntity<>(HttpStatus.NOT_FOUND); return new ResponseEntity<>(HttpStatus.NOT_FOUND);
} }
ConnectionOptions connectionOptions; ConnectionProperties connectionProperties;
try { try {
connectionOptions = getConnectionOptionsFromParams(params); connectionProperties = getConnectionPropertiesFromParams(params);
} catch (Exception e) { } catch (Exception e) {
return this.generateErrorResponse(e.getMessage(), "/sessions/" + sessionId + "/connection", return this.generateErrorResponse(e.getMessage(), "/sessions/" + sessionId + "/connection",
HttpStatus.BAD_REQUEST); HttpStatus.BAD_REQUEST);
} }
switch (connectionOptions.getType()) { switch (connectionProperties.getType()) {
case WEBRTC: case WEBRTC:
return this.newWebrtcConnection(session, connectionOptions); return this.newWebrtcConnection(session, connectionProperties);
case IPCAM: case IPCAM:
return this.newIpcamConnection(session, connectionOptions); return this.newIpcamConnection(session, connectionProperties);
default: default:
return this.generateErrorResponse("Wrong type parameter", "/sessions/" + sessionId + "/connection", return this.generateErrorResponse("Wrong type parameter", "/sessions/" + sessionId + "/connection",
HttpStatus.BAD_REQUEST); HttpStatus.BAD_REQUEST);
@ -657,14 +657,15 @@ public class SessionRestController {
return this.generateErrorResponse("Session " + sessionId + " not found", "/tokens", HttpStatus.NOT_FOUND); return this.generateErrorResponse("Session " + sessionId + " not found", "/tokens", HttpStatus.NOT_FOUND);
} }
ConnectionOptions connectionOptions; ConnectionProperties connectionProperties;
params.remove("record");
try { try {
connectionOptions = getConnectionOptionsFromParams(params); connectionProperties = getConnectionPropertiesFromParams(params);
} catch (Exception e) { } catch (Exception e) {
return this.generateErrorResponse(e.getMessage(), "/sessions/" + sessionId + "/connection", return this.generateErrorResponse(e.getMessage(), "/sessions/" + sessionId + "/connection",
HttpStatus.BAD_REQUEST); HttpStatus.BAD_REQUEST);
} }
ResponseEntity<?> entity = this.newWebrtcConnection(session, connectionOptions); ResponseEntity<?> entity = this.newWebrtcConnection(session, connectionProperties);
JsonObject jsonResponse = JsonParser.parseString(entity.getBody().toString()).getAsJsonObject(); JsonObject jsonResponse = JsonParser.parseString(entity.getBody().toString()).getAsJsonObject();
if (jsonResponse.has("error")) { if (jsonResponse.has("error")) {
@ -779,15 +780,15 @@ public class SessionRestController {
return new ResponseEntity<>(HttpStatus.OK); return new ResponseEntity<>(HttpStatus.OK);
} }
protected ResponseEntity<?> newWebrtcConnection(Session session, ConnectionOptions connectionOptions) { protected ResponseEntity<?> newWebrtcConnection(Session session, ConnectionProperties connectionProperties) {
final String REQUEST_PATH = "/sessions/" + session.getSessionId() + "/connection"; final String REQUEST_PATH = "/sessions/" + session.getSessionId() + "/connection";
// While closing a session tokens can't be generated // While closing a session tokens can't be generated
if (session.closingLock.readLock().tryLock()) { if (session.closingLock.readLock().tryLock()) {
try { try {
Token token = sessionManager.newToken(session, connectionOptions.getRole(), connectionOptions.getData(), Token token = sessionManager.newToken(session, connectionProperties.getRole(), connectionProperties.getData(),
connectionOptions.record(), connectionOptions.getKurentoOptions()); connectionProperties.record(), connectionProperties.getKurentoOptions());
return new ResponseEntity<>(token.toJsonAsParticipant().toString(), RestUtils.getResponseHeaders(), return new ResponseEntity<>(token.toJsonAsParticipant().toString(), RestUtils.getResponseHeaders(),
HttpStatus.OK); HttpStatus.OK);
} catch (Exception e) { } catch (Exception e) {
@ -805,7 +806,7 @@ public class SessionRestController {
} }
} }
protected ResponseEntity<?> newIpcamConnection(Session session, ConnectionOptions connectionOptions) { protected ResponseEntity<?> newIpcamConnection(Session session, ConnectionProperties connectionProperties) {
final String REQUEST_PATH = "/sessions/" + session.getSessionId() + "/connection"; final String REQUEST_PATH = "/sessions/" + session.getSessionId() + "/connection";
@ -817,9 +818,9 @@ public class SessionRestController {
Integer frameRate = null; Integer frameRate = null;
String videoDimensions = null; String videoDimensions = null;
KurentoMediaOptions mediaOptions = new KurentoMediaOptions(true, null, hasAudio, hasVideo, audioActive, KurentoMediaOptions mediaOptions = new KurentoMediaOptions(true, null, hasAudio, hasVideo, audioActive,
videoActive, typeOfVideo, frameRate, videoDimensions, null, false, connectionOptions.getRtspUri(), videoActive, typeOfVideo, frameRate, videoDimensions, null, false, connectionProperties.getRtspUri(),
connectionOptions.adaptativeBitrate(), connectionOptions.onlyPlayWithSubscribers(), connectionProperties.adaptativeBitrate(), connectionProperties.onlyPlayWithSubscribers(),
connectionOptions.getNetworkCache()); connectionProperties.getNetworkCache());
// While closing a session IP cameras can't be published // While closing a session IP cameras can't be published
if (session.closingLock.readLock().tryLock()) { if (session.closingLock.readLock().tryLock()) {
@ -828,7 +829,7 @@ public class SessionRestController {
return new ResponseEntity<>(HttpStatus.NOT_FOUND); return new ResponseEntity<>(HttpStatus.NOT_FOUND);
} }
Participant ipcamParticipant = this.sessionManager.publishIpcam(session, mediaOptions, Participant ipcamParticipant = this.sessionManager.publishIpcam(session, mediaOptions,
connectionOptions); connectionProperties);
return new ResponseEntity<>(ipcamParticipant.toJson().toString(), RestUtils.getResponseHeaders(), return new ResponseEntity<>(ipcamParticipant.toJson().toString(), RestUtils.getResponseHeaders(),
HttpStatus.OK); HttpStatus.OK);
} catch (MalformedURLException e) { } catch (MalformedURLException e) {
@ -857,9 +858,9 @@ public class SessionRestController {
return token; return token;
} }
protected ConnectionOptions getConnectionOptionsFromParams(Map<?, ?> params) throws Exception { protected ConnectionProperties getConnectionPropertiesFromParams(Map<?, ?> params) throws Exception {
ConnectionOptions.Builder builder = new ConnectionOptions.Builder(); ConnectionProperties.Builder builder = new ConnectionProperties.Builder();
String typeString; String typeString;
String data; String data;

View File

@ -45,7 +45,7 @@ import com.google.gson.JsonSyntaxException;
import io.openvidu.client.OpenViduException; import io.openvidu.client.OpenViduException;
import io.openvidu.client.OpenViduException.Code; import io.openvidu.client.OpenViduException.Code;
import io.openvidu.client.internal.ProtocolElements; import io.openvidu.client.internal.ProtocolElements;
import io.openvidu.java.client.ConnectionOptions; import io.openvidu.java.client.ConnectionProperties;
import io.openvidu.server.config.OpenviduConfig; import io.openvidu.server.config.OpenviduConfig;
import io.openvidu.server.core.EndReason; import io.openvidu.server.core.EndReason;
import io.openvidu.server.core.IdentifierPrefixes; import io.openvidu.server.core.IdentifierPrefixes;
@ -249,7 +249,7 @@ public class RpcHandler extends DefaultJsonRpcHandler<JsonObject> {
token = IdentifierPrefixes.TOKEN_ID + RandomStringUtils.randomAlphabetic(1).toUpperCase() token = IdentifierPrefixes.TOKEN_ID + RandomStringUtils.randomAlphabetic(1).toUpperCase()
+ RandomStringUtils.randomAlphanumeric(15); + RandomStringUtils.randomAlphanumeric(15);
try { try {
sessionManager.newTokenForInsecureUser(session, token, new ConnectionOptions.Builder().build()); sessionManager.newTokenForInsecureUser(session, token, new ConnectionProperties.Builder().build());
} catch (Exception e) { } catch (Exception e) {
throw new OpenViduException(Code.TOKEN_CANNOT_BE_CREATED_ERROR_CODE, throw new OpenViduException(Code.TOKEN_CANNOT_BE_CREATED_ERROR_CODE,
"Unable to create token for session " + sessionId + ": " + e.getMessage()); "Unable to create token for session " + sessionId + ": " + e.getMessage());

View File

@ -36,7 +36,7 @@ import org.springframework.test.context.web.WebAppConfiguration;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import io.openvidu.java.client.ConnectionOptions; import io.openvidu.java.client.ConnectionProperties;
import io.openvidu.server.core.Participant; import io.openvidu.server.core.Participant;
import io.openvidu.server.core.SessionManager; import io.openvidu.server.core.SessionManager;
import io.openvidu.server.core.Token; import io.openvidu.server.core.Token;
@ -115,8 +115,8 @@ public class SessionGarbageCollectorIntegrationTest {
} }
private void joinParticipant(String sessionId, String token) { private void joinParticipant(String sessionId, String token) {
ConnectionOptions connectionOptions = new ConnectionOptions.Builder().data("SERVER_METADATA").build(); ConnectionProperties connectionProperties = new ConnectionProperties.Builder().data("SERVER_METADATA").build();
Token t = new Token(token, sessionId, connectionOptions, null); Token t = new Token(token, sessionId, connectionProperties, null);
String uuid = UUID.randomUUID().toString(); String uuid = UUID.randomUUID().toString();
String participantPrivateId = "PARTICIPANT_PRIVATE_ID_" + uuid; String participantPrivateId = "PARTICIPANT_PRIVATE_ID_" + uuid;
String finalUserId = "FINAL_USER_ID_" + uuid; String finalUserId = "FINAL_USER_ID_" + uuid;

View File

@ -25,7 +25,7 @@ import com.google.gson.stream.JsonReader;
import com.mashape.unirest.http.HttpMethod; import com.mashape.unirest.http.HttpMethod;
import io.openvidu.java.client.Connection; import io.openvidu.java.client.Connection;
import io.openvidu.java.client.ConnectionOptions; import io.openvidu.java.client.ConnectionProperties;
import io.openvidu.java.client.OpenVidu; import io.openvidu.java.client.OpenVidu;
import io.openvidu.java.client.OpenViduHttpException; import io.openvidu.java.client.OpenViduHttpException;
import io.openvidu.java.client.OpenViduRole; import io.openvidu.java.client.OpenViduRole;
@ -230,14 +230,14 @@ public class OpenViduProTestAppE2eTest extends AbstractOpenViduTestAppE2eTest {
Assert.assertTrue("OpenVidu object should have changed", OV.fetch()); Assert.assertTrue("OpenVidu object should have changed", OV.fetch());
Session session = OV.getActiveSessions().get(0); Session session = OV.getActiveSessions().get(0);
try { try {
session.updateConnection("WRONG_CONNECTION_ID", new ConnectionOptions.Builder().build()); session.updateConnection("WRONG_CONNECTION_ID", new ConnectionProperties.Builder().build());
Assert.fail("Expected OpenViduHttpException exception"); Assert.fail("Expected OpenViduHttpException exception");
} catch (OpenViduHttpException exception) { } catch (OpenViduHttpException exception) {
Assert.assertEquals("Wrong HTTP status", HttpStatus.SC_NOT_FOUND, exception.getStatus()); Assert.assertEquals("Wrong HTTP status", HttpStatus.SC_NOT_FOUND, exception.getStatus());
} }
Assert.assertFalse("Session object should not have changed", session.fetch()); Assert.assertFalse("Session object should not have changed", session.fetch());
Connection connection = session.updateConnection(tokenConnectionId, Connection connection = session.updateConnection(tokenConnectionId,
new ConnectionOptions.Builder().role(OpenViduRole.SUBSCRIBER).record(false).build()); new ConnectionProperties.Builder().role(OpenViduRole.SUBSCRIBER).record(false).build());
Assert.assertEquals("Wrong role Connection property", OpenViduRole.SUBSCRIBER, connection.getRole()); Assert.assertEquals("Wrong role Connection property", OpenViduRole.SUBSCRIBER, connection.getRole());
Assert.assertFalse("Wrong record Connection property", connection.record()); Assert.assertFalse("Wrong record Connection property", connection.record());
@ -339,25 +339,25 @@ public class OpenViduProTestAppE2eTest extends AbstractOpenViduTestAppE2eTest {
// Test with openvidu-java-client // Test with openvidu-java-client
Assert.assertFalse("Session object should not have changed", session.fetch()); Assert.assertFalse("Session object should not have changed", session.fetch());
try { try {
session.updateConnection("WRONG_CONNECTION_ID", new ConnectionOptions.Builder().build()); session.updateConnection("WRONG_CONNECTION_ID", new ConnectionProperties.Builder().build());
Assert.fail("Expected OpenViduHttpException exception"); Assert.fail("Expected OpenViduHttpException exception");
} catch (OpenViduHttpException exception) { } catch (OpenViduHttpException exception) {
Assert.assertEquals("Wrong HTTP status", HttpStatus.SC_NOT_FOUND, exception.getStatus()); Assert.assertEquals("Wrong HTTP status", HttpStatus.SC_NOT_FOUND, exception.getStatus());
} }
Assert.assertFalse("Session object should not have changed", session.fetch()); Assert.assertFalse("Session object should not have changed", session.fetch());
connection = session.updateConnection(tokenConnectionId, connection = session.updateConnection(tokenConnectionId,
new ConnectionOptions.Builder().role(OpenViduRole.PUBLISHER).build()); new ConnectionProperties.Builder().role(OpenViduRole.PUBLISHER).build());
Assert.assertFalse("Session object should not have changed", session.fetch()); Assert.assertFalse("Session object should not have changed", session.fetch());
Assert.assertEquals("Wrong connectionId in Connection object", tokenConnectionId, connection.getConnectionId()); Assert.assertEquals("Wrong connectionId in Connection object", tokenConnectionId, connection.getConnectionId());
Assert.assertEquals("Wrong role in Connection object", OpenViduRole.PUBLISHER, connection.getRole()); Assert.assertEquals("Wrong role in Connection object", OpenViduRole.PUBLISHER, connection.getRole());
Assert.assertFalse("Wrong record in Connection object", connection.record()); Assert.assertFalse("Wrong record in Connection object", connection.record());
Assert.assertEquals("Wrong status in Connection object", "active", connection.getStatus()); Assert.assertEquals("Wrong status in Connection object", "active", connection.getStatus());
connection = session.updateConnection(tokenConnectionId, connection = session.updateConnection(tokenConnectionId,
new ConnectionOptions.Builder().role(OpenViduRole.SUBSCRIBER).build()); new ConnectionProperties.Builder().role(OpenViduRole.SUBSCRIBER).build());
Assert.assertEquals("Wrong role in Connection object", OpenViduRole.SUBSCRIBER, connection.getRole()); Assert.assertEquals("Wrong role in Connection object", OpenViduRole.SUBSCRIBER, connection.getRole());
Assert.assertFalse("Session object should not have changed", session.fetch()); Assert.assertFalse("Session object should not have changed", session.fetch());
connection = session.updateConnection(tokenConnectionId, connection = session.updateConnection(tokenConnectionId,
new ConnectionOptions.Builder().role(OpenViduRole.MODERATOR).record(false).data("NO CHANGE").build()); new ConnectionProperties.Builder().role(OpenViduRole.MODERATOR).record(false).data("NO CHANGE").build());
Assert.assertFalse("Session object should not have changed", session.fetch()); Assert.assertFalse("Session object should not have changed", session.fetch());
Assert.assertEquals("Wrong role in Connection object", OpenViduRole.MODERATOR, connection.getRole()); Assert.assertEquals("Wrong role in Connection object", OpenViduRole.MODERATOR, connection.getRole());
Assert.assertFalse("Wrong record in Connection object", connection.record()); Assert.assertFalse("Wrong record in Connection object", connection.record());
@ -411,7 +411,7 @@ public class OpenViduProTestAppE2eTest extends AbstractOpenViduTestAppE2eTest {
Assert.assertEquals("Wrong role property", OpenViduRole.PUBLISHER, connection.getRole()); Assert.assertEquals("Wrong role property", OpenViduRole.PUBLISHER, connection.getRole());
Assert.assertTrue("Wrong record property", connection.record()); Assert.assertTrue("Wrong record property", connection.record());
session.updateConnection(connection.getConnectionId(), session.updateConnection(connection.getConnectionId(),
new ConnectionOptions.Builder().role(OpenViduRole.SUBSCRIBER).record(false).build()); new ConnectionProperties.Builder().role(OpenViduRole.SUBSCRIBER).record(false).build());
Assert.assertEquals("Wrong role property", OpenViduRole.SUBSCRIBER, connection.getRole()); Assert.assertEquals("Wrong role property", OpenViduRole.SUBSCRIBER, connection.getRole());
Assert.assertFalse("Wrong record property", connection.record()); Assert.assertFalse("Wrong record property", connection.record());
Assert.assertFalse(session.fetch()); Assert.assertFalse(session.fetch());

View File

@ -54,7 +54,7 @@ import com.google.gson.JsonParser;
import com.mashape.unirest.http.HttpMethod; import com.mashape.unirest.http.HttpMethod;
import io.openvidu.java.client.Connection; import io.openvidu.java.client.Connection;
import io.openvidu.java.client.ConnectionOptions; import io.openvidu.java.client.ConnectionProperties;
import io.openvidu.java.client.ConnectionType; import io.openvidu.java.client.ConnectionType;
import io.openvidu.java.client.KurentoOptions; import io.openvidu.java.client.KurentoOptions;
import io.openvidu.java.client.MediaMode; import io.openvidu.java.client.MediaMode;
@ -2138,13 +2138,13 @@ public class OpenViduTestAppE2eTest extends AbstractOpenViduTestAppE2eTest {
KurentoOptions kurentoOptions = new KurentoOptions.Builder().videoMaxRecvBandwidth(250) KurentoOptions kurentoOptions = new KurentoOptions.Builder().videoMaxRecvBandwidth(250)
.allowedFilters(new String[] { "GStreamerFilter" }).build(); .allowedFilters(new String[] { "GStreamerFilter" }).build();
ConnectionOptions moderatorConnectionOptions = new ConnectionOptions.Builder().role(OpenViduRole.MODERATOR) ConnectionProperties moderatorConnectionProperties = new ConnectionProperties.Builder().role(OpenViduRole.MODERATOR)
.data(serverDataModerator).kurentoOptions(kurentoOptions).build(); .data(serverDataModerator).kurentoOptions(kurentoOptions).build();
Connection connectionModerator = session.createConnection(moderatorConnectionOptions); Connection connectionModerator = session.createConnection(moderatorConnectionProperties);
ConnectionOptions subscriberConnectionOptions = new ConnectionOptions.Builder().type(ConnectionType.WEBRTC) ConnectionProperties subscriberConnectionProperties = new ConnectionProperties.Builder().type(ConnectionType.WEBRTC)
.role(OpenViduRole.SUBSCRIBER).data(serverDataSubscriber).build(); .role(OpenViduRole.SUBSCRIBER).data(serverDataSubscriber).build();
Connection connectionSubscriber = session.createConnection(subscriberConnectionOptions); Connection connectionSubscriber = session.createConnection(subscriberConnectionProperties);
Assert.assertFalse("Session.fetch() should return false after Session.createConnection", session.fetch()); Assert.assertFalse("Session.fetch() should return false after Session.createConnection", session.fetch());
Assert.assertFalse("OpenVidu.fetch() should return false after Session.fetch()", OV.fetch()); Assert.assertFalse("OpenVidu.fetch() should return false after Session.fetch()", OV.fetch());
@ -2543,7 +2543,7 @@ public class OpenViduTestAppE2eTest extends AbstractOpenViduTestAppE2eTest {
// Test IPCAM // Test IPCAM
final String rtsp = "rtsp://dummyurl.com"; final String rtsp = "rtsp://dummyurl.com";
Connection ipcamera = session.createConnection(new ConnectionOptions.Builder().type(ConnectionType.IPCAM) Connection ipcamera = session.createConnection(new ConnectionProperties.Builder().type(ConnectionType.IPCAM)
.rtspUri(rtsp).adaptativeBitrate(false).onlyPlayWithSubscribers(false).networkCache(50).build()); .rtspUri(rtsp).adaptativeBitrate(false).onlyPlayWithSubscribers(false).networkCache(50).build());
Assert.assertFalse("OpenVidu.fetch() should return false", OV.fetch()); Assert.assertFalse("OpenVidu.fetch() should return false", OV.fetch());
Assert.assertFalse("Session.fetch() should return false", session.fetch()); Assert.assertFalse("Session.fetch() should return false", session.fetch());

View File

@ -17,10 +17,10 @@
<input matInput id="stream-id-field" placeholder="streamId" [(ngModel)]="streamId"> <input matInput id="stream-id-field" placeholder="streamId" [(ngModel)]="streamId">
</mat-form-field> </mat-form-field>
<div style="margin-left:9px"> <div style="margin-left:9px">
<mat-checkbox class="checkbox-form" [(ngModel)]="connectionOptions.record" id="record-checkbox">Record <mat-checkbox class="checkbox-form" [(ngModel)]="connectionProperties.record" id="record-checkbox">Record
</mat-checkbox> </mat-checkbox>
<mat-form-field class="inner-text-input" [style.fontSize.px]=14> <mat-form-field class="inner-text-input" [style.fontSize.px]=14>
<mat-select [(ngModel)]="connectionOptions.role" id="token-role-select"> <mat-select [(ngModel)]="connectionProperties.role" id="token-role-select">
<mat-option *ngFor="let enumerator of enumToArray(openviduRoles)" [value]="enumerator"> <mat-option *ngFor="let enumerator of enumToArray(openviduRoles)" [value]="enumerator">
<span [attr.id]="'option-' + enumerator">{{ enumerator }}</span> <span [attr.id]="'option-' + enumerator">{{ enumerator }}</span>
</mat-option> </mat-option>

View File

@ -1,7 +1,7 @@
import { Component, Inject } from '@angular/core'; import { Component, Inject } from '@angular/core';
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material'; import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material';
import { OpenVidu as OpenViduAPI, Session as SessionAPI, Recording, RecordingProperties, RecordingLayout, ConnectionOptions, OpenViduRole } from 'openvidu-node-client'; import { OpenVidu as OpenViduAPI, Session as SessionAPI, Recording, RecordingProperties, RecordingLayout, ConnectionProperties, OpenViduRole } from 'openvidu-node-client';
@Component({ @Component({
selector: 'app-session-api-dialog', selector: 'app-session-api-dialog',
@ -26,7 +26,7 @@ export class SessionApiDialogComponent {
recPropertiesIcon = 'add_circle'; recPropertiesIcon = 'add_circle';
showRecProperties = false; showRecProperties = false;
connectionOptions: ConnectionOptions = { connectionProperties: ConnectionProperties = {
record: true, record: true,
role: OpenViduRole.PUBLISHER role: OpenViduRole.PUBLISHER
}; };
@ -174,7 +174,7 @@ export class SessionApiDialogComponent {
createConnection() { createConnection() {
console.log('Creating connection'); console.log('Creating connection');
this.session.createConnection(this.connectionOptions) this.session.createConnection(this.connectionProperties)
.then(connection => { .then(connection => {
this.response = 'Connection created: ' + connection.connectionId; this.response = 'Connection created: ' + connection.connectionId;
}) })
@ -185,9 +185,9 @@ export class SessionApiDialogComponent {
updateConnection() { updateConnection() {
console.log('Updating connection'); console.log('Updating connection');
this.session.updateConnection(this.connectionId, this.connectionOptions) this.session.updateConnection(this.connectionId, this.connectionProperties)
.then(modifiedConnection => { .then(modifiedConnection => {
this.response = 'Connection updated: ' + JSON.stringify({ role: modifiedConnection.connectionOptions.role, record: modifiedConnection.connectionOptions.record }); this.response = 'Connection updated: ' + JSON.stringify({ role: modifiedConnection.connectionProperties.role, record: modifiedConnection.connectionProperties.record });
}) })
.catch(error => { .catch(error => {
this.response = 'Error [' + error.message + ']'; this.response = 'Error [' + error.message + ']';

View File

@ -68,7 +68,7 @@
<mat-dialog-content> <mat-dialog-content>
<label class="label">Role</label> <label class="label">Role</label>
<div id="role-div"> <div id="role-div">
<mat-radio-group name="Role" [(ngModel)]="connectionOptions.role"> <mat-radio-group name="Role" [(ngModel)]="connectionProperties.role">
<mat-radio-button id="radio-btn-sub" value="SUBSCRIBER">SUB</mat-radio-button> <mat-radio-button id="radio-btn-sub" value="SUBSCRIBER">SUB</mat-radio-button>
<mat-radio-button id="radio-btn-pub" value="PUBLISHER">PUB</mat-radio-button> <mat-radio-button id="radio-btn-pub" value="PUBLISHER">PUB</mat-radio-button>
<mat-radio-button id="radio-btn-mod" value="MODERATOR">MOD</mat-radio-button> <mat-radio-button id="radio-btn-mod" value="MODERATOR">MOD</mat-radio-button>
@ -79,19 +79,19 @@
<div id="kurento-config-div"> <div id="kurento-config-div">
<mat-form-field style="width: 39%; margin-right: 5px"> <mat-form-field style="width: 39%; margin-right: 5px">
<input matInput placeholder="Max recv" type="number" <input matInput placeholder="Max recv" type="number"
[(ngModel)]="connectionOptions.kurentoOptions.videoMaxRecvBandwidth"> [(ngModel)]="connectionProperties.kurentoOptions.videoMaxRecvBandwidth">
</mat-form-field> </mat-form-field>
<mat-form-field style="width: 39%"> <mat-form-field style="width: 39%">
<input matInput placeholder="Min recv" type="number" <input matInput placeholder="Min recv" type="number"
[(ngModel)]="connectionOptions.kurentoOptions.videoMinRecvBandwidth"> [(ngModel)]="connectionProperties.kurentoOptions.videoMinRecvBandwidth">
</mat-form-field> </mat-form-field>
<mat-form-field style="width: 39%; margin-right: 5px"> <mat-form-field style="width: 39%; margin-right: 5px">
<input matInput placeholder="Max send" type="number" <input matInput placeholder="Max send" type="number"
[(ngModel)]="connectionOptions.kurentoOptions.videoMaxSendBandwidth"> [(ngModel)]="connectionProperties.kurentoOptions.videoMaxSendBandwidth">
</mat-form-field> </mat-form-field>
<mat-form-field style="width: 39%"> <mat-form-field style="width: 39%">
<input matInput placeholder="Min send" type="number" <input matInput placeholder="Min send" type="number"
[(ngModel)]="connectionOptions.kurentoOptions.videoMinSendBandwidth"> [(ngModel)]="connectionProperties.kurentoOptions.videoMinSendBandwidth">
</mat-form-field> </mat-form-field>
<mat-chip-list *ngIf="filters.length > 0"> <mat-chip-list *ngIf="filters.length > 0">
<mat-chip style="height: 20px" *ngFor="let filterName of filters" <mat-chip style="height: 20px" *ngFor="let filterName of filters"
@ -108,7 +108,7 @@
</div> </div>
<div id="record-div"> <div id="record-div">
<mat-checkbox class="checkbox-form" [(ngModel)]="connectionOptions.record" id="record-checkbox">Record <mat-checkbox class="checkbox-form" [(ngModel)]="connectionProperties.record" id="record-checkbox">Record
</mat-checkbox> </mat-checkbox>
</div> </div>
@ -132,6 +132,6 @@
<mat-dialog-actions> <mat-dialog-actions>
<button id="cancel-btn" mat-button [mat-dialog-close]="undefined">CANCEL</button> <button id="cancel-btn" mat-button [mat-dialog-close]="undefined">CANCEL</button>
<button id="save-btn" mat-button <button id="save-btn" mat-button
[mat-dialog-close]="{sessionProperties: sessionProperties, turnConf: turnConf, manualTurnConf: manualTurnConf, customToken: customToken, forcePublishing: forcePublishing, connectionOptions: generateConnectionOptions()}">SAVE</button> [mat-dialog-close]="{sessionProperties: sessionProperties, turnConf: turnConf, manualTurnConf: manualTurnConf, customToken: customToken, forcePublishing: forcePublishing, connectionProperties: generateConnectionProperties()}">SAVE</button>
</mat-dialog-actions> </mat-dialog-actions>
</div> </div>

View File

@ -1,7 +1,7 @@
import { Component, Inject } from '@angular/core'; import { Component, Inject } from '@angular/core';
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material'; import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material';
import { SessionProperties, MediaMode, Recording, RecordingMode, RecordingLayout, ConnectionOptions } from 'openvidu-node-client'; import { SessionProperties, MediaMode, Recording, RecordingMode, RecordingLayout, ConnectionProperties } from 'openvidu-node-client';
@Component({ @Component({
selector: 'app-session-properties-dialog', selector: 'app-session-properties-dialog',
@ -15,7 +15,7 @@ export class SessionPropertiesDialogComponent {
manualTurnConf: RTCIceServer = { urls: [] }; manualTurnConf: RTCIceServer = { urls: [] };
customToken: string; customToken: string;
forcePublishing: boolean = false; forcePublishing: boolean = false;
connectionOptions: ConnectionOptions; connectionProperties: ConnectionProperties;
filterName = 'GStreamerFilter'; filterName = 'GStreamerFilter';
filters: string[] = []; filters: string[] = [];
@ -32,16 +32,16 @@ export class SessionPropertiesDialogComponent {
this.manualTurnConf = data.manualTurnConf; this.manualTurnConf = data.manualTurnConf;
this.customToken = data.customToken; this.customToken = data.customToken;
this.forcePublishing = data.forcePublishing; this.forcePublishing = data.forcePublishing;
this.connectionOptions = data.connectionOptions; this.connectionProperties = data.connectionProperties;
} }
enumToArray(enumerator: any) { enumToArray(enumerator: any) {
return Object.keys(enumerator); return Object.keys(enumerator);
} }
generateConnectionOptions(): ConnectionOptions { generateConnectionProperties(): ConnectionProperties {
this.connectionOptions.kurentoOptions.allowedFilters = this.filters; this.connectionProperties.kurentoOptions.allowedFilters = this.filters;
return this.connectionOptions; return this.connectionProperties;
} }
} }

View File

@ -16,7 +16,7 @@ import {
RecordingMode, RecordingMode,
RecordingLayout, RecordingLayout,
Connection, Connection,
ConnectionOptions, ConnectionProperties,
OpenViduRole, OpenViduRole,
RecordingProperties, RecordingProperties,
Recording, Recording,
@ -129,7 +129,7 @@ export class OpenviduInstanceComponent implements OnInit, OnChanges, OnDestroy {
manualTurnConf: RTCIceServer = { urls: [] }; manualTurnConf: RTCIceServer = { urls: [] };
customToken: string; customToken: string;
forcePublishing: boolean; forcePublishing: boolean;
connectionOptions: ConnectionOptions = { connectionProperties: ConnectionProperties = {
role: OpenViduRole.PUBLISHER, role: OpenViduRole.PUBLISHER,
record: true, record: true,
kurentoOptions: { kurentoOptions: {
@ -566,7 +566,7 @@ export class OpenviduInstanceComponent implements OnInit, OnChanges, OnDestroy {
manualTurnConf: this.manualTurnConf, manualTurnConf: this.manualTurnConf,
customToken: this.customToken, customToken: this.customToken,
forcePublishing: this.forcePublishing, forcePublishing: this.forcePublishing,
connectionOptions: this.connectionOptions, connectionProperties: this.connectionProperties,
}, },
width: '450px' width: '450px'
}); });
@ -581,7 +581,7 @@ export class OpenviduInstanceComponent implements OnInit, OnChanges, OnDestroy {
this.manualTurnConf = result.manualTurnConf; this.manualTurnConf = result.manualTurnConf;
this.customToken = result.customToken; this.customToken = result.customToken;
this.forcePublishing = result.forcePublishing; this.forcePublishing = result.forcePublishing;
this.connectionOptions = result.connectionOptions; this.connectionProperties = result.connectionProperties;
} }
document.getElementById('session-settings-btn-' + this.index).classList.remove('cdk-program-focused'); document.getElementById('session-settings-btn-' + this.index).classList.remove('cdk-program-focused');
}); });
@ -693,7 +693,7 @@ export class OpenviduInstanceComponent implements OnInit, OnChanges, OnDestroy {
} }
async createConnection(): Promise<Connection> { async createConnection(): Promise<Connection> {
return this.sessionAPI.createConnection(this.connectionOptions); return this.sessionAPI.createConnection(this.connectionProperties);
} }
updateEventFromChild(event: OpenViduEvent) { updateEventFromChild(event: OpenViduEvent) {