Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/stream_video/lib/src/call/call.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2149,6 +2149,9 @@ class Call {
Result.error('Session is null');

if (result.isSuccess) {
await _streamVideo.pushNotificationManager
?.setCallMutedByCid(callCid.value, !enabled);

_stateManager.participantSetMicrophoneEnabled(
enabled: enabled,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ abstract class PushNotificationManager {
/// [uuid] is the unique identifier for the call.
Future<void> setCallConnected(String uuid);

/// Sets call as muted/unmuted (iOS only).
Future<void> setCallMutedByCid(String cid, bool isMuted);

/// Retrieves a list of active calls.
Future<List<CallData>> activeCalls();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ class _StreamCallContainerState extends State<StreamCallContainer> {
_callState = callState;
});
if (callState.status.isDisconnected) {
_callStateSubscription?.cancel();
if (widget.onCallDisconnected != null) {
final disconnectedStatus = callState.status as CallStatusDisconnected;
final disconnectedProperties = CallDisconnectedProperties(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,19 @@ class StreamVideoPushNotificationManager implements PushNotificationManager {
_idCallKit,
onCallEvent.listen(
(event) {
if (event is ActionCallIncoming) {
if (event is ActionCallToggleMute) {
{
_logger.d(() =>
'[onCallEvent] ActionCallToggleMute received: uuid=${event.uuid}, isMuted=${event.isMuted}');
final call = activeCall;
if (call != null) {
call.setMicrophoneEnabled(enabled: !event.isMuted);
} else {
_logger.w(
() => '[onCallEvent] Cannot toggle mute: no active call');
}
}
} else if (event is ActionCallIncoming) {
if (!client.isConnected) {
client.openConnection();
}
Expand Down Expand Up @@ -406,6 +418,21 @@ class StreamVideoPushNotificationManager implements PushNotificationManager {
}
}

@override
Future<void> setCallMutedByCid(String cid, bool isMuted) async {
final activeCalls = await this.activeCalls();
final calls = activeCalls
.where((call) => call.callCid == cid && call.uuid != null)
.toList();

for (final call in calls) {
// Silence events to avoid infinite loop
FlutterCallkitIncoming.silenceEvents();
await FlutterCallkitIncoming.muteCall(call.uuid!, isMuted: isMuted);
FlutterCallkitIncoming.unsilenceEvents();
}
}

@override
Future<String?> getDevicePushTokenVoIP() async {
if (CurrentPlatform.isIos) {
Expand Down