mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-04 10:33:45 +00:00
Update SDK to 25.10.21 (#4642)
* update sdk * fix normalized waveform * added a comment on normalization * running on MacOS-26 * Revert "running on MacOS-26" This reverts commit 1c8ececf0b84200193eaa2ab205094215b168060.
This commit is contained in:
@@ -17541,9 +17541,9 @@ class TimelineProxyMock: TimelineProxyProtocol, @unchecked Sendable {
|
||||
}
|
||||
}
|
||||
}
|
||||
var sendVoiceMessageUrlAudioInfoWaveformRequestHandleClosure: ((URL, AudioInfo, [UInt16], @MainActor (SendAttachmentJoinHandleProtocol) -> Void) async -> Result<Void, TimelineProxyError>)?
|
||||
var sendVoiceMessageUrlAudioInfoWaveformRequestHandleClosure: ((URL, AudioInfo, [Float], @MainActor (SendAttachmentJoinHandleProtocol) -> Void) async -> Result<Void, TimelineProxyError>)?
|
||||
|
||||
func sendVoiceMessage(url: URL, audioInfo: AudioInfo, waveform: [UInt16], requestHandle: @MainActor (SendAttachmentJoinHandleProtocol) -> Void) async -> Result<Void, TimelineProxyError> {
|
||||
func sendVoiceMessage(url: URL, audioInfo: AudioInfo, waveform: [Float], requestHandle: @MainActor (SendAttachmentJoinHandleProtocol) -> Void) async -> Result<Void, TimelineProxyError> {
|
||||
sendVoiceMessageUrlAudioInfoWaveformRequestHandleCallsCount += 1
|
||||
if let sendVoiceMessageUrlAudioInfoWaveformRequestHandleClosure = sendVoiceMessageUrlAudioInfoWaveformRequestHandleClosure {
|
||||
return await sendVoiceMessageUrlAudioInfoWaveformRequestHandleClosure(url, audioInfo, waveform, requestHandle)
|
||||
|
||||
@@ -17054,6 +17054,81 @@ open class RoomSDKMock: MatrixRustSDK.Room, @unchecked Sendable {
|
||||
}
|
||||
}
|
||||
|
||||
//MARK: - subscribeToSendQueueUpdates
|
||||
|
||||
open var subscribeToSendQueueUpdatesListenerThrowableError: Error?
|
||||
var subscribeToSendQueueUpdatesListenerUnderlyingCallsCount = 0
|
||||
open var subscribeToSendQueueUpdatesListenerCallsCount: Int {
|
||||
get {
|
||||
if Thread.isMainThread {
|
||||
return subscribeToSendQueueUpdatesListenerUnderlyingCallsCount
|
||||
} else {
|
||||
var returnValue: Int? = nil
|
||||
DispatchQueue.main.sync {
|
||||
returnValue = subscribeToSendQueueUpdatesListenerUnderlyingCallsCount
|
||||
}
|
||||
|
||||
return returnValue!
|
||||
}
|
||||
}
|
||||
set {
|
||||
if Thread.isMainThread {
|
||||
subscribeToSendQueueUpdatesListenerUnderlyingCallsCount = newValue
|
||||
} else {
|
||||
DispatchQueue.main.sync {
|
||||
subscribeToSendQueueUpdatesListenerUnderlyingCallsCount = newValue
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
open var subscribeToSendQueueUpdatesListenerCalled: Bool {
|
||||
return subscribeToSendQueueUpdatesListenerCallsCount > 0
|
||||
}
|
||||
open var subscribeToSendQueueUpdatesListenerReceivedListener: SendQueueListener?
|
||||
open var subscribeToSendQueueUpdatesListenerReceivedInvocations: [SendQueueListener] = []
|
||||
|
||||
var subscribeToSendQueueUpdatesListenerUnderlyingReturnValue: TaskHandle!
|
||||
open var subscribeToSendQueueUpdatesListenerReturnValue: TaskHandle! {
|
||||
get {
|
||||
if Thread.isMainThread {
|
||||
return subscribeToSendQueueUpdatesListenerUnderlyingReturnValue
|
||||
} else {
|
||||
var returnValue: TaskHandle? = nil
|
||||
DispatchQueue.main.sync {
|
||||
returnValue = subscribeToSendQueueUpdatesListenerUnderlyingReturnValue
|
||||
}
|
||||
|
||||
return returnValue!
|
||||
}
|
||||
}
|
||||
set {
|
||||
if Thread.isMainThread {
|
||||
subscribeToSendQueueUpdatesListenerUnderlyingReturnValue = newValue
|
||||
} else {
|
||||
DispatchQueue.main.sync {
|
||||
subscribeToSendQueueUpdatesListenerUnderlyingReturnValue = newValue
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
open var subscribeToSendQueueUpdatesListenerClosure: ((SendQueueListener) async throws -> TaskHandle)?
|
||||
|
||||
open override func subscribeToSendQueueUpdates(listener: SendQueueListener) async throws -> TaskHandle {
|
||||
if let error = subscribeToSendQueueUpdatesListenerThrowableError {
|
||||
throw error
|
||||
}
|
||||
subscribeToSendQueueUpdatesListenerCallsCount += 1
|
||||
subscribeToSendQueueUpdatesListenerReceivedListener = listener
|
||||
DispatchQueue.main.async {
|
||||
self.subscribeToSendQueueUpdatesListenerReceivedInvocations.append(listener)
|
||||
}
|
||||
if let subscribeToSendQueueUpdatesListenerClosure = subscribeToSendQueueUpdatesListenerClosure {
|
||||
return try await subscribeToSendQueueUpdatesListenerClosure(listener)
|
||||
} else {
|
||||
return subscribeToSendQueueUpdatesListenerReturnValue
|
||||
}
|
||||
}
|
||||
|
||||
//MARK: - subscribeToTypingNotifications
|
||||
|
||||
var subscribeToTypingNotificationsListenerUnderlyingCallsCount = 0
|
||||
@@ -25247,8 +25322,8 @@ open class TimelineSDKMock: MatrixRustSDK.Timeline, @unchecked Sendable {
|
||||
open var sendVoiceMessageParamsAudioInfoWaveformCalled: Bool {
|
||||
return sendVoiceMessageParamsAudioInfoWaveformCallsCount > 0
|
||||
}
|
||||
open var sendVoiceMessageParamsAudioInfoWaveformReceivedArguments: (params: UploadParameters, audioInfo: AudioInfo, waveform: [UInt16])?
|
||||
open var sendVoiceMessageParamsAudioInfoWaveformReceivedInvocations: [(params: UploadParameters, audioInfo: AudioInfo, waveform: [UInt16])] = []
|
||||
open var sendVoiceMessageParamsAudioInfoWaveformReceivedArguments: (params: UploadParameters, audioInfo: AudioInfo, waveform: [Float])?
|
||||
open var sendVoiceMessageParamsAudioInfoWaveformReceivedInvocations: [(params: UploadParameters, audioInfo: AudioInfo, waveform: [Float])] = []
|
||||
|
||||
var sendVoiceMessageParamsAudioInfoWaveformUnderlyingReturnValue: SendAttachmentJoinHandle!
|
||||
open var sendVoiceMessageParamsAudioInfoWaveformReturnValue: SendAttachmentJoinHandle! {
|
||||
@@ -25274,9 +25349,9 @@ open class TimelineSDKMock: MatrixRustSDK.Timeline, @unchecked Sendable {
|
||||
}
|
||||
}
|
||||
}
|
||||
open var sendVoiceMessageParamsAudioInfoWaveformClosure: ((UploadParameters, AudioInfo, [UInt16]) throws -> SendAttachmentJoinHandle)?
|
||||
open var sendVoiceMessageParamsAudioInfoWaveformClosure: ((UploadParameters, AudioInfo, [Float]) throws -> SendAttachmentJoinHandle)?
|
||||
|
||||
open override func sendVoiceMessage(params: UploadParameters, audioInfo: AudioInfo, waveform: [UInt16]) throws -> SendAttachmentJoinHandle {
|
||||
open override func sendVoiceMessage(params: UploadParameters, audioInfo: AudioInfo, waveform: [Float]) throws -> SendAttachmentJoinHandle {
|
||||
if let error = sendVoiceMessageParamsAudioInfoWaveformThrowableError {
|
||||
throw error
|
||||
}
|
||||
|
||||
@@ -241,7 +241,7 @@ class MockTimelineController: TimelineControllerProtocol {
|
||||
|
||||
func sendVoiceMessage(url: URL,
|
||||
audioInfo: MatrixRustSDK.AudioInfo,
|
||||
waveform: [UInt16],
|
||||
waveform: [Float],
|
||||
requestHandle: @MainActor (SendAttachmentJoinHandleProtocol) -> Void) async -> Result<Void, TimelineControllerError> {
|
||||
if let timelineProxy {
|
||||
return await timelineProxy.sendVoiceMessage(url: url,
|
||||
|
||||
@@ -356,7 +356,7 @@ class TimelineController: TimelineControllerProtocol {
|
||||
|
||||
func sendVoiceMessage(url: URL,
|
||||
audioInfo: MatrixRustSDK.AudioInfo,
|
||||
waveform: [UInt16],
|
||||
waveform: [Float],
|
||||
requestHandle: @MainActor (SendAttachmentJoinHandleProtocol) -> Void) async -> Result<Void, TimelineControllerError> {
|
||||
await activeTimeline.sendVoiceMessage(url: url,
|
||||
audioInfo: audioInfo,
|
||||
|
||||
+1
-1
@@ -130,7 +130,7 @@ protocol TimelineControllerProtocol {
|
||||
|
||||
func sendVoiceMessage(url: URL,
|
||||
audioInfo: AudioInfo,
|
||||
waveform: [UInt16],
|
||||
waveform: [Float],
|
||||
requestHandle: @MainActor (SendAttachmentJoinHandleProtocol) -> Void) async -> Result<Void, TimelineControllerError>
|
||||
|
||||
// MARK: - Poll
|
||||
|
||||
@@ -359,7 +359,7 @@ final class TimelineProxy: TimelineProxyProtocol {
|
||||
|
||||
func sendVoiceMessage(url: URL,
|
||||
audioInfo: AudioInfo,
|
||||
waveform: [UInt16],
|
||||
waveform: [Float],
|
||||
requestHandle: @MainActor (SendAttachmentJoinHandleProtocol) -> Void) async -> Result<Void, TimelineProxyError> {
|
||||
MXLog.info("Sending voice message")
|
||||
|
||||
|
||||
@@ -109,7 +109,7 @@ protocol TimelineProxyProtocol {
|
||||
|
||||
func sendVoiceMessage(url: URL,
|
||||
audioInfo: AudioInfo,
|
||||
waveform: [UInt16],
|
||||
waveform: [Float],
|
||||
requestHandle: @MainActor (SendAttachmentJoinHandleProtocol) -> Void) async -> Result<Void, TimelineProxyError>
|
||||
|
||||
func sendReadReceipt(for eventID: String, type: ReceiptType) async -> Result<Void, TimelineProxyError>
|
||||
|
||||
@@ -127,17 +127,17 @@ class VoiceMessageRecorder: VoiceMessageRecorderProtocol {
|
||||
await previewAudioPlayerState?.updateState(progress: progress)
|
||||
}
|
||||
|
||||
func buildRecordingWaveform() async -> Result<[UInt16], VoiceMessageRecorderError> {
|
||||
func buildRecordingWaveform() async -> Result<[Float], VoiceMessageRecorderError> {
|
||||
guard let url = audioRecorder.audioFileURL else {
|
||||
return .failure(.missingRecordingFile)
|
||||
}
|
||||
// build the waveform
|
||||
var waveformData: [UInt16] = []
|
||||
var waveformData: [Float] = []
|
||||
let analyzer = WaveformAnalyzer()
|
||||
do {
|
||||
let samples = try await analyzer.samples(fromAudioAt: url, count: 100)
|
||||
// linearly normalized to [0, 1] (1 -> -50 dB)
|
||||
waveformData = samples.map { UInt16(max(0, (1 - $0) * 1024)) }
|
||||
waveformData = samples.map { max(0, 1 - $0) }
|
||||
} catch {
|
||||
MXLog.error("Waveform analysis failed. \(error)")
|
||||
return .failure(.waveformAnalysisError)
|
||||
|
||||
Reference in New Issue
Block a user