File tree Expand file tree Collapse file tree 4 files changed +35
-1
lines changed
stream_video_flutter/lib/src/call_screen
stream_video_push_notification/lib/src Expand file tree Collapse file tree 4 files changed +35
-1
lines changed Original file line number Diff line number Diff line change @@ -2156,6 +2156,9 @@ class Call {
21562156 Result .error ('Session is null' );
21572157
21582158 if (result.isSuccess) {
2159+ await _streamVideo.pushNotificationManager
2160+ ? .setCallMutedByCid (callCid.value, ! enabled);
2161+
21592162 _stateManager.participantSetMicrophoneEnabled (
21602163 enabled: enabled,
21612164 );
Original file line number Diff line number Diff line change @@ -107,6 +107,9 @@ abstract class PushNotificationManager {
107107 /// [uuid] is the unique identifier for the call.
108108 Future <void > setCallConnected (String uuid);
109109
110+ /// Sets call as muted/unmuted (iOS only).
111+ Future <void > setCallMutedByCid (String cid, bool isMuted);
112+
110113 /// Retrieves a list of active calls.
111114 Future <List <CallData >> activeCalls ();
112115
Original file line number Diff line number Diff line change @@ -131,6 +131,7 @@ class _StreamCallContainerState extends State<StreamCallContainer> {
131131 _callState = callState;
132132 });
133133 if (callState.status.isDisconnected) {
134+ _callStateSubscription? .cancel ();
134135 if (widget.onCallDisconnected != null ) {
135136 final disconnectedStatus = callState.status as CallStatusDisconnected ;
136137 final disconnectedProperties = CallDisconnectedProperties (
Original file line number Diff line number Diff line change @@ -176,7 +176,19 @@ class StreamVideoPushNotificationManager implements PushNotificationManager {
176176 _idCallKit,
177177 onCallEvent.listen (
178178 (event) {
179- if (event is ActionCallIncoming ) {
179+ if (event is ActionCallToggleMute ) {
180+ {
181+ _logger.d (() =>
182+ '[onCallEvent] ActionCallToggleMute received: uuid=${event .uuid }, isMuted=${event .isMuted }' );
183+ final call = activeCall;
184+ if (call != null ) {
185+ call.setMicrophoneEnabled (enabled: ! event.isMuted);
186+ } else {
187+ _logger.w (
188+ () => '[onCallEvent] Cannot toggle mute: no active call' );
189+ }
190+ }
191+ } else if (event is ActionCallIncoming ) {
180192 if (! client.isConnected) {
181193 client.openConnection ();
182194 }
@@ -406,6 +418,21 @@ class StreamVideoPushNotificationManager implements PushNotificationManager {
406418 }
407419 }
408420
421+ @override
422+ Future <void > setCallMutedByCid (String cid, bool isMuted) async {
423+ final activeCalls = await this .activeCalls ();
424+ final calls = activeCalls
425+ .where ((call) => call.callCid == cid && call.uuid != null )
426+ .toList ();
427+
428+ for (final call in calls) {
429+ // Silence events to avoid infinite loop
430+ FlutterCallkitIncoming .silenceEvents ();
431+ await FlutterCallkitIncoming .muteCall (call.uuid! , isMuted: isMuted);
432+ FlutterCallkitIncoming .unsilenceEvents ();
433+ }
434+ }
435+
409436 @override
410437 Future <String ?> getDevicePushTokenVoIP () async {
411438 if (CurrentPlatform .isIos) {
You can’t perform that action at this time.
0 commit comments