Skip to content
Merged
2 changes: 2 additions & 0 deletions dogfooding/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
<uses-permission android:name="android.permission.BLUETOOTH" android:maxSdkVersion="30"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" android:maxSdkVersion="30"/>
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.READ_CALL_STATE" />

<application
android:label="Stream Video Calls (Flutter)"
Expand Down
14 changes: 14 additions & 0 deletions dogfooding/lib/app/app_content.dart
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ class _StreamDogFoodingAppContentState
});

_tryConsumingIncomingCallFromTerminatedState();
_handleMobileAudioInterruptions();
}

void initPushNotificationManagerIfAvailable() {
Expand All @@ -120,6 +121,19 @@ class _StreamDogFoodingAppContentState
_observeFcmMessages();
}

void _handleMobileAudioInterruptions() {
if (!CurrentPlatform.isMobile) return;

RtcMediaDeviceNotifier.instance.handleCallInterruptionCallbacks(
onInterruptionStart: () {
StreamVideo.instance.activeCall?.setMicrophoneEnabled(enabled: false);
},
onInterruptionEnd: () {
StreamVideo.instance.activeCall?.setMicrophoneEnabled(enabled: true);
},
);
}

void _tryConsumingIncomingCallFromTerminatedState() {
if (!CurrentPlatform.isAndroid) return;

Expand Down
1 change: 1 addition & 0 deletions dogfooding/lib/screens/home_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class _HomeScreenState extends State<HomeScreen> {
Permission.notification,
Permission.camera,
Permission.microphone,
if (CurrentPlatform.isAndroid) Permission.phone,
].request();

StreamVideoPushNotificationManager.ensureFullScreenIntentPermission();
Expand Down
2 changes: 1 addition & 1 deletion melos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ command:
device_info_plus: ">=10.1.2 <12.0.0"
share_plus: ^11.0.0
stream_chat_flutter: ^9.8.0
stream_webrtc_flutter: ^1.0.6
stream_webrtc_flutter: ^1.0.7

scripts:
postclean:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@
import '../../utils/result.dart';
import 'rtc_media_device.dart';

abstract class InterruptionEvent {}

class InterruptionBeginEvent extends InterruptionEvent {}

class InterruptionEndEvent extends InterruptionEvent {}

class RtcMediaDeviceNotifier {
RtcMediaDeviceNotifier._internal() {
// Debounce call the onDeviceChange callback.
Expand All @@ -22,6 +28,43 @@
Stream<List<RtcMediaDevice>> get onDeviceChange => _devicesController.stream;
final _devicesController = BehaviorSubject<List<RtcMediaDevice>>();

/// Allows to handle call interruption callbacks.
/// [onInterruptionStart] is called when the call interruption begins.
/// [onInterruptionEnd] is called when the call interruption ends.
/// [androidInterruptionSource] specifies the source of the interruption on Android.
///
/// On iOS, interruptions can occur due to:
/// - Incoming phone calls
/// - Siri activation
/// - Alarm or timer sounds
/// - Audio from other apps taking over (e.g., voice memo, navigation)
///
/// On Android, interruption sources depend on the [androidInterruptionSource]:
/// - With audioFocus:
/// - Other media apps interrupting (e.g., Spotify)
/// - Assistant voice prompts (e.g., Google Assistant)
/// - Alarms and notifications
/// - With telephony:
/// - Phone calls (requires READ_PHONE_STATE permission)
///
/// This method allows you to pause the call, mute the audio, or perform any other
/// necessary actions when interruptions occur.
///
/// For more details on handling call interruptions, refer to the
/// [Stream Video documentation](https://getstream.io/video/docs/flutter/advanced/handling-system-audio-interruptions/).
Future<void> handleCallInterruptionCallbacks({

Check warning on line 55 in packages/stream_video/lib/src/webrtc/rtc_media_device/rtc_media_device_notifier.dart

View check run for this annotation

Codecov / codecov/patch

packages/stream_video/lib/src/webrtc/rtc_media_device/rtc_media_device_notifier.dart#L55

Added line #L55 was not covered by tests
void Function()? onInterruptionStart,
void Function()? onInterruptionEnd,
rtc.AndroidInterruptionSource androidInterruptionSource =
rtc.AndroidInterruptionSource.audioFocusAndTelephony,
}) {
return rtc.handleCallInterruptionCallbacks(

Check warning on line 61 in packages/stream_video/lib/src/webrtc/rtc_media_device/rtc_media_device_notifier.dart

View check run for this annotation

Codecov / codecov/patch

packages/stream_video/lib/src/webrtc/rtc_media_device/rtc_media_device_notifier.dart#L61

Added line #L61 was not covered by tests
onInterruptionStart,
onInterruptionEnd,
androidInterruptionSource: androidInterruptionSource,
);
}

Future<void> _onDeviceChange(_) async {
final devicesResult = await enumerateDevices();
final devices = devicesResult.getDataOrNull();
Expand Down
2 changes: 1 addition & 1 deletion packages/stream_video/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ dependencies:
rxdart: ^0.28.0
sdp_transform: ^0.3.2
state_notifier: ^1.0.0
stream_webrtc_flutter: ^1.0.6
stream_webrtc_flutter: ^1.0.7
synchronized: ^3.1.0
system_info2: ^4.0.0
tart: ^0.5.1
Expand Down
2 changes: 1 addition & 1 deletion packages/stream_video_flutter/example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ dependencies:
stream_video: ^0.9.5
stream_video_flutter: ^0.9.5
stream_video_push_notification: ^0.9.5
stream_webrtc_flutter: ^1.0.6
stream_webrtc_flutter: ^1.0.7

dependency_overrides:
stream_video:
Expand Down
4 changes: 2 additions & 2 deletions packages/stream_video_flutter/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ dependencies:
plugin_platform_interface: ^2.1.8
rate_limiter: ^1.0.0
stream_video: ^0.9.5
stream_webrtc_flutter: ^1.0.6
stream_webrtc_flutter: ^1.0.7
visibility_detector: ^0.4.0+2

dev_dependencies:
alchemist: '>=0.11.0 <0.13.0'
alchemist: ">=0.11.0 <0.13.0"
flutter_test:
sdk: flutter
mocktail: ^1.0.0
Expand Down
2 changes: 1 addition & 1 deletion packages/stream_video_noise_cancellation/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ dependencies:
sdk: flutter
plugin_platform_interface: ^2.0.2
stream_video: ^0.9.5
stream_webrtc_flutter: ^1.0.6
stream_webrtc_flutter: ^1.0.7

dev_dependencies:
flutter_test:
Expand Down
2 changes: 1 addition & 1 deletion packages/stream_video_push_notification/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ dependencies:
stream_video: ^0.9.5
uuid: ^4.2.1
shared_preferences: ^2.3.2
stream_webrtc_flutter: ^1.0.6
stream_webrtc_flutter: ^1.0.7

dev_dependencies:
build_runner: ^2.4.4
Expand Down