@@ -553,7 +553,17 @@ export class GroupCall extends TypedEventEmitter<
553
553
// hasAudioDevice can block indefinitely if the window has lost focus,
554
554
// and it doesn't make much sense to keep a device from being muted, so
555
555
// we always allow muted = true changes to go through
556
- if ( ! muted && ! ( await this . client . getMediaHandler ( ) . hasAudioDevice ( ) ) ) {
556
+ const hasAudioDevice = await this . client
557
+ . getMediaHandler ( )
558
+ . hasAudioDevice ( )
559
+ . catch ( ( _ ) => {
560
+ logger . log (
561
+ `GroupCall ${ this . groupCallId } setMicrophoneMuted() no audio device or permission for audio device, muted=${ muted } ` ,
562
+ ) ;
563
+ return false ;
564
+ } ) ;
565
+
566
+ if ( ! muted && ! hasAudioDevice ) {
557
567
return false ;
558
568
}
559
569
@@ -592,6 +602,22 @@ export class GroupCall extends TypedEventEmitter<
592
602
logger . log (
593
603
`GroupCall ${ this . groupCallId } setMicrophoneMuted() (streamId=${ this . localCallFeed . stream . id } , muted=${ muted } )` ,
594
604
) ;
605
+
606
+ // We needed this here to avoid an error in case user join a call without a device.
607
+ if ( ! muted ) {
608
+ const stream = await this . client
609
+ . getMediaHandler ( )
610
+ . getUserMediaStream ( true , ! this . localCallFeed . isVideoMuted ( ) )
611
+ . catch ( ( _ ) => null ) ;
612
+ if ( stream === null ) {
613
+ // if case permission denied to get a stream stop this here
614
+ logger . log (
615
+ `GroupCall ${ this . groupCallId } setMicrophoneMuted() no device or permission to receive local stream, muted=${ muted } ` ,
616
+ ) ;
617
+ return false ;
618
+ }
619
+ }
620
+
595
621
this . localCallFeed . setAudioVideoMuted ( muted , null ) ;
596
622
// I don't believe its actually necessary to enable these tracks: they
597
623
// are the one on the GroupCall's own CallFeed and are cloned before being
@@ -617,15 +643,20 @@ export class GroupCall extends TypedEventEmitter<
617
643
* @returns Whether muting/unmuting was successful
618
644
*/
619
645
public async setLocalVideoMuted ( muted : boolean ) : Promise < boolean > {
620
- // Because we need a Local Call Feed to establish a call connection, we avoid muting video in case of empty
621
- // video track. In this way we go sure if a client implements muting we don't raise an error.
622
- if ( this . localCallFeed ?. stream . getVideoTracks ( ) . length === 0 ) {
623
- return false ;
624
- }
625
646
// hasAudioDevice can block indefinitely if the window has lost focus,
626
647
// and it doesn't make much sense to keep a device from being muted, so
627
648
// we always allow muted = true changes to go through
628
- if ( ! muted && ! ( await this . client . getMediaHandler ( ) . hasVideoDevice ( ) ) ) {
649
+ const hasVideoDevice = await this . client
650
+ . getMediaHandler ( )
651
+ . hasVideoDevice ( )
652
+ . catch ( ( _ ) => {
653
+ logger . log (
654
+ `GroupCall ${ this . groupCallId } setLocalVideoMuted() no video device or permission for video device, muted=${ muted } ` ,
655
+ ) ;
656
+ return false ;
657
+ } ) ;
658
+
659
+ if ( ! muted && ! hasVideoDevice ) {
629
660
return false ;
630
661
}
631
662
@@ -634,7 +665,17 @@ export class GroupCall extends TypedEventEmitter<
634
665
`GroupCall ${ this . groupCallId } setLocalVideoMuted() (stream=${ this . localCallFeed . stream . id } , muted=${ muted } )` ,
635
666
) ;
636
667
637
- const stream = await this . client . getMediaHandler ( ) . getUserMediaStream ( true , ! muted ) ;
668
+ const stream = await this . client
669
+ . getMediaHandler ( )
670
+ . getUserMediaStream ( true , ! muted )
671
+ . catch ( ( _ ) => null ) ;
672
+ if ( stream === null ) {
673
+ // if case permission denied to get a stream stop this here
674
+ logger . log (
675
+ `GroupCall ${ this . groupCallId } setLocalVideoMuted() no device or permission to receive local stream, muted=${ muted } ` ,
676
+ ) ;
677
+ return false ;
678
+ }
638
679
await this . updateLocalUsermediaStream ( stream ) ;
639
680
this . localCallFeed . setAudioVideoMuted ( null , muted ) ;
640
681
setTracksEnabled ( this . localCallFeed . stream . getVideoTracks ( ) , ! muted ) ;
0 commit comments