openvidu-server: Added Network Quality support

pull/550/head
csantosm 2020-10-08 15:43:06 +02:00
parent c24606aca7
commit 417d645e45
6 changed files with 72 additions and 14 deletions

View File

@ -773,20 +773,6 @@ public class OpenviduConfig {
}
}
protected Double asNonNegativeDouble(String property) {
try {
Double doubleValue = Double.parseDouble(getValue(property));
if (doubleValue < 0) {
addError(property, "Is not a non negative double");
}
return doubleValue;
} catch (NumberFormatException e) {
addError(property, "Is not a non negative doubleValue");
return 0.0;
}
}
/*
* This method checks all types of Internet addresses (IPv4, IPv6 and Domains)
*/

View File

@ -38,6 +38,10 @@ public class Participant {
protected GeoLocation location; // Location of the participant
protected String platform; // Platform used by the participant to connect to the session
protected EndpointType endpointType; // Type of participant (web participant, IP cam participant...)
protected Integer videoWidth = 0;
protected Integer videoHeight = 0;
protected Boolean videoActive = false;
protected Boolean audioActive = false;
protected boolean streaming = false;
protected volatile boolean closed = false;
@ -142,6 +146,38 @@ public class Participant {
return this.endpointType;
}
public Integer getVideoWidth() {
return videoWidth;
}
public void setVideoWidth(Integer videoWidth) {
this.videoWidth = videoWidth;
}
public Integer getVideoHeight() {
return videoHeight;
}
public void setVideoHeight(Integer videoHeight) {
this.videoHeight = videoHeight;
}
public Boolean isVideoActive() {
return videoActive;
}
public void setVideoActive(Boolean videoActive) {
this.videoActive = videoActive;
}
public Boolean isAudioActive() {
return audioActive;
}
public void setAudioActive(Boolean audioActive) {
this.audioActive = audioActive;
}
public boolean isStreaming() {
return streaming;
}

View File

@ -558,6 +558,18 @@ public class SessionEventsHandler {
}
}
public void onVideoData(Participant participant, Integer transactionId, Integer height, Integer width,
Boolean videoActive, Boolean audioActive) {
participant.setVideoHeight(height);
participant.setVideoWidth(width);
participant.setVideoActive(videoActive);
participant.setAudioActive(audioActive);
log.info(
"Video data of participant {} was initialized. height:{}, width:{}, isVideoActive: {}, isAudioActive: {}",
participant.getParticipantPublicId(), height, width, videoActive, audioActive);
rpcNotificationService.sendResponse(participant.getParticipantPrivateId(), transactionId, new JsonObject());
}
public void closeRpcSession(String participantPrivateId) {
this.rpcNotificationService.closeRpcSession(participantPrivateId);
}

View File

@ -166,6 +166,8 @@ public abstract class SessionManager {
public abstract String getParticipantPrivateIdFromStreamId(String sessionId, String streamId)
throws OpenViduException;
public abstract void onVideoData(Participant participant, Integer transactionId, Integer height, Integer width, Boolean videoActive, Boolean audioActive);
/**
* Returns a Session given its id
*

View File

@ -1108,6 +1108,11 @@ public class KurentoSessionManager extends SessionManager {
return ((KurentoSession) session).getParticipantPrivateIdFromStreamId(streamId);
}
@Override
public void onVideoData(Participant participant, Integer transactionId, Integer height, Integer width, Boolean videoActive, Boolean audioActive) {
sessionEventsHandler.onVideoData(participant, transactionId, height, width, videoActive, audioActive);
}
private void applyFilterInPublisher(KurentoParticipant kParticipant, KurentoFilter filter)
throws OpenViduException {
GenericMediaElement.Builder builder = new GenericMediaElement.Builder(kParticipant.getPipeline(),

View File

@ -165,6 +165,9 @@ public class RpcHandler extends DefaultJsonRpcHandler<JsonObject> {
case ProtocolElements.RECONNECTSTREAM_METHOD:
reconnectStream(rpcConnection, request);
break;
case ProtocolElements.VIDEODATA_METHOD:
updateVideoData(rpcConnection, request);
break;
default:
log.error("Unrecognized request {}", request);
break;
@ -634,6 +637,20 @@ public class RpcHandler extends DefaultJsonRpcHandler<JsonObject> {
}
}
private void updateVideoData(RpcConnection rpcConnection, Request<JsonObject> request) {
Participant participant;
try {
participant = sanityCheckOfSession(rpcConnection, "videoData");
int height = getIntParam(request, "height");
int width = getIntParam(request, "width");
boolean videoActive = getBooleanParam(request, "videoActive");
boolean audioActive = getBooleanParam(request, "audioActive");
sessionManager.onVideoData(participant, request.getId(), height, width, videoActive, audioActive);
} catch (OpenViduException e) {
log.error("Error getting video data: {}", e.toString());
}
}
public void leaveRoomAfterConnClosed(String participantPrivateId, EndReason reason) {
try {
sessionManager.evictParticipant(this.sessionManager.getParticipant(participantPrivateId), null, null,