Camera: Plumb through stream mirroring mode
The stream mirroring mode is used to override the default flip for front
facing camera.
Test: Camera CTS
Bug: 200309079
Change-Id: I161875ccf33267686d54ba3c1c94b597032bd4e8
diff --git a/camera/CameraUtils.cpp b/camera/CameraUtils.cpp
index af3c492..3473780 100644
--- a/camera/CameraUtils.cpp
+++ b/camera/CameraUtils.cpp
@@ -18,6 +18,7 @@
//#define LOG_NDEBUG 0
#include <camera/CameraUtils.h>
+#include <camera/camera2/OutputConfiguration.h>
#include <media/hardware/HardwareAPI.h>
#include <android-base/properties.h>
@@ -31,7 +32,7 @@
const char *kCameraServiceDisabledProperty = "config.disable_cameraservice";
status_t CameraUtils::getRotationTransform(const CameraMetadata& staticInfo,
- /*out*/int32_t* transform) {
+ int mirrorMode, /*out*/int32_t* transform) {
ALOGV("%s", __FUNCTION__);
if (transform == NULL) {
@@ -55,9 +56,18 @@
int32_t& flags = *transform;
- bool mirror = (entryFacing.data.u8[0] == ANDROID_LENS_FACING_FRONT);
+ int32_t mirror = 0;
+ if (mirrorMode == OutputConfiguration::MIRROR_MODE_AUTO &&
+ entryFacing.data.u8[0] == ANDROID_LENS_FACING_FRONT) {
+ mirror = NATIVE_WINDOW_TRANSFORM_FLIP_H;
+ } else if (mirrorMode == OutputConfiguration::MIRROR_MODE_H) {
+ mirror = NATIVE_WINDOW_TRANSFORM_FLIP_H;
+ } else if (mirrorMode == OutputConfiguration::MIRROR_MODE_V) {
+ mirror = NATIVE_WINDOW_TRANSFORM_FLIP_V;
+ }
+
int orientation = entry.data.i32[0];
- if (!mirror) {
+ if (mirror == 0) {
switch (orientation) {
case 0:
flags = 0;
@@ -77,25 +87,25 @@
return INVALID_OPERATION;
}
} else {
- // Front camera needs to be horizontally flipped for mirror-like behavior.
+ // - Front camera needs to be horizontally flipped for mirror-like behavior.
+ // - Application-specified mirroring needs to be applied.
// Note: Flips are applied before rotates; using XOR here as some of these flags are
// composed in terms of other flip/rotation flags, and are not bitwise-ORable.
switch (orientation) {
case 0:
- flags = NATIVE_WINDOW_TRANSFORM_FLIP_H;
+ flags = mirror;
break;
case 90:
- flags = NATIVE_WINDOW_TRANSFORM_FLIP_H ^
+ flags = mirror ^
NATIVE_WINDOW_TRANSFORM_ROT_270;
break;
case 180:
- flags = NATIVE_WINDOW_TRANSFORM_FLIP_H ^
+ flags = mirror ^
NATIVE_WINDOW_TRANSFORM_ROT_180;
break;
case 270:
- flags = NATIVE_WINDOW_TRANSFORM_FLIP_H ^
+ flags = mirror ^
NATIVE_WINDOW_TRANSFORM_ROT_90;
-
break;
default:
ALOGE("%s: Invalid HAL android.sensor.orientation value: %d",