From e52c6cc2a33eca7e7e4fbcef5d8a0b0533806649 Mon Sep 17 00:00:00 2001 From: hristoterezov Date: Thu, 10 Dec 2015 17:09:34 +1100 Subject: [PATCH] Adds recording support --- JitsiConference.js | 25 ++++++++++++++----------- lib-jitsi-meet.js | 25 ++++++++++++++----------- modules/xmpp/recording.js | 33 ++++++++++++++++++++++++++++++++- 3 files changed, 60 insertions(+), 23 deletions(-) diff --git a/JitsiConference.js b/JitsiConference.js index a55a4c630..e30c13de3 100644 --- a/JitsiConference.js +++ b/JitsiConference.js @@ -419,9 +419,9 @@ JitsiConference.prototype.sendTones = function (tones, duration, pause) { * Returns true if the recording is supproted and false if not. */ JitsiConference.prototype.isRecordingSupported = function () { - // if(this.room) - // return this.room.isRecordingSupported(); - // return false; + if(this.room) + return this.room.isRecordingSupported(); + return false; }; /** @@ -429,18 +429,18 @@ JitsiConference.prototype.isRecordingSupported = function () { * and "off" if the recording is not started. */ JitsiConference.prototype.getRecordingState = function () { - // if(this.room) - // return this.room.getRecordingState(); - // return "off"; + if(this.room) + return this.room.getRecordingState(); + return "off"; } /** * Returns the url of the recorded video. */ JitsiConference.prototype.getRecordingURL = function () { - // if(this.room) - // return this.room.getRecordingURL(); - // return null; + if(this.room) + return this.room.getRecordingURL(); + return null; } /** @@ -448,8 +448,8 @@ JitsiConference.prototype.getRecordingURL = function () { * @param token a token for authentication. */ JitsiConference.prototype.toggleRecording = function (token) { - // if(this.room) - // this.room.toggleRecording(token); + if(this.room) + this.room.toggleRecording(token); } /** @@ -493,6 +493,9 @@ function setupListeners(conference) { conference.room.addListener(XMPPEvents.CONNECTION_INTERRUPTED, function () { conference.eventEmitter.emit(JitsiConferenceEvents.CONNECTION_INTERRUPTED); }); + conference.room.addListener(XMPPEvents.RECORDING_STATE_CHANGED, function () { + conference.eventEmitter.emit(JitsiConferenceEvents.RECORDING_STATE_CHANGED); + }); conference.room.addListener(XMPPEvents.CONNECTION_RESTORED, function () { conference.eventEmitter.emit(JitsiConferenceEvents.CONNECTION_RESTORED); diff --git a/lib-jitsi-meet.js b/lib-jitsi-meet.js index f24b7665b..61f512a7e 100644 --- a/lib-jitsi-meet.js +++ b/lib-jitsi-meet.js @@ -421,9 +421,9 @@ JitsiConference.prototype.sendTones = function (tones, duration, pause) { * Returns true if the recording is supproted and false if not. */ JitsiConference.prototype.isRecordingSupported = function () { - // if(this.room) - // return this.room.isRecordingSupported(); - // return false; + if(this.room) + return this.room.isRecordingSupported(); + return false; }; /** @@ -431,18 +431,18 @@ JitsiConference.prototype.isRecordingSupported = function () { * and "off" if the recording is not started. */ JitsiConference.prototype.getRecordingState = function () { - // if(this.room) - // return this.room.getRecordingState(); - // return "off"; + if(this.room) + return this.room.getRecordingState(); + return "off"; } /** * Returns the url of the recorded video. */ JitsiConference.prototype.getRecordingURL = function () { - // if(this.room) - // return this.room.getRecordingURL(); - // return null; + if(this.room) + return this.room.getRecordingURL(); + return null; } /** @@ -450,8 +450,8 @@ JitsiConference.prototype.getRecordingURL = function () { * @param token a token for authentication. */ JitsiConference.prototype.toggleRecording = function (token) { - // if(this.room) - // this.room.toggleRecording(token); + if(this.room) + this.room.toggleRecording(token); } /** @@ -495,6 +495,9 @@ function setupListeners(conference) { conference.room.addListener(XMPPEvents.CONNECTION_INTERRUPTED, function () { conference.eventEmitter.emit(JitsiConferenceEvents.CONNECTION_INTERRUPTED); }); + conference.room.addListener(XMPPEvents.RECORDING_STATE_CHANGED, function () { + conference.eventEmitter.emit(JitsiConferenceEvents.RECORDING_STATE_CHANGED); + }); conference.room.addListener(XMPPEvents.CONNECTION_RESTORED, function () { conference.eventEmitter.emit(JitsiConferenceEvents.CONNECTION_RESTORED); diff --git a/modules/xmpp/recording.js b/modules/xmpp/recording.js index cd927265a..4f7edb2b0 100644 --- a/modules/xmpp/recording.js +++ b/modules/xmpp/recording.js @@ -9,10 +9,19 @@ function Recording(ee, connection, focusMucJid) { this.state = "off"; this.focusMucJid = focusMucJid; this.url = null; - this.isRecordingSupported = false; + this.isSupported = false; } Recording.prototype.handleJibriPresence = function (jibri) { + var attributes = jibri.attributes; + if(!attributes) + return; + + this.isSupported = (attributes.status && attributes.status !== "undefined"); + if(this.isSupported) { + this.url = attributes.url || null; + this.state = attributes.status || "off"; + } this.eventEmitter.emit(XMPPEvents.RECORDING_STATE_CHANGED); }; @@ -67,4 +76,26 @@ Recording.prototype.toggleRecording = function (token) { ); }; +/** + * Returns true if the recording is supproted and false if not. + */ +Recording.prototype.isSupported = function () { + return this.isSupported; +}; + +/** + * Returns null if the recording is not supported, "on" if the recording started + * and "off" if the recording is not started. + */ +Recording.prototype.getState = function () { + return this.state; +} + +/** + * Returns the url of the recorded video. + */ +Recording.prototype.getURL = function () { + return this.url; +} + module.exports = Recording;