Implements recording through a jirecon instance.
This commit is contained in:
parent
fdcae01d21
commit
87f8b91a96
|
@ -4,6 +4,7 @@ var config = {
|
||||||
//anonymousdomain: 'guest.example.com',
|
//anonymousdomain: 'guest.example.com',
|
||||||
muc: 'conference.jitsi-meet.example.com', // FIXME: use XEP-0030
|
muc: 'conference.jitsi-meet.example.com', // FIXME: use XEP-0030
|
||||||
bridge: 'jitsi-videobridge.jitsi-meet.example.com', // FIXME: use XEP-0030
|
bridge: 'jitsi-videobridge.jitsi-meet.example.com', // FIXME: use XEP-0030
|
||||||
|
//jirecon: 'jirecon.jitsi-meet.example.com',
|
||||||
//call_control: 'callcontrol.jitsi-meet.example.com',
|
//call_control: 'callcontrol.jitsi-meet.example.com',
|
||||||
//focus: 'focus.jitsi-meet.example.com' - defaults to 'focus.jitsi-meet.example.com'
|
//focus: 'focus.jitsi-meet.example.com' - defaults to 'focus.jitsi-meet.example.com'
|
||||||
},
|
},
|
||||||
|
|
5
muc.js
5
muc.js
|
@ -83,8 +83,9 @@ Strophe.addConnectionPlugin('emuc', {
|
||||||
},
|
},
|
||||||
onPresence: function (pres) {
|
onPresence: function (pres) {
|
||||||
var from = pres.getAttribute('from');
|
var from = pres.getAttribute('from');
|
||||||
var type = pres.getAttribute('type');
|
|
||||||
if (type != null) {
|
// What is this for? A workaround for something?
|
||||||
|
if (pres.getAttribute('type')) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
71
recording.js
71
recording.js
|
@ -4,21 +4,76 @@ var Recording = (function (my) {
|
||||||
var recordingToken = null;
|
var recordingToken = null;
|
||||||
var recordingEnabled;
|
var recordingEnabled;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether to use a jirecon component for recording, or use the videobridge
|
||||||
|
* through COLIBRI.
|
||||||
|
*/
|
||||||
|
var useJirecon = (typeof config.hosts.jirecon != "undefined");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The ID of the jirecon recording session. Jirecon generates it when we
|
||||||
|
* initially start recording, and it needs to be used in subsequent requests
|
||||||
|
* to jirecon.
|
||||||
|
*/
|
||||||
|
var jireconRid = null;
|
||||||
|
|
||||||
my.setRecordingToken = function (token) {
|
my.setRecordingToken = function (token) {
|
||||||
recordingToken = token;
|
recordingToken = token;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
my.setRecording = function (state, token, callback) {
|
||||||
|
if (useJirecon){
|
||||||
|
this.setRecordingJirecon(state, token, callback);
|
||||||
|
} else {
|
||||||
|
this.setRecordingColibri(state, token, callback);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
my.setRecordingJirecon = function (state, token, callback) {
|
||||||
|
if (state == recordingEnabled){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var iq = $iq({to: config.hosts.jirecon, type: 'set'})
|
||||||
|
.c('recording', {xmlns: 'http://jitsi.org/protocol/jirecon',
|
||||||
|
action: state ? 'start' : 'stop',
|
||||||
|
mucjid: connection.emuc.roomjid});
|
||||||
|
if (!state){
|
||||||
|
iq.attrs({rid: jireconRid});
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('Start recording');
|
||||||
|
|
||||||
|
connection.sendIQ(
|
||||||
|
iq,
|
||||||
|
function (result) {
|
||||||
|
// TODO wait for an IQ with the real status, since this is
|
||||||
|
// provisional?
|
||||||
|
jireconRid = $(result).find('recording').attr('rid');
|
||||||
|
console.log('Recording ' + (state ? 'started' : 'stopped') +
|
||||||
|
'(jirecon)' + result);
|
||||||
|
recordingEnabled = state;
|
||||||
|
if (!state){
|
||||||
|
jireconRid = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
callback(state);
|
||||||
|
},
|
||||||
|
function (error) {
|
||||||
|
console.log('Failed to start recording, error: ', error);
|
||||||
|
callback(recordingEnabled);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
// Sends a COLIBRI message which enables or disables (according to 'state')
|
// Sends a COLIBRI message which enables or disables (according to 'state')
|
||||||
// the recording on the bridge. Waits for the result IQ and calls 'callback'
|
// the recording on the bridge. Waits for the result IQ and calls 'callback'
|
||||||
// with the new recording state, according to the IQ.
|
// with the new recording state, according to the IQ.
|
||||||
my.setRecording = function (state, token, callback) {
|
my.setRecordingColibri = function (state, token, callback) {
|
||||||
var self = this;
|
|
||||||
var elem = $iq({to: focusMucJid, type: 'set'});
|
var elem = $iq({to: focusMucJid, type: 'set'});
|
||||||
elem.c('conference', {
|
elem.c('conference', {
|
||||||
xmlns: 'http://jitsi.org/protocol/colibri'
|
xmlns: 'http://jitsi.org/protocol/colibri'
|
||||||
});
|
});
|
||||||
elem.c('recording', {state: state, token: token});
|
elem.c('recording', {state: state, token: token});
|
||||||
elem.up();
|
|
||||||
|
|
||||||
connection.sendIQ(elem,
|
connection.sendIQ(elem,
|
||||||
function (result) {
|
function (result) {
|
||||||
|
@ -31,6 +86,7 @@ var Recording = (function (my) {
|
||||||
},
|
},
|
||||||
function (error) {
|
function (error) {
|
||||||
console.warn(error);
|
console.warn(error);
|
||||||
|
callback(recordingEnabled);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -43,11 +99,13 @@ var Recording = (function (my) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!recordingToken)
|
// Jirecon does not (currently) support a token.
|
||||||
|
if (!recordingToken && !useJirecon)
|
||||||
{
|
{
|
||||||
messageHandler.openTwoButtonDialog(null,
|
messageHandler.openTwoButtonDialog(null,
|
||||||
'<h2>Enter recording token</h2>' +
|
'<h2>Enter recording token</h2>' +
|
||||||
'<input id="recordingToken" type="text" placeholder="token" autofocus>',
|
'<input id="recordingToken" type="text" ' +
|
||||||
|
'placeholder="token" autofocus>',
|
||||||
false,
|
false,
|
||||||
"Save",
|
"Save",
|
||||||
function (e, v, m, f) {
|
function (e, v, m, f) {
|
||||||
|
@ -63,7 +121,8 @@ var Recording = (function (my) {
|
||||||
},
|
},
|
||||||
function (event) {
|
function (event) {
|
||||||
document.getElementById('recordingToken').focus();
|
document.getElementById('recordingToken').focus();
|
||||||
}
|
},
|
||||||
|
function () {}
|
||||||
);
|
);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in New Issue