Changed kurento-screenshare session index to voiceBridge
This commit is contained in:
parent
54faf33001
commit
ade78eaff0
@ -19,7 +19,9 @@ Kurento = function (
|
||||
this.extensionInstalled = false;
|
||||
this.screenConstraints = {};
|
||||
this.mediaCallback = null;
|
||||
voiceBridge += "-DESKSHARE";
|
||||
|
||||
this.voiceBridge = voiceBridge;
|
||||
this.internalMeetingId = internalMeetingId;
|
||||
|
||||
this.vid_width = window.screen.width;
|
||||
this.vid_height = window.screen.height;
|
||||
@ -29,7 +31,6 @@ Kurento = function (
|
||||
|
||||
this.renderTag = 'remote-media';
|
||||
|
||||
this.destination_number = internalMeetingId;
|
||||
this.caller_id_name = conferenceUsername;
|
||||
this.caller_id_number = conferenceUsername;
|
||||
this.pingInterval;
|
||||
@ -200,9 +201,10 @@ Kurento.prototype.onOfferPresenter = function (error, offerSdp) {
|
||||
|
||||
var message = {
|
||||
id : 'presenter',
|
||||
presenterId : kurentoHandler.sessid,
|
||||
type: 'screenshare',
|
||||
internalMeetingId: kurentoHandler.internalMeetingId,
|
||||
voiceBridge: kurentoHandler.voiceBridge,
|
||||
callerName : kurentoHandler.caller_id_name,
|
||||
voiceBridge : kurentoHandler.destination_number,
|
||||
sdpOffer : offerSdp,
|
||||
vh: kurentoHandler.vid_height,
|
||||
vw: kurentoHandler.vid_width
|
||||
@ -253,7 +255,8 @@ Kurento.prototype.onIceCandidate = function(candidate) {
|
||||
|
||||
var message = {
|
||||
id : 'onIceCandidate',
|
||||
presenterId : kurentoHandler.sessid,
|
||||
type: 'screenshare',
|
||||
voiceBridge: kurentoHandler.voiceBridge,
|
||||
candidate : candidate
|
||||
}
|
||||
console.log("this object " + JSON.stringify(this, null, 2));
|
||||
@ -294,9 +297,10 @@ Kurento.prototype.onOfferViewer = function (error, offerSdp) {
|
||||
}
|
||||
var message = {
|
||||
id : 'viewer',
|
||||
presenterId : kurentoHandler.sessid,
|
||||
type: 'screenshare',
|
||||
internalMeetingId: kurentoHandler.internalMeetingId,
|
||||
voiceBridge: kurentoHandler.voiceBridge,
|
||||
callerName : kurentoHandler.caller_id_name,
|
||||
voiceBridge : kurentoHandler.destination_number,
|
||||
sdpOffer : offerSdp
|
||||
};
|
||||
|
||||
@ -307,9 +311,10 @@ Kurento.prototype.onOfferViewer = function (error, offerSdp) {
|
||||
Kurento.prototype.ping = function() {
|
||||
var message = {
|
||||
id : 'ping',
|
||||
presenterId : kurentoHandler.sessid,
|
||||
type: 'screenshare',
|
||||
internalMeetingId: kurentoHandler.internalMeetingId,
|
||||
voiceBridge: kurentoHandler.voiceBridge,
|
||||
callerName : kurentoHandler.caller_id_name,
|
||||
voiceBridge : kurentoHandler.destination_number,
|
||||
};
|
||||
|
||||
kurentoHandler.sendMessage(message);
|
||||
@ -319,7 +324,8 @@ Kurento.prototype.stop = function() {
|
||||
if (this.webRtcPeer) {
|
||||
var message = {
|
||||
id : 'stop',
|
||||
presenterId : kurentoHandler.sessId,
|
||||
type : 'screenshare',
|
||||
voiceBridge: kurentoHandler.voiceBridge
|
||||
}
|
||||
kurentoHandler.sendMessage(message);
|
||||
kurentoHandler.disposeScreenShare();
|
||||
|
@ -25,7 +25,7 @@ module.exports = class ConnectionManager {
|
||||
this._logger = logger;
|
||||
this._clientId = 0;
|
||||
this._app = express();
|
||||
this._sessions = {};
|
||||
this._screenshareSessions = {};
|
||||
|
||||
this._setupExpressSession();
|
||||
this._setupHttpServer();
|
||||
@ -76,54 +76,59 @@ module.exports = class ConnectionManager {
|
||||
|
||||
_onNewConnection(webSocket) {
|
||||
let self = this;
|
||||
let sessionId;
|
||||
let connectionId;
|
||||
let request = webSocket.upgradeReq;
|
||||
let sessionId;
|
||||
let response = {
|
||||
writeHead : {}
|
||||
};
|
||||
|
||||
self._sessionHandler(request, response, function(err) {
|
||||
sessionId = request.session.id + "_" + self.clientId++;
|
||||
if (!self._sessions[sessionId]) {
|
||||
self._sessions[sessionId] = {};
|
||||
}
|
||||
|
||||
console.log('Connection received with sessionId ' + sessionId);
|
||||
this._sessionHandler(request, response, function(err) {
|
||||
connectionId = request.session.id + "_" + self._clientId++;
|
||||
console.log('Connection received with connectionId ' + connectionId);
|
||||
});
|
||||
|
||||
webSocket.on('error', function(error) {
|
||||
console.log('Connection ' + sessionId + ' error');
|
||||
// stop(sessionId);
|
||||
console.log('Connection ' + connectionId + ' error');
|
||||
self._stopSession(sessionId);
|
||||
});
|
||||
|
||||
webSocket.on('close', function() {
|
||||
console.log('Connection ' + sessionId + ' closed');
|
||||
console.log('Connection ' + connectionId + ' closed');
|
||||
self._stopSession(sessionId);
|
||||
});
|
||||
|
||||
webSocket.on('message', function(_message) {
|
||||
let message = JSON.parse(_message);
|
||||
|
||||
let session;
|
||||
// The sessionId is voiceBridge for screensharing sessions
|
||||
sessionId = message.voiceBridge;
|
||||
|
||||
if (message.presenterId && self._sessions[sessionId][message.presenterId]) {
|
||||
session = self._sessions[sessionId][message.presenterId];
|
||||
if(self._screenshareSessions[sessionId]) {
|
||||
session = self._screenshareSessions[sessionId];
|
||||
}
|
||||
|
||||
switch (message.id) {
|
||||
|
||||
case 'presenter':
|
||||
console.log('Presenter message => [' + message.id + '] connection [' + sessionId + '][' + message.presenterId + '][' + message.voiceBridge + '][' + message.callerName + ']');
|
||||
|
||||
session = new Screenshare(webSocket, message.presenterId, self._bbbGW, message.voiceBridge, message.callerName, message.vh, message.vw);
|
||||
// Checking if there's already a Screenshare session started
|
||||
// because we shouldn't overwrite it
|
||||
|
||||
//session.on('message', self._assembleSessionMessage.bind(self));
|
||||
if(session) {
|
||||
break;
|
||||
}
|
||||
|
||||
self._sessions[sessionId][message.presenterId] = session;
|
||||
session = new Screenshare(webSocket, connectionId, self._bbbGW,
|
||||
sessionId, message.callerName, message.vh, message.vw,
|
||||
message.internalMeetingId);
|
||||
|
||||
self._screenshareSessions[sessionId] = {}
|
||||
self._screenshareSessions[sessionId] = session;
|
||||
|
||||
// starts presenter by sending sessionID, websocket and sdpoffer
|
||||
session._startPresenter(sessionId, webSocket, message.sdpOffer, function(error, sdpAnswer) {
|
||||
console.log(" Started presenter " + sessionId);
|
||||
session._startPresenter(connectionId, webSocket, message.sdpOffer, function(error, sdpAnswer) {
|
||||
console.log(" Started presenter " + connectionId);
|
||||
if (error) {
|
||||
return webSocket.send(JSON.stringify({
|
||||
id : 'presenterResponse',
|
||||
@ -142,12 +147,12 @@ module.exports = class ConnectionManager {
|
||||
break;
|
||||
|
||||
case 'viewer':
|
||||
console.log('Viewer message => [' + message.id + '] connection [' + sessionId + '][' + message.presenterId + '][' + message.voiceBridge + '][' + message.callerName + ']');
|
||||
console.log('Viewer message => [' + message.id + '] connection [' + connectionId + '][' + message.presenterId + '][' + message.sessionId + '][' + message.callerName + ']');
|
||||
|
||||
break;
|
||||
case 'stop':
|
||||
|
||||
console.log('[' + message.id + '] connection ' + sessionId);
|
||||
console.log('[' + message.id + '] connection ' + connectionId);
|
||||
|
||||
if (session) {
|
||||
session._stop(sessionId);
|
||||
@ -178,27 +183,25 @@ module.exports = class ConnectionManager {
|
||||
});
|
||||
}
|
||||
|
||||
_stopSession(sessionId) {
|
||||
console.log(' [>] Stopping session ' + sessionId);
|
||||
let sessionIds = Object.keys(this._sessions[sessionId]);
|
||||
_stopSession(sessionId) {
|
||||
console.log(' [>] Stopping session ' + sessionId);
|
||||
let session = this._screenshareSessions[sessionId];
|
||||
|
||||
for (let i = 0; i < sessionIds.length; i++) {
|
||||
let session = this._sessions[sessionId][sessionIds[i]];
|
||||
session._stop();
|
||||
delete this._sessions[sessionId][sessionIds[i]];
|
||||
}
|
||||
|
||||
delete this._sessions[sessionId];
|
||||
if(session._stop === 'function') {
|
||||
session._stop();
|
||||
}
|
||||
|
||||
_stopAll() {
|
||||
console.log('\n [x] Stopping everything! ');
|
||||
let sessionIds = Object.keys(this._sessions);
|
||||
|
||||
for (let i = 0; i < sessionIds.length; i++) {
|
||||
this._stopSession(sessionIds[i]);
|
||||
}
|
||||
|
||||
setTimeout(process.exit, 1000);
|
||||
}
|
||||
delete this._screenshareSessions[sessionId];
|
||||
}
|
||||
|
||||
_stopAll() {
|
||||
console.log('\n [x] Stopping everything! ');
|
||||
let sessionIds = Object.keys(this._screenshareSessions);
|
||||
|
||||
for (let i = 0; i < sessionIds.length; i++) {
|
||||
this._stopSession(sessionIds[i]);
|
||||
}
|
||||
|
||||
setTimeout(process.exit, 1000);
|
||||
}
|
||||
}
|
||||
|
@ -31,13 +31,14 @@ if (config.get('acceptSelfSignedCertificate')) {
|
||||
}
|
||||
|
||||
module.exports = class Screenshare {
|
||||
constructor(ws, id, bbbgw, voiceBridge, caller, vh, vw) {
|
||||
constructor(ws, id, bbbgw, voiceBridge, caller, vh, vw, meetingId) {
|
||||
this._ws = ws;
|
||||
this._id = id;
|
||||
this._BigBlueButtonGW = bbbgw;
|
||||
this._presenterEndpoint = null;
|
||||
this._ffmpegRtpEndpoint = null;
|
||||
this._voiceBridge = voiceBridge;
|
||||
this._meetingId = meetingId;
|
||||
this._caller = caller;
|
||||
this._streamUrl = "";
|
||||
this._vw = vw;
|
||||
@ -128,14 +129,14 @@ module.exports = class Screenshare {
|
||||
console.log(" [rtpendpoint] KMS answer SDP => " + rtpSdpAnswer);
|
||||
let recvVideoPort = rtpSdpAnswer.match(/m=video\s(\d*)/)[1];
|
||||
let rtpParams = MediaHandler.generateTranscoderParams(kurentoIp, localIpAddress,
|
||||
sendVideoPort, recvVideoPort, self._voiceBridge, "stream_type_video", C.RTP_TO_RTMP, "copy", "caller");
|
||||
sendVideoPort, recvVideoPort, self._meetingId, "stream_type_video", C.RTP_TO_RTMP, "copy", "caller");
|
||||
|
||||
self._ffmpegRtpEndpoint.on('MediaFlowInStateChange', function(event) {
|
||||
if (event.state === 'NOT_FLOWING') {
|
||||
self._onRtpMediaNotFlowing();
|
||||
}
|
||||
else if (event.state === 'FLOWING') {
|
||||
self._onRtpMediaFlowing(self._voiceBridge, rtpParams);
|
||||
self._onRtpMediaFlowing(self._meetingId, rtpParams);
|
||||
}
|
||||
});
|
||||
return _callback(null, webRtcSdpAnswer);
|
||||
@ -176,7 +177,7 @@ module.exports = class Screenshare {
|
||||
|
||||
_stopScreensharing() {
|
||||
let self = this;
|
||||
let strm = Messaging.generateStopTranscoderRequestMessage(this._voiceBridge, this._voiceBridge);
|
||||
let strm = Messaging.generateStopTranscoderRequestMessage(this._meetingId, this._meetingId);
|
||||
|
||||
self._BigBlueButtonGW.publish(strm, C.TO_BBB_TRANSCODE_SYSTEM_CHAN, function(error) {});
|
||||
|
||||
@ -194,9 +195,9 @@ module.exports = class Screenshare {
|
||||
|
||||
}
|
||||
|
||||
_onRtpMediaFlowing(voiceBridge, rtpParams) {
|
||||
_onRtpMediaFlowing(meetingId, rtpParams) {
|
||||
let self = this;
|
||||
let strm = Messaging.generateStartTranscoderRequestMessage(voiceBridge, voiceBridge, rtpParams);
|
||||
let strm = Messaging.generateStartTranscoderRequestMessage(meetingId, meetingId, rtpParams);
|
||||
|
||||
// Interoperability: capturing 1.1 start_transcoder_reply messages
|
||||
self._BigBlueButtonGW.once(C.START_TRANSCODER_REPLY, function(payload) {
|
||||
@ -218,7 +219,7 @@ module.exports = class Screenshare {
|
||||
|
||||
_stopRtmpBroadcast (meetingId) {
|
||||
var self = this;
|
||||
if(self._voiceBridge === meetingId) {
|
||||
if(self._meetingId === meetingId) {
|
||||
// TODO correctly assemble this timestamp
|
||||
let timestamp = now.format('hhmmss');
|
||||
let dsrstom = Messaging.generateScreenshareRTMPBroadcastStoppedEvent2x(self._voiceBridge,
|
||||
@ -229,7 +230,7 @@ module.exports = class Screenshare {
|
||||
|
||||
_startRtmpBroadcast (meetingId, output) {
|
||||
var self = this;
|
||||
if(self._voiceBridge === meetingId) {
|
||||
if(self._meetingId === meetingId) {
|
||||
// TODO correctly assemble this timestamp
|
||||
let timestamp = now.format('hhmmss');
|
||||
self._streamUrl = MediaHandler.generateStreamUrl(localIpAddress, meetingId, output);
|
||||
|
Loading…
Reference in New Issue
Block a user