mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-15 13:35:19 +00:00
Add logging
This commit is contained in:
parent
155b8765a8
commit
193f9b9124
1
.bazelrc
1
.bazelrc
@ -9,4 +9,5 @@ build --strategy=SwiftCompile=local
|
||||
build --features=debug_prefix_map_pwd_is_dot
|
||||
build --features=swift.cacheable_swiftmodules
|
||||
build --features=swift.debug_prefix_map
|
||||
build --features=swift.enable_vfsoverlays
|
||||
|
||||
|
2
.gitmodules
vendored
2
.gitmodules
vendored
@ -4,7 +4,7 @@
|
||||
url=../rlottie.git
|
||||
[submodule "build-system/bazel-rules/rules_apple"]
|
||||
path = build-system/bazel-rules/rules_apple
|
||||
url=https://github.com/ali-fareed/rules_apple.git
|
||||
url=https://github.com/bazelbuild/rules_apple.git
|
||||
[submodule "build-system/bazel-rules/rules_swift"]
|
||||
path = build-system/bazel-rules/rules_swift
|
||||
url = https://github.com/bazelbuild/rules_swift.git
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 6e1f592277650a2727b6e84705ec1a2dc17764fa
|
||||
Subproject commit 748e7e2b1ee5e8976ba873394cbd5e32b61818c7
|
@ -1 +1 @@
|
||||
Subproject commit bbe187c4b1f55c0974a0da345e5e313eaed37c05
|
||||
Subproject commit 6408d85da799ec2af053c4e2883dce3ce6d30f08
|
@ -4278,3 +4278,7 @@ private func findAccessibilityFocus(_ node: ASDisplayNode) -> Bool {
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
public func randomfqweeqwf() {
|
||||
print("t")
|
||||
}
|
||||
|
@ -1,118 +0,0 @@
|
||||
import Foundation
|
||||
import UIKit
|
||||
import Postbox
|
||||
import TelegramCore
|
||||
import SyncCore
|
||||
import SwiftSignalKit
|
||||
import CoreMedia
|
||||
import UniversalMediaPlayer
|
||||
|
||||
private final class RunningSoftwareVideoSource {
|
||||
let fetchDisposable: Disposable
|
||||
let fetchStatusDisposable: Disposable
|
||||
|
||||
var source: SoftwareVideoSource?
|
||||
var beginTime: Double?
|
||||
var frame: MediaTrackFrame?
|
||||
|
||||
init(fetchDisposable: Disposable, fetchStatusDisposable: Disposable) {
|
||||
self.fetchDisposable = fetchDisposable
|
||||
self.fetchStatusDisposable = fetchStatusDisposable
|
||||
}
|
||||
|
||||
deinit {
|
||||
self.fetchDisposable.dispose()
|
||||
self.fetchStatusDisposable.dispose()
|
||||
}
|
||||
}
|
||||
|
||||
final class MultiplexedSoftwareVideoSourceManager {
|
||||
private let queue: Queue
|
||||
private let account: Account
|
||||
private var videoSources: [MediaId: RunningSoftwareVideoSource] = [:]
|
||||
private(set) var immediateVideoFrames: [MediaId: MediaTrackFrame] = [:]
|
||||
|
||||
private var updatingAt: Double?
|
||||
|
||||
var updateFrame: ((MediaId, MediaTrackFrame) -> Void)?
|
||||
|
||||
init(queue: Queue, account: Account) {
|
||||
self.queue = queue
|
||||
self.account = account
|
||||
}
|
||||
|
||||
func updateVisibleItems(_ media: [TelegramMediaFile]) {
|
||||
self.queue.async {
|
||||
var dict: [MediaId: TelegramMediaFile] = [:]
|
||||
for file in media {
|
||||
dict[file.fileId] = file
|
||||
}
|
||||
|
||||
var removeIds: [MediaId] = []
|
||||
for id in self.videoSources.keys {
|
||||
if dict[id] == nil {
|
||||
removeIds.append(id)
|
||||
}
|
||||
}
|
||||
|
||||
for id in removeIds {
|
||||
self.videoSources.removeValue(forKey: id)
|
||||
}
|
||||
|
||||
for (id, file) in dict {
|
||||
if self.videoSources[id] == nil {
|
||||
self.videoSources[id] = RunningSoftwareVideoSource(fetchDisposable: (self.account.postbox.mediaBox.resourceData(file.resource) |> deliverOn(self.queue)).start(next: { [weak self] data in
|
||||
if let strongSelf = self, let context = strongSelf.videoSources[id] {
|
||||
if data.complete {
|
||||
context.source = SoftwareVideoSource(path: data.path)
|
||||
}
|
||||
}
|
||||
}), fetchStatusDisposable: fetchedMediaResource(mediaBox: self.account.postbox.mediaBox, reference: AnyMediaReference.standalone(media: file).resourceReference(file.resource)).start())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func update(at timestamp: Double) {
|
||||
assert(Queue.mainQueue().isCurrent())
|
||||
let begin = self.updatingAt == nil
|
||||
self.updatingAt = timestamp
|
||||
if begin {
|
||||
self.queue.async {
|
||||
var immediateVideoFrames: [MediaId: MediaTrackFrame] = [:]
|
||||
loop: for (id, source) in self.videoSources {
|
||||
if let context = source.source {
|
||||
if let beginTime = source.beginTime, let currentFrame = source.frame {
|
||||
let framePosition = currentFrame.position.seconds
|
||||
let frameDuration = currentFrame.duration.seconds
|
||||
|
||||
if false && beginTime + framePosition + frameDuration > timestamp {
|
||||
immediateVideoFrames[id] = currentFrame
|
||||
continue loop
|
||||
}
|
||||
}
|
||||
|
||||
/*if let frame = context.readFrame(maxPts: nil) {
|
||||
if source.frame == nil || CMTimeCompare(source.frame!.position, frame.position) > 0 {
|
||||
source.beginTime = timestamp
|
||||
}
|
||||
source.frame = frame
|
||||
immediateVideoFrames[id] = frame
|
||||
self.updateFrame?(id, frame)
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
Queue.mainQueue().async {
|
||||
self.immediateVideoFrames = immediateVideoFrames
|
||||
if let updatingAt = self.updatingAt, !updatingAt.isEqual(to: timestamp) {
|
||||
self.updatingAt = nil
|
||||
self.update(at: updatingAt)
|
||||
} else {
|
||||
self.updatingAt = nil
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -61,6 +61,17 @@ final class SoftwareVideoLayerFrameManager {
|
||||
}
|
||||
|
||||
func start() {
|
||||
func stringForResource(_ resource: MediaResource?) -> String {
|
||||
guard let resource = resource else {
|
||||
return "<none>"
|
||||
}
|
||||
if let resource = resource as? WebFileReferenceMediaResource {
|
||||
return resource.url
|
||||
} else {
|
||||
return resource.id.uniqueId
|
||||
}
|
||||
}
|
||||
Logger.shared.log("SoftwareVideo", "load video from \(stringForResource(self.resource)) or \(stringForResource(self.secondaryResource))")
|
||||
let secondarySignal: Signal<String?, NoError>
|
||||
if let secondaryResource = self.secondaryResource {
|
||||
secondarySignal = self.account.postbox.mediaBox.resourceData(secondaryResource, option: .complete(waitUntilFetchStatus: false))
|
||||
@ -90,7 +101,8 @@ final class SoftwareVideoLayerFrameManager {
|
||||
}
|
||||
|> take(1)
|
||||
|
||||
self.dataDisposable.set((firstReady |> deliverOn(applyQueue)).start(next: { [weak self] path in
|
||||
self.dataDisposable.set((firstReady
|
||||
|> deliverOn(applyQueue)).start(next: { [weak self] path in
|
||||
if let strongSelf = self {
|
||||
let _ = strongSelf.source.swap(SoftwareVideoSource(path: path))
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user