Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
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.10
stream_webrtc_flutter: ^1.0.11
stream_video: ^0.10.2
stream_video_flutter: ^0.10.2
stream_video_noise_cancellation: ^0.10.2
Expand Down
5 changes: 5 additions & 0 deletions packages/stream_video/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## Unregistered

✅ Added
* Added option to configure android audio configuration when initializing `StreamVideo` instance by providing `androidAudioConfiguration` to `StreamVideoOptions`.

## 0.10.2

✅ Added
Expand Down
15 changes: 15 additions & 0 deletions packages/stream_video/lib/src/call/call.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2640,6 +2640,21 @@ class Call {
await setAudioInputDevice(_connectOptions.audioInputDevice!);
}

if (enabled && CurrentPlatform.isAndroid) {
try {
if (_streamVideo.options.androidAudioConfiguration != null) {
await rtc.Helper.setAndroidAudioConfiguration(
_streamVideo.options.androidAudioConfiguration!,
);
}
} catch (e) {
_logger.w(
() =>
'[setMicrophoneEnabled] Failed to set Android audio configuration: $e',
);
}
}

_sfuStatsTimers.add(
Future<void>.delayed(const Duration(seconds: 3)).then((_) {
if (result.getDataOrNull()!.mediaTrack.enabled) {
Expand Down
17 changes: 17 additions & 0 deletions packages/stream_video/lib/src/call/session/call_session.dart
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ class CallSession extends Disposable {
this.clientPublishOptions,
this.joinResponseTimeout = const Duration(seconds: 5),
}) : _tracer = tracer,
_streamVideo = streamVideo,
sfuClient = SfuClient(
baseUrl: config.sfuUrl,
sfuToken: config.sfuToken,
Expand Down Expand Up @@ -115,6 +116,7 @@ class CallSession extends Disposable {
final InternetConnection networkMonitor;
final StatsOptions statsOptions;
final Tracer _tracer;
final StreamVideo _streamVideo;

final Duration joinResponseTimeout;

Expand Down Expand Up @@ -889,6 +891,21 @@ class CallSession extends Disposable {
) async {
_logger.d(() => '[onRemoteTrackReceived] remoteTrack: $remoteTrack');

if (CurrentPlatform.isAndroid &&
remoteTrack.isAudioTrack &&
_streamVideo.options.androidAudioConfiguration != null) {
try {
await rtc.Helper.setAndroidAudioConfiguration(
_streamVideo.options.androidAudioConfiguration!,
);
} catch (e) {
_logger.w(
() =>
'[onRemoteTrackReceived] Failed to apply Android audio configuration: $e',
);
}
}

// Start the track.
await remoteTrack.start();

Expand Down
14 changes: 14 additions & 0 deletions packages/stream_video/lib/src/stream_video.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import 'package:internet_connection_checker_plus/internet_connection_checker_plu
import 'package:meta/meta.dart';
import 'package:package_info_plus/package_info_plus.dart';
import 'package:rxdart/rxdart.dart';
import 'package:stream_webrtc_flutter/stream_webrtc_flutter.dart' as rtc;
import 'package:uuid/uuid.dart';

import '../globals.dart';
Expand Down Expand Up @@ -175,6 +176,16 @@ class StreamVideo extends Disposable {

_state.user.value = user;

unawaited(
rtc.WebRTC.initialize(
options: {
if (CurrentPlatform.isAndroid)
'androidAudioConfiguration':
options.androidAudioConfiguration!.toMap(),
},
),
);

final tokenProvider = switch (user.type) {
UserType.authenticated => TokenProvider.from(
userToken?.let(UserToken.jwt),
Expand Down Expand Up @@ -1195,6 +1206,7 @@ class StreamVideoOptions {
this.keepConnectionsAliveWhenInBackground = false,
this.networkMonitorSettings = const NetworkMonitorSettings(),
this.allowMultipleActiveCalls = false,
this.androidAudioConfiguration,
});

final String coordinatorRpcUrl;
Expand Down Expand Up @@ -1222,4 +1234,6 @@ class StreamVideoOptions {

/// Returns the current [NetworkMonitorSettings].
final NetworkMonitorSettings networkMonitorSettings;

final rtc.AndroidAudioConfiguration? androidAudioConfiguration;
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ class RtcMediaDeviceNotifier {
/// [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.
/// [androidAudioAttributesUsageType] and [androidAudioAttributesContentType] allow you to specify
/// the audio attributes that will be used when requesting audio focus.
///
/// On iOS, interruptions can occur due to:
/// - Incoming phone calls
Expand All @@ -57,11 +59,15 @@ class RtcMediaDeviceNotifier {
void Function()? onInterruptionEnd,
rtc.AndroidInterruptionSource androidInterruptionSource =
rtc.AndroidInterruptionSource.audioFocusAndTelephony,
rtc.AndroidAudioAttributesUsageType? androidAudioAttributesUsageType,
rtc.AndroidAudioAttributesContentType? androidAudioAttributesContentType,
}) {
return rtc.handleCallInterruptionCallbacks(
onInterruptionStart,
onInterruptionEnd,
androidInterruptionSource: androidInterruptionSource,
androidAudioAttributesUsageType: androidAudioAttributesUsageType,
androidAudioAttributesContentType: androidAudioAttributesContentType,
);
}

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.10
stream_webrtc_flutter: ^1.0.11
synchronized: ^3.1.0
system_info2: ^4.0.0
tart: ^0.5.1
Expand Down
5 changes: 5 additions & 0 deletions packages/stream_video_flutter/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## Unregistered

✅ Added
* Added option to configure android audio configuration when initializing `StreamVideo` instance by providing `androidAudioConfiguration` to `StreamVideoOptions`.

## 0.10.2

✅ Added
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.10.2
stream_video_flutter: ^0.10.2
stream_video_push_notification: ^0.10.2
stream_webrtc_flutter: ^1.0.10
stream_webrtc_flutter: ^1.0.11

dependency_overrides:
stream_video:
Expand Down
2 changes: 1 addition & 1 deletion packages/stream_video_flutter/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ dependencies:
plugin_platform_interface: ^2.1.8
rate_limiter: ^1.0.0
stream_video: ^0.10.2
stream_webrtc_flutter: ^1.0.10
stream_webrtc_flutter: ^1.0.11
visibility_detector: ^0.4.0+2

dev_dependencies:
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.10.2
stream_webrtc_flutter: ^1.0.10
stream_webrtc_flutter: ^1.0.11

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.10.2
uuid: ^4.2.1
shared_preferences: ^2.3.2
stream_webrtc_flutter: ^1.0.10
stream_webrtc_flutter: ^1.0.11

dev_dependencies:
build_runner: ^2.4.4
Expand Down
Loading