mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-10-31 08:15:24 +00:00
d33dc058c2
The call package now says why a call ended. Only our own hang-up is an end call action; a call the other side declined or left, that nobody answered, or that failed is reported to CallKit with that reason, so the call log no longer shows it as one we ended, and no end action comes back to hang up a call that is already over. Also adopts the package's other host changes: the voice call icon beside "Calling…", and the call's large avatar rendered at the 140 pt it is drawn at. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
77 lines
3.2 KiB
Swift
77 lines
3.2 KiB
Swift
//
|
|
// Copyright 2025 Element Creations Ltd.
|
|
// Copyright 2024-2025 New Vector Ltd.
|
|
//
|
|
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial.
|
|
// Please see LICENSE files in the repository root for full details.
|
|
//
|
|
|
|
import CallKit
|
|
import Combine
|
|
import ElementCall
|
|
|
|
/// What the host has to do about a native call, beyond running it.
|
|
enum NativeCallPresentation: Equatable {
|
|
case present
|
|
case restore
|
|
case minimize
|
|
case dismiss
|
|
}
|
|
|
|
enum ElementCallServiceAction {
|
|
case receivedIncomingCallRequest
|
|
case startCall(roomID: String, isVoiceCall: Bool)
|
|
case endCall(roomID: String)
|
|
case setAudioEnabled(_ enabled: Bool, roomID: String)
|
|
/// CallKit activated the audio session: a native call may start its audio engine now.
|
|
case audioSessionActivated
|
|
case audioSessionDeactivated
|
|
/// The native call's screen needs presenting, minimizing, restoring or dismissing.
|
|
case nativeCall(NativeCallPresentation)
|
|
}
|
|
|
|
// sourcery: AutoMockable
|
|
protocol ElementCallServiceProtocol: AnyObject {
|
|
var actions: AnyPublisher<ElementCallServiceAction, Never> { get }
|
|
|
|
var ongoingCallRoomIDPublisher: CurrentValuePublisher<String?, Never> { get }
|
|
|
|
/// The controller for this session's native call stack, `nil` when native calls are unavailable.
|
|
var nativeCallController: ElementCallController? { get }
|
|
|
|
/// Builds the native call stack for the session, or releases it along with the to-device
|
|
/// subscription it holds open. Pass `nil` when signing out.
|
|
func setUserSession(_ userSession: UserSessionProtocol?)
|
|
|
|
/// Starts, or returns to, a native call in the room, driving its screen through
|
|
/// ``ElementCallServiceAction/nativeCall(_:)``.
|
|
///
|
|
/// Returns `false` when there's no native call stack and the caller should present the Element
|
|
/// Call web view instead.
|
|
@discardableResult
|
|
func handleNativeCallRequest(roomProxy: JoinedRoomProxyProtocol, isVoiceCall: Bool) -> Bool
|
|
|
|
/// Asks the native call to minimize. The screen only comes down once a system window has
|
|
/// started, which arrives as ``ElementCallServiceAction/nativeCall(_:)``.
|
|
func minimizeNativeCall()
|
|
|
|
/// Brings the native call back out of its system window.
|
|
func restoreNativeCall()
|
|
|
|
/// Registers the call with CallKit, adopting the ringing incoming call for the room if there is one.
|
|
func setupCallSession(roomID: String, roomDisplayName: String, isVideo: Bool) async
|
|
|
|
/// Tells CallKit the call is connected. Does nothing for web view calls, which CallKit never tracks.
|
|
func reportCallSessionConnected(roomID: String)
|
|
|
|
/// Ends the call for the room, including an answered call the native stack never took over.
|
|
func tearDownCallSession(roomID: String)
|
|
|
|
/// The call for the room ended without us: declined, unanswered, the other side gone, or failed.
|
|
/// Reported to the system as such rather than as an end call action, which would log it as one
|
|
/// we hung up and ask the call stack to end a call it already has.
|
|
func reportCallSessionEnded(roomID: String, reason: CXCallEndedReason)
|
|
|
|
func setAudioEnabled(_ enabled: Bool, roomID: String)
|
|
}
|