Demo stream settings

This commit is contained in:
Ali 2021-02-27 00:39:47 +04:00
parent 64d5e51934
commit e33eb8db32
4 changed files with 31 additions and 23 deletions

View File

@ -73,7 +73,7 @@ private enum DebugControllerEntry: ItemListNodeEntry {
case optimizeDatabase(PresentationTheme) case optimizeDatabase(PresentationTheme)
case photoPreview(PresentationTheme, Bool) case photoPreview(PresentationTheme, Bool)
case knockoutWallpaper(PresentationTheme, Bool) case knockoutWallpaper(PresentationTheme, Bool)
case alternativeFolderTabs(Bool) case demoAudioStream(Bool)
case snapPinListToTop(Bool) case snapPinListToTop(Bool)
case playerEmbedding(Bool) case playerEmbedding(Bool)
case playlistPlayback(Bool) case playlistPlayback(Bool)
@ -94,7 +94,7 @@ private enum DebugControllerEntry: ItemListNodeEntry {
return DebugControllerSection.logging.rawValue return DebugControllerSection.logging.rawValue
case .enableRaiseToSpeak, .keepChatNavigationStack, .skipReadHistory, .crashOnSlowQueries: case .enableRaiseToSpeak, .keepChatNavigationStack, .skipReadHistory, .crashOnSlowQueries:
return DebugControllerSection.experiments.rawValue return DebugControllerSection.experiments.rawValue
case .clearTips, .reimport, .resetData, .resetDatabase, .resetDatabaseAndCache, .resetHoles, .reindexUnread, .resetBiometricsData, .optimizeDatabase, .photoPreview, .knockoutWallpaper, .alternativeFolderTabs, .snapPinListToTop, .playerEmbedding, .playlistPlayback, .voiceConference: case .clearTips, .reimport, .resetData, .resetDatabase, .resetDatabaseAndCache, .resetHoles, .reindexUnread, .resetBiometricsData, .optimizeDatabase, .photoPreview, .knockoutWallpaper, .demoAudioStream, .snapPinListToTop, .playerEmbedding, .playlistPlayback, .voiceConference:
return DebugControllerSection.experiments.rawValue return DebugControllerSection.experiments.rawValue
case .preferredVideoCodec: case .preferredVideoCodec:
return DebugControllerSection.videoExperiments.rawValue return DebugControllerSection.videoExperiments.rawValue
@ -155,7 +155,7 @@ private enum DebugControllerEntry: ItemListNodeEntry {
return 22 return 22
case .knockoutWallpaper: case .knockoutWallpaper:
return 23 return 23
case .alternativeFolderTabs: case .demoAudioStream:
return 24 return 24
case .snapPinListToTop: case .snapPinListToTop:
return 25 return 25
@ -696,7 +696,7 @@ private enum DebugControllerEntry: ItemListNodeEntry {
}) })
}).start() }).start()
}) })
case let .knockoutWallpaper(theme, value): case let .knockoutWallpaper(_, value):
return ItemListSwitchItem(presentationData: presentationData, title: "Knockout Wallpaper", value: value, sectionId: self.section, style: .blocks, updated: { value in return ItemListSwitchItem(presentationData: presentationData, title: "Knockout Wallpaper", value: value, sectionId: self.section, style: .blocks, updated: { value in
let _ = arguments.sharedContext.accountManager.transaction ({ transaction in let _ = arguments.sharedContext.accountManager.transaction ({ transaction in
transaction.updateSharedData(ApplicationSpecificSharedDataKeys.experimentalUISettings, { settings in transaction.updateSharedData(ApplicationSpecificSharedDataKeys.experimentalUISettings, { settings in
@ -706,12 +706,12 @@ private enum DebugControllerEntry: ItemListNodeEntry {
}) })
}).start() }).start()
}) })
case let .alternativeFolderTabs(value): case let .demoAudioStream(value):
return ItemListSwitchItem(presentationData: presentationData, title: "Alternative Tabs", value: value, sectionId: self.section, style: .blocks, updated: { value in return ItemListSwitchItem(presentationData: presentationData, title: "Demo Audio Stream", value: value, sectionId: self.section, style: .blocks, updated: { value in
let _ = arguments.sharedContext.accountManager.transaction ({ transaction in let _ = arguments.sharedContext.accountManager.transaction ({ transaction in
transaction.updateSharedData(ApplicationSpecificSharedDataKeys.experimentalUISettings, { settings in transaction.updateSharedData(ApplicationSpecificSharedDataKeys.experimentalUISettings, { settings in
var settings = settings as? ExperimentalUISettings ?? ExperimentalUISettings.defaultSettings var settings = settings as? ExperimentalUISettings ?? ExperimentalUISettings.defaultSettings
settings.foldersTabAtBottom = value settings.demoAudioStream = value
return settings return settings
}) })
}).start() }).start()
@ -826,7 +826,7 @@ private func debugControllerEntries(presentationData: PresentationData, loggingS
entries.append(.optimizeDatabase(presentationData.theme)) entries.append(.optimizeDatabase(presentationData.theme))
//entries.append(.photoPreview(presentationData.theme, experimentalSettings.chatListPhotos)) //entries.append(.photoPreview(presentationData.theme, experimentalSettings.chatListPhotos))
entries.append(.knockoutWallpaper(presentationData.theme, experimentalSettings.knockoutWallpaper)) entries.append(.knockoutWallpaper(presentationData.theme, experimentalSettings.knockoutWallpaper))
entries.append(.alternativeFolderTabs(experimentalSettings.foldersTabAtBottom)) entries.append(.demoAudioStream(experimentalSettings.demoAudioStream))
entries.append(.snapPinListToTop(experimentalSettings.snapPinListToTop)) entries.append(.snapPinListToTop(experimentalSettings.snapPinListToTop))
entries.append(.playerEmbedding(experimentalSettings.playerEmbedding)) entries.append(.playerEmbedding(experimentalSettings.playerEmbedding))
entries.append(.playlistPlayback(experimentalSettings.playlistPlayback)) entries.append(.playlistPlayback(experimentalSettings.playlistPlayback))

View File

@ -845,7 +845,7 @@ public final class PresentationGroupCallImpl: PresentationGroupCall {
} }
strongSelf.maybeRequestParticipants(ssrcs: ssrcs) strongSelf.maybeRequestParticipants(ssrcs: ssrcs)
} }
}) }, demoAudioStream: self.accountContext.sharedContext.immediateExperimentalUISettings.demoAudioStream)
self.incomingVideoSourcePromise.set(callContext.videoSources self.incomingVideoSourcePromise.set(callContext.videoSources
|> deliverOnMainQueue |> deliverOnMainQueue
|> map { [weak self] sources -> [PeerId: UInt32] in |> map { [weak self] sources -> [PeerId: UInt32] in

View File

@ -15,6 +15,7 @@ public struct ExperimentalUISettings: Equatable, PreferencesEntry {
public var disableVideoAspectScaling: Bool public var disableVideoAspectScaling: Bool
public var enableVoipTcp: Bool public var enableVoipTcp: Bool
public var snapPinListToTop: Bool public var snapPinListToTop: Bool
public var demoAudioStream: Bool
public static var defaultSettings: ExperimentalUISettings { public static var defaultSettings: ExperimentalUISettings {
return ExperimentalUISettings( return ExperimentalUISettings(
@ -29,7 +30,8 @@ public struct ExperimentalUISettings: Equatable, PreferencesEntry {
preferredVideoCodec: nil, preferredVideoCodec: nil,
disableVideoAspectScaling: false, disableVideoAspectScaling: false,
enableVoipTcp: false, enableVoipTcp: false,
snapPinListToTop: false snapPinListToTop: false,
demoAudioStream: false
) )
} }
@ -45,7 +47,8 @@ public struct ExperimentalUISettings: Equatable, PreferencesEntry {
preferredVideoCodec: String?, preferredVideoCodec: String?,
disableVideoAspectScaling: Bool, disableVideoAspectScaling: Bool,
enableVoipTcp: Bool, enableVoipTcp: Bool,
snapPinListToTop: Bool snapPinListToTop: Bool,
demoAudioStream: Bool
) { ) {
self.keepChatNavigationStack = keepChatNavigationStack self.keepChatNavigationStack = keepChatNavigationStack
self.skipReadHistory = skipReadHistory self.skipReadHistory = skipReadHistory
@ -59,6 +62,7 @@ public struct ExperimentalUISettings: Equatable, PreferencesEntry {
self.disableVideoAspectScaling = disableVideoAspectScaling self.disableVideoAspectScaling = disableVideoAspectScaling
self.enableVoipTcp = enableVoipTcp self.enableVoipTcp = enableVoipTcp
self.snapPinListToTop = snapPinListToTop self.snapPinListToTop = snapPinListToTop
self.demoAudioStream = demoAudioStream
} }
public init(decoder: PostboxDecoder) { public init(decoder: PostboxDecoder) {
@ -74,6 +78,7 @@ public struct ExperimentalUISettings: Equatable, PreferencesEntry {
self.disableVideoAspectScaling = decoder.decodeInt32ForKey("disableVideoAspectScaling", orElse: 0) != 0 self.disableVideoAspectScaling = decoder.decodeInt32ForKey("disableVideoAspectScaling", orElse: 0) != 0
self.enableVoipTcp = decoder.decodeInt32ForKey("enableVoipTcp", orElse: 0) != 0 self.enableVoipTcp = decoder.decodeInt32ForKey("enableVoipTcp", orElse: 0) != 0
self.snapPinListToTop = decoder.decodeInt32ForKey("snapPinListToTop", orElse: 0) != 0 self.snapPinListToTop = decoder.decodeInt32ForKey("snapPinListToTop", orElse: 0) != 0
self.demoAudioStream = decoder.decodeInt32ForKey("demoAudioStream", orElse: 0) != 0
} }
public func encode(_ encoder: PostboxEncoder) { public func encode(_ encoder: PostboxEncoder) {
@ -91,6 +96,7 @@ public struct ExperimentalUISettings: Equatable, PreferencesEntry {
encoder.encodeInt32(self.disableVideoAspectScaling ? 1 : 0, forKey: "disableVideoAspectScaling") encoder.encodeInt32(self.disableVideoAspectScaling ? 1 : 0, forKey: "disableVideoAspectScaling")
encoder.encodeInt32(self.enableVoipTcp ? 1 : 0, forKey: "enableVoipTcp") encoder.encodeInt32(self.enableVoipTcp ? 1 : 0, forKey: "enableVoipTcp")
encoder.encodeInt32(self.snapPinListToTop ? 1 : 0, forKey: "snapPinListToTop") encoder.encodeInt32(self.snapPinListToTop ? 1 : 0, forKey: "snapPinListToTop")
encoder.encodeInt32(self.demoAudioStream ? 1 : 0, forKey: "demoAudioStream")
} }
public func isEqual(to: PreferencesEntry) -> Bool { public func isEqual(to: PreferencesEntry) -> Bool {

View File

@ -129,7 +129,7 @@ public final class OngoingGroupCallContext {
private var broadcastPacketSource: DemoBroadcastPacketSource? private var broadcastPacketSource: DemoBroadcastPacketSource?
private var broadcastPacketsDisposable: Disposable? private var broadcastPacketsDisposable: Disposable?
init(queue: Queue, inputDeviceId: String, outputDeviceId: String, video: OngoingCallVideoCapturer?, participantDescriptionsRequired: @escaping (Set<UInt32>) -> Void) { init(queue: Queue, inputDeviceId: String, outputDeviceId: String, video: OngoingCallVideoCapturer?, participantDescriptionsRequired: @escaping (Set<UInt32>) -> Void, demoAudioStream: Bool) {
self.queue = queue self.queue = queue
var networkStateUpdatedImpl: ((GroupCallNetworkState) -> Void)? var networkStateUpdatedImpl: ((GroupCallNetworkState) -> Void)?
@ -204,15 +204,17 @@ public final class OngoingGroupCallContext {
} }
}) })
let broadcastPacketSource = DemoBroadcastPacketSource(queue: queue) if demoAudioStream {
self.broadcastPacketSource = broadcastPacketSource let broadcastPacketSource = DemoBroadcastPacketSource(queue: queue)
self.broadcastPacketsDisposable = (broadcastPacketSource.packets self.broadcastPacketSource = broadcastPacketSource
|> deliverOn(queue)).start(next: { [weak self] packets in self.broadcastPacketsDisposable = (broadcastPacketSource.packets
guard let strongSelf = self else { |> deliverOn(queue)).start(next: { [weak self] packets in
return guard let strongSelf = self else {
} return
strongSelf.context.add(packets) }
}) strongSelf.context.add(packets)
})
}
/*var packets: [OngoingGroupCallBroadcastPacket] = [] /*var packets: [OngoingGroupCallBroadcastPacket] = []
for i in 0 ..< 200 { for i in 0 ..< 200 {
@ -466,10 +468,10 @@ public final class OngoingGroupCallContext {
} }
} }
public init(inputDeviceId: String = "", outputDeviceId: String = "", video: OngoingCallVideoCapturer?, participantDescriptionsRequired: @escaping (Set<UInt32>) -> Void) { public init(inputDeviceId: String = "", outputDeviceId: String = "", video: OngoingCallVideoCapturer?, participantDescriptionsRequired: @escaping (Set<UInt32>) -> Void, demoAudioStream: Bool) {
let queue = self.queue let queue = self.queue
self.impl = QueueLocalObject(queue: queue, generate: { self.impl = QueueLocalObject(queue: queue, generate: {
return Impl(queue: queue, inputDeviceId: inputDeviceId, outputDeviceId: outputDeviceId, video: video, participantDescriptionsRequired: participantDescriptionsRequired) return Impl(queue: queue, inputDeviceId: inputDeviceId, outputDeviceId: outputDeviceId, video: video, participantDescriptionsRequired: participantDescriptionsRequired, demoAudioStream: demoAudioStream)
}) })
} }