Added kurento screensharing viewer stop logic
This commit is contained in:
parent
9175400c2e
commit
c04e3da068
@ -99,8 +99,15 @@ module.exports = class ConnectionManager {
|
|||||||
|
|
||||||
webSocket.on('close', function() {
|
webSocket.on('close', function() {
|
||||||
console.log('Connection ' + connectionId + ' closed');
|
console.log('Connection ' + connectionId + ' closed');
|
||||||
if (self._screenshareSessions[sessionId] && self._screenshareSessions[sessionId].id == connectionId) { // if presenter // FIXME (this conditional was added to prevent screenshare stop when an iOS user quits)
|
console.log(webSocket.presenter);
|
||||||
self._stopSession(sessionId);
|
|
||||||
|
if (webSocket.presenter && self._screenshareSessions[sessionId]) { // if presenter // FIXME (this conditional was added to prevent screenshare stop when an iOS user quits)
|
||||||
|
console.log(" [CM] Stopping presenter " + sessionId);
|
||||||
|
self._stopSession(sessionId);
|
||||||
|
}
|
||||||
|
if (webSocket.viewer && typeof webSocket.session !== 'undefined') {
|
||||||
|
console.log(" [CM] Stopping viewer " + webSocket.viewerId);
|
||||||
|
webSocket.session._stopViewer(webSocket.viewerId);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -111,6 +118,7 @@ module.exports = class ConnectionManager {
|
|||||||
sessionId = message.voiceBridge;
|
sessionId = message.voiceBridge;
|
||||||
if(self._screenshareSessions[sessionId]) {
|
if(self._screenshareSessions[sessionId]) {
|
||||||
session = self._screenshareSessions[sessionId];
|
session = self._screenshareSessions[sessionId];
|
||||||
|
webSocket.session = session;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (message.id) {
|
switch (message.id) {
|
||||||
@ -119,11 +127,12 @@ module.exports = class ConnectionManager {
|
|||||||
|
|
||||||
// Checking if there's already a Screenshare session started
|
// Checking if there's already a Screenshare session started
|
||||||
// because we shouldn't overwrite it
|
// because we shouldn't overwrite it
|
||||||
|
webSocket.presenter = true;
|
||||||
|
|
||||||
if (!self._screenshareSessions[message.voiceBridge]) {
|
if (!self._screenshareSessions[message.voiceBridge]) {
|
||||||
self._screenshareSessions[message.voiceBridge] = {}
|
self._screenshareSessions[message.voiceBridge] = {}
|
||||||
self._screenshareSessions[message.voiceBridge] = session;
|
self._screenshareSessions[message.voiceBridge] = session;
|
||||||
}
|
}
|
||||||
|
|
||||||
//session.on('message', self._assembleSessionMessage.bind(self));
|
//session.on('message', self._assembleSessionMessage.bind(self));
|
||||||
if(session) {
|
if(session) {
|
||||||
@ -159,6 +168,10 @@ module.exports = class ConnectionManager {
|
|||||||
|
|
||||||
case 'viewer':
|
case 'viewer':
|
||||||
console.log("[viewer] Session output \n " + session);
|
console.log("[viewer] Session output \n " + session);
|
||||||
|
|
||||||
|
webSocket.viewer = true;
|
||||||
|
webSocket.viewerId = message.callerName;
|
||||||
|
|
||||||
if (message.sdpOffer && message.voiceBridge) {
|
if (message.sdpOffer && message.voiceBridge) {
|
||||||
if (session) {
|
if (session) {
|
||||||
session._startViewer(webSocket, message.voiceBridge, message.sdpOffer, message.callerName, self._screenshareSessions[message.voiceBridge]._presenterEndpoint);
|
session._startViewer(webSocket, message.voiceBridge, message.sdpOffer, message.callerName, self._screenshareSessions[message.voiceBridge]._presenterEndpoint);
|
||||||
@ -182,6 +195,7 @@ module.exports = class ConnectionManager {
|
|||||||
|
|
||||||
case 'onIceCandidate':
|
case 'onIceCandidate':
|
||||||
if (session) {
|
if (session) {
|
||||||
|
console.log(" [CM] What the fluff is happening");
|
||||||
session._onIceCandidate(message.candidate);
|
session._onIceCandidate(message.candidate);
|
||||||
} else {
|
} else {
|
||||||
console.log(" [iceCandidate] Why is there no session on ICE CANDIDATE?");
|
console.log(" [iceCandidate] Why is there no session on ICE CANDIDATE?");
|
||||||
@ -196,14 +210,14 @@ module.exports = class ConnectionManager {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
case 'viewerIceCandidate':
|
case 'viewerIceCandidate':
|
||||||
console.log("[viewerIceCandidate] Session output => " + session);
|
console.log("[viewerIceCandidate] Session output => " + session);
|
||||||
if (session) {
|
if (session) {
|
||||||
session._onViewerIceCandidate(message.candidate, message.callerName);
|
session._onViewerIceCandidate(message.candidate, message.callerName);
|
||||||
} else {
|
} else {
|
||||||
console.log("[iceCandidate] Why is there no session on ICE CANDIDATE?");
|
console.log("[iceCandidate] Why is there no session on ICE CANDIDATE?");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
webSocket.sendMessage({ id : 'error', message : 'Invalid message ' + message });
|
webSocket.sendMessage({ id : 'error', message : 'Invalid message ' + message });
|
||||||
|
@ -53,6 +53,7 @@ module.exports = class Screenshare {
|
|||||||
let candidate = kurento.getComplexType('IceCandidate')(_candidate);
|
let candidate = kurento.getComplexType('IceCandidate')(_candidate);
|
||||||
|
|
||||||
if (this._presenterEndpoint) {
|
if (this._presenterEndpoint) {
|
||||||
|
console.log(" [screenshare] Adding ICE candidate to presenter");
|
||||||
this._presenterEndpoint.addIceCandidate(candidate);
|
this._presenterEndpoint.addIceCandidate(candidate);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -107,8 +108,7 @@ module.exports = class Screenshare {
|
|||||||
|
|
||||||
// ICE NEGOTIATION WITH THE ENDPOINT
|
// ICE NEGOTIATION WITH THE ENDPOINT
|
||||||
self._viewersEndpoint[callerName].on('OnIceCandidate', function(event) {
|
self._viewersEndpoint[callerName].on('OnIceCandidate', function(event) {
|
||||||
let candidate = kurento.getComplexType('IceCandidate')(event.candidate);
|
let candidate = kurento.getComplexType('IceCandidate')(event.candidate); ws.sendMessage({ id : 'iceCandidate', candidate : candidate });
|
||||||
ws.sendMessage({ id : 'iceCandidate', candidate : candidate });
|
|
||||||
});
|
});
|
||||||
|
|
||||||
sdp = h264_sdp.transform(sdp);
|
sdp = h264_sdp.transform(sdp);
|
||||||
@ -127,13 +127,13 @@ module.exports = class Screenshare {
|
|||||||
return _callback(error);
|
return _callback(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
self._viewersEndpoint[callerName].on('MediaFlowInStateChange', function(event) {
|
self._viewersEndpoint[callerName].on('MediaFlowInStateChange', function(event) {
|
||||||
if (event.state === 'NOT_FLOWING') {
|
if (event.state === 'NOT_FLOWING') {
|
||||||
console.log(" NOT FLOWING ");
|
console.log(" NOT FLOWING ");
|
||||||
}
|
}
|
||||||
else if (event.state === 'FLOWING') {
|
else if (event.state === 'FLOWING') {
|
||||||
console.log(" FLOWING ");
|
console.log(" FLOWING ");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -243,8 +243,7 @@ module.exports = class Screenshare {
|
|||||||
this._presenterEndpoint = null;
|
this._presenterEndpoint = null;
|
||||||
} else {
|
} else {
|
||||||
console.log(" [webRtcEndpoint] PLEASE DONT TRY STOPPING THINGS TWICE");
|
console.log(" [webRtcEndpoint] PLEASE DONT TRY STOPPING THINGS TWICE");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this._ffmpegRtpEndpoint) {
|
if (this._ffmpegRtpEndpoint) {
|
||||||
MediaController.releaseMediaElement(this._ffmpegRtpEndpoint.id);
|
MediaController.releaseMediaElement(this._ffmpegRtpEndpoint.id);
|
||||||
this._ffmpegRtpEndpoint = null;
|
this._ffmpegRtpEndpoint = null;
|
||||||
@ -280,6 +279,7 @@ module.exports = class Screenshare {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_onRtpMediaFlowing(meetingId, rtpParams) {
|
_onRtpMediaFlowing(meetingId, rtpParams) {
|
||||||
|
console.log(" [screenshare] Media FLOWING for meeting => " + meetingId);
|
||||||
let self = this;
|
let self = this;
|
||||||
let strm = Messaging.generateStartTranscoderRequestMessage(meetingId, meetingId, rtpParams);
|
let strm = Messaging.generateStartTranscoderRequestMessage(meetingId, meetingId, rtpParams);
|
||||||
|
|
||||||
@ -302,7 +302,8 @@ module.exports = class Screenshare {
|
|||||||
};
|
};
|
||||||
|
|
||||||
_stopRtmpBroadcast (meetingId) {
|
_stopRtmpBroadcast (meetingId) {
|
||||||
var self = this;
|
console.log(" [screenshare] _stopRtmpBroadcast for meeting => " + meetingId);
|
||||||
|
let self = this;
|
||||||
if(self._meetingId === meetingId) {
|
if(self._meetingId === meetingId) {
|
||||||
// TODO correctly assemble this timestamp
|
// TODO correctly assemble this timestamp
|
||||||
let timestamp = now.format('hhmmss');
|
let timestamp = now.format('hhmmss');
|
||||||
@ -313,6 +314,7 @@ module.exports = class Screenshare {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_startRtmpBroadcast (meetingId, output) {
|
_startRtmpBroadcast (meetingId, output) {
|
||||||
|
console.log(" [screenshare] _startRtmpBroadcast for meeting => " + meetingId);
|
||||||
var self = this;
|
var self = this;
|
||||||
if(self._meetingId === meetingId) {
|
if(self._meetingId === meetingId) {
|
||||||
// TODO correctly assemble this timestamp
|
// TODO correctly assemble this timestamp
|
||||||
@ -329,5 +331,17 @@ module.exports = class Screenshare {
|
|||||||
console.log(" [screenshare] TODO RTP NOT_FLOWING");
|
console.log(" [screenshare] TODO RTP NOT_FLOWING");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
_stopViewer(id) {
|
||||||
|
let viewer = this._viewersEndpoint[id];
|
||||||
|
console.log(' [stop] Releasing endpoints for ' + id);
|
||||||
|
|
||||||
|
if (viewer) {
|
||||||
|
MediaController.releaseMediaElement(viewer.id);
|
||||||
|
this._viewersEndpoint[viewer.id] = null;
|
||||||
|
} else {
|
||||||
|
console.log(" [webRtcEndpoint] PLEASE DONT TRY STOPPING THINGS TWICE");
|
||||||
|
}
|
||||||
|
|
||||||
|
delete this._viewersCandidatesQueue[id];
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user