mirror of https://github.com/OpenVidu/openvidu.git
openvidu-server: support reconnection with mediasoup
parent
3086b4aaf2
commit
4ea531a379
|
@ -72,6 +72,7 @@ public class ProtocolElements {
|
||||||
|
|
||||||
public static final String PREPARERECEIVEVIDEO_METHOD = "prepareReceiveVideFrom";
|
public static final String PREPARERECEIVEVIDEO_METHOD = "prepareReceiveVideFrom";
|
||||||
public static final String PREPARERECEIVEVIDEO_SDPOFFER_PARAM = "sdpOffer";
|
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_METHOD = "receiveVideoFrom";
|
||||||
public static final String RECEIVEVIDEO_SDPOFFER_PARAM = "sdpOffer";
|
public static final String RECEIVEVIDEO_SDPOFFER_PARAM = "sdpOffer";
|
||||||
|
|
|
@ -106,7 +106,7 @@ public abstract class SessionManager {
|
||||||
public abstract void unpublishVideo(Participant participant, Participant moderator, Integer transactionId,
|
public abstract void unpublishVideo(Participant participant, Participant moderator, Integer transactionId,
|
||||||
EndReason reason);
|
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);
|
public abstract void subscribe(Participant participant, String senderName, String sdpAnwser, Integer transactionId);
|
||||||
|
|
||||||
|
|
|
@ -505,7 +505,8 @@ public class KurentoSessionManager extends SessionManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void prepareSubscription(Participant participant, String senderPublicId, Integer transactionId) {
|
public void prepareSubscription(Participant participant, String senderPublicId, boolean reconnect,
|
||||||
|
Integer transactionId) {
|
||||||
String sdpOffer = null;
|
String sdpOffer = null;
|
||||||
Session session = null;
|
Session session = null;
|
||||||
try {
|
try {
|
||||||
|
@ -533,6 +534,10 @@ public class KurentoSessionManager extends SessionManager {
|
||||||
"User '" + senderPublicId + " not streaming media in session '" + session.getSessionId() + "'");
|
"User '" + senderPublicId + " not streaming media in session '" + session.getSessionId() + "'");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (reconnect) {
|
||||||
|
kParticipant.cancelReceivingMedia(((KurentoParticipant) senderParticipant), null, true);
|
||||||
|
}
|
||||||
|
|
||||||
sdpOffer = kParticipant.prepareReceiveMediaFrom(senderParticipant);
|
sdpOffer = kParticipant.prepareReceiveMediaFrom(senderParticipant);
|
||||||
if (sdpOffer == null) {
|
if (sdpOffer == null) {
|
||||||
throw new OpenViduException(Code.MEDIA_SDP_ERROR_CODE, "Unable to generate SDP offer when subscribing '"
|
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);
|
String senderPrivateId = kSession.getParticipantPrivateIdFromStreamId(streamId);
|
||||||
if (senderPrivateId != null) {
|
if (senderPrivateId != null) {
|
||||||
KurentoParticipant sender = (KurentoParticipant) kSession.getParticipantByPrivateId(senderPrivateId);
|
KurentoParticipant sender = (KurentoParticipant) kSession.getParticipantByPrivateId(senderPrivateId);
|
||||||
kParticipant.cancelReceivingMedia(sender, null, true);
|
|
||||||
kParticipant.receiveMediaFrom(sender, sdpString, true);
|
kParticipant.receiveMediaFrom(sender, sdpString, true);
|
||||||
sessionEventsHandler.onSubscribe(participant, kSession, transactionId, null);
|
sessionEventsHandler.onSubscribe(participant, kSession, transactionId, null);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -339,21 +339,22 @@ public class RpcHandler extends DefaultJsonRpcHandler<JsonObject> {
|
||||||
private void prepareReceiveVideoFrom(RpcConnection rpcConnection, Request<JsonObject> request) {
|
private void prepareReceiveVideoFrom(RpcConnection rpcConnection, Request<JsonObject> request) {
|
||||||
Participant participant;
|
Participant participant;
|
||||||
try {
|
try {
|
||||||
participant = sanityCheckOfSession(rpcConnection, "subscribe");
|
participant = sanityCheckOfSession(rpcConnection, "prepareReceiveVideFrom");
|
||||||
} catch (OpenViduException e) {
|
} catch (OpenViduException e) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String senderStreamId = getStringParam(request, ProtocolElements.RECEIVEVIDEO_SENDER_PARAM);
|
String senderStreamId = getStringParam(request, ProtocolElements.RECEIVEVIDEO_SENDER_PARAM);
|
||||||
String senderPublicId = parseSenderPublicIdFromStreamId(senderStreamId);
|
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) {
|
private void receiveVideoFrom(RpcConnection rpcConnection, Request<JsonObject> request) {
|
||||||
Participant participant;
|
Participant participant;
|
||||||
try {
|
try {
|
||||||
participant = sanityCheckOfSession(rpcConnection, "subscribe");
|
participant = sanityCheckOfSession(rpcConnection, "receiveVideoFrom");
|
||||||
} catch (OpenViduException e) {
|
} catch (OpenViduException e) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue