From d9927380ed7c8366f762049be9f3fee225860833 Mon Sep 17 00:00:00 2001
From: liyujie <2352380935@qq.com>
Date: Thu, 28 Aug 2025 12:04:16 +0000
Subject: [PATCH] [2/4]解决USB摄像头打开相机预览界面绿屏

---
 android/hardware/aw/camera/3_4/stream_manager.cpp |   23 +++++++++++++++++++----
 1 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/android/hardware/aw/camera/3_4/stream_manager.cpp b/android/hardware/aw/camera/3_4/stream_manager.cpp
index 673948e..36f19b9 100755
--- a/android/hardware/aw/camera/3_4/stream_manager.cpp
+++ b/android/hardware/aw/camera/3_4/stream_manager.cpp
@@ -57,6 +57,7 @@
   HAL_LOG_ENTER();
   mDrop_main_buffers = 0;
   mDrop_sub_buffers = 0;
+  merge_stream_flag = 0;
   HAL_LOGD("device.use_count:%ld. camera.use_count:%ld.",
       device.use_count(), camera.use_count());
 }
@@ -96,7 +97,8 @@
                                           uint32_t height,
                                           int      format,
                                           uint32_t usage,
-                                          int      isBlob) {
+                                          int      isBlob,
+                                          bool     mergeStreamFlag) {
 
   HAL_LOG_ENTER();
   mMapFrameNumRef.clear();
@@ -105,7 +107,14 @@
     return nullptr;
   }
 
-  mConnection[ss +isBlob].reset(new V4L2Wrapper::Connection(device_, ss));
+  //mConnection[ss +isBlob].reset(new V4L2Wrapper::Connection(device_, ss));
+  if (width * height > 4000*3000) {
+      merge_stream_flag = 1;
+      mConnection[ss + isBlob].reset(new V4L2Wrapper::Connection(device_, ss, merge_stream_flag));
+  } else {
+      mConnection[ss + isBlob].reset(new V4L2Wrapper::Connection(device_, ss, merge_stream_flag));
+  }
+
   if (mConnection[ss +isBlob]->status()) {
     HAL_LOGE("Failed to connect to device: %d.",
         mConnection[ss +isBlob]->status());
@@ -146,7 +155,10 @@
     if (isBlob) {
       if (mCameraStream[ss] == nullptr) {
         if (mCameraStream[ss +isBlob]->initialize(width,
-                                                  height, format, usage)) {
+                                                  height,
+                                                  format,
+                                                  usage,
+                                                  mergeStreamFlag)) {
           HAL_LOGE("mCameraStream %d initialize failed.", ss);
           mConnection[ss +isBlob].reset();
           return nullptr;
@@ -158,7 +170,10 @@
     } else {
       if (mCameraStream[ss +1] == nullptr) {
         if (mCameraStream[ss +isBlob]->initialize(width,
-              height, format, usage)) {
+                                                  height,
+                                                  format,
+                                                  usage,
+                                                  mergeStreamFlag)) {
           HAL_LOGE("mCameraStream %d initialize failed.", ss);
           mConnection[ss +isBlob].reset();
           return nullptr;

--
Gitblit v1.6.2