11import { EventEmitter } from "node:events" ;
22
33import { getFolder , type Folder } from "#src/services/resources.ts" ;
4- import { RecordingTask } from "#src/models/recording_task.ts" ;
4+ import { RecordingTask , type RecordingParameters } from "#src/models/recording_task.ts" ;
55import { Logger } from "#src/utils/utils.ts" ;
66
77import type { Channel } from "#src/models/channel" ;
@@ -108,7 +108,6 @@ export class Recorder extends EventEmitter {
108108 this . isRecording = false ;
109109 this . isTranscribing = false ;
110110 this . state = RECORDER_STATE . STOPPING ;
111- // remove all listener from the channel
112111 // TODO name
113112 const name = "test-folder-name" ;
114113 const results = await this . stopTasks ( ) ;
@@ -130,14 +129,7 @@ export class Recorder extends EventEmitter {
130129 if ( ! session ) {
131130 return ;
132131 }
133- this . tasks . set (
134- session . id ,
135- new RecordingTask ( session , {
136- audio : this . isRecording || this . isTranscribing ,
137- camera : this . isRecording ,
138- screen : this . isRecording
139- } )
140- ) ;
132+ this . tasks . set ( session . id , new RecordingTask ( session , this . getTaskParameters ( ) ) ) ;
141133 }
142134
143135 private onSessionLeave ( id : SessionId ) {
@@ -173,10 +165,9 @@ export class Recorder extends EventEmitter {
173165 }
174166
175167 private async update ( ) {
168+ const params = this . getTaskParameters ( ) ;
176169 for ( const task of this . tasks . values ( ) ) {
177- task . audio = this . isRecording || this . isTranscribing ;
178- task . camera = this . isRecording ;
179- task . screen = this . isRecording ;
170+ Object . assign ( task , params ) ;
180171 }
181172 }
182173
@@ -185,10 +176,7 @@ export class Recorder extends EventEmitter {
185176 this . folder = getFolder ( ) ;
186177 logger . trace ( `TO IMPLEMENT: recording channel ${ this . channel . name } ` ) ;
187178 for ( const [ sessionId , session ] of this . channel . sessions ) {
188- this . tasks . set (
189- sessionId ,
190- new RecordingTask ( session , { audio : true , camera : true , screen : true } )
191- ) ;
179+ this . tasks . set ( sessionId , new RecordingTask ( session , this . getTaskParameters ( ) ) ) ;
192180 }
193181 this . channel . on ( "sessionJoin" , this . onSessionJoin ) ;
194182 this . channel . on ( "sessionLeave" , this . onSessionLeave ) ;
@@ -202,4 +190,12 @@ export class Recorder extends EventEmitter {
202190 this . tasks . clear ( ) ;
203191 return Promise . allSettled ( proms ) ;
204192 }
193+
194+ private getTaskParameters ( ) : RecordingParameters {
195+ return {
196+ audio : this . isRecording || this . isTranscribing ,
197+ camera : this . isRecording ,
198+ screen : this . isRecording
199+ } ;
200+ }
205201}
0 commit comments