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() {
|
||||
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)
|
||||
self._stopSession(sessionId);
|
||||
console.log(webSocket.presenter);
|
||||
|
||||
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;
|
||||
if(self._screenshareSessions[sessionId]) {
|
||||
session = self._screenshareSessions[sessionId];
|
||||
webSocket.session = session;
|
||||
}
|
||||
|
||||
switch (message.id) {
|
||||
@ -119,11 +127,12 @@ module.exports = class ConnectionManager {
|
||||
|
||||
// Checking if there's already a Screenshare session started
|
||||
// because we shouldn't overwrite it
|
||||
webSocket.presenter = true;
|
||||
|
||||
if (!self._screenshareSessions[message.voiceBridge]) {
|
||||
self._screenshareSessions[message.voiceBridge] = {}
|
||||
self._screenshareSessions[message.voiceBridge] = session;
|
||||
}
|
||||
if (!self._screenshareSessions[message.voiceBridge]) {
|
||||
self._screenshareSessions[message.voiceBridge] = {}
|
||||
self._screenshareSessions[message.voiceBridge] = session;
|
||||
}
|
||||
|
||||
//session.on('message', self._assembleSessionMessage.bind(self));
|
||||
if(session) {
|
||||
@ -159,6 +168,10 @@ module.exports = class ConnectionManager {
|
||||
|
||||
case 'viewer':
|
||||
console.log("[viewer] Session output \n " + session);
|
||||
|
||||
webSocket.viewer = true;
|
||||
webSocket.viewerId = message.callerName;
|
||||
|
||||
if (message.sdpOffer && message.voiceBridge) {
|
||||
if (session) {
|
||||
session._startViewer(webSocket, message.voiceBridge, message.sdpOffer, message.callerName, self._screenshareSessions[message.voiceBridge]._presenterEndpoint);
|
||||
@ -182,6 +195,7 @@ module.exports = class ConnectionManager {
|
||||
|
||||
case 'onIceCandidate':
|
||||
if (session) {
|
||||
console.log(" [CM] What the fluff is happening");
|
||||
session._onIceCandidate(message.candidate);
|
||||
} else {
|
||||
console.log(" [iceCandidate] Why is there no session on ICE CANDIDATE?");
|
||||
@ -196,14 +210,14 @@ module.exports = class ConnectionManager {
|
||||
break;
|
||||
|
||||
|
||||
case 'viewerIceCandidate':
|
||||
console.log("[viewerIceCandidate] Session output => " + session);
|
||||
if (session) {
|
||||
session._onViewerIceCandidate(message.candidate, message.callerName);
|
||||
} else {
|
||||
console.log("[iceCandidate] Why is there no session on ICE CANDIDATE?");
|
||||
}
|
||||
break;
|
||||
case 'viewerIceCandidate':
|
||||
console.log("[viewerIceCandidate] Session output => " + session);
|
||||
if (session) {
|
||||
session._onViewerIceCandidate(message.candidate, message.callerName);
|
||||
} else {
|
||||
console.log("[iceCandidate] Why is there no session on ICE CANDIDATE?");
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
webSocket.sendMessage({ id : 'error', message : 'Invalid message ' + message });
|
||||
|
@ -53,6 +53,7 @@ module.exports = class Screenshare {
|
||||
let candidate = kurento.getComplexType('IceCandidate')(_candidate);
|
||||
|
||||
if (this._presenterEndpoint) {
|
||||
console.log(" [screenshare] Adding ICE candidate to presenter");
|
||||
this._presenterEndpoint.addIceCandidate(candidate);
|
||||
}
|
||||
else {
|
||||
@ -107,8 +108,7 @@ module.exports = class Screenshare {
|
||||
|
||||
// ICE NEGOTIATION WITH THE ENDPOINT
|
||||
self._viewersEndpoint[callerName].on('OnIceCandidate', function(event) {
|
||||
let candidate = kurento.getComplexType('IceCandidate')(event.candidate);
|
||||
ws.sendMessage({ id : 'iceCandidate', candidate : candidate });
|
||||
let candidate = kurento.getComplexType('IceCandidate')(event.candidate); ws.sendMessage({ id : 'iceCandidate', candidate : candidate });
|
||||
});
|
||||
|
||||
sdp = h264_sdp.transform(sdp);
|
||||
@ -127,13 +127,13 @@ module.exports = class Screenshare {
|
||||
return _callback(error);
|
||||
}
|
||||
|
||||
self._viewersEndpoint[callerName].on('MediaFlowInStateChange', function(event) {
|
||||
if (event.state === 'NOT_FLOWING') {
|
||||
console.log(" NOT FLOWING ");
|
||||
}
|
||||
else if (event.state === 'FLOWING') {
|
||||
console.log(" FLOWING ");
|
||||
}
|
||||
self._viewersEndpoint[callerName].on('MediaFlowInStateChange', function(event) {
|
||||
if (event.state === 'NOT_FLOWING') {
|
||||
console.log(" NOT FLOWING ");
|
||||
}
|
||||
else if (event.state === 'FLOWING') {
|
||||
console.log(" FLOWING ");
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
@ -243,8 +243,7 @@ module.exports = class Screenshare {
|
||||
this._presenterEndpoint = null;
|
||||
} else {
|
||||
console.log(" [webRtcEndpoint] PLEASE DONT TRY STOPPING THINGS TWICE");
|
||||
}
|
||||
|
||||
}
|
||||
if (this._ffmpegRtpEndpoint) {
|
||||
MediaController.releaseMediaElement(this._ffmpegRtpEndpoint.id);
|
||||
this._ffmpegRtpEndpoint = null;
|
||||
@ -280,6 +279,7 @@ module.exports = class Screenshare {
|
||||
}
|
||||
|
||||
_onRtpMediaFlowing(meetingId, rtpParams) {
|
||||
console.log(" [screenshare] Media FLOWING for meeting => " + meetingId);
|
||||
let self = this;
|
||||
let strm = Messaging.generateStartTranscoderRequestMessage(meetingId, meetingId, rtpParams);
|
||||
|
||||
@ -302,7 +302,8 @@ module.exports = class Screenshare {
|
||||
};
|
||||
|
||||
_stopRtmpBroadcast (meetingId) {
|
||||
var self = this;
|
||||
console.log(" [screenshare] _stopRtmpBroadcast for meeting => " + meetingId);
|
||||
let self = this;
|
||||
if(self._meetingId === meetingId) {
|
||||
// TODO correctly assemble this timestamp
|
||||
let timestamp = now.format('hhmmss');
|
||||
@ -313,6 +314,7 @@ module.exports = class Screenshare {
|
||||
}
|
||||
|
||||
_startRtmpBroadcast (meetingId, output) {
|
||||
console.log(" [screenshare] _startRtmpBroadcast for meeting => " + meetingId);
|
||||
var self = this;
|
||||
if(self._meetingId === meetingId) {
|
||||
// TODO correctly assemble this timestamp
|
||||
@ -329,5 +331,17 @@ module.exports = class Screenshare {
|
||||
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