Fix rotation when rebinding camera use cases

This commit is contained in:
Matéo Duparc 2023-05-08 21:30:38 +02:00
parent ad19b9e645
commit 9fc981fee8
Signed by: hardcoresushi
GPG Key ID: AFE384344A45E13A
2 changed files with 7 additions and 1 deletions

View File

@ -77,6 +77,7 @@ class CameraActivity : BaseActivity(), SensorOrientationListener.Listener {
}
}
private lateinit var sensorOrientationListener: SensorOrientationListener
private var currentRotation = 0
private var previousOrientation: Float = 0f
private lateinit var orientedIcons: List<ImageView>
private lateinit var encryptedVolume: EncryptedVolume
@ -390,6 +391,7 @@ class CameraActivity : BaseActivity(), SensorOrientationListener.Listener {
}
supportedSizes
}.build())
.setTargetRotation(currentRotation)
.build()
}
@ -401,7 +403,9 @@ class CameraActivity : BaseActivity(), SensorOrientationListener.Listener {
recorderBuilder.setQualitySelector(QualitySelector.from(qualities!![currentQualityIndex]))
}
videoRecorder = recorderBuilder.build()
videoCapture = VideoCapture.withOutput(videoRecorder!!)
videoCapture = VideoCapture.withOutput(videoRecorder!!).apply {
targetRotation = currentRotation
}
}
private fun rebindUseCases(): UseCase {
@ -598,6 +602,7 @@ class CameraActivity : BaseActivity(), SensorOrientationListener.Listener {
previousOrientation = realOrientation
imageCapture?.targetRotation = newOrientation
videoCapture?.targetRotation = newOrientation
currentRotation = newOrientation
}
}

View File

@ -154,6 +154,7 @@ JNIEXPORT void JNICALL
Java_sushi_hardcore_droidfs_video_1recording_FFmpegMuxer_release(JNIEnv *env, jobject thiz, jlong format_context) {
AVFormatContext* fc = (AVFormatContext *) format_context;
av_free(fc->pb->buffer);
(*env)->DeleteGlobalRef(env, ((struct Muxer*)fc->pb->opaque)->thiz);
free(fc->pb->opaque);
avio_context_free(&fc->pb);
avformat_free_context(fc);