-
Notifications
You must be signed in to change notification settings - Fork 25
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
[Enhancement]Improve AudioSession management #639
Merged
ipavlidakis
merged 28 commits into
develop
from
enhancement/allow-muting-audio-during-call
Feb 13, 2025
Merged
[Enhancement]Improve AudioSession management #639
ipavlidakis
merged 28 commits into
develop
from
enhancement/allow-muting-audio-during-call
Feb 13, 2025
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SDK Size
|
f0bfe60
to
2b2d1f0
Compare
194ea1a
to
8c9003e
Compare
926ef4b
to
8590eb0
Compare
martinmitrevski
approved these changes
Feb 13, 2025
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.
Things are looking great ✅ Just one question, and we also need to see the failed tests.
Sources/StreamVideo/Utils/AudioSession/Policies/DefaultAudioSessionPolicy.swift
Show resolved
Hide resolved
eb35747
to
0ad953f
Compare
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
🔗 Issue Links
Tickets: [1, 2]
🎯 Goal
Provide a way for users to move audio volume to 0 using the device's physical buttons or the ControlCentre.
📝 Summary
We are now driving AudioSession configurations based on CallSettings and OwnCapabilities. However, due to the way that AVAudioSession stores volume profiles per category, we are forced to introduce a way to customise the functionality based on the use-cases. Spefically:
Viewer
, in your code like below:🛠 Implementation
During callSettings and ownCapabilities changes, the internal AudioSession component will ask the provided
AudioSessionPolicy
to provide the desired AVAudioSession configuration. It's expected that the configuration returned from theAudioSessionPolicy
should be a valid change. Each policy works differently depending on the input CallSettings and OwnCapabilities:DefaultAudioSessionPolicy
:This policy is the one that
Call
objects use by default. The policy will always return the following configuration: category:.playAndRecord
and categoryOptions: .allowBluetooth, .allowBluetoothA2DP, .allowAirPlay. While for mode it will toggle between.videoChat
and.voiceChat
depending on thespeakerOn
value on CallSettings. This policy doesn't allow zeroing the volume.OwnCapabilitiesAudioSessionPolicy
:The policy relies on both the provide
CallSettings
andOwnCapabilities
to produce a valid AudioSessionConfiguration. The rules examined are the following:if the user has no capability to
sendAudio
it always returns category:.playback
, mode:.default
, categoryOptions: [], ignoring theCallSettings
.If the user has capability to
sendAudio
:CallSettings.audioOn == true
or (CallSettings.speakerOn == true
and the device is an iPhone): It returnscategory:. playAndRecord
. Mode and and CategoryOptions are being calculated similarly to theDefaultAudioSessionPolicy
.In any other case it returns:
category: .playback
similarly on what it would return if the user had no capability tosendAudio
.🧪 Manual Testing Notes
AudioSession Policy
debug option to try different policies☑️ Contributor Checklist