TM-SGNL-iOS/SignalServiceKit/Messages/Attachments/V2/AudioWaveform/AudioWaveformManager.swift
TeleMessage developers dde0620daf initial commit
2025-05-03 12:28:28 -07:00

48 lines
1.3 KiB
Swift

//
// Copyright 2024 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
//
import Foundation
public enum AudioWaveformError: Error {
case audioTooLong
case fileIOError
case invalidAudioFile
}
public protocol AudioWaveformManager {
func audioWaveform(
forAttachment attachment: AttachmentStream,
highPriority: Bool
) -> Task<AudioWaveform, Error>
func audioWaveform(
forAudioPath audioPath: String,
waveformPath: String
) -> Task<AudioWaveform, Error>
func audioWaveform(
forEncryptedAudioFileAtPath filePath: String,
encryptionKey: Data,
plaintextDataLength: UInt32,
mimeType: String,
outputWaveformPath: String
) async throws
/// No caching, no enqueueing.
/// Generates an audio waveform synchronously, blocking on file I/O operations.
func audioWaveformSync(
forAudioPath audioPath: String
) throws -> AudioWaveform
/// No caching, no enqueueing.
/// Generates an audio waveform synchronously, blocking on file I/O operations.
func audioWaveformSync(
forEncryptedAudioFileAtPath filePath: String,
encryptionKey: Data,
plaintextDataLength: UInt32,
mimeType: String
) throws -> AudioWaveform
}