mirror of
https://github.com/Myzel394/Alibi.git
synced 2025-06-19 07:15:25 +02:00
feat: Improve settings for video recording
This commit is contained in:
parent
b3bb43367a
commit
448108a974
@ -6,7 +6,8 @@ import android.os.Build
|
|||||||
import androidx.camera.video.Quality
|
import androidx.camera.video.Quality
|
||||||
import androidx.camera.video.QualitySelector
|
import androidx.camera.video.QualitySelector
|
||||||
import app.myzel394.alibi.R
|
import app.myzel394.alibi.R
|
||||||
import app.myzel394.alibi.helpers.BatchesFolder
|
import app.myzel394.alibi.helpers.AudioBatchesFolder
|
||||||
|
import app.myzel394.alibi.helpers.VideoBatchesFolder
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
import kotlinx.serialization.json.Json
|
import kotlinx.serialization.json.Json
|
||||||
import java.time.LocalDateTime
|
import java.time.LocalDateTime
|
||||||
@ -75,9 +76,21 @@ data class RecordingInformation(
|
|||||||
val maxDuration: Long,
|
val maxDuration: Long,
|
||||||
val intervalDuration: Long,
|
val intervalDuration: Long,
|
||||||
val fileExtension: String,
|
val fileExtension: String,
|
||||||
|
val type: Type,
|
||||||
) {
|
) {
|
||||||
fun hasRecordingsAvailable(context: Context): Boolean =
|
fun hasRecordingsAvailable(context: Context): Boolean =
|
||||||
BatchesFolder.importFromFolder(folderPath, context).hasRecordingsAvailable()
|
when (type) {
|
||||||
|
Type.AUDIO -> AudioBatchesFolder.importFromFolder(folderPath, context)
|
||||||
|
.hasRecordingsAvailable()
|
||||||
|
|
||||||
|
Type.VIDEO -> VideoBatchesFolder.importFromFolder(folderPath, context)
|
||||||
|
.hasRecordingsAvailable()
|
||||||
|
}
|
||||||
|
|
||||||
|
enum class Type {
|
||||||
|
AUDIO,
|
||||||
|
VIDEO,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
|
@ -142,6 +142,7 @@ class AudioRecorderService :
|
|||||||
maxDuration = settings.maxDuration,
|
maxDuration = settings.maxDuration,
|
||||||
fileExtension = settings.fileExtension,
|
fileExtension = settings.fileExtension,
|
||||||
intervalDuration = settings.intervalDuration,
|
intervalDuration = settings.intervalDuration,
|
||||||
|
type = RecordingInformation.Type.AUDIO,
|
||||||
)
|
)
|
||||||
|
|
||||||
override fun startNewCycle() {
|
override fun startNewCycle() {
|
||||||
@ -214,7 +215,7 @@ class AudioRecorderService :
|
|||||||
super.onAudioDevicesAdded(addedDevices)
|
super.onAudioDevicesAdded(addedDevices)
|
||||||
|
|
||||||
if (selectedMicrophone == null) {
|
if (selectedMicrophone == null) {
|
||||||
return;
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// We can't compare the ID, as it seems to be changing on each reconnect
|
// We can't compare the ID, as it seems to be changing on each reconnect
|
||||||
@ -238,7 +239,7 @@ class AudioRecorderService :
|
|||||||
super.onAudioDevicesRemoved(removedDevices)
|
super.onAudioDevicesRemoved(removedDevices)
|
||||||
|
|
||||||
if (selectedMicrophone == null) {
|
if (selectedMicrophone == null) {
|
||||||
return;
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (removedDevices?.find { it.id == selectedMicrophone!!.deviceInfo.id } != null) {
|
if (removedDevices?.find { it.id == selectedMicrophone!!.deviceInfo.id } != null) {
|
||||||
|
@ -58,7 +58,7 @@ class VideoRecorderService :
|
|||||||
runInMain {
|
runInMain {
|
||||||
camera = cameraProvider!!.bindToLifecycle(
|
camera = cameraProvider!!.bindToLifecycle(
|
||||||
this,
|
this,
|
||||||
settings.cameraSelector,
|
CameraSelector.DEFAULT_BACK_CAMERA,
|
||||||
videoCapture
|
videoCapture
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -136,6 +136,7 @@ class VideoRecorderService :
|
|||||||
maxDuration = settings.maxDuration,
|
maxDuration = settings.maxDuration,
|
||||||
fileExtension = settings.fileExtension,
|
fileExtension = settings.fileExtension,
|
||||||
intervalDuration = settings.intervalDuration,
|
intervalDuration = settings.intervalDuration,
|
||||||
|
type = RecordingInformation.Type.VIDEO,
|
||||||
)
|
)
|
||||||
|
|
||||||
data class Settings(
|
data class Settings(
|
||||||
@ -143,7 +144,6 @@ class VideoRecorderService :
|
|||||||
override val intervalDuration: Long,
|
override val intervalDuration: Long,
|
||||||
val folder: String? = null,
|
val folder: String? = null,
|
||||||
val targetVideoBitRate: Int? = null,
|
val targetVideoBitRate: Int? = null,
|
||||||
val cameraSelector: CameraSelector = CameraSelector.DEFAULT_BACK_CAMERA,
|
|
||||||
val quality: QualitySelector = QualitySelector.from(Quality.HIGHEST),
|
val quality: QualitySelector = QualitySelector.from(Quality.HIGHEST),
|
||||||
) : IntervalRecorderService.Settings(
|
) : IntervalRecorderService.Settings(
|
||||||
maxDuration = maxDuration,
|
maxDuration = maxDuration,
|
||||||
@ -162,9 +162,16 @@ class VideoRecorderService :
|
|||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun from() = Settings(
|
fun from(appSettings: AppSettings) = Settings(
|
||||||
maxDuration = 60_000,
|
// TODO: Migrate audioSettings
|
||||||
intervalDuration = 10_000,
|
maxDuration = appSettings.audioRecorderSettings.maxDuration,
|
||||||
|
intervalDuration = appSettings.audioRecorderSettings.intervalDuration,
|
||||||
|
folder = appSettings.audioRecorderSettings.saveFolder,
|
||||||
|
targetVideoBitRate = appSettings.videoRecorderSettings.targetedVideoBitRate,
|
||||||
|
quality = appSettings.videoRecorderSettings.getQualitySelector()
|
||||||
|
?: QualitySelector.from(
|
||||||
|
Quality.HIGHEST
|
||||||
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user