Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 2a8647b

Browse files
authoredMar 20, 2025
feat(ts) migrate RecordingManager to TS
1 parent ec76798 commit 2a8647b

File tree

1 file changed

+24
-15
lines changed

1 file changed

+24
-15
lines changed
 

‎modules/recording/RecordingManager.js ‎modules/recording/RecordingManager.ts

+24-15
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,39 @@
11
import { getLogger } from '@jitsi/logger';
22

33
import { XMPPEvents } from '../../service/xmpp/XMPPEvents';
4+
import ChatRoom from '../xmpp/ChatRoom';
45

56
import JibriSession from './JibriSession';
67
import recordingXMLUtils from './recordingXMLUtils';
78

89
const logger = getLogger(__filename);
910

11+
export interface IRecordingOptions {
12+
appData?: string;
13+
broadcastId?: string;
14+
mode: string;
15+
streamId?: string;
16+
}
17+
1018
/**
1119
* A class responsible for starting and stopping recording sessions and emitting
1220
* state updates for them.
1321
*/
1422
class RecordingManager {
23+
private _sessions: { [key: string]: JibriSession; } = {};
24+
private _chatRoom: any;
25+
1526
/**
1627
* Initialize {@code RecordingManager} with other objects that are necessary
1728
* for starting a recording.
1829
*
1930
* @param {ChatRoom} chatRoom - The chat room to handle.
2031
* @returns {void}
2132
*/
22-
constructor(chatRoom) {
33+
constructor(chatRoom: ChatRoom) {
2334
/**
2435
* All known recording sessions from the current conference.
2536
*/
26-
this._sessions = {};
27-
2837
this._chatRoom = chatRoom;
2938

3039
this.onPresence = this.onPresence.bind(this);
@@ -43,7 +52,7 @@ class RecordingManager {
4352
* @param {string} sessionID - The session ID associated with the recording.
4453
* @returns {JibriSession|undefined}
4554
*/
46-
getSession(sessionID) {
55+
getSession(sessionID: string): JibriSession | undefined {
4756
return this._sessions[sessionID];
4857
}
4958

@@ -53,8 +62,8 @@ class RecordingManager {
5362
* @param {string} jibriJid the JID to search for.
5463
* @returns
5564
*/
56-
getSessionByJibriJid(jibriJid) {
57-
let s;
65+
getSessionByJibriJid(jibriJid: string): JibriSession | undefined {
66+
let s: JibriSession | undefined;
5867

5968
Object.values(this._sessions).forEach(session => {
6069
if (session.getJibriJid() === jibriJid) {
@@ -77,7 +86,7 @@ class RecordingManager {
7786
* with the Jibri recorder participant.
7887
* @returns {void}
7988
*/
80-
onPresence({ fromHiddenDomain, presence }) {
89+
onPresence({ fromHiddenDomain, presence }: { fromHiddenDomain: boolean; presence: Node; }): void {
8190
if (recordingXMLUtils.isFromFocus(presence)) {
8291
this._handleFocusPresence(presence);
8392
} else if (fromHiddenDomain) {
@@ -89,7 +98,7 @@ class RecordingManager {
8998
* Handle a participant leaving the room.
9099
* @param {string} jid the JID of the participant that left.
91100
*/
92-
onMemberLeft(jid) {
101+
onMemberLeft(jid: string): void {
93102
const session = this.getSessionByJibriJid(jid);
94103

95104
if (session) {
@@ -122,7 +131,7 @@ class RecordingManager {
122131
* back the session on success. The promise resolves after receiving an
123132
* acknowledgment of the start request success or fail.
124133
*/
125-
startRecording(options) {
134+
startRecording(options: IRecordingOptions): Promise<JibriSession> {
126135
const session = new JibriSession({
127136
...options,
128137
connection: this._chatRoom.connection
@@ -161,7 +170,7 @@ class RecordingManager {
161170
* @returns {Promise} The promise resolves after receiving an
162171
* acknowledgment of the stop request success or fail.
163172
*/
164-
stopRecording(sessionID) {
173+
stopRecording(sessionID: string): Promise<any> {
165174
const session = this.getSession(sessionID);
166175

167176
if (session) {
@@ -177,7 +186,7 @@ class RecordingManager {
177186
* @param {string} session - The JibriSession instance to store.
178187
* @returns {void}
179188
*/
180-
_addSession(session) {
189+
_addSession(session: JibriSession): void {
181190
this._sessions[session.getID()] = session;
182191
}
183192

@@ -190,7 +199,7 @@ class RecordingManager {
190199
* @param {string} mode - The recording mode of the session.
191200
* @returns {JibriSession}
192201
*/
193-
_createSession(sessionID, status, mode) {
202+
_createSession(sessionID: string, status: string, mode: string): JibriSession {
194203
const session = new JibriSession({
195204
connection: this._chatRoom.connection,
196205
focusMucJid: this._chatRoom.focusMucJid,
@@ -210,7 +219,7 @@ class RecordingManager {
210219
* @param {JibriSession} session - The session that has been updated.
211220
* @param {string|undefined} initiator - The jid of the initiator of the update.
212221
*/
213-
_emitSessionUpdate(session, initiator) {
222+
_emitSessionUpdate(session: JibriSession, initiator?: string): void {
214223
this._chatRoom.eventEmitter.emit(
215224
XMPPEvents.RECORDER_STATE_CHANGED, session, initiator);
216225
}
@@ -222,7 +231,7 @@ class RecordingManager {
222231
* @param {Node} presence - An XMPP presence update.
223232
* @returns {void}
224233
*/
225-
_handleFocusPresence(presence) {
234+
_handleFocusPresence(presence: Node): void {
226235
const jibriStatus = recordingXMLUtils.getFocusRecordingUpdate(presence);
227236

228237
if (!jibriStatus) {
@@ -280,7 +289,7 @@ class RecordingManager {
280289
* @param {Node} presence - An XMPP presence update.
281290
* @returns {void}
282291
*/
283-
_handleJibriPresence(presence) {
292+
_handleJibriPresence(presence: any): void {
284293
const { liveStreamViewURL, mode, sessionID }
285294
= recordingXMLUtils.getHiddenDomainUpdate(presence);
286295

0 commit comments

Comments
 (0)
Please sign in to comment.