From af42550fa147761a3264bd3ac7ca5b442339210f Mon Sep 17 00:00:00 2001 From: wangchaole Date: Thu, 16 Jun 2022 15:42:45 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=84=E7=90=86reviewbot=E5=91=8A=E8=AD=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangchaole --- .../dstream_operator/dstream_operator.h | 1 + .../src/dstream_operator/dstream_operator.cpp | 17 +++++++---- .../client/include/dcamera_client.h | 1 + .../client/src/dcamera_client.cpp | 29 ++++++++++--------- .../client/src/dcamera_client_common.cpp | 27 ++++++++++------- 5 files changed, 45 insertions(+), 30 deletions(-) diff --git a/camera_hdf/hdi_impl/include/dstream_operator/dstream_operator.h b/camera_hdf/hdi_impl/include/dstream_operator/dstream_operator.h index 5a7eea2..f9b39de 100644 --- a/camera_hdf/hdi_impl/include/dstream_operator/dstream_operator.h +++ b/camera_hdf/hdi_impl/include/dstream_operator/dstream_operator.h @@ -90,6 +90,7 @@ private: void ExtractStreamInfo(DCStreamInfo &dstStreamInfo, const std::shared_ptr &srcStreamInfo); void ExtractCaptureInfo(std::vector &captureInfos); void ExtractCameraAttr(Json::Value &rootValue, std::set &allFormats, std::vector &photoFormats); + void SetSrcStreamInfo(std::vector>& srcStreamInfo); private: std::shared_ptr dMetadataProcessor_; diff --git a/camera_hdf/hdi_impl/src/dstream_operator/dstream_operator.cpp b/camera_hdf/hdi_impl/src/dstream_operator/dstream_operator.cpp index 735359e..53d30ab 100644 --- a/camera_hdf/hdi_impl/src/dstream_operator/dstream_operator.cpp +++ b/camera_hdf/hdi_impl/src/dstream_operator/dstream_operator.cpp @@ -699,12 +699,7 @@ DCamRetCode DStreamOperator::NegotiateSuitableCaptureInfo(const std::shared_ptr< bool isStreaming) { std::vector> srcStreamInfo; - for (auto &id : srcCaptureInfo->streamIds_) { - auto iter = dcStreamInfoMap_.find(id); - if (iter != dcStreamInfoMap_.end()) { - srcStreamInfo.push_back(iter->second); - } - } + SetSrcStreamInfo(srcStreamInfo); if (srcStreamInfo.empty()) { DHLOGE("Input source stream info vector is empty."); return DCamRetCode::INVALID_ARGUMENT; @@ -751,6 +746,16 @@ DCamRetCode DStreamOperator::NegotiateSuitableCaptureInfo(const std::shared_ptr< return SUCCESS; } +void DStreamOperator::SetSrcStreamInfo(std::vector>& srcStreamInfo) +{ + for (auto &id : srcCaptureInfo->streamIds_) { + auto iter = dcStreamInfoMap_.find(id); + if (iter != dcStreamInfoMap_.end()) { + srcStreamInfo.push_back(iter->second); + } + } +} + std::shared_ptr DStreamOperator::BuildSuitableCaptureInfo(const shared_ptr& srcCaptureInfo, std::vector> &srcStreamInfo) { diff --git a/services/cameraservice/cameraoperator/client/include/dcamera_client.h b/services/cameraservice/cameraoperator/client/include/dcamera_client.h index 712d754..e734217 100644 --- a/services/cameraservice/cameraoperator/client/include/dcamera_client.h +++ b/services/cameraservice/cameraoperator/client/include/dcamera_client.h @@ -57,6 +57,7 @@ private: int32_t StartVideoOutput(); void SetQualityAndGpsLocation(const std::shared_ptr& cameraMetadata, std::shared_ptr& photoCaptureSettings); + void ReleasCaptureSession(); bool isInit_; std::string cameraId_; diff --git a/services/cameraservice/cameraoperator/client/src/dcamera_client.cpp b/services/cameraservice/cameraoperator/client/src/dcamera_client.cpp index 86e22eb..c66fccb 100644 --- a/services/cameraservice/cameraoperator/client/src/dcamera_client.cpp +++ b/services/cameraservice/cameraoperator/client/src/dcamera_client.cpp @@ -163,19 +163,7 @@ int32_t DCameraClient::StopCapture() photoOutput_->Release(); photoOutput_ = nullptr; } - - if (captureSession_ != nullptr) { - DHLOGI("DCameraClient::StopCapture %s stop captureSession", GetAnonyString(cameraId_).c_str()); - int32_t ret = captureSession_->Stop(); - if (ret != DCAMERA_OK) { - DHLOGE("DCameraClient::StopCapture captureSession stop failed, cameraId: %s, ret: %d", - GetAnonyString(cameraId_).c_str(), ret); - } - DHLOGI("DCameraClient::StopCapture %s release captureSession", GetAnonyString(cameraId_).c_str()); - captureSession_->Release(); - captureSession_ = nullptr; - } - + ReleasCaptureSession(); if (cameraInput_ != nullptr) { DHLOGI("DCameraClient::StopCapture %s release cameraInput", GetAnonyString(cameraId_).c_str()); cameraInput_->Release(); @@ -210,6 +198,21 @@ int32_t DCameraClient::StopCapture() return DCAMERA_OK; } +void DCameraClient::ReleasCaptureSession() +{ + if (captureSession_ != nullptr) { + DHLOGI("DCameraClient::StopCapture %s stop captureSession", GetAnonyString(cameraId_).c_str()); + int32_t ret = captureSession_->Stop(); + if (ret != DCAMERA_OK) { + DHLOGE("DCameraClient::StopCapture captureSession stop failed, cameraId: %s, ret: %d", + GetAnonyString(cameraId_).c_str(), ret); + } + DHLOGI("DCameraClient::StopCapture %s release captureSession", GetAnonyString(cameraId_).c_str()); + captureSession_->Release(); + captureSession_ = nullptr; + } +} + int32_t DCameraClient::SetStateCallback(std::shared_ptr& callback) { DHLOGI("DCameraClient::SetStateCallback cameraId: %s", GetAnonyString(cameraId_).c_str()); diff --git a/services/cameraservice/cameraoperator/client/src/dcamera_client_common.cpp b/services/cameraservice/cameraoperator/client/src/dcamera_client_common.cpp index 72ec751..7f9b6fa 100644 --- a/services/cameraservice/cameraoperator/client/src/dcamera_client_common.cpp +++ b/services/cameraservice/cameraoperator/client/src/dcamera_client_common.cpp @@ -146,17 +146,7 @@ int32_t DCameraClient::StartCapture(std::vectorStop(); - if (ret != DCAMERA_OK) { - DHLOGE("DCameraClientCommon::StopCapture captureSession stop failed, cameraId: %s, ret: %d", - GetAnonyString(cameraId_).c_str(), ret); - } - DHLOGI("DCameraClientCommon::StopCapture %s release captureSession", GetAnonyString(cameraId_).c_str()); - captureSession_->Release(); - captureSession_ = nullptr; - } + ReleasCaptureSession(); if (cameraInput_ != nullptr) { DHLOGI("DCameraClientCommon::StopCapture %s release cameraInput", GetAnonyString(cameraId_).c_str()); @@ -194,6 +184,21 @@ int32_t DCameraClient::StopCapture() return DCAMERA_OK; } +void DCameraClient::ReleasCaptureSession() +{ + if (captureSession_ != nullptr) { + DHLOGI("DCameraClientCommon::StopCapture %s stop captureSession", GetAnonyString(cameraId_).c_str()); + int32_t ret = captureSession_->Stop(); + if (ret != DCAMERA_OK) { + DHLOGE("DCameraClientCommon::StopCapture captureSession stop failed, cameraId: %s, ret: %d", + GetAnonyString(cameraId_).c_str(), ret); + } + DHLOGI("DCameraClientCommon::StopCapture %s release captureSession", GetAnonyString(cameraId_).c_str()); + captureSession_->Release(); + captureSession_ = nullptr; + } +} + int32_t DCameraClient::SetStateCallback(std::shared_ptr& callback) { DHLOGI("DCameraClientCommon::SetStateCallback cameraId: %s", GetAnonyString(cameraId_).c_str());