diff --git a/submodules/SettingsUI/Sources/DebugController.swift b/submodules/SettingsUI/Sources/DebugController.swift index d06d8a8810..bbb4655be9 100644 --- a/submodules/SettingsUI/Sources/DebugController.swift +++ b/submodules/SettingsUI/Sources/DebugController.swift @@ -73,6 +73,7 @@ private enum DebugControllerEntry: ItemListNodeEntry { case playerEmbedding(Bool) case playlistPlayback(Bool) case videoCalls(Bool) + case videoCallsReference(Bool) case videoCallsInfo(PresentationTheme, String) case hostInfo(PresentationTheme, String) case versionInfo(PresentationTheme) @@ -89,7 +90,7 @@ private enum DebugControllerEntry: ItemListNodeEntry { return DebugControllerSection.experiments.rawValue case .clearTips, .reimport, .resetData, .resetDatabase, .resetHoles, .reindexUnread, .resetBiometricsData, .optimizeDatabase, .photoPreview, .knockoutWallpaper, .alternativeFolderTabs, .playerEmbedding, .playlistPlayback: return DebugControllerSection.experiments.rawValue - case .videoCalls, .videoCallsInfo: + case .videoCalls, .videoCallsReference, .videoCallsInfo: return DebugControllerSection.videoExperiments.rawValue case .hostInfo, .versionInfo: return DebugControllerSection.info.rawValue @@ -150,12 +151,14 @@ private enum DebugControllerEntry: ItemListNodeEntry { return 25 case .videoCalls: return 26 - case .videoCallsInfo: + case .videoCallsReference: return 27 - case .hostInfo: + case .videoCallsInfo: return 28 - case .versionInfo: + case .hostInfo: return 29 + case .versionInfo: + return 30 } } @@ -583,6 +586,16 @@ private enum DebugControllerEntry: ItemListNodeEntry { }) }).start() }) + case let .videoCallsReference(value): + return ItemListSwitchItem(presentationData: presentationData, title: "Reference Implementation", value: value, sectionId: self.section, style: .blocks, updated: { value in + let _ = arguments.sharedContext.accountManager.transaction ({ transaction in + transaction.updateSharedData(ApplicationSpecificSharedDataKeys.experimentalUISettings, { settings in + var settings = settings as? ExperimentalUISettings ?? ExperimentalUISettings.defaultSettings + settings.videoCallsReference = value + return settings + }) + }).start() + }) case let .videoCallsInfo(_, text): return ItemListTextItem(presentationData: presentationData, text: .plain(text), sectionId: self.section) case let .hostInfo(theme, string): @@ -631,6 +644,9 @@ private func debugControllerEntries(presentationData: PresentationData, loggingS entries.append(.playerEmbedding(experimentalSettings.playerEmbedding)) entries.append(.playlistPlayback(experimentalSettings.playlistPlayback)) entries.append(.videoCalls(experimentalSettings.videoCalls)) + if experimentalSettings.videoCalls { + entries.append(.videoCallsReference(experimentalSettings.videoCallsReference)) + } entries.append(.videoCallsInfo(presentationData.theme, "Enables experimental transmission of electromagnetic radiation synchronized with pressure waves. Needs to be enabled on both sides.")) if let backupHostOverride = networkSettings?.backupHostOverride { diff --git a/submodules/TelegramCallsUI/Sources/PresentationCallManager.swift b/submodules/TelegramCallsUI/Sources/PresentationCallManager.swift index 07e10639f9..2e46db75d8 100644 --- a/submodules/TelegramCallsUI/Sources/PresentationCallManager.swift +++ b/submodules/TelegramCallsUI/Sources/PresentationCallManager.swift @@ -117,8 +117,8 @@ public final class PresentationCallManagerImpl: PresentationCallManager { return OngoingCallContext.maxLayer } - public static func voipVersions(includeExperimental: Bool) -> [String] { - return OngoingCallContext.versions(includeExperimental: includeExperimental) + public static func voipVersions(includeExperimental: Bool, includeReference: Bool) -> [String] { + return OngoingCallContext.versions(includeExperimental: includeExperimental, includeReference: includeReference) } public init(accountManager: AccountManager, enableVideoCalls: Bool, getDeviceAccessData: @escaping () -> (presentationData: PresentationData, present: (ViewController, Any?) -> Void, openSettings: () -> Void), isMediaPlaying: @escaping () -> Bool, resumeMediaPlayback: @escaping () -> Void, audioSession: ManagedAudioSession, activeAccounts: Signal<[Account], NoError>) { diff --git a/submodules/TelegramUI/Sources/AccountContext.swift b/submodules/TelegramUI/Sources/AccountContext.swift index 415122b9be..2831a024c4 100644 --- a/submodules/TelegramUI/Sources/AccountContext.swift +++ b/submodules/TelegramUI/Sources/AccountContext.swift @@ -251,7 +251,7 @@ public final class AccountContextImpl: AccountContext { self.experimentalUISettingsDisposable = (sharedContext.accountManager.sharedData(keys: [ApplicationSpecificSharedDataKeys.experimentalUISettings]) |> deliverOnMainQueue).start(next: { sharedData in if let settings = sharedData.entries[ApplicationSpecificSharedDataKeys.experimentalUISettings] as? ExperimentalUISettings { - account.callSessionManager.updateVersions(versions: PresentationCallManagerImpl.voipVersions(includeExperimental: settings.videoCalls)) + account.callSessionManager.updateVersions(versions: PresentationCallManagerImpl.voipVersions(includeExperimental: settings.videoCalls, includeReference: settings.videoCallsReference)) } }) } diff --git a/submodules/TelegramUI/Sources/AppDelegate.swift b/submodules/TelegramUI/Sources/AppDelegate.swift index 46a7105a54..34b6d9f77c 100644 --- a/submodules/TelegramUI/Sources/AppDelegate.swift +++ b/submodules/TelegramUI/Sources/AppDelegate.swift @@ -401,7 +401,7 @@ final class SharedApplicationContext { } } - let networkArguments = NetworkInitializationArguments(apiId: apiId, apiHash: apiHash, languagesCategory: languagesCategory, appVersion: appVersion, voipMaxLayer: PresentationCallManagerImpl.voipMaxLayer, voipVersions: PresentationCallManagerImpl.voipVersions(includeExperimental: false), appData: self.deviceToken.get() + let networkArguments = NetworkInitializationArguments(apiId: apiId, apiHash: apiHash, languagesCategory: languagesCategory, appVersion: appVersion, voipMaxLayer: PresentationCallManagerImpl.voipMaxLayer, voipVersions: PresentationCallManagerImpl.voipVersions(includeExperimental: false, includeReference: false), appData: self.deviceToken.get() |> map { token in let data = buildConfig.bundleData(withAppToken: token, signatureDict: signatureDict) if let data = data, let jsonString = String(data: data, encoding: .utf8) { diff --git a/submodules/TelegramUIPreferences/Sources/ExperimentalUISettings.swift b/submodules/TelegramUIPreferences/Sources/ExperimentalUISettings.swift index 53d7c35a41..dfe4522ec2 100644 --- a/submodules/TelegramUIPreferences/Sources/ExperimentalUISettings.swift +++ b/submodules/TelegramUIPreferences/Sources/ExperimentalUISettings.swift @@ -10,6 +10,7 @@ public struct ExperimentalUISettings: Equatable, PreferencesEntry { public var knockoutWallpaper: Bool public var foldersTabAtBottom: Bool public var videoCalls: Bool + public var videoCallsReference: Bool public var playerEmbedding: Bool public var playlistPlayback: Bool @@ -22,6 +23,7 @@ public struct ExperimentalUISettings: Equatable, PreferencesEntry { knockoutWallpaper: false, foldersTabAtBottom: false, videoCalls: false, + videoCallsReference: true, playerEmbedding: false, playlistPlayback: false ) @@ -35,6 +37,7 @@ public struct ExperimentalUISettings: Equatable, PreferencesEntry { knockoutWallpaper: Bool, foldersTabAtBottom: Bool, videoCalls: Bool, + videoCallsReference: Bool, playerEmbedding: Bool, playlistPlayback: Bool ) { @@ -45,6 +48,7 @@ public struct ExperimentalUISettings: Equatable, PreferencesEntry { self.knockoutWallpaper = knockoutWallpaper self.foldersTabAtBottom = foldersTabAtBottom self.videoCalls = videoCalls + self.videoCallsReference = videoCallsReference self.playerEmbedding = playerEmbedding self.playlistPlayback = playlistPlayback } @@ -57,6 +61,7 @@ public struct ExperimentalUISettings: Equatable, PreferencesEntry { self.knockoutWallpaper = decoder.decodeInt32ForKey("knockoutWallpaper", orElse: 0) != 0 self.foldersTabAtBottom = decoder.decodeInt32ForKey("foldersTabAtBottom", orElse: 0) != 0 self.videoCalls = decoder.decodeInt32ForKey("videoCalls", orElse: 0) != 0 + self.videoCallsReference = decoder.decodeInt32ForKey("videoCallsReference", orElse: 1) != 0 self.playerEmbedding = decoder.decodeInt32ForKey("playerEmbedding", orElse: 0) != 0 self.playlistPlayback = decoder.decodeInt32ForKey("playlistPlayback", orElse: 0) != 0 } @@ -69,6 +74,7 @@ public struct ExperimentalUISettings: Equatable, PreferencesEntry { encoder.encodeInt32(self.knockoutWallpaper ? 1 : 0, forKey: "knockoutWallpaper") encoder.encodeInt32(self.foldersTabAtBottom ? 1 : 0, forKey: "foldersTabAtBottom") encoder.encodeInt32(self.videoCalls ? 1 : 0, forKey: "videoCalls") + encoder.encodeInt32(self.videoCallsReference ? 1 : 0, forKey: "videoCallsReference") encoder.encodeInt32(self.playerEmbedding ? 1 : 0, forKey: "playerEmbedding") encoder.encodeInt32(self.playlistPlayback ? 1 : 0, forKey: "playlistPlayback") } diff --git a/submodules/TelegramVoip/Sources/OngoingCallContext.swift b/submodules/TelegramVoip/Sources/OngoingCallContext.swift index 05f0d10e4c..decd2602b9 100644 --- a/submodules/TelegramVoip/Sources/OngoingCallContext.swift +++ b/submodules/TelegramVoip/Sources/OngoingCallContext.swift @@ -468,10 +468,10 @@ public final class OngoingCallContext { return OngoingCallThreadLocalContext.maxLayer() } - public static func versions(includeExperimental: Bool) -> [String] { + public static func versions(includeExperimental: Bool, includeReference: Bool) -> [String] { var result: [String] = [OngoingCallThreadLocalContext.version()] if includeExperimental { - result.append(contentsOf: OngoingCallThreadLocalContextWebrtc.versions()) + result.append(contentsOf: OngoingCallThreadLocalContextWebrtc.versions(withIncludeReference: includeReference)) } return result } @@ -495,7 +495,7 @@ public final class OngoingCallContext { |> take(1) |> deliverOn(queue)).start(next: { [weak self] _ in if let strongSelf = self { - if OngoingCallThreadLocalContextWebrtc.versions().contains(version) { + if OngoingCallThreadLocalContextWebrtc.versions(withIncludeReference: true).contains(version) { var voipProxyServer: VoipProxyServerWebrtc? if let proxyServer = proxyServer { switch proxyServer.connection { diff --git a/submodules/TgVoipWebrtc/PublicHeaders/TgVoip/OngoingCallThreadLocalContext.h b/submodules/TgVoipWebrtc/PublicHeaders/TgVoip/OngoingCallThreadLocalContext.h index ccfbb751fa..aa26669cba 100644 --- a/submodules/TgVoipWebrtc/PublicHeaders/TgVoip/OngoingCallThreadLocalContext.h +++ b/submodules/TgVoipWebrtc/PublicHeaders/TgVoip/OngoingCallThreadLocalContext.h @@ -107,7 +107,7 @@ typedef NS_ENUM(int32_t, OngoingCallDataSavingWebrtc) { + (void)setupLoggingFunction:(void (* _Nullable)(NSString * _Nullable))loggingFunction; + (void)applyServerConfig:(NSString * _Nullable)data; + (int32_t)maxLayer; -+ (NSArray * _Nonnull)versions; ++ (NSArray * _Nonnull)versionsWithIncludeReference:(bool)includeReference; @property (nonatomic, copy) void (^ _Nullable stateChanged)(OngoingCallStateWebrtc, OngoingCallVideoStateWebrtc, OngoingCallRemoteVideoStateWebrtc); @property (nonatomic, copy) void (^ _Nullable signalBarsChanged)(int32_t); diff --git a/submodules/TgVoipWebrtc/Sources/OngoingCallThreadLocalContext.mm b/submodules/TgVoipWebrtc/Sources/OngoingCallThreadLocalContext.mm index 9d5074d98a..6cc65df000 100644 --- a/submodules/TgVoipWebrtc/Sources/OngoingCallThreadLocalContext.mm +++ b/submodules/TgVoipWebrtc/Sources/OngoingCallThreadLocalContext.mm @@ -235,8 +235,12 @@ static void (*InternalVoipLoggingFunction)(NSString *) = NULL; return 92; } -+ (NSArray * _Nonnull)versions { - return @[@"2.7.7", @"2.8.8"]; ++ (NSArray * _Nonnull)versionsWithIncludeReference:(bool)includeReference { + if (includeReference) { + return @[@"2.7.7", @"2.8.8"]; + } else { + return @[@"2.7.7"]; + } } - (instancetype _Nonnull)initWithVersion:(NSString * _Nonnull)version queue:(id _Nonnull)queue proxy:(VoipProxyServerWebrtc * _Nullable)proxy rtcServers:(NSArray * _Nonnull)rtcServers networkType:(OngoingCallNetworkTypeWebrtc)networkType dataSaving:(OngoingCallDataSavingWebrtc)dataSaving derivedState:(NSData * _Nonnull)derivedState key:(NSData * _Nonnull)key isOutgoing:(bool)isOutgoing primaryConnection:(OngoingCallConnectionDescriptionWebrtc * _Nonnull)primaryConnection alternativeConnections:(NSArray * _Nonnull)alternativeConnections maxLayer:(int32_t)maxLayer allowP2P:(BOOL)allowP2P logPath:(NSString * _Nonnull)logPath sendSignalingData:(void (^)(NSData * _Nonnull))sendSignalingData videoCapturer:(OngoingCallThreadLocalContextVideoCapturer * _Nullable)videoCapturer { @@ -246,7 +250,7 @@ static void (*InternalVoipLoggingFunction)(NSString *) = NULL; _queue = queue; assert([queue isCurrent]); - assert([[OngoingCallThreadLocalContextWebrtc versions] containsObject:version]); + assert([[OngoingCallThreadLocalContextWebrtc versionsWithIncludeReference:true] containsObject:version]); _callReceiveTimeout = 20.0; _callRingTimeout = 90.0; @@ -327,9 +331,8 @@ static void (*InternalVoipLoggingFunction)(NSString *) = NULL; .maxApiLayer = [OngoingCallThreadLocalContextWebrtc maxLayer] }; - std::vector encryptionKeyValue; - encryptionKeyValue.resize(key.length); - memcpy(encryptionKeyValue.data(), key.bytes, key.length); + auto encryptionKeyValue = std::make_shared>(); + memcpy(encryptionKeyValue->data(), key.bytes, key.length); tgcalls::EncryptionKey encryptionKey(encryptionKeyValue, isOutgoing); diff --git a/submodules/TgVoipWebrtc/tgcalls b/submodules/TgVoipWebrtc/tgcalls index a022072ed3..8e9d3e56d4 160000 --- a/submodules/TgVoipWebrtc/tgcalls +++ b/submodules/TgVoipWebrtc/tgcalls @@ -1 +1 @@ -Subproject commit a022072ed3f57f4cd4ec42c088f5baad8dfdd7c4 +Subproject commit 8e9d3e56d43ffa4ed9ababd5fe7a4b5df8ec94d1