liyujie
2025-08-28 d9927380ed7c8366f762049be9f3fee225860833
android/hardware/aw/camera/3_4/v4l2_camera.cpp
....@@ -57,7 +57,8 @@
5757
5858 V4L2Camera* V4L2Camera::NewV4L2Camera(
5959 int id,
60
- std::shared_ptr<CCameraConfig> pCameraCfg) {
60
+ std::shared_ptr<CCameraConfig> pCameraCfg,
61
+ bool mergeStreamStatus) {
6162 HAL_LOG_ENTER();
6263 // Select one stream for fill metadata.
6364 // The path has been pick the stream for query format.
....@@ -80,13 +81,15 @@
8081 return new V4L2Camera(id,
8182 std::move(v4l2_wrapper),
8283 std::move(metadata),
83
- std::move(pCameraCfg));
84
+ std::move(pCameraCfg),
85
+ mergeStreamStatus);
8486 }
8587
8688 V4L2Camera::V4L2Camera(int id,
8789 std::shared_ptr<V4L2Wrapper> v4l2_wrapper,
8890 std::unique_ptr<Metadata> metadata,
89
- std::shared_ptr<CCameraConfig> pCameraCfg)
91
+ std::shared_ptr<CCameraConfig> pCameraCfg,
92
+ bool mergeStreamStatus)
9093 : default_camera_hal::Camera(id),
9194 mCameraConfig(std::move(pCameraCfg)),
9295 device_(std::move(v4l2_wrapper)),
....@@ -101,7 +104,9 @@
101104 FlashStatusFlag(0),
102105 MarkFrameNum(0),
103106 curFlashStateE(CAM_FLASH_STATE_MAX),
104
- curFlashModeE(CAM_FLASH_MODE_MAX) {
107
+ curFlashModeE(CAM_FLASH_MODE_MAX),
108
+ merge_stream_status_(mergeStreamStatus),
109
+ is_merge_stream_flag(false){
105110
106111 HAL_LOG_ENTER();
107112 instance = std::shared_ptr<V4L2Camera>(this);
....@@ -1224,7 +1229,7 @@
12241229 return true;
12251230 }
12261231
1227
-int V4L2Camera::sResultCallback(uint32_t frameNumber, struct timeval /*ts*/) {
1232
+int V4L2Camera::sResultCallback(uint32_t frameNumber, struct timeval ts) {
12281233 std::unique_lock<std::mutex> lock(frameNumber_request_lock_);
12291234 int res = 0;
12301235 int ret = 0;
....@@ -1272,6 +1277,17 @@
12721277 HAL_LOGE("Failed to update metadata tag 0x%x",
12731278 ANDROID_JPEG_THUMBNAIL_SIZE);
12741279 }
1280
+ }
1281
+
1282
+ if(!is_merge_stream_flag)
1283
+ {
1284
+ int64_t timestamp = 0;
1285
+ timestamp = ts.tv_sec * 1000000000ULL + ts.tv_usec*1000;
1286
+ ret = (&map_entry->second->settings)->update(ANDROID_SENSOR_TIMESTAMP, &timestamp, 1);
1287
+ if (ret) {
1288
+ HAL_LOGE("Failed to update metadata tag 0x%x", ANDROID_SENSOR_TIMESTAMP);
1289
+ }
1290
+ res = 404;
12751291 }
12761292
12771293 if (mCameraConfig->supportFlashMode()) {
....@@ -1533,6 +1549,19 @@
15331549 while (!wfequest_queue_stream_.empty()) {
15341550 if (rfequest_queue_stream_.front()->frame_number ==
15351551 wfequest_queue_stream_.front()->frame_number) {
1552
+
1553
+ if (!is_merge_stream_flag) {
1554
+ int64_t timestamp_w = 0;
1555
+ timestamp_w = ts.tv_sec * 1000000000ULL + ts.tv_usec*1000;
1556
+ ret = (&map_entry->second->settings)->update(
1557
+ ANDROID_SENSOR_TIMESTAMP, &timestamp_w, 1);
1558
+ if (ret) {
1559
+ HAL_LOGE("Failed to update metadata tag 0x%x",
1560
+ ANDROID_SENSOR_TIMESTAMP);
1561
+ }
1562
+ res = 404;
1563
+ }
1564
+
15361565 completeRequest(wfequest_queue_stream_.front(), res);
15371566 wfequest_queue_stream_.pop();
15381567 rfequest_queue_stream_.pop();
....@@ -1638,7 +1667,8 @@
16381667 stream_config->streams[retIndex]->height,
16391668 stream_config->streams[retIndex]->format,
16401669 stream_config->streams[retIndex]->usage,
1641
- isBlob));
1670
+ isBlob,
1671
+ merge_stream_status_));
16421672 if (nullptr == stream_config->streams[retIndex]->priv) {
16431673 HAL_LOGE("Failed create main stream!");
16441674 return -EINVAL;
....@@ -1676,7 +1706,8 @@
16761706 stream_config->streams[retIndex]->height,
16771707 stream_config->streams[retIndex]->format,
16781708 stream_config->streams[retIndex]->usage,
1679
- isBlob));
1709
+ isBlob,
1710
+ merge_stream_status_));
16801711 if (nullptr == stream_config->streams[retIndex]->priv) {
16811712 HAL_LOGE("Failed create sub stream!");
16821713 return -EINVAL;
....@@ -1731,7 +1762,8 @@
17311762 stream_config->streams[thirdIndex]->height,
17321763 stream_config->streams[thirdIndex]->format,
17331764 stream_config->streams[thirdIndex]->usage,
1734
- isBlob));
1765
+ isBlob,
1766
+ merge_stream_status_));
17351767
17361768 if (nullptr == stream_config->streams[thirdIndex]->priv) {
17371769 HAL_LOGE("Failed create third stream!");
....@@ -1772,7 +1804,8 @@
17721804 stream_config->streams[thirdIndex]->height,
17731805 stream_config->streams[thirdIndex]->format,
17741806 stream_config->streams[thirdIndex]->usage,
1775
- isBlob));
1807
+ isBlob,
1808
+ merge_stream_status_));
17761809
17771810 camera3_stream_t* subIndexStream = stream_config->streams[subIndex];
17781811 camera3_stream_t* thirdIndexStream = stream_config->streams[thirdIndex];
....@@ -1829,6 +1862,7 @@
18291862 for (uint32_t i = 0; i < stream_config->num_streams; ++i) {
18301863 fillStreamInfo(stream_config->streams[i]);
18311864 }
1865
+ is_merge_stream_flag = false;
18321866 for (uint32_t i = 0; i < stream_config->num_streams; ++i) {
18331867 HAL_LOGD("stream %d is format %d(%s), width %d, height %d, "
18341868 "usage %d(%s), stream_type %d, data_space %d, num_streams:%d.",
....@@ -1842,6 +1876,10 @@
18421876 stream_config->streams[i]->stream_type,
18431877 stream_config->streams[i]->data_space,
18441878 stream_config->num_streams);
1879
+ if(stream_config->streams[i]->width * stream_config->streams[i]->height >
1880
+ 4000*3000) {
1881
+ is_merge_stream_flag = true;
1882
+ }
18451883 }
18461884
18471885 HAL_LOGI("setupStreams finished");