Browse Source

Extracts the jid that start/stopped a jibri session.

master
damencho 5 years ago
parent
commit
16e08408aa

+ 18
- 2
JitsiConferenceEventManager.js View File

@@ -220,8 +220,24 @@ JitsiConferenceEventManager.prototype.setupChatRoomListeners = function() {
220 220
                     { p2p: jingleSession.isP2P }));
221 221
         });
222 222
 
223
-    this.chatRoomForwarder.forward(XMPPEvents.RECORDER_STATE_CHANGED,
224
-        JitsiConferenceEvents.RECORDER_STATE_CHANGED);
223
+    chatRoom.addListener(XMPPEvents.RECORDER_STATE_CHANGED,
224
+        (session, jid) => {
225
+
226
+            if (jid) {
227
+                const participant = conference.getParticipantById(
228
+                    Strophe.getResourceFromJid(jid));
229
+
230
+                if (session.getStatus() === 'off') {
231
+                    session.setTerminator(participant);
232
+                } else if (session.getStatus() === 'on') {
233
+                    session.setInitiator(participant);
234
+                }
235
+            }
236
+
237
+            conference.eventEmitter.emit(
238
+                JitsiConferenceEvents.RECORDER_STATE_CHANGED,
239
+                session);
240
+        });
225 241
 
226 242
     this.chatRoomForwarder.forward(XMPPEvents.TRANSCRIPTION_STATUS_CHANGED,
227 243
         JitsiConferenceEvents.TRANSCRIPTION_STATUS_CHANGED);

+ 35
- 0
modules/recording/JibriSession.js View File

@@ -37,6 +37,15 @@ export default class JibriSession {
37 37
         return this._sessionID;
38 38
     }
39 39
 
40
+    /**
41
+     * Returns the initiator of the session instance.
42
+     *
43
+     * @returns {JitsiParticipant|undefined} The participant that started the session.
44
+     */
45
+    getInitiator() {
46
+        return this._initiator;
47
+    }
48
+
40 49
     /**
41 50
      * Returns the streaming URL of the session.
42 51
      *
@@ -55,6 +64,15 @@ export default class JibriSession {
55 64
         return this._status;
56 65
     }
57 66
 
67
+    /**
68
+     * Returns the jid of the participant that stopped the session.
69
+     *
70
+     * @returns {JitsiParticipant|undefined} The participant that stopped the session.
71
+     */
72
+    getTerminator() {
73
+        return this._terminator;
74
+    }
75
+
58 76
     /**
59 77
      * Returns the current recording mode of the session, such as "file".
60 78
      *
@@ -96,6 +114,23 @@ export default class JibriSession {
96 114
         this._status = status;
97 115
     }
98 116
 
117
+    /**
118
+     * Sets the creator's jid of the session.
119
+     * @param {JitsiParticipant} participant - The creator of the session.
120
+     */
121
+    setInitiator(participant) {
122
+        this._initiator = participant;
123
+    }
124
+
125
+    /**
126
+     * Sets the jid of the participant that stopped the session.
127
+     * @param {JitsiParticipant} participant  - The participant's jid,
128
+     * that stopped the session.
129
+     */
130
+    setTerminator(participant) {
131
+        this._terminator = participant;
132
+    }
133
+
99 134
     /**
100 135
      * Sends a message to start the actual recording.
101 136
      *

+ 5
- 4
modules/recording/RecordingManager.js View File

@@ -165,10 +165,11 @@ class RecordingManager {
165 165
      * Notifies listeners of an update to a recording session.
166 166
      *
167 167
      * @param {JibriSession} session - The session that has been updated.
168
+     * @param {string|undefined} initiator - The jid of the initiator of the update.
168 169
      */
169
-    _emitSessionUpdate(session) {
170
+    _emitSessionUpdate(session, initiator) {
170 171
         this._chatRoom.eventEmitter.emit(
171
-            XMPPEvents.RECORDER_STATE_CHANGED, session);
172
+            XMPPEvents.RECORDER_STATE_CHANGED, session, initiator);
172 173
     }
173 174
 
174 175
     /**
@@ -185,7 +186,7 @@ class RecordingManager {
185 186
             return;
186 187
         }
187 188
 
188
-        const { sessionID, status, error, recordingMode } = jibriStatus;
189
+        const { error, initiator, recordingMode, sessionID, status } = jibriStatus;
189 190
 
190 191
         // We'll look for an existing session or create one (in case we're a
191 192
         // participant joining a call with an existing recording going on).
@@ -226,7 +227,7 @@ class RecordingManager {
226 227
             session.setError(error);
227 228
         }
228 229
 
229
-        this._emitSessionUpdate(session);
230
+        this._emitSessionUpdate(session, initiator);
230 231
     }
231 232
 
232 233
     /**

+ 1
- 0
modules/recording/recordingXMLUtils.js View File

@@ -20,6 +20,7 @@ export default {
20 20
 
21 21
         return {
22 22
             error: jibriStatus.getAttribute('failure_reason'),
23
+            initiator: jibriStatus.getAttribute('initiator'),
23 24
             recordingMode: jibriStatus.getAttribute('recording_mode'),
24 25
             sessionID: jibriStatus.getAttribute('session_id'),
25 26
             status: jibriStatus.getAttribute('status')

Loading…
Cancel
Save