Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

Basic recording.

paweldomas6afcfb259803
diff --git a/app.js b/app.js
index 05ff6372a6..970f96fcee 100644
--- a/app.js
+++ b/app.js
@@ -6,7 +6,7 @@ var activecall = null;
var RTC = null;
var nickname = null;
var sharedKey = '';
-var recordingToken ='';
+var focusJid = null;
var roomUrl = null;
var roomName = null;
var ssrc2jid = {};
@@ -676,6 +676,16 @@ $(document).bind('joined.muc', function (event, jid, info) {
document.createTextNode(Strophe.getResourceFromJid(jid) + ' (me)')
);
+ if (connection.emuc.isModerator())
+ {
+ Toolbar.showSipCallButton(true);
+ Toolbar.showRecordingButton(true);
+ }
+ else
+ {
+ Toolbar.showSipCallButton(false);
+ Toolbar.showRecordingButton(false);
+ }
/* if (Object.keys(connection.emuc.members).length < 1) {
focus = new ColibriFocus(connection, config.hosts.bridge);
if (nickname !== null) {
@@ -737,7 +747,8 @@ $(document).bind('entered.muc', function (event, jid, info, pres) {
if (Strophe.getResourceFromJid(jid).indexOf('focus') != -1)
{
- console.info("Ignore focus");
+ focusJid = jid;
+ console.info("Ignore focus " + jid);
return;
}
@@ -1036,51 +1047,7 @@ function isAudioMuted()
// Starts or stops the recording for the conference.
function toggleRecording() {
- if (focus === null || focus.confid === null) {
- console.log('non-focus, or conference not yet organized: not enabling recording');
- return;
- }
-
- if (!recordingToken)
- {
- messageHandler.openTwoButtonDialog(null,
- '<h2>Enter recording token</h2>' +
- '<input id="recordingToken" type="text" placeholder="token" autofocus>',
- false,
- "Save",
- function (e, v, m, f) {
- if (v) {
- var token = document.getElementById('recordingToken');
-
- if (token.value) {
- setRecordingToken(Util.escapeHtml(token.value));
- toggleRecording();
- }
- }
- },
- function (event) {
- document.getElementById('recordingToken').focus();
- }
- );
-
- return;
- }
-
- var oldState = focus.recordingEnabled;
- Toolbar.toggleRecordingButtonState();
- focus.setRecording(!oldState,
- recordingToken,
- function (state) {
- console.log("New recording state: ", state);
- if (state == oldState) //failed to change, reset the token because it might have been wrong
- {
- Toolbar.toggleRecordingButtonState();
- setRecordingToken(null);
- }
- }
- );
-
-
+ Recording.toggleRecording();
}
/**
@@ -1472,10 +1439,6 @@ function setSharedKey(sKey) {
sharedKey = sKey;
}
-function setRecordingToken(token) {
- recordingToken = token;
-}
-
/**
* Updates the room invite url.
*/
diff --git a/config.js b/config.js
index 009412d0a0..c7abd9350d 100644
--- a/config.js
+++ b/config.js
@@ -25,7 +25,7 @@ var config = {
adaptiveSimulcast: false,
useRtcpMux: true,
useBundle: true,
- enableRecording: false,
- enableWelcomePage: true,
+ enableRecording: true,
+ enableWelcomePage: false,
enableSimulcast: false
};
diff --git a/index.html b/index.html
index 1a6d99f791..67ce730502 100644
--- a/index.html
+++ b/index.html
@@ -57,6 +57,7 @@
<script src="bottom_toolbar.js?v=5"></script><!-- media stream -->
<script src="roomname_generator.js?v=1"></script><!-- generator for random room names -->
<script src="keyboard_shortcut.js?v=3"></script>
+ <script src="recording.js?v=1"></script>
<script src="tracking.js?v=1"></script><!-- tracking -->
<script src="jitsipopover.js?v=3"></script>
<script src="message_handler.js?v=2"></script>
diff --git a/muc.js b/muc.js
index 9ce52cff96..c99731751d 100644
--- a/muc.js
+++ b/muc.js
@@ -12,6 +12,7 @@ Strophe.addConnectionPlugin('emuc', {
preziMap: {},
joined: false,
isOwner: false,
+ role: null,
init: function (conn) {
this.connection = conn;
},
@@ -127,6 +128,10 @@ Strophe.addConnectionPlugin('emuc', {
if (from == this.myroomjid) {
if (member.affiliation == 'owner') this.isOwner = true;
+ if (this.role !== member.role) {
+ this.role = member.role;
+ console.info("My role: " + this.role);
+ }
if (!this.joined) {
this.joined = true;
$(document).trigger('joined.muc', [from, member]);
@@ -456,5 +461,8 @@ Strophe.addConnectionPlugin('emuc', {
},
addBridgeIsDownToPresence: function() {
this.presMap['bridgeIsDown'] = true;
+ },
+ isModerator: function() {
+ return this.role === 'moderator';
}
});
diff --git a/recording.js b/recording.js
new file mode 100644
index 0000000000..92c3f07714
--- /dev/null
+++ b/recording.js
@@ -0,0 +1,90 @@
+/* global $, $iq, config, connection, focusJid, messageHandler, Toolbar, Util */
+var Recording = (function (my) {
+ var status = false;
+ var recordingToken = null;
+ var recordingEnabled = false;
+
+ my.setRecordingToken = function (token) {
+ recordingToken = token;
+ };
+
+ // Sends a COLIBRI message which enables or disables (according to 'state')
+ // the recording on the bridge. Waits for the result IQ and calls 'callback'
+ // with the new recording state, according to the IQ.
+ my.setRecording = function (state, token, callback) {
+ var self = this;
+ var elem = $iq({to: focusJid, type: 'set'});
+ elem.c('conference', {
+ xmlns: 'http://jitsi.org/protocol/colibri'
+ });
+ elem.c('recording', {state: state, token: token});
+ elem.up();
+
+ connection.sendIQ(elem,
+ function (result) {
+ console.log('Set recording "', state, '". Result:', result);
+ var recordingElem = $(result).find('>conference>recording');
+ var newState = ('true' === recordingElem.attr('state'));
+
+ recordingEnabled = newState;
+ callback(newState);
+ },
+ function (error) {
+ console.warn(error);
+ }
+ );
+ };
+
+ my.toggleRecording = function () {
+ if (!connection.emuc.isModerator()) {
+ console.log(
+ 'non-focus, or conference not yet organized:' +
+ ' not enabling recording');
+ return;
+ }
+
+ if (!recordingToken)
+ {
+ messageHandler.openTwoButtonDialog(null,
+ '<h2>Enter recording token</h2>' +
+ '<input id="recordingToken" type="text" placeholder="token" autofocus>',
+ false,
+ "Save",
+ function (e, v, m, f) {
+ if (v) {
+ var token = document.getElementById('recordingToken');
+
+ if (token.value) {
+ my.setRecordingToken(
+ Util.escapeHtml(token.value));
+ my.toggleRecording();
+ }
+ }
+ },
+ function (event) {
+ document.getElementById('recordingToken').focus();
+ }
+ );
+
+ return;
+ }
+
+ var oldState = recordingEnabled;
+ Toolbar.toggleRecordingButtonState();
+ my.setRecording(!oldState,
+ recordingToken,
+ function (state) {
+ console.log("New recording state: ", state);
+ if (state == oldState)
+ {
+ // Failed to change, reset the token because it might
+ // have been wrong
+ Toolbar.toggleRecordingButtonState();
+ my.setRecordingToken(null);
+ }
+ }
+ );
+ };
+
+ return my;
+}(Recording || {}));