|
@@ -573,9 +573,13 @@ JitsiConference.prototype.getRecordingURL = function () {
|
573
|
573
|
*/
|
574
|
574
|
JitsiConference.prototype.toggleRecording = function (options) {
|
575
|
575
|
if(this.room)
|
576
|
|
- return this.room.toggleRecording(options);
|
577
|
|
- return new Promise(function(resolve, reject){
|
578
|
|
- reject(new Error("The conference is not created yet!"))});
|
|
576
|
+ return this.room.toggleRecording(options, function (status, error) {
|
|
577
|
+ this.eventEmitter.emit(
|
|
578
|
+ JitsiConferenceEvents.RECORDING_STATE_CHANGED, status, error);
|
|
579
|
+ }.bind(this));
|
|
580
|
+ this.eventEmitter.emit(
|
|
581
|
+ JitsiConferenceEvents.RECORDING_STATE_CHANGED, "error",
|
|
582
|
+ new Error("The conference is not created yet!"));
|
579
|
583
|
}
|
580
|
584
|
|
581
|
585
|
/**
|
|
@@ -903,7 +907,11 @@ var JitsiConferenceEvents = {
|
903
|
907
|
/**
|
904
|
908
|
* Indicates that phone number changed.
|
905
|
909
|
*/
|
906
|
|
- PHONE_NUMBER_CHANGED: "conference.phoneNumberChanged"
|
|
910
|
+ PHONE_NUMBER_CHANGED: "conference.phoneNumberChanged",
|
|
911
|
+ /**
|
|
912
|
+ * Indicates that recording status changed.
|
|
913
|
+ */
|
|
914
|
+ RECORDING_STATE_CHANGED: "conferenece.recordingStateChanged"
|
907
|
915
|
};
|
908
|
916
|
|
909
|
917
|
module.exports = JitsiConferenceEvents;
|
|
@@ -956,12 +964,15 @@ JitsiConnection.prototype.setToken = function (token) {
|
956
|
964
|
|
957
|
965
|
/**
|
958
|
966
|
* Creates and joins new conference.
|
959
|
|
- * @param name the name of the conference; if null - a generated name will be provided from the api
|
960
|
|
- * @param options Object with properties / settings related to the conference that will be created.
|
|
967
|
+ * @param name the name of the conference; if null - a generated name will be
|
|
968
|
+ * provided from the api
|
|
969
|
+ * @param options Object with properties / settings related to the conference
|
|
970
|
+ * that will be created.
|
961
|
971
|
* @returns {JitsiConference} returns the new conference object.
|
962
|
972
|
*/
|
963
|
973
|
JitsiConnection.prototype.initJitsiConference = function (name, options) {
|
964
|
|
- this.conferences[name] = new JitsiConference({name: name, config: options, connection: this});
|
|
974
|
+ this.conferences[name] = new JitsiConference({name: name, config: options,
|
|
975
|
+ connection: this});
|
965
|
976
|
return this.conferences[name];
|
966
|
977
|
}
|
967
|
978
|
|
|
@@ -6173,15 +6184,16 @@ ChatRoom.prototype.join = function (password) {
|
6173
|
6184
|
var self = this;
|
6174
|
6185
|
this.moderator.allocateConferenceFocus(function()
|
6175
|
6186
|
{
|
6176
|
|
- self.sendPresence();
|
|
6187
|
+ self.sendPresence(true);
|
6177
|
6188
|
}.bind(this));
|
6178
|
6189
|
};
|
6179
|
6190
|
|
6180
|
|
-ChatRoom.prototype.sendPresence = function () {
|
6181
|
|
- if (!this.presMap['to']) {
|
|
6191
|
+ChatRoom.prototype.sendPresence = function (fromJoin) {
|
|
6192
|
+ if (!this.presMap['to'] || (!this.joined && !fromJoin)) {
|
6182
|
6193
|
// Too early to send presence - not initialized
|
6183
|
6194
|
return;
|
6184
|
6195
|
}
|
|
6196
|
+
|
6185
|
6197
|
var pres = $pres({to: this.presMap['to'] });
|
6186
|
6198
|
pres.c('x', {xmlns: this.presMap['xns']});
|
6187
|
6199
|
|
|
@@ -6753,13 +6765,14 @@ ChatRoom.prototype.getRecordingURL = function () {
|
6753
|
6765
|
/**
|
6754
|
6766
|
* Starts/stops the recording
|
6755
|
6767
|
* @param token token for authentication
|
|
6768
|
+ * @param statusChangeHandler {function} receives the new status as argument.
|
6756
|
6769
|
*/
|
6757
|
|
-ChatRoom.prototype.toggleRecording = function (options) {
|
|
6770
|
+ChatRoom.prototype.toggleRecording = function (options, statusChangeHandler) {
|
6758
|
6771
|
if(this.recording)
|
6759
|
|
- return this.recording.toggleRecording(options);
|
|
6772
|
+ return this.recording.toggleRecording(options, statusChangeHandler);
|
6760
|
6773
|
|
6761
|
|
- return new Promise(function(resolve, reject){
|
6762
|
|
- reject(new Error("The conference is not created yet!"))});
|
|
6774
|
+ return statusChangeHandler("error",
|
|
6775
|
+ new Error("The conference is not created yet!"));
|
6763
|
6776
|
}
|
6764
|
6777
|
|
6765
|
6778
|
/**
|
|
@@ -11005,7 +11018,8 @@ function Recording(type, eventEmitter, connection, focusMucJid, jirecon,
|
11005
|
11018
|
this.jirecon = jirecon;
|
11006
|
11019
|
this.url = null;
|
11007
|
11020
|
this.type = type;
|
11008
|
|
- this._isSupported = false;
|
|
11021
|
+ this._isSupported = ((type === Recording.types.JIBRI)
|
|
11022
|
+ || (type === Recording.types.JIRECON && !this.jirecon))? false : true;
|
11009
|
11023
|
/**
|
11010
|
11024
|
* The ID of the jirecon recording session. Jirecon generates it when we
|
11011
|
11025
|
* initially start recording, and it needs to be used in subsequent requests
|
|
@@ -11019,7 +11033,7 @@ Recording.types = {
|
11019
|
11033
|
COLIBRI: "colibri",
|
11020
|
11034
|
JIRECON: "jirecon",
|
11021
|
11035
|
JIBRI: "jibri"
|
11022
|
|
-}
|
|
11036
|
+};
|
11023
|
11037
|
|
11024
|
11038
|
Recording.prototype.handleJibriPresence = function (jibri) {
|
11025
|
11039
|
var attributes = jibri.attributes;
|
|
@@ -11101,7 +11115,7 @@ function (state, callback, errCallback, options) {
|
11101
|
11115
|
console.log('Failed to start recording, error: ', error);
|
11102
|
11116
|
errCallback(error);
|
11103
|
11117
|
});
|
11104
|
|
-}
|
|
11118
|
+};
|
11105
|
11119
|
|
11106
|
11120
|
// Sends a COLIBRI message which enables or disables (according to 'state')
|
11107
|
11121
|
// the recording on the bridge. Waits for the result IQ and calls 'callback'
|
|
@@ -11125,7 +11139,7 @@ function (state, callback, errCallback, options) {
|
11125
|
11139
|
callback(newState);
|
11126
|
11140
|
|
11127
|
11141
|
if (newState === 'pending') {
|
11128
|
|
- connection.addHandler(function(iq){
|
|
11142
|
+ self.connection.addHandler(function(iq){
|
11129
|
11143
|
var state = $(iq).find('recording').attr('state');
|
11130
|
11144
|
if (state) {
|
11131
|
11145
|
self.state = newState;
|
|
@@ -11139,7 +11153,7 @@ function (state, callback, errCallback, options) {
|
11139
|
11153
|
errCallback(error);
|
11140
|
11154
|
}
|
11141
|
11155
|
);
|
11142
|
|
-}
|
|
11156
|
+};
|
11143
|
11157
|
|
11144
|
11158
|
Recording.prototype.setRecording =
|
11145
|
11159
|
function (state, callback, errCallback, options) {
|
|
@@ -11157,36 +11171,37 @@ function (state, callback, errCallback, options) {
|
11157
|
11171
|
console.error("Unknown recording type!");
|
11158
|
11172
|
return;
|
11159
|
11173
|
}
|
11160
|
|
-}
|
11161
|
|
-
|
11162
|
|
-Recording.prototype.toggleRecording = function (options) {
|
11163
|
|
- var self = this;
|
11164
|
|
- return new Promise(function(resolve, reject) {
|
11165
|
|
- if (!token && self.type === Recording.types.COLIBRI) {
|
11166
|
|
- reject(new Error("No token passed!"));
|
11167
|
|
- logger.error("No token passed!");
|
11168
|
|
- return;
|
11169
|
|
- }
|
|
11174
|
+};
|
11170
|
11175
|
|
11171
|
|
- var oldState = self.state;
|
11172
|
|
- var newState = (oldState === 'off' || !oldState) ? 'on' : 'off';
|
|
11176
|
+/**
|
|
11177
|
+ *Starts/stops the recording
|
|
11178
|
+ * @param token token for authentication
|
|
11179
|
+ * @param statusChangeHandler {function} receives the new status as argument.
|
|
11180
|
+ */
|
|
11181
|
+Recording.prototype.toggleRecording = function (options, statusChangeHandler) {
|
|
11182
|
+ if ((!options.token && this.type === Recording.types.COLIBRI) ||
|
|
11183
|
+ (!options.streamId && this.type === Recording.types.JIBRI)){
|
|
11184
|
+ statusChangeHandler("error", new Error("No token passed!"));
|
|
11185
|
+ logger.error("No token passed!");
|
|
11186
|
+ return;
|
|
11187
|
+ }
|
11173
|
11188
|
|
11174
|
|
- self.setRecording(newState,
|
11175
|
|
- function (state, url) {
|
11176
|
|
- logger.log("New recording state: ", state);
|
11177
|
|
- if (state && state !== oldState) {
|
11178
|
|
- if(state !== "on" && state !== "off") //state === "pending" we are waiting for the real state
|
11179
|
|
- return;
|
11180
|
|
- self.state = state;
|
11181
|
|
- self.url = url;
|
11182
|
|
- resolve();
|
11183
|
|
- } else {
|
11184
|
|
- reject(new Error("State not changed!"));
|
11185
|
|
- }
|
11186
|
|
- }, function (error) {
|
11187
|
|
- reject(error);
|
11188
|
|
- }, options);
|
11189
|
|
- });
|
|
11189
|
+ var oldState = this.state;
|
|
11190
|
+ var newState = (oldState === 'off' || !oldState) ? 'on' : 'off';
|
|
11191
|
+ var self = this;
|
|
11192
|
+ this.setRecording(newState,
|
|
11193
|
+ function (state, url) {
|
|
11194
|
+ logger.log("New recording state: ", state);
|
|
11195
|
+ if (state && state !== oldState) {
|
|
11196
|
+ self.state = state;
|
|
11197
|
+ self.url = url;
|
|
11198
|
+ statusChangeHandler(state);
|
|
11199
|
+ } else {
|
|
11200
|
+ statusChangeHandler("error", new Error("Status not changed!"));
|
|
11201
|
+ }
|
|
11202
|
+ }, function (error) {
|
|
11203
|
+ statusChangeHandler("error", error);
|
|
11204
|
+ }, options);
|
11190
|
11205
|
};
|
11191
|
11206
|
|
11192
|
11207
|
/**
|