From bbe0867114b3a937e9d7dfc8cea4f25639be61d6 Mon Sep 17 00:00:00 2001 From: wangchaole Date: Fri, 20 May 2022 11:45:41 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E5=88=86=E5=B8=83=E5=BC=8F=E7=9B=B8?= =?UTF-8?q?=E6=9C=BAcodex=E6=B8=85=E7=90=86:=E5=87=BD=E6=95=B0=E4=BD=93?= =?UTF-8?q?=E8=B6=85=E8=BF=8750=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangchaole --- .../include/dcamera_device/dcamera_device.h | 5 +- .../src/dcamera_device/dcamera_device.cpp | 50 +++++++++++-------- .../distributedcamera/dcamera_sink_hidumper.h | 2 +- .../dcamera_sink_hidumper.cpp | 2 +- .../dcamera_source_hidumper.h | 2 +- .../dcamera_source_hidumper.cpp | 2 +- 6 files changed, 37 insertions(+), 26 deletions(-) diff --git a/camera_hdf/hdi_impl/include/dcamera_device/dcamera_device.h b/camera_hdf/hdi_impl/include/dcamera_device/dcamera_device.h index 49b1f32e..2c3f0c4a 100644 --- a/camera_hdf/hdi_impl/include/dcamera_device/dcamera_device.h +++ b/camera_hdf/hdi_impl/include/dcamera_device/dcamera_device.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -62,7 +62,8 @@ private: void Init(const std::string &abilityInfo); DCamRetCode CreateDStreamOperator(); std::string GenerateCameraId(const std::shared_ptr &dhBase); - + void NotifyStartCaptureError(); + void NotifyCameraError(const std::shared_ptr &event); private: bool isOpened_; std::string dCameraId_; diff --git a/camera_hdf/hdi_impl/src/dcamera_device/dcamera_device.cpp b/camera_hdf/hdi_impl/src/dcamera_device/dcamera_device.cpp index e6a1a60c..490aad11 100644 --- a/camera_hdf/hdi_impl/src/dcamera_device/dcamera_device.cpp +++ b/camera_hdf/hdi_impl/src/dcamera_device/dcamera_device.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -391,28 +391,11 @@ DCamRetCode DCameraDevice::Notify(const std::shared_ptr &event) } case DCameraEventResult::DCAMERA_EVENT_CONFIG_STREAMS_ERROR: case DCameraEventResult::DCAMERA_EVENT_START_CAPTURE_ERROR: { - if (dCameraDeviceCallback_ != nullptr) { - dCameraDeviceCallback_->OnError(ErrorType::REQUEST_TIMEOUT, 0); - } - std::shared_ptr provider = DCameraProvider::GetInstance(); - if ((provider != nullptr) && (dCameraStreamOperator_ != nullptr)) { - std::vector streamIds = dCameraStreamOperator_->GetStreamIds(); - provider->StopCapture(dhBase_, streamIds); - } - if (dCameraStreamOperator_ != nullptr) { - dCameraStreamOperator_->Release(); - } + NotifyStartCaptureError(); break; } case DCameraEventResult::DCAMERA_EVENT_CAMERA_ERROR: { - std::shared_ptr dCameraHost = DCameraHost::GetInstance(); - if (dCameraHost != nullptr) { - dCameraHost->NotifyDCameraStatus(dhBase_, event->result_); - } - if (dCameraDeviceCallback_ != nullptr) { - dCameraDeviceCallback_->OnError(ErrorType::REQUEST_TIMEOUT, 0); - Close(); - } + NotifyCameraError(event); break; } default: @@ -421,6 +404,33 @@ DCamRetCode DCameraDevice::Notify(const std::shared_ptr &event) return SUCCESS; } +void DCameraDevice::NotifyStartCaptureError() +{ + if (dCameraDeviceCallback_ != nullptr) { + dCameraDeviceCallback_->OnError(ErrorType::REQUEST_TIMEOUT, 0); + } + std::shared_ptr provider = DCameraProvider::GetInstance(); + if ((provider != nullptr) && (dCameraStreamOperator_ != nullptr)) { + std::vector streamIds = dCameraStreamOperator_->GetStreamIds(); + provider->StopCapture(dhBase_, streamIds); + } + if (dCameraStreamOperator_ != nullptr) { + dCameraStreamOperator_->Release(); + } +} + +void DCameraDevice::NotifyCameraError(const std::shared_ptr &event) +{ + std::shared_ptr dCameraHost = DCameraHost::GetInstance(); + if (dCameraHost != nullptr) { + dCameraHost->NotifyDCameraStatus(dhBase_, event->result_); + } + if (dCameraDeviceCallback_ != nullptr) { + dCameraDeviceCallback_->OnError(ErrorType::REQUEST_TIMEOUT, 0); + Close(); + } +} + void DCameraDevice::SetProviderCallback(const OHOS::sptr &callback) { dCameraProviderCallback_ = callback; diff --git a/services/cameraservice/sinkservice/include/distributedcamera/dcamera_sink_hidumper.h b/services/cameraservice/sinkservice/include/distributedcamera/dcamera_sink_hidumper.h index 7622d9c9..4cd40fa1 100644 --- a/services/cameraservice/sinkservice/include/distributedcamera/dcamera_sink_hidumper.h +++ b/services/cameraservice/sinkservice/include/distributedcamera/dcamera_sink_hidumper.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/services/cameraservice/sinkservice/src/distributedcamera/dcamera_sink_hidumper.cpp b/services/cameraservice/sinkservice/src/distributedcamera/dcamera_sink_hidumper.cpp index 12006789..9cdf3b4c 100644 --- a/services/cameraservice/sinkservice/src/distributedcamera/dcamera_sink_hidumper.cpp +++ b/services/cameraservice/sinkservice/src/distributedcamera/dcamera_sink_hidumper.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/services/cameraservice/sourceservice/include/distributedcamera/dcamera_source_hidumper.h b/services/cameraservice/sourceservice/include/distributedcamera/dcamera_source_hidumper.h index 99e97e0b..85b2c17a 100644 --- a/services/cameraservice/sourceservice/include/distributedcamera/dcamera_source_hidumper.h +++ b/services/cameraservice/sourceservice/include/distributedcamera/dcamera_source_hidumper.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/services/cameraservice/sourceservice/src/distributedcamera/dcamera_source_hidumper.cpp b/services/cameraservice/sourceservice/src/distributedcamera/dcamera_source_hidumper.cpp index 991fb84a..55b05904 100644 --- a/services/cameraservice/sourceservice/src/distributedcamera/dcamera_source_hidumper.cpp +++ b/services/cameraservice/sourceservice/src/distributedcamera/dcamera_source_hidumper.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at -- Gitee From 19afe28c4f9b329de3344a330375c74d5d13fdd0 Mon Sep 17 00:00:00 2001 From: wangchaole Date: Fri, 20 May 2022 16:19:41 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E5=88=86=E5=B8=83=E5=BC=8F=E7=9B=B8?= =?UTF-8?q?=E6=9C=BAcodex=E6=B8=85=E7=90=86:=E5=87=BD=E6=95=B0=E4=BD=93?= =?UTF-8?q?=E8=B6=85=E8=BF=8750=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangchaole --- .../src/distributedcamera/distributed_camera_sink_service.cpp | 2 +- .../src/distributedcamera/distributed_camera_source_service.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/services/cameraservice/sinkservice/src/distributedcamera/distributed_camera_sink_service.cpp b/services/cameraservice/sinkservice/src/distributedcamera/distributed_camera_sink_service.cpp index 158bb04a..9f2389e5 100644 --- a/services/cameraservice/sinkservice/src/distributedcamera/distributed_camera_sink_service.cpp +++ b/services/cameraservice/sinkservice/src/distributedcamera/distributed_camera_sink_service.cpp @@ -97,7 +97,7 @@ int32_t DistributedCameraSinkService::InitSink(const std::string& params) DHLOGE("DistributedCameraSinkService::InitSink no camera device"); return DCAMERA_BAD_VALUE; } - g_camDump.camNumber = cameras.size(); + g_camDump.camNumber = static_cast(cameras.size()); for (auto& dhId : cameras) { std::shared_ptr sinkDevice = std::make_shared(dhId); ret = sinkDevice->Init(); diff --git a/services/cameraservice/sourceservice/src/distributedcamera/distributed_camera_source_service.cpp b/services/cameraservice/sourceservice/src/distributedcamera/distributed_camera_source_service.cpp index 5e28cb4b..3dcc1419 100644 --- a/services/cameraservice/sourceservice/src/distributedcamera/distributed_camera_source_service.cpp +++ b/services/cameraservice/sourceservice/src/distributedcamera/distributed_camera_source_service.cpp @@ -238,7 +238,7 @@ int DistributedCameraSourceService::Dump(int32_t fd, const std::vector(camerasMap_.size()); std::map curState; for (auto it = camerasMap_.begin(); it != camerasMap_.end(); it++) { DCameraIndex cam = it->first; -- Gitee From 8bc6ce4f610cac706749482da7fd2412f13b894a Mon Sep 17 00:00:00 2001 From: wangchaole Date: Fri, 20 May 2022 16:21:05 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E5=88=86=E5=B8=83=E5=BC=8F=E7=9B=B8?= =?UTF-8?q?=E6=9C=BAcodex=E6=B8=85=E7=90=86:=E5=87=BD=E6=95=B0=E4=BD=93?= =?UTF-8?q?=E8=B6=85=E8=BF=8750=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangchaole --- .../src/distributedcamera/distributed_camera_sink_service.cpp | 2 +- .../src/distributedcamera/distributed_camera_source_service.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/services/cameraservice/sinkservice/src/distributedcamera/distributed_camera_sink_service.cpp b/services/cameraservice/sinkservice/src/distributedcamera/distributed_camera_sink_service.cpp index 9f2389e5..01eba3b2 100644 --- a/services/cameraservice/sinkservice/src/distributedcamera/distributed_camera_sink_service.cpp +++ b/services/cameraservice/sinkservice/src/distributedcamera/distributed_camera_sink_service.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/services/cameraservice/sourceservice/src/distributedcamera/distributed_camera_source_service.cpp b/services/cameraservice/sourceservice/src/distributedcamera/distributed_camera_source_service.cpp index 3dcc1419..959fded5 100644 --- a/services/cameraservice/sourceservice/src/distributedcamera/distributed_camera_source_service.cpp +++ b/services/cameraservice/sourceservice/src/distributedcamera/distributed_camera_source_service.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at -- Gitee