|
|
@@ -1,17 +1,28 @@
|
|
1
|
1
|
import { getLogger } from '@jitsi/logger';
|
|
2
|
2
|
|
|
3
|
3
|
import { XMPPEvents } from '../../service/xmpp/XMPPEvents';
|
|
|
4
|
+import ChatRoom from '../xmpp/ChatRoom';
|
|
4
|
5
|
|
|
5
|
6
|
import JibriSession from './JibriSession';
|
|
6
|
7
|
import recordingXMLUtils from './recordingXMLUtils';
|
|
7
|
8
|
|
|
8
|
9
|
const logger = getLogger(__filename);
|
|
9
|
10
|
|
|
|
11
|
+export interface IRecordingOptions {
|
|
|
12
|
+ appData?: string;
|
|
|
13
|
+ broadcastId?: string;
|
|
|
14
|
+ mode: string;
|
|
|
15
|
+ streamId?: string;
|
|
|
16
|
+}
|
|
|
17
|
+
|
|
10
|
18
|
/**
|
|
11
|
19
|
* A class responsible for starting and stopping recording sessions and emitting
|
|
12
|
20
|
* state updates for them.
|
|
13
|
21
|
*/
|
|
14
|
22
|
class RecordingManager {
|
|
|
23
|
+ private _sessions: { [key: string]: JibriSession; } = {};
|
|
|
24
|
+ private _chatRoom: any;
|
|
|
25
|
+
|
|
15
|
26
|
/**
|
|
16
|
27
|
* Initialize {@code RecordingManager} with other objects that are necessary
|
|
17
|
28
|
* for starting a recording.
|
|
|
@@ -19,12 +30,10 @@ class RecordingManager {
|
|
19
|
30
|
* @param {ChatRoom} chatRoom - The chat room to handle.
|
|
20
|
31
|
* @returns {void}
|
|
21
|
32
|
*/
|
|
22
|
|
- constructor(chatRoom) {
|
|
|
33
|
+ constructor(chatRoom: ChatRoom) {
|
|
23
|
34
|
/**
|
|
24
|
35
|
* All known recording sessions from the current conference.
|
|
25
|
36
|
*/
|
|
26
|
|
- this._sessions = {};
|
|
27
|
|
-
|
|
28
|
37
|
this._chatRoom = chatRoom;
|
|
29
|
38
|
|
|
30
|
39
|
this.onPresence = this.onPresence.bind(this);
|
|
|
@@ -43,7 +52,7 @@ class RecordingManager {
|
|
43
|
52
|
* @param {string} sessionID - The session ID associated with the recording.
|
|
44
|
53
|
* @returns {JibriSession|undefined}
|
|
45
|
54
|
*/
|
|
46
|
|
- getSession(sessionID) {
|
|
|
55
|
+ getSession(sessionID: string): JibriSession | undefined {
|
|
47
|
56
|
return this._sessions[sessionID];
|
|
48
|
57
|
}
|
|
49
|
58
|
|
|
|
@@ -53,8 +62,8 @@ class RecordingManager {
|
|
53
|
62
|
* @param {string} jibriJid the JID to search for.
|
|
54
|
63
|
* @returns
|
|
55
|
64
|
*/
|
|
56
|
|
- getSessionByJibriJid(jibriJid) {
|
|
57
|
|
- let s;
|
|
|
65
|
+ getSessionByJibriJid(jibriJid: string): JibriSession | undefined {
|
|
|
66
|
+ let s: JibriSession | undefined;
|
|
58
|
67
|
|
|
59
|
68
|
Object.values(this._sessions).forEach(session => {
|
|
60
|
69
|
if (session.getJibriJid() === jibriJid) {
|
|
|
@@ -77,7 +86,7 @@ class RecordingManager {
|
|
77
|
86
|
* with the Jibri recorder participant.
|
|
78
|
87
|
* @returns {void}
|
|
79
|
88
|
*/
|
|
80
|
|
- onPresence({ fromHiddenDomain, presence }) {
|
|
|
89
|
+ onPresence({ fromHiddenDomain, presence }: { fromHiddenDomain: boolean; presence: Node; }): void {
|
|
81
|
90
|
if (recordingXMLUtils.isFromFocus(presence)) {
|
|
82
|
91
|
this._handleFocusPresence(presence);
|
|
83
|
92
|
} else if (fromHiddenDomain) {
|
|
|
@@ -89,7 +98,7 @@ class RecordingManager {
|
|
89
|
98
|
* Handle a participant leaving the room.
|
|
90
|
99
|
* @param {string} jid the JID of the participant that left.
|
|
91
|
100
|
*/
|
|
92
|
|
- onMemberLeft(jid) {
|
|
|
101
|
+ onMemberLeft(jid: string): void {
|
|
93
|
102
|
const session = this.getSessionByJibriJid(jid);
|
|
94
|
103
|
|
|
95
|
104
|
if (session) {
|
|
|
@@ -122,7 +131,7 @@ class RecordingManager {
|
|
122
|
131
|
* back the session on success. The promise resolves after receiving an
|
|
123
|
132
|
* acknowledgment of the start request success or fail.
|
|
124
|
133
|
*/
|
|
125
|
|
- startRecording(options) {
|
|
|
134
|
+ startRecording(options: IRecordingOptions): Promise<JibriSession> {
|
|
126
|
135
|
const session = new JibriSession({
|
|
127
|
136
|
...options,
|
|
128
|
137
|
connection: this._chatRoom.connection
|
|
|
@@ -161,7 +170,7 @@ class RecordingManager {
|
|
161
|
170
|
* @returns {Promise} The promise resolves after receiving an
|
|
162
|
171
|
* acknowledgment of the stop request success or fail.
|
|
163
|
172
|
*/
|
|
164
|
|
- stopRecording(sessionID) {
|
|
|
173
|
+ stopRecording(sessionID: string): Promise<any> {
|
|
165
|
174
|
const session = this.getSession(sessionID);
|
|
166
|
175
|
|
|
167
|
176
|
if (session) {
|
|
|
@@ -177,7 +186,7 @@ class RecordingManager {
|
|
177
|
186
|
* @param {string} session - The JibriSession instance to store.
|
|
178
|
187
|
* @returns {void}
|
|
179
|
188
|
*/
|
|
180
|
|
- _addSession(session) {
|
|
|
189
|
+ _addSession(session: JibriSession): void {
|
|
181
|
190
|
this._sessions[session.getID()] = session;
|
|
182
|
191
|
}
|
|
183
|
192
|
|
|
|
@@ -190,7 +199,7 @@ class RecordingManager {
|
|
190
|
199
|
* @param {string} mode - The recording mode of the session.
|
|
191
|
200
|
* @returns {JibriSession}
|
|
192
|
201
|
*/
|
|
193
|
|
- _createSession(sessionID, status, mode) {
|
|
|
202
|
+ _createSession(sessionID: string, status: string, mode: string): JibriSession {
|
|
194
|
203
|
const session = new JibriSession({
|
|
195
|
204
|
connection: this._chatRoom.connection,
|
|
196
|
205
|
focusMucJid: this._chatRoom.focusMucJid,
|
|
|
@@ -210,7 +219,7 @@ class RecordingManager {
|
|
210
|
219
|
* @param {JibriSession} session - The session that has been updated.
|
|
211
|
220
|
* @param {string|undefined} initiator - The jid of the initiator of the update.
|
|
212
|
221
|
*/
|
|
213
|
|
- _emitSessionUpdate(session, initiator) {
|
|
|
222
|
+ _emitSessionUpdate(session: JibriSession, initiator?: string): void {
|
|
214
|
223
|
this._chatRoom.eventEmitter.emit(
|
|
215
|
224
|
XMPPEvents.RECORDER_STATE_CHANGED, session, initiator);
|
|
216
|
225
|
}
|
|
|
@@ -222,7 +231,7 @@ class RecordingManager {
|
|
222
|
231
|
* @param {Node} presence - An XMPP presence update.
|
|
223
|
232
|
* @returns {void}
|
|
224
|
233
|
*/
|
|
225
|
|
- _handleFocusPresence(presence) {
|
|
|
234
|
+ _handleFocusPresence(presence: Node): void {
|
|
226
|
235
|
const jibriStatus = recordingXMLUtils.getFocusRecordingUpdate(presence);
|
|
227
|
236
|
|
|
228
|
237
|
if (!jibriStatus) {
|
|
|
@@ -280,7 +289,7 @@ class RecordingManager {
|
|
280
|
289
|
* @param {Node} presence - An XMPP presence update.
|
|
281
|
290
|
* @returns {void}
|
|
282
|
291
|
*/
|
|
283
|
|
- _handleJibriPresence(presence) {
|
|
|
292
|
+ _handleJibriPresence(presence: any): void {
|
|
284
|
293
|
const { liveStreamViewURL, mode, sessionID }
|
|
285
|
294
|
= recordingXMLUtils.getHiddenDomainUpdate(presence);
|
|
286
|
295
|
|