Compute max file size from chunk length
This commit is contained in:
parent
64e6a2bfab
commit
9d35e81db7
|
@ -34,8 +34,8 @@ abstract class AbstractVoiceRecorderQ(private val context: Context) : AbstractVo
|
||||||
protected var nextOutputFile: File? = null
|
protected var nextOutputFile: File? = null
|
||||||
|
|
||||||
private val audioSource: Int = MediaRecorder.AudioSource.DEFAULT
|
private val audioSource: Int = MediaRecorder.AudioSource.DEFAULT
|
||||||
private val audioEncodingBitRate: Int = 24_000
|
|
||||||
private val audioSamplingRate: Int = 48_000
|
private val audioSamplingRate: Int = 48_000
|
||||||
|
protected val audioEncodingBitRate: Int = 24_000
|
||||||
|
|
||||||
abstract val outputFormat: Int // see MediaRecorder.OutputFormat
|
abstract val outputFormat: Int // see MediaRecorder.OutputFormat
|
||||||
abstract val audioEncoder: Int // see MediaRecorder.AudioEncoder
|
abstract val audioEncoder: Int // see MediaRecorder.AudioEncoder
|
||||||
|
|
|
@ -22,5 +22,5 @@ object VoiceBroadcastConstants {
|
||||||
const val STATE_ROOM_VOICE_BROADCAST_INFO = "io.element.voice_broadcast_info"
|
const val STATE_ROOM_VOICE_BROADCAST_INFO = "io.element.voice_broadcast_info"
|
||||||
|
|
||||||
/** Default voice broadcast chunk duration, in seconds */
|
/** Default voice broadcast chunk duration, in seconds */
|
||||||
const val DEFAULT_CHUNK_LENGTH = 5
|
const val DEFAULT_CHUNK_LENGTH = 30
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ class VoiceBroadcastRecorderQ(
|
||||||
context: Context,
|
context: Context,
|
||||||
) : AbstractVoiceRecorderQ(context), VoiceBroadcastRecorder {
|
) : 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
|
override var listener: VoiceBroadcastRecorder.Listener? = null
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ class VoiceBroadcastRecorderQ(
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun startRecord(roomId: String, chunkLength: Int) {
|
override fun startRecord(roomId: String, chunkLength: Int) {
|
||||||
maxFileSize = (chunkLength * 0.004166).toLong() // TODO change this approximate conversion
|
maxFileSize = (chunkLength * audioEncodingBitRate / 8).toLong()
|
||||||
startRecord(roomId)
|
startRecord(roomId)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue