mirror of https://github.com/OpenVidu/openvidu.git
openvidu-server: ParticipantRole to openvidu-java-client OpenViduRole
parent
cd347d6064
commit
77df02c8e9
|
@ -22,7 +22,7 @@ import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.boot.info.BuildProperties;
|
import org.springframework.boot.info.BuildProperties;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import io.openvidu.server.core.ParticipantRole;
|
import io.openvidu.java.client.OpenViduRole;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class OpenviduConfig {
|
public class OpenviduConfig {
|
||||||
|
@ -200,24 +200,23 @@ public class OpenviduConfig {
|
||||||
return this.openviduRecordingNotification;
|
return this.openviduRecordingNotification;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ParticipantRole[] getRolesFromRecordingNotification() {
|
public OpenViduRole[] getRolesFromRecordingNotification() {
|
||||||
ParticipantRole[] roles;
|
OpenViduRole[] roles;
|
||||||
switch (this.openviduRecordingNotification) {
|
switch (this.openviduRecordingNotification) {
|
||||||
case "none":
|
case "none":
|
||||||
roles = new ParticipantRole[0];
|
roles = new OpenViduRole[0];
|
||||||
break;
|
break;
|
||||||
case "moderator":
|
case "moderator":
|
||||||
roles = new ParticipantRole[] { ParticipantRole.MODERATOR };
|
roles = new OpenViduRole[] { OpenViduRole.MODERATOR };
|
||||||
break;
|
break;
|
||||||
case "publisher_moderator":
|
case "publisher_moderator":
|
||||||
roles = new ParticipantRole[] { ParticipantRole.PUBLISHER, ParticipantRole.MODERATOR };
|
roles = new OpenViduRole[] { OpenViduRole.PUBLISHER, OpenViduRole.MODERATOR };
|
||||||
break;
|
break;
|
||||||
case "all":
|
case "all":
|
||||||
roles = new ParticipantRole[] { ParticipantRole.SUBSCRIBER, ParticipantRole.PUBLISHER,
|
roles = new OpenViduRole[] { OpenViduRole.SUBSCRIBER, OpenViduRole.PUBLISHER, OpenViduRole.MODERATOR };
|
||||||
ParticipantRole.MODERATOR };
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
roles = new ParticipantRole[] { ParticipantRole.PUBLISHER, ParticipantRole.MODERATOR };
|
roles = new OpenViduRole[] { OpenViduRole.PUBLISHER, OpenViduRole.MODERATOR };
|
||||||
}
|
}
|
||||||
return roles;
|
return roles;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,24 +0,0 @@
|
||||||
/*
|
|
||||||
* (C) Copyright 2017-2019 OpenVidu (https://openvidu.io/)
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
package io.openvidu.server.core;
|
|
||||||
|
|
||||||
public enum ParticipantRole {
|
|
||||||
SUBSCRIBER,
|
|
||||||
PUBLISHER,
|
|
||||||
MODERATOR;
|
|
||||||
}
|
|
|
@ -36,6 +36,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.OpenViduRole;
|
||||||
import io.openvidu.server.cdr.CallDetailRecord;
|
import io.openvidu.server.cdr.CallDetailRecord;
|
||||||
import io.openvidu.server.config.InfoHandler;
|
import io.openvidu.server.config.InfoHandler;
|
||||||
import io.openvidu.server.config.OpenviduConfig;
|
import io.openvidu.server.config.OpenviduConfig;
|
||||||
|
@ -552,13 +553,13 @@ public class SessionEventsHandler {
|
||||||
return this.infoHandler;
|
return this.infoHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Set<Participant> filterParticipantsByRole(ParticipantRole[] roles, Set<Participant> participants) {
|
private Set<Participant> filterParticipantsByRole(OpenViduRole[] roles, Set<Participant> participants) {
|
||||||
return participants.stream().filter(part -> {
|
return participants.stream().filter(part -> {
|
||||||
if (ProtocolElements.RECORDER_PARTICIPANT_PUBLICID.equals(part.getParticipantPublicId())) {
|
if (ProtocolElements.RECORDER_PARTICIPANT_PUBLICID.equals(part.getParticipantPublicId())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
boolean isRole = false;
|
boolean isRole = false;
|
||||||
for (ParticipantRole role : roles) {
|
for (OpenViduRole role : roles) {
|
||||||
isRole = role.equals(part.getToken().getRole());
|
isRole = role.equals(part.getToken().getRole());
|
||||||
if (isRole)
|
if (isRole)
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -38,6 +38,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.OpenViduRole;
|
||||||
import io.openvidu.java.client.SessionProperties;
|
import io.openvidu.java.client.SessionProperties;
|
||||||
import io.openvidu.server.OpenViduServer;
|
import io.openvidu.server.OpenViduServer;
|
||||||
import io.openvidu.server.cdr.CallDetailRecord;
|
import io.openvidu.server.cdr.CallDetailRecord;
|
||||||
|
@ -225,7 +226,7 @@ public abstract class SessionManager {
|
||||||
return sessionNotActive;
|
return sessionNotActive;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String newToken(String sessionId, ParticipantRole role, String serverMetadata,
|
public String newToken(String sessionId, OpenViduRole role, String serverMetadata,
|
||||||
KurentoTokenOptions kurentoTokenOptions) throws OpenViduException {
|
KurentoTokenOptions kurentoTokenOptions) throws OpenViduException {
|
||||||
|
|
||||||
ConcurrentHashMap<String, Token> map = this.sessionidTokenTokenobj.putIfAbsent(sessionId,
|
ConcurrentHashMap<String, Token> map = this.sessionidTokenTokenobj.putIfAbsent(sessionId,
|
||||||
|
@ -273,7 +274,7 @@ public abstract class SessionManager {
|
||||||
this.sessionidParticipantpublicidParticipant.putIfAbsent(sessionId, new ConcurrentHashMap<>());
|
this.sessionidParticipantpublicidParticipant.putIfAbsent(sessionId, new ConcurrentHashMap<>());
|
||||||
this.sessionidTokenTokenobj.putIfAbsent(sessionId, new ConcurrentHashMap<>());
|
this.sessionidTokenTokenobj.putIfAbsent(sessionId, new ConcurrentHashMap<>());
|
||||||
this.sessionidTokenTokenobj.get(sessionId).putIfAbsent(token,
|
this.sessionidTokenTokenobj.get(sessionId).putIfAbsent(token,
|
||||||
new Token(token, ParticipantRole.PUBLISHER, "",
|
new Token(token, OpenViduRole.PUBLISHER, "",
|
||||||
this.coturnCredentialsService.isCoturnAvailable()
|
this.coturnCredentialsService.isCoturnAvailable()
|
||||||
? this.coturnCredentialsService.createUser()
|
? this.coturnCredentialsService.createUser()
|
||||||
: null,
|
: null,
|
||||||
|
@ -285,8 +286,8 @@ public abstract class SessionManager {
|
||||||
public boolean isPublisherInSession(String sessionId, Participant participant) {
|
public boolean isPublisherInSession(String sessionId, Participant participant) {
|
||||||
if (!this.isInsecureParticipant(participant.getParticipantPrivateId())) {
|
if (!this.isInsecureParticipant(participant.getParticipantPrivateId())) {
|
||||||
if (this.sessionidParticipantpublicidParticipant.get(sessionId) != null) {
|
if (this.sessionidParticipantpublicidParticipant.get(sessionId) != null) {
|
||||||
return (ParticipantRole.PUBLISHER.equals(participant.getToken().getRole())
|
return (OpenViduRole.PUBLISHER.equals(participant.getToken().getRole())
|
||||||
|| ParticipantRole.MODERATOR.equals(participant.getToken().getRole()));
|
|| OpenViduRole.MODERATOR.equals(participant.getToken().getRole()));
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -298,7 +299,7 @@ public abstract class SessionManager {
|
||||||
public boolean isModeratorInSession(String sessionId, Participant participant) {
|
public boolean isModeratorInSession(String sessionId, Participant participant) {
|
||||||
if (!this.isInsecureParticipant(participant.getParticipantPrivateId())) {
|
if (!this.isInsecureParticipant(participant.getParticipantPrivateId())) {
|
||||||
if (this.sessionidParticipantpublicidParticipant.get(sessionId) != null) {
|
if (this.sessionidParticipantpublicidParticipant.get(sessionId) != null) {
|
||||||
return ParticipantRole.MODERATOR.equals(participant.getToken().getRole());
|
return OpenViduRole.MODERATOR.equals(participant.getToken().getRole());
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,13 +17,14 @@
|
||||||
|
|
||||||
package io.openvidu.server.core;
|
package io.openvidu.server.core;
|
||||||
|
|
||||||
|
import io.openvidu.java.client.OpenViduRole;
|
||||||
import io.openvidu.server.coturn.TurnCredentials;
|
import io.openvidu.server.coturn.TurnCredentials;
|
||||||
import io.openvidu.server.kurento.core.KurentoTokenOptions;
|
import io.openvidu.server.kurento.core.KurentoTokenOptions;
|
||||||
|
|
||||||
public class Token {
|
public class Token {
|
||||||
|
|
||||||
private String token;
|
private String token;
|
||||||
private ParticipantRole role;
|
private OpenViduRole role;
|
||||||
private String serverMetadata = "";
|
private String serverMetadata = "";
|
||||||
private TurnCredentials turnCredentials;
|
private TurnCredentials turnCredentials;
|
||||||
|
|
||||||
|
@ -33,7 +34,7 @@ public class Token {
|
||||||
this.token = token;
|
this.token = token;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Token(String token, ParticipantRole role, String serverMetadata, TurnCredentials turnCredentials,
|
public Token(String token, OpenViduRole role, String serverMetadata, TurnCredentials turnCredentials,
|
||||||
KurentoTokenOptions kurentoTokenOptions) {
|
KurentoTokenOptions kurentoTokenOptions) {
|
||||||
this.token = token;
|
this.token = token;
|
||||||
this.role = role;
|
this.role = role;
|
||||||
|
@ -46,7 +47,7 @@ public class Token {
|
||||||
return token;
|
return token;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ParticipantRole getRole() {
|
public OpenViduRole getRole() {
|
||||||
return role;
|
return role;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,6 +43,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.MediaMode;
|
import io.openvidu.java.client.MediaMode;
|
||||||
|
import io.openvidu.java.client.OpenViduRole;
|
||||||
import io.openvidu.java.client.Recording.OutputMode;
|
import io.openvidu.java.client.Recording.OutputMode;
|
||||||
import io.openvidu.java.client.RecordingLayout;
|
import io.openvidu.java.client.RecordingLayout;
|
||||||
import io.openvidu.java.client.RecordingMode;
|
import io.openvidu.java.client.RecordingMode;
|
||||||
|
@ -50,7 +51,6 @@ import io.openvidu.java.client.RecordingProperties;
|
||||||
import io.openvidu.java.client.SessionProperties;
|
import io.openvidu.java.client.SessionProperties;
|
||||||
import io.openvidu.server.config.OpenviduConfig;
|
import io.openvidu.server.config.OpenviduConfig;
|
||||||
import io.openvidu.server.core.Participant;
|
import io.openvidu.server.core.Participant;
|
||||||
import io.openvidu.server.core.ParticipantRole;
|
|
||||||
import io.openvidu.server.core.Session;
|
import io.openvidu.server.core.Session;
|
||||||
import io.openvidu.server.core.SessionManager;
|
import io.openvidu.server.core.SessionManager;
|
||||||
import io.openvidu.server.kurento.core.KurentoTokenOptions;
|
import io.openvidu.server.kurento.core.KurentoTokenOptions;
|
||||||
|
@ -300,12 +300,12 @@ public class SessionRestController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ParticipantRole role;
|
OpenViduRole role;
|
||||||
try {
|
try {
|
||||||
if (roleString != null) {
|
if (roleString != null) {
|
||||||
role = ParticipantRole.valueOf(roleString);
|
role = OpenViduRole.valueOf(roleString);
|
||||||
} else {
|
} else {
|
||||||
role = ParticipantRole.PUBLISHER;
|
role = OpenViduRole.PUBLISHER;
|
||||||
}
|
}
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
return this.generateErrorResponse("Parameter role " + params.get("role") + " is not defined", "/api/tokens",
|
return this.generateErrorResponse("Parameter role " + params.get("role") + " is not defined", "/api/tokens",
|
||||||
|
|
Loading…
Reference in New Issue