diff --git a/Signal/src/call/CallService.swift b/Signal/src/call/CallService.swift index bedf912b6..5f39c0d72 100644 --- a/Signal/src/call/CallService.swift +++ b/Signal/src/call/CallService.swift @@ -75,7 +75,6 @@ enum CallError: Error { case disconnected case externalError(underlyingError: Error) case timeout(description: String) - case unexpected(description: String) } // FIXME TODO do we need to timeout? @@ -286,7 +285,7 @@ protocol CallServiceObserver: class { return getIceServers().then { iceServers -> Promise<HardenedRTCSessionDescription> in Logger.debug("\(self.TAG) got ice servers:\(iceServers)") - let peerConnectionClient = PeerConnectionClient(iceServers: iceServers, delegate: self, callType: .Outgoing) + let peerConnectionClient = PeerConnectionClient(iceServers: iceServers, delegate: self, callType: .outgoing) assert(self.peerConnectionClient == nil, "Unexpected PeerConnectionClient instance") Logger.debug("\(self.TAG) setting peerConnectionClient in \(#function)") @@ -440,11 +439,11 @@ protocol CallServiceObserver: class { // FIXME for first time call recipients I think we'll see mic/camera permission requests here, // even though, from the users perspective, no incoming call is yet visible. guard self.call == newCall else { - throw CallError.unexpected(description: "getIceServers() response for obsolete call") + throw CallError.assertionError(description: "getIceServers() response for obsolete call") } assert(self.peerConnectionClient == nil, "Unexpected PeerConnectionClient instance") Logger.debug("\(self.self.TAG) setting peerConnectionClient in \(#function)") - self.peerConnectionClient = PeerConnectionClient(iceServers: iceServers, delegate: self, callType: .Incoming) + self.peerConnectionClient = PeerConnectionClient(iceServers: iceServers, delegate: self, callType: .incoming) let offerSessionDescription = RTCSessionDescription(type: .offer, sdp: callerSessionDescription) let constraints = RTCMediaConstraints(mandatoryConstraints: nil, optionalConstraints: nil) @@ -453,7 +452,7 @@ protocol CallServiceObserver: class { return self.peerConnectionClient!.negotiateSessionDescription(remoteDescription: offerSessionDescription, constraints: constraints) }.then { (negotiatedSessionDescription: HardenedRTCSessionDescription) in guard self.call == newCall else { - throw CallError.unexpected(description: "negotiateSessionDescription() response for obsolete call") + throw CallError.assertionError(description: "negotiateSessionDescription() response for obsolete call") } Logger.debug("\(self.TAG) set the remote description") @@ -463,7 +462,7 @@ protocol CallServiceObserver: class { return self.messageSender.sendCallMessage(callAnswerMessage) }.then { guard self.call == newCall else { - throw CallError.unexpected(description: "sendCallMessage() response for obsolete call") + throw CallError.assertionError(description: "sendCallMessage() response for obsolete call") } Logger.debug("\(self.TAG) successfully sent callAnswerMessage") diff --git a/Signal/src/call/PeerConnectionClient.swift b/Signal/src/call/PeerConnectionClient.swift index a89d4d795..8d9cc4234 100644 --- a/Signal/src/call/PeerConnectionClient.swift +++ b/Signal/src/call/PeerConnectionClient.swift @@ -65,8 +65,8 @@ protocol PeerConnectionClientDelegate: class { class PeerConnectionClient: NSObject, RTCPeerConnectionDelegate, RTCDataChannelDelegate { enum CallType { - case Incoming - case Outgoing + case incoming + case outgoing } let TAG = "[PeerConnectionClient]" @@ -145,7 +145,7 @@ class PeerConnectionClient: NSObject, RTCPeerConnectionDelegate, RTCDataChannelD createAudioSender() createVideoSender() - if callType == .Outgoing { + if callType == .outgoing { // When placing an outgoing call, it's our responsibility to create the DataChannel. // Recipient will not have to do this explicitly. createSignalingDataChannel() @@ -154,7 +154,7 @@ class PeerConnectionClient: NSObject, RTCPeerConnectionDelegate, RTCDataChannelD // MARK: - Media Streams - fileprivate func createSignalingDataChannel() { + private func createSignalingDataChannel() { AssertIsOnMainThread() let dataChannel = peerConnection.dataChannel(forLabel: Identifiers.dataChannelSignaling.rawValue, @@ -550,7 +550,7 @@ class PeerConnectionClient: NSObject, RTCPeerConnectionDelegate, RTCDataChannelD } weak var remoteVideoTrack = stream.videoTracks[0] Logger.debug("\(self.TAG) didAdd stream:\(stream) video tracks: \(stream.videoTracks.count) audio tracks: \(stream.audioTracks.count)") - + PeerConnectionClient.signalingQueue.async { guard self.peerConnection != nil else { Logger.debug("\(self.TAG) \(#function) Ignoring obsolete event in terminated client") diff --git a/Signal/test/call/PeerConnectionClientTest.swift b/Signal/test/call/PeerConnectionClientTest.swift index d9887915a..a977a9d2b 100644 --- a/Signal/test/call/PeerConnectionClientTest.swift +++ b/Signal/test/call/PeerConnectionClientTest.swift @@ -55,7 +55,7 @@ class PeerConnectionClientTest: XCTestCase { let iceServers = [RTCIceServer]() clientDelegate = FakePeerConnectionClientDelegate() - client = PeerConnectionClient(iceServers: iceServers, delegate: clientDelegate, callType: .Outgoing) + client = PeerConnectionClient(iceServers: iceServers, delegate: clientDelegate, callType: .outgoing) peerConnection = client.peerConnectionForTests() dataChannel = client.dataChannelForTests() }