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/camera.cpp | 106 +++++++++++++++++++++++++++++++++++++---------------- 1 files changed, 74 insertions(+), 32 deletions(-) diff --git a/android/hardware/aw/camera/3_4/camera.cpp b/android/hardware/aw/camera/3_4/camera.cpp index 08aeac5..67b394f 100755 --- a/android/hardware/aw/camera/3_4/camera.cpp +++ b/android/hardware/aw/camera/3_4/camera.cpp @@ -371,48 +371,90 @@ return; } int64_t timestamp = 0; - struct timespec ts; - int res = 0; - res = clock_gettime(CLOCK_MONOTONIC, &ts); - if (res) { - HAL_LOGE("Failed to get BOOTTIME for state delegate: %d (%s)", - errno, - strerror(errno)); - completeRequestWithError(request); - return; - } - timestamp = ts.tv_sec * 1000000000ULL + ts.tv_nsec; - res = request->settings.update(ANDROID_SENSOR_TIMESTAMP, ×tamp, 1); - if (res) { - HAL_LOGE("Failed to update metadata tag 0x%x", ANDROID_SENSOR_TIMESTAMP); - } +// struct timespec ts; +// int res = 0; +// res = clock_gettime(CLOCK_MONOTONIC, &ts); +// if (res) { +// HAL_LOGE("Failed to get BOOTTIME for state delegate: %d (%s)", +// errno, +// strerror(errno)); +// completeRequestWithError(request); +// return; +// } + //timestamp = ts.tv_sec * 1000000000ULL + ts.tv_nsec; + //res = request->settings.update(ANDROID_SENSOR_TIMESTAMP, ×tamp, 1); + //if (res) { + // HAL_LOGE("Failed to update metadata tag 0x%x", ANDROID_SENSOR_TIMESTAMP); + //} // Since |request| has been removed from the tracking, this method // MUST call sendResult (can still return a result in an error state, e.g. // through completeRequestWithError) so the frame doesn't get lost. if (err) { - HAL_LOGE("mId:%d: Error completing request for frame %d.", - mId, request->frame_number); - completeRequestWithError(request); - return; + switch (err) { + case 404: + HAL_LOGI("This is a record complete request!"); + break; + default: + HAL_LOGE("mId:%d: Error completing request for frame %d.", + mId, request->frame_number); + completeRequestWithError(request); + return; + } } - // Notify the framework with the shutter time (extracted from the result). - // TODO(b/31360070): The general metadata methods should be part of the - // default_camera_hal namespace, not the v4l2_camera_hal namespace. - res = v4l2_camera_hal::SingleTagValue( - request->settings, ANDROID_SENSOR_TIMESTAMP, ×tamp); + if (!err) { + HAL_LOGI("It's a merge picture!"); + struct timespec ts; + int res; + res = clock_gettime(CLOCK_BOOTTIME, &ts); + if (res) { + HAL_LOGE("Failed to get BOOTTIME for state delegate: %d (%s)", + errno, + strerror(errno)); + } + timestamp = ts.tv_sec * 1000000000ULL + ts.tv_nsec; + res = request->settings.update(ANDROID_SENSOR_TIMESTAMP, ×tamp, 1); + if (res) { + HAL_LOGE("Failed to UpdateMetadata timestamp."); + } + } else { + HAL_LOGI("It's a record!"); + int res; + // Notify the framework with the shutter time (extracted from the result). + // TODO(b/31360070): The general metadata methods should be part of the + // default_camera_hal namespace, not the v4l2_camera_hal namespace. + res = v4l2_camera_hal::SingleTagValue( + request->settings, ANDROID_SENSOR_TIMESTAMP, ×tamp); - if (res) { - HAL_LOGE("mId:%d: Request for frame %d is missing required metadata.", - mId, request->frame_number); - // TODO(b/31653322): Send RESULT error. - // For now sending REQUEST error instead. - // TODO(calvin) fix this one, SingleTagValue error. - // completeRequestWithError(request); - // return; + if (res) { + HAL_LOGE("%s:%d: Request for frame %d is missing required metadata.", + __func__, mId, request->frame_number); + // TODO(b/31653322): Send RESULT error. + // For now sending REQUEST error instead. + // TODO:calvin, fix this one, SingleTagValue error. + // completeRequestWithError(request); + // return; + } } + + //// Notify the framework with the shutter time (extracted from the result). + //// TODO(b/31360070): The general metadata methods should be part of the + //// default_camera_hal namespace, not the v4l2_camera_hal namespace. + //res = v4l2_camera_hal::SingleTagValue( + // request->settings, ANDROID_SENSOR_TIMESTAMP, ×tamp); + + //if (res) { + // HAL_LOGE("mId:%d: Request for frame %d is missing required metadata.", + // mId, request->frame_number); + // // TODO(b/31653322): Send RESULT error. + // // For now sending REQUEST error instead. + // // TODO(calvin) fix this one, SingleTagValue error. + // // completeRequestWithError(request); + // // return; + //} + #if DBG_PERFORMANCE if (btimeRequest == 0) { btimeRequest = request->timeRequest; -- Gitblit v1.6.2