openvidu-server: do not allow client forceUnpublish over IPCAM streams

pull/405/head
pabloFuente 2020-02-19 16:30:14 +01:00
parent e6dcb7941e
commit 2741605b78
2 changed files with 14 additions and 1 deletions

View File

@ -163,6 +163,11 @@ public class Participant {
return fullMetadata;
}
public void deleteIpcamProperties() {
this.clientMetadata = "";
this.token.setToken(null);
}
@Override
public int hashCode() {
final int prime = 31;
@ -225,7 +230,9 @@ public class Participant {
json.addProperty("createdAt", this.createdAt);
json.addProperty("location", this.location != null ? this.location.toString() : "unknown");
json.addProperty("platform", this.platform);
json.addProperty("token", this.token.getToken());
if (this.token.getToken() != null) {
json.addProperty("token", this.token.getToken());
}
json.addProperty("role", this.token.getRole().name());
json.addProperty("serverData", this.serverMetadata);
json.addProperty("clientData", this.clientMetadata);

View File

@ -624,6 +624,10 @@ public class KurentoSessionManager extends SessionManager {
if (participantPrivateId != null) {
Participant participant = this.getParticipant(participantPrivateId);
if (participant != null) {
if (participant.isIpcam()) {
throw new OpenViduException(Code.USER_GENERIC_ERROR_CODE, "Stream '" + streamId
+ " belonging to an IPCAM participant cannot be unpublished. IPCAM streams can only be unpublished by forcing the disconnection of the IPCAM connection");
}
this.unpublishVideo(participant, moderator, transactionId, reason);
return true;
} else {
@ -921,6 +925,8 @@ public class KurentoSessionManager extends SessionManager {
// Publish the IpCam stream into the session
KurentoParticipant kParticipant = (KurentoParticipant) this.getParticipant(rtspConnectionId);
kParticipant.deleteIpcamProperties();
this.publishVideo(kParticipant, mediaOptions, null);
return kParticipant;
}