Merge branch 'charlesmchen/fixCallHangupCrashes'

pull/1/head
Matthew Chen 7 years ago
commit 37f653a7f9

@ -225,19 +225,23 @@ class PeerConnectionClient: NSObject, RTCPeerConnectionDelegate, RTCDataChannelD
} }
public func setCameraSource(useBackCamera: Bool) { public func setCameraSource(useBackCamera: Bool) {
SwiftAssertIsOnMainThread(#function)
PeerConnectionClient.signalingQueue.async {
guard let localVideoSource = self.localVideoSource else { guard let localVideoSource = self.localVideoSource else {
owsFail("\(logTag) in \(#function) localVideoSource was unexpectedly nil") owsFail("\(self.logTag) in \(#function) localVideoSource was unexpectedly nil")
return return
} }
// certain devices, e.g. 16GB iPod touch don't have a back camera // certain devices, e.g. 16GB iPod touch don't have a back camera
guard localVideoSource.canUseBackCamera else { guard localVideoSource.canUseBackCamera else {
owsFail("\(logTag) in \(#function) canUseBackCamera was unexpectedly false") owsFail("\(self.logTag) in \(#function) canUseBackCamera was unexpectedly false")
return return
} }
localVideoSource.useBackCamera = useBackCamera localVideoSource.useBackCamera = useBackCamera
} }
}
public func setLocalVideoEnabled(enabled: Bool) { public func setLocalVideoEnabled(enabled: Bool) {
SwiftAssertIsOnMainThread(#function) SwiftAssertIsOnMainThread(#function)
@ -525,6 +529,7 @@ class PeerConnectionClient: NSObject, RTCPeerConnectionDelegate, RTCDataChannelD
audioSender = nil audioSender = nil
audioTrack = nil audioTrack = nil
videoSender = nil videoSender = nil
localVideoSource = nil
localVideoTrack = nil localVideoTrack = nil
remoteVideoTrack = nil remoteVideoTrack = nil
@ -827,12 +832,12 @@ class HardenedRTCSessionDescription {
// Enforce Constant bit rate. // Enforce Constant bit rate.
let cbrRegex = try! NSRegularExpression(pattern: "(a=fmtp:111 ((?!cbr=).)*)\r?\n", options: .caseInsensitive) let cbrRegex = try! NSRegularExpression(pattern: "(a=fmtp:111 ((?!cbr=).)*)\r?\n", options: .caseInsensitive)
description = cbrRegex.stringByReplacingMatches(in: description, options: [], range: NSMakeRange(0, description.count), withTemplate: "$1;cbr=1\r\n") description = cbrRegex.stringByReplacingMatches(in: description, options: [], range: NSRange(location: 0, length: description.count), withTemplate: "$1;cbr=1\r\n")
// Strip plaintext audio-level details // Strip plaintext audio-level details
// https://tools.ietf.org/html/rfc6464 // https://tools.ietf.org/html/rfc6464
let audioLevelRegex = try! NSRegularExpression(pattern: ".+urn:ietf:params:rtp-hdrext:ssrc-audio-level.*\r?\n", options: .caseInsensitive) let audioLevelRegex = try! NSRegularExpression(pattern: ".+urn:ietf:params:rtp-hdrext:ssrc-audio-level.*\r?\n", options: .caseInsensitive)
description = audioLevelRegex.stringByReplacingMatches(in: description, options: [], range: NSMakeRange(0, description.count), withTemplate: "") description = audioLevelRegex.stringByReplacingMatches(in: description, options: [], range: NSRange(location: 0, length: description.count), withTemplate: "")
return RTCSessionDescription.init(type: rtcSessionDescription.type, sdp: description) return RTCSessionDescription.init(type: rtcSessionDescription.type, sdp: description)
} }

Loading…
Cancel
Save