Revert whitespace changes.

// FREEBIE
pull/1/head
Matthew Chen 9 years ago
parent af289145b5
commit d6c849eab3

@ -34,7 +34,7 @@ import WebRTC
* | Caller | Callee | * | Caller | Callee |
* +----------------------------+-------------------------+ * +----------------------------+-------------------------+
* Start outgoing call: `handleOutgoingCall`... * Start outgoing call: `handleOutgoingCall`...
--[SS.CallOffer]--> --[SS.CallOffer]-->
* ...and start generating ICE updates. * ...and start generating ICE updates.
* As ICE candidates are generated, `handleLocalAddedIceCandidate` is called. * As ICE candidates are generated, `handleLocalAddedIceCandidate` is called.
* and we *store* the ICE updates for later. * and we *store* the ICE updates for later.
@ -44,7 +44,7 @@ import WebRTC
* <--[SS.CallAnswer]-- * <--[SS.CallAnswer]--
* Start generating ICE updates. * Start generating ICE updates.
* As they are generated `handleLocalAddedIceCandidate` is called * As they are generated `handleLocalAddedIceCandidate` is called
which immediately sends the ICE updates to the Caller. which immediately sends the ICE updates to the Caller.
* <--[SS.ICEUpdate]-- (sent multiple times) * <--[SS.ICEUpdate]-- (sent multiple times)
* *
* Received CallAnswer: `handleReceivedAnswer` * Received CallAnswer: `handleReceivedAnswer`
@ -252,24 +252,22 @@ protocol CallServiceObserver: class {
self.peerConnectionClient = peerConnectionClient self.peerConnectionClient = peerConnectionClient
let sessionDescription = self.peerConnectionClient!.createOffer() return self.peerConnectionClient!.createOffer()
return sessionDescription }.then(on: DispatchQueue.main) { (sessionDescription: HardenedRTCSessionDescription) -> Promise<Void> in
}.then(on: DispatchQueue.main) { (sessionDescription: HardenedRTCSessionDescription) -> Promise<Void> in return self.peerConnectionClient!.setLocalSessionDescription(sessionDescription).then(on: DispatchQueue.main) {
return self.peerConnectionClient!.setLocalSessionDescription(sessionDescription).then(on: DispatchQueue.main) { let offerMessage = OWSCallOfferMessage(callId: call.signalingId, sessionDescription: sessionDescription.sdp)
let offerMessage = OWSCallOfferMessage(callId: call.signalingId, sessionDescription: sessionDescription.sdp) let callMessage = OWSOutgoingCallMessage(thread: thread, offerMessage: offerMessage)
let callMessage = OWSOutgoingCallMessage(thread: thread, offerMessage: offerMessage) return self.messageSender.sendCallMessage(callMessage)
let result = self.messageSender.sendCallMessage(callMessage) }
return result }.catch(on: DispatchQueue.main) { error in
} Logger.error("\(self.TAG) placing call failed with error: \(error)")
}.catch(on: DispatchQueue.main) { error in
Logger.error("\(self.TAG) placing call failed with error: \(error)") if let callError = error as? CallError {
self.handleFailedCall(error: callError)
if let callError = error as? CallError { } else {
self.handleFailedCall(error: callError) let externalError = CallError.externalError(underlyingError: error)
} else { self.handleFailedCall(error: externalError)
let externalError = CallError.externalError(underlyingError: error) }
self.handleFailedCall(error: externalError)
}
} }
} }
@ -309,13 +307,13 @@ protocol CallServiceObserver: class {
let sessionDescription = RTCSessionDescription(type: .answer, sdp: sessionDescription) let sessionDescription = RTCSessionDescription(type: .answer, sdp: sessionDescription)
_ = peerConnectionClient.setRemoteSessionDescription(sessionDescription).then { _ = peerConnectionClient.setRemoteSessionDescription(sessionDescription).then {
Logger.debug("\(self.TAG) successfully set remote description") Logger.debug("\(self.TAG) successfully set remote description")
}.catch(on: DispatchQueue.main) { error in }.catch(on: DispatchQueue.main) { error in
if let callError = error as? CallError { if let callError = error as? CallError {
self.handleFailedCall(error: callError) self.handleFailedCall(error: callError)
} else { } else {
let externalError = CallError.externalError(underlyingError: error) let externalError = CallError.externalError(underlyingError: error)
self.handleFailedCall(error: externalError) self.handleFailedCall(error: externalError)
} }
} }
} }
@ -394,47 +392,47 @@ protocol CallServiceObserver: class {
incomingCallPromise = firstly { incomingCallPromise = firstly {
return getIceServers() return getIceServers()
}.then(on: DispatchQueue.main) { (iceServers: [RTCIceServer]) -> Promise<HardenedRTCSessionDescription> in }.then(on: DispatchQueue.main) { (iceServers: [RTCIceServer]) -> Promise<HardenedRTCSessionDescription> in
// FIXME for first time call recipients I think we'll see mic/camera permission requests here, // 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. // even though, from the users perspective, no incoming call is yet visible.
self.peerConnectionClient = PeerConnectionClient(iceServers: iceServers, delegate: self) self.peerConnectionClient = PeerConnectionClient(iceServers: iceServers, delegate: self)
let offerSessionDescription = RTCSessionDescription(type: .offer, sdp: callerSessionDescription) let offerSessionDescription = RTCSessionDescription(type: .offer, sdp: callerSessionDescription)
let constraints = RTCMediaConstraints(mandatoryConstraints: nil, optionalConstraints: nil) let constraints = RTCMediaConstraints(mandatoryConstraints: nil, optionalConstraints: nil)
// Find a sessionDescription compatible with my constraints and the remote sessionDescription // Find a sessionDescription compatible with my constraints and the remote sessionDescription
return self.peerConnectionClient!.negotiateSessionDescription(remoteDescription: offerSessionDescription, constraints: constraints) return self.peerConnectionClient!.negotiateSessionDescription(remoteDescription: offerSessionDescription, constraints: constraints)
}.then(on: DispatchQueue.main) { (negotiatedSessionDescription: HardenedRTCSessionDescription) in }.then(on: DispatchQueue.main) { (negotiatedSessionDescription: HardenedRTCSessionDescription) in
Logger.debug("\(self.TAG) set the remote description") Logger.debug("\(self.TAG) set the remote description")
let answerMessage = OWSCallAnswerMessage(callId: newCall.signalingId, sessionDescription: negotiatedSessionDescription.sdp) let answerMessage = OWSCallAnswerMessage(callId: newCall.signalingId, sessionDescription: negotiatedSessionDescription.sdp)
let callAnswerMessage = OWSOutgoingCallMessage(thread: thread, answerMessage: answerMessage) let callAnswerMessage = OWSOutgoingCallMessage(thread: thread, answerMessage: answerMessage)
return self.messageSender.sendCallMessage(callAnswerMessage) return self.messageSender.sendCallMessage(callAnswerMessage)
}.then(on: DispatchQueue.main) { }.then(on: DispatchQueue.main) {
Logger.debug("\(self.TAG) successfully sent callAnswerMessage") Logger.debug("\(self.TAG) successfully sent callAnswerMessage")
let (promise, fulfill, _) = Promise<Void>.pending() let (promise, fulfill, _) = Promise<Void>.pending()
let timeout: Promise<Void> = after(interval: TimeInterval(timeoutSeconds)).then { () -> Void in let timeout: Promise<Void> = after(interval: TimeInterval(timeoutSeconds)).then { () -> Void in
// rejecting a promise by throwing is safely a no-op if the promise has already been fulfilled // rejecting a promise by throwing is safely a no-op if the promise has already been fulfilled
throw CallError.timeout(description: "timed out waiting for call to connect") throw CallError.timeout(description: "timed out waiting for call to connect")
} }
// This will be fulfilled (potentially) by the RTCDataChannel delegate method // This will be fulfilled (potentially) by the RTCDataChannel delegate method
self.fulfillCallConnectedPromise = fulfill self.fulfillCallConnectedPromise = fulfill
return race(promise, timeout) return race(promise, timeout)
}.catch(on: DispatchQueue.main) { error in }.catch(on: DispatchQueue.main) { error in
if let callError = error as? CallError { if let callError = error as? CallError {
self.handleFailedCall(error: callError) self.handleFailedCall(error: callError)
} else { } else {
let externalError = CallError.externalError(underlyingError: error) let externalError = CallError.externalError(underlyingError: error)
self.handleFailedCall(error: externalError) self.handleFailedCall(error: externalError)
} }
}.always { }.always {
Logger.debug("\(self.TAG) ending background task awaiting inbound call connection") Logger.debug("\(self.TAG) ending background task awaiting inbound call connection")
UIApplication.shared.endBackgroundTask(backgroundTask) UIApplication.shared.endBackgroundTask(backgroundTask)
} }
} }
@ -750,8 +748,8 @@ protocol CallServiceObserver: class {
let callMessage = OWSOutgoingCallMessage(thread: thread, hangupMessage: hangupMessage) let callMessage = OWSOutgoingCallMessage(thread: thread, hangupMessage: hangupMessage)
_ = self.messageSender.sendCallMessage(callMessage).then(on: DispatchQueue.main) { _ = self.messageSender.sendCallMessage(callMessage).then(on: DispatchQueue.main) {
Logger.debug("\(self.TAG) successfully sent hangup call message to \(thread)") Logger.debug("\(self.TAG) successfully sent hangup call message to \(thread)")
}.catch(on: DispatchQueue.main) { error in }.catch(on: DispatchQueue.main) { error in
Logger.error("\(self.TAG) failed to send hangup call message to \(thread) with error: \(error)") Logger.error("\(self.TAG) failed to send hangup call message to \(thread) with error: \(error)")
} }
terminateCall() terminateCall()
@ -956,24 +954,24 @@ protocol CallServiceObserver: class {
return firstly { return firstly {
return accountManager.getTurnServerInfo() return accountManager.getTurnServerInfo()
}.then(on: DispatchQueue.main) { turnServerInfo -> [RTCIceServer] in }.then(on: DispatchQueue.main) { turnServerInfo -> [RTCIceServer] in
Logger.debug("\(self.TAG) got turn server urls: \(turnServerInfo.urls)") Logger.debug("\(self.TAG) got turn server urls: \(turnServerInfo.urls)")
return turnServerInfo.urls.map { url in return turnServerInfo.urls.map { url in
if url.hasPrefix("turn") { if url.hasPrefix("turn") {
// Only "turn:" servers require authentication. Don't include the credentials to other ICE servers // Only "turn:" servers require authentication. Don't include the credentials to other ICE servers
// as 1.) they aren't used, and 2.) the non-turn servers might not be under our control. // as 1.) they aren't used, and 2.) the non-turn servers might not be under our control.
// e.g. we use a public fallback STUN server. // e.g. we use a public fallback STUN server.
return RTCIceServer(urlStrings: [url], username: turnServerInfo.username, credential: turnServerInfo.password) return RTCIceServer(urlStrings: [url], username: turnServerInfo.username, credential: turnServerInfo.password)
} else { } else {
return RTCIceServer(urlStrings: [url]) return RTCIceServer(urlStrings: [url])
} }
} + [CallService.fallbackIceServer] } + [CallService.fallbackIceServer]
}.recover { error -> [RTCIceServer] in }.recover { error -> [RTCIceServer] in
Logger.error("\(self.TAG) fetching ICE servers failed with error: \(error)") Logger.error("\(self.TAG) fetching ICE servers failed with error: \(error)")
Logger.warn("\(self.TAG) using fallback ICE Servers") Logger.warn("\(self.TAG) using fallback ICE Servers")
return [CallService.fallbackIceServer] return [CallService.fallbackIceServer]
} }
} }

Loading…
Cancel
Save