|
@@ -29,8 +29,12 @@ class RecordingManager {
|
29
|
29
|
|
30
|
30
|
this.onPresence = this.onPresence.bind(this);
|
31
|
31
|
|
|
32
|
+ this.onMemberLeft = this.onMemberLeft.bind(this);
|
|
33
|
+
|
32
|
34
|
this._chatRoom.eventEmitter.addListener(
|
33
|
35
|
XMPPEvents.PRESENCE_RECEIVED, this.onPresence);
|
|
36
|
+ this._chatRoom.eventEmitter.addListener(
|
|
37
|
+ XMPPEvents.MUC_MEMBER_LEFT, this.onMemberLeft);
|
34
|
38
|
}
|
35
|
39
|
|
36
|
40
|
/**
|
|
@@ -43,6 +47,24 @@ class RecordingManager {
|
43
|
47
|
return this._sessions[sessionID];
|
44
|
48
|
}
|
45
|
49
|
|
|
50
|
+ /**
|
|
51
|
+ * Find a session with a specific jibri JID.
|
|
52
|
+ *
|
|
53
|
+ * @param {string} jibriJid the JID to search for.
|
|
54
|
+ * @returns
|
|
55
|
+ */
|
|
56
|
+ getSessionByJibriJid(jibriJid) {
|
|
57
|
+ let s;
|
|
58
|
+
|
|
59
|
+ Object.values(this._sessions).forEach(session => {
|
|
60
|
+ if (session.getJibriJid() === jibriJid) {
|
|
61
|
+ s = session;
|
|
62
|
+ }
|
|
63
|
+ });
|
|
64
|
+
|
|
65
|
+ return s;
|
|
66
|
+ }
|
|
67
|
+
|
46
|
68
|
/**
|
47
|
69
|
* Callback to invoke to parse through a presence update to find recording
|
48
|
70
|
* related updates (from Jibri participant doing the recording and the
|
|
@@ -63,6 +85,27 @@ class RecordingManager {
|
63
|
85
|
}
|
64
|
86
|
}
|
65
|
87
|
|
|
88
|
+ /**
|
|
89
|
+ * Handle a participant leaving the room.
|
|
90
|
+ * @param {string} jid the JID of the participant that left.
|
|
91
|
+ */
|
|
92
|
+ onMemberLeft(jid) {
|
|
93
|
+ const session = this.getSessionByJibriJid(jid);
|
|
94
|
+
|
|
95
|
+ if (session) {
|
|
96
|
+
|
|
97
|
+ const prevStatus = session.getStatus();
|
|
98
|
+
|
|
99
|
+ // Setting to ''
|
|
100
|
+ session.setStatus('');
|
|
101
|
+ session.setJibriJid(null);
|
|
102
|
+
|
|
103
|
+ if (session.getStatus() !== prevStatus) {
|
|
104
|
+ this._emitSessionUpdate(session);
|
|
105
|
+ }
|
|
106
|
+ }
|
|
107
|
+ }
|
|
108
|
+
|
66
|
109
|
/**
|
67
|
110
|
* Start a recording session.
|
68
|
111
|
*
|
|
@@ -221,7 +264,7 @@ class RecordingManager {
|
221
|
264
|
session = this._createSession(sessionID, status, recordingMode);
|
222
|
265
|
}
|
223
|
266
|
|
224
|
|
- session.setStatus(status);
|
|
267
|
+ session.setStatusFromJicofo(status);
|
225
|
268
|
|
226
|
269
|
if (error) {
|
227
|
270
|
session.setError(error);
|
|
@@ -251,9 +294,12 @@ class RecordingManager {
|
251
|
294
|
let session = this.getSession(sessionID);
|
252
|
295
|
|
253
|
296
|
if (!session) {
|
254
|
|
- session = this._createSession(sessionID, '', mode);
|
|
297
|
+ session = this._createSession(sessionID, 'on', mode);
|
255
|
298
|
}
|
256
|
299
|
|
|
300
|
+ // When a jibri is present the status is always 'on';
|
|
301
|
+ session.setStatus('on');
|
|
302
|
+ session.setJibriJid(presence.getAttribute('from'));
|
257
|
303
|
session.setLiveStreamViewURL(liveStreamViewURL);
|
258
|
304
|
|
259
|
305
|
this._emitSessionUpdate(session);
|