openvidu-server: support reconnection with mediasoup

pull/600/head
pabloFuente 2020-09-02 13:25:38 +02:00
parent 3086b4aaf2
commit 4ea531a379
4 changed files with 12 additions and 6 deletions

View File

@ -72,6 +72,7 @@ public class ProtocolElements {
public static final String PREPARERECEIVEVIDEO_METHOD = "prepareReceiveVideFrom";
public static final String PREPARERECEIVEVIDEO_SDPOFFER_PARAM = "sdpOffer";
public static final String PREPARERECEIVEVIDEO_RECONNECT_PARAM = "reconnect";
public static final String RECEIVEVIDEO_METHOD = "receiveVideoFrom";
public static final String RECEIVEVIDEO_SDPOFFER_PARAM = "sdpOffer";

View File

@ -106,7 +106,7 @@ public abstract class SessionManager {
public abstract void unpublishVideo(Participant participant, Participant moderator, Integer transactionId,
EndReason reason);
public abstract void prepareSubscription(Participant participant, String senderPublicId, Integer id);
public abstract void prepareSubscription(Participant participant, String senderPublicId, boolean reconnect, Integer id);
public abstract void subscribe(Participant participant, String senderName, String sdpAnwser, Integer transactionId);

View File

@ -505,7 +505,8 @@ public class KurentoSessionManager extends SessionManager {
}
@Override
public void prepareSubscription(Participant participant, String senderPublicId, Integer transactionId) {
public void prepareSubscription(Participant participant, String senderPublicId, boolean reconnect,
Integer transactionId) {
String sdpOffer = null;
Session session = null;
try {
@ -533,6 +534,10 @@ public class KurentoSessionManager extends SessionManager {
"User '" + senderPublicId + " not streaming media in session '" + session.getSessionId() + "'");
}
if (reconnect) {
kParticipant.cancelReceivingMedia(((KurentoParticipant) senderParticipant), null, true);
}
sdpOffer = kParticipant.prepareReceiveMediaFrom(senderParticipant);
if (sdpOffer == null) {
throw new OpenViduException(Code.MEDIA_SDP_ERROR_CODE, "Unable to generate SDP offer when subscribing '"
@ -1118,7 +1123,6 @@ public class KurentoSessionManager extends SessionManager {
String senderPrivateId = kSession.getParticipantPrivateIdFromStreamId(streamId);
if (senderPrivateId != null) {
KurentoParticipant sender = (KurentoParticipant) kSession.getParticipantByPrivateId(senderPrivateId);
kParticipant.cancelReceivingMedia(sender, null, true);
kParticipant.receiveMediaFrom(sender, sdpString, true);
sessionEventsHandler.onSubscribe(participant, kSession, transactionId, null);
} else {

View File

@ -339,21 +339,22 @@ public class RpcHandler extends DefaultJsonRpcHandler<JsonObject> {
private void prepareReceiveVideoFrom(RpcConnection rpcConnection, Request<JsonObject> request) {
Participant participant;
try {
participant = sanityCheckOfSession(rpcConnection, "subscribe");
participant = sanityCheckOfSession(rpcConnection, "prepareReceiveVideFrom");
} catch (OpenViduException e) {
return;
}
String senderStreamId = getStringParam(request, ProtocolElements.RECEIVEVIDEO_SENDER_PARAM);
String senderPublicId = parseSenderPublicIdFromStreamId(senderStreamId);
boolean reconnect = getBooleanParam(request, ProtocolElements.PREPARERECEIVEVIDEO_RECONNECT_PARAM);
sessionManager.prepareSubscription(participant, senderPublicId, request.getId());
sessionManager.prepareSubscription(participant, senderPublicId, reconnect, request.getId());
}
private void receiveVideoFrom(RpcConnection rpcConnection, Request<JsonObject> request) {
Participant participant;
try {
participant = sanityCheckOfSession(rpcConnection, "subscribe");
participant = sanityCheckOfSession(rpcConnection, "receiveVideoFrom");
} catch (OpenViduException e) {
return;
}