Compute max file size from chunk length

This commit is contained in:
Florian Renaud 2022-10-14 16:37:59 +02:00
parent 64e6a2bfab
commit 9d35e81db7
3 changed files with 4 additions and 4 deletions

View file

@ -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

View file

@ -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
}

View file

@ -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)
}