|
|
@ -10,6 +10,7 @@ public final class SessionCall: NSObject, WebRTCSessionDelegate {
|
|
|
|
let callID: UUID // This is for CallKit
|
|
|
|
let callID: UUID // This is for CallKit
|
|
|
|
let sessionID: String
|
|
|
|
let sessionID: String
|
|
|
|
let mode: Mode
|
|
|
|
let mode: Mode
|
|
|
|
|
|
|
|
var audioMode: AudioMode
|
|
|
|
let webRTCSession: WebRTCSession
|
|
|
|
let webRTCSession: WebRTCSession
|
|
|
|
let isOutgoing: Bool
|
|
|
|
let isOutgoing: Bool
|
|
|
|
var remoteSDP: RTCSessionDescription? = nil
|
|
|
|
var remoteSDP: RTCSessionDescription? = nil
|
|
|
@ -70,6 +71,14 @@ public final class SessionCall: NSObject, WebRTCSessionDelegate {
|
|
|
|
case unanswered
|
|
|
|
case unanswered
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// MARK: Audio I/O mode
|
|
|
|
|
|
|
|
enum AudioMode {
|
|
|
|
|
|
|
|
case earpiece
|
|
|
|
|
|
|
|
case speaker
|
|
|
|
|
|
|
|
case headphone
|
|
|
|
|
|
|
|
case bluetooth
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// MARK: Call State Properties
|
|
|
|
// MARK: Call State Properties
|
|
|
|
var connectingDate: Date? {
|
|
|
|
var connectingDate: Date? {
|
|
|
|
didSet {
|
|
|
|
didSet {
|
|
|
@ -141,6 +150,7 @@ public final class SessionCall: NSObject, WebRTCSessionDelegate {
|
|
|
|
self.uuid = uuid
|
|
|
|
self.uuid = uuid
|
|
|
|
self.callID = UUID()
|
|
|
|
self.callID = UUID()
|
|
|
|
self.mode = mode
|
|
|
|
self.mode = mode
|
|
|
|
|
|
|
|
self.audioMode = .earpiece
|
|
|
|
self.webRTCSession = WebRTCSession.current ?? WebRTCSession(for: sessionID, with: uuid)
|
|
|
|
self.webRTCSession = WebRTCSession.current ?? WebRTCSession(for: sessionID, with: uuid)
|
|
|
|
self.isOutgoing = outgoing
|
|
|
|
self.isOutgoing = outgoing
|
|
|
|
WebRTCSession.current = self.webRTCSession
|
|
|
|
WebRTCSession.current = self.webRTCSession
|
|
|
@ -258,6 +268,16 @@ public final class SessionCall: NSObject, WebRTCSessionDelegate {
|
|
|
|
webRTCSession.attachLocalRenderer(renderer)
|
|
|
|
webRTCSession.attachLocalRenderer(renderer)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// MARK: Audio I/O swithcing
|
|
|
|
|
|
|
|
func switchAudioMode(mode: AudioMode) {
|
|
|
|
|
|
|
|
audioMode = mode
|
|
|
|
|
|
|
|
if mode == .speaker {
|
|
|
|
|
|
|
|
webRTCSession.configureAudioSession(outputAudioPort: .speaker)
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
webRTCSession.configureAudioSession()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// MARK: Delegate
|
|
|
|
// MARK: Delegate
|
|
|
|
public func webRTCIsConnected() {
|
|
|
|
public func webRTCIsConnected() {
|
|
|
|
guard !self.hasConnected else { return }
|
|
|
|
guard !self.hasConnected else { return }
|
|
|
|