How to configure left and right mirror images for camera APK when connecting to a USB camera ?

Which system do you use? Android, Ubuntu, OOWOW or others?

Android

Which version of system do you use? Khadas official images, self built images, or others?

self built images

Please describe your issue below:

problem:
I am connected to a USB camera, and I would like the image to be mirrored left and right. How do I configure it?

I tried and configured the camera to be front facing:
Then force mirroring processing:

frameworks/av/services/camera/libcameraservice/api1/CameraClient.cpp:

CameraClient::sendCommand(int32_t cmd, int32_t arg1, int32_t arg2) {
 
         // Mirror the preview if the camera is front-facing.
         orientation = getOrientation(arg1, mCameraFacing == CAMERA_FACING_FRONT);
+        orientation = 1;  // add

But it doesn’t run here!
Camera2 api2, I am not very familiar with it. how to configure and solve the system problem??
Please tell me, thank you.

I have made changes to the left and right mirrors of the camera, but where have the left and right mirrors of the camera’s video been modified?
Please tell me!
thank you!

How did you modify it?

+++ b/av/camera/CameraUtils.cpp
@@ -30,15 +30,15 @@ namespace android {

 status_t CameraUtils::getRotationTransform(const CameraMetadata& staticInfo,
                 /*out*/int32_t* transform) {
-    ALOGV("%s", __FUNCTION__);
+    ALOGW("jack%s", __FUNCTION__);

-    if (transform == NULL) {
-        ALOGW("%s: null transform", __FUNCTION__);
-        return BAD_VALUE;
-    }
+ //   if (transform == NULL) {
+ //       ALOGW("%s: null transform", __FUNCTION__);
+ //       return BAD_VALUE;
+ //   }

     *transform = 0;
-
+      ALOGW("%s: null transform", __FUNCTION__);
     camera_metadata_ro_entry_t entry = staticInfo.find(ANDROID_SENSOR_ORIENTATION);
     if (entry.count == 0) {
         ALOGE("%s: Can't find android.sensor.orientation in static metadata!", __FUNCTION__);
@@ -56,6 +56,8 @@ status_t CameraUtils::getRotationTransform(const CameraMetadata& staticInfo,
     bool mirror = (entryFacing.data.u8[0] == ANDROID_LENS_FACING_FRONT)
            || (entryFacing.data.u8[0] == ANDROID_LENS_FACING_EXTERNAL);
     int orientation = entry.data.i32[0];
+     mirror =0;
+      orientation = 0;
     if (!mirror) {
         switch (orientation) {
             case 0:

But where did the camera video modify the left and right mirrors?

I added printing, but the camera video left and right mirrors don’t go here

@goenjoy You have excellent skills Please help me solve this system configuration issue.