mirror of https://github.com/OpenVidu/openvidu.git
Merge branch 'mediasoup' of github.com:OpenVidu/openvidu into mediasoup
commit
b399e686ed
|
@ -99,14 +99,6 @@ export class Session extends EventDispatcher {
|
|||
*/
|
||||
remoteStreamsCreated: ObjMap<boolean> = {};
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
isFirstIonicIosSubscriber = true;
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
countDownForIonicIosSubscribersActive = true;
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
|
@ -724,11 +716,6 @@ export class Session extends EventDispatcher {
|
|||
streamEvent.callDefaultBehavior();
|
||||
|
||||
delete this.remoteStreamsCreated[stream.streamId];
|
||||
|
||||
if (Object.keys(this.remoteStreamsCreated).length === 0) {
|
||||
this.isFirstIonicIosSubscriber = true;
|
||||
this.countDownForIonicIosSubscribersActive = true;
|
||||
}
|
||||
}
|
||||
delete this.remoteConnections[connection.connectionId];
|
||||
this.ee.emitEvent('connectionDestroyed', [new ConnectionEvent(false, this, 'connectionDestroyed', connection, msg.reason)]);
|
||||
|
@ -798,12 +785,6 @@ export class Session extends EventDispatcher {
|
|||
// Deleting the remote stream
|
||||
const streamId: string = connection.stream.streamId;
|
||||
delete this.remoteStreamsCreated[streamId];
|
||||
|
||||
if (Object.keys(this.remoteStreamsCreated).length === 0) {
|
||||
this.isFirstIonicIosSubscriber = true;
|
||||
this.countDownForIonicIosSubscribersActive = true;
|
||||
}
|
||||
|
||||
connection.removeStream(streamId);
|
||||
})
|
||||
.catch(openViduError => {
|
||||
|
|
|
@ -913,7 +913,7 @@ export class Stream extends EventDispatcher {
|
|||
*/
|
||||
initWebRtcPeerReceive(reconnect: boolean): Promise<any> {
|
||||
return new Promise((resolve, reject) => {
|
||||
this.session.openvidu.sendRequest('prepareReceiveVideFrom', { sender: this.streamId }, (error, response) => {
|
||||
this.session.openvidu.sendRequest('prepareReceiveVideFrom', { sender: this.streamId, reconnect }, (error, response) => {
|
||||
if (error) {
|
||||
reject(new Error('Error on prepareReceiveVideFrom: ' + JSON.stringify(error)));
|
||||
} else {
|
||||
|
@ -965,26 +965,6 @@ export class Stream extends EventDispatcher {
|
|||
reject(new Error('Error on receiveVideFrom: ' + JSON.stringify(error)));
|
||||
} else {
|
||||
resolve();
|
||||
// // Ios Ionic. Limitation: some bug in iosrtc cordova plugin makes it necessary
|
||||
// // to add a timeout before calling PeerConnection#setRemoteDescription during
|
||||
// // some time (400 ms) from the moment first subscriber stream is received
|
||||
// if (this.session.isFirstIonicIosSubscriber) {
|
||||
// this.session.isFirstIonicIosSubscriber = false;
|
||||
// setTimeout(() => {
|
||||
// // After 400 ms Ionic iOS subscribers won't need to run
|
||||
// // PeerConnection#setRemoteDescription after 250 ms timeout anymore
|
||||
// this.session.countDownForIonicIosSubscribersActive = false;
|
||||
// }, 400);
|
||||
// }
|
||||
// const needsTimeoutOnProcessAnswer = this.session.countDownForIonicIosSubscribersActive;
|
||||
// this.webRtcPeer.processAnswer(response.sdpAnswer, needsTimeoutOnProcessAnswer).then(() => {
|
||||
// logger.info("'Subscriber' (" + this.streamId + ") successfully " + (reconnect ? "reconnected" : "subscribed"));
|
||||
// this.remotePeerSuccessfullyEstablished();
|
||||
// this.initWebRtcStats();
|
||||
// resolve();
|
||||
// }).catch(error => {
|
||||
// reject(error);
|
||||
// });
|
||||
}
|
||||
});
|
||||
};
|
||||
|
|
|
@ -232,8 +232,7 @@ export class WebRtcPeer {
|
|||
if (this.pc.signalingState === 'closed') {
|
||||
reject('RTCPeerConnection is closed when trying to set remote description');
|
||||
}
|
||||
// TODO: check if Ionic iOS still needs timeout on setting first remote description when subscribing
|
||||
this.setRemoteDescription(offer, false)
|
||||
this.setRemoteDescription(offer)
|
||||
.then(() => {
|
||||
resolve();
|
||||
})
|
||||
|
@ -272,7 +271,7 @@ export class WebRtcPeer {
|
|||
if (this.pc.signalingState === 'closed') {
|
||||
reject('RTCPeerConnection is closed when trying to set remote description');
|
||||
}
|
||||
this.setRemoteDescription(answer, false)
|
||||
this.setRemoteDescription(answer)
|
||||
.then(() => resolve())
|
||||
.catch(error => reject(error));
|
||||
});
|
||||
|
@ -281,22 +280,8 @@ export class WebRtcPeer {
|
|||
/**
|
||||
* @hidden
|
||||
*/
|
||||
async setRemoteDescription(sdp: RTCSessionDescriptionInit, needsTimeoutOnProcessAnswer: boolean): Promise<void> {
|
||||
// if (platform['isIonicIos']) {
|
||||
// // Ionic iOS platform
|
||||
// if (needsTimeoutOnProcessAnswer) {
|
||||
// // 400 ms have not elapsed yet since first remote stream triggered Stream#initWebRtcPeerReceive
|
||||
// await new Promise(resolve => setTimeout(resolve, 250)); // Sleep for 250ms
|
||||
// logger.info('setRemoteDescription run after timeout for Ionic iOS device');
|
||||
// return this.pc.setRemoteDescription(sdp);
|
||||
// } else {
|
||||
// // 400 ms have elapsed
|
||||
// return this.pc.setRemoteDescription(sdp);
|
||||
// }
|
||||
// } else {
|
||||
// Rest of platforms
|
||||
return this.pc.setRemoteDescription(sdp);
|
||||
// }
|
||||
async setRemoteDescription(sdp: RTCSessionDescriptionInit): Promise<void> {
|
||||
return this.pc.setRemoteDescription(sdp);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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";
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -524,7 +524,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 {
|
||||
|
@ -552,6 +553,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 '"
|
||||
|
@ -1165,7 +1170,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 {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue