mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 12:07:55 +00:00
f7dd9cdcf8
* Update copyright holding and dates * compound IDE Macros updated * update copyright * update copyrights done * update templates and README
41 lines
1.2 KiB
Swift
41 lines
1.2 KiB
Swift
//
|
|
// Copyright 2025 Element Creations Ltd.
|
|
// Copyright 2023-2025 New Vector Ltd.
|
|
//
|
|
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial.
|
|
// Please see LICENSE files in the repository root for full details.
|
|
//
|
|
|
|
import AVFoundation
|
|
import Foundation
|
|
import SwiftOGG
|
|
|
|
enum AudioConverterError: Error {
|
|
case conversionFailed(Error?)
|
|
}
|
|
|
|
enum AudioConverterPreferredFileExtension: String {
|
|
case mpeg4aac = "m4a"
|
|
case ogg
|
|
}
|
|
|
|
struct AudioConverter: AudioConverterProtocol {
|
|
func convertToOpusOgg(sourceURL: URL, destinationURL: URL) throws {
|
|
do {
|
|
try OGGConverter.convertM4aFileToOpusOGG(src: sourceURL, dest: destinationURL)
|
|
} catch {
|
|
MXLog.error("failed to convert to OpusOgg: \(error)")
|
|
throw AudioConverterError.conversionFailed(error)
|
|
}
|
|
}
|
|
|
|
func convertToMPEG4AAC(sourceURL: URL, destinationURL: URL) throws {
|
|
do {
|
|
try OGGConverter.convertOpusOGGToM4aFile(src: sourceURL, dest: destinationURL)
|
|
} catch {
|
|
MXLog.error("failed to convert to MPEG4AAC: \(error)")
|
|
throw AudioConverterError.conversionFailed(error)
|
|
}
|
|
}
|
|
}
|