From 52f5aa63caded52b91b23962ca5527d4f6e6e73c Mon Sep 17 00:00:00 2001 From: mazhanwei Date: Mon, 28 Oct 2024 09:50:27 +0000 Subject: [PATCH] =?UTF-8?q?=E7=9B=B8=E6=9C=BA=E9=A2=84=E8=A7=88OK=20patch?= =?UTF-8?q?=20=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- patches/build/0001-camera-white-list.patch | 12 + .../peripheral/0001-camera-driver.patch | 1627 +++++++++++++++++ 2 files changed, 1639 insertions(+) create mode 100644 patches/build/0001-camera-white-list.patch create mode 100644 patches/drivers/peripheral/0001-camera-driver.patch diff --git a/patches/build/0001-camera-white-list.patch b/patches/build/0001-camera-white-list.patch new file mode 100644 index 0000000..ee24ec6 --- /dev/null +++ b/patches/build/0001-camera-white-list.patch @@ -0,0 +1,12 @@ +diff --git a/core/gn/ohos_exec_script_allowlist.gni b/core/gn/ohos_exec_script_allowlist.gni +index 8b97f4a1..63072b7f 100644 +--- a/core/gn/ohos_exec_script_allowlist.gni ++++ b/core/gn/ohos_exec_script_allowlist.gni +@@ -62,6 +62,7 @@ ohos_exec_script_config = { + "//device/board/bearpi/bearpi_hm_micro/liteos_a/BUILD.gn", + "//device/board/hihope/dayu210/camera/vdi_impl/v4l2/BUILD.gn", + "//device/board/hihope/rk3568/camera/vdi_impl/v4l2/BUILD.gn", ++ "//device/board/hardmony/oriole/camera/vdi_impl/v4l2/BUILD.gn", + "//device/board/hisilicon/hispark_aries/liteos_a/BUILD.gn", + "//device/board/hisilicon/hispark_taurus/camera/BUILD.gn", + "//device/board/hisilicon/hispark_taurus/liteos_a/BUILD.gn", diff --git a/patches/drivers/peripheral/0001-camera-driver.patch b/patches/drivers/peripheral/0001-camera-driver.patch new file mode 100644 index 0000000..753fbe6 --- /dev/null +++ b/patches/drivers/peripheral/0001-camera-driver.patch @@ -0,0 +1,1627 @@ +diff --git a/camera/BUILD.gn b/camera/BUILD.gn +index d5dad64f4..e8f228131 100644 +--- a/camera/BUILD.gn ++++ b/camera/BUILD.gn +@@ -37,7 +37,6 @@ if (defined(ohos_lite)) { + "hdi_service/v1_0:camera_host_service_1.0", + "vdi_base/common/metadata_manager:camera_example_vendor_tag_impl", + "vdi_base/common/utils:peripheral_camera_utils", +- "vdi_base/usb_camera:usb_camera_vdi_impl", + ] + if (drivers_peripheral_camera_feature_usb == false) { + deps += [ +@@ -56,7 +55,7 @@ if (defined(ohos_lite)) { + } else { + testonly = true + if (drivers_peripheral_camera_feature_usb == true) { +- deps = [ "test/ut/usb_camera:camera_usb_test_ut" ] ++ #deps = [ "test/ut/usb_camera:camera_usb_test_ut" ] + } else { + deps = [ + # acceptance unit test +@@ -73,7 +72,7 @@ if (defined(ohos_lite)) { + "test/ut/buffer_manager:camera_buffer_manager_ut", + + # usb camera unit test +- "test/ut/usb_camera:camera_usb_test_ut", ++ #"test/ut/usb_camera:camera_usb_test_ut", + ] + } + } +diff --git a/camera/hdi_service/v1_0/BUILD.gn b/camera/hdi_service/v1_0/BUILD.gn +index 6e1fb07d5..01eb97dc4 100644 +--- a/camera/hdi_service/v1_0/BUILD.gn ++++ b/camera/hdi_service/v1_0/BUILD.gn +@@ -120,9 +120,6 @@ if (defined(ohos_lite)) { + if (use_hitrace) { + defines += [ "HITRACE_LOG_ENABLED" ] + } +- if (drivers_peripheral_camera_feature_usb) { +- defines += [ "CHIP_PROD_CAMERA_HOST_CONFIG" ] +- } + + if (is_standard_system) { + external_deps = [ +diff --git a/camera/test/BUILD.gn b/camera/test/BUILD.gn +index 53fbf1ba6..209a23043 100644 +--- a/camera/test/BUILD.gn ++++ b/camera/test/BUILD.gn +@@ -16,7 +16,7 @@ import("../camera.gni") + group("camera_hal_test") { + testonly = true + if (drivers_peripheral_camera_feature_usb == true) { +- deps = [ "$test_path/ut/usb_camera:camera_usb_test_ut" ] ++ #deps = [ "$test_path/ut/usb_camera:camera_usb_test_ut" ] + } else { + deps = [ + "$test_path/benchmarktest/v1_0:hdf_camera_benchmark_test", +@@ -25,7 +25,7 @@ group("camera_hal_test") { + "$test_path/hdi/sequenceable_test:camera_hdi_sequenceable_ut", + "$test_path/hdi/v1_0:camera_test_at", + "$test_path/ut/buffer_manager:camera_buffer_manager_ut", +- "$test_path/ut/usb_camera:camera_usb_test_ut", ++ #"$test_path/ut/usb_camera:camera_usb_test_ut", + "$test_path/ut/v4l2:camera_test_v4l2_ut", + ] + } +diff --git a/camera/vdi_base/common/adapter/platform/v4l2/src/device_manager/include/sensor_controller.h b/camera/vdi_base/common/adapter/platform/v4l2/src/device_manager/include/sensor_controller.h +index e4c140287..18d09cb43 100644 +--- a/camera/vdi_base/common/adapter/platform/v4l2/src/device_manager/include/sensor_controller.h ++++ b/camera/vdi_base/common/adapter/platform/v4l2/src/device_manager/include/sensor_controller.h +@@ -37,12 +37,18 @@ public: + RetCode ConfigStart(); + RetCode ConfigStop(); + RetCode Start(int buffCont, DeviceFormat& format); ++ RetCode Start(std::vector &vBufCnt, std::vector &vDeviceFormat); + RetCode Stop(); + ++ RetCode CreateBuffers(); ++ RetCode DestoryBuffers(); + RetCode SendFrameBuffer(std::shared_ptr buffer); ++ RetCode SendPhotoFrameBuffer(std::shared_ptr buffer); + + void SetNodeCallBack(const NodeBufferCb cb); ++ void SetPhotoNodeCallBack(const NodeBufferCb cb); + void BufferCallback(std::shared_ptr buffer); ++ void PhotoBufferCallback(std::shared_ptr buffer); + + void SetAbilityMetaDataTag(std::vector abilityMetaDataTag); + RetCode GetAbilityMetaData(std::shared_ptr meta); +@@ -113,6 +119,7 @@ private: + std::mutex startSensorLock_; + bool startSensorState_ = false; + NodeBufferCb nodeBufferCb_ = nullptr; ++ NodeBufferCb photoNodeBufferCb_ = nullptr; + std::vector abilityMetaData_; + std::mutex metaDataSetlock_; + std::mutex metaDataFlaglock_; +diff --git a/camera/vdi_base/common/adapter/platform/v4l2/src/device_manager/sensor_controller.cpp b/camera/vdi_base/common/adapter/platform/v4l2/src/device_manager/sensor_controller.cpp +index bbeff8268..7ce086e7c 100644 +--- a/camera/vdi_base/common/adapter/platform/v4l2/src/device_manager/sensor_controller.cpp ++++ b/camera/vdi_base/common/adapter/platform/v4l2/src/device_manager/sensor_controller.cpp +@@ -136,10 +136,48 @@ RetCode SensorController::Start(int buffCont, DeviceFormat& format) + RetCode rc = RC_OK; + if (startSensorState_ == false) { + buffCont_ = buffCont; ++ rc = sensorVideo_->start(GetName()); ++ if (rc != RC_OK) { ++ return rc; ++ } ++ rc = sensorVideo_->ConfigSys(GetName(), CMD_V4L2_SET_FORMAT, format); ++ if (rc != RC_OK) { ++ return rc; ++ } ++ rc = sensorVideo_->ReqBuffers(GetName(), buffCont_); ++ if (rc != RC_OK) { ++ return rc; ++ } ++ startSensorState_ = true; ++ } ++ return rc; ++}; ++ ++ ++RetCode SensorController::Start(std::vector &vBufCnt, std::vector &vDeviceFormat) ++{ ++ CAMERA_LOGI("%s Start multiports SensorController", __FUNCTION__); ++ std::lock_guard lock(startSensorLock_); ++ RetCode rc = RC_OK; ++ if (startSensorState_ == false) { ++ buffCont_ = vBufCnt[0]; ++ rc = sensorVideo_->start(GetName()); ++ if (rc != RC_OK) { ++ return rc; ++ } ++ for (int i = 0; i < vBufCnt.size(); i++) { ++ rc = sensorVideo_->ConfigSys(GetName(), CMD_V4L2_SET_FORMAT, vDeviceFormat[i]); ++ if (rc != RC_OK) { ++ return rc; ++ } ++ } ++ for (int i = 0; i < vBufCnt.size(); i++) { ++ rc = sensorVideo_->ReqBuffers(GetName(), vBufCnt[i], vDeviceFormat[i]); ++ if (rc != RC_OK) { ++ return rc; ++ } ++ } + startSensorState_ = true; +- sensorVideo_->start(GetName()); +- sensorVideo_->ConfigSys(GetName(), CMD_V4L2_SET_FORMAT, format); +- sensorVideo_->ReqBuffers(GetName(), buffCont_); + } + return rc; + }; +@@ -159,19 +197,30 @@ RetCode SensorController::Stop() + return rc; + }; + +-RetCode SensorController::SendFrameBuffer(std::shared_ptr buffer) ++RetCode SensorController::CreateBuffers() + { + RetCode ret = RC_OK; +- if (buffCont_ >= 1) { +- CAMERA_LOGI("buffCont_ %{public}d", buffCont_); +- sensorVideo_->CreatBuffer(GetName(), buffer); +- if (buffCont_ == 1) { +- ret = sensorVideo_->StartStream(GetName()); +- } +- buffCont_--; +- } else { +- ret = sensorVideo_->QueueBuffer(GetName(), buffer); +- } ++ sensorVideo_->CreatBuffer(GetName(), buffCont_); ++ ret = sensorVideo_->StartStream(GetName()); ++ return ret; ++} ++ ++ ++RetCode SensorController::DestoryBuffers() ++{ ++ sensorVideo_->DestoryBuffers(); ++ return RC_OK; ++} ++ ++RetCode SensorController::SendFrameBuffer(std::shared_ptr buffer) ++{ ++ RetCode ret = sensorVideo_->QueueBuffer(GetName(), buffer); ++ return ret; ++} ++ ++RetCode SensorController::SendPhotoFrameBuffer(std::shared_ptr buffer) ++{ ++ RetCode ret = sensorVideo_->QueuePhotoBuffer(GetName(), buffer); + return ret; + } + +@@ -184,6 +233,55 @@ void SensorController::SetNodeCallBack(const NodeBufferCb cb) + }); + } + ++void SensorController::SetPhotoNodeCallBack(const NodeBufferCb cb) ++{ ++ CAMERA_LOGI("SensorController SetPhotoNodeCallBack entry"); ++ photoNodeBufferCb_ = cb; ++ sensorVideo_->SetPhotoCallback([&](std::shared_ptr buffer) { ++ PhotoBufferCallback(buffer); ++ }); ++} ++ ++void SensorController::PhotoBufferCallback(std::shared_ptr buffer) ++{ ++ if (photoNodeBufferCb_ == nullptr) { ++ CAMERA_LOGE("photoNodeBufferCb_ is nullptr"); ++ return; ++ } ++ ++ constexpr uint32_t UNIT_COUNT = 1000; ++ struct timeval tv; ++ gettimeofday(&tv, NULL); ++ int64_t timestamp = static_cast(tv.tv_sec) * UNIT_COUNT * UNIT_COUNT + tv.tv_usec; ++ buffer->buffer_->SetEsTimestamp(timestamp); ++ photoNodeBufferCb_(buffer); ++ ++ // const int ENTRY_CAPACITY = 30; // 30:entry capacity ++ // const int DATA_CAPACITY = 2000; // 2000:data capacity ++ // std::shared_ptr meta = ++ // std::make_shared(ENTRY_CAPACITY, DATA_CAPACITY); ++ // if (meta == nullptr) { ++ // CAMERA_LOGE("meta is nullptr"); ++ // return; ++ // } ++ // RetCode rc = GetAbilityMetaData(meta); ++ // std::lock_guard lock(metaDataFlaglock_); ++ // if (rc == RC_OK && metaDataFlag_ == true) { ++ // if (metaDataCb_ == nullptr) { ++ // CAMERA_LOGE("metaDataCb_ is nullptr"); ++ // return; ++ // } ++ // metaDataCb_(meta); ++ // metaDataFlag_ = false; ++ // } else { ++ // if (rc == RC_ERROR) { ++ // CAMERA_LOGE("%s GetAbilityMetaData error", __FUNCTION__); ++ // } else { ++ // CAMERA_LOGI("%s no send", __FUNCTION__); ++ // } ++ // } ++} ++ + void SensorController::BufferCallback(std::shared_ptr buffer) + { + if (nodeBufferCb_ == nullptr) { +diff --git a/camera/vdi_base/common/adapter/platform/v4l2/src/device_manager/v4l2_device_manager.cpp b/camera/vdi_base/common/adapter/platform/v4l2/src/device_manager/v4l2_device_manager.cpp +index 8f91f4691..186c27229 100644 +--- a/camera/vdi_base/common/adapter/platform/v4l2/src/device_manager/v4l2_device_manager.cpp ++++ b/camera/vdi_base/common/adapter/platform/v4l2/src/device_manager/v4l2_device_manager.cpp +@@ -355,7 +355,7 @@ void V4L2DeviceManager::UvcCallBack(const std::string hardwareName, std::vector< + CameraId id = ReturnEnableCameraId(hardwareName); + CHECK_IF_EQUAL_RETURN_VOID(id, CAMERA_MAX); + CHECK_IF_PTR_NULL_RETURN_VOID(uvcCb_); +- ++ + for (auto iter = hardwareList_.cbegin(); iter != hardwareList_.cend();) { + if ((*iter).cameraId != id) { + iter++; +diff --git a/camera/vdi_base/common/adapter/platform/v4l2/src/driver_adapter/BUILD.gn b/camera/vdi_base/common/adapter/platform/v4l2/src/driver_adapter/BUILD.gn +index a3b427d74..1e43f8059 100644 +--- a/camera/vdi_base/common/adapter/platform/v4l2/src/driver_adapter/BUILD.gn ++++ b/camera/vdi_base/common/adapter/platform/v4l2/src/driver_adapter/BUILD.gn +@@ -19,9 +19,28 @@ config("v4l2_config") { + visibility = [ ":*" ] + + cflags = [ ++ "-Wall", ++ "-Wextra", ++ "-Werror", ++ "-Wno-error", + "-DGST_DISABLE_DEPRECATED", + "-DHAVE_CONFIG_H", + "-DCOLORSPACE=\"videoconvert\"", ++ "-fno-strict-aliasing", ++ "-Wno-sign-compare", ++ "-Wno-builtin-requires-header", ++ "-Wno-unused-variable", ++ "-Wno-unused-label", ++ "-Wno-implicit-function-declaration", ++ "-Wno-format", ++ "-Wno-int-conversion", ++ "-Wno-unused-function", ++ "-Wno-thread-safety-attributes", ++ "-Wno-inconsistent-missing-override", ++ "-fno-rtti", ++ "-fno-exceptions", ++ "-ffunction-sections", ++ "-fdata-sections", + ] + + if (enable_camera_device_utest) { +@@ -33,7 +52,8 @@ config("v4l2_config") { + ldflags = [ "--coverage" ] + } + +- include_dirs = [ "./include" ] ++ #include_dirs = [ "./include" ] ++ include_dirs = [ "//device/board/${product_company}/${product_name}/camera/vdi_impl/v4l2/driver_adapter/include" ] + } + + ohos_shared_library("peripheral_camera_v4l2_adapter") { +@@ -42,16 +62,23 @@ ohos_shared_library("peripheral_camera_v4l2_adapter") { + defines += [ "CAMERA_BUILT_ON_USB" ] + } + sources = [ +- "$camera_path/dump/src/camera_dump.cpp", +- "src/v4l2_buffer.cpp", +- "src/v4l2_control.cpp", +- "src/v4l2_dev.cpp", +- "src/v4l2_fileformat.cpp", +- "src/v4l2_stream.cpp", +- "src/v4l2_uvc.cpp", ++ #"$camera_path/dump/src/camera_dump.cpp", ++ #"src/v4l2_buffer.cpp", ++ #"src/v4l2_control.cpp", ++ #"src/v4l2_dev.cpp", ++ #"src/v4l2_fileformat.cpp", ++ #"src/v4l2_stream.cpp", ++ #"src/v4l2_uvc.cpp", ++ "//device/board/${product_company}/${product_name}/camera/vdi_impl/v4l2/driver_adapter/src/v4l2_buffer.cpp", ++ "//device/board/${product_company}/${product_name}/camera/vdi_impl/v4l2/driver_adapter/src/v4l2_control.cpp", ++ "//device/board/${product_company}/${product_name}/camera/vdi_impl/v4l2/driver_adapter/src/v4l2_dev.cpp", ++ "//device/board/${product_company}/${product_name}/camera/vdi_impl/v4l2/driver_adapter/src/v4l2_fileformat.cpp", ++ "//device/board/${product_company}/${product_name}/camera/vdi_impl/v4l2/driver_adapter/src/v4l2_stream.cpp", ++ "//device/board/${product_company}/${product_name}/camera/vdi_impl/v4l2/driver_adapter/src/v4l2_uvc.cpp", + ] + + include_dirs = [ ++ "//device/board/${product_company}/${product_name}/camera/vdi_impl/v4l2/driver_adapter/include", + "$camera_path/include", + "$camera_path/dump/include", + "$camera_path/../interfaces", +diff --git a/camera/vdi_base/common/adapter/platform/v4l2/src/pipeline_core/nodes/v4l2_source_node/v4l2_source_node.cpp b/camera/vdi_base/common/adapter/platform/v4l2/src/pipeline_core/nodes/v4l2_source_node/v4l2_source_node.cpp +index 0a8f26463..e98686252 100644 +--- a/camera/vdi_base/common/adapter/platform/v4l2/src/pipeline_core/nodes/v4l2_source_node/v4l2_source_node.cpp ++++ b/camera/vdi_base/common/adapter/platform/v4l2/src/pipeline_core/nodes/v4l2_source_node/v4l2_source_node.cpp +@@ -20,6 +20,7 @@ namespace OHOS::Camera { + V4L2SourceNode::V4L2SourceNode(const std::string& name, const std::string& type, const std::string &cameraId) + : SourceNode(name, type, cameraId), NodeBase(name, type, cameraId) + { ++ streamId_ = -1; + CAMERA_LOGI("%s enter, type(%s)\n", name_.c_str(), type_.c_str()); + RetCode rc = RC_OK; + constexpr int itemCapacitySize = 30; +@@ -37,9 +38,33 @@ V4L2SourceNode::V4L2SourceNode(const std::string& name, const std::string& type, + meta_ = std::make_shared(itemCapacitySize, dataCapacitySize); + } + ++struct SourceMetadataTag { ++ std::string cameraId1 = "lcam001"; ++ CameraId cameraId2 = CAMERA_FIRST; ++}; ++ ++const SourceMetadataTag g_sourceMapCameraId[] = { ++ { "lcam001", CAMERA_FIRST }, ++ { "lcam002", CAMERA_SECOND }, ++ { "lcam003", CAMERA_THIRD }, ++ { "lcam004", CAMERA_FOURTH }, ++ { "lcam005", CAMERA_FIFTH }, ++ { "lcam006", CAMERA_SIXTH } ++}; ++ ++CameraId V4L2SourceNode::ConvertCameraId(const std::string &cameraId) ++{ ++ for (auto cameraID : g_sourceMapCameraId) { ++ if (cameraID.cameraId1 == cameraId) { ++ return cameraID.cameraId2; ++ } ++ } ++ return CAMERA_FIRST; ++} ++ + RetCode V4L2SourceNode::GetDeviceController() + { +- CameraId cameraId = CAMERA_FIRST; ++ CameraId cameraId = ConvertCameraId(cameraId_); + sensorController_ = std::static_pointer_cast + (deviceManager_->GetController(cameraId, DM_M_SENSOR, DM_C_SENSOR)); + if (sensorController_ == nullptr) { +@@ -57,67 +82,119 @@ RetCode V4L2SourceNode::Init(const int32_t streamId) + RetCode V4L2SourceNode::Start(const int32_t streamId) + { + RetCode rc = RC_OK; +- deviceManager_ = IDeviceManager::GetInstance(); +- if (deviceManager_ == nullptr) { +- CAMERA_LOGE("get device manager failed."); +- return RC_ERROR; +- } +- rc = GetDeviceController(); +- if (rc == RC_ERROR) { +- CAMERA_LOGE("GetDeviceController failed."); +- return RC_ERROR; +- } +- std::vector> outPorts = GetOutPorts(); +- for (const auto& it : outPorts) { +- DeviceFormat format; +- format.fmtdesc.pixelformat = V4L2Utils::ConvertPixfmtHal2V4l2( +- static_cast(it->format_.format_)); +- format.fmtdesc.width = wide_; +- format.fmtdesc.height = high_; +- int bufCnt = it->format_.bufferCount_; +- rc = sensorController_->Start(bufCnt, format); +- if (rc == RC_ERROR) { +- CAMERA_LOGE("start failed."); +- return RC_ERROR; ++ if (streamId_ < 0) { ++ std::vector> outPorts = GetOutPorts(); ++ for (const auto& it : outPorts) { ++ if ((it->GetName() == "out0") && (streamId == it->format_.streamId_)) { ++ streamId_ = streamId; ++ break; ++ } + } + } +- isAdjust_ = true; +- if (meta_ != nullptr) { +- sensorController_->ConfigFps(meta_); +- } ++ if (streamId_ == streamId) { ++ deviceManager_ = IDeviceManager::GetInstance(); ++ if (deviceManager_ == nullptr) { ++ CAMERA_LOGE("get device manager failed."); ++ return RC_ERROR; ++ } ++ rc = GetDeviceController(); ++ if (rc == RC_ERROR) { ++ CAMERA_LOGE("GetDeviceController failed."); ++ return RC_ERROR; ++ } ++ std::vector> outPorts = GetOutPorts(); ++ if (outPorts.size() == 2) { ++ std::vector vBufCnt; ++ std::vector vDeviceFormat; ++ for (const auto& it : outPorts) { ++ if (streamId == it->format_.streamId_) { ++ DeviceFormat format; ++ format.fmtdesc.pixelformat = V4L2Utils::ConvertPixfmtHal2V4l2( ++ static_cast(it->format_.format_)); ++ format.fmtdesc.width = it->format_.w_; ++ format.fmtdesc.height = it->format_.h_; ++ format.fmtdesc.streamtype = it->format_.streamType_; ++ int bufCnt = it->format_.bufferCount_; ++ vBufCnt.insert(vBufCnt.begin(), bufCnt); ++ vDeviceFormat.insert(vDeviceFormat.begin(), format); ++ } else { ++ DeviceFormat format; ++ format.fmtdesc.pixelformat = V4L2Utils::ConvertPixfmtHal2V4l2( ++ static_cast(it->format_.format_)); ++ format.fmtdesc.width = it->format_.w_; ++ format.fmtdesc.height = it->format_.h_; ++ format.fmtdesc.streamtype = it->format_.streamType_; ++ int bufCnt = it->format_.bufferCount_; ++ vBufCnt.push_back(bufCnt); ++ vDeviceFormat.push_back(format); ++ } ++ } ++ rc = sensorController_->Start(vBufCnt, vDeviceFormat); ++ if (rc == RC_ERROR) { ++ CAMERA_LOGE("start failed."); ++ return RC_ERROR; ++ } ++ isAdjust_ = false; ++ if (meta_ != nullptr) { ++ sensorController_->ConfigFps(meta_); ++ } ++ rc = SourceNode::StartWithDoubleStream(streamId); ++ } else { ++ for (const auto& it : outPorts) { ++ DeviceFormat format; ++ format.fmtdesc.pixelformat = V4L2Utils::ConvertPixfmtHal2V4l2( ++ static_cast(it->format_.format_)); ++ format.fmtdesc.width = it->format_.w_; ++ format.fmtdesc.height = it->format_.h_; ++ int bufCnt = it->format_.bufferCount_; ++ rc = sensorController_->Start(bufCnt, format); ++ if (rc == RC_ERROR) { ++ CAMERA_LOGE("start failed."); ++ return RC_ERROR; ++ } ++ } + +- rc = SourceNode::Start(streamId); ++ isAdjust_ = false; ++ if (meta_ != nullptr) { ++ sensorController_->ConfigFps(meta_); ++ } ++ ++ rc = SourceNode::Start(streamId); ++ } ++ } + return rc; + } + + V4L2SourceNode::~V4L2SourceNode() + { ++ streamId_ = -1; + CAMERA_LOGV("%{public}s, v4l2 source node dtor.", __FUNCTION__); + } + + RetCode V4L2SourceNode::Flush(const int32_t streamId) + { +- RetCode rc; +- +- if (sensorController_ != nullptr) { +- rc = sensorController_->Flush(streamId); +- CHECK_IF_NOT_EQUAL_RETURN_VALUE(rc, RC_OK, RC_ERROR); ++ RetCode rc = RC_OK; ++ if (streamId_ == streamId) { ++ if (sensorController_ != nullptr) { ++ rc = sensorController_->Flush(streamId); ++ CHECK_IF_NOT_EQUAL_RETURN_VALUE(rc, RC_OK, RC_ERROR); ++ } ++ rc = SourceNode::Flush(streamId); + } +- rc = SourceNode::Flush(streamId); +- + return rc; + } + + RetCode V4L2SourceNode::Stop(const int32_t streamId) + { +- RetCode rc; +- +- if (sensorController_ != nullptr) { +- rc = sensorController_->Stop(); +- CHECK_IF_NOT_EQUAL_RETURN_VALUE(rc, RC_OK, RC_ERROR); ++ RetCode rc = RC_OK; ++ if (streamId_ == streamId) { ++ if (sensorController_ != nullptr) { ++ rc = sensorController_->Stop(); ++ CHECK_IF_NOT_EQUAL_RETURN_VALUE(rc, RC_OK, RC_ERROR); ++ } ++ rc = SourceNode::Stop(streamId); + } +- +- return SourceNode::Stop(streamId); ++ return rc; + } + + RetCode V4L2SourceNode::SetCallback() +@@ -170,6 +247,36 @@ void V4L2SourceNode::SetBufferCallback() + return; + } + ++void V4L2SourceNode::SetPhotoBufferCallback() ++{ ++ CAMERA_LOGI("V4L2SourceNode::SetPhotoBufferCallback enter."); ++ sensorController_->SetPhotoNodeCallBack([&](std::shared_ptr frameSpec) { ++ OnPhotoPackBuffer(frameSpec); ++ }); ++ CAMERA_LOGI("V4L2SourceNode::SetPhotoBufferCallback end."); ++ return; ++} ++ ++RetCode V4L2SourceNode::CreateBuffers() ++{ ++ CAMERA_LOGI("V4L2SourceNode CreateBuffers enter."); ++ if (sensorController_->CreateBuffers() == RC_OK) { ++ CAMERA_LOGI("CreateBuffers success "); ++ return RC_OK; ++ } ++ return RC_ERROR; ++} ++ ++RetCode V4L2SourceNode::DestoryBuffers() ++{ ++ CAMERA_LOGI("V4L2SourceNode DestoryBuffers enter."); ++ if (sensorController_->DestoryBuffers() == RC_OK) { ++ CAMERA_LOGI("DestoryBuffers success "); ++ return RC_OK; ++ } ++ return RC_ERROR; ++} ++ + RetCode V4L2SourceNode::ProvideBuffers(std::shared_ptr frameSpec) + { + CAMERA_LOGI("provide buffers enter."); +@@ -180,6 +287,16 @@ RetCode V4L2SourceNode::ProvideBuffers(std::shared_ptr frameSpec) + return RC_ERROR; + } + ++RetCode V4L2SourceNode::ProvidePhotoBuffers(std::shared_ptr frameSpec) ++{ ++ CAMERA_LOGI("provide ProvidePhotoBuffers enter."); ++ if (sensorController_->SendPhotoFrameBuffer(frameSpec) == RC_OK) { ++ CAMERA_LOGI("SendPhotoFrameBuffer success bufferpool id = %llu", frameSpec->bufferPoolId_); ++ return RC_OK; ++ } ++ return RC_ERROR; ++} ++ + void V4L2SourceNode::GetUpdateFps(const std::shared_ptr& metadata) + { + common_metadata_header_t *data = metadata->get(); +diff --git a/camera/vdi_base/common/adapter/platform/v4l2/src/pipeline_core/nodes/v4l2_source_node/v4l2_source_node.h b/camera/vdi_base/common/adapter/platform/v4l2/src/pipeline_core/nodes/v4l2_source_node/v4l2_source_node.h +index ca7918278..a1ad24d57 100644 +--- a/camera/vdi_base/common/adapter/platform/v4l2/src/pipeline_core/nodes/v4l2_source_node/v4l2_source_node.h ++++ b/camera/vdi_base/common/adapter/platform/v4l2/src/pipeline_core/nodes/v4l2_source_node/v4l2_source_node.h +@@ -27,6 +27,7 @@ class V4L2SourceNode : public SourceNode { + public: + V4L2SourceNode(const std::string& name, const std::string& type, const std::string &cameraId); + ~V4L2SourceNode() override; ++ CameraId ConvertCameraId(const std::string &cameraId); + RetCode Init(const int32_t streamId) override; + RetCode Start(const int32_t streamId) override; + RetCode Flush(const int32_t streamId) override; +@@ -34,8 +35,12 @@ public: + RetCode GetDeviceController(); + RetCode SetCallback() override; + void SetBufferCallback() override; ++ void SetPhotoBufferCallback() override; ++ RetCode CreateBuffers() override; ++ RetCode DestoryBuffers() override; + void DeliverBuffer(std::shared_ptr& buffer) override; + RetCode ProvideBuffers(std::shared_ptr frameSpec) override; ++ RetCode ProvidePhotoBuffers(std::shared_ptr frameSpec) override; + private: + void OnMetadataChanged(const std::shared_ptr& metadata); + int32_t GetStreamId(const CaptureMeta &meta); +diff --git a/camera/vdi_base/common/device_manager/BUILD.gn b/camera/vdi_base/common/device_manager/BUILD.gn +index 65a39705d..77cdb7b20 100644 +--- a/camera/vdi_base/common/device_manager/BUILD.gn ++++ b/camera/vdi_base/common/device_manager/BUILD.gn +@@ -66,7 +66,7 @@ ohos_shared_library("peripheral_camera_device_manager") { + include_dirs = [ + "$camera_path/utils/event", + "$camera_path/adapter/platform/v4l2/src/device_manager/include", +- "$camera_path/adapter/platform/v4l2/src/driver_adapter/include/", ++ "//device/board/${product_company}/${product_name}/camera/vdi_impl/v4l2/driver_adapter/include", + ] + + deps = [ "$camera_path/adapter/platform/v4l2/src/driver_adapter:peripheral_camera_v4l2_adapter" ] +diff --git a/camera/vdi_base/common/pipeline_core/BUILD.gn b/camera/vdi_base/common/pipeline_core/BUILD.gn +index dce841e59..e8c1da006 100644 +--- a/camera/vdi_base/common/pipeline_core/BUILD.gn ++++ b/camera/vdi_base/common/pipeline_core/BUILD.gn +@@ -140,7 +140,7 @@ ohos_shared_library("peripheral_camera_pipeline_core") { + "$camera_path/adapter/platform/v4l2/src/device_manager/include", + "$camera_path/adapter/platform/v4l2/src/pipeline_core/nodes/v4l2_source_node", + "$camera_path/adapter/platform/v4l2/src/pipeline_core/nodes/uvc_node", +- "$camera_path/adapter/platform/v4l2/src/driver_adapter/include/", ++ "//device/board/${product_company}/${product_name}/camera/vdi_impl/v4l2/driver_adapter/include", + "$camera_path/dump/include", + "$camera_path/../interfaces", + ] +diff --git a/camera/vdi_base/common/pipeline_core/host_stream/src/host_stream_mgr_impl.cpp b/camera/vdi_base/common/pipeline_core/host_stream/src/host_stream_mgr_impl.cpp +index 81c747260..c7b60262d 100644 +--- a/camera/vdi_base/common/pipeline_core/host_stream/src/host_stream_mgr_impl.cpp ++++ b/camera/vdi_base/common/pipeline_core/host_stream/src/host_stream_mgr_impl.cpp +@@ -37,7 +37,7 @@ RetCode HostStreamMgrImpl::CreateHostStream(const HostStreamInfo& info, BufferCb + }); + if (it != streams_.end()) { + CAMERA_LOGE("host stream %{public}d exists.", info.streamId_); +- return RC_OK; ++ DestroyHostStream({info.streamId_}); + } + CAMERA_LOGI("bufferpool id = %{public}llu , stream id = %{public}d,stream type = %{public}d, encode = %{public}d", + info.bufferPoolId_, info.streamId_, info.type_, info.encodeType_); +diff --git a/camera/vdi_base/common/pipeline_core/ipp/include/ipp_node.h b/camera/vdi_base/common/pipeline_core/ipp/include/ipp_node.h +index ca6037dd0..d4d5ff434 100644 +--- a/camera/vdi_base/common/pipeline_core/ipp/include/ipp_node.h ++++ b/camera/vdi_base/common/pipeline_core/ipp/include/ipp_node.h +@@ -27,6 +27,7 @@ class IppNode : public NodeBase, public OfflinePipeline { + public: + IppNode(const std::string& name, const std::string& type, const std::string &cameraId); + ~IppNode(); ++ CameraId ConvertCameraId(const std::string &cameraId); + RetCode Init(const int32_t streamId) override; + RetCode Start(const int32_t streamId) override; + RetCode Stop(const int32_t streamId) override; +diff --git a/camera/vdi_base/common/pipeline_core/ipp/src/ipp_algo_parser.cpp b/camera/vdi_base/common/pipeline_core/ipp/src/ipp_algo_parser.cpp +index 3d43951a3..c276a2bc6 100644 +--- a/camera/vdi_base/common/pipeline_core/ipp/src/ipp_algo_parser.cpp ++++ b/camera/vdi_base/common/pipeline_core/ipp/src/ipp_algo_parser.cpp +@@ -125,7 +125,7 @@ std::shared_ptr IppAlgoParser::ConstructPlugin(const DeviceResourceN + + std::string nodeName = std::string(path); + if (path[0] != '/') { +- nodeName = nodeName.insert(0, HDF_LIBRARY_DIR "/"); ++ nodeName = nodeName.insert(0, "/vendor/lib64" "/"); + } + std::shared_ptr plugin = std::make_shared(name, description, algoModeMap_[mode], nodeName); + if (plugin == nullptr) { +diff --git a/camera/vdi_base/common/pipeline_core/ipp/src/ipp_node.cpp b/camera/vdi_base/common/pipeline_core/ipp/src/ipp_node.cpp +index 8956c993b..79f4b78f8 100644 +--- a/camera/vdi_base/common/pipeline_core/ipp/src/ipp_node.cpp ++++ b/camera/vdi_base/common/pipeline_core/ipp/src/ipp_node.cpp +@@ -191,6 +191,30 @@ void IppNode::PrintExposureState(const common_metadata_header_t *data) + CAMERA_LOGI("exposureState =%{public}d", exposureState); + } + ++struct IPPMetadataTag { ++ std::string cameraId1 = "lcam001"; ++ CameraId cameraId2 = CAMERA_FIRST; ++}; ++ ++const IPPMetadataTag g_ippMapCameraId[] = { ++ { "lcam001", CAMERA_FIRST }, ++ { "lcam002", CAMERA_SECOND }, ++ { "lcam003", CAMERA_THIRD }, ++ { "lcam004", CAMERA_FOURTH }, ++ { "lcam005", CAMERA_FIFTH }, ++ { "lcam006", CAMERA_SIXTH } ++}; ++ ++CameraId IppNode::ConvertCameraId(const std::string &cameraId) ++{ ++ for (auto cameraID : g_ippMapCameraId) { ++ if (cameraID.cameraId1 == cameraId) { ++ return cameraID.cameraId2; ++ } ++ } ++ return CAMERA_FIRST; ++} ++ + RetCode IppNode::GetDeviceController() + { + deviceManager_ = IDeviceManager::GetInstance(); +@@ -198,7 +222,7 @@ RetCode IppNode::GetDeviceController() + CAMERA_LOGE("get device manager failed."); + return RC_ERROR; + } +- CameraId cameraId = CAMERA_FIRST; ++ CameraId cameraId = ConvertCameraId(cameraId_); + sensorController_ = std::static_pointer_cast + (deviceManager_->GetController(cameraId, DM_M_SENSOR, DM_C_SENSOR)); + if (sensorController_ == nullptr) { +diff --git a/camera/vdi_base/common/pipeline_core/nodes/include/inode.h b/camera/vdi_base/common/pipeline_core/nodes/include/inode.h +index 51e42a823..0c6f2bb5e 100644 +--- a/camera/vdi_base/common/pipeline_core/nodes/include/inode.h ++++ b/camera/vdi_base/common/pipeline_core/nodes/include/inode.h +@@ -73,6 +73,8 @@ public: + virtual RetCode ProvideBuffers(std::shared_ptr frameSpec) = 0; + virtual void DeliverBuffers(std::shared_ptr frameSpec) = 0; + virtual void DeliverBuffers(std::vector> mergeVec) = 0; ++ virtual RetCode CreateBuffers() = 0; ++ virtual RetCode DestoryBuffers() = 0; + + public: + int32_t wide_; +diff --git a/camera/vdi_base/common/pipeline_core/nodes/src/node_base/node_base.cpp b/camera/vdi_base/common/pipeline_core/nodes/src/node_base/node_base.cpp +index fa004f99a..1a8f63613 100644 +--- a/camera/vdi_base/common/pipeline_core/nodes/src/node_base/node_base.cpp ++++ b/camera/vdi_base/common/pipeline_core/nodes/src/node_base/node_base.cpp +@@ -240,7 +240,9 @@ void NodeBase::DeliverBuffer(std::shared_ptr& buffer) + streamId = %{public}d, index = %{public}d", + GetName().c_str(), (*it)->Peer()->GetNode()->GetName().c_str(), buffer->GetStreamId(), buffer->GetIndex()); + (*it)->DeliverBuffer(buffer); ++ return; + } ++ return; + } + + void NodeBase::DeliverBuffers(std::vector>& buffers) +@@ -275,4 +277,14 @@ void NodeBase::DeliverBuffers(std::vector> mergeVec) + (void)mergeVec; + return; + } ++ ++RetCode NodeBase::CreateBuffers() ++{ ++ return RC_OK; ++} ++ ++RetCode NodeBase::DestoryBuffers() ++{ ++ return RC_OK; ++} + } // namespace OHOS::Camera +\ No newline at end of file +diff --git a/camera/vdi_base/common/pipeline_core/nodes/src/node_base/node_base.h b/camera/vdi_base/common/pipeline_core/nodes/src/node_base/node_base.h +index 3ab575ab4..85fc7c514 100644 +--- a/camera/vdi_base/common/pipeline_core/nodes/src/node_base/node_base.h ++++ b/camera/vdi_base/common/pipeline_core/nodes/src/node_base/node_base.h +@@ -84,6 +84,8 @@ public: + virtual RetCode ProvideBuffers(std::shared_ptr frameSpec); + void DeliverBuffers(std::shared_ptr frameSpec) override; + void DeliverBuffers(std::vector> mergeVec) override; ++ RetCode CreateBuffers() override; ++ RetCode DestoryBuffers() override; + + protected: + std::string name_; +diff --git a/camera/vdi_base/common/pipeline_core/nodes/src/source_node/source_node.cpp b/camera/vdi_base/common/pipeline_core/nodes/src/source_node/source_node.cpp +index 0e1f26760..f0a564f9f 100644 +--- a/camera/vdi_base/common/pipeline_core/nodes/src/source_node/source_node.cpp ++++ b/camera/vdi_base/common/pipeline_core/nodes/src/source_node/source_node.cpp +@@ -26,6 +26,7 @@ SourceNode::SourceNode(const std::string& name, const std::string& type, const s + + SourceNode::~SourceNode() + { ++ sourceStop_ = true; + CAMERA_LOGV("%{public}s, source node dtor.", __FUNCTION__); + } + +@@ -63,11 +64,12 @@ RetCode SourceNode::Start(const int32_t streamId) + SetBufferCallback(); + std::shared_ptr ph = std::make_shared(port, isAdjust_); + CHECK_IF_PTR_NULL_RETURN_VALUE(ph, RC_ERROR); +- ph->setWideAndHigh(wide_, high_); ++ // ph->setWideAndHigh(wide_, high_); + { + std::lock_guard l(hndl_); + handler_[streamId] = ph; + } ++ sourceStop_ = false; + RetCode rc = handler_[streamId]->StartCollectBuffers(); + CHECK_IF_NOT_EQUAL_RETURN_VALUE(rc, RC_OK, RC_ERROR); + +@@ -77,17 +79,93 @@ RetCode SourceNode::Start(const int32_t streamId) + return RC_OK; + } + ++RetCode SourceNode::StartWithDoubleStream(const int32_t streamId) ++{ ++ std::shared_ptr port = nullptr; ++ auto outPorts = GetOutPorts(); ++ for (auto& p : outPorts) { ++ PortFormat format = {}; ++ p->GetFormat(format); ++ if (streamId == format.streamId_) { ++ port = p; ++ break; ++ } else { ++ ++ } ++ } ++ if (port == nullptr) { ++ return RC_ERROR; ++ } ++ ++ { ++ std::lock_guard l(hndl_); ++ if (handler_.count(streamId) > 0) { ++ CAMERA_LOGI("stream [%{public}d] StartWithDoubleStream again, skip", streamId); ++ return RC_OK; ++ } ++ } ++ ++ SetBufferCallback(); ++ std::shared_ptr ph = std::make_shared(port, isAdjust_); ++ CHECK_IF_PTR_NULL_RETURN_VALUE(ph, RC_ERROR); ++ { ++ std::lock_guard l(hndl_); ++ handler_[streamId] = ph; ++ } ++ sourceStop_ = false; ++ RetCode rc = handler_[streamId]->StartCollectBuffers(); ++ CHECK_IF_NOT_EQUAL_RETURN_VALUE(rc, RC_OK, RC_ERROR); ++ rc = handler_[streamId]->StartDistributeBuffers(); ++ CHECK_IF_NOT_EQUAL_RETURN_VALUE(rc, RC_OK, RC_ERROR); ++ std::shared_ptr port1 = nullptr; ++ for (auto& p : outPorts) { ++ port1 = p; ++ if (port1 == nullptr) { ++ return RC_ERROR; ++ } ++ PortFormat format = {}; ++ p->GetFormat(format); ++ if (streamId != format.streamId_) { ++ int photoStreamId = format.streamId_; ++ { ++ std::lock_guard l(hndl_); ++ if (handler_.count(photoStreamId) > 0) { ++ return RC_OK; ++ } ++ } ++ ++ SetPhotoBufferCallback(); ++ std::shared_ptr ph1 = std::make_shared(port1, isAdjust_); ++ CHECK_IF_PTR_NULL_RETURN_VALUE(ph1, RC_ERROR); ++ { ++ std::lock_guard l(hndl_); ++ handler_[photoStreamId] = ph1; ++ } ++ break; ++ } ++ } ++ ++ return RC_OK; ++} ++ + RetCode SourceNode::Flush(const int32_t streamId) + { +- CHECK_IF_NOT_EQUAL_RETURN_VALUE(handler_.count(streamId) > 0, true, RC_ERROR); +- handler_[streamId]->StopCollectBuffers(); ++ if (streamId == streamId_) { ++ CHECK_IF_NOT_EQUAL_RETURN_VALUE(handler_.count(streamId) > 0, true, RC_ERROR); ++ handler_[streamId]->StopCollectBuffers(); ++ } else { ++ handler_[streamId]->StopPhotoBuffers(streamId); ++ } + return RC_OK; + } + + RetCode SourceNode::Stop(const int32_t streamId) + { + CHECK_IF_NOT_EQUAL_RETURN_VALUE(handler_.count(streamId) > 0, true, RC_ERROR); +- handler_[streamId]->StopDistributeBuffers(); ++ if (streamId == streamId_) { ++ sourceStop_ = true; ++ handler_[streamId]->StopDistributeBuffers(); ++ } + + { + std::lock_guard l(hndl_); +@@ -141,27 +219,103 @@ void SourceNode::OnPackBuffer(std::shared_ptr frameSpec) + return; + } + ++void SourceNode::OnPhotoPackBuffer(std::shared_ptr frameSpec) ++{ ++ CAMERA_LOGI("SourceNode::OnPhotoPackBuffer enter"); ++ ++ CHECK_IF_PTR_NULL_RETURN_VOID(frameSpec); ++ auto buffer = frameSpec->buffer_; ++ CHECK_IF_PTR_NULL_RETURN_VOID(buffer); ++ handler_[buffer->GetStreamId()]->OnPhoteBuffer(buffer); ++ ++ CAMERA_LOGI("SourceNode::OnPhotoPackBuffer exit"); ++ return; ++} ++ + void SourceNode::SetBufferCallback() + { + return; + } + ++void SourceNode::SetPhotoBufferCallback() ++{ ++ return; ++} ++ + RetCode SourceNode::ProvideBuffers(std::shared_ptr frameSpec) + { + (void)frameSpec; + return RC_OK; + } + ++RetCode SourceNode::ProvidePhotoBuffers(std::shared_ptr frameSpec) ++{ ++ (void)frameSpec; ++ return RC_OK; ++} ++ + RetCode SourceNode::Capture(const int32_t streamId, const int32_t captureId) + { +- std::lock_guard l(requestLock_); +- if (captureRequests_.count(streamId) == 0) { +- captureRequests_[streamId] = {captureId}; +- } else { +- captureRequests_[streamId].emplace_back(captureId); ++ { ++ std::lock_guard l(requestLock_); ++ if (sourceStop_) { ++ if (streamId != streamId_) { ++ CAMERA_LOGV("SourceNode::Capture bypass v4l2source stop"); ++ return RC_OK; ++ } ++ } ++ if (captureRequests_.count(streamId) == 0) { ++ captureRequests_[streamId] = {captureId}; ++ } else { ++ captureRequests_[streamId].emplace_back(captureId); ++ } ++ CAMERA_LOGV("received a request from stream [id:%{public}d], queue size:%{public}u", ++ streamId, captureRequests_[streamId].size()); ++ } ++ if (streamId != streamId_) { ++ CAMERA_LOGV("SourceNode::Capture"); ++ PortFormat format = {}; ++ auto outPorts = GetOutPorts(); ++ for (const auto& it : outPorts) { ++ if (streamId == it->format_.streamId_) { ++ it->GetFormat(format); ++ break; ++ } ++ } ++ if (format.bufferPoolId_ > 0) { ++ BufferManager* bufferManager = Camera::BufferManager::GetInstance(); ++ if (bufferManager == nullptr) { ++ CAMERA_LOGE("photo buffer get bufferManager instance failed"); ++ return RC_ERROR; ++ } ++ ++ std::shared_ptr bufferPool = bufferManager->GetBufferPool(format.bufferPoolId_); ++ if (bufferPool == nullptr) { ++ CAMERA_LOGE("get photo bufferpool failed: %{public}zu", format.bufferPoolId_); ++ return RC_ERROR; ++ } ++ bufferPool->NotifyStart(); ++ std::shared_ptr buffer = bufferPool->AcquireBuffer(-1); ++ if (buffer == nullptr) { ++ CAMERA_LOGE("get photo buffer failed."); ++ return RC_ERROR; ++ } ++ ++ std::shared_ptr frameSpec = std::make_shared(); ++ frameSpec->bufferPoolId_ = format.bufferPoolId_; ++ frameSpec->bufferCount_ = format.bufferCount_; ++ frameSpec->buffer_ = buffer; ++ ++ RetCode rc = ProvidePhotoBuffers(frameSpec); ++ if (rc == RC_ERROR) { ++ CAMERA_LOGE("provide photo buffer failed."); ++ } ++ bufferPool->NotifyStop(); ++ } else { ++ CAMERA_LOGE("get photo bufferpoolId failed."); ++ return RC_ERROR; ++ } + } +- CAMERA_LOGV("received a request from stream [id:%{public}d], queue size:%{public}u", +- streamId, captureRequests_[streamId].size()); + return RC_OK; + } + +@@ -187,7 +341,6 @@ RetCode SourceNode::PortHandler::StartCollectBuffers() + CHECK_IF_PTR_NULL_RETURN_VALUE(port, RC_ERROR); + PortFormat format = {}; + port->GetFormat(format); +- uint32_t streamId = format.streamId_; + + pool = BufferManager::GetInstance()->GetBufferPool(format.bufferPoolId_); + CHECK_IF_PTR_NULL_RETURN_VALUE(pool, RC_ERROR); +@@ -199,23 +352,38 @@ RetCode SourceNode::PortHandler::StartCollectBuffers() + cltRun = true; + } + +- collector = std::make_unique([this, &streamId] { +- std::string name = "collect#" + std::to_string(streamId); +- prctl(PR_SET_NAME, name.c_str()); +- CAMERA_LOGI("StartCollectBuffers thread start, name = %{public}s", name.c_str()); +- while (true) { +- { +- std::unique_lock l(cltLock); +- if (cltRun == false) { +- CAMERA_LOGD("collect buffer thread break"); +- break; +- } ++ if (format.streamType_ == 0) { ++ auto node = port->GetNode(); ++ if (node != nullptr) { ++ if (node->CreateBuffers() == RC_OK) { ++ collector = std::make_unique([&] { ++ PortFormat format1 = {}; ++ port->GetFormat(format1); ++ uint32_t streamId1 = format1.streamId_; ++ std::string name = "collect#" + std::to_string(streamId1); ++ prctl(PR_SET_NAME, name.c_str()); ++ while (true) { ++ { ++ std::unique_lock l(cltLock); ++ if (cltRun == false) { ++ CAMERA_LOGD("collect buffer thread break"); ++ break; ++ } ++ } ++ CollectBuffers(); ++ } ++ }); ++ } else { ++ CAMERA_LOGI("SourceNode::PortHandler::StartCollectBuffers format.streamType_=%{public}d node null", format.streamType_); ++ return RC_ERROR; + } +- CollectBuffers(); ++ } else { ++ CAMERA_LOGI("SourceNode::PortHandler::StartCollectBuffers format.streamType_=%{public}d node null", format.streamType_); ++ return RC_ERROR; + } +- CAMERA_LOGI("StartCollectBuffers thread end, name = %{public}s", name.c_str()); +- }); +- ++ } else { ++ CAMERA_LOGI("SourceNode::PortHandler::StartCollectBuffers format.streamType_=%{public}d", format.streamType_); ++ } + return RC_OK; + } + +@@ -236,6 +404,48 @@ RetCode SourceNode::PortHandler::CollectorJoin() + return RC_OK; + } + ++RetCode SourceNode::PortHandler::StopPhotoBuffers(const int32_t streamId) ++{ ++ CAMERA_LOGV("SourceNode::PortHandler::StopPhotoBuffers enter streamId=%{public}d", streamId); ++ PortFormat format = {}; ++ if ((port != nullptr) && (streamId == port->format_.streamId_)) { ++ port->GetFormat(format); ++ } else { ++ CAMERA_LOGV("SourceNode::PortHandler::StopPhotoBuffers fail,streamId=%{public}d", streamId); ++ return RC_ERROR; ++ } ++ if (format.bufferPoolId_ > 0) { ++ BufferManager* bufferManager = Camera::BufferManager::GetInstance(); ++ if (bufferManager == nullptr) { ++ CAMERA_LOGE("photo buffer get bufferManager instance failed"); ++ return RC_ERROR; ++ } ++ ++ std::shared_ptr bufferPool = bufferManager->GetBufferPool(format.bufferPoolId_); ++ if (bufferPool == nullptr) { ++ CAMERA_LOGE("get photo bufferpool failed: %{public}zu", format.bufferPoolId_); ++ return RC_ERROR; ++ } ++ bufferPool->NotifyStop(); ++ // if (port) { ++ // auto node = port->GetNode(); ++ // if (node != nullptr) { ++ // uint32_t n = pool->GetIdleBufferCount(); ++ // for (uint32_t i = 0; i < n; i++) { ++ // auto buffer = pool->AcquireBuffer(-1); ++ // node->DeliverBuffer(buffer); ++ // } ++ // } ++ // } ++ } else { ++ CAMERA_LOGE("get photo bufferpoolId failed."); ++ return RC_ERROR; ++ } ++ ++ CAMERA_LOGI("SourceNode::PortHandler::StopPhotoBuffers exit"); ++ return RC_OK; ++} ++ + RetCode SourceNode::PortHandler::StopCollectBuffers() + { + RetCode rc = CollectorJoin(); +@@ -247,6 +457,11 @@ RetCode SourceNode::PortHandler::StopCollectBuffers() + for (uint32_t i = 0; i < n; i++) { + auto buffer = pool->AcquireBuffer(-1); + node->DeliverBuffer(buffer); ++ } ++ PortFormat format = {}; ++ port->GetFormat(format); ++ if (format.streamType_ == 0) { ++ node->DestoryBuffers(); + } + } + CAMERA_LOGI("SourceNode::PortHandler::StopCollectBuffers exit"); +@@ -255,7 +470,7 @@ RetCode SourceNode::PortHandler::StopCollectBuffers() + + void SourceNode::PortHandler::CollectBuffers() + { +- CAMERA_LOGV("SourceNode::PortHandler::CollectBuffers"); ++ CAMERA_LOGE("mazhw-mem3 SourceNode::PortHandler::CollectBuffers"); + CHECK_IF_PTR_NULL_RETURN_VOID(pool); + std::shared_ptr buffer = pool->AcquireBuffer(-1); + CHECK_IF_PTR_NULL_RETURN_VOID(buffer); +@@ -265,21 +480,21 @@ void SourceNode::PortHandler::CollectBuffers() + std::shared_ptr frameSpec = std::make_shared(); + frameSpec->bufferPoolId_ = format.bufferPoolId_; + frameSpec->bufferCount_ = format.bufferCount_; +- constexpr uint32_t NewBufferBytePrePiex = 4; +- uint32_t bufferSize = maxWide_ * maxHigh_ * NewBufferBytePrePiex; +- CAMERA_LOGI("streamId[%{public}d], bufferIndex[%{public}d], Size %{public}d => %{public}d", +- buffer->GetStreamId(), buffer->GetIndex(), buffer->GetSize(), bufferSize); +- +- if (buffer->GetVirAddress() == buffer->GetSuffaceBufferAddr()) { +- CAMERA_LOGI("CollectBuffers begin malloc buffer"); +- auto bufferAddr = malloc(bufferSize); +- if (bufferAddr != nullptr) { +- buffer->SetVirAddress(bufferAddr); +- buffer->SetSize(bufferSize); +- } else { +- CAMERA_LOGE("CollectBuffers malloc buffer fail"); +- } +- } ++ // constexpr uint32_t NewBufferBytePrePiex = 4; ++ // uint32_t bufferSize = maxWide_ * maxHigh_ * NewBufferBytePrePiex; ++ // CAMERA_LOGI("streamId[%{public}d], bufferIndex[%{public}d], Size %{public}d => %{public}d", ++ // buffer->GetStreamId(), buffer->GetIndex(), buffer->GetSize(), bufferSize); ++ ++ // if (buffer->GetVirAddress() == buffer->GetSuffaceBufferAddr()) { ++ // CAMERA_LOGI("CollectBuffers begin malloc buffer"); ++ // auto bufferAddr = malloc(bufferSize); ++ // if (bufferAddr != nullptr) { ++ // buffer->SetVirAddress(bufferAddr); ++ // buffer->SetSize(bufferSize); ++ // } else { ++ // CAMERA_LOGE("CollectBuffers malloc buffer fail"); ++ // } ++ // } + frameSpec->buffer_ = buffer; + auto node = port->GetNode(); + CHECK_IF_PTR_NULL_RETURN_VOID(node); +@@ -356,7 +571,7 @@ void SourceNode::PortHandler::DistributeBuffers() + std::shared_ptr buffer = nullptr; + { + std::unique_lock l(rblock); +- auto timeout = std::chrono::system_clock::now() + std::chrono::milliseconds(500); // 500ms ++ auto timeout = std::chrono::system_clock::now() + std::chrono::milliseconds(5000); // 5000ms + if (!rbcv.wait_until(l, timeout, [this] { + return (!dbtRun || !respondBufferList.empty()); + })) { +@@ -394,6 +609,17 @@ void SourceNode::PortHandler::OnBuffer(std::shared_ptr& buffer) + return; + } + ++void SourceNode::PortHandler::OnPhoteBuffer(std::shared_ptr& buffer) ++{ ++ CAMERA_LOGV("SourceNode::PortHandler::OnPhoteBuffer enter"); ++ auto node = port->GetNode(); ++ CHECK_IF_PTR_NULL_RETURN_VOID(node); ++ node->DeliverBuffer(buffer); ++ CAMERA_LOGV("SourceNode::PortHandler::OnPhoteBuffer exit"); ++ ++ return; ++} ++ + void SourceNode::PortHandler::FlushBuffers() + { + CAMERA_LOGV("SourceNode::PortHandler::FlushBuffers enter"); +diff --git a/camera/vdi_base/common/pipeline_core/nodes/src/source_node/source_node.h b/camera/vdi_base/common/pipeline_core/nodes/src/source_node/source_node.h +index a332298b9..cea018895 100644 +--- a/camera/vdi_base/common/pipeline_core/nodes/src/source_node/source_node.h ++++ b/camera/vdi_base/common/pipeline_core/nodes/src/source_node/source_node.h +@@ -26,6 +26,7 @@ public: + ~SourceNode() override; + RetCode Init(const int32_t streamId) override; + RetCode Start(const int32_t streamId) override; ++ RetCode StartWithDoubleStream(const int32_t streamId); + RetCode Flush(const int32_t streamId) override; + RetCode Stop(const int32_t streamId) override; + RetCode Capture(const int32_t streamId, const int32_t captureId) override; +@@ -35,7 +36,10 @@ public: + RetCode ProvideBuffers(std::shared_ptr frameSpec) override; + + virtual void OnPackBuffer(std::shared_ptr frameSpec); ++ virtual void OnPhotoPackBuffer(std::shared_ptr frameSpec); + virtual void SetBufferCallback(); ++ virtual void SetPhotoBufferCallback(); ++ virtual RetCode ProvidePhotoBuffers(std::shared_ptr frameSpec); + + protected: + class PortHandler { +@@ -45,11 +49,14 @@ protected: + explicit PortHandler(std::shared_ptr& p, bool isResize); + RetCode StartCollectBuffers(); + RetCode StopCollectBuffers(); ++ RetCode StartPhotoBuffers(const int32_t streamId); ++ RetCode StopPhotoBuffers(const int32_t streamId); + RetCode StartDistributeBuffers(); + RetCode StopDistributeBuffers(); + RetCode CollectorJoin(); + RetCode DistributorJoin(); + void OnBuffer(std::shared_ptr& buffer); ++ void OnPhoteBuffer(std::shared_ptr& buffer); + void setWideAndHigh(int32_t wide, int32_t high); + + private: +@@ -86,6 +93,8 @@ protected: + std::unordered_map> captureRequests_ = {}; + std::string cameraIds_; + bool isAdjust_ = false; ++ int32_t streamId_; ++ std::atomic sourceStop_ = true; + }; + } // namespace OHOS::Camera + #endif +diff --git a/camera/vdi_base/common/pipeline_core/pipeline_impl/include/istream_pipeline_core.h b/camera/vdi_base/common/pipeline_core/pipeline_impl/include/istream_pipeline_core.h +index adde23690..f690b02b5 100644 +--- a/camera/vdi_base/common/pipeline_core/pipeline_impl/include/istream_pipeline_core.h ++++ b/camera/vdi_base/common/pipeline_core/pipeline_impl/include/istream_pipeline_core.h +@@ -21,6 +21,7 @@ + #include "offline_pipeline.h" + #include "camera_metadata_info.h" + #include "stream.h" ++#include "stream_pipeline_strategy.h" + + namespace OHOS::Camera { + +@@ -48,6 +49,7 @@ public: + virtual VdiOperationMode GetCurrentMode() const = 0; + virtual DynamicStreamSwitchMode CheckStreamsSupported(VdiOperationMode mode, + const ModeMeta& meta, const std::vector& configs) = 0; ++ virtual std::shared_ptr GetCurrentStrategy() const = 0; + }; + } + #endif +diff --git a/camera/vdi_base/common/pipeline_core/pipeline_impl/include/stream_pipeline_data_structure.h b/camera/vdi_base/common/pipeline_core/pipeline_impl/include/stream_pipeline_data_structure.h +index 45e300e5c..735efec5c 100644 +--- a/camera/vdi_base/common/pipeline_core/pipeline_impl/include/stream_pipeline_data_structure.h ++++ b/camera/vdi_base/common/pipeline_core/pipeline_impl/include/stream_pipeline_data_structure.h +@@ -36,6 +36,7 @@ using PortFormat = struct { + int32_t h_; + uint32_t streamId_; + int32_t format_; ++ int32_t streamType_; + uint64_t usage_; + uint8_t needAllocation_; + uint32_t bufferCount_; +@@ -57,6 +58,15 @@ struct NodeSpec { + bool operator==(const NodeSpec& n) + { + if (this->portSpecSet_.size() == n.portSpecSet_.size()) { ++ for (const auto& it : this->portSpecSet_) { ++ auto port = std::find_if(n.portSpecSet_.begin(), n.portSpecSet_.end(), ++ [it](const PortSpec& m) { ++ return m.info_.peerPortNodeName_ == it.info_.peerPortNodeName_; ++ }); ++ if (port == n.portSpecSet_.end()) { ++ return false; ++ } ++ } + return true; + } else { + return false; +@@ -67,6 +77,15 @@ struct NodeSpec { + if (this->portSpecSet_.size() != n.portSpecSet_.size()) { + return true; + } else { ++ for (const auto& it : this->portSpecSet_) { ++ auto port = std::find_if(n.portSpecSet_.begin(), n.portSpecSet_.end(), ++ [it](const PortSpec& m) { ++ return m.info_.peerPortNodeName_ == it.info_.peerPortNodeName_; ++ }); ++ if (port == n.portSpecSet_.end()) { ++ return true; ++ } ++ } + return false; + } + } +@@ -74,6 +93,7 @@ struct NodeSpec { + + struct PipelineSpec { + std::vector nodeSpecSet_; ++ bool isDoubleStream = false; + }; + + extern "C" const struct HdfConfigRoot* HdfGetModuleConfigRoot(void); +diff --git a/camera/vdi_base/common/pipeline_core/pipeline_impl/src/builder/stream_pipeline_builder.cpp b/camera/vdi_base/common/pipeline_core/pipeline_impl/src/builder/stream_pipeline_builder.cpp +index 9e55b61a3..b549972ac 100644 +--- a/camera/vdi_base/common/pipeline_core/pipeline_impl/src/builder/stream_pipeline_builder.cpp ++++ b/camera/vdi_base/common/pipeline_core/pipeline_impl/src/builder/stream_pipeline_builder.cpp +@@ -42,6 +42,16 @@ std::shared_ptr StreamPipelineBuilder::Build(const std::shared_ptr> sizeSet; + for (auto& it : pipelineSpec->nodeSpecSet_) { ++ if (it.status_ == "update"){ ++ auto updateNode = std::find_if(pipeline_->nodes_.begin(), pipeline_->nodes_.end(), ++ [it](const std::shared_ptr& m) { ++ return it.name_ == m->GetName(); ++ }); ++ if (updateNode != pipeline_->nodes_.end()) { ++ pipeline_->nodes_.erase(updateNode); ++ } ++ it.status_ = "new"; ++ } + if (it.status_ == "new") { + std::string nodeName; + size_t pos = it.name_.find_first_of('#'); +@@ -83,7 +93,7 @@ std::shared_ptr StreamPipelineBuilder::Build(const std::shared_ptrnodeSpec[j].portSpec[k].needAllocation, +- .bufferCount_ = hostStreamInfo.bufferCount_ ++ .bufferCount_ = hostStreamInfo.bufferCount_, ++ .streamType_ = ((typeId == std::nullopt)?0:typeId.value()) + }; + (void)typeId; + CAMERA_LOGI("buffercount = %{public}d", f.bufferCount_); +@@ -232,9 +233,26 @@ RetCode StreamPipelineStrategy::CombineSpecs(PipelineSpec& pipe) + if (*node != *it) { + CAMERA_LOGI("change node:%{public}s\n", (*it).name_.c_str()); + std::swap((*node).portSpecSet_, (*it).portSpecSet_); ++ (*node).status_ = "update"; + } + } + } ++ auto node = std::find_if(pipelineSpec_->nodeSpecSet_.begin(), pipelineSpec_->nodeSpecSet_.end(), ++ [](const NodeSpec& n) { ++ return n.name_ == "v4l2_source#0"; ++ }); ++ if (node == pipelineSpec_->nodeSpecSet_.end()) { ++ CAMERA_LOGI("no node:v4l2_source#0, isDoubleStream false\n"); ++ pipelineSpec_->isDoubleStream = false; ++ } else { ++ if (node->portSpecSet_.size() == 2) { ++ CAMERA_LOGI("node:v4l2_source#0 isDoubleStream true\n"); ++ pipelineSpec_->isDoubleStream = true; ++ } else { ++ CAMERA_LOGI("node:v4l2_source#0 isDoubleStream false\n"); ++ pipelineSpec_->isDoubleStream = false; ++ } ++ } + CAMERA_LOGI("------------------------Connection Dump Begin-------------\n"); + PrintConnection(pipelineSpec_->nodeSpecSet_[0]); + CAMERA_LOGI("------------------------Connection Dump End-------------\n"); +@@ -280,4 +298,9 @@ RetCode StreamPipelineStrategy::CheckPipelineSpecExist(const int32_t mode, const + + return RC_ERROR; + } ++ ++std::shared_ptr StreamPipelineStrategy::GetCurrentPipelineSpec() const ++{ ++ return pipelineSpec_; ++} + } +diff --git a/camera/vdi_base/common/pipeline_core/pipeline_impl/src/strategy/stream_pipeline_strategy.h b/camera/vdi_base/common/pipeline_core/pipeline_impl/src/strategy/stream_pipeline_strategy.h +index 51f95e987..90904353f 100644 +--- a/camera/vdi_base/common/pipeline_core/pipeline_impl/src/strategy/stream_pipeline_strategy.h ++++ b/camera/vdi_base/common/pipeline_core/pipeline_impl/src/strategy/stream_pipeline_strategy.h +@@ -33,6 +33,7 @@ public: + PortFormat SetPortFormat(G_PIPELINE_SPEC_DATA_TYPE &pipeSpecPtr, const std::optional& typeId, + int j, int k, HostStreamInfo hostStreamInfo); + void InitPipeSpecPtr(G_PIPELINE_SPEC_DATA_TYPE &pipeSpecPtr, const std::string& keyStr); ++ std::shared_ptr GetCurrentPipelineSpec() const; + + protected: + virtual std::string ConstructKeyStrIndex(const int32_t& mode); +diff --git a/camera/vdi_base/common/pipeline_core/pipeline_impl/src/stream_pipeline_core.cpp b/camera/vdi_base/common/pipeline_core/pipeline_impl/src/stream_pipeline_core.cpp +index 5bb94a24b..4ccdde0f0 100644 +--- a/camera/vdi_base/common/pipeline_core/pipeline_impl/src/stream_pipeline_core.cpp ++++ b/camera/vdi_base/common/pipeline_core/pipeline_impl/src/stream_pipeline_core.cpp +@@ -196,6 +196,11 @@ DynamicStreamSwitchMode StreamPipelineCore::CheckStreamsSupported(VdiOperationMo + return DYNAMIC_STREAM_SWITCH_NOT_SUPPORT; + } + ++std::shared_ptr StreamPipelineCore::GetCurrentStrategy() const ++{ ++ return strategy_; ++} ++ + std::shared_ptr IStreamPipelineCore::Create(const std::shared_ptr& c) + { + return std::make_shared(c); +diff --git a/camera/vdi_base/common/pipeline_core/pipeline_impl/src/stream_pipeline_core.h b/camera/vdi_base/common/pipeline_core/pipeline_impl/src/stream_pipeline_core.h +index 504bb9c08..f60304058 100644 +--- a/camera/vdi_base/common/pipeline_core/pipeline_impl/src/stream_pipeline_core.h ++++ b/camera/vdi_base/common/pipeline_core/pipeline_impl/src/stream_pipeline_core.h +@@ -42,12 +42,13 @@ public: + VdiOperationMode GetCurrentMode() const override; + DynamicStreamSwitchMode CheckStreamsSupported(VdiOperationMode mode, + const ModeMeta& meta, const std::vector& configs) override; ++ std::shared_ptr GetCurrentStrategy() const override; + + protected: + std::recursive_mutex mutex_; + VdiOperationMode mode_ = NORMAL; + std::shared_ptr context_ = nullptr; +- std::unique_ptr strategy_ = nullptr; ++ std::shared_ptr strategy_ = nullptr; + std::unique_ptr builder_ = nullptr; + std::unique_ptr dispatcher_ = nullptr; + std::string cameraId_; +diff --git a/camera/vdi_base/usb_camera/device_manager/BUILD.gn b/camera/vdi_base/usb_camera/device_manager/BUILD.gn +index 29335df6c..29275fb51 100644 +--- a/camera/vdi_base/usb_camera/device_manager/BUILD.gn ++++ b/camera/vdi_base/usb_camera/device_manager/BUILD.gn +@@ -42,7 +42,7 @@ config("device_manager_config") { + ] + } + +-ohos_shared_library("usb_camera_device_manager") { ++ohos_shared_library("usb_camera_device_manager1") { + sources = [ + "$camera_path_usb/adapter/platform/v4l2/src/device_manager/v4l2_device_manager.cpp", + "$camera_path_vdi/adapter/platform/v4l2/src/device_manager/enumerator_manager.cpp", +diff --git a/camera/vdi_base/v4l2/include/stream_operator/capture_request.h b/camera/vdi_base/v4l2/include/stream_operator/capture_request.h +index 9f94f8390..6c5e216c2 100644 +--- a/camera/vdi_base/v4l2/include/stream_operator/capture_request.h ++++ b/camera/vdi_base/v4l2/include/stream_operator/capture_request.h +@@ -42,6 +42,7 @@ public: + uint64_t GetEndTime() const; + bool NeedShutterCallback() const; + bool IsContinous() const; ++ void SetContinous(bool isContinuous); + int32_t GetCaptureId() const; + void AttachBuffer(std::shared_ptr& b); + std::shared_ptr GetAttachedBuffer() const; +diff --git a/camera/vdi_base/v4l2/include/stream_operator/stream_still_capture.h b/camera/vdi_base/v4l2/include/stream_operator/stream_still_capture.h +index 52c76ad3c..1aae91d5d 100644 +--- a/camera/vdi_base/v4l2/include/stream_operator/stream_still_capture.h ++++ b/camera/vdi_base/v4l2/include/stream_operator/stream_still_capture.h +@@ -29,11 +29,13 @@ public: + virtual ~StreamStillCapture(); + + public: ++ uint32_t GetBufferCount() override; + void HandleResult(std::shared_ptr& buffer) override; + RetCode Capture(const std::shared_ptr& request) override; + RetCode ChangeToOfflineStream(std::shared_ptr offlineStream) override; + RetCode StopStream() override; + bool IsRunning() const override; ++ RetCode AddRequest(std::shared_ptr& request) override; + + private: + std::weak_ptr offlineStream; +diff --git a/camera/vdi_base/v4l2/src/stream_operator/capture_request.cpp b/camera/vdi_base/v4l2/src/stream_operator/capture_request.cpp +index 3cfb2017b..7f3f513c8 100644 +--- a/camera/vdi_base/v4l2/src/stream_operator/capture_request.cpp ++++ b/camera/vdi_base/v4l2/src/stream_operator/capture_request.cpp +@@ -116,6 +116,11 @@ bool CaptureRequest::IsContinous() const + return isContinuous_; + } + ++void CaptureRequest::SetContinous(bool isContinuous) ++{ ++ isContinuous_ = isContinuous; ++} ++ + int32_t CaptureRequest::GetCaptureId() const + { + return captureId_; +diff --git a/camera/vdi_base/v4l2/src/stream_operator/stream_base.cpp b/camera/vdi_base/v4l2/src/stream_operator/stream_base.cpp +index 340bd9457..399d60ee1 100644 +--- a/camera/vdi_base/v4l2/src/stream_operator/stream_base.cpp ++++ b/camera/vdi_base/v4l2/src/stream_operator/stream_base.cpp +@@ -230,6 +230,7 @@ RetCode StreamBase::AddRequest(std::shared_ptr& request) + CHECK_IF_PTR_NULL_RETURN_VALUE(request, RC_ERROR); + request->AddOwner(shared_from_this()); + ++ request->SetFirstRequest(false); + if (isFirstRequest) { + RetCode rc = StartStream(); + if (rc != RC_OK) { +@@ -551,12 +552,13 @@ RetCode StreamBase::ChangeToOfflineStream(std::shared_ptr offline + + uint64_t StreamBase::GetUsage() + { +- return CAMERA_USAGE_SW_WRITE_OFTEN | CAMERA_USAGE_SW_READ_OFTEN | CAMERA_USAGE_MEM_DMA; ++ // return CAMERA_USAGE_SW_WRITE_OFTEN | CAMERA_USAGE_SW_READ_OFTEN | CAMERA_USAGE_MEM_DMA; ++ return CAMERA_USAGE_SW_WRITE_OFTEN | CAMERA_USAGE_MEM_DMA;//Used to solve the problem of flashing stripes in camera preview screen + } + + uint32_t StreamBase::GetBufferCount() + { +- return 3; // 3: buffer count ++ return 8; // buffer count + } + + StreamConfiguration StreamBase::GetStreamAttribute() const +diff --git a/camera/vdi_base/v4l2/src/stream_operator/stream_operator_vdi_impl.cpp b/camera/vdi_base/v4l2/src/stream_operator/stream_operator_vdi_impl.cpp +index 263ea5c34..ae35b4d08 100644 +--- a/camera/vdi_base/v4l2/src/stream_operator/stream_operator_vdi_impl.cpp ++++ b/camera/vdi_base/v4l2/src/stream_operator/stream_operator_vdi_impl.cpp +@@ -521,7 +521,8 @@ int32_t StreamOperatorVdiImpl::CancelCapture(int32_t captureId) + auto itr = requestMap_.find(captureId); + if (itr == requestMap_.end()) { + CAMERA_LOGE("can't cancel capture [id = %{public}d], this capture doesn't exist", captureId); +- return INVALID_ARGUMENT; ++ return VDI::Camera::V1_0::NO_ERROR; ++ // return INVALID_ARGUMENT; + } + + RetCode rc = itr->second->Cancel(); +@@ -687,7 +688,6 @@ void StreamOperatorVdiImpl::OnCaptureEnded(int32_t captureId, const std::vector< + CAMERA_LOGE("OnCaptureEnded captureId: %{public}d not found request", captureId); + return; + } +- requestMap_.erase(itr); + } + + void StreamOperatorVdiImpl::OnCaptureError(int32_t captureId, const std::vector &infos) +diff --git a/camera/vdi_base/v4l2/src/stream_operator/stream_still_capture.cpp b/camera/vdi_base/v4l2/src/stream_operator/stream_still_capture.cpp +index 2d3ef92be..c88cb490b 100644 +--- a/camera/vdi_base/v4l2/src/stream_operator/stream_still_capture.cpp ++++ b/camera/vdi_base/v4l2/src/stream_operator/stream_still_capture.cpp +@@ -31,6 +31,11 @@ StreamStillCapture::~StreamStillCapture() + CAMERA_LOGV("enter"); + } + ++uint32_t StreamStillCapture::GetBufferCount() ++{ ++ return 1; // 1: double stream buffer count ++} ++ + void StreamStillCapture::HandleResult(std::shared_ptr& buffer) + { + if (state_ == STREAM_STATE_OFFLINE) { +@@ -104,11 +109,20 @@ RetCode StreamStillCapture::StopStream() + if (state_ != STREAM_STATE_OFFLINE) { + state_ = STREAM_STATE_IDLE; + } +- ++ std::shared_ptr strategy = pipeline_->GetCurrentStrategy(); ++ if (strategy != nullptr) { ++ std::shared_ptr pipelineSpec = strategy->GetCurrentPipelineSpec(); ++ if (pipelineSpec != nullptr) { ++ if (pipelineSpec->isDoubleStream) { ++ bufferPool_->NotifyStop(); ++ } ++ } ++ } + tunnel_->NotifyStop(); + cv_.notify_one(); +- if (handler_ != nullptr) { ++ if (handler_ != nullptr && handler_->joinable()) { + handler_->join(); ++ handler_ = nullptr; + } + + if (!waitingList_.empty()) { +@@ -156,5 +170,12 @@ bool StreamStillCapture::IsRunning() const + return state_ == STREAM_STATE_BUSY || state_ == STREAM_STATE_OFFLINE; + } + ++RetCode StreamStillCapture::AddRequest(std::shared_ptr& request) ++{ ++ CHECK_IF_PTR_NULL_RETURN_VALUE(request, RC_ERROR); ++ request->SetContinous(false); ++ return StreamBase::AddRequest(request); ++} ++ + REGISTERSTREAM(StreamStillCapture, {"STILL_CAPTURE"}); + } // namespace OHOS::Camera -- Gitee