Basic recording.

This commit is contained in:
paweldomas 2014-11-28 16:05:10 +01:00
parent 4efad3d3da
commit 6afcfb2598
5 changed files with 115 additions and 53 deletions

65
app.js
View File

@ -6,7 +6,7 @@ var activecall = null;
var RTC = null; var RTC = null;
var nickname = null; var nickname = null;
var sharedKey = ''; var sharedKey = '';
var recordingToken =''; var focusJid = null;
var roomUrl = null; var roomUrl = null;
var roomName = null; var roomName = null;
var ssrc2jid = {}; var ssrc2jid = {};
@ -676,6 +676,16 @@ $(document).bind('joined.muc', function (event, jid, info) {
document.createTextNode(Strophe.getResourceFromJid(jid) + ' (me)') 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) { /* if (Object.keys(connection.emuc.members).length < 1) {
focus = new ColibriFocus(connection, config.hosts.bridge); focus = new ColibriFocus(connection, config.hosts.bridge);
if (nickname !== null) { if (nickname !== null) {
@ -737,7 +747,8 @@ $(document).bind('entered.muc', function (event, jid, info, pres) {
if (Strophe.getResourceFromJid(jid).indexOf('focus') != -1) if (Strophe.getResourceFromJid(jid).indexOf('focus') != -1)
{ {
console.info("Ignore focus"); focusJid = jid;
console.info("Ignore focus " + jid);
return; return;
} }
@ -1036,51 +1047,7 @@ function isAudioMuted()
// Starts or stops the recording for the conference. // Starts or stops the recording for the conference.
function toggleRecording() { function toggleRecording() {
if (focus === null || focus.confid === null) { Recording.toggleRecording();
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);
}
}
);
} }
/** /**
@ -1472,10 +1439,6 @@ function setSharedKey(sKey) {
sharedKey = sKey; sharedKey = sKey;
} }
function setRecordingToken(token) {
recordingToken = token;
}
/** /**
* Updates the room invite url. * Updates the room invite url.
*/ */

View File

@ -25,7 +25,7 @@ var config = {
adaptiveSimulcast: false, adaptiveSimulcast: false,
useRtcpMux: true, useRtcpMux: true,
useBundle: true, useBundle: true,
enableRecording: false, enableRecording: true,
enableWelcomePage: true, enableWelcomePage: false,
enableSimulcast: false enableSimulcast: false
}; };

View File

@ -57,6 +57,7 @@
<script src="bottom_toolbar.js?v=5"></script><!-- media stream --> <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="roomname_generator.js?v=1"></script><!-- generator for random room names -->
<script src="keyboard_shortcut.js?v=3"></script> <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="tracking.js?v=1"></script><!-- tracking -->
<script src="jitsipopover.js?v=3"></script> <script src="jitsipopover.js?v=3"></script>
<script src="message_handler.js?v=2"></script> <script src="message_handler.js?v=2"></script>

8
muc.js
View File

@ -12,6 +12,7 @@ Strophe.addConnectionPlugin('emuc', {
preziMap: {}, preziMap: {},
joined: false, joined: false,
isOwner: false, isOwner: false,
role: null,
init: function (conn) { init: function (conn) {
this.connection = conn; this.connection = conn;
}, },
@ -127,6 +128,10 @@ Strophe.addConnectionPlugin('emuc', {
if (from == this.myroomjid) { if (from == this.myroomjid) {
if (member.affiliation == 'owner') this.isOwner = true; 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) { if (!this.joined) {
this.joined = true; this.joined = true;
$(document).trigger('joined.muc', [from, member]); $(document).trigger('joined.muc', [from, member]);
@ -456,5 +461,8 @@ Strophe.addConnectionPlugin('emuc', {
}, },
addBridgeIsDownToPresence: function() { addBridgeIsDownToPresence: function() {
this.presMap['bridgeIsDown'] = true; this.presMap['bridgeIsDown'] = true;
},
isModerator: function() {
return this.role === 'moderator';
} }
}); });

90
recording.js Normal file
View File

@ -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 || {}));