mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Move logging to tgcalls
This commit is contained in:
parent
40f81fed3b
commit
34c34f0671
@ -162,11 +162,6 @@ private let setupLogs: Bool = {
|
|||||||
Logger.shared.log("TGVOIP", value)
|
Logger.shared.log("TGVOIP", value)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
/*OngoingCallThreadLocalContextWebrtcCustom.setupLoggingFunction({ value in
|
|
||||||
if let value = value {
|
|
||||||
Logger.shared.log("TGVOIP", value)
|
|
||||||
}
|
|
||||||
})*/
|
|
||||||
return true
|
return true
|
||||||
}()
|
}()
|
||||||
|
|
||||||
@ -1241,7 +1236,7 @@ private final class CallSignalingConnectionImpl: CallSignalingConnection {
|
|||||||
private func stateUpdated(state: NWConnection.State) {
|
private func stateUpdated(state: NWConnection.State) {
|
||||||
switch state {
|
switch state {
|
||||||
case .ready:
|
case .ready:
|
||||||
Logger.shared.log("CallSignaling", "Connection state is ready")
|
OngoingCallThreadLocalContextWebrtc.logMessage("CallSignaling: Connection state is ready")
|
||||||
|
|
||||||
var headerData = Data(count: 4)
|
var headerData = Data(count: 4)
|
||||||
headerData.withUnsafeMutableBytes { bytes in
|
headerData.withUnsafeMutableBytes { bytes in
|
||||||
@ -1249,7 +1244,7 @@ private final class CallSignalingConnectionImpl: CallSignalingConnection {
|
|||||||
}
|
}
|
||||||
self.connection.send(content: headerData, completion: .contentProcessed({ error in
|
self.connection.send(content: headerData, completion: .contentProcessed({ error in
|
||||||
if let error = error {
|
if let error = error {
|
||||||
Logger.shared.log("CallSignaling", "Connection send header error: \(error)")
|
OngoingCallThreadLocalContextWebrtc.logMessage("CallSignaling: Connection send header error: \(error)")
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
|
|
||||||
@ -1257,7 +1252,7 @@ private final class CallSignalingConnectionImpl: CallSignalingConnection {
|
|||||||
|
|
||||||
self.sendPacket(payload: Data())
|
self.sendPacket(payload: Data())
|
||||||
case let .failed(error):
|
case let .failed(error):
|
||||||
Logger.shared.log("CallSignaling", "Connection error: \(error)")
|
OngoingCallThreadLocalContextWebrtc.logMessage("CallSignaling: Connection error: \(error)")
|
||||||
self.onIsClosed()
|
self.onIsClosed()
|
||||||
default:
|
default:
|
||||||
break
|
break
|
||||||
@ -1293,10 +1288,10 @@ private final class CallSignalingConnectionImpl: CallSignalingConnection {
|
|||||||
if payloadSize < 2 * 1024 * 1024 {
|
if payloadSize < 2 * 1024 * 1024 {
|
||||||
strongSelf.receivePacketPayload(size: Int(payloadSize))
|
strongSelf.receivePacketPayload(size: Int(payloadSize))
|
||||||
} else {
|
} else {
|
||||||
Logger.shared.log("CallSignaling", "Connection received invalid packet size: \(payloadSize)")
|
OngoingCallThreadLocalContextWebrtc.logMessage("CallSignaling: Connection received invalid packet size: \(payloadSize)")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Logger.shared.log("CallSignaling", "Connection receive packet header error: \(String(describing: error))")
|
OngoingCallThreadLocalContextWebrtc.logMessage("CallSignaling: Connection receive packet header error: \(String(describing: error))")
|
||||||
strongSelf.onIsClosed()
|
strongSelf.onIsClosed()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -1308,15 +1303,15 @@ private final class CallSignalingConnectionImpl: CallSignalingConnection {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if let data = data, data.count == size {
|
if let data = data, data.count == size {
|
||||||
Logger.shared.log("CallSignaling", "Connection receive packet payload: \(data.count) bytes")
|
OngoingCallThreadLocalContextWebrtc.logMessage("CallSignaling: Connection receive packet payload: \(data.count) bytes")
|
||||||
|
|
||||||
if data.count < 16 + 4 {
|
if data.count < 16 + 4 {
|
||||||
Logger.shared.log("CallSignaling", "Connection invalid payload size: \(data.count)")
|
OngoingCallThreadLocalContextWebrtc.logMessage("CallSignaling: Connection invalid payload size: \(data.count)")
|
||||||
strongSelf.onIsClosed()
|
strongSelf.onIsClosed()
|
||||||
} else {
|
} else {
|
||||||
let readPeerTag = data.subdata(in: 0 ..< 16)
|
let readPeerTag = data.subdata(in: 0 ..< 16)
|
||||||
if readPeerTag != strongSelf.peerTag {
|
if readPeerTag != strongSelf.peerTag {
|
||||||
Logger.shared.log("CallSignaling", "Peer tag mismatch: \(hexString(readPeerTag))")
|
OngoingCallThreadLocalContextWebrtc.logMessage("CallSignaling: Peer tag mismatch: \(hexString(readPeerTag))")
|
||||||
strongSelf.onIsClosed()
|
strongSelf.onIsClosed()
|
||||||
} else {
|
} else {
|
||||||
let actualPayloadSize = data.withUnsafeBytes { bytes -> UInt32 in
|
let actualPayloadSize = data.withUnsafeBytes { bytes -> UInt32 in
|
||||||
@ -1326,7 +1321,7 @@ private final class CallSignalingConnectionImpl: CallSignalingConnection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if Int(actualPayloadSize) > data.count - 16 - 4 {
|
if Int(actualPayloadSize) > data.count - 16 - 4 {
|
||||||
Logger.shared.log("CallSignaling", "Connection invalid actual payload size: \(actualPayloadSize)")
|
OngoingCallThreadLocalContextWebrtc.logMessage("CallSignaling: Connection invalid actual payload size: \(actualPayloadSize)")
|
||||||
strongSelf.onIsClosed()
|
strongSelf.onIsClosed()
|
||||||
} else {
|
} else {
|
||||||
if !strongSelf.isConnected {
|
if !strongSelf.isConnected {
|
||||||
@ -1348,7 +1343,7 @@ private final class CallSignalingConnectionImpl: CallSignalingConnection {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Logger.shared.log("CallSignaling", "Connection receive packet payload error: \(String(describing: error))")
|
OngoingCallThreadLocalContextWebrtc.logMessage("CallSignaling: Connection receive packet payload error: \(String(describing: error))")
|
||||||
strongSelf.onIsClosed()
|
strongSelf.onIsClosed()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -1397,11 +1392,11 @@ private final class CallSignalingConnectionImpl: CallSignalingConnection {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger.shared.log("CallSignaling", "Send packet payload: \(totalSize) bytes")
|
OngoingCallThreadLocalContextWebrtc.logMessage("CallSignaling: Send packet payload: \(totalSize) bytes")
|
||||||
|
|
||||||
self.connection.send(content: sendBuffer, isComplete: true, completion: .contentProcessed({ error in
|
self.connection.send(content: sendBuffer, isComplete: true, completion: .contentProcessed({ error in
|
||||||
if let error = error {
|
if let error = error {
|
||||||
Logger.shared.log("CallSignaling", "Connection send payload error: \(error)")
|
OngoingCallThreadLocalContextWebrtc.logMessage("CallSignaling: Connection send payload error: \(error)")
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
@ -195,6 +195,8 @@ typedef NS_ENUM(int32_t, OngoingCallDataSavingWebrtc) {
|
|||||||
|
|
||||||
@interface OngoingCallThreadLocalContextWebrtc : NSObject
|
@interface OngoingCallThreadLocalContextWebrtc : NSObject
|
||||||
|
|
||||||
|
+ (void)logMessage:(NSString * _Nonnull)string;
|
||||||
|
|
||||||
+ (void)setupLoggingFunction:(void (* _Nullable)(NSString * _Nullable))loggingFunction;
|
+ (void)setupLoggingFunction:(void (* _Nullable)(NSString * _Nullable))loggingFunction;
|
||||||
+ (void)applyServerConfig:(NSString * _Nullable)data;
|
+ (void)applyServerConfig:(NSString * _Nullable)data;
|
||||||
+ (int32_t)maxLayer;
|
+ (int32_t)maxLayer;
|
||||||
|
@ -38,6 +38,7 @@
|
|||||||
#include "sdk/objc/native/src/objc_frame_buffer.h"
|
#include "sdk/objc/native/src/objc_frame_buffer.h"
|
||||||
#import "components/video_frame_buffer/RTCCVPixelBuffer.h"
|
#import "components/video_frame_buffer/RTCCVPixelBuffer.h"
|
||||||
#import "platform/darwin/TGRTCCVPixelBuffer.h"
|
#import "platform/darwin/TGRTCCVPixelBuffer.h"
|
||||||
|
#include "rtc_base/logging.h"
|
||||||
|
|
||||||
@implementation OngoingCallConnectionDescriptionWebrtc
|
@implementation OngoingCallConnectionDescriptionWebrtc
|
||||||
|
|
||||||
@ -783,6 +784,10 @@ static tgcalls::DataSaving callControllerDataSavingForType(OngoingCallDataSaving
|
|||||||
|
|
||||||
static void (*InternalVoipLoggingFunction)(NSString *) = NULL;
|
static void (*InternalVoipLoggingFunction)(NSString *) = NULL;
|
||||||
|
|
||||||
|
+ (void)logMessage:(NSString * _Nonnull)string {
|
||||||
|
RTC_LOG(LS_INFO) << std::string(string.UTF8String);
|
||||||
|
}
|
||||||
|
|
||||||
+ (void)setupLoggingFunction:(void (*)(NSString *))loggingFunction {
|
+ (void)setupLoggingFunction:(void (*)(NSString *))loggingFunction {
|
||||||
InternalVoipLoggingFunction = loggingFunction;
|
InternalVoipLoggingFunction = loggingFunction;
|
||||||
tgcalls::SetLoggingFunction([](std::string const &string) {
|
tgcalls::SetLoggingFunction([](std::string const &string) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user