diff --git a/Session/Calls/Call Management/SessionCall.swift b/Session/Calls/Call Management/SessionCall.swift index ef3b9e1a4..79b31fe69 100644 --- a/Session/Calls/Call Management/SessionCall.swift +++ b/Session/Calls/Call Management/SessionCall.swift @@ -178,7 +178,7 @@ public final class SessionCall: NSObject, WebRTCSessionDelegate { } func didReceiveRemoteSDP(sdp: RTCSessionDescription) { - print("[Calls] Did receive remote sdp.") + SNLog("[Calls] Did receive remote sdp.") remoteSDP = sdp if hasStartedConnecting { webRTCSession.handleRemoteSDP(sdp, from: sessionID) // This sends an answer message internally diff --git a/Session/Calls/Call Management/SessionCallManager.swift b/Session/Calls/Call Management/SessionCallManager.swift index 1a099d396..019ba48c0 100644 --- a/Session/Calls/Call Management/SessionCallManager.swift +++ b/Session/Calls/Call Management/SessionCallManager.swift @@ -129,7 +129,7 @@ public final class SessionCallManager: NSObject { let message = CallMessage() message.uuid = offerMessage.uuid message.kind = .endCall - print("[Calls] Sending end call message.") + SNLog("[Calls] Sending end call message.") MessageSender.sendNonDurably(message, in: thread, using: transaction).retainUntilComplete() let infoMessage = TSInfoMessage.from(offerMessage, associatedWith: thread) infoMessage.save(with: transaction) diff --git a/Session/Calls/CallVC.swift b/Session/Calls/CallVC.swift index 4aea91db3..90008d743 100644 --- a/Session/Calls/CallVC.swift +++ b/Session/Calls/CallVC.swift @@ -379,7 +379,7 @@ final class CallVC : UIViewController, VideoPreviewDelegate { } func handleEndCallMessage() { - print("[Calls] Ending call.") + SNLog("[Calls] Ending call.") callInfoLabel.text = "Call Ended" UIView.animate(withDuration: 0.25) { self.remoteVideoView.alpha = 0 diff --git a/SessionMessagingKit/Calls/WebRTCSession+DataChannel.swift b/SessionMessagingKit/Calls/WebRTCSession+DataChannel.swift index acdfe5be0..81805f70a 100644 --- a/SessionMessagingKit/Calls/WebRTCSession+DataChannel.swift +++ b/SessionMessagingKit/Calls/WebRTCSession+DataChannel.swift @@ -9,7 +9,7 @@ extension WebRTCSession: RTCDataChannelDelegate { dataChannelConfiguration.isNegotiated = true dataChannelConfiguration.channelId = 548 guard let dataChannel = peerConnection.dataChannel(forLabel: "CONTROL", configuration: dataChannelConfiguration) else { - print("[Calls] Couldn't create data channel.") + SNLog("[Calls] Couldn't create data channel.") return nil } return dataChannel @@ -17,7 +17,7 @@ extension WebRTCSession: RTCDataChannelDelegate { public func sendJSON(_ json: JSON) { if let dataChannel = self.dataChannel, let jsonAsData = try? JSONSerialization.data(withJSONObject: json, options: [ .fragmentsAllowed ]) { - print("[Calls] Send json to data channel") + SNLog("[Calls] Send json to data channel") let dataBuffer = RTCDataBuffer(data: jsonAsData, isBinary: false) dataChannel.sendData(dataBuffer) } @@ -25,7 +25,7 @@ extension WebRTCSession: RTCDataChannelDelegate { // MARK: Data channel delegate public func dataChannelDidChangeState(_ dataChannel: RTCDataChannel) { - print("[Calls] Data channel did change to \(dataChannel.readyState.rawValue)") + SNLog("[Calls] Data channel did change to \(dataChannel.readyState.rawValue)") if dataChannel.readyState == .open { delegate?.dataChannelDidOpen() } @@ -33,7 +33,7 @@ extension WebRTCSession: RTCDataChannelDelegate { public func dataChannel(_ dataChannel: RTCDataChannel, didReceiveMessageWith buffer: RTCDataBuffer) { if let json = try? JSONSerialization.jsonObject(with: buffer.data, options: [ .fragmentsAllowed ]) as? JSON { - print("[Calls] Data channel did receive data: \(json)") + SNLog("[Calls] Data channel did receive data: \(json)") if let isRemoteVideoEnabled = json["video"] as? Bool { delegate?.isRemoteVideoDidChange(isEnabled: isRemoteVideoEnabled) } diff --git a/SessionMessagingKit/Calls/WebRTCSession+MessageHandling.swift b/SessionMessagingKit/Calls/WebRTCSession+MessageHandling.swift index 0ab2fa2d6..f8a760779 100644 --- a/SessionMessagingKit/Calls/WebRTCSession+MessageHandling.swift +++ b/SessionMessagingKit/Calls/WebRTCSession+MessageHandling.swift @@ -3,12 +3,12 @@ import WebRTC extension WebRTCSession { public func handleICECandidates(_ candidate: [RTCIceCandidate]) { - print("[Calls] Received ICE candidate message.") + SNLog("[Calls] Received ICE candidate message.") candidate.forEach { peerConnection.add($0) } } public func handleRemoteSDP(_ sdp: RTCSessionDescription, from sessionID: String) { - print("[Calls] Received remote SDP: \(sdp.sdp).") + SNLog("[Calls] Received remote SDP: \(sdp.sdp).") peerConnection.setRemoteDescription(sdp, completionHandler: { [weak self] error in if let error = error { SNLog("[Calls] Couldn't set SDP due to error: \(error).") diff --git a/SessionMessagingKit/Calls/WebRTCSession.swift b/SessionMessagingKit/Calls/WebRTCSession.swift index 190e0061d..9f6f26acb 100644 --- a/SessionMessagingKit/Calls/WebRTCSession.swift +++ b/SessionMessagingKit/Calls/WebRTCSession.swift @@ -108,11 +108,11 @@ public final class WebRTCSession : NSObject, RTCPeerConnectionDelegate { // MARK: Signaling public func sendPreOffer(_ message: CallMessage, in thread: TSThread, using transaction: YapDatabaseReadWriteTransaction) -> Promise { - print("[Calls] Sending pre-offer message.") + SNLog("[Calls] Sending pre-offer message.") let (promise, seal) = Promise.pending() DispatchQueue.main.async { MessageSender.sendNonDurably(message, in: thread, using: transaction).done2 { - print("[Calls] Pre-offer message has been sent.") + SNLog("[Calls] Pre-offer message has been sent.") seal.fulfill(()) }.catch2 { error in seal.reject(error) @@ -122,7 +122,7 @@ public final class WebRTCSession : NSObject, RTCPeerConnectionDelegate { } public func sendOffer(to sessionID: String, using transaction: YapDatabaseReadWriteTransaction, isRestartingICEConnection: Bool = false) -> Promise { - print("[Calls] Sending offer message.") + SNLog("[Calls] Sending offer message.") guard let thread = TSContactThread.fetch(for: sessionID, using: transaction) else { return Promise(error: Error.noThread) } let (promise, seal) = Promise.pending() peerConnection.offer(for: mediaConstraints(isRestartingICEConnection)) { [weak self] sdp, error in @@ -154,7 +154,7 @@ public final class WebRTCSession : NSObject, RTCPeerConnectionDelegate { } public func sendAnswer(to sessionID: String, using transaction: YapDatabaseReadWriteTransaction) -> Promise { - print("[Calls] Sending answer message.") + SNLog("[Calls] Sending answer message.") guard let thread = TSContactThread.fetch(for: sessionID, using: transaction) else { return Promise(error: Error.noThread) } let (promise, seal) = Promise.pending() peerConnection.answer(for: mediaConstraints(false)) { [weak self] sdp, error in @@ -198,7 +198,7 @@ public final class WebRTCSession : NSObject, RTCPeerConnectionDelegate { Storage.write { transaction in let candidates = self.queuedICECandidates guard let thread = TSContactThread.fetch(for: self.contactSessionID, using: transaction) else { return } - print("[Calls] Batch sending \(candidates.count) ICE candidates.") + SNLog("[Calls] Batch sending \(candidates.count) ICE candidates.") let message = CallMessage() let sdps = candidates.map { $0.sdp } let sdpMLineIndexes = candidates.map { UInt32($0.sdpMLineIndex) } @@ -216,7 +216,7 @@ public final class WebRTCSession : NSObject, RTCPeerConnectionDelegate { let message = CallMessage() message.uuid = self.uuid message.kind = .endCall - print("[Calls] Sending end call message.") + SNLog("[Calls] Sending end call message.") MessageSender.sendNonDurably(message, in: thread, using: transaction).retainUntilComplete() } @@ -243,23 +243,23 @@ public final class WebRTCSession : NSObject, RTCPeerConnectionDelegate { // MARK: Peer connection delegate public func peerConnection(_ peerConnection: RTCPeerConnection, didChange state: RTCSignalingState) { - print("[Calls] Signaling state changed to: \(state).") + SNLog("[Calls] Signaling state changed to: \(state).") } public func peerConnection(_ peerConnection: RTCPeerConnection, didAdd stream: RTCMediaStream) { - print("[Calls] Peer connection did add stream.") + SNLog("[Calls] Peer connection did add stream.") } public func peerConnection(_ peerConnection: RTCPeerConnection, didRemove stream: RTCMediaStream) { - print("[Calls] Peer connection did remove stream.") + SNLog("[Calls] Peer connection did remove stream.") } public func peerConnectionShouldNegotiate(_ peerConnection: RTCPeerConnection) { - print("[Calls] Peer connection should negotiate.") + SNLog("[Calls] Peer connection should negotiate.") } public func peerConnection(_ peerConnection: RTCPeerConnection, didChange state: RTCIceConnectionState) { - print("[Calls] ICE connection state changed to: \(state).") + SNLog("[Calls] ICE connection state changed to: \(state).") if state == .connected { delegate?.webRTCIsConnected() } else if state == .disconnected { @@ -270,7 +270,7 @@ public final class WebRTCSession : NSObject, RTCPeerConnectionDelegate { } public func peerConnection(_ peerConnection: RTCPeerConnection, didChange state: RTCIceGatheringState) { - print("[Calls] ICE gathering state changed to: \(state).") + SNLog("[Calls] ICE gathering state changed to: \(state).") } public func peerConnection(_ peerConnection: RTCPeerConnection, didGenerate candidate: RTCIceCandidate) { @@ -278,11 +278,11 @@ public final class WebRTCSession : NSObject, RTCPeerConnectionDelegate { } public func peerConnection(_ peerConnection: RTCPeerConnection, didRemove candidates: [RTCIceCandidate]) { - print("[Calls] \(candidates.count) ICE candidate(s) removed.") + SNLog("[Calls] \(candidates.count) ICE candidate(s) removed.") } public func peerConnection(_ peerConnection: RTCPeerConnection, didOpen dataChannel: RTCDataChannel) { - print("[Calls] Data channel opened.") + SNLog("[Calls] Data channel opened.") } } diff --git a/SessionMessagingKit/Sending & Receiving/MessageReceiver+Handling.swift b/SessionMessagingKit/Sending & Receiving/MessageReceiver+Handling.swift index 19abb4723..32d670b04 100644 --- a/SessionMessagingKit/Sending & Receiving/MessageReceiver+Handling.swift +++ b/SessionMessagingKit/Sending & Receiving/MessageReceiver+Handling.swift @@ -314,16 +314,16 @@ extension MessageReceiver { let transaction = transaction as! YapDatabaseReadWriteTransaction switch message.kind! { case .preOffer: - print("[Calls] Received pre-offer message.") + SNLog("[Calls] Received pre-offer message.") // It is enough just ignoring the pre offers, other call messages // for this call would be dropped because of no Session call instance guard let sender = message.sender, let contact = Storage.shared.getContact(with: sender), contact.isApproved else { return } handleNewCallOfferMessageIfNeeded?(message, transaction) case .offer: - print("[Calls] Received offer message.") + SNLog("[Calls] Received offer message.") handleOfferCallMessage?(message) case .answer: - print("[Calls] Received answer message.") + SNLog("[Calls] Received answer message.") guard let currentWebRTCSession = WebRTCSession.current, currentWebRTCSession.uuid == message.uuid! else { return } handleAnswerCallMessage?(message) case .provisionalAnswer: break // TODO: Implement @@ -340,7 +340,7 @@ extension MessageReceiver { } currentWebRTCSession.handleICECandidates(candidates) case .endCall: - print("[Calls] Received end call message.") + SNLog("[Calls] Received end call message.") guard WebRTCSession.current?.uuid == message.uuid! else { return } handleEndCallMessage?(message) }