twilio / twilio-video-ios

Programmable Video SDK by Twilio
http://twilio.com/video
Other
64 stars 22 forks source link

Audio of streaming lowering or going down when audioDevice is enabled #269

Open lrodriguezcds opened 5 months ago

lrodriguezcds commented 5 months ago

Before filing an issue please check that the issue is not already addressed by the following:

If this is an issue with the SDK itself, file it here. If this is an issue with the QuickStart apps, please use video-quickstart-ios.

Please ensure that you are not sharing any Personally Identifiable Information(PII) or sensitive account information (API keys, credentials, etc.) when reporting an issue.

Description

Hi everyone! I have an iOS app that is streaming content and also has a videoconferencing on the same screen. Both audios, the videoconferencing and the streaming should play simultaneously. However when the audioDevice of the videoconferencing is enabled the audio of the stream goes down to the point that users can practically not hear it.

I tried to configure AVAudioSession by providing a block to the DefaultAudioDevice and set the categories playback and playAndRecord with the mixWithOthers option with no luck

self.audioDevice.block = {
    do {
        DefaultAudioDevice.DefaultAVAudioSessionConfigurationBlock()

        let audioSession = AVAudioSession.sharedInstance()

        try audioSession.setCategory(.playback, mode: .default, options: [.mixWithOthers])

    } catch let error as NSError {
        print("Fail: \(error.localizedDescription)")
    }
}

self.audioDevice.block();

With this block of code video conferencing audio stops working, meaning I can't hear the participants even when audioDevice.enabled = true

self.audioDevice.block = {
    do {
        DefaultAudioDevice.DefaultAVAudioSessionConfigurationBlock()

        let audioSession = AVAudioSession.sharedInstance()
        try audioSession.setCategory(.playAndRecord, mode: .default, options: [.mixWithOthers])
    } catch let error as NSError {
        print("Fail: \(error.localizedDescription)")
    }
}

self.audioDevice.block();

With this block of code video conferencing audio works fine but the audio of the streaming gets lower when audioDevice is enabled.

I am enabling the audioDevice on the CXProviderDelegate delegates methods:

func provider(_ provider: CXProvider, didActivate audioSession: AVAudioSession) {
        audiDevice.isEnabled = true
 }
func provider(_ provider: CXProvider, didDeactivate audioSession: AVAudioSession) {
        audiDevice.isEnabled = false
 }

This lines of code are executed after AVAudioSession properties (categories, mode and options) where configured (shown above).

I am using pod 'TwilioVideo', '~> 4.6.2'.

I am not sure if the issue is related to the version of the TwilioVideo I am using or if the way of initializing and configuring the Twilio AudioDevice should be another one.

The issue we are experiencing, is that we need to avoid the audio of the stream content from decreasing when video conferencing is enabled, even if the participants are on mute the audio of the streaming content decreases. How can I do to prevent the app from doing that with Twilio?

Thanks in advance.

Video iOS SDK

pod 'TwilioVideo', '~> 4.6.2'.

Xcode

15.0

iOS Version

15.7

iOS Device

iPad pro 3rd gen