mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Merge branch 'master' into experiments/metal-background
This commit is contained in:
commit
609df3331f
@ -557,7 +557,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
|
|||||||
dict[1471006352] = { return Api.PhoneCallDiscardReason.parse_phoneCallDiscardReasonHangup($0) }
|
dict[1471006352] = { return Api.PhoneCallDiscardReason.parse_phoneCallDiscardReasonHangup($0) }
|
||||||
dict[-2048646399] = { return Api.PhoneCallDiscardReason.parse_phoneCallDiscardReasonMissed($0) }
|
dict[-2048646399] = { return Api.PhoneCallDiscardReason.parse_phoneCallDiscardReasonMissed($0) }
|
||||||
dict[-58224696] = { return Api.PhoneCallProtocol.parse_phoneCallProtocol($0) }
|
dict[-58224696] = { return Api.PhoneCallProtocol.parse_phoneCallProtocol($0) }
|
||||||
dict[-1655957568] = { return Api.PhoneConnection.parse_phoneConnection($0) }
|
dict[-1665063993] = { return Api.PhoneConnection.parse_phoneConnection($0) }
|
||||||
dict[1667228533] = { return Api.PhoneConnection.parse_phoneConnectionWebrtc($0) }
|
dict[1667228533] = { return Api.PhoneConnection.parse_phoneConnectionWebrtc($0) }
|
||||||
dict[-82216347] = { return Api.Photo.parse_photo($0) }
|
dict[-82216347] = { return Api.Photo.parse_photo($0) }
|
||||||
dict[590459437] = { return Api.Photo.parse_photoEmpty($0) }
|
dict[590459437] = { return Api.Photo.parse_photoEmpty($0) }
|
||||||
|
@ -1130,15 +1130,16 @@ public extension Api {
|
|||||||
}
|
}
|
||||||
public extension Api {
|
public extension Api {
|
||||||
enum PhoneConnection: TypeConstructorDescription {
|
enum PhoneConnection: TypeConstructorDescription {
|
||||||
case phoneConnection(id: Int64, ip: String, ipv6: String, port: Int32, peerTag: Buffer)
|
case phoneConnection(flags: Int32, id: Int64, ip: String, ipv6: String, port: Int32, peerTag: Buffer)
|
||||||
case phoneConnectionWebrtc(flags: Int32, id: Int64, ip: String, ipv6: String, port: Int32, username: String, password: String)
|
case phoneConnectionWebrtc(flags: Int32, id: Int64, ip: String, ipv6: String, port: Int32, username: String, password: String)
|
||||||
|
|
||||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||||
switch self {
|
switch self {
|
||||||
case .phoneConnection(let id, let ip, let ipv6, let port, let peerTag):
|
case .phoneConnection(let flags, let id, let ip, let ipv6, let port, let peerTag):
|
||||||
if boxed {
|
if boxed {
|
||||||
buffer.appendInt32(-1655957568)
|
buffer.appendInt32(-1665063993)
|
||||||
}
|
}
|
||||||
|
serializeInt32(flags, buffer: buffer, boxed: false)
|
||||||
serializeInt64(id, buffer: buffer, boxed: false)
|
serializeInt64(id, buffer: buffer, boxed: false)
|
||||||
serializeString(ip, buffer: buffer, boxed: false)
|
serializeString(ip, buffer: buffer, boxed: false)
|
||||||
serializeString(ipv6, buffer: buffer, boxed: false)
|
serializeString(ipv6, buffer: buffer, boxed: false)
|
||||||
@ -1162,31 +1163,34 @@ public extension Api {
|
|||||||
|
|
||||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||||
switch self {
|
switch self {
|
||||||
case .phoneConnection(let id, let ip, let ipv6, let port, let peerTag):
|
case .phoneConnection(let flags, let id, let ip, let ipv6, let port, let peerTag):
|
||||||
return ("phoneConnection", [("id", String(describing: id)), ("ip", String(describing: ip)), ("ipv6", String(describing: ipv6)), ("port", String(describing: port)), ("peerTag", String(describing: peerTag))])
|
return ("phoneConnection", [("flags", String(describing: flags)), ("id", String(describing: id)), ("ip", String(describing: ip)), ("ipv6", String(describing: ipv6)), ("port", String(describing: port)), ("peerTag", String(describing: peerTag))])
|
||||||
case .phoneConnectionWebrtc(let flags, let id, let ip, let ipv6, let port, let username, let password):
|
case .phoneConnectionWebrtc(let flags, let id, let ip, let ipv6, let port, let username, let password):
|
||||||
return ("phoneConnectionWebrtc", [("flags", String(describing: flags)), ("id", String(describing: id)), ("ip", String(describing: ip)), ("ipv6", String(describing: ipv6)), ("port", String(describing: port)), ("username", String(describing: username)), ("password", String(describing: password))])
|
return ("phoneConnectionWebrtc", [("flags", String(describing: flags)), ("id", String(describing: id)), ("ip", String(describing: ip)), ("ipv6", String(describing: ipv6)), ("port", String(describing: port)), ("username", String(describing: username)), ("password", String(describing: password))])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static func parse_phoneConnection(_ reader: BufferReader) -> PhoneConnection? {
|
public static func parse_phoneConnection(_ reader: BufferReader) -> PhoneConnection? {
|
||||||
var _1: Int64?
|
var _1: Int32?
|
||||||
_1 = reader.readInt64()
|
_1 = reader.readInt32()
|
||||||
var _2: String?
|
var _2: Int64?
|
||||||
_2 = parseString(reader)
|
_2 = reader.readInt64()
|
||||||
var _3: String?
|
var _3: String?
|
||||||
_3 = parseString(reader)
|
_3 = parseString(reader)
|
||||||
var _4: Int32?
|
var _4: String?
|
||||||
_4 = reader.readInt32()
|
_4 = parseString(reader)
|
||||||
var _5: Buffer?
|
var _5: Int32?
|
||||||
_5 = parseBytes(reader)
|
_5 = reader.readInt32()
|
||||||
|
var _6: Buffer?
|
||||||
|
_6 = parseBytes(reader)
|
||||||
let _c1 = _1 != nil
|
let _c1 = _1 != nil
|
||||||
let _c2 = _2 != nil
|
let _c2 = _2 != nil
|
||||||
let _c3 = _3 != nil
|
let _c3 = _3 != nil
|
||||||
let _c4 = _4 != nil
|
let _c4 = _4 != nil
|
||||||
let _c5 = _5 != nil
|
let _c5 = _5 != nil
|
||||||
if _c1 && _c2 && _c3 && _c4 && _c5 {
|
let _c6 = _6 != nil
|
||||||
return Api.PhoneConnection.phoneConnection(id: _1!, ip: _2!, ipv6: _3!, port: _4!, peerTag: _5!)
|
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 {
|
||||||
|
return Api.PhoneConnection.phoneConnection(flags: _1!, id: _2!, ip: _3!, ipv6: _4!, port: _5!, peerTag: _6!)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return nil
|
return nil
|
||||||
|
@ -217,6 +217,7 @@ public enum CallSessionConnection: Equatable {
|
|||||||
public let id: Int64
|
public let id: Int64
|
||||||
public let ip: String
|
public let ip: String
|
||||||
public let ipv6: String
|
public let ipv6: String
|
||||||
|
public let isTcp: Bool
|
||||||
public let port: Int32
|
public let port: Int32
|
||||||
public let peerTag: Data
|
public let peerTag: Data
|
||||||
|
|
||||||
@ -224,12 +225,14 @@ public enum CallSessionConnection: Equatable {
|
|||||||
id: Int64,
|
id: Int64,
|
||||||
ip: String,
|
ip: String,
|
||||||
ipv6: String,
|
ipv6: String,
|
||||||
|
isTcp: Bool,
|
||||||
port: Int32,
|
port: Int32,
|
||||||
peerTag: Data
|
peerTag: Data
|
||||||
) {
|
) {
|
||||||
self.id = id
|
self.id = id
|
||||||
self.ip = ip
|
self.ip = ip
|
||||||
self.ipv6 = ipv6
|
self.ipv6 = ipv6
|
||||||
|
self.isTcp = isTcp
|
||||||
self.port = port
|
self.port = port
|
||||||
self.peerTag = peerTag
|
self.peerTag = peerTag
|
||||||
}
|
}
|
||||||
@ -272,8 +275,9 @@ public enum CallSessionConnection: Equatable {
|
|||||||
|
|
||||||
private func parseConnection(_ apiConnection: Api.PhoneConnection) -> CallSessionConnection {
|
private func parseConnection(_ apiConnection: Api.PhoneConnection) -> CallSessionConnection {
|
||||||
switch apiConnection {
|
switch apiConnection {
|
||||||
case let .phoneConnection(id, ip, ipv6, port, peerTag):
|
case let .phoneConnection(flags, id, ip, ipv6, port, peerTag):
|
||||||
return .reflector(CallSessionConnection.Reflector(id: id, ip: ip, ipv6: ipv6, port: port, peerTag: peerTag.makeData()))
|
let isTcp = (flags & (1 << 0)) != 0
|
||||||
|
return .reflector(CallSessionConnection.Reflector(id: id, ip: ip, ipv6: ipv6, isTcp: isTcp, port: port, peerTag: peerTag.makeData()))
|
||||||
case let .phoneConnectionWebrtc(flags, id, ip, ipv6, port, username, password):
|
case let .phoneConnectionWebrtc(flags, id, ip, ipv6, port, username, password):
|
||||||
return .webRtcReflector(CallSessionConnection.WebRtcReflector(
|
return .webRtcReflector(CallSessionConnection.WebRtcReflector(
|
||||||
id: id,
|
id: id,
|
||||||
|
@ -9,7 +9,7 @@ import TgVoip
|
|||||||
import TgVoipWebrtc
|
import TgVoipWebrtc
|
||||||
|
|
||||||
private let debugUseLegacyVersionForReflectors: Bool = {
|
private let debugUseLegacyVersionForReflectors: Bool = {
|
||||||
#if DEBUG
|
#if DEBUG && false
|
||||||
return true
|
return true
|
||||||
#else
|
#else
|
||||||
return false
|
return false
|
||||||
@ -81,10 +81,10 @@ private func callConnectionDescriptionsWebrtc(_ connection: CallSessionConnectio
|
|||||||
}
|
}
|
||||||
var result: [OngoingCallConnectionDescriptionWebrtc] = []
|
var result: [OngoingCallConnectionDescriptionWebrtc] = []
|
||||||
if !reflector.ip.isEmpty {
|
if !reflector.ip.isEmpty {
|
||||||
result.append(OngoingCallConnectionDescriptionWebrtc(reflectorId: id, hasStun: false, hasTurn: true, hasTcp: false, ip: reflector.ip, port: reflector.port, username: "reflector", password: hexString(reflector.peerTag)))
|
result.append(OngoingCallConnectionDescriptionWebrtc(reflectorId: id, hasStun: false, hasTurn: true, hasTcp: reflector.isTcp, ip: reflector.ip, port: reflector.port, username: "reflector", password: hexString(reflector.peerTag)))
|
||||||
}
|
}
|
||||||
if !reflector.ipv6.isEmpty {
|
if !reflector.ipv6.isEmpty {
|
||||||
result.append(OngoingCallConnectionDescriptionWebrtc(reflectorId: id, hasStun: false, hasTurn: true, hasTcp: false, ip: reflector.ipv6, port: reflector.port, username: "reflector", password: hexString(reflector.peerTag)))
|
result.append(OngoingCallConnectionDescriptionWebrtc(reflectorId: id, hasStun: false, hasTurn: true, hasTcp: reflector.isTcp, ip: reflector.ipv6, port: reflector.port, username: "reflector", password: hexString(reflector.peerTag)))
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
case let .webRtcReflector(reflector):
|
case let .webRtcReflector(reflector):
|
||||||
@ -743,6 +743,12 @@ public final class OngoingCallContext {
|
|||||||
private var signalingConnectionManager: QueueLocalObject<CallSignalingConnectionManager>?
|
private var signalingConnectionManager: QueueLocalObject<CallSignalingConnectionManager>?
|
||||||
|
|
||||||
public static func versions(includeExperimental: Bool, includeReference: Bool) -> [(version: String, supportsVideo: Bool)] {
|
public static func versions(includeExperimental: Bool, includeReference: Bool) -> [(version: String, supportsVideo: Bool)] {
|
||||||
|
#if DEBUG
|
||||||
|
if "".isEmpty {
|
||||||
|
return [("5.0.0", true)]
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if debugUseLegacyVersionForReflectors {
|
if debugUseLegacyVersionForReflectors {
|
||||||
return [(OngoingCallThreadLocalContext.version(), true)]
|
return [(OngoingCallThreadLocalContext.version(), true)]
|
||||||
} else {
|
} else {
|
||||||
@ -784,7 +790,7 @@ public final class OngoingCallContext {
|
|||||||
var allowP2P = allowP2P
|
var allowP2P = allowP2P
|
||||||
if debugUseLegacyVersionForReflectors {
|
if debugUseLegacyVersionForReflectors {
|
||||||
useModernImplementation = true
|
useModernImplementation = true
|
||||||
version = "10.0.0"
|
version = "5.0.0"
|
||||||
allowP2P = false
|
allowP2P = false
|
||||||
} else {
|
} else {
|
||||||
useModernImplementation = version != OngoingCallThreadLocalContext.version()
|
useModernImplementation = version != OngoingCallThreadLocalContext.version()
|
||||||
@ -820,35 +826,53 @@ public final class OngoingCallContext {
|
|||||||
reflectorIdMapping[reflectorIdList[i]] = UInt8(i + 1)
|
reflectorIdMapping[reflectorIdList[i]] = UInt8(i + 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var signalingReflector: OngoingCallConnectionDescriptionWebrtc?
|
||||||
|
|
||||||
var processedConnections: [CallSessionConnection] = []
|
var processedConnections: [CallSessionConnection] = []
|
||||||
var filteredConnections: [OngoingCallConnectionDescriptionWebrtc] = []
|
var filteredConnections: [OngoingCallConnectionDescriptionWebrtc] = []
|
||||||
for connection in unfilteredConnections {
|
connectionsLoop: for connection in unfilteredConnections {
|
||||||
if processedConnections.contains(connection) {
|
if processedConnections.contains(connection) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
processedConnections.append(connection)
|
processedConnections.append(connection)
|
||||||
filteredConnections.append(contentsOf: callConnectionDescriptionsWebrtc(connection, idMapping: reflectorIdMapping))
|
|
||||||
|
switch connection {
|
||||||
|
case let .reflector(reflector):
|
||||||
|
if reflector.isTcp {
|
||||||
|
if signalingReflector == nil {
|
||||||
|
signalingReflector = OngoingCallConnectionDescriptionWebrtc(reflectorId: 0, hasStun: false, hasTurn: true, hasTcp: true, ip: reflector.ip, port: reflector.port, username: "reflector", password: hexString(reflector.peerTag))
|
||||||
|
}
|
||||||
|
|
||||||
|
continue connectionsLoop
|
||||||
|
}
|
||||||
|
case .webRtcReflector:
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
var webrtcConnections: [OngoingCallConnectionDescriptionWebrtc] = []
|
||||||
|
for connection in callConnectionDescriptionsWebrtc(connection, idMapping: reflectorIdMapping) {
|
||||||
|
webrtcConnections.append(connection)
|
||||||
|
}
|
||||||
|
|
||||||
|
filteredConnections.append(contentsOf: webrtcConnections)
|
||||||
}
|
}
|
||||||
|
|
||||||
for connection in filteredConnections {
|
if let signalingReflector = signalingReflector {
|
||||||
if connection.username == "reflector" {
|
if #available(iOS 12.0, *) {
|
||||||
let peerTag = dataWithHexString(connection.password)
|
let peerTag = dataWithHexString(signalingReflector.password)
|
||||||
if #available(iOS 12.0, *) {
|
|
||||||
strongSelf.signalingConnectionManager = QueueLocalObject(queue: queue, generate: {
|
|
||||||
return CallSignalingConnectionManager(queue: queue, peerTag: peerTag, servers: [OngoingCallConnectionDescriptionWebrtc(reflectorId: 0, hasStun: false, hasTurn: true, hasTcp: true, ip: "91.108.12.1", port: 533, username: "reflector", password: connection.password)], dataReceived: { data in
|
|
||||||
guard let strongSelf = self else {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
strongSelf.withContext { context in
|
|
||||||
if let context = context as? OngoingCallThreadLocalContextWebrtc {
|
|
||||||
context.addSignaling(data)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
break
|
strongSelf.signalingConnectionManager = QueueLocalObject(queue: queue, generate: {
|
||||||
|
return CallSignalingConnectionManager(queue: queue, peerTag: peerTag, servers: [signalingReflector], dataReceived: { data in
|
||||||
|
guard let strongSelf = self else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
strongSelf.withContext { context in
|
||||||
|
if let context = context as? OngoingCallThreadLocalContextWebrtc {
|
||||||
|
context.addSignaling(data)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit f3c148739bf0ad37a0882a7fcafcbc56969c4f8a
|
Subproject commit c741da4568b0971ed06d9ccdc7a94db566bb84a0
|
Loading…
x
Reference in New Issue
Block a user