@@ -112,6 +112,7 @@ export class GroupCall extends EventEmitter {
112
112
public activeSpeakerInterval = 1000 ;
113
113
public retryCallInterval = 5000 ;
114
114
public participantTimeout = 1000 * 15 ;
115
+ public pttMaxTransmitTime = 1000 * 20 ;
115
116
116
117
public state = GroupCallState . LocalCallFeedUninitialized ;
117
118
public activeSpeaker ?: string ; // userId
@@ -129,6 +130,7 @@ export class GroupCall extends EventEmitter {
129
130
private retryCallLoopTimeout ?: number ;
130
131
private retryCallCounts : Map < string , number > = new Map ( ) ;
131
132
private reEmitter : ReEmitter ;
133
+ private transmitTimer : number | null = null ;
132
134
133
135
constructor (
134
136
private client : MatrixClient ,
@@ -325,17 +327,32 @@ export class GroupCall extends EventEmitter {
325
327
this . retryCallCounts . clear ( ) ;
326
328
clearTimeout ( this . retryCallLoopTimeout ) ;
327
329
330
+ if ( this . transmitTimer !== null ) {
331
+ clearTimeout ( this . transmitTimer ) ;
332
+ this . transmitTimer = null ;
333
+ }
334
+
328
335
this . client . removeListener ( "Call.incoming" , this . onIncomingCall ) ;
329
336
}
330
337
331
338
public leave ( ) {
339
+ if ( this . transmitTimer !== null ) {
340
+ clearTimeout ( this . transmitTimer ) ;
341
+ this . transmitTimer = null ;
342
+ }
343
+
332
344
this . dispose ( ) ;
333
345
this . setState ( GroupCallState . LocalCallFeedUninitialized ) ;
334
346
}
335
347
336
348
public async terminate ( emitStateEvent = true ) {
337
349
this . dispose ( ) ;
338
350
351
+ if ( this . transmitTimer !== null ) {
352
+ clearTimeout ( this . transmitTimer ) ;
353
+ this . transmitTimer = null ;
354
+ }
355
+
339
356
this . participants = [ ] ;
340
357
this . client . removeListener (
341
358
"RoomState.members" ,
@@ -389,6 +406,18 @@ export class GroupCall extends EventEmitter {
389
406
return false ;
390
407
}
391
408
409
+ // set a timer for the maximum transmit time on PTT calls
410
+ if ( this . isPtt ) {
411
+ if ( ! muted && this . isMicrophoneMuted ( ) ) {
412
+ this . transmitTimer = setTimeout ( ( ) => {
413
+ this . setMicrophoneMuted ( true ) ;
414
+ } , this . pttMaxTransmitTime ) ;
415
+ } else if ( muted && ! this . isMicrophoneMuted ( ) ) {
416
+ clearTimeout ( this . transmitTimer ) ;
417
+ this . transmitTimer = null ;
418
+ }
419
+ }
420
+
392
421
if ( this . localCallFeed ) {
393
422
logger . log ( `groupCall ${ this . groupCallId } setMicrophoneMuted stream ${
394
423
this . localCallFeed . stream . id } muted ${ muted } `) ;
0 commit comments