Commit 7bafd370 authored by QuentinArguillere's avatar QuentinArguillere
Browse files

When enabling the video in a call, we only redirect the sound to speaker if...

When enabling the video in a call, we only redirect the sound to speaker if there is not other output device connected
parent a4d2c834
Pipeline #30908 failed with stage
in 13 minutes and 29 seconds
......@@ -43,7 +43,6 @@ import AVFoundation
var referedFromCall: String?
var referedToCall: String?
var endCallkit: Bool = false
static var speaker_already_enabled : Bool = false
var globalState : GlobalState = .Off
var actionsToPerformOnceWhenCoreIsOn : [(()->Void)] = []
......@@ -172,6 +171,13 @@ import AVFoundation
return false
}
@objc func isReceiverEnabled() -> Bool {
if let outputDevice = lc!.outputAudioDevice {
return outputDevice.type == AudioDeviceType.Microphone
}
return false
}
func requestTransaction(_ transaction: CXTransaction, action: String) {
callController.request(transaction) { error in
if let error = error {
......@@ -454,9 +460,6 @@ import AVFoundation
displayIncomingCall(call: call, handle: "Calling", hasVideo: false, callId: callId!, displayName: "Calling")
} else {
let video = UIApplication.shared.applicationState == .active && (core.videoActivationPolicy?.automaticallyAccept ?? false) && (call.remoteParams?.videoEnabled ?? false)
// we keep the speaker auto-enabled state in this static so that we don't
// force-enable it on ICE re-invite if the user disabled it.
CallManager.speaker_already_enabled = false
if (call.userData == nil) {
let appData = CallAppData()
......@@ -504,7 +507,6 @@ import AVFoundation
if (CallManager.instance().speakerBeforePause) {
CallManager.instance().speakerBeforePause = false
CallManager.instance().changeRouteToSpeaker()
CallManager.speaker_already_enabled = true
}
break
case .OutgoingInit,
......@@ -535,7 +537,6 @@ import AVFoundation
}
UIDevice.current.isProximityMonitoringEnabled = false
CallManager.speaker_already_enabled = false
if (CallManager.instance().lc!.callsNb == 0) {
CallManager.instance().changeRouteToDefault()
// disable this because I don't find anygood reason for it: _bluetoothAvailable = FALSE;
......@@ -602,10 +603,8 @@ import AVFoundation
}
if (cstate == .IncomingReceived || cstate == .OutgoingInit || cstate == .Connected || cstate == .StreamsRunning) {
// if ((call.currentParams?.videoEnabled ?? false) && !CallManager.speaker_already_enabled && !CallManager.instance().bluetoothEnabled) {
if ((call.currentParams?.videoEnabled ?? false) && !CallManager.speaker_already_enabled && !CallManager.instance().isBluetoothEnabled()) {
if ((call.currentParams?.videoEnabled ?? false) && CallManager.instance().isReceiverEnabled()) {
CallManager.instance().changeRouteToSpeaker()
CallManager.speaker_already_enabled = true
}
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment