hristoterezov 9 лет назад
Родитель
Сommit
b981c12dd8

+ 39
- 113
JitsiConference.js Просмотреть файл

@@ -1,4 +1,4 @@
1
-/* global Strophe, $, Promise */
1
+/* global Strophe, $ */
2 2
 /* jshint -W101 */
3 3
 var logger = require("jitsi-meet-logger").getLogger(__filename);
4 4
 var RTC = require("./modules/RTC/RTC");
@@ -6,7 +6,6 @@ var XMPPEvents = require("./service/xmpp/XMPPEvents");
6 6
 var RTCEvents = require("./service/RTC/RTCEvents");
7 7
 var EventEmitter = require("events");
8 8
 var JitsiConferenceEvents = require("./JitsiConferenceEvents");
9
-var JitsiConferenceErrors = require("./JitsiConferenceErrors");
10 9
 var JitsiParticipant = require("./JitsiParticipant");
11 10
 var Statistics = require("./modules/statistics/statistics");
12 11
 var JitsiDTMFManager = require('./modules/DTMF/JitsiDTMFManager');
@@ -52,13 +51,6 @@ JitsiConference.prototype.join = function (password) {
52 51
         this.room.join(password, this.connection.tokenPassword);
53 52
 };
54 53
 
55
-/**
56
- * Check if joined to the conference.
57
- */
58
-JitsiConference.prototype.isJoined = function () {
59
-    return this.room && this.room.joined;
60
-};
61
-
62 54
 /**
63 55
  * Leaves the conference.
64 56
  */
@@ -68,40 +60,6 @@ JitsiConference.prototype.leave = function () {
68 60
     this.room = null;
69 61
 };
70 62
 
71
-/**
72
- * Returns name of this conference.
73
- */
74
-JitsiConference.prototype.getName = function () {
75
-    return this.options.name;
76
-};
77
-
78
-/**
79
- * Check if external authentication is enabled for this conference.
80
- */
81
-JitsiConference.prototype.isExternalAuthEnabled = function () {
82
-    return this.room && this.room.moderator.isExternalAuthEnabled();
83
-};
84
-
85
-/**
86
- * Get url for external authentication.
87
- * @param {boolean} [urlForPopup] if true then return url for login popup,
88
- *                                else url of login page.
89
- * @returns {Promise}
90
- */
91
-JitsiConference.prototype.getExternalAuthUrl = function (urlForPopup) {
92
-    return new Promise(function (resolve, reject) {
93
-        if (!this.isExternalAuthEnabled()) {
94
-            reject();
95
-            return;
96
-        }
97
-        if (urlForPopup) {
98
-            this.room.moderator.getPopupLoginUrl(resolve, reject);
99
-        } else {
100
-            this.room.moderator.getLoginUrl(resolve, reject);
101
-        }
102
-    }.bind(this));
103
-};
104
-
105 63
 /**
106 64
  * Returns the local tracks.
107 65
  */
@@ -264,11 +222,6 @@ JitsiConference.prototype._fireMuteChangeEvent = function (track) {
264 222
  * @param track the JitsiLocalTrack object.
265 223
  */
266 224
 JitsiConference.prototype.removeTrack = function (track) {
267
-    if(!this.room){
268
-        if(this.rtc)
269
-            this.rtc.removeLocalStream(track);
270
-        return;
271
-    }
272 225
     this.room.removeStream(track.getOriginalStream(), function(){
273 226
         this.rtc.removeLocalStream(track);
274 227
         this.eventEmitter.emit(JitsiConferenceEvents.TRACK_REMOVED, track);
@@ -291,36 +244,6 @@ JitsiConference.prototype.isModerator = function () {
291 244
     return this.room.isModerator();
292 245
 };
293 246
 
294
-/**
295
- * Set password for the room.
296
- * @param {string} password new password for the room.
297
- * @returns {Promise}
298
- */
299
-JitsiConference.prototype.lock = function (password) {
300
-  if (!this.isModerator()) {
301
-    return Promise.reject();
302
-  }
303
-
304
-  var conference = this;
305
-  return new Promise(function (resolve, reject) {
306
-    conference.xmpp.lockRoom(password, function () {
307
-      resolve();
308
-    }, function (err) {
309
-      reject(err);
310
-    }, function () {
311
-      reject(JitsiConferenceErrors.PASSWORD_NOT_SUPPORTED);
312
-    });
313
-  });
314
-};
315
-
316
-/**
317
- * Remove password from the room.
318
- * @returns {Promise}
319
- */
320
-JitsiConference.prototype.unlock = function () {
321
-  return this.lock(undefined);
322
-};
323
-
324 247
 /**
325 248
  * Elects the participant with the given id to be the selected participant or the speaker.
326 249
  * @param id the identifier of the participant
@@ -362,13 +285,10 @@ JitsiConference.prototype.getParticipantById = function(id) {
362 285
 
363 286
 JitsiConference.prototype.onMemberJoined = function (jid, email, nick) {
364 287
     var id = Strophe.getResourceFromJid(jid);
365
-    if (id === 'focus') {
366
-       return;
367
-    }
368 288
     var participant = new JitsiParticipant(id, this, nick);
289
+    this.eventEmitter.emit(JitsiConferenceEvents.USER_JOINED, id);
369 290
     this.participants[id] = participant;
370
-    this.eventEmitter.emit(JitsiConferenceEvents.USER_JOINED, id, participant);
371
-    this.xmpp.connection.disco.info(
291
+    this.connection.xmpp.connection.disco.info(
372 292
         jid, "node", function(iq) {
373 293
             participant._supportsDTMF = $(iq).find(
374 294
                 '>query>feature[var="urn:xmpp:jingle:dtmf:0"]').length > 0;
@@ -379,9 +299,8 @@ JitsiConference.prototype.onMemberJoined = function (jid, email, nick) {
379 299
 
380 300
 JitsiConference.prototype.onMemberLeft = function (jid) {
381 301
     var id = Strophe.getResourceFromJid(jid);
382
-    var participant = this.participants[id];
383 302
     delete this.participants[id];
384
-    this.eventEmitter.emit(JitsiConferenceEvents.USER_LEFT, id, participant);
303
+    this.eventEmitter.emit(JitsiConferenceEvents.USER_LEFT, id);
385 304
 };
386 305
 
387 306
 JitsiConference.prototype.onUserRoleChanged = function (jid, role) {
@@ -477,7 +396,7 @@ JitsiConference.prototype.myUserId = function () {
477 396
 
478 397
 JitsiConference.prototype.sendTones = function (tones, duration, pause) {
479 398
     if (!this.dtmfManager) {
480
-        var connection = this.xmpp.connection.jingle.activecall.peerconnection;
399
+        var connection = this.connection.xmpp.connection.jingle.activecall.peerconnection;
481 400
         if (!connection) {
482 401
             logger.warn("cannot sendTones: no conneciton");
483 402
             return;
@@ -497,13 +416,40 @@ JitsiConference.prototype.sendTones = function (tones, duration, pause) {
497 416
 };
498 417
 
499 418
 /**
500
- * Returns the connection state for the current room. Its ice connection state
501
- * for its session.
419
+ * Returns true if the recording is supproted and false if not.
502 420
  */
503
-JitsiConference.prototype.getConnectionState = function () {
504
-    if(this.room)
505
-        return this.room.getConnectionState();
506
-    return null;
421
+JitsiConference.prototype.isRecordingSupported = function () {
422
+    // if(this.room)
423
+    //     return this.room.isRecordingSupported();
424
+    // return false;
425
+};
426
+
427
+/**
428
+ * Returns null if the recording is not supported, "on" if the recording started
429
+ * and "off" if the recording is not started.
430
+ */
431
+JitsiConference.prototype.getRecordingState = function () {
432
+    // if(this.room)
433
+    //     return this.room.getRecordingState();
434
+    // return "off";
435
+}
436
+
437
+/**
438
+ * Returns the url of the recorded video.
439
+ */
440
+JitsiConference.prototype.getRecordingURL = function () {
441
+    // if(this.room)
442
+    //     return this.room.getRecordingURL();
443
+    // return null;
444
+}
445
+
446
+/**
447
+ * Starts/stops the recording
448
+ * @param token a token for authentication.
449
+ */
450
+JitsiConference.prototype.toggleRecording = function (token) {
451
+    // if(this.room)
452
+    //     this.room.toggleRecording(token);
507 453
 }
508 454
 
509 455
 /**
@@ -529,18 +475,6 @@ function setupListeners(conference) {
529 475
     conference.room.addListener(XMPPEvents.MUC_JOINED, function () {
530 476
         conference.eventEmitter.emit(JitsiConferenceEvents.CONFERENCE_JOINED);
531 477
     });
532
-    conference.room.addListener(XMPPEvents.ROOM_JOIN_ERROR, function (pres) {
533
-        conference.eventEmitter.emit(JitsiConferenceEvents.CONFERENCE_FAILED, JitsiConferenceErrors.CONNECTION_ERROR, pres);
534
-    });
535
-    conference.room.addListener(XMPPEvents.ROOM_CONNECT_ERROR, function (pres) {
536
-        conference.eventEmitter.emit(JitsiConferenceEvents.CONFERENCE_FAILED, JitsiConferenceErrors.CONNECTION_ERROR, pres);
537
-    });
538
-    conference.room.addListener(XMPPEvents.PASSWORD_REQUIRED, function (pres) {
539
-        conference.eventEmitter.emit(JitsiConferenceEvents.CONFERENCE_FAILED, JitsiConferenceErrors.PASSWORD_REQUIRED, pres);
540
-    });
541
-    conference.room.addListener(XMPPEvents.AUTHENTICATION_REQUIRED, function () {
542
-        conference.eventEmitter.emit(JitsiConferenceEvents.CONFERENCE_FAILED, JitsiConferenceErrors.AUTHENTICATION_REQUIRED);
543
-    });
544 478
 //    FIXME
545 479
 //    conference.room.addListener(XMPPEvents.MUC_JOINED, function () {
546 480
 //        conference.eventEmitter.emit(JitsiConferenceEvents.CONFERENCE_LEFT);
@@ -564,12 +498,7 @@ function setupListeners(conference) {
564 498
         conference.eventEmitter.emit(JitsiConferenceEvents.CONNECTION_RESTORED);
565 499
     });
566 500
     conference.room.addListener(XMPPEvents.CONFERENCE_SETUP_FAILED, function () {
567
-        conference.eventEmitter.emit(JitsiConferenceEvents.CONFERENCE_FAILED, JitsiConferenceErrors.SETUP_FAILED);
568
-    });
569
-
570
-    conference.room.addListener(XMPPEvents.MESSAGE_RECEIVED, function (jid, displayName, txt, myJid, ts) {
571
-        var id = Strophe.getResourceFromJid(jid);
572
-        conference.eventEmitter.emit(JitsiConferenceEvents.MESSAGE_RECEIVED, id, txt, ts);
501
+        conference.eventEmitter.emit(JitsiConferenceEvents.SETUP_FAILED);
573 502
     });
574 503
 
575 504
     conference.rtc.addListener(RTCEvents.DOMINANTSPEAKER_CHANGED, function (id) {
@@ -588,9 +517,6 @@ function setupListeners(conference) {
588 517
             conference.eventEmitter.emit(JitsiConferenceEvents.LAST_N_ENDPOINTS_CHANGED,
589 518
                 lastNEndpoints, endpointsEnteringLastN);
590 519
         });
591
-    conference.xmpp.addListener(XMPPEvents.PASSWORD_REQUIRED, function () {
592
-        conference.eventEmitter.emit(JitsiConferenceErrors.PASSWORD_REQUIRED);
593
-    });
594 520
 
595 521
     if(conference.statistics) {
596 522
         //FIXME: Maybe remove event should not be associated with the conference.

+ 5
- 1
JitsiConferenceEvents.js Просмотреть файл

@@ -83,7 +83,11 @@ var JitsiConferenceEvents = {
83 83
     /**
84 84
      * Indicates that DTMF support changed.
85 85
      */
86
-    DTMF_SUPPORT_CHANGED: "conference.dtmfSupportChanged"
86
+    DTMF_SUPPORT_CHANGED: "conference.dtmfSupportChanged",
87
+    /**
88
+     * Indicates that recording state changed.
89
+     */
90
+    RECORDING_STATE_CHANGED: "conference.recordingStateChanged"
87 91
 };
88 92
 
89 93
 module.exports = JitsiConferenceEvents;

+ 2
- 3
JitsiConnection.js Просмотреть файл

@@ -8,9 +8,8 @@ var RandomUtil = require("./modules/util/RandomUtil");
8 8
  * @returns {string}
9 9
  */
10 10
 function generateUserName() {
11
-    return RandomUtil.randomHexString(8) + "-" + RandomUtil.randomHexString(4) +
12
-        "-" + RandomUtil.randomHexString(4) + "-" +
13
-        RandomUtil.randomHexDigit(8);
11
+    return RandomUtil.random8digitsHex() + "-" + RandomUtil.random4digitsHex() + "-" +
12
+        RandomUtil.random4digitsHex() + "-" + RandomUtil.random8digitsHex();
14 13
 }
15 14
 
16 15
 /**

+ 313
- 349
lib-jitsi-meet.js
Разница между файлами не показана из-за своего большого размера
Просмотреть файл


+ 46
- 7
modules/xmpp/ChatRoom.js Просмотреть файл

@@ -4,6 +4,7 @@ var logger = require("jitsi-meet-logger").getLogger(__filename);
4 4
 var XMPPEvents = require("../../service/xmpp/XMPPEvents");
5 5
 var Moderator = require("./moderator");
6 6
 var EventEmitter = require("events");
7
+var JIBRI_XMLNS = 'http://jitsi.org/protocol/jibri';
7 8
 
8 9
 var parser = {
9 10
     packet2JSON: function (packet, nodes) {
@@ -216,6 +217,7 @@ ChatRoom.prototype.onPresence = function (pres) {
216 217
     var nodes = [];
217 218
     parser.packet2JSON(pres, nodes);
218 219
     this.lastPresences[from] = nodes;
220
+    var jibri = null;
219 221
     for(var i = 0; i < nodes.length; i++)
220 222
     {
221 223
         var node = nodes[i];
@@ -245,6 +247,8 @@ ChatRoom.prototype.onPresence = function (pres) {
245 247
                     this.eventEmitter.emit(XMPPEvents.BRIDGE_DOWN);
246 248
                 }
247 249
                 break;
250
+            case "jibri-recording-status":
251
+                var jibri = node;
248 252
             default :
249 253
                 this.processNode(node, from);
250 254
         }
@@ -261,6 +265,8 @@ ChatRoom.prototype.onPresence = function (pres) {
261 265
             }
262 266
         if (!this.joined) {
263 267
             this.joined = true;
268
+            this.recording = new Recording(this.eventEmitter, this.connection,
269
+                this.focusMucJid);
264 270
             console.log("(TIME) MUC joined:\t", window.performance.now());
265 271
             this.eventEmitter.emit(XMPPEvents.MUC_JOINED, from, member);
266 272
         }
@@ -298,6 +304,11 @@ ChatRoom.prototype.onPresence = function (pres) {
298 304
         this.eventEmitter.emit(XMPPEvents.PRESENCE_STATUS, from, member);
299 305
     }
300 306
 
307
+    if(this.recording)
308
+    {
309
+        this.recording.handleJibriPresence(jibri);
310
+    }
311
+
301 312
 };
302 313
 
303 314
 ChatRoom.prototype.processNode = function (node, from) {
@@ -515,10 +526,10 @@ ChatRoom.prototype.setJingleSession = function(session){
515 526
 };
516 527
 
517 528
 
518
-ChatRoom.prototype.removeStream = function (stream) {
529
+ChatRoom.prototype.removeStream = function (stream, callback) {
519 530
     if(!this.session)
520 531
         return;
521
-    this.session.peerconnection.removeStream(stream);
532
+    this.session.removeStream(stream, callback);
522 533
 };
523 534
 
524 535
 ChatRoom.prototype.switchStreams = function (stream, oldStream, callback, isAudio) {
@@ -640,12 +651,40 @@ ChatRoom.prototype.getJidBySSRC = function (ssrc) {
640 651
 };
641 652
 
642 653
 /**
643
- * Returns the connection state for the current session.
654
+ * Returns true if the recording is supproted and false if not.
644 655
  */
645
-ChatRoom.prototype.getConnectionState = function () {
646
-    if(!this.session)
647
-        return null;
648
-    return this.session.getIceConnectionState();
656
+ChatRoom.prototype.isRecordingSupported = function () {
657
+    if(this.recording)
658
+        return this.recording.isSupported();
659
+    return false;
660
+};
661
+
662
+/**
663
+ * Returns null if the recording is not supported, "on" if the recording started
664
+ * and "off" if the recording is not started.
665
+ */
666
+ChatRoom.prototype.getRecordingState = function () {
667
+    if(this.recording)
668
+        return this.recording.getState();
669
+    return "off";
670
+}
671
+
672
+/**
673
+ * Returns the url of the recorded video.
674
+ */
675
+ChatRoom.prototype.getRecordingURL = function () {
676
+    if(this.recording)
677
+        return this.recording.getURL();
678
+    return null;
679
+}
680
+
681
+/**
682
+ * Starts/stops the recording
683
+ * @param token token for authentication
684
+ */
685
+ChatRoom.prototype.toggleRecording = function (token) {
686
+    if(this.recording && this.moderator.isModerator())
687
+        this.recording.toggleRecording(token);
649 688
 }
650 689
 
651 690
 module.exports = ChatRoom;

+ 30
- 182
modules/xmpp/recording.js Просмотреть файл

@@ -1,91 +1,37 @@
1 1
 /* global $, $iq, config, connection, focusMucJid, messageHandler,
2 2
    Toolbar, Util */
3
-var Moderator = require("./moderator");
4
-
5
-
6
-var recordingToken = null;
7
-var recordingEnabled;
8
-
9
-/**
10
- * Whether to use a jirecon component for recording, or use the videobridge
11
- * through COLIBRI.
12
- */
13
-var useJirecon;
14
-
15
-var useJibri;
16
-var eventEmitter;
17
-
18
-/**
19
- * The ID of the jirecon recording session. Jirecon generates it when we
20
- * initially start recording, and it needs to be used in subsequent requests
21
- * to jirecon.
22
- */
23
-var jireconRid = null;
24
-
25
-/**
26
- * The callback to update the recording button. Currently used from colibri
27
- * after receiving a pending status.
28
- */
29
-var recordingStateChangeCallback = null;
30
-
31
-function setRecordingToken(token) {
32
-    recordingToken = token;
33
-}
34
-
35
-function setRecordingJirecon(state, token, callback, connection) {
36
-    if (state == recordingEnabled){
37
-        return;
38
-    }
39
-
40
-    var iq = $iq({to: config.hosts.jirecon, type: 'set'})
41
-        .c('recording', {xmlns: 'http://jitsi.org/protocol/jirecon',
42
-            action: (state === 'on') ? 'start' : 'stop',
43
-            mucjid: connection.emuc.roomjid});
44
-    if (state === 'off'){
45
-        iq.attrs({rid: jireconRid});
46
-    }
47
-
48
-    console.log('Start recording');
3
+var XMPPEvents = require("../../service/XMPP/XMPPEvents");
4
+
5
+function Recording(ee, connection, focusMucJid) {
6
+    this.eventEmitter = ee;
7
+    this.connection = connection;
8
+    this.connection.jibri.setHandler(this.handleJibriIq);
9
+    this.state = "off";
10
+    this.focusMucJid = focusMucJid;
11
+    this.url = null;
12
+    this.isRecordingSupported = false;
13
+};
49 14
 
50
-    connection.sendIQ(
51
-        iq,
52
-        function (result) {
53
-            // TODO wait for an IQ with the real status, since this is
54
-            // provisional?
55
-            //FIXME: state should reflect the NEW state.
56
-            jireconRid = $(result).find('recording').attr('rid');
57
-            console.log('Recording ' +
58
-                ((state === 'on') ? 'started' : 'stopped') +
59
-                '(jirecon)' + result);
60
-            recordingEnabled = state;
61
-            if (state === 'off'){
62
-                jireconRid = null;
63
-            }
15
+Recording.prototype.handleJibriPresence = function (jibri) {
64 16
 
65
-            callback(state);
66
-        },
67
-        function (error) {
68
-            console.log('Failed to start recording, error: ', error);
69
-            callback(recordingEnabled);
70
-        });
17
+    this.eventEmitter.emit(XMPPEvents.RECORDING_STATE_CHANGED);
71 18
 }
72 19
 
73
-function setRecordingJibri(state, token, callback, connection) {
74
-    if (state == recordingEnabled){
20
+Recording.prototype.setRecording = function (state, streamId, callback){
21
+    if (state == this.state){
75 22
         return;
76 23
     }
77 24
 
78
-    var focusJid = connection.emuc.focusMucJid;
79
-    var iq = $iq({to: focusJid, type: 'set'})
25
+    var iq = $iq({to: this.focusMucJid, type: 'set'})
80 26
         .c('jibri', {
81 27
             xmlns: 'http://jitsi.org/protocol/jibri',
82
-            action: (state === 'on') ? 'start' : 'stop'
83
-            //TODO: add the stream id?
28
+            action: (state === 'on') ? 'start' : 'stop',
29
+            streamId: streamId
84 30
         }).up();
85 31
 
86 32
     console.log('Set jibri recording: '+state, iq);
87 33
 
88
-    connection.sendIQ(
34
+    this.connection.sendIQ(
89 35
         iq,
90 36
         function (result) {
91 37
             var recordingEnabled = $(result).find('jibri').attr('state');
@@ -99,127 +45,29 @@ function setRecordingJibri(state, token, callback, connection) {
99 45
         });
100 46
 }
101 47
 
102
-// Sends a COLIBRI message which enables or disables (according to 'state')
103
-// the recording on the bridge. Waits for the result IQ and calls 'callback'
104
-// with the new recording state, according to the IQ.
105
-function setRecordingColibri(state, token, callback, connection) {
106
-    var elem = $iq({to: connection.emuc.focusMucJid, type: 'set'});
107
-    elem.c('conference', {
108
-        xmlns: 'http://jitsi.org/protocol/colibri'
109
-    });
110
-    elem.c('recording', {state: state, token: token});
111 48
 
112
-    connection.sendIQ(elem,
113
-        function (result) {
114
-            console.log('Set recording "', state, '". Result:', result);
115
-            var recordingElem = $(result).find('>conference>recording');
116
-            var newState = recordingElem.attr('state');
117
-
118
-            recordingEnabled = newState;
119
-            callback(newState);
120
-
121
-            if (newState === 'pending' && !recordingStateChangeCallback) {
122
-                recordingStateChangeCallback = callback;
123
-                connection.addHandler(function(iq){
124
-                    var state = $(iq).find('recording').attr('state');
125
-                    if (state)
126
-                        recordingStateChangeCallback(state);
127
-                }, 'http://jitsi.org/protocol/colibri', 'iq', null, null, null);
128
-            }
129
-        },
130
-        function (error) {
131
-            console.warn(error);
132
-            callback(recordingEnabled);
133
-        }
134
-    );
135
-}
136
-
137
-function setRecording(state, token, callback, connection) {
138
-    if (useJibri) {
139
-        setRecordingJibri(state, token, callback, connection);
140
-    } else if (useJirecon){
141
-        setRecordingJirecon(state, token, callback, connection);
142
-    } else {
143
-        setRecordingColibri(state, token, callback, connection);
144
-    }
145
-}
146
-
147
-function handleJibriIq(iq) {
148
-    //TODO verify it comes from the focus
149
-
150
-    var newState = $(iq).find('jibri').attr('state');
151
-    if (newState) {
152
-        eventEmitter.emit('recording.state_changed', newState);
153
-    }
154
-}
155
-
156
-var Recording = {
157
-    init: function (ee) {
158
-        eventEmitter = ee;
159
-        useJirecon = config.hosts &&
160
-            (typeof config.hosts.jirecon != "undefined");
161
-        useJibri = config.recordingUseJibri;
162
-        connection.jibri.setHandler(handleJibriIq);
163
-    },
164
-    toggleRecording: function (tokenEmptyCallback,
165
-                               recordingStateChangeCallback,
166
-                               connection) {
167
-        if (!Moderator.isModerator()) {
168
-            console.log(
169
-                    'non-focus, or conference not yet organized:' +
170
-                    ' not enabling recording');
171
-            return;
172
-        }
173
-
174
-        var self = this;
49
+Recording.prototype.toggleRecording = function (token) {
175 50
         // Jirecon does not (currently) support a token.
176
-        if (!recordingToken && !useJirecon) {
177
-            tokenEmptyCallback(function (value) {
178
-                setRecordingToken(value);
179
-                self.toggleRecording(tokenEmptyCallback,
180
-                                     recordingStateChangeCallback,
181
-                                     connection);
182
-            });
183
-
51
+        if (!token) {
52
+            console.error("No token passed!");
184 53
             return;
185 54
         }
186 55
 
187
-        var oldState = recordingEnabled;
56
+        var oldState = this.state;
188 57
         var newState = (oldState === 'off' || !oldState) ? 'on' : 'off';
189 58
 
190
-        setRecording(newState,
191
-            recordingToken,
59
+        this.setRecording(newState,
60
+            token,
192 61
             function (state) {
193 62
                 console.log("New recording state: ", state);
194
-                if (state === oldState) {
195
-                    // FIXME: new focus:
196
-                    // this will not work when moderator changes
197
-                    // during active session. Then it will assume that
198
-                    // recording status has changed to true, but it might have
199
-                    // been already true(and we only received actual status from
200
-                    // the focus).
201
-                    //
202
-                    // SO we start with status null, so that it is initialized
203
-                    // here and will fail only after second click, so if invalid
204
-                    // token was used we have to press the button twice before
205
-                    // current status will be fetched and token will be reset.
206
-                    //
207
-                    // Reliable way would be to return authentication error.
208
-                    // Or status update when moderator connects.
209
-                    // Or we have to stop recording session when current
210
-                    // moderator leaves the room.
211
-
212
-                    // Failed to change, reset the token because it might
213
-                    // have been wrong
214
-                    setRecordingToken(null);
63
+                if (state !== oldState) {
64
+                    this.state = state;
65
+                    this.eventEmitter.emit(XMPPEvents.RECORDING_STATE_CHANGED, state);
215 66
                 }
216
-                recordingStateChangeCallback(state);
217
-
218
-            },
219
-            connection
67
+            }
220 68
         );
221 69
     }
222 70
 
223 71
 };
224 72
 
225
-module.exports = Recording;
73
+module.exports = Recording;

+ 1
- 1
modules/xmpp/strophe.jibri.js Просмотреть файл

@@ -4,7 +4,7 @@ var jibriHandler;
4 4
 module.exports = function() {
5 5
     Strophe.addConnectionPlugin('jibri',
6 6
         {
7
-            JIBRI_XMLNS: 'http://jitsi.org/protocol/jibri',
7
+            
8 8
             connection: null,
9 9
             init: function (conn) {
10 10
                 this.connection = conn;

+ 6
- 2
service/xmpp/XMPPEvents.js Просмотреть файл

@@ -97,6 +97,10 @@ var XMPPEvents = {
97 97
     // xmpp is connected and obtained user media
98 98
     READY_TO_JOIN: 'xmpp.ready_to_join',
99 99
     FOCUS_LEFT: "xmpp.focus_left",
100
-    REMOTE_STREAM_RECEIVED: "xmpp.remote_stream_received"
100
+    REMOTE_STREAM_RECEIVED: "xmpp.remote_stream_received",
101
+    /**
102
+     * Indicates that recording state changed.
103
+     */
104
+    RECORDING_STATE_CHANGED: "xmpp.recordingStateChanged"
101 105
 };
102
-module.exports = XMPPEvents;
106
+module.exports = XMPPEvents;

Загрузка…
Отмена
Сохранить