You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
session-ios/Session/Calls/WebRTC/WebRTCSession+MessageHandli...

36 lines
1.2 KiB
Swift

// Copyright © 2022 Rangeproof Pty Ltd. All rights reserved.
import Foundation
import Combine
import WebRTC
import SessionMessagingKit
import SessionUtilitiesKit
extension WebRTCSession {
public func handleICECandidates(_ candidate: [RTCIceCandidate]) {
Log.info(.calls, "Received ICE candidate message.")
self.delegate?.iceCandidateDidReceive()
candidate.forEach { peerConnection?.add($0, completionHandler: { _ in }) }
}
public func handleRemoteSDP(_ sdp: RTCSessionDescription, from sessionId: String) {
Log.info(.calls, "Received remote SDP: \(sdp.sdp).")
peerConnection?.setRemoteDescription(sdp, completionHandler: { [weak self] error in
if let error = error {
Log.error(.calls, "Couldn't set SDP due to error: \(error).")
}
else {
guard sdp.type == .offer else { return }
DispatchQueue.global(qos: .userInitiated).async {
self?.sendAnswer(to: sessionId)
.retry(5)
.sinkUntilComplete()
}
}
})
}
}