From c2143f9a5088fdfc5b7398f2312d5c4017831b38 Mon Sep 17 00:00:00 2001 From: prlanzarin <prlanzarin@inf.ufrgs.br> Date: Sun, 29 Apr 2018 00:18:54 +0000 Subject: [PATCH] Added first working versions of join/exitAudio for kurento bridge and fixed SFU session termination for freeswitch adapter --- .../api/audio/client/bridge/kurento.js | 49 ++++++++++++------- .../lib/adapters/freeswitch/freeswitch.js | 10 ++-- 2 files changed, 37 insertions(+), 22 deletions(-) diff --git a/bigbluebutton-html5/imports/api/audio/client/bridge/kurento.js b/bigbluebutton-html5/imports/api/audio/client/bridge/kurento.js index fadce7246c..bb8e613ad5 100644 --- a/bigbluebutton-html5/imports/api/audio/client/bridge/kurento.js +++ b/bigbluebutton-html5/imports/api/audio/client/bridge/kurento.js @@ -1,5 +1,8 @@ import BaseAudioBridge from './base'; +const MEDIA = Meteor.settings.public.media; +const MEDIA_TAG = MEDIA.mediaTag; + export default class KurentoAudioBridge extends BaseAudioBridge { constructor(userData) { super(); @@ -20,22 +23,34 @@ export default class KurentoAudioBridge extends BaseAudioBridge { window.kurentoExitAudio(); } - joinAudio({ isListenOnly }) { - if (!isListenOnly) { - return; - } - - window.kurentoJoinAudio( - 'remote-media', - this.voiceBridge, - "GLOBAL_AUDIO_" + this.voiceBridge, - this.internalMeetingID, - null, - null, - null, - this.userId, - this.userName, - null, - ); + joinAudio({ isListenOnly }, callback) { + return new Promise((resolve, reject) => { + this.callback = callback; + if (!isListenOnly) { + return resolve(); + } + + window.kurentoJoinAudio( + "remote-media", + this.voiceBridge, + "GLOBAL_AUDIO_" + this.voiceBridge, + this.internalMeetingID, + null, + null, + null, + this.userId, + this.userName, + null, + ); + + resolve (this.callback({ status: this.baseCallStates.started })); + }); + } + + exitAudio() { + return new Promise((resolve, reject) => { + window.kurentoExitAudio(); + return resolve (this.callback({status: this.baseCallStates.ended})); + }); } } diff --git a/labs/bbb-webrtc-sfu/lib/mcs-core/lib/adapters/freeswitch/freeswitch.js b/labs/bbb-webrtc-sfu/lib/mcs-core/lib/adapters/freeswitch/freeswitch.js index f3a9e0b0fa..74c59070fa 100644 --- a/labs/bbb-webrtc-sfu/lib/mcs-core/lib/adapters/freeswitch/freeswitch.js +++ b/labs/bbb-webrtc-sfu/lib/mcs-core/lib/adapters/freeswitch/freeswitch.js @@ -48,7 +48,7 @@ module.exports = class Freeswitch extends EventEmitter { try { let userAgent = await this._createUserAgent(type, params.name, roomId); this._userAgents[roomId] = userAgent; - return Promise.resolve(roomId); + return Promise.resolve(roomId); } catch (err) { return Promise.reject(err); @@ -62,7 +62,7 @@ module.exports = class Freeswitch extends EventEmitter { if (source) { return new Promise((resolve, reject) => { switch (type) { - case 'ALL': + case 'ALL': case 'AUDIO': @@ -80,7 +80,7 @@ module.exports = class Freeswitch extends EventEmitter { } } - stop (roomId, elementId) { + stop (roomId, type = {}, elementId) { Logger.info("[mcs-media-freeswitch] Releasing endpoint", elementId, "from room", roomId); let userAgent = this._userAgents[elementId]; let rtpConverter = this._rtpConverters[elementId]; @@ -88,7 +88,7 @@ module.exports = class Freeswitch extends EventEmitter { if (userAgent) { Logger.info("[mcs-media-freeswitch] Stopping user agent", elementId); userAgent.stop(); - delete this._userAgents[elementId]; + delete this._userAgents[elementId]; } if (rtpConverter) { @@ -200,7 +200,7 @@ module.exports = class Freeswitch extends EventEmitter { connector: this.sipjsLogConnector }, traceSip: true, - hackIpInContact: LOCAL_IP_ADDRESS + hackIpInContact: LOCAL_IP_ADDRESS }); Logger.info("[mcs-freeswitch-adapter] Created new user agent for endpoint " + displayName); -- GitLab