import Foundation import UIKit import Postbox import TelegramCore import SyncCore import SwiftSignalKit import TelegramAudio public enum RequestCallResult { case requested case alreadyInProgress(PeerId?) } public struct CallAuxiliaryServer { public enum Connection { case stun case turn(username: String, password: String) } public let host: String public let port: Int public let connection: Connection public init( host: String, port: Int, connection: Connection ) { self.host = host self.port = port self.connection = connection } } public struct PresentationCallState: Equatable { public enum State: Equatable { case waiting case ringing case requesting(Bool) case connecting(Data?) case active(Double, Int32?, Data) case reconnecting(Double, Int32?, Data) case terminating(CallSessionTerminationReason?) case terminated(CallId?, CallSessionTerminationReason?, Bool) } public enum VideoState: Equatable { case notAvailable case inactive case active case paused } public enum RemoteVideoState: Equatable { case inactive case active case paused } public enum RemoteAudioState: Equatable { case active case muted } public enum RemoteBatteryLevel: Equatable { case normal case low } public var state: State public var videoState: VideoState public var remoteVideoState: RemoteVideoState public var remoteAudioState: RemoteAudioState public var remoteBatteryLevel: RemoteBatteryLevel public init(state: State, videoState: VideoState, remoteVideoState: RemoteVideoState, remoteAudioState: RemoteAudioState, remoteBatteryLevel: RemoteBatteryLevel) { self.state = state self.videoState = videoState self.remoteVideoState = remoteVideoState self.remoteAudioState = remoteAudioState self.remoteBatteryLevel = remoteBatteryLevel } } public final class PresentationCallVideoView { public enum Orientation { case rotation0 case rotation90 case rotation180 case rotation270 } public let view: UIView public let setOnFirstFrameReceived: (((Float) -> Void)?) -> Void public let getOrientation: () -> Orientation public let getAspect: () -> CGFloat public let setOnOrientationUpdated: (((Orientation, CGFloat) -> Void)?) -> Void public let setOnIsMirroredUpdated: (((Bool) -> Void)?) -> Void public init( view: UIView, setOnFirstFrameReceived: @escaping (((Float) -> Void)?) -> Void, getOrientation: @escaping () -> Orientation, getAspect: @escaping () -> CGFloat, setOnOrientationUpdated: @escaping (((Orientation, CGFloat) -> Void)?) -> Void, setOnIsMirroredUpdated: @escaping (((Bool) -> Void)?) -> Void ) { self.view = view self.setOnFirstFrameReceived = setOnFirstFrameReceived self.getOrientation = getOrientation self.getAspect = getAspect self.setOnOrientationUpdated = setOnOrientationUpdated self.setOnIsMirroredUpdated = setOnIsMirroredUpdated } } public protocol PresentationCall: class { var account: Account { get } var isIntegratedWithCallKit: Bool { get } var internalId: CallSessionInternalId { get } var peerId: PeerId { get } var isOutgoing: Bool { get } var isVideo: Bool { get } var isVideoPossible: Bool { get } var peer: Peer? { get } var state: Signal { get } var isMuted: Signal { get } var audioOutputState: Signal<([AudioSessionOutput], AudioSessionOutput?), NoError> { get } var canBeRemoved: Signal { get } func answer() func hangUp() -> Signal func rejectBusy() func toggleIsMuted() func setIsMuted(_ value: Bool) func requestVideo() func setRequestedVideoAspect(_ aspect: Float) func disableVideo() func setOutgoingVideoIsPaused(_ isPaused: Bool) func switchVideoCamera() func setCurrentAudioOutput(_ output: AudioSessionOutput) func debugInfo() -> Signal<(String, String), NoError> func makeIncomingVideoView(completion: @escaping (PresentationCallVideoView?) -> Void) func makeOutgoingVideoView(completion: @escaping (PresentationCallVideoView?) -> Void) } public protocol PresentationCallManager: class { var currentCallSignal: Signal { get } func requestCall(context: AccountContext, peerId: PeerId, isVideo: Bool, endCurrentIfAny: Bool) -> RequestCallResult }