Use libtess2 instead of boost graph and earcut

This commit is contained in:
Ali
2021-11-12 20:39:58 +04:00
parent 5ef9c9be73
commit 7617da6aff
53 changed files with 6647 additions and 35 deletions

View File

@@ -213,7 +213,7 @@ public final class MediaBox {
return ResourceStorePaths(partial: "\(fileNameForId(id))_partial", complete: "\(fileNameForId(id))")
}
private func cachedRepresentationPathsForId(_ id: MediaResourceId, representationId: String, keepDuration: CachedMediaRepresentationKeepDuration) -> ResourceStorePaths {
private func cachedRepresentationPathsForId(_ id: String, representationId: String, keepDuration: CachedMediaRepresentationKeepDuration) -> ResourceStorePaths {
let cacheString: String
switch keepDuration {
case .general:
@@ -784,14 +784,22 @@ public final class MediaBox {
public func storeCachedResourceRepresentation(_ resource: MediaResource, representation: CachedMediaResourceRepresentation, data: Data) {
self.dataQueue.async {
let path = self.cachedRepresentationPathsForId(resource.id, representationId: representation.uniqueId, keepDuration: representation.keepDuration).complete
let path = self.cachedRepresentationPathsForId(resource.id.stringRepresentation, representationId: representation.uniqueId, keepDuration: representation.keepDuration).complete
let _ = try? data.write(to: URL(fileURLWithPath: path))
}
}
public func storeCachedResourceRepresentation(_ resource: MediaResource, representationId: String, keepDuration: CachedMediaRepresentationKeepDuration, data: Data, completion: @escaping (String) -> Void = { _ in }) {
self.dataQueue.async {
let path = self.cachedRepresentationPathsForId(resource.id, representationId: representationId, keepDuration: keepDuration).complete
let path = self.cachedRepresentationPathsForId(resource.id.stringRepresentation, representationId: representationId, keepDuration: keepDuration).complete
let _ = try? data.write(to: URL(fileURLWithPath: path))
completion(path)
}
}
public func storeCachedResourceRepresentation(_ resourceId: String, representationId: String, keepDuration: CachedMediaRepresentationKeepDuration, data: Data, completion: @escaping (String) -> Void = { _ in }) {
self.dataQueue.async {
let path = self.cachedRepresentationPathsForId(resourceId, representationId: representationId, keepDuration: keepDuration).complete
let _ = try? data.write(to: URL(fileURLWithPath: path))
completion(path)
}
@@ -802,7 +810,7 @@ public final class MediaBox {
let disposable = MetaDisposable()
let begin: () -> Void = {
let paths = self.cachedRepresentationPathsForId(resource.id, representationId: representation.uniqueId, keepDuration: representation.keepDuration)
let paths = self.cachedRepresentationPathsForId(resource.id.stringRepresentation, representationId: representation.uniqueId, keepDuration: representation.keepDuration)
if let size = fileSize(paths.complete) {
self.timeBasedCleanup.touch(paths: [
paths.complete
@@ -971,7 +979,7 @@ public final class MediaBox {
let begin: () -> Void = {
let paths: ResourceStorePaths
if let baseResourceId = baseResourceId {
paths = self.cachedRepresentationPathsForId(MediaResourceId(baseResourceId), representationId: id, keepDuration: keepDuration)
paths = self.cachedRepresentationPathsForId(MediaResourceId(baseResourceId).stringRepresentation, representationId: id, keepDuration: keepDuration)
} else {
paths = self.storePathsForId(MediaResourceId(id))
}