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/v4l2_wrapper.cpp | 52 +++++++++++++++++++++++++++++----------------------- 1 files changed, 29 insertions(+), 23 deletions(-) diff --git a/android/hardware/aw/camera/3_4/v4l2_wrapper.cpp b/android/hardware/aw/camera/3_4/v4l2_wrapper.cpp index e5bcb6e..a63f733 100755 --- a/android/hardware/aw/camera/3_4/v4l2_wrapper.cpp +++ b/android/hardware/aw/camera/3_4/v4l2_wrapper.cpp @@ -95,7 +95,7 @@ V4L2Wrapper::~V4L2Wrapper() {} -int V4L2Wrapper::Connect(STREAM_SERIAL ss) { +int V4L2Wrapper::Connect(STREAM_SERIAL ss, int merge_status) { HAL_LOG_ENTER(); std::lock_guard<std::mutex> lock(connection_lock_); std::string device_path; @@ -107,19 +107,23 @@ case MAIN_STREAM_BLOB: case MAIN_MIRROR_STREAM: case MAIN_MIRROR_STREAM_BLOB: - if (Support_Id == 0) { - device_path = MAIN_STREAM_PATH; - } - tmpss = MAIN_STREAM; + if (device_id_ == 0 && merge_status) { + device_path = MAIN_MERGE_STREAM_PATH; + } else if (device_id_ == 0 && merge_status == 0) { + device_path = MAIN_STREAM_PATH; + } + tmpss = MAIN_STREAM; break; case SUB_0_STREAM: case SUB_0_STREAM_BLOB: case SUB_0_MIRROR_STREAM: case SUB_0_MIRROR_STREAM_BLOB: - if (Support_Id == 0) { - device_path = SUB_0_STREAM_PATH; - } - tmpss = SUB_0_STREAM; + if (device_id_ == 0 && merge_status) { + device_path = SUB_0_MERGE_STREAM_PATH; + } else if (device_id_ == 0 && merge_status == 0) { + device_path = SUB_0_STREAM_PATH; + } + tmpss = SUB_0_STREAM; break; default: HAL_LOGE("Failed to set stream device_path."); @@ -141,13 +145,15 @@ std::shared_ptr<V4L2Stream> stream(V4L2Stream::NewV4L2Stream(device_id_, device_path, - mCameraConfig)); + mCameraConfig, + merge_status + )); if (!stream) { HAL_LOGE("Failed to initialize stream helper."); return -1; } - stream_connection[tmpss].reset(new ConnectionStream(stream)); + stream_connection[tmpss].reset(new ConnectionStream(stream, merge_status)); if (stream_connection[tmpss]->status()) { HAL_LOGE("Failed to connect to device: %d.", stream_connection[tmpss]->status()); @@ -168,18 +174,18 @@ case MAIN_STREAM_BLOB: case MAIN_MIRROR_STREAM: case MAIN_MIRROR_STREAM_BLOB: - if (device_id_ == 0) { - device_path = MAIN_STREAM_PATH; - } + //if (device_id_ == 0) { + // device_path = MAIN_STREAM_PATH; + //} tmpss = MAIN_STREAM; break; case SUB_0_STREAM: case SUB_0_STREAM_BLOB: case SUB_0_MIRROR_STREAM: case SUB_0_MIRROR_STREAM_BLOB: - if (device_id_ == 0) { - device_path = SUB_0_STREAM_PATH; - } + //if (device_id_ == 0) { + // device_path = SUB_0_STREAM_PATH; + //} tmpss = SUB_0_STREAM; break; default: @@ -194,12 +200,12 @@ return; } - if (device_id_ == 1 && tmpss == MAIN_STREAM) { - device_path = MAIN_FRONT_STREAM_PATH; - } - if (device_id_ == 1 && tmpss == SUB_0_STREAM) { - device_path = SUB_0_FRONT_STREAM_PATH; - } + //if (device_id_ == 1 && tmpss == MAIN_STREAM) { + // device_path = MAIN_FRONT_STREAM_PATH; + //} + //if (device_id_ == 1 && tmpss == SUB_0_STREAM) { + // device_path = SUB_0_FRONT_STREAM_PATH; + //} --connection_count_[tmpss]; if (connection_count_[tmpss] > 0) { -- Gitblit v1.6.2