Respond to CR.

// FREEBIE
pull/1/head
Matthew Chen 8 years ago
parent 6f3a45ff8c
commit ca76ec6f36

@ -75,7 +75,6 @@ enum CallError: Error {
case disconnected case disconnected
case externalError(underlyingError: Error) case externalError(underlyingError: Error)
case timeout(description: String) case timeout(description: String)
case unexpected(description: String)
} }
// FIXME TODO do we need to timeout? // FIXME TODO do we need to timeout?
@ -286,7 +285,7 @@ protocol CallServiceObserver: class {
return getIceServers().then { iceServers -> Promise<HardenedRTCSessionDescription> in return getIceServers().then { iceServers -> Promise<HardenedRTCSessionDescription> in
Logger.debug("\(self.TAG) got ice servers:\(iceServers)") 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") assert(self.peerConnectionClient == nil, "Unexpected PeerConnectionClient instance")
Logger.debug("\(self.TAG) setting peerConnectionClient in \(#function)") 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, // 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.
guard self.call == newCall else { 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") assert(self.peerConnectionClient == nil, "Unexpected PeerConnectionClient instance")
Logger.debug("\(self.self.TAG) setting peerConnectionClient in \(#function)") 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 offerSessionDescription = RTCSessionDescription(type: .offer, sdp: callerSessionDescription)
let constraints = RTCMediaConstraints(mandatoryConstraints: nil, optionalConstraints: nil) let constraints = RTCMediaConstraints(mandatoryConstraints: nil, optionalConstraints: nil)
@ -453,7 +452,7 @@ protocol CallServiceObserver: class {
return self.peerConnectionClient!.negotiateSessionDescription(remoteDescription: offerSessionDescription, constraints: constraints) return self.peerConnectionClient!.negotiateSessionDescription(remoteDescription: offerSessionDescription, constraints: constraints)
}.then { (negotiatedSessionDescription: HardenedRTCSessionDescription) in }.then { (negotiatedSessionDescription: HardenedRTCSessionDescription) in
guard self.call == newCall else { 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") Logger.debug("\(self.TAG) set the remote description")
@ -463,7 +462,7 @@ protocol CallServiceObserver: class {
return self.messageSender.sendCallMessage(callAnswerMessage) return self.messageSender.sendCallMessage(callAnswerMessage)
}.then { }.then {
guard self.call == newCall else { 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") Logger.debug("\(self.TAG) successfully sent callAnswerMessage")

@ -65,8 +65,8 @@ protocol PeerConnectionClientDelegate: class {
class PeerConnectionClient: NSObject, RTCPeerConnectionDelegate, RTCDataChannelDelegate { class PeerConnectionClient: NSObject, RTCPeerConnectionDelegate, RTCDataChannelDelegate {
enum CallType { enum CallType {
case Incoming case incoming
case Outgoing case outgoing
} }
let TAG = "[PeerConnectionClient]" let TAG = "[PeerConnectionClient]"
@ -145,7 +145,7 @@ class PeerConnectionClient: NSObject, RTCPeerConnectionDelegate, RTCDataChannelD
createAudioSender() createAudioSender()
createVideoSender() createVideoSender()
if callType == .Outgoing { if callType == .outgoing {
// When placing an outgoing call, it's our responsibility to create the DataChannel. // When placing an outgoing call, it's our responsibility to create the DataChannel.
// Recipient will not have to do this explicitly. // Recipient will not have to do this explicitly.
createSignalingDataChannel() createSignalingDataChannel()
@ -154,7 +154,7 @@ class PeerConnectionClient: NSObject, RTCPeerConnectionDelegate, RTCDataChannelD
// MARK: - Media Streams // MARK: - Media Streams
fileprivate func createSignalingDataChannel() { private func createSignalingDataChannel() {
AssertIsOnMainThread() AssertIsOnMainThread()
let dataChannel = peerConnection.dataChannel(forLabel: Identifiers.dataChannelSignaling.rawValue, let dataChannel = peerConnection.dataChannel(forLabel: Identifiers.dataChannelSignaling.rawValue,

@ -55,7 +55,7 @@ class PeerConnectionClientTest: XCTestCase {
let iceServers = [RTCIceServer]() let iceServers = [RTCIceServer]()
clientDelegate = FakePeerConnectionClientDelegate() clientDelegate = FakePeerConnectionClientDelegate()
client = PeerConnectionClient(iceServers: iceServers, delegate: clientDelegate, callType: .Outgoing) client = PeerConnectionClient(iceServers: iceServers, delegate: clientDelegate, callType: .outgoing)
peerConnection = client.peerConnectionForTests() peerConnection = client.peerConnectionForTests()
dataChannel = client.dataChannelForTests() dataChannel = client.dataChannelForTests()
} }

Loading…
Cancel
Save