From 9d35e81db7a8e3b7206b2afadc94435863145c99 Mon Sep 17 00:00:00 2001 From: Florian Renaud Date: Fri, 14 Oct 2022 16:37:59 +0200 Subject: [PATCH] Compute max file size from chunk length --- .../im/vector/app/features/voice/AbstractVoiceRecorderQ.kt | 2 +- .../app/features/voicebroadcast/VoiceBroadcastConstants.kt | 2 +- .../app/features/voicebroadcast/VoiceBroadcastRecorderQ.kt | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/voice/AbstractVoiceRecorderQ.kt b/vector/src/main/java/im/vector/app/features/voice/AbstractVoiceRecorderQ.kt index bd30c38366..428b3c578b 100644 --- a/vector/src/main/java/im/vector/app/features/voice/AbstractVoiceRecorderQ.kt +++ b/vector/src/main/java/im/vector/app/features/voice/AbstractVoiceRecorderQ.kt @@ -34,8 +34,8 @@ abstract class AbstractVoiceRecorderQ(private val context: Context) : AbstractVo protected var nextOutputFile: File? = null private val audioSource: Int = MediaRecorder.AudioSource.DEFAULT - private val audioEncodingBitRate: Int = 24_000 private val audioSamplingRate: Int = 48_000 + protected val audioEncodingBitRate: Int = 24_000 abstract val outputFormat: Int // see MediaRecorder.OutputFormat abstract val audioEncoder: Int // see MediaRecorder.AudioEncoder diff --git a/vector/src/main/java/im/vector/app/features/voicebroadcast/VoiceBroadcastConstants.kt b/vector/src/main/java/im/vector/app/features/voicebroadcast/VoiceBroadcastConstants.kt index 07bd94ca8c..83d83b167e 100644 --- a/vector/src/main/java/im/vector/app/features/voicebroadcast/VoiceBroadcastConstants.kt +++ b/vector/src/main/java/im/vector/app/features/voicebroadcast/VoiceBroadcastConstants.kt @@ -22,5 +22,5 @@ object VoiceBroadcastConstants { const val STATE_ROOM_VOICE_BROADCAST_INFO = "io.element.voice_broadcast_info" /** Default voice broadcast chunk duration, in seconds */ - const val DEFAULT_CHUNK_LENGTH = 5 + const val DEFAULT_CHUNK_LENGTH = 30 } diff --git a/vector/src/main/java/im/vector/app/features/voicebroadcast/VoiceBroadcastRecorderQ.kt b/vector/src/main/java/im/vector/app/features/voicebroadcast/VoiceBroadcastRecorderQ.kt index fe8222e840..620db721c9 100644 --- a/vector/src/main/java/im/vector/app/features/voicebroadcast/VoiceBroadcastRecorderQ.kt +++ b/vector/src/main/java/im/vector/app/features/voicebroadcast/VoiceBroadcastRecorderQ.kt @@ -28,7 +28,7 @@ class VoiceBroadcastRecorderQ( context: Context, ) : AbstractVoiceRecorderQ(context), VoiceBroadcastRecorder { - private var maxFileSize = 25_000L // 0,025 Mb = 25 Kb ~= 6s + private var maxFileSize = 0L // zero or negative for no limit override var listener: VoiceBroadcastRecorder.Listener? = null @@ -50,7 +50,7 @@ class VoiceBroadcastRecorderQ( } override fun startRecord(roomId: String, chunkLength: Int) { - maxFileSize = (chunkLength * 0.004166).toLong() // TODO change this approximate conversion + maxFileSize = (chunkLength * audioEncodingBitRate / 8).toLong() startRecord(roomId) }