From 67617a7a7dc304e935802fc696463f80c29600cf Mon Sep 17 00:00:00 2001 From: wangchaole Date: Thu, 16 Jun 2022 17:27:22 +0800 Subject: [PATCH] reviewbot Signed-off-by: wangchaole --- .../include/dstream_operator/dstream_operator.h | 2 +- .../src/dstream_operator/dstream_operator.cpp | 4 ++-- .../constants/distributed_camera_constants.h | 3 +++ .../client/src/callback/dcamera_input_callback.cpp | 7 +++++-- .../client/src/callback/dcamera_photo_callback.cpp | 2 +- .../dcamera_sink_controller.cpp | 14 +++++++++----- 6 files changed, 21 insertions(+), 11 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 f9b39de..efac168 100644 --- a/camera_hdf/hdi_impl/include/dstream_operator/dstream_operator.h +++ b/camera_hdf/hdi_impl/include/dstream_operator/dstream_operator.h @@ -90,7 +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); + void SetSrcStreamInfo(const std::shared_ptr& srcCaptureInfo, 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 53d30ab..a2fe63c 100644 --- a/camera_hdf/hdi_impl/src/dstream_operator/dstream_operator.cpp +++ b/camera_hdf/hdi_impl/src/dstream_operator/dstream_operator.cpp @@ -699,7 +699,7 @@ DCamRetCode DStreamOperator::NegotiateSuitableCaptureInfo(const std::shared_ptr< bool isStreaming) { std::vector> srcStreamInfo; - SetSrcStreamInfo(srcStreamInfo); + SetSrcStreamInfo(srcCaptureInfo, srcStreamInfo); if (srcStreamInfo.empty()) { DHLOGE("Input source stream info vector is empty."); return DCamRetCode::INVALID_ARGUMENT; @@ -746,7 +746,7 @@ DCamRetCode DStreamOperator::NegotiateSuitableCaptureInfo(const std::shared_ptr< return SUCCESS; } -void DStreamOperator::SetSrcStreamInfo(std::vector>& srcStreamInfo) +void DStreamOperator::SetSrcStreamInfo(const std::shared_ptr& srcCaptureInfo, std::vector>& srcStreamInfo) { for (auto &id : srcCaptureInfo->streamIds_) { auto iter = dcStreamInfoMap_.find(id); diff --git a/common/include/constants/distributed_camera_constants.h b/common/include/constants/distributed_camera_constants.h index eddb2f5..90d7acd 100644 --- a/common/include/constants/distributed_camera_constants.h +++ b/common/include/constants/distributed_camera_constants.h @@ -58,6 +58,9 @@ typedef enum { DCAMERA_EVENT_START_CAPTURE_ERROR = -6, DCAMERA_EVENT_STOP_CAPTURE_ERROR = -7, DCAMERA_EVENT_UPDATE_SETTINGS_ERROR = -8, + DCAMERA_EVENT_DEVICE_PREEMPT = -9, + DCAMERA_EVENT_DEVICE_IN_USE = -10, + DCAMERA_EVENT_NO_PERMISSION = -11, } DCameraEventResult; typedef enum { diff --git a/services/cameraservice/cameraoperator/client/src/callback/dcamera_input_callback.cpp b/services/cameraservice/cameraoperator/client/src/callback/dcamera_input_callback.cpp index 8d980fd..0cbf46a 100644 --- a/services/cameraservice/cameraoperator/client/src/callback/dcamera_input_callback.cpp +++ b/services/cameraservice/cameraoperator/client/src/callback/dcamera_input_callback.cpp @@ -31,10 +31,13 @@ void DCameraInputCallback::OnError(const int32_t errorType, const int32_t errorM DHLOGE("DCameraInputCallback::OnError StateCallback is null"); return; } - std::shared_ptr event = std::make_shared(); event->eventType_ = DCAMERA_MESSAGE; - event->eventResult_ = DCAMERA_EVENT_CAMERA_ERROR; + if (errorType == CamServiceError::) { + event->eventResult_ = DCAMERA_DEVICE_PREEMPT; + } else { + event->eventResult_ = DCAMERA_EVENT_CAMERA_ERROR; + } callback_->OnStateChanged(event); } } // namespace DistributedHardware diff --git a/services/cameraservice/cameraoperator/client/src/callback/dcamera_photo_callback.cpp b/services/cameraservice/cameraoperator/client/src/callback/dcamera_photo_callback.cpp index 1ad5ca5..bbadae4 100644 --- a/services/cameraservice/cameraoperator/client/src/callback/dcamera_photo_callback.cpp +++ b/services/cameraservice/cameraoperator/client/src/callback/dcamera_photo_callback.cpp @@ -49,7 +49,7 @@ void DCameraPhotoCallback::OnCaptureError(const int32_t captureId, const int32_t std::shared_ptr event = std::make_shared(); event->eventType_ = DCAMERA_MESSAGE; - event->eventResult_ = DCAMERA_EVENT_CAMERA_ERROR; + event->eventResult_ = DCAMERA_DEVICE_ERROR; callback_->OnStateChanged(event); } } // namespace DistributedHardware diff --git a/services/cameraservice/sinkservice/src/distributedcameramgr/dcamera_sink_controller.cpp b/services/cameraservice/sinkservice/src/distributedcameramgr/dcamera_sink_controller.cpp index 9501728..ecf5eb3 100644 --- a/services/cameraservice/sinkservice/src/distributedcameramgr/dcamera_sink_controller.cpp +++ b/services/cameraservice/sinkservice/src/distributedcameramgr/dcamera_sink_controller.cpp @@ -79,7 +79,7 @@ int32_t DCameraSinkController::StopCapture() if (ret != DCAMERA_OK) { DHLOGE("DCameraSinkController::StopCapture client stop capture failed, dhId: %s, ret: %d", GetAnonyString(dhId_).c_str(), ret); - DCameraNotifyInner(DCAMERA_MESSAGE, DCAMERA_EVENT_CAMERA_ERROR, std::string("operator stop capture failed")); + DCameraNotifyInner(DCAMERA_MESSAGE, ret, std::string("operator stop capture failed")); return ret; } @@ -87,7 +87,7 @@ int32_t DCameraSinkController::StopCapture() if (ret != DCAMERA_OK) { DHLOGE("DCameraSinkController::StopCapture output stop capture failed, dhId: %s, ret: %d", GetAnonyString(dhId_).c_str(), ret); - DCameraNotifyInner(DCAMERA_MESSAGE, DCAMERA_EVENT_CAMERA_ERROR, std::string("output stop capture failed")); + DCameraNotifyInner(DCAMERA_MESSAGE, ret, std::string("output stop capture failed")); return ret; } @@ -309,7 +309,11 @@ void DCameraSinkController::OnStateChanged(std::shared_ptr& event) { DHLOGI("DCameraSinkController::OnStateChanged dhId: %s, result: %d", GetAnonyString(dhId_).c_str(), event->eventResult_); - DCameraNotifyInner(DCAMERA_MESSAGE, DCAMERA_EVENT_CAMERA_ERROR, std::string("camera error")); + if (event->eventResult_ == CamServiceError::) { + DCameraNotifyInner(DCAMERA_MESSAGE, DCAMERA_EVENT_DEVICE_PREEMPT, std::string("camera preempted")); + } else { + DCameraNotifyInner(DCAMERA_MESSAGE, DCAMERA_EVENT_CAMERA_ERROR, std::string("camera error")); + } } void DCameraSinkController::OnMetadataResult() @@ -387,7 +391,7 @@ int32_t DCameraSinkController::StartCaptureInner(std::vector