|
|
|
|
@ -85,7 +85,9 @@ public final class SessionCall: CurrentCallProtocol, WebRTCSessionDelegate {
|
|
|
|
|
didSet {
|
|
|
|
|
stateDidChange?()
|
|
|
|
|
hasConnectedDidChange?()
|
|
|
|
|
updateCallDetailedStatus?("Call Connected")
|
|
|
|
|
updateCallDetailedStatus?(
|
|
|
|
|
mode == .offer ? Constants.call_connection_steps_sender[5] : Constants.call_connection_steps_receiver[4]
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -210,6 +212,9 @@ public final class SessionCall: CurrentCallProtocol, WebRTCSessionDelegate {
|
|
|
|
|
if hasStartedConnecting {
|
|
|
|
|
webRTCSession.handleRemoteSDP(sdp, from: sessionId) // This sends an answer message internally
|
|
|
|
|
}
|
|
|
|
|
if mode == .answer {
|
|
|
|
|
self.updateCallDetailedStatus?(Constants.call_connection_steps_receiver[0])
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// MARK: - Actions
|
|
|
|
|
@ -250,7 +255,7 @@ public final class SessionCall: CurrentCallProtocol, WebRTCSessionDelegate {
|
|
|
|
|
|
|
|
|
|
self.callInteractionId = interaction?.id
|
|
|
|
|
|
|
|
|
|
self.updateCallDetailedStatus?("Creating Call")
|
|
|
|
|
self.updateCallDetailedStatus?(Constants.call_connection_steps_sender[0])
|
|
|
|
|
|
|
|
|
|
try? webRTCSession
|
|
|
|
|
.sendPreOffer(
|
|
|
|
|
@ -263,7 +268,7 @@ public final class SessionCall: CurrentCallProtocol, WebRTCSessionDelegate {
|
|
|
|
|
// Start the timeout timer for the call
|
|
|
|
|
.handleEvents(receiveOutput: { [weak self] _ in self?.setupTimeoutTimer() })
|
|
|
|
|
.flatMap { [weak self] _ in
|
|
|
|
|
self?.updateCallDetailedStatus?("Sending Call Offer")
|
|
|
|
|
self?.updateCallDetailedStatus?(Constants.call_connection_steps_sender[1])
|
|
|
|
|
return webRTCSession
|
|
|
|
|
.sendOffer(to: thread)
|
|
|
|
|
.retry(5)
|
|
|
|
|
@ -273,7 +278,6 @@ public final class SessionCall: CurrentCallProtocol, WebRTCSessionDelegate {
|
|
|
|
|
switch result {
|
|
|
|
|
case .finished:
|
|
|
|
|
SNLog("[Calls] Offer message sent")
|
|
|
|
|
self?.updateCallDetailedStatus?("Sending Connection Candidates")
|
|
|
|
|
case .failure(let error):
|
|
|
|
|
SNLog("[Calls] Error initializing call after 5 retries: \(error), ending call...")
|
|
|
|
|
self?.handleCallInitializationFailed()
|
|
|
|
|
@ -289,7 +293,7 @@ public final class SessionCall: CurrentCallProtocol, WebRTCSessionDelegate {
|
|
|
|
|
|
|
|
|
|
if let sdp = remoteSDP {
|
|
|
|
|
SNLog("[Calls] Got remote sdp already")
|
|
|
|
|
self.updateCallDetailedStatus?("Answering Call")
|
|
|
|
|
self.updateCallDetailedStatus?(Constants.call_connection_steps_receiver[1])
|
|
|
|
|
webRTCSession.handleRemoteSDP(sdp, from: sessionId) // This sends an answer message internally
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -428,15 +432,27 @@ public final class SessionCall: CurrentCallProtocol, WebRTCSessionDelegate {
|
|
|
|
|
isRemoteVideoEnabled = isEnabled
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public func iceCandidateDidSend() {
|
|
|
|
|
public func sendingIceCandidates() {
|
|
|
|
|
DispatchQueue.main.async {
|
|
|
|
|
self.updateCallDetailedStatus?("Awaiting Recipient Answer...")
|
|
|
|
|
self.updateCallDetailedStatus?(
|
|
|
|
|
self.mode == .offer ? Constants.call_connection_steps_sender[2] : Constants.call_connection_steps_receiver[2]
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public func iceCandidateDidSend() {
|
|
|
|
|
if self.mode == .offer {
|
|
|
|
|
DispatchQueue.main.async {
|
|
|
|
|
self.updateCallDetailedStatus?(Constants.call_connection_steps_sender[3])
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public func iceCandidateDidReceive() {
|
|
|
|
|
DispatchQueue.main.async {
|
|
|
|
|
self.updateCallDetailedStatus?("Handling Connection Candidates")
|
|
|
|
|
self.updateCallDetailedStatus?(
|
|
|
|
|
self.mode == .offer ? Constants.call_connection_steps_sender[4] : Constants.call_connection_steps_receiver[3]
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|