|
|
@ -139,7 +139,7 @@ public final class WebRTCSession : NSObject, RTCPeerConnectionDelegate {
|
|
|
|
if let error = error {
|
|
|
|
if let error = error {
|
|
|
|
seal.reject(error)
|
|
|
|
seal.reject(error)
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
guard let self = self, let sdp = sdp else { preconditionFailure() }
|
|
|
|
guard let self = self, let sdp = self.correctSessionDescription(sdp: sdp) else { preconditionFailure() }
|
|
|
|
self.peerConnection.setLocalDescription(sdp) { error in
|
|
|
|
self.peerConnection.setLocalDescription(sdp) { error in
|
|
|
|
if let error = error {
|
|
|
|
if let error = error {
|
|
|
|
print("Couldn't initiate call due to error: \(error).")
|
|
|
|
print("Couldn't initiate call due to error: \(error).")
|
|
|
@ -171,7 +171,7 @@ public final class WebRTCSession : NSObject, RTCPeerConnectionDelegate {
|
|
|
|
if let error = error {
|
|
|
|
if let error = error {
|
|
|
|
seal.reject(error)
|
|
|
|
seal.reject(error)
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
guard let self = self, let sdp = sdp else { preconditionFailure() }
|
|
|
|
guard let self = self, let sdp = self.correctSessionDescription(sdp: sdp) else { preconditionFailure() }
|
|
|
|
self.peerConnection.setLocalDescription(sdp) { error in
|
|
|
|
self.peerConnection.setLocalDescription(sdp) { error in
|
|
|
|
if let error = error {
|
|
|
|
if let error = error {
|
|
|
|
print("Couldn't accept call due to error: \(error).")
|
|
|
|
print("Couldn't accept call due to error: \(error).")
|
|
|
@ -244,6 +244,13 @@ public final class WebRTCSession : NSObject, RTCPeerConnectionDelegate {
|
|
|
|
return RTCMediaConstraints(mandatoryConstraints: mandatory, optionalConstraints: optional)
|
|
|
|
return RTCMediaConstraints(mandatoryConstraints: mandatory, optionalConstraints: optional)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private func correctSessionDescription(sdp: RTCSessionDescription?) -> RTCSessionDescription? {
|
|
|
|
|
|
|
|
guard let sdp = sdp else { return nil }
|
|
|
|
|
|
|
|
let cbrSdp = sdp.description.replace(regex: "(a=fmtp:111 ((?!cbr=).)*)\r?\n", with: "$1;cbr=1\r\n")
|
|
|
|
|
|
|
|
let finalSdp = cbrSdp.replace(regex: ".+urn:ietf:params:rtp-hdrext:ssrc-audio-level.*\r?\n", with: "")
|
|
|
|
|
|
|
|
return RTCSessionDescription(type: sdp.type, sdp: finalSdp)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// MARK: Peer connection delegate
|
|
|
|
// MARK: Peer connection delegate
|
|
|
|
public func peerConnection(_ peerConnection: RTCPeerConnection, didChange state: RTCSignalingState) {
|
|
|
|
public func peerConnection(_ peerConnection: RTCPeerConnection, didChange state: RTCSignalingState) {
|
|
|
|
print("[Calls] Signaling state changed to: \(state).")
|
|
|
|
print("[Calls] Signaling state changed to: \(state).")
|
|
|
|