-
Notifications
You must be signed in to change notification settings - Fork 46
feat(llc): option to set android audio configuration to WebRTC #1046
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughAdds an Android-specific audio configuration option (StreamVideoOptions.androidAudioConfiguration), wires it into StreamVideo initialization and runtime paths (microphone enabling and remote track start), extends interruption callback signatures for Android audio attributes, and bumps stream_webrtc_flutter dependency and changelogs. Changes
Sequence Diagram(s)sequenceDiagram
participant App
participant StreamVideo
participant WebRTC as rtc.WebRTC
participant Helper as rtc.Helper
App->>StreamVideo: new StreamVideo(options)
alt Android && options.androidAudioConfiguration
StreamVideo->>WebRTC: initialize({ androidAudioConfiguration })
else
StreamVideo->>WebRTC: initialize({})
end
App->>StreamVideo: enableMicrophone()
StreamVideo-->>App: mic enabled
alt Android && config provided
StreamVideo->>Helper: setAndroidAudioConfiguration(config)
Helper-->>StreamVideo: success / throws (logged)
end
sequenceDiagram
participant RemotePeer
participant CallSession
participant Helper as rtc.Helper
participant RemoteTrack
RemotePeer-->>CallSession: onRemoteTrackReceived(track)
alt Android && streamVideo.options.androidAudioConfiguration
CallSession->>Helper: setAndroidAudioConfiguration(config)
end
CallSession->>RemoteTrack: start()
sequenceDiagram
participant App
participant Notifier as RtcMediaDeviceNotifier
participant RTC as rtc
App->>Notifier: handleCallInterruptionCallbacks(onStart,onEnd, usage?, content?)
Notifier->>RTC: handleCallInterruptionCallbacks(..., usage?, content?)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Assessment against linked issues
Out-of-scope changes
Possibly related PRs
Suggested reviewers
Poem
Tip 🔌 Remote MCP (Model Context Protocol) integration is now available!Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats. 📜 Recent review detailsConfiguration used: CodeRabbit UI 💡 Knowledge Base configuration:
You can enable these settings in your CodeRabbit configuration. 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
✨ Finishing Touches🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🧹 Nitpick comments (5)
packages/stream_video_flutter/CHANGELOG.md (1)
3-5: Wording/capitalization nit in the Added entryTweak phrasing to avoid repetition and capitalize Android.
Apply this diff:
-* Added option to configure android audio configuration when initializing `StreamVideo` instance by providing `androidAudioConfiguration` to `StreamVideoOptions`. +* Added an option to configure Android audio via `androidAudioConfiguration` in `StreamVideoOptions` when initializing a `StreamVideo` instance.packages/stream_video/CHANGELOG.md (1)
3-5: Wording/capitalization nit in the Added entryMirror the improved phrasing here as well.
Apply this diff:
-* Added option to configure android audio configuration when initializing `StreamVideo` instance by providing `androidAudioConfiguration` to `StreamVideoOptions`. +* Added an option to configure Android audio via `androidAudioConfiguration` in `StreamVideoOptions` when initializing a `StreamVideo` instance.packages/stream_video/lib/src/webrtc/rtc_media_device/rtc_media_device_notifier.dart (1)
35-37: Clarify platform scope in docs for new Android-only parametersThese two parameters are Android-only. Make that explicit in the doc comment to reduce confusion for iOS/Web users.
Apply this diff to the doc lines:
- /// [androidAudioAttributesUsageType] and [androidAudioAttributesContentType] allow you to specify - /// the audio attributes that will be used when requesting audio focus. + /// [androidAudioAttributesUsageType] and [androidAudioAttributesContentType] (Android only) + /// allow you to specify the audio attributes that will be used when requesting audio focus.packages/stream_video/lib/src/call/call.dart (1)
2643-2656: Good safety: Android-only, try/catch wrapping for audio configurationApplying the Android audio configuration after enabling the microphone is reasonable and safely guarded.
Two optional improvements to consider:
- Order of operations: Depending on
stream_webrtc_fluttersemantics, setting the audio configuration before enabling the microphone may ensure audio focus/session attributes are active by the time the track is created. Verify with the plugin docs or a quick runtime check.- Deduplication: This configuration is also applied in CallSession._onRemoteTrackReceived and during WebRTC initialization. If the plugin treats this configuration as global, centralize to apply once per session/app to avoid redundant calls.
If you want, I can consolidate this into a single application point and open a follow-up PR.
packages/stream_video/lib/src/stream_video.dart (1)
1236-1236: Document the new public option and consider not exposing plugin types in the public API.
- Add a short doc comment to clarify platform scope and behavior.
- Architectural suggestion: exposing
rtc.AndroidAudioConfigurationin your public API couples this package to the rtc package’s types. Consider defining a StreamVideo-owned DTO (e.g.,AndroidAudioConfiguration) and mapping it to rtc types internally to reduce cross-package API coupling and future breakage risks.Proposed documentation:
- final rtc.AndroidAudioConfiguration? androidAudioConfiguration; + /// Android-only. When provided, configures the underlying WebRTC + /// AudioManager behavior (usage/content types, focus, mode, etc.). + /// If null, SDK defaults are used. + final rtc.AndroidAudioConfiguration? androidAudioConfiguration;
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
packages/stream_video/CHANGELOG.md(1 hunks)packages/stream_video/lib/src/call/call.dart(1 hunks)packages/stream_video/lib/src/call/session/call_session.dart(3 hunks)packages/stream_video/lib/src/stream_video.dart(4 hunks)packages/stream_video/lib/src/webrtc/rtc_media_device/rtc_media_device_notifier.dart(2 hunks)packages/stream_video_flutter/CHANGELOG.md(1 hunks)
🔇 Additional comments (5)
packages/stream_video/lib/src/webrtc/rtc_media_device/rtc_media_device_notifier.dart (1)
62-64: LGTM: Optional Android audio attributes are correctly plumbed throughThe new optional parameters are added to the public API and forwarded to
rtc.handleCallInterruptionCallbackswith named args. Backward compatible and clear.Also applies to: 69-71
packages/stream_video/lib/src/call/session/call_session.dart (2)
119-119: LGTM: Private field for StreamVideoStoring the
StreamVideoreference for later use is appropriate.
76-77: All CallSession constructors now includestreamVideo
- CallSessionFactory.makeCallSession returns
CallSession(..., streamVideo: streamVideo, …).- In
packages/stream_video/lib/src/call/call.dart,sessionFactory.makeCallSession(…, streamVideo: _streamVideo, …)is present.- Tests in
call_test_helpers.dartandcall_test.darthave been updated to pass or mock thestreamVideo:parameter.No further updates required.
packages/stream_video/lib/src/stream_video.dart (2)
10-10: Import looks correct and scoped via alias.The new rtc import is used for both initialization and the public type in options. No concerns here.
1207-1208: Constructor parameter addition looks good.Optional and defaulting to null is appropriate. No functional issues from this change alone.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
♻️ Duplicate comments (2)
packages/stream_video/lib/src/call/session/call_session.dart (1)
894-907: Apply Android audio configuration only once per session to avoid redundant callsGood platform/audio guards and error handling. However, this still executes on every remote audio track. Apply once per session and short-circuit subsequent calls.
Apply this diff to gate by a one-time flag and set it on success:
- if (CurrentPlatform.isAndroid && - remoteTrack.isAudioTrack && - _streamVideo.options.androidAudioConfiguration != null) { + if (CurrentPlatform.isAndroid && + remoteTrack.isAudioTrack && + !_androidAudioConfigApplied && + _streamVideo.options.androidAudioConfiguration != null) { try { await rtc.Helper.setAndroidAudioConfiguration( _streamVideo.options.androidAudioConfiguration!, ); + _androidAudioConfigApplied = true; } catch (e) { _logger.w( () => '[onRemoteTrackReceived] Failed to apply Android audio configuration: $e', ); } }Add this field to the class (near other fields):
// Tracks whether Android audio configuration has been applied this session. bool _androidAudioConfigApplied = false;Optional: Given the config is also applied during WebRTC.initialize and after enabling microphone, consider centralizing to a single application point (if plugin semantics allow) to avoid duplication.
packages/stream_video/lib/src/stream_video.dart (1)
179-187: Guard against null and platform; fix potential null-deref and handle unawaited Future
options.androidAudioConfiguration!.toMap()will throw when the option is null. Also, only initialize with the Android configuration on Android, and capture errors on the unawaited Future.Apply this diff:
- unawaited( - rtc.WebRTC.initialize( - options: { - if (CurrentPlatform.isAndroid) - 'androidAudioConfiguration': - options.androidAudioConfiguration!.toMap(), - }, - ), - ); + if (CurrentPlatform.isAndroid && options.androidAudioConfiguration != null) { + unawaited( + rtc.WebRTC.initialize( + options: { + 'androidAudioConfiguration': + options.androidAudioConfiguration!.toMap(), + }, + ).catchError((e, stk) { + _logger.w( + () => + '[init] WebRTC.initialize(androidAudioConfiguration) failed: $e', + ); + }), + ); + }Note: This keeps the initialization focused on Android when the option is present and avoids constructor-time crashes.
🧹 Nitpick comments (1)
packages/stream_video/lib/src/stream_video.dart (1)
209-210: Consider documenting the new constructor optionAdd a short dartdoc on the parameter to surface it in generated docs (mirroring the field’s doc once added).
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
packages/stream_video/lib/src/call/session/call_session.dart(3 hunks)packages/stream_video/lib/src/stream_video.dart(4 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
- GitHub Check: stream_video_push_notification
- GitHub Check: stream_video_noise_cancellation
- GitHub Check: stream_video
- GitHub Check: stream_video_screen_sharing
- GitHub Check: stream_video_flutter
- GitHub Check: analyze
- GitHub Check: build
- GitHub Check: analyze_legacy_version
🔇 Additional comments (4)
packages/stream_video/lib/src/call/session/call_session.dart (1)
76-76: LGTM: Injecting StreamVideo to access options is appropriateStoring the client reference for session-scoped option lookups is sensible and consistent with the surrounding design.
Also applies to: 119-119
packages/stream_video/lib/src/stream_video.dart (3)
10-10: LGTM: Importing stream_webrtc_flutter for Android audio config APIThe alias and import are correct for both WebRTC.initialize and configuration types.
1238-1239: LGTM: New public option is well-typed and scopedExposing
rtc.AndroidAudioConfiguration?on StreamVideoOptions aligns with the new feature.
179-187: Review Android audio configuration calls for duplicationI found three places where the Android audio configuration is applied:
• packages/stream_video/lib/src/stream_video.dart (≈L179)
- rtc.WebRTC.initialize(options: { androidAudioConfiguration: … })
• packages/stream_video/lib/src/call/call.dart (≈L2645)
- rtc.Helper.setAndroidAudioConfiguration after enabling the microphone
• packages/stream_video/lib/src/call/session/call_session.dart (≈L896)
- rtc.Helper.setAndroidAudioConfiguration before starting remote audio tracks
Please verify against the underlying WebRTC plugin docs whether all three invocations are required. If the plugin only needs a single configuration call (e.g. at initialize), consider consolidating these into one shared helper or removing redundant calls to reduce duplication.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
packages/stream_video_push_notification/pubspec.yaml (1)
27-27: Dependency bump to stream_webrtc_flutter ^1.0.11 looks correct.Matches the workspace-wide upgrade and aligns with the new Android audio configuration feature.
Consider running melos bootstrap afterwards to refresh lockfiles across the workspace to avoid version drift.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
melos.yaml(1 hunks)packages/stream_video/pubspec.yaml(1 hunks)packages/stream_video_flutter/example/pubspec.yaml(1 hunks)packages/stream_video_flutter/pubspec.yaml(1 hunks)packages/stream_video_noise_cancellation/pubspec.yaml(1 hunks)packages/stream_video_push_notification/pubspec.yaml(1 hunks)
✅ Files skipped from review due to trivial changes (1)
- packages/stream_video_noise_cancellation/pubspec.yaml
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
- GitHub Check: analyze
- GitHub Check: stream_video_noise_cancellation
- GitHub Check: stream_video_push_notification
- GitHub Check: build
- GitHub Check: stream_video_screen_sharing
- GitHub Check: stream_video_flutter
- GitHub Check: stream_video
🔇 Additional comments (4)
packages/stream_video/pubspec.yaml (1)
34-34: APIs present in stream_webrtc_flutter ^1.0.11
Verified that version 1.0.11 exposes both the AndroidAudioConfiguration class and the setAndroidAudioConfiguration method.
• lib/src/native/android/audio_configuration.dart –class AndroidAudioConfiguration& itssetAndroidAudioConfiguration
• lib/src/helper.dart –Helper.setAndroidAudioConfiguration
• android/src/main/java/.../MethodCallHandlerImpl – handles"setAndroidAudioConfiguration"No risk of missing-method errors; nothing further required here.
melos.yaml (1)
25-25: Allstream_webrtc_flutterversions are consistently set to ^1.0.11
Validation confirms melos.yaml (line 25) and every pubspec.yaml in the repository referencestream_webrtc_flutter: ^1.0.11. No further changes required.packages/stream_video_flutter/example/pubspec.yaml (1)
33-33: Example app dependency aligned to ^1.0.11.Keeps the example in sync with workspace versions; good to reduce incompatibility during demos and CI builds.
packages/stream_video_flutter/pubspec.yaml (1)
26-26: UI package dependency bump looks good and consistent.No additional changes required here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
packages/stream_video/test/src/core/client_state_test.dart (1)
18-19: Optional: Initialize the binding once to avoid redundant callsYou can initialize the binding once per group (or file) rather than per test. It’s idempotent, but this keeps setup lean.
- Remove the per-test initialization:
- TestWidgetsFlutterBinding.ensureInitialized(); -
- Add a one-time init in this group:
setUpAll(() { TestWidgetsFlutterBinding.ensureInitialized(); });
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
packages/stream_video/test/src/core/client_state_test.dart(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
- GitHub Check: analyze
- GitHub Check: build
- GitHub Check: stream_video_push_notification
- GitHub Check: stream_video_noise_cancellation
- GitHub Check: stream_video_screen_sharing
- GitHub Check: stream_video
- GitHub Check: stream_video_flutter
🔇 Additional comments (1)
packages/stream_video/test/src/core/client_state_test.dart (1)
18-19: Initialize Flutter test binding to prevent platform channel errors — good fixCalling TestWidgetsFlutterBinding.ensureInitialized() before constructing StreamVideo prevents binding-related errors when platform channels are touched (e.g., during WebRTC/Android audio configuration setup). This aligns with the new Android audio configuration path.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #1046 +/- ##
=====================================
Coverage 4.83% 4.83%
=====================================
Files 577 577
Lines 38802 38824 +22
=====================================
+ Hits 1875 1877 +2
- Misses 36927 36947 +20 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Resolves FLU-230
This PR provides an option to configure Android audio configuration when initializing the StreamVideo instance.
Summary by CodeRabbit
New Features
Documentation
Chores
Tests