mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Merge branch 'master' of gitlab.com:peter-iakovlev/telegram-ios
This commit is contained in:
commit
6b25fa3e4b
@ -880,7 +880,7 @@ private final class ContextControllerNode: ViewControllerTracingNode, UIScrollVi
|
|||||||
if let validLayout = self.validLayout {
|
if let validLayout = self.validLayout {
|
||||||
self.updateLayout(
|
self.updateLayout(
|
||||||
layout: validLayout,
|
layout: validLayout,
|
||||||
transition: .animated(duration: 0.25, curve: .easeInOut),
|
transition: .animated(duration: 0.35, curve: .easeInOut),
|
||||||
previousActionsContainerNode: nil
|
previousActionsContainerNode: nil
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,58 @@ private struct ScanFilesResult {
|
|||||||
var totalSize: UInt64 = 0
|
var totalSize: UInt64 = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private func printOpenFiles() {
|
||||||
|
var flags: Int32 = 0
|
||||||
|
var fd: Int32 = 0
|
||||||
|
var buf = Data(count: Int(MAXPATHLEN) + 1)
|
||||||
|
|
||||||
|
while fd < FD_SETSIZE {
|
||||||
|
errno = 0;
|
||||||
|
flags = fcntl(fd, F_GETFD, 0);
|
||||||
|
if flags == -1 && errno != 0 {
|
||||||
|
if errno != EBADF {
|
||||||
|
return
|
||||||
|
} else {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
buf.withUnsafeMutableBytes { buffer -> Void in
|
||||||
|
let _ = fcntl(fd, F_GETPATH, buffer.baseAddress!)
|
||||||
|
let string = String(cString: buffer.baseAddress!.assumingMemoryBound(to: CChar.self))
|
||||||
|
print(string)
|
||||||
|
}
|
||||||
|
|
||||||
|
fd += 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
+(void) lsof
|
||||||
|
{
|
||||||
|
int flags;
|
||||||
|
int fd;
|
||||||
|
char buf[MAXPATHLEN+1] ;
|
||||||
|
int n = 1 ;
|
||||||
|
|
||||||
|
for (fd = 0; fd < (int) FD_SETSIZE; fd++) {
|
||||||
|
errno = 0;
|
||||||
|
flags = fcntl(fd, F_GETFD, 0);
|
||||||
|
if (flags == -1 && errno) {
|
||||||
|
if (errno != EBADF) {
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
fcntl(fd , F_GETPATH, buf ) ;
|
||||||
|
NSLog( @"File Descriptor %d number %d in use for: %s",fd,n , buf ) ;
|
||||||
|
++n ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
private func scanFiles(at path: String, olderThan minTimestamp: Int32, inodes: inout [InodeInfo]) -> ScanFilesResult {
|
private func scanFiles(at path: String, olderThan minTimestamp: Int32, inodes: inout [InodeInfo]) -> ScanFilesResult {
|
||||||
var result = ScanFilesResult()
|
var result = ScanFilesResult()
|
||||||
|
|
||||||
@ -208,8 +260,12 @@ private final class TimeBasedCleanupImpl {
|
|||||||
mapFiles(paths: paths, inodes: &inodes, removeSize: totalLimitSize - bytesLimit)
|
mapFiles(paths: paths, inodes: &inodes, removeSize: totalLimitSize - bytesLimit)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if DEBUG
|
||||||
|
//printOpenFiles()
|
||||||
|
#endif
|
||||||
|
|
||||||
if removedShortLivedCount != 0 || removedGeneralCount != 0 || removedGeneralLimitCount != 0 {
|
if removedShortLivedCount != 0 || removedGeneralCount != 0 || removedGeneralLimitCount != 0 {
|
||||||
print("[TimeBasedCleanup] \(CFAbsoluteTimeGetCurrent() - startTime) s removed \(removedShortLivedCount) short-lived files, \(removedGeneralCount) general files, \(removedGeneralLimitCount) limit files")
|
postboxLog("[TimeBasedCleanup] \(CFAbsoluteTimeGetCurrent() - startTime) s removed \(removedShortLivedCount) short-lived files, \(removedGeneralCount) general files, \(removedGeneralLimitCount) limit files")
|
||||||
}
|
}
|
||||||
subscriber.putCompletion()
|
subscriber.putCompletion()
|
||||||
}
|
}
|
||||||
|
@ -81,7 +81,7 @@ public final class CallKitIntegration {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func dropCall(uuid: UUID) {
|
public func dropCall(uuid: UUID) {
|
||||||
if #available(iOSApplicationExtension 10.0, iOS 10.0, *) {
|
if #available(iOSApplicationExtension 10.0, iOS 10.0, *) {
|
||||||
(sharedProviderDelegate as? CallKitProviderDelegate)?.dropCall(uuid: uuid)
|
(sharedProviderDelegate as? CallKitProviderDelegate)?.dropCall(uuid: uuid)
|
||||||
}
|
}
|
||||||
|
@ -537,9 +537,14 @@ private final class CallSessionManagerContext {
|
|||||||
guard let strongSelf = self else {
|
guard let strongSelf = self else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
strongSelf.contexts.removeValue(forKey: internalId)
|
context.state = .terminated(id: nil, accessHash: nil, reason: .ended(.missed), reportRating: false, sendDebugLogs: false)
|
||||||
strongSelf.contextIdByStableId.removeValue(forKey: stableId)
|
strongSelf.contextUpdated(internalId: internalId)
|
||||||
strongSelf.ringingStatesUpdated()
|
strongSelf.ringingStatesUpdated()
|
||||||
|
if context.isEmpty {
|
||||||
|
strongSelf.contexts.removeValue(forKey: internalId)
|
||||||
|
}
|
||||||
|
|
||||||
|
strongSelf.contextIdByStableId.removeValue(forKey: stableId)
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
self.contextIdByStableId[stableId] = internalId
|
self.contextIdByStableId[stableId] = internalId
|
||||||
|
@ -247,6 +247,7 @@ private func extractAccountManagerState(records: AccountRecordsView<TelegramAcco
|
|||||||
private let notificationAuthorizationDisposable = MetaDisposable()
|
private let notificationAuthorizationDisposable = MetaDisposable()
|
||||||
|
|
||||||
private var replyFromNotificationsDisposables = DisposableSet()
|
private var replyFromNotificationsDisposables = DisposableSet()
|
||||||
|
private var watchedCallsDisposables = DisposableSet()
|
||||||
|
|
||||||
private var _notificationTokenPromise: Promise<Data>?
|
private var _notificationTokenPromise: Promise<Data>?
|
||||||
private let voipTokenPromise = Promise<Data>()
|
private let voipTokenPromise = Promise<Data>()
|
||||||
@ -1582,13 +1583,34 @@ private func extractAccountManagerState(records: AccountRecordsView<TelegramAcco
|
|||||||
let _ = (sharedApplicationContext.sharedContext.activeAccountContexts
|
let _ = (sharedApplicationContext.sharedContext.activeAccountContexts
|
||||||
|> take(1)
|
|> take(1)
|
||||||
|> deliverOnMainQueue).start(next: { activeAccounts in
|
|> deliverOnMainQueue).start(next: { activeAccounts in
|
||||||
|
var processed = false
|
||||||
for (_, context, _) in activeAccounts.accounts {
|
for (_, context, _) in activeAccounts.accounts {
|
||||||
if context.account.id == accountId {
|
if context.account.id == accountId {
|
||||||
context.account.stateManager.processIncomingCallUpdate(data: updateData, completion: { _ in
|
context.account.stateManager.processIncomingCallUpdate(data: updateData, completion: { _ in
|
||||||
})
|
})
|
||||||
|
|
||||||
|
//callUpdate.callId
|
||||||
|
let disposable = MetaDisposable()
|
||||||
|
self.watchedCallsDisposables.add(disposable)
|
||||||
|
|
||||||
|
disposable.set((context.account.callSessionManager.callState(internalId: CallSessionManager.getStableIncomingUUID(stableId: callUpdate.callId))
|
||||||
|
|> deliverOnMainQueue).start(next: { state in
|
||||||
|
switch state.state {
|
||||||
|
case .terminated:
|
||||||
|
callKitIntegration.dropCall(uuid: CallSessionManager.getStableIncomingUUID(stableId: callUpdate.callId))
|
||||||
|
default:
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
}))
|
||||||
|
|
||||||
|
processed = true
|
||||||
|
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if !processed {
|
||||||
|
callKitIntegration.dropCall(uuid: CallSessionManager.getStableIncomingUUID(stableId: callUpdate.callId))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -144,9 +144,9 @@ final class NetworkBroadcastPartSource: BroadcastPartSource {
|
|||||||
}
|
}
|
||||||
|> deliverOn(self.queue)
|
|> deliverOn(self.queue)
|
||||||
|
|
||||||
#if DEBUG
|
/*#if DEBUG
|
||||||
let debugDumpDirectory = self.debugDumpDirectory
|
let debugDumpDirectory = self.debugDumpDirectory
|
||||||
#endif
|
#endif*/
|
||||||
return signal.start(next: { result in
|
return signal.start(next: { result in
|
||||||
guard let result = result else {
|
guard let result = result else {
|
||||||
completion(OngoingGroupCallBroadcastPart(timestampMilliseconds: timestampIdMilliseconds, responseTimestamp: Double(timestampIdMilliseconds), status: .notReady, oggData: Data()))
|
completion(OngoingGroupCallBroadcastPart(timestampMilliseconds: timestampIdMilliseconds, responseTimestamp: Double(timestampIdMilliseconds), status: .notReady, oggData: Data()))
|
||||||
@ -155,11 +155,11 @@ final class NetworkBroadcastPartSource: BroadcastPartSource {
|
|||||||
let part: OngoingGroupCallBroadcastPart
|
let part: OngoingGroupCallBroadcastPart
|
||||||
switch result.status {
|
switch result.status {
|
||||||
case let .data(dataValue):
|
case let .data(dataValue):
|
||||||
#if DEBUG
|
/*#if DEBUG
|
||||||
let tempFilePath = debugDumpDirectory.path + "/\(timestampMilliseconds).mp4"
|
let tempFilePath = debugDumpDirectory.path + "/\(timestampMilliseconds).mp4"
|
||||||
let _ = try? dataValue.subdata(in: 32 ..< dataValue.count).write(to: URL(fileURLWithPath: tempFilePath))
|
let _ = try? dataValue.subdata(in: 32 ..< dataValue.count).write(to: URL(fileURLWithPath: tempFilePath))
|
||||||
print("Dump stream part: \(tempFilePath)")
|
print("Dump stream part: \(tempFilePath)")
|
||||||
#endif
|
#endif*/
|
||||||
part = OngoingGroupCallBroadcastPart(timestampMilliseconds: timestampIdMilliseconds, responseTimestamp: result.responseTimestamp, status: .success, oggData: dataValue)
|
part = OngoingGroupCallBroadcastPart(timestampMilliseconds: timestampIdMilliseconds, responseTimestamp: result.responseTimestamp, status: .success, oggData: dataValue)
|
||||||
case .notReady:
|
case .notReady:
|
||||||
part = OngoingGroupCallBroadcastPart(timestampMilliseconds: timestampIdMilliseconds, responseTimestamp: result.responseTimestamp, status: .notReady, oggData: Data())
|
part = OngoingGroupCallBroadcastPart(timestampMilliseconds: timestampIdMilliseconds, responseTimestamp: result.responseTimestamp, status: .notReady, oggData: Data())
|
||||||
|
@ -18,8 +18,19 @@ private func callConnectionDescription(_ connection: CallSessionConnection) -> O
|
|||||||
|
|
||||||
private func callConnectionDescriptionsWebrtc(_ connection: CallSessionConnection) -> [OngoingCallConnectionDescriptionWebrtc] {
|
private func callConnectionDescriptionsWebrtc(_ connection: CallSessionConnection) -> [OngoingCallConnectionDescriptionWebrtc] {
|
||||||
switch connection {
|
switch connection {
|
||||||
case .reflector:
|
case let .reflector(reflector):
|
||||||
|
#if DEBUG
|
||||||
|
var result: [OngoingCallConnectionDescriptionWebrtc] = []
|
||||||
|
if !reflector.ip.isEmpty {
|
||||||
|
result.append(OngoingCallConnectionDescriptionWebrtc(connectionId: reflector.id, hasStun: false, hasTurn: true, ip: reflector.ip, port: reflector.port, username: "reflector", password: hexString(reflector.peerTag)))
|
||||||
|
}
|
||||||
|
if !reflector.ipv6.isEmpty {
|
||||||
|
result.append(OngoingCallConnectionDescriptionWebrtc(connectionId: reflector.id, hasStun: false, hasTurn: true, ip: reflector.ipv6, port: reflector.port, username: "reflector", password: hexString(reflector.peerTag)))
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
#else
|
||||||
return []
|
return []
|
||||||
|
#endif
|
||||||
case let .webRtcReflector(reflector):
|
case let .webRtcReflector(reflector):
|
||||||
var result: [OngoingCallConnectionDescriptionWebrtc] = []
|
var result: [OngoingCallConnectionDescriptionWebrtc] = []
|
||||||
if !reflector.ip.isEmpty {
|
if !reflector.ip.isEmpty {
|
||||||
@ -686,6 +697,11 @@ public final class OngoingCallContext {
|
|||||||
let _ = setupLogs
|
let _ = setupLogs
|
||||||
OngoingCallThreadLocalContext.applyServerConfig(serializedData)
|
OngoingCallThreadLocalContext.applyServerConfig(serializedData)
|
||||||
|
|
||||||
|
#if DEBUG
|
||||||
|
let version = "4.1.2"
|
||||||
|
let allowP2P = false
|
||||||
|
#endif
|
||||||
|
|
||||||
self.internalId = internalId
|
self.internalId = internalId
|
||||||
self.account = account
|
self.account = account
|
||||||
self.callSessionManager = callSessionManager
|
self.callSessionManager = callSessionManager
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#import "Instance.h"
|
#import "Instance.h"
|
||||||
#import "InstanceImpl.h"
|
#import "InstanceImpl.h"
|
||||||
#import "v2/InstanceV2Impl.h"
|
#import "v2/InstanceV2Impl.h"
|
||||||
|
#import "v2/InstanceV2ReferenceImpl.h"
|
||||||
#import "v2_4_0_0/InstanceV2_4_0_0Impl.h"
|
#import "v2_4_0_0/InstanceV2_4_0_0Impl.h"
|
||||||
#include "StaticThreads.h"
|
#include "StaticThreads.h"
|
||||||
|
|
||||||
@ -800,14 +801,29 @@ static void (*InternalVoipLoggingFunction)(NSString *) = NULL;
|
|||||||
return 92;
|
return 92;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
+ (void)ensureRegisteredImplementations {
|
||||||
|
static dispatch_once_t onceToken;
|
||||||
|
dispatch_once(&onceToken, ^{
|
||||||
|
tgcalls::Register<tgcalls::InstanceImpl>();
|
||||||
|
tgcalls::Register<tgcalls::InstanceV2_4_0_0Impl>();
|
||||||
|
tgcalls::Register<tgcalls::InstanceV2Impl>();
|
||||||
|
tgcalls::Register<tgcalls::InstanceV2ReferenceImpl>();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
+ (NSArray<NSString *> * _Nonnull)versionsWithIncludeReference:(bool)includeReference {
|
+ (NSArray<NSString *> * _Nonnull)versionsWithIncludeReference:(bool)includeReference {
|
||||||
|
[self ensureRegisteredImplementations];
|
||||||
|
|
||||||
NSMutableArray<NSString *> *list = [[NSMutableArray alloc] init];
|
NSMutableArray<NSString *> *list = [[NSMutableArray alloc] init];
|
||||||
[list addObject:@"2.7.7"];
|
|
||||||
[list addObject:@"3.0.0"];
|
for (const auto &version : tgcalls::Meta::Versions()) {
|
||||||
if (includeReference) {
|
[list addObject:[NSString stringWithUTF8String:version.c_str()]];
|
||||||
[list addObject:@"4.0.0"];
|
|
||||||
}
|
}
|
||||||
[list addObject:@"4.0.1"];
|
|
||||||
|
[list sortUsingComparator:^NSComparisonResult(NSString * _Nonnull lhs, NSString * _Nonnull rhs) {
|
||||||
|
return [lhs compare:rhs];
|
||||||
|
}];
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -915,15 +931,11 @@ static void (*InternalVoipLoggingFunction)(NSString *) = NULL;
|
|||||||
|
|
||||||
tgcalls::EncryptionKey encryptionKey(encryptionKeyValue, isOutgoing);
|
tgcalls::EncryptionKey encryptionKey(encryptionKeyValue, isOutgoing);
|
||||||
|
|
||||||
__weak OngoingCallThreadLocalContextWebrtc *weakSelf = self;
|
[OngoingCallThreadLocalContextWebrtc ensureRegisteredImplementations];
|
||||||
static dispatch_once_t onceToken;
|
|
||||||
dispatch_once(&onceToken, ^{
|
|
||||||
tgcalls::Register<tgcalls::InstanceImpl>();
|
|
||||||
tgcalls::Register<tgcalls::InstanceV2_4_0_0Impl>();
|
|
||||||
tgcalls::Register<tgcalls::InstanceV2Impl>();
|
|
||||||
});
|
|
||||||
|
|
||||||
|
__weak OngoingCallThreadLocalContextWebrtc *weakSelf = self;
|
||||||
_tgVoip = tgcalls::Meta::Create([version UTF8String], (tgcalls::Descriptor){
|
_tgVoip = tgcalls::Meta::Create([version UTF8String], (tgcalls::Descriptor){
|
||||||
|
.version = [version UTF8String],
|
||||||
.config = config,
|
.config = config,
|
||||||
.persistentState = (tgcalls::PersistentState){ derivedStateValue },
|
.persistentState = (tgcalls::PersistentState){ derivedStateValue },
|
||||||
.endpoints = endpoints,
|
.endpoints = endpoints,
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit b7460dd9572173aed1e3838f5eb33b813a1e6b31
|
Subproject commit 3ce2c38805ea5af7a05b8fe93a26becaf9e76bd3
|
4
third-party/webrtc/BUILD
vendored
4
third-party/webrtc/BUILD
vendored
@ -3256,6 +3256,7 @@ common_flags = [
|
|||||||
"-DWEBRTC_USE_H264",
|
"-DWEBRTC_USE_H264",
|
||||||
"-DHAVE_SCTP",
|
"-DHAVE_SCTP",
|
||||||
"-DWEBRTC_HAVE_USRSCTP",
|
"-DWEBRTC_HAVE_USRSCTP",
|
||||||
|
"-DWEBRTC_HAVE_SCTP",
|
||||||
"-Ithird-party/openh264",
|
"-Ithird-party/openh264",
|
||||||
"-DWEBRTC_NS_FLOAT",
|
"-DWEBRTC_NS_FLOAT",
|
||||||
"-DRTC_DISABLE_TRACE_EVENTS",
|
"-DRTC_DISABLE_TRACE_EVENTS",
|
||||||
@ -3392,6 +3393,7 @@ cc_library(
|
|||||||
"-DPACKAGE_VERSION=''",
|
"-DPACKAGE_VERSION=''",
|
||||||
"-DHAVE_SCTP",
|
"-DHAVE_SCTP",
|
||||||
"-DWEBRTC_HAVE_USRSCTP",
|
"-DWEBRTC_HAVE_USRSCTP",
|
||||||
|
"-DWEBRTC_HAVE_SCTP",
|
||||||
"-DNON_WINDOWS_DEFINE",
|
"-DNON_WINDOWS_DEFINE",
|
||||||
] + arch_specific_cflags + optimization_flags,
|
] + arch_specific_cflags + optimization_flags,
|
||||||
visibility = ["//visibility:public"],
|
visibility = ["//visibility:public"],
|
||||||
@ -3472,6 +3474,7 @@ cc_library(
|
|||||||
"-DPACKAGE_STRING='\"\"'",
|
"-DPACKAGE_STRING='\"\"'",
|
||||||
"-DHAVE_SCTP",
|
"-DHAVE_SCTP",
|
||||||
"-DWEBRTC_HAVE_USRSCTP",
|
"-DWEBRTC_HAVE_USRSCTP",
|
||||||
|
"-DWEBRTC_HAVE_SCTP",
|
||||||
] + arch_specific_cflags + optimization_flags,
|
] + arch_specific_cflags + optimization_flags,
|
||||||
deps = [
|
deps = [
|
||||||
"//third-party/boringssl:crypto",
|
"//third-party/boringssl:crypto",
|
||||||
@ -3522,6 +3525,7 @@ objc_library(
|
|||||||
"-DPACKAGE_VERSION='\"\"'",
|
"-DPACKAGE_VERSION='\"\"'",
|
||||||
"-DHAVE_SCTP",
|
"-DHAVE_SCTP",
|
||||||
"-DWEBRTC_HAVE_USRSCTP",
|
"-DWEBRTC_HAVE_USRSCTP",
|
||||||
|
"-DWEBRTC_HAVE_SCTP",
|
||||||
"-DNO_MAIN_THREAD_WRAPPING",
|
"-DNO_MAIN_THREAD_WRAPPING",
|
||||||
"-DRTC_DISABLE_TRACE_EVENTS",
|
"-DRTC_DISABLE_TRACE_EVENTS",
|
||||||
"-DRTC_DISABLE_METRICS",
|
"-DRTC_DISABLE_METRICS",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user