|
|
@@ -19,6 +19,12 @@ var useJirecon = (typeof config.hosts.jirecon != "undefined");
|
|
19
|
19
|
*/
|
|
20
|
20
|
var jireconRid = null;
|
|
21
|
21
|
|
|
|
22
|
+/**
|
|
|
23
|
+ * The callback to update the recording button. Currently used from colibri
|
|
|
24
|
+ * after receiving a pending status.
|
|
|
25
|
+ */
|
|
|
26
|
+var recordingStateChangeCallback = null;
|
|
|
27
|
+
|
|
22
|
28
|
function setRecordingToken(token) {
|
|
23
|
29
|
recordingToken = token;
|
|
24
|
30
|
}
|
|
|
@@ -30,9 +36,9 @@ function setRecordingJirecon(state, token, callback, connection) {
|
|
30
|
36
|
|
|
31
|
37
|
var iq = $iq({to: config.hosts.jirecon, type: 'set'})
|
|
32
|
38
|
.c('recording', {xmlns: 'http://jitsi.org/protocol/jirecon',
|
|
33
|
|
- action: state ? 'start' : 'stop',
|
|
|
39
|
+ action: (state === 'on') ? 'start' : 'stop',
|
|
34
|
40
|
mucjid: connection.emuc.roomjid});
|
|
35
|
|
- if (!state){
|
|
|
41
|
+ if (state === 'off'){
|
|
36
|
42
|
iq.attrs({rid: jireconRid});
|
|
37
|
43
|
}
|
|
38
|
44
|
|
|
|
@@ -44,10 +50,10 @@ function setRecordingJirecon(state, token, callback, connection) {
|
|
44
|
50
|
// TODO wait for an IQ with the real status, since this is
|
|
45
|
51
|
// provisional?
|
|
46
|
52
|
jireconRid = $(result).find('recording').attr('rid');
|
|
47
|
|
- console.log('Recording ' + (state ? 'started' : 'stopped') +
|
|
|
53
|
+ console.log('Recording ' + ((state === 'on') ? 'started' : 'stopped') +
|
|
48
|
54
|
'(jirecon)' + result);
|
|
49
|
55
|
recordingEnabled = state;
|
|
50
|
|
- if (!state){
|
|
|
56
|
+ if (state === 'off'){
|
|
51
|
57
|
jireconRid = null;
|
|
52
|
58
|
}
|
|
53
|
59
|
|
|
|
@@ -73,10 +79,19 @@ function setRecordingColibri(state, token, callback, connection) {
|
|
73
|
79
|
function (result) {
|
|
74
|
80
|
console.log('Set recording "', state, '". Result:', result);
|
|
75
|
81
|
var recordingElem = $(result).find('>conference>recording');
|
|
76
|
|
- var newState = ('true' === recordingElem.attr('state'));
|
|
|
82
|
+ var newState = recordingElem.attr('state');
|
|
77
|
83
|
|
|
78
|
84
|
recordingEnabled = newState;
|
|
79
|
85
|
callback(newState);
|
|
|
86
|
+
|
|
|
87
|
+ if (newState === 'pending' && recordingStateChangeCallback == null) {
|
|
|
88
|
+ recordingStateChangeCallback = callback;
|
|
|
89
|
+ connection.addHandler(function(iq){
|
|
|
90
|
+ var state = $(iq).find('recording').attr('state');
|
|
|
91
|
+ if (state)
|
|
|
92
|
+ recordingStateChangeCallback(state);
|
|
|
93
|
+ }, 'http://jitsi.org/protocol/colibri', 'iq', null, null, null);
|
|
|
94
|
+ }
|
|
80
|
95
|
},
|
|
81
|
96
|
function (error) {
|
|
82
|
97
|
console.warn(error);
|
|
|
@@ -94,8 +109,7 @@ function setRecording(state, token, callback, connection) {
|
|
94
|
109
|
}
|
|
95
|
110
|
|
|
96
|
111
|
var Recording = {
|
|
97
|
|
- toggleRecording: function (tokenEmptyCallback,
|
|
98
|
|
- startingCallback, startedCallback, connection) {
|
|
|
112
|
+ toggleRecording: function (tokenEmptyCallback, recordingStateChangeCallback, connection) {
|
|
99
|
113
|
if (!Moderator.isModerator()) {
|
|
100
|
114
|
console.log(
|
|
101
|
115
|
'non-focus, or conference not yet organized:' +
|
|
|
@@ -108,16 +122,16 @@ var Recording = {
|
|
108
|
122
|
if (!recordingToken && !useJirecon) {
|
|
109
|
123
|
tokenEmptyCallback(function (value) {
|
|
110
|
124
|
setRecordingToken(value);
|
|
111
|
|
- self.toggleRecording(tokenEmptyCallback,
|
|
112
|
|
- startingCallback, startedCallback, connection);
|
|
|
125
|
+ self.toggleRecording(tokenEmptyCallback, recordingStateChangeCallback, connection);
|
|
113
|
126
|
});
|
|
114
|
127
|
|
|
115
|
128
|
return;
|
|
116
|
129
|
}
|
|
117
|
130
|
|
|
118
|
131
|
var oldState = recordingEnabled;
|
|
119
|
|
- startingCallback(!oldState);
|
|
120
|
|
- setRecording(!oldState,
|
|
|
132
|
+ var newState = (oldState === 'off' || !oldState) ? 'on' : 'off';
|
|
|
133
|
+
|
|
|
134
|
+ setRecording(newState,
|
|
121
|
135
|
recordingToken,
|
|
122
|
136
|
function (state) {
|
|
123
|
137
|
console.log("New recording state: ", state);
|
|
|
@@ -143,7 +157,7 @@ var Recording = {
|
|
143
|
157
|
// have been wrong
|
|
144
|
158
|
setRecordingToken(null);
|
|
145
|
159
|
}
|
|
146
|
|
- startedCallback(state);
|
|
|
160
|
+ recordingStateChangeCallback(state);
|
|
147
|
161
|
|
|
148
|
162
|
},
|
|
149
|
163
|
connection
|