mirror of https://github.com/OpenVidu/openvidu.git
Retrocompatibility with 2.15.0: StreamLEGACY remote streams only for 2.15.0
parent
243dfcee67
commit
c6019394ec
|
@ -155,75 +155,69 @@ export class StreamLEGACY extends Stream {
|
||||||
*/
|
*/
|
||||||
initWebRtcPeerReceive(reconnect: boolean): Promise<any> {
|
initWebRtcPeerReceive(reconnect: boolean): Promise<any> {
|
||||||
|
|
||||||
if (!!this.session.openvidu.openviduServerVersion) {
|
// 2.15.0
|
||||||
// 2.16.0
|
return new Promise((resolve, reject) => {
|
||||||
return super.initWebRtcPeerReceive(reconnect);
|
|
||||||
|
|
||||||
} else {
|
const offerConstraints = {
|
||||||
// 2.15.0
|
audio: this.inboundStreamOpts.hasAudio,
|
||||||
return new Promise((resolve, reject) => {
|
video: this.inboundStreamOpts.hasVideo
|
||||||
|
};
|
||||||
|
logger.debug("'Session.subscribe(Stream)' called. Constraints of generate SDP offer",
|
||||||
|
offerConstraints);
|
||||||
|
const options = {
|
||||||
|
onicecandidate: this.connection.sendIceCandidate.bind(this.connection),
|
||||||
|
mediaConstraints: offerConstraints,
|
||||||
|
iceServers: this.getIceServersConf(),
|
||||||
|
simulcast: false
|
||||||
|
};
|
||||||
|
|
||||||
const offerConstraints = {
|
const successCallback = (sdpOfferParam) => {
|
||||||
audio: this.inboundStreamOpts.hasAudio,
|
logger.debug('Sending SDP offer to subscribe to '
|
||||||
video: this.inboundStreamOpts.hasVideo
|
+ this.streamId, sdpOfferParam);
|
||||||
};
|
|
||||||
logger.debug("'Session.subscribe(Stream)' called. Constraints of generate SDP offer",
|
|
||||||
offerConstraints);
|
|
||||||
const options = {
|
|
||||||
onicecandidate: this.connection.sendIceCandidate.bind(this.connection),
|
|
||||||
mediaConstraints: offerConstraints,
|
|
||||||
iceServers: this.getIceServersConf(),
|
|
||||||
simulcast: false
|
|
||||||
};
|
|
||||||
|
|
||||||
const successCallback = (sdpOfferParam) => {
|
const method = reconnect ? 'reconnectStream' : 'receiveVideoFrom';
|
||||||
logger.debug('Sending SDP offer to subscribe to '
|
const params = { sdpOffer: sdpOfferParam };
|
||||||
+ this.streamId, sdpOfferParam);
|
params[reconnect ? 'stream' : 'sender'] = this.streamId;
|
||||||
|
|
||||||
const method = reconnect ? 'reconnectStream' : 'receiveVideoFrom';
|
this.session.openvidu.sendRequest(method, params, (error, response) => {
|
||||||
const params = { sdpOffer: sdpOfferParam };
|
if (error) {
|
||||||
params[reconnect ? 'stream' : 'sender'] = this.streamId;
|
reject(new Error('Error on recvVideoFrom: ' + JSON.stringify(error)));
|
||||||
|
} else {
|
||||||
this.session.openvidu.sendRequest(method, params, (error, response) => {
|
// Ios Ionic. Limitation: some bug in iosrtc cordova plugin makes it necessary
|
||||||
if (error) {
|
// to add a timeout before calling PeerConnection#setRemoteDescription during
|
||||||
reject(new Error('Error on recvVideoFrom: ' + JSON.stringify(error)));
|
// some time (400 ms) from the moment first subscriber stream is received
|
||||||
} else {
|
if (this.session.isFirstIonicIosSubscriber) {
|
||||||
// Ios Ionic. Limitation: some bug in iosrtc cordova plugin makes it necessary
|
this.session.isFirstIonicIosSubscriber = false;
|
||||||
// to add a timeout before calling PeerConnection#setRemoteDescription during
|
setTimeout(() => {
|
||||||
// some time (400 ms) from the moment first subscriber stream is received
|
// After 400 ms Ionic iOS subscribers won't need to run
|
||||||
if (this.session.isFirstIonicIosSubscriber) {
|
// PeerConnection#setRemoteDescription after 250 ms timeout anymore
|
||||||
this.session.isFirstIonicIosSubscriber = false;
|
this.session.countDownForIonicIosSubscribersActive = false;
|
||||||
setTimeout(() => {
|
}, 400);
|
||||||
// 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;
|
|
||||||
(<WebRtcPeerLEGACY>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);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
const needsTimeoutOnProcessAnswer = this.session.countDownForIonicIosSubscribersActive;
|
||||||
};
|
(<WebRtcPeerLEGACY>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);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
this.webRtcPeer = new WebRtcPeerRecvonlyLEGACY(options);
|
this.webRtcPeer = new WebRtcPeerRecvonlyLEGACY(options);
|
||||||
this.webRtcPeer.addIceConnectionStateChangeListener(this.streamId);
|
this.webRtcPeer.addIceConnectionStateChangeListener(this.streamId);
|
||||||
(<WebRtcPeerLEGACY>this.webRtcPeer).generateOffer()
|
(<WebRtcPeerLEGACY>this.webRtcPeer).generateOffer()
|
||||||
.then(sdpOffer => {
|
.then(sdpOffer => {
|
||||||
successCallback(sdpOffer);
|
successCallback(sdpOffer);
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
reject(new Error('(subscribe) SDP offer error: ' + JSON.stringify(error)));
|
reject(new Error('(subscribe) SDP offer error: ' + JSON.stringify(error)));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -231,40 +225,34 @@ export class StreamLEGACY extends Stream {
|
||||||
*/
|
*/
|
||||||
remotePeerSuccessfullyEstablished(): void {
|
remotePeerSuccessfullyEstablished(): void {
|
||||||
|
|
||||||
if (!!this.session.openvidu.openviduServerVersion) {
|
// 2.15.0
|
||||||
// 2.16.0
|
this.mediaStream = new MediaStream();
|
||||||
super.remotePeerSuccessfullyEstablished();
|
let receiver: RTCRtpReceiver;
|
||||||
|
for (receiver of this.webRtcPeer.pc.getReceivers()) {
|
||||||
} else {
|
if (!!receiver.track) {
|
||||||
// 2.15.0
|
this.mediaStream.addTrack(receiver.track);
|
||||||
this.mediaStream = new MediaStream();
|
|
||||||
let receiver: RTCRtpReceiver;
|
|
||||||
for (receiver of this.webRtcPeer.pc.getReceivers()) {
|
|
||||||
if (!!receiver.track) {
|
|
||||||
this.mediaStream.addTrack(receiver.track);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
logger.debug('Peer remote stream', this.mediaStream);
|
|
||||||
|
|
||||||
if (!!this.mediaStream) {
|
|
||||||
|
|
||||||
if (this.streamManager instanceof Subscriber) {
|
|
||||||
// Apply SubscriberProperties.subscribeToAudio and SubscriberProperties.subscribeToVideo
|
|
||||||
if (!!this.mediaStream.getAudioTracks()[0]) {
|
|
||||||
const enabled = !!((<Subscriber>this.streamManager).properties.subscribeToAudio);
|
|
||||||
this.mediaStream.getAudioTracks()[0].enabled = enabled;
|
|
||||||
}
|
|
||||||
if (!!this.mediaStream.getVideoTracks()[0]) {
|
|
||||||
const enabled = !!((<Subscriber>this.streamManager).properties.subscribeToVideo);
|
|
||||||
this.mediaStream.getVideoTracks()[0].enabled = enabled;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.updateMediaStreamInVideos();
|
|
||||||
this.initHarkEvents(); // Init hark events for the remote stream
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
logger.debug('Peer remote stream', this.mediaStream);
|
||||||
|
|
||||||
|
if (!!this.mediaStream) {
|
||||||
|
|
||||||
|
if (this.streamManager instanceof Subscriber) {
|
||||||
|
// Apply SubscriberProperties.subscribeToAudio and SubscriberProperties.subscribeToVideo
|
||||||
|
if (!!this.mediaStream.getAudioTracks()[0]) {
|
||||||
|
const enabled = !!((<Subscriber>this.streamManager).properties.subscribeToAudio);
|
||||||
|
this.mediaStream.getAudioTracks()[0].enabled = enabled;
|
||||||
|
}
|
||||||
|
if (!!this.mediaStream.getVideoTracks()[0]) {
|
||||||
|
const enabled = !!((<Subscriber>this.streamManager).properties.subscribeToVideo);
|
||||||
|
this.mediaStream.getVideoTracks()[0].enabled = enabled;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.updateMediaStreamInVideos();
|
||||||
|
this.initHarkEvents(); // Init hark events for the remote stream
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue