mirror of
https://github.com/SimpleMobileTools/Simple-Camera.git
synced 2025-02-06 18:13:18 +01:00
fix some video rotation checks
This commit is contained in:
parent
0bead6f1fb
commit
9cca79877b
@ -535,7 +535,7 @@ class Preview : ViewGroup, SurfaceHolder.Callback, MediaScannerConnection.OnScan
|
||||
}
|
||||
mRecorder!!.setPreviewDisplay(mSurfaceHolder.surface)
|
||||
|
||||
val rotation = mActivity.getMediaRotation(mCurrCameraId)
|
||||
val rotation = getVideoRotation()
|
||||
mInitVideoRotation = rotation
|
||||
mRecorder!!.setOrientationHint(rotation)
|
||||
|
||||
@ -565,10 +565,15 @@ class Preview : ViewGroup, SurfaceHolder.Callback, MediaScannerConnection.OnScan
|
||||
return mIsRecording
|
||||
}
|
||||
|
||||
private fun getVideoRotation(): Int {
|
||||
val deviceRot = MainActivity.mOrientation.compensateDeviceRotation(mCurrCameraId)
|
||||
val previewRot = mActivity.getPreviewRotation(mCurrCameraId)
|
||||
return (deviceRot + previewRot) % 360
|
||||
}
|
||||
|
||||
private fun startRecording() {
|
||||
if (mInitVideoRotation != mActivity.getFinalRotation(mCurrCameraId, MainActivity.mOrientation)) {
|
||||
cleanupRecorder()
|
||||
initRecorder()
|
||||
if (mInitVideoRotation != getVideoRotation()) {
|
||||
|
||||
}
|
||||
|
||||
try {
|
||||
|
@ -19,20 +19,6 @@ fun Activity.getPreviewRotation(cameraId: Int): Int {
|
||||
return result % 360
|
||||
}
|
||||
|
||||
fun Activity.getMediaRotation(cameraId: Int): Int {
|
||||
val degrees = getDeviceRotationDegrees()
|
||||
val info = getCameraInfo(cameraId)
|
||||
return if (info.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) {
|
||||
(360 + info.orientation + degrees) % 360
|
||||
} else
|
||||
(360 + info.orientation - degrees) % 360
|
||||
}
|
||||
|
||||
fun Activity.getFinalRotation(currCameraId: Int, deviceOrientation: Int): Int {
|
||||
var rotation = getMediaRotation(currCameraId)
|
||||
return rotation % 360
|
||||
}
|
||||
|
||||
fun Activity.getDeviceRotationDegrees() = when (windowManager.defaultDisplay.rotation) {
|
||||
Surface.ROTATION_90 -> 90
|
||||
Surface.ROTATION_180 -> 180
|
||||
|
Loading…
x
Reference in New Issue
Block a user