From 03e2d9562b0f6f9f54bd2f3485feb6dcdcc6ff21 Mon Sep 17 00:00:00 2001 From: wangchaole Date: Mon, 11 Apr 2022 21:39:29 +0800 Subject: [PATCH 01/18] =?UTF-8?q?=E6=8C=89=E9=9C=80=E5=90=AF=E5=8A=A8sa?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangchaole --- .../native_cpp/camera_source/BUILD.gn | 3 ++ .../include/dcamera_source_handler.h | 2 + .../include/dcamera_source_load_callback.h | 33 ++++++++++++++++ .../src/dcamera_source_handler.cpp | 11 ++++++ .../src/dcamera_source_load_callback.cpp | 39 +++++++++++++++++++ .../src/distributed_camera_source_proxy.cpp | 2 +- sa_profile/4803.xml | 4 +- sa_profile/4804.xml | 4 +- services/cameraservice/sinkservice/BUILD.gn | 8 ++++ .../cameraservice/sinkservice/dcamerasink.cfg | 10 +++++ .../distributed_camera_sink_service.cpp | 1 + services/cameraservice/sourceservice/BUILD.gn | 8 ++++ .../sourceservice/dcamerasrc.cfg | 0 .../distributed_camera_source_service.cpp | 1 + 14 files changed, 121 insertions(+), 5 deletions(-) create mode 100644 interfaces/inner_kits/native_cpp/camera_source/include/dcamera_source_load_callback.h create mode 100644 interfaces/inner_kits/native_cpp/camera_source/src/dcamera_source_load_callback.cpp create mode 100644 services/cameraservice/sinkservice/dcamerasink.cfg create mode 100644 services/cameraservice/sourceservice/dcamerasrc.cfg diff --git a/interfaces/inner_kits/native_cpp/camera_source/BUILD.gn b/interfaces/inner_kits/native_cpp/camera_source/BUILD.gn index 50cc17a1..47244c34 100644 --- a/interfaces/inner_kits/native_cpp/camera_source/BUILD.gn +++ b/interfaces/inner_kits/native_cpp/camera_source/BUILD.gn @@ -17,6 +17,8 @@ import( ohos_shared_library("distributed_camera_source_sdk") { include_dirs = [ + "//drivers/adapter/uhdf2/include/hdi", + "//drivers/adapter/uhdf2/osal/include", "//utils/native/base/include", "//utils/system/safwk/native/include", "${fwk_utils_path}/include/log", @@ -41,6 +43,7 @@ ohos_shared_library("distributed_camera_source_sdk") { deps = [ "${fwk_utils_path}:distributedhardwareutils", + "//drivers/adapter/uhdf2/hdi:libhdi", "//utils/native/base:utils", ] diff --git a/interfaces/inner_kits/native_cpp/camera_source/include/dcamera_source_handler.h b/interfaces/inner_kits/native_cpp/camera_source/include/dcamera_source_handler.h index a1f47f6c..506fb82b 100644 --- a/interfaces/inner_kits/native_cpp/camera_source/include/dcamera_source_handler.h +++ b/interfaces/inner_kits/native_cpp/camera_source/include/dcamera_source_handler.h @@ -28,6 +28,7 @@ namespace OHOS { namespace DistributedHardware { +constexpr int WAIT_TIME = 1000; class DCameraSourceHandler : public IDistributedHardwareSource { DECLARE_SINGLE_INSTANCE_BASE(DCameraSourceHandler); public: @@ -39,6 +40,7 @@ public: std::shared_ptr callback) override; int32_t ConfigDistributedHardware(const std::string& devId, const std::string& dhId, const std::string& key, const std::string& value) override; + void FinishStartSA(const std::string ¶ms, const sptr &remoteObject); private: DCameraSourceHandler() = default; diff --git a/interfaces/inner_kits/native_cpp/camera_source/include/dcamera_source_load_callback.h b/interfaces/inner_kits/native_cpp/camera_source/include/dcamera_source_load_callback.h new file mode 100644 index 00000000..b49df198 --- /dev/null +++ b/interfaces/inner_kits/native_cpp/camera_source/include/dcamera_source_load_callback.h @@ -0,0 +1,33 @@ +/* + * 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef OHOS_DCAMERA_SOURCE_LOAD_CALLBACK_H +#define OHOS_DCAMERA_SOURCE_LOAD_CALLBACK_H + +#include "system_ability_load_callback_stub.h" + +namespace OHOS { +namespace DistributedHardware{ +class DCameraSourceLoadCallback : public SystemAbilityLoadCallbackStub { +public: + + explicit DCameraSourceLoadCallback(const std::string params); + void OnLoadSystemAbilitySuccess(int32_t systemAbilityId, const sptr& remoteObject); + void OnLoadSystemAbilityFail(int32_t systemAbilityId); +private: + std::string params; +}; +} +} +#endif \ No newline at end of file diff --git a/interfaces/inner_kits/native_cpp/camera_source/src/dcamera_source_handler.cpp b/interfaces/inner_kits/native_cpp/camera_source/src/dcamera_source_handler.cpp index ddee107f..e0c41fa6 100644 --- a/interfaces/inner_kits/native_cpp/camera_source/src/dcamera_source_handler.cpp +++ b/interfaces/inner_kits/native_cpp/camera_source/src/dcamera_source_handler.cpp @@ -48,9 +48,20 @@ int32_t DCameraSourceHandler::InitSource(const std::string& params) } int32_t ret = dCameraSourceSrv->InitSource(params, callback_); DHLOGI("DCameraSourceHandler InitSource end, ret: %d", ret); + OsalMsleep(WAIT_TIME); return ret; } +void DCameraSourceHandler::FinishStartSA(const std::string ¶ms, const sptr &remoteObject) +{ + sptr dCameraSourceSrc::GetInstance().GetSourceLocalDHMS(); + if((!dCameraSourceSrc) || (!dCameraSourceSrc->AsObject())) { + DHLOGE("Failed to get dscreen source proxy.") + return; + } + dCameraSourceSrc->InitSource(params, callback_); +} + int32_t DCameraSourceHandler::ReleaseSource() { DHLOGI("DCameraSourceHandler ReleaseSource Start"); diff --git a/interfaces/inner_kits/native_cpp/camera_source/src/dcamera_source_load_callback.cpp b/interfaces/inner_kits/native_cpp/camera_source/src/dcamera_source_load_callback.cpp new file mode 100644 index 00000000..20fc7fd9 --- /dev/null +++ b/interfaces/inner_kits/native_cpp/camera_source/src/dcamera_source_load_callback.cpp @@ -0,0 +1,39 @@ +/* + * 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "dcamera_source_load_callback.h" +#include "dcamera_source_handler.h" +#include "distributed_hardware_log" + +namespace OHOS { +namespace DistributedHardware { + DcameraSourceLoadCallback::DcameraSourceLoadCallback(const std::string params) : params(params) {} + void DcameraSourceLoadCallback::OnLoadSystemAbilitySuccess(int32_t systemAbilityId, const sptr& remoteObject) + { + DHLOGE("OnLoadSystemAbilitySuccess systemAbilityId: %d, IRmoteObject result: %s", + systemAbilityId, (remoteObject != nullptr) ? "true" : false); + if(remoteObject == nullptr) { + DHLOGE("remoteObject is null."); + } + return; + DCameraSourceHandler::GetInstance().FinishStartSA(params, remoteObject); + } + + void DcameraSourceLoadCallback::OnLoadSystemAbilityFail(int32_t systemAbilityId) + { + DHLOGE("OnLoadSystemAbilityFail systemAbilityId: %d.", systemAbilityId); + } + +} +} \ No newline at end of file diff --git a/interfaces/inner_kits/native_cpp/camera_source/src/distributed_camera_source_proxy.cpp b/interfaces/inner_kits/native_cpp/camera_source/src/distributed_camera_source_proxy.cpp index 113bdbda..33af72b0 100644 --- a/interfaces/inner_kits/native_cpp/camera_source/src/distributed_camera_source_proxy.cpp +++ b/interfaces/inner_kits/native_cpp/camera_source/src/distributed_camera_source_proxy.cpp @@ -34,7 +34,7 @@ int32_t DistributedCameraSourceProxy::InitSource(const std::string& params, } MessageParcel data; MessageParcel reply; - MessageOption option; + MessageOption option = { MessageOption::TF_ASYNC }; if (!data.WriteInterfaceToken(DistributedCameraSourceProxy::GetDescriptor())) { DHLOGE("DistributedCameraSourceProxy InitSource write token failed"); return DCAMERA_BAD_VALUE; diff --git a/sa_profile/4803.xml b/sa_profile/4803.xml index d5e5bfaa..fb50166a 100644 --- a/sa_profile/4803.xml +++ b/sa_profile/4803.xml @@ -14,13 +14,13 @@ * limitations under the License. --> - dhardware + dcamerasrc 4803 libdistributed_camera_source.z.so - true + false true 1 diff --git a/sa_profile/4804.xml b/sa_profile/4804.xml index f0e70574..a827ae53 100644 --- a/sa_profile/4804.xml +++ b/sa_profile/4804.xml @@ -14,13 +14,13 @@ * limitations under the License. --> - dhardware + dcamerasink 4804 libdistributed_camera_sink.z.so - true + false true 1 diff --git a/services/cameraservice/sinkservice/BUILD.gn b/services/cameraservice/sinkservice/BUILD.gn index 2ce72ccf..7f5416e6 100644 --- a/services/cameraservice/sinkservice/BUILD.gn +++ b/services/cameraservice/sinkservice/BUILD.gn @@ -108,6 +108,7 @@ ohos_shared_library("distributed_camera_sink") { "${services_path}/data_process:distributed_camera_data_process", "//third_party/jsoncpp:jsoncpp", "//utils/native/base:utils", + ":distributed_camera_source_proxy.cfg", ] defines = [ @@ -127,4 +128,11 @@ ohos_shared_library("distributed_camera_sink") { subsystem_name = "distributedhardware" part_name = "distributed_camera" + + ohos_prebuild_etc("dcamerasrc.cfg") { + relative_install_dir = "init" + source = "dcamerasink.cfg" + part_name = "distributed_camera" + subsystem_name = "distributedhardware" + } } diff --git a/services/cameraservice/sinkservice/dcamerasink.cfg b/services/cameraservice/sinkservice/dcamerasink.cfg new file mode 100644 index 00000000..bc17e464 --- /dev/null +++ b/services/cameraservice/sinkservice/dcamerasink.cfg @@ -0,0 +1,10 @@ +{ + "services" : [{ + "name" : "dcamerasink", + "dynamic" : true, + "path" : ["/system/nim/sa_main","/system/profile/dcamerasink.xml"], + "uid" : "system", + "gid" : ["system"], + "ondemand" : true + }] +} \ No newline at end of file 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 888708d8..d35bd197 100644 --- a/services/cameraservice/sinkservice/src/distributedcamera/distributed_camera_sink_service.cpp +++ b/services/cameraservice/sinkservice/src/distributedcamera/distributed_camera_sink_service.cpp @@ -117,6 +117,7 @@ int32_t DistributedCameraSinkService::ReleaseSink() } camerasMap_.clear(); DHLOGI("DistributedCameraSinkService::ReleaseSink success"); + exit(0); return DCAMERA_OK; } diff --git a/services/cameraservice/sourceservice/BUILD.gn b/services/cameraservice/sourceservice/BUILD.gn index 8f53c80d..065ebe61 100644 --- a/services/cameraservice/sourceservice/BUILD.gn +++ b/services/cameraservice/sourceservice/BUILD.gn @@ -27,6 +27,7 @@ ohos_shared_library("distributed_camera_source") { "${fwk_utils_path}/include", "//third_party/jsoncpp/include", "//drivers/peripheral/base", + ":dcamerasrc.cfg", ] include_dirs += [ @@ -112,4 +113,11 @@ ohos_shared_library("distributed_camera_source") { subsystem_name = "distributedhardware" part_name = "distributed_camera" + + ohos_prebuild_etc("dcamerasrc.cfg") { + relative_install_dir = "init" + source = "dcamerasrc.cfg" + part_name = "distributed_camera" + subsystem_name = "distributedhardware" + } } diff --git a/services/cameraservice/sourceservice/dcamerasrc.cfg b/services/cameraservice/sourceservice/dcamerasrc.cfg new file mode 100644 index 00000000..e69de29b 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 1119e87b..6fcdf75c 100644 --- a/services/cameraservice/sourceservice/src/distributedcamera/distributed_camera_source_service.cpp +++ b/services/cameraservice/sourceservice/src/distributedcamera/distributed_camera_source_service.cpp @@ -102,6 +102,7 @@ int32_t DistributedCameraSourceService::ReleaseSource() return ret; } callbackProxy_ = nullptr; + exit(0); return DCAMERA_OK; } -- Gitee From 1c6c2b023ecf256544f9bdd5b09e102a971f4b7c Mon Sep 17 00:00:00 2001 From: wangchaole Date: Mon, 11 Apr 2022 22:38:07 +0800 Subject: [PATCH 02/18] =?UTF-8?q?=E5=88=86=E5=B8=83=E5=BC=8F=E7=9B=B8?= =?UTF-8?q?=E6=9C=BA=E6=8C=89=E9=9C=80=E5=90=AF=E5=8A=A8SA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangchaole --- services/cameraservice/sinkservice/BUILD.gn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/cameraservice/sinkservice/BUILD.gn b/services/cameraservice/sinkservice/BUILD.gn index 7f5416e6..5dc577d4 100644 --- a/services/cameraservice/sinkservice/BUILD.gn +++ b/services/cameraservice/sinkservice/BUILD.gn @@ -108,7 +108,7 @@ ohos_shared_library("distributed_camera_sink") { "${services_path}/data_process:distributed_camera_data_process", "//third_party/jsoncpp:jsoncpp", "//utils/native/base:utils", - ":distributed_camera_source_proxy.cfg", + ":dcamerasrc.cfg", ] defines = [ -- Gitee From 1cc612956fdbc6ee918fab2a1a3de015b2dfb1f4 Mon Sep 17 00:00:00 2001 From: wangchaole Date: Mon, 11 Apr 2022 22:52:39 +0800 Subject: [PATCH 03/18] =?UTF-8?q?=E5=88=86=E5=B8=83=E5=BC=8F=E7=9B=B8?= =?UTF-8?q?=E6=9C=BA=E6=8C=89=E9=9C=80=E5=90=AF=E5=8A=A8SA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangchaole --- .../camera_source/src/dcamera_source_handler.cpp | 2 +- .../camera_source/src/dcamera_source_load_callback.cpp | 3 ++- services/cameraservice/sinkservice/BUILD.gn | 4 ++-- services/cameraservice/sourceservice/BUILD.gn | 1 + services/cameraservice/sourceservice/dcamerasrc.cfg | 10 ++++++++++ 5 files changed, 16 insertions(+), 4 deletions(-) diff --git a/interfaces/inner_kits/native_cpp/camera_source/src/dcamera_source_handler.cpp b/interfaces/inner_kits/native_cpp/camera_source/src/dcamera_source_handler.cpp index e0c41fa6..52359171 100644 --- a/interfaces/inner_kits/native_cpp/camera_source/src/dcamera_source_handler.cpp +++ b/interfaces/inner_kits/native_cpp/camera_source/src/dcamera_source_handler.cpp @@ -54,7 +54,7 @@ int32_t DCameraSourceHandler::InitSource(const std::string& params) void DCameraSourceHandler::FinishStartSA(const std::string ¶ms, const sptr &remoteObject) { - sptr dCameraSourceSrc::GetInstance().GetSourceLocalDHMS(); + sptr dCameraSourceSrc = DCameraSourceHandlerIpc::GetInstance().GetSourceLocalDHMS(); if((!dCameraSourceSrc) || (!dCameraSourceSrc->AsObject())) { DHLOGE("Failed to get dscreen source proxy.") return; diff --git a/interfaces/inner_kits/native_cpp/camera_source/src/dcamera_source_load_callback.cpp b/interfaces/inner_kits/native_cpp/camera_source/src/dcamera_source_load_callback.cpp index 20fc7fd9..b1f9afb9 100644 --- a/interfaces/inner_kits/native_cpp/camera_source/src/dcamera_source_load_callback.cpp +++ b/interfaces/inner_kits/native_cpp/camera_source/src/dcamera_source_load_callback.cpp @@ -19,7 +19,8 @@ namespace OHOS { namespace DistributedHardware { DcameraSourceLoadCallback::DcameraSourceLoadCallback(const std::string params) : params(params) {} - void DcameraSourceLoadCallback::OnLoadSystemAbilitySuccess(int32_t systemAbilityId, const sptr& remoteObject) + void DcameraSourceLoadCallback::OnLoadSystemAbilitySuccess(int32_t systemAbilityId, + const sptr& remoteObject) { DHLOGE("OnLoadSystemAbilitySuccess systemAbilityId: %d, IRmoteObject result: %s", systemAbilityId, (remoteObject != nullptr) ? "true" : false); diff --git a/services/cameraservice/sinkservice/BUILD.gn b/services/cameraservice/sinkservice/BUILD.gn index 5dc577d4..f094f0ee 100644 --- a/services/cameraservice/sinkservice/BUILD.gn +++ b/services/cameraservice/sinkservice/BUILD.gn @@ -108,7 +108,7 @@ ohos_shared_library("distributed_camera_sink") { "${services_path}/data_process:distributed_camera_data_process", "//third_party/jsoncpp:jsoncpp", "//utils/native/base:utils", - ":dcamerasrc.cfg", + ":dcamerasink.cfg", ] defines = [ @@ -129,7 +129,7 @@ ohos_shared_library("distributed_camera_sink") { part_name = "distributed_camera" - ohos_prebuild_etc("dcamerasrc.cfg") { + ohos_prebuild_etc("dcamerasink.cfg") { relative_install_dir = "init" source = "dcamerasink.cfg" part_name = "distributed_camera" diff --git a/services/cameraservice/sourceservice/BUILD.gn b/services/cameraservice/sourceservice/BUILD.gn index 065ebe61..6fcb7157 100644 --- a/services/cameraservice/sourceservice/BUILD.gn +++ b/services/cameraservice/sourceservice/BUILD.gn @@ -94,6 +94,7 @@ ohos_shared_library("distributed_camera_source") { "${services_path}/data_process:distributed_camera_data_process", "//third_party/jsoncpp:jsoncpp", "//utils/native/base:utils", + ":dcamerasrc.cfg" ] defines = [ diff --git a/services/cameraservice/sourceservice/dcamerasrc.cfg b/services/cameraservice/sourceservice/dcamerasrc.cfg index e69de29b..8419a4aa 100644 --- a/services/cameraservice/sourceservice/dcamerasrc.cfg +++ b/services/cameraservice/sourceservice/dcamerasrc.cfg @@ -0,0 +1,10 @@ +{ + "services" : [{ + "name" : "dcamerasrc", + "dynamic" : true, + "path" : ["/system/nim/sa_main","/system/profile/dcamerasrc.xml"], + "uid" : "system", + "gid" : ["system"], + "ondemand" : true + }] +} \ No newline at end of file -- Gitee From 8a719614ed7e7dccf9477c9db4a458e41e53ec71 Mon Sep 17 00:00:00 2001 From: wangchaole Date: Mon, 11 Apr 2022 23:11:12 +0800 Subject: [PATCH 04/18] =?UTF-8?q?=E5=88=86=E5=B8=83=E5=BC=8F=E7=9B=B8?= =?UTF-8?q?=E6=9C=BA=E6=8C=89=E9=9C=80=E5=90=AF=E5=8A=A8SA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangchaole --- .../native_cpp/camera_source/src/dcamera_source_handler.cpp | 2 +- .../camera_source/src/dcamera_source_load_callback.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/interfaces/inner_kits/native_cpp/camera_source/src/dcamera_source_handler.cpp b/interfaces/inner_kits/native_cpp/camera_source/src/dcamera_source_handler.cpp index 52359171..3595a76e 100644 --- a/interfaces/inner_kits/native_cpp/camera_source/src/dcamera_source_handler.cpp +++ b/interfaces/inner_kits/native_cpp/camera_source/src/dcamera_source_handler.cpp @@ -55,7 +55,7 @@ int32_t DCameraSourceHandler::InitSource(const std::string& params) void DCameraSourceHandler::FinishStartSA(const std::string ¶ms, const sptr &remoteObject) { sptr dCameraSourceSrc = DCameraSourceHandlerIpc::GetInstance().GetSourceLocalDHMS(); - if((!dCameraSourceSrc) || (!dCameraSourceSrc->AsObject())) { + if ((!dCameraSourceSrc) || (!dCameraSourceSrc->AsObject())) { DHLOGE("Failed to get dscreen source proxy.") return; } diff --git a/interfaces/inner_kits/native_cpp/camera_source/src/dcamera_source_load_callback.cpp b/interfaces/inner_kits/native_cpp/camera_source/src/dcamera_source_load_callback.cpp index b1f9afb9..19da7096 100644 --- a/interfaces/inner_kits/native_cpp/camera_source/src/dcamera_source_load_callback.cpp +++ b/interfaces/inner_kits/native_cpp/camera_source/src/dcamera_source_load_callback.cpp @@ -18,13 +18,14 @@ namespace OHOS { namespace DistributedHardware { + DcameraSourceLoadCallback::DcameraSourceLoadCallback(const std::string params) : params(params) {} void DcameraSourceLoadCallback::OnLoadSystemAbilitySuccess(int32_t systemAbilityId, const sptr& remoteObject) { DHLOGE("OnLoadSystemAbilitySuccess systemAbilityId: %d, IRmoteObject result: %s", systemAbilityId, (remoteObject != nullptr) ? "true" : false); - if(remoteObject == nullptr) { + if (remoteObject == nullptr) { DHLOGE("remoteObject is null."); } return; @@ -35,6 +36,5 @@ namespace DistributedHardware { { DHLOGE("OnLoadSystemAbilityFail systemAbilityId: %d.", systemAbilityId); } - } } \ No newline at end of file -- Gitee From 0bbf7667672f13e709003dd5029196443d049e84 Mon Sep 17 00:00:00 2001 From: wangchaole Date: Mon, 11 Apr 2022 23:31:08 +0800 Subject: [PATCH 05/18] =?UTF-8?q?=E5=88=86=E5=B8=83=E5=BC=8F=E7=9B=B8?= =?UTF-8?q?=E6=9C=BA=E6=8C=89=E9=9C=80=E5=90=AF=E5=8A=A8SA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangchaole --- interfaces/inner_kits/native_cpp/camera_source/BUILD.gn | 1 + services/cameraservice/sinkservice/BUILD.gn | 2 +- services/cameraservice/sourceservice/BUILD.gn | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/interfaces/inner_kits/native_cpp/camera_source/BUILD.gn b/interfaces/inner_kits/native_cpp/camera_source/BUILD.gn index 47244c34..7ff8b7c2 100644 --- a/interfaces/inner_kits/native_cpp/camera_source/BUILD.gn +++ b/interfaces/inner_kits/native_cpp/camera_source/BUILD.gn @@ -39,6 +39,7 @@ ohos_shared_library("distributed_camera_source_sdk") { "src/dcamera_source_handler.cpp", "src/dcamera_source_handler_ipc.cpp", "src/distributed_camera_source_proxy.cpp", + "src/dcamera_source_load_callback.cpp", ] deps = [ diff --git a/services/cameraservice/sinkservice/BUILD.gn b/services/cameraservice/sinkservice/BUILD.gn index f094f0ee..068425bd 100644 --- a/services/cameraservice/sinkservice/BUILD.gn +++ b/services/cameraservice/sinkservice/BUILD.gn @@ -129,7 +129,7 @@ ohos_shared_library("distributed_camera_sink") { part_name = "distributed_camera" - ohos_prebuild_etc("dcamerasink.cfg") { + ohos_prebuilt_etc("dcamerasink.cfg") { relative_install_dir = "init" source = "dcamerasink.cfg" part_name = "distributed_camera" diff --git a/services/cameraservice/sourceservice/BUILD.gn b/services/cameraservice/sourceservice/BUILD.gn index 6fcb7157..b9e47659 100644 --- a/services/cameraservice/sourceservice/BUILD.gn +++ b/services/cameraservice/sourceservice/BUILD.gn @@ -94,7 +94,7 @@ ohos_shared_library("distributed_camera_source") { "${services_path}/data_process:distributed_camera_data_process", "//third_party/jsoncpp:jsoncpp", "//utils/native/base:utils", - ":dcamerasrc.cfg" + ":dcamerasrc.cfg", ] defines = [ @@ -115,7 +115,7 @@ ohos_shared_library("distributed_camera_source") { part_name = "distributed_camera" - ohos_prebuild_etc("dcamerasrc.cfg") { + ohos_prebuilt_etc("dcamerasrc.cfg") { relative_install_dir = "init" source = "dcamerasrc.cfg" part_name = "distributed_camera" -- Gitee From d2469fddee99d26cf4e3b52ec7fcafcbc1b8ecf2 Mon Sep 17 00:00:00 2001 From: wangchaole Date: Tue, 12 Apr 2022 08:00:56 +0800 Subject: [PATCH 06/18] =?UTF-8?q?=E5=88=86=E5=B8=83=E5=BC=8F=E7=9B=B8?= =?UTF-8?q?=E6=9C=BA=E6=8C=89=E9=9C=80=E5=90=AF=E5=8A=A8SA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangchaole --- .../camera_source/include/dcamera_source_load_callback.h | 2 +- .../camera_source/src/dcamera_source_load_callback.cpp | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/interfaces/inner_kits/native_cpp/camera_source/include/dcamera_source_load_callback.h b/interfaces/inner_kits/native_cpp/camera_source/include/dcamera_source_load_callback.h index b49df198..d4d97b50 100644 --- a/interfaces/inner_kits/native_cpp/camera_source/include/dcamera_source_load_callback.h +++ b/interfaces/inner_kits/native_cpp/camera_source/include/dcamera_source_load_callback.h @@ -18,7 +18,7 @@ #include "system_ability_load_callback_stub.h" namespace OHOS { -namespace DistributedHardware{ +namespace DistributedHardware { class DCameraSourceLoadCallback : public SystemAbilityLoadCallbackStub { public: diff --git a/interfaces/inner_kits/native_cpp/camera_source/src/dcamera_source_load_callback.cpp b/interfaces/inner_kits/native_cpp/camera_source/src/dcamera_source_load_callback.cpp index 19da7096..9e0c413d 100644 --- a/interfaces/inner_kits/native_cpp/camera_source/src/dcamera_source_load_callback.cpp +++ b/interfaces/inner_kits/native_cpp/camera_source/src/dcamera_source_load_callback.cpp @@ -18,7 +18,6 @@ namespace OHOS { namespace DistributedHardware { - DcameraSourceLoadCallback::DcameraSourceLoadCallback(const std::string params) : params(params) {} void DcameraSourceLoadCallback::OnLoadSystemAbilitySuccess(int32_t systemAbilityId, const sptr& remoteObject) -- Gitee From bb90c1dc1277492c05aa5982d186aa98b9085966 Mon Sep 17 00:00:00 2001 From: wangchaole Date: Tue, 12 Apr 2022 17:34:26 +0800 Subject: [PATCH 07/18] =?UTF-8?q?=E5=88=86=E5=B8=83=E5=BC=8F=E7=9B=B8?= =?UTF-8?q?=E6=9C=BA=E6=8C=89=E9=9C=80=E5=90=AF=E5=8A=A8SA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangchaole --- .../native_cpp/camera_sink/BUILD.gn | 1 + .../include/dcamera_sink_handler.h | 14 ++++- .../include/dcamera_sink_load_callback.h | 33 +++++++++++ .../camera_sink/src/dcamera_sink_handler.cpp | 41 +++++++++++++- .../src/dcamera_sink_load_callback.cpp | 49 ++++++++++++++++ .../native_cpp/camera_source/BUILD.gn | 3 - .../include/dcamera_source_handler.h | 11 +++- .../include/dcamera_source_load_callback.h | 2 +- .../src/dcamera_source_handler.cpp | 56 +++++++++++++++---- .../src/dcamera_source_load_callback.cpp | 40 ++++++++----- services/cameraservice/sinkservice/BUILD.gn | 12 ++-- .../cameraservice/sinkservice/dcamerasink.cfg | 2 +- services/cameraservice/sourceservice/BUILD.gn | 18 +++--- .../sourceservice/dcamerasrc.cfg | 2 +- 14 files changed, 231 insertions(+), 53 deletions(-) create mode 100644 interfaces/inner_kits/native_cpp/camera_sink/include/dcamera_sink_load_callback.h create mode 100644 interfaces/inner_kits/native_cpp/camera_sink/src/dcamera_sink_load_callback.cpp diff --git a/interfaces/inner_kits/native_cpp/camera_sink/BUILD.gn b/interfaces/inner_kits/native_cpp/camera_sink/BUILD.gn index ea379967..33d359b6 100644 --- a/interfaces/inner_kits/native_cpp/camera_sink/BUILD.gn +++ b/interfaces/inner_kits/native_cpp/camera_sink/BUILD.gn @@ -33,6 +33,7 @@ ohos_shared_library("distributed_camera_sink_sdk") { sources = [ "src/dcamera_sink_handler.cpp", "src/dcamera_sink_handler_ipc.cpp", + "src/dcamera_sink_load_callback.cpp", "src/distributed_camera_sink_proxy.cpp", ] diff --git a/interfaces/inner_kits/native_cpp/camera_sink/include/dcamera_sink_handler.h b/interfaces/inner_kits/native_cpp/camera_sink/include/dcamera_sink_handler.h index 52b95b6e..e9829725 100644 --- a/interfaces/inner_kits/native_cpp/camera_sink/include/dcamera_sink_handler.h +++ b/interfaces/inner_kits/native_cpp/camera_sink/include/dcamera_sink_handler.h @@ -16,6 +16,9 @@ #ifndef OHOS_DCAMERA_SINK_HANDLER_H #define OHOS_DCAMERA_SINK_HANDLER_H +#include +#include + #include "idistributed_hardware_sink.h" #include "single_instance.h" @@ -28,10 +31,19 @@ public: int32_t ReleaseSink() override; int32_t SubscribeLocalHardware(const std::string& dhId, const std::string& parameters) override; int32_t UnsubscribeLocalHardware(const std::string& dhId) override; - + void FinishStartSA(const std::string ¶ms); + void FinishStartSAFailed(int32_t systemAbilityId); private: + typedef enum { + DCAMERA_SA_STATE_STOP = 0, + DCAMERA_SA_STATE_START = 1, + } DCameraSAState; DCameraSinkHandler() = default; ~DCameraSinkHandler(); +private: + std::condition_variable producerCon_; + std::mutex producerMutex_; + DCameraSAState state_ = DCAMERA_SA_STATE_STOP; }; #ifdef __cplusplus diff --git a/interfaces/inner_kits/native_cpp/camera_sink/include/dcamera_sink_load_callback.h b/interfaces/inner_kits/native_cpp/camera_sink/include/dcamera_sink_load_callback.h new file mode 100644 index 00000000..8230e097 --- /dev/null +++ b/interfaces/inner_kits/native_cpp/camera_sink/include/dcamera_sink_load_callback.h @@ -0,0 +1,33 @@ +/* + * 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef OHOS_DCAMERA_SINk_LOAD_CALLBACK_H +#define OHOS_DCAMERA_SINk_LOAD_CALLBACK_H + +#include "system_ability_load_callback_stub.h" + +namespace OHOS { +namespace DistributedHardware { +class DCameraSinkLoadCallback : public SystemAbilityLoadCallbackStub { +public: + + explicit DCameraSinkLoadCallback(const std::string params); + void OnLoadSystemAbilitySuccess(int32_t systemAbilityId, const sptr& remoteObject); + void OnLoadSystemAbilityFail(int32_t systemAbilityId); +private: + std::string params; +}; +} +} +#endif \ No newline at end of file diff --git a/interfaces/inner_kits/native_cpp/camera_sink/src/dcamera_sink_handler.cpp b/interfaces/inner_kits/native_cpp/camera_sink/src/dcamera_sink_handler.cpp index 4ddea60a..96df9231 100644 --- a/interfaces/inner_kits/native_cpp/camera_sink/src/dcamera_sink_handler.cpp +++ b/interfaces/inner_kits/native_cpp/camera_sink/src/dcamera_sink_handler.cpp @@ -14,11 +14,15 @@ */ #include "dcamera_sink_handler.h" +#include "dcamera_sink_load_callback.h" #include "anonymous_string.h" #include "dcamera_sink_handler_ipc.h" +#include "distributed_camera_constants.h" #include "distributed_camera_errno.h" #include "distributed_hardware_log.h" +#include "if_system_ability_manager.h" +#include "iservice_registry.h" namespace OHOS { namespace DistributedHardware { @@ -32,13 +36,47 @@ DCameraSinkHandler::~DCameraSinkHandler() int32_t DCameraSinkHandler::InitSink(const std::string& params) { DHLOGI("DCameraSinkHandler::InitSink"); + sptr loadCallback = new DcameraSinkLoadCallback(params); + sptr sm = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); + if (sm == nullptr) { + DHLOGE("GetSourceLocalDHMS GetSystemAbilityManager failed"); + return DCAMERA_INIT_ERR; + } + int32_t ret = sm->LoadSystemAbility(DISTRIBUTED_HARDWARE_CAMERA_SINK_SA_ID, loadCallback); + if (ret != DCAMERA_OK) { + DHLOGE("systemAbilityId: %d load filed,result code: %d.", DISTRIBUTED_HARDWARE_CAMERA_SINK_SA_ID, ret); + return DCAMERA_INIT_ERR; + } + //设置延时1分钟 + uint32_t interval = 1; + std::unique_lock lock(producerMutex_); + producerCon_.wait_for(lock, std::chrono::minutes(interval), [this] { + return (this->state_ == DCAMERA_SA_STATE_START); + }); + if (state_ == DCAMERA_SA_STATE_STOP) { + DHLOGE("SinkSA Start failed!"); + return DCAMERA_INIT_ERR; + } + DHLOGI("DCameraSinkHandler InitSink end, result: %d", ret); + return ret; +} + +void DCameraSinkHandler::FinishStartSA(const std::string ¶ms) +{ + state_ = DCAMERA_SA_STATE_START; DCameraSinkHandlerIpc::GetInstance().Init(); sptr dCameraSinkSrv = DCameraSinkHandlerIpc::GetInstance().GetSinkLocalDHMS(); if (dCameraSinkSrv == nullptr) { DHLOGE("DCameraSinkHandler::InitSink get Service failed"); return DCAMERA_INIT_ERR; } - return dCameraSinkSrv->InitSink(params); + dCameraSinkSrv->InitSink(params); +} + +void DCameraSinkHandler::FinishStartSAFailed(int32_t systemAbilityId) +{ + DHLOGI("SinkSA Start failed, systemAbilityId: %d.", systemAbilityId); + producerMutex_.notify_one(); } int32_t DCameraSinkHandler::ReleaseSink() @@ -57,6 +95,7 @@ int32_t DCameraSinkHandler::ReleaseSink() } DCameraSinkHandlerIpc::GetInstance().UnInit(); + producerMutex_.notify_one(); DHLOGI("DCameraSinkHandler::ReleaseSink success"); return DCAMERA_OK; } diff --git a/interfaces/inner_kits/native_cpp/camera_sink/src/dcamera_sink_load_callback.cpp b/interfaces/inner_kits/native_cpp/camera_sink/src/dcamera_sink_load_callback.cpp new file mode 100644 index 00000000..db6f884c --- /dev/null +++ b/interfaces/inner_kits/native_cpp/camera_sink/src/dcamera_sink_load_callback.cpp @@ -0,0 +1,49 @@ +/* + * 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "dcamera_sink_load_callback.h" +#include "dcamera_sink_handler.h" +#include "distributed_hardware_log" +#include "distributed_camera_constants.h" + +namespace OHOS { +namespace DistributedHardware { +DCameraSinkLoadCallback::DCameraSinkLoadCallback(const std::string params) : params(params) {} +void DCameraSinkLoadCallback::OnLoadSystemAbilitySuccess(int32_t systemAbilityId, + const sptr& remoteObject) +{ + if(systemAbilityId != DISTRIBUTED_HARDWARE_CAMERA_SINK_SA_ID) { + DHLOGE("start aystemabilityId is not sinkSAId!"); + return; + } + DHLOGE("OnLoadSystemAbilitySuccess systemAbilityId: %d, IRmoteObject result: %s", + systemAbilityId, (remoteObject != nullptr) ? "true" : "false"); + if (remoteObject == nullptr) { + DHLOGE("remoteObject is null."); + return; + } + DCameraSinkHandler::GetInstance().FinishStartSA(params); +} + +void DCameraSinkLoadCallback::OnLoadSystemAbilityFail(int32_t systemAbilityId) +{ + DHLOGE("OnLoadSystemAbilityFail systemAbilityId: %d.", systemAbilityId); + if(systemAbilityId != DISTRIBUTED_HARDWARE_CAMERA_SINK_SA_ID) { + DHLOGE("start aystemabilityId is not sinkSAId!"); + return; + } + DCameraSinkHandler::GetInstance().FinishStartSAFailed(systemAbilityId); +} +} +} \ No newline at end of file diff --git a/interfaces/inner_kits/native_cpp/camera_source/BUILD.gn b/interfaces/inner_kits/native_cpp/camera_source/BUILD.gn index 7ff8b7c2..ac7d116d 100644 --- a/interfaces/inner_kits/native_cpp/camera_source/BUILD.gn +++ b/interfaces/inner_kits/native_cpp/camera_source/BUILD.gn @@ -17,8 +17,6 @@ import( ohos_shared_library("distributed_camera_source_sdk") { include_dirs = [ - "//drivers/adapter/uhdf2/include/hdi", - "//drivers/adapter/uhdf2/osal/include", "//utils/native/base/include", "//utils/system/safwk/native/include", "${fwk_utils_path}/include/log", @@ -44,7 +42,6 @@ ohos_shared_library("distributed_camera_source_sdk") { deps = [ "${fwk_utils_path}:distributedhardwareutils", - "//drivers/adapter/uhdf2/hdi:libhdi", "//utils/native/base:utils", ] diff --git a/interfaces/inner_kits/native_cpp/camera_source/include/dcamera_source_handler.h b/interfaces/inner_kits/native_cpp/camera_source/include/dcamera_source_handler.h index 506fb82b..b6b6ddbb 100644 --- a/interfaces/inner_kits/native_cpp/camera_source/include/dcamera_source_handler.h +++ b/interfaces/inner_kits/native_cpp/camera_source/include/dcamera_source_handler.h @@ -17,6 +17,7 @@ #define OHOS_DCAMERA_SOURCE_HANDLER_H #include +#include #include "iremote_proxy.h" #include "iremote_broker.h" @@ -28,7 +29,6 @@ namespace OHOS { namespace DistributedHardware { -constexpr int WAIT_TIME = 1000; class DCameraSourceHandler : public IDistributedHardwareSource { DECLARE_SINGLE_INSTANCE_BASE(DCameraSourceHandler); public: @@ -41,14 +41,21 @@ public: int32_t ConfigDistributedHardware(const std::string& devId, const std::string& dhId, const std::string& key, const std::string& value) override; void FinishStartSA(const std::string ¶ms, const sptr &remoteObject); - + void FinishStartSAFailed(int32_t systemAbilityId); private: + typedef enum { + DCAMERA_SA_STATE_STOP = 0, + DCAMERA_SA_STATE_START = 1, + } DCameraSAState; DCameraSourceHandler() = default; ~DCameraSourceHandler(); private: std::mutex optLock_; sptr callback_; + std::condition_variable producerCon_; + std::mutex producerMutex_; + DCameraSAState state_ = DCAMERA_SA_STATE_STOP; }; #ifdef __cplusplus diff --git a/interfaces/inner_kits/native_cpp/camera_source/include/dcamera_source_load_callback.h b/interfaces/inner_kits/native_cpp/camera_source/include/dcamera_source_load_callback.h index d4d97b50..05f4d347 100644 --- a/interfaces/inner_kits/native_cpp/camera_source/include/dcamera_source_load_callback.h +++ b/interfaces/inner_kits/native_cpp/camera_source/include/dcamera_source_load_callback.h @@ -23,7 +23,7 @@ class DCameraSourceLoadCallback : public SystemAbilityLoadCallbackStub { public: explicit DCameraSourceLoadCallback(const std::string params); - void OnLoadSystemAbilitySuccess(int32_t systemAbilityId, const sptr& remoteObject); + void OnLoadSystemAbilitySuccess(int32_t systemAbilityId, const sptr& remoteObject); void OnLoadSystemAbilityFail(int32_t systemAbilityId); private: std::string params; diff --git a/interfaces/inner_kits/native_cpp/camera_source/src/dcamera_source_handler.cpp b/interfaces/inner_kits/native_cpp/camera_source/src/dcamera_source_handler.cpp index 3595a76e..a4870b2c 100644 --- a/interfaces/inner_kits/native_cpp/camera_source/src/dcamera_source_handler.cpp +++ b/interfaces/inner_kits/native_cpp/camera_source/src/dcamera_source_handler.cpp @@ -15,10 +15,14 @@ #include "dcamera_source_handler.h" #include "dcamera_source_callback.h" +#include "dcamera_source_load_callback.h" +#include "if_system_ability_manager.h" +#include "iservice_registry.h" #include "anonymous_string.h" #include "dcamera_source_handler_ipc.h" #include "dh_utils_tool.h" +#include "distributed_camera_constants.h" #include "distributed_camera_errno.h" #include "distributed_hardware_log.h" @@ -34,32 +38,59 @@ DCameraSourceHandler::~DCameraSourceHandler() int32_t DCameraSourceHandler::InitSource(const std::string& params) { DHLOGI("DCameraSourceHandler InitSource Start"); - DCameraSourceHandlerIpc::GetInstance().Init(); - sptr dCameraSourceSrv = DCameraSourceHandlerIpc::GetInstance().GetSourceLocalDHMS(); - if (dCameraSourceSrv == nullptr) { - DHLOGE("DCameraSourceHandler InitSource get Service failed"); + //通过samanage通知拉起sa。 + sptr loadCallback = new DCameraSourceLoadCallback(params); + sptr sm = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); + if (sm == nullptr) { + DHLOGE("GetSourceLocalDHMS GetSystemAbilityManager failed"); return DCAMERA_INIT_ERR; } - - callback_ = new DCameraSourceCallback(); - if (callback_ == nullptr) { - DHLOGE("DCameraSourceHandler InitSource init callback failed"); + int32_t ret = sm->LoadSystemAbility(DISTRIBUTED_HARDWARE_CAMERA_SOURCE_SA_ID, loadCallback); + if (ret != DCAMERA_OK) { + DHLOGE("systemAbilityId: %d load filed,result code: %d.", DISTRIBUTED_HARDWARE_CAMERA_SINK_SA_ID, ret); return DCAMERA_INIT_ERR; } - int32_t ret = dCameraSourceSrv->InitSource(params, callback_); - DHLOGI("DCameraSourceHandler InitSource end, ret: %d", ret); - OsalMsleep(WAIT_TIME); + //设置延时1分钟 + uint32_t interval = 1; + std::unique_lock lock(producerMutex_); + producerMutex_.wait_for(lock, std::chrono::minutes(interval), [this] { + return (this->state_ == DCAMERA_SA_STATE_START); + }); + if (state_ == DCAMERA_SA_STATE_STOP) { + DHLOGE("SourceSA Start failed!"); + return DCAMERA_INIT_ERR; + } + DHLOGI("DCameraSourceHandler InitSource end, result: %d", ret); return ret; } void DCameraSourceHandler::FinishStartSA(const std::string ¶ms, const sptr &remoteObject) { + //设置sa的状态 + state_ = DCAMERA_SA_STATE_START; + DCameraSourceHandlerIpc::GetInstance().Init(); sptr dCameraSourceSrc = DCameraSourceHandlerIpc::GetInstance().GetSourceLocalDHMS(); + if (dCameraSourceSrc == nullptr) { + DHLOGE("DCameraSourceHandler InitSource get Service failed"); + return; + } + + callback_ = new DCameraSourceCallback(); + if (callback_ == nullptr) { + DHLOGE("DCameraSourceHandler InitSource init callback failed"); + return; + } + int32_t ret = dCameraSourceSrc->InitSource(params, callback_); if ((!dCameraSourceSrc) || (!dCameraSourceSrc->AsObject())) { DHLOGE("Failed to get dscreen source proxy.") return; } - dCameraSourceSrc->InitSource(params, callback_); +} + +void DCameraSourceHandler::FinishStartSAFailed(int32_t systemAbilityId) +{ + DHLOGE("SourceSA Start failed, systemAbilityId: %d.", systemAbilityId); + producerMutex_.notify_one(); } int32_t DCameraSourceHandler::ReleaseSource() @@ -72,6 +103,7 @@ int32_t DCameraSourceHandler::ReleaseSource() } dCameraSourceSrv->ReleaseSource(); DCameraSourceHandlerIpc::GetInstance().UnInit(); + producerMutex_.notify_one(); DHLOGI("DCameraSourceHandler ReleaseSource end"); return DCAMERA_OK; } diff --git a/interfaces/inner_kits/native_cpp/camera_source/src/dcamera_source_load_callback.cpp b/interfaces/inner_kits/native_cpp/camera_source/src/dcamera_source_load_callback.cpp index 9e0c413d..9fe8e698 100644 --- a/interfaces/inner_kits/native_cpp/camera_source/src/dcamera_source_load_callback.cpp +++ b/interfaces/inner_kits/native_cpp/camera_source/src/dcamera_source_load_callback.cpp @@ -15,25 +15,37 @@ #include "dcamera_source_load_callback.h" #include "dcamera_source_handler.h" #include "distributed_hardware_log" +#include "distributed_camera_constants.h" namespace OHOS { namespace DistributedHardware { - DcameraSourceLoadCallback::DcameraSourceLoadCallback(const std::string params) : params(params) {} - void DcameraSourceLoadCallback::OnLoadSystemAbilitySuccess(int32_t systemAbilityId, - const sptr& remoteObject) - { - DHLOGE("OnLoadSystemAbilitySuccess systemAbilityId: %d, IRmoteObject result: %s", - systemAbilityId, (remoteObject != nullptr) ? "true" : false); - if (remoteObject == nullptr) { - DHLOGE("remoteObject is null."); - } - return; - DCameraSourceHandler::GetInstance().FinishStartSA(params, remoteObject); + +DCameraSourceLoadCallback::DCameraSourceLoadCallback(const std::string params) : params(params) {} + +void DCameraSourceLoadCallback::OnLoadSystemAbilitySuccess(int32_t systemAbilityId, + const sptr& remoteObject) +{ + if(systemAbilityId != DISTRIBUTED_HARDWARE_CAMERA_SOURCE_SA_ID) { + DHLOGE("start systemabilityId is not sourceSAId!"); + return; + } + DHLOGE("OnLoadSystemAbilitySuccess systemAbilityId: %d, IRmoteObject result: %s", + systemAbilityId, (remoteObject != nullptr) ? "true" : "false"); + if (remoteObject == nullptr) { + DHLOGE("remoteObject is null."); + return; } + DCameraSourceHandler::GetInstance().FinishStartSA(params, remoteObject); +} - void DcameraSourceLoadCallback::OnLoadSystemAbilityFail(int32_t systemAbilityId) - { - DHLOGE("OnLoadSystemAbilityFail systemAbilityId: %d.", systemAbilityId); +void DCameraSourceLoadCallback::OnLoadSystemAbilityFail(int32_t systemAbilityId) +{ + DHLOGE("OnLoadSystemAbilityFail systemAbilityId: %d.", systemAbilityId); + if(systemAbilityId != DISTRIBUTED_HARDWARE_CAMERA_SOURCE_SA_ID) { + DHLOGE("start systemabilityId is not sourceSAId!"); + return; } + DCameraSourceHandler::GetInstance().FinishStartSAFailed(systemAbilityId); +} } } \ No newline at end of file diff --git a/services/cameraservice/sinkservice/BUILD.gn b/services/cameraservice/sinkservice/BUILD.gn index 068425bd..af74befb 100644 --- a/services/cameraservice/sinkservice/BUILD.gn +++ b/services/cameraservice/sinkservice/BUILD.gn @@ -129,10 +129,10 @@ ohos_shared_library("distributed_camera_sink") { part_name = "distributed_camera" - ohos_prebuilt_etc("dcamerasink.cfg") { - relative_install_dir = "init" - source = "dcamerasink.cfg" - part_name = "distributed_camera" - subsystem_name = "distributedhardware" - } } +ohos_prebuilt_etc("dcamerasink.cfg") { + relative_install_dir = "init" + source = "dcamerasink.cfg" + part_name = "distributed_camera" + subsystem_name = "distributedhardware" +} \ No newline at end of file diff --git a/services/cameraservice/sinkservice/dcamerasink.cfg b/services/cameraservice/sinkservice/dcamerasink.cfg index bc17e464..7ed7633d 100644 --- a/services/cameraservice/sinkservice/dcamerasink.cfg +++ b/services/cameraservice/sinkservice/dcamerasink.cfg @@ -2,7 +2,7 @@ "services" : [{ "name" : "dcamerasink", "dynamic" : true, - "path" : ["/system/nim/sa_main","/system/profile/dcamerasink.xml"], + "path" : ["/system/bin/sa_main","/system/profile/dcamerasink.xml"], "uid" : "system", "gid" : ["system"], "ondemand" : true diff --git a/services/cameraservice/sourceservice/BUILD.gn b/services/cameraservice/sourceservice/BUILD.gn index b9e47659..0c9608b9 100644 --- a/services/cameraservice/sourceservice/BUILD.gn +++ b/services/cameraservice/sourceservice/BUILD.gn @@ -27,7 +27,6 @@ ohos_shared_library("distributed_camera_source") { "${fwk_utils_path}/include", "//third_party/jsoncpp/include", "//drivers/peripheral/base", - ":dcamerasrc.cfg", ] include_dirs += [ @@ -110,15 +109,12 @@ ohos_shared_library("distributed_camera_source") { "safwk:system_ability_fwk", "samgr_standard:samgr_proxy", ] - - subsystem_name = "distributedhardware" - part_name = "distributed_camera" - - ohos_prebuilt_etc("dcamerasrc.cfg") { - relative_install_dir = "init" - source = "dcamerasrc.cfg" - part_name = "distributed_camera" - subsystem_name = "distributedhardware" - } + subsystem_name = "distributedhardware" } +ohos_prebuilt_etc("dcamerasrc.cfg") { + relative_install_dir = "init" + source = "dcamerasrc.cfg" + part_name = "distributed_camera" + subsystem_name = "distributedhardware" +} \ No newline at end of file diff --git a/services/cameraservice/sourceservice/dcamerasrc.cfg b/services/cameraservice/sourceservice/dcamerasrc.cfg index 8419a4aa..dddfbef8 100644 --- a/services/cameraservice/sourceservice/dcamerasrc.cfg +++ b/services/cameraservice/sourceservice/dcamerasrc.cfg @@ -2,7 +2,7 @@ "services" : [{ "name" : "dcamerasrc", "dynamic" : true, - "path" : ["/system/nim/sa_main","/system/profile/dcamerasrc.xml"], + "path" : ["/system/bin/sa_main","/system/profile/dcamerasrc.xml"], "uid" : "system", "gid" : ["system"], "ondemand" : true -- Gitee From e9f068a29b23ba69918d9ee0836a683ede80ece9 Mon Sep 17 00:00:00 2001 From: wangchaole Date: Tue, 12 Apr 2022 17:36:47 +0800 Subject: [PATCH 08/18] =?UTF-8?q?=E5=88=86=E5=B8=83=E5=BC=8F=E7=9B=B8?= =?UTF-8?q?=E6=9C=BA=E6=8C=89=E9=9C=80=E5=90=AF=E5=8A=A8SA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangchaole --- .../native_cpp/camera_sink/src/dcamera_sink_handler.cpp | 4 ++-- .../native_cpp/camera_source/src/dcamera_source_handler.cpp | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/interfaces/inner_kits/native_cpp/camera_sink/src/dcamera_sink_handler.cpp b/interfaces/inner_kits/native_cpp/camera_sink/src/dcamera_sink_handler.cpp index 96df9231..949835d4 100644 --- a/interfaces/inner_kits/native_cpp/camera_sink/src/dcamera_sink_handler.cpp +++ b/interfaces/inner_kits/native_cpp/camera_sink/src/dcamera_sink_handler.cpp @@ -76,7 +76,7 @@ void DCameraSinkHandler::FinishStartSA(const std::string ¶ms) void DCameraSinkHandler::FinishStartSAFailed(int32_t systemAbilityId) { DHLOGI("SinkSA Start failed, systemAbilityId: %d.", systemAbilityId); - producerMutex_.notify_one(); + producerCon_.notify_one(); } int32_t DCameraSinkHandler::ReleaseSink() @@ -95,7 +95,7 @@ int32_t DCameraSinkHandler::ReleaseSink() } DCameraSinkHandlerIpc::GetInstance().UnInit(); - producerMutex_.notify_one(); + producerCon_.notify_one(); DHLOGI("DCameraSinkHandler::ReleaseSink success"); return DCAMERA_OK; } diff --git a/interfaces/inner_kits/native_cpp/camera_source/src/dcamera_source_handler.cpp b/interfaces/inner_kits/native_cpp/camera_source/src/dcamera_source_handler.cpp index a4870b2c..72702150 100644 --- a/interfaces/inner_kits/native_cpp/camera_source/src/dcamera_source_handler.cpp +++ b/interfaces/inner_kits/native_cpp/camera_source/src/dcamera_source_handler.cpp @@ -53,7 +53,7 @@ int32_t DCameraSourceHandler::InitSource(const std::string& params) //设置延时1分钟 uint32_t interval = 1; std::unique_lock lock(producerMutex_); - producerMutex_.wait_for(lock, std::chrono::minutes(interval), [this] { + producerCon_.wait_for(lock, std::chrono::minutes(interval), [this] { return (this->state_ == DCAMERA_SA_STATE_START); }); if (state_ == DCAMERA_SA_STATE_STOP) { @@ -90,7 +90,7 @@ void DCameraSourceHandler::FinishStartSA(const std::string ¶ms, const sptrReleaseSource(); DCameraSourceHandlerIpc::GetInstance().UnInit(); - producerMutex_.notify_one(); + producerCon_.notify_one(); DHLOGI("DCameraSourceHandler ReleaseSource end"); return DCAMERA_OK; } -- Gitee From 67b2830656512abf2bc6f287c4b35703656c999e Mon Sep 17 00:00:00 2001 From: wangchaole Date: Tue, 12 Apr 2022 18:37:07 +0800 Subject: [PATCH 09/18] =?UTF-8?q?=E5=88=86=E5=B8=83=E5=BC=8F=E7=9B=B8?= =?UTF-8?q?=E6=9C=BA=E6=8C=89=E9=9C=80=E5=90=AF=E5=8A=A8SA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangchaole --- .../camera_sink/src/dcamera_sink_handler.cpp | 5 ++--- .../camera_sink/src/dcamera_sink_load_callback.cpp | 14 +++++++------- .../camera_source/src/dcamera_source_handler.cpp | 3 --- .../src/dcamera_source_load_callback.cpp | 14 ++++++-------- 4 files changed, 15 insertions(+), 21 deletions(-) diff --git a/interfaces/inner_kits/native_cpp/camera_sink/src/dcamera_sink_handler.cpp b/interfaces/inner_kits/native_cpp/camera_sink/src/dcamera_sink_handler.cpp index 949835d4..dd5f8828 100644 --- a/interfaces/inner_kits/native_cpp/camera_sink/src/dcamera_sink_handler.cpp +++ b/interfaces/inner_kits/native_cpp/camera_sink/src/dcamera_sink_handler.cpp @@ -36,7 +36,7 @@ DCameraSinkHandler::~DCameraSinkHandler() int32_t DCameraSinkHandler::InitSink(const std::string& params) { DHLOGI("DCameraSinkHandler::InitSink"); - sptr loadCallback = new DcameraSinkLoadCallback(params); + sptr loadCallback = new DCameraSinkLoadCallback(params); sptr sm = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); if (sm == nullptr) { DHLOGE("GetSourceLocalDHMS GetSystemAbilityManager failed"); @@ -47,7 +47,6 @@ int32_t DCameraSinkHandler::InitSink(const std::string& params) DHLOGE("systemAbilityId: %d load filed,result code: %d.", DISTRIBUTED_HARDWARE_CAMERA_SINK_SA_ID, ret); return DCAMERA_INIT_ERR; } - //设置延时1分钟 uint32_t interval = 1; std::unique_lock lock(producerMutex_); producerCon_.wait_for(lock, std::chrono::minutes(interval), [this] { @@ -68,7 +67,7 @@ void DCameraSinkHandler::FinishStartSA(const std::string ¶ms) sptr dCameraSinkSrv = DCameraSinkHandlerIpc::GetInstance().GetSinkLocalDHMS(); if (dCameraSinkSrv == nullptr) { DHLOGE("DCameraSinkHandler::InitSink get Service failed"); - return DCAMERA_INIT_ERR; + return; } dCameraSinkSrv->InitSink(params); } diff --git a/interfaces/inner_kits/native_cpp/camera_sink/src/dcamera_sink_load_callback.cpp b/interfaces/inner_kits/native_cpp/camera_sink/src/dcamera_sink_load_callback.cpp index db6f884c..d0faf643 100644 --- a/interfaces/inner_kits/native_cpp/camera_sink/src/dcamera_sink_load_callback.cpp +++ b/interfaces/inner_kits/native_cpp/camera_sink/src/dcamera_sink_load_callback.cpp @@ -14,7 +14,7 @@ */ #include "dcamera_sink_load_callback.h" #include "dcamera_sink_handler.h" -#include "distributed_hardware_log" +#include "distributed_hardware_log.h" #include "distributed_camera_constants.h" namespace OHOS { @@ -23,9 +23,9 @@ DCameraSinkLoadCallback::DCameraSinkLoadCallback(const std::string params) : par void DCameraSinkLoadCallback::OnLoadSystemAbilitySuccess(int32_t systemAbilityId, const sptr& remoteObject) { - if(systemAbilityId != DISTRIBUTED_HARDWARE_CAMERA_SINK_SA_ID) { - DHLOGE("start aystemabilityId is not sinkSAId!"); - return; + if (systemAbilityId != DISTRIBUTED_HARDWARE_CAMERA_SINK_SA_ID) { + DHLOGE("start aystemabilityId is not sinkSAId!"); + return; } DHLOGE("OnLoadSystemAbilitySuccess systemAbilityId: %d, IRmoteObject result: %s", systemAbilityId, (remoteObject != nullptr) ? "true" : "false"); @@ -39,9 +39,9 @@ void DCameraSinkLoadCallback::OnLoadSystemAbilitySuccess(int32_t systemAbilityId void DCameraSinkLoadCallback::OnLoadSystemAbilityFail(int32_t systemAbilityId) { DHLOGE("OnLoadSystemAbilityFail systemAbilityId: %d.", systemAbilityId); - if(systemAbilityId != DISTRIBUTED_HARDWARE_CAMERA_SINK_SA_ID) { - DHLOGE("start aystemabilityId is not sinkSAId!"); - return; + if (systemAbilityId != DISTRIBUTED_HARDWARE_CAMERA_SINK_SA_ID) { + DHLOGE("start aystemabilityId is not sinkSAId!"); + return; } DCameraSinkHandler::GetInstance().FinishStartSAFailed(systemAbilityId); } diff --git a/interfaces/inner_kits/native_cpp/camera_source/src/dcamera_source_handler.cpp b/interfaces/inner_kits/native_cpp/camera_source/src/dcamera_source_handler.cpp index 72702150..5c49a087 100644 --- a/interfaces/inner_kits/native_cpp/camera_source/src/dcamera_source_handler.cpp +++ b/interfaces/inner_kits/native_cpp/camera_source/src/dcamera_source_handler.cpp @@ -38,7 +38,6 @@ DCameraSourceHandler::~DCameraSourceHandler() int32_t DCameraSourceHandler::InitSource(const std::string& params) { DHLOGI("DCameraSourceHandler InitSource Start"); - //通过samanage通知拉起sa。 sptr loadCallback = new DCameraSourceLoadCallback(params); sptr sm = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); if (sm == nullptr) { @@ -50,7 +49,6 @@ int32_t DCameraSourceHandler::InitSource(const std::string& params) DHLOGE("systemAbilityId: %d load filed,result code: %d.", DISTRIBUTED_HARDWARE_CAMERA_SINK_SA_ID, ret); return DCAMERA_INIT_ERR; } - //设置延时1分钟 uint32_t interval = 1; std::unique_lock lock(producerMutex_); producerCon_.wait_for(lock, std::chrono::minutes(interval), [this] { @@ -66,7 +64,6 @@ int32_t DCameraSourceHandler::InitSource(const std::string& params) void DCameraSourceHandler::FinishStartSA(const std::string ¶ms, const sptr &remoteObject) { - //设置sa的状态 state_ = DCAMERA_SA_STATE_START; DCameraSourceHandlerIpc::GetInstance().Init(); sptr dCameraSourceSrc = DCameraSourceHandlerIpc::GetInstance().GetSourceLocalDHMS(); diff --git a/interfaces/inner_kits/native_cpp/camera_source/src/dcamera_source_load_callback.cpp b/interfaces/inner_kits/native_cpp/camera_source/src/dcamera_source_load_callback.cpp index 9fe8e698..819c4502 100644 --- a/interfaces/inner_kits/native_cpp/camera_source/src/dcamera_source_load_callback.cpp +++ b/interfaces/inner_kits/native_cpp/camera_source/src/dcamera_source_load_callback.cpp @@ -19,15 +19,13 @@ namespace OHOS { namespace DistributedHardware { - DCameraSourceLoadCallback::DCameraSourceLoadCallback(const std::string params) : params(params) {} - void DCameraSourceLoadCallback::OnLoadSystemAbilitySuccess(int32_t systemAbilityId, const sptr& remoteObject) { - if(systemAbilityId != DISTRIBUTED_HARDWARE_CAMERA_SOURCE_SA_ID) { - DHLOGE("start systemabilityId is not sourceSAId!"); - return; + if (systemAbilityId != DISTRIBUTED_HARDWARE_CAMERA_SOURCE_SA_ID) { + DHLOGE("start systemabilityId is not sourceSAId!"); + return; } DHLOGE("OnLoadSystemAbilitySuccess systemAbilityId: %d, IRmoteObject result: %s", systemAbilityId, (remoteObject != nullptr) ? "true" : "false"); @@ -41,9 +39,9 @@ void DCameraSourceLoadCallback::OnLoadSystemAbilitySuccess(int32_t systemAbility void DCameraSourceLoadCallback::OnLoadSystemAbilityFail(int32_t systemAbilityId) { DHLOGE("OnLoadSystemAbilityFail systemAbilityId: %d.", systemAbilityId); - if(systemAbilityId != DISTRIBUTED_HARDWARE_CAMERA_SOURCE_SA_ID) { - DHLOGE("start systemabilityId is not sourceSAId!"); - return; + if (systemAbilityId != DISTRIBUTED_HARDWARE_CAMERA_SOURCE_SA_ID) { + DHLOGE("start systemabilityId is not sourceSAId!"); + return; } DCameraSourceHandler::GetInstance().FinishStartSAFailed(systemAbilityId); } -- Gitee From c98d611d1bb89a0b1e1689755082093c557af3cf Mon Sep 17 00:00:00 2001 From: wangchaole Date: Tue, 12 Apr 2022 18:56:49 +0800 Subject: [PATCH 10/18] =?UTF-8?q?=E5=88=86=E5=B8=83=E5=BC=8F=E7=9B=B8?= =?UTF-8?q?=E6=9C=BA=E6=8C=89=E9=9C=80=E5=90=AF=E5=8A=A8SA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangchaole --- .../native_cpp/camera_source/src/dcamera_source_handler.cpp | 2 +- .../camera_source/src/dcamera_source_load_callback.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/interfaces/inner_kits/native_cpp/camera_source/src/dcamera_source_handler.cpp b/interfaces/inner_kits/native_cpp/camera_source/src/dcamera_source_handler.cpp index 5c49a087..c4c7f5d2 100644 --- a/interfaces/inner_kits/native_cpp/camera_source/src/dcamera_source_handler.cpp +++ b/interfaces/inner_kits/native_cpp/camera_source/src/dcamera_source_handler.cpp @@ -79,7 +79,7 @@ void DCameraSourceHandler::FinishStartSA(const std::string ¶ms, const sptrInitSource(params, callback_); if ((!dCameraSourceSrc) || (!dCameraSourceSrc->AsObject())) { - DHLOGE("Failed to get dscreen source proxy.") + DHLOGE("Failed to get dscreen source proxy."); return; } } diff --git a/interfaces/inner_kits/native_cpp/camera_source/src/dcamera_source_load_callback.cpp b/interfaces/inner_kits/native_cpp/camera_source/src/dcamera_source_load_callback.cpp index 819c4502..32bbed71 100644 --- a/interfaces/inner_kits/native_cpp/camera_source/src/dcamera_source_load_callback.cpp +++ b/interfaces/inner_kits/native_cpp/camera_source/src/dcamera_source_load_callback.cpp @@ -14,7 +14,7 @@ */ #include "dcamera_source_load_callback.h" #include "dcamera_source_handler.h" -#include "distributed_hardware_log" +#include "distributed_hardware_log.h" #include "distributed_camera_constants.h" namespace OHOS { -- Gitee From f3756d93db77394224d2af2a0baad7b47d91da0f Mon Sep 17 00:00:00 2001 From: wangchaole Date: Tue, 12 Apr 2022 19:28:26 +0800 Subject: [PATCH 11/18] =?UTF-8?q?=E5=88=86=E5=B8=83=E5=BC=8F=E7=9B=B8?= =?UTF-8?q?=E6=9C=BA=E6=8C=89=E9=9C=80=E5=90=AF=E5=8A=A8SA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangchaole --- .../native_cpp/camera_source/src/dcamera_source_handler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interfaces/inner_kits/native_cpp/camera_source/src/dcamera_source_handler.cpp b/interfaces/inner_kits/native_cpp/camera_source/src/dcamera_source_handler.cpp index c4c7f5d2..0c7001bf 100644 --- a/interfaces/inner_kits/native_cpp/camera_source/src/dcamera_source_handler.cpp +++ b/interfaces/inner_kits/native_cpp/camera_source/src/dcamera_source_handler.cpp @@ -77,7 +77,7 @@ void DCameraSourceHandler::FinishStartSA(const std::string ¶ms, const sptrInitSource(params, callback_); + dCameraSourceSrc->InitSource(params, callback_); if ((!dCameraSourceSrc) || (!dCameraSourceSrc->AsObject())) { DHLOGE("Failed to get dscreen source proxy."); return; -- Gitee From 71162bf636d72a2be2918f24ac7c94368cb09a97 Mon Sep 17 00:00:00 2001 From: wangchaole Date: Tue, 12 Apr 2022 20:44:57 +0800 Subject: [PATCH 12/18] =?UTF-8?q?=E5=88=86=E5=B8=83=E5=BC=8F=E7=9B=B8?= =?UTF-8?q?=E6=9C=BA=E6=8C=89=E9=9C=80=E5=90=AF=E5=8A=A8SA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangchaole --- .../camera_sink/src/dcamera_sink_handler.cpp | 9 ++++++--- .../native_cpp/camera_source/BUILD.gn | 2 +- .../include/dcamera_source_handler.h | 2 +- .../src/dcamera_source_handler.cpp | 19 +++++++++---------- services/cameraservice/sourceservice/BUILD.gn | 5 ++++- 5 files changed, 21 insertions(+), 16 deletions(-) diff --git a/interfaces/inner_kits/native_cpp/camera_sink/src/dcamera_sink_handler.cpp b/interfaces/inner_kits/native_cpp/camera_sink/src/dcamera_sink_handler.cpp index dd5f8828..00a849e9 100644 --- a/interfaces/inner_kits/native_cpp/camera_sink/src/dcamera_sink_handler.cpp +++ b/interfaces/inner_kits/native_cpp/camera_sink/src/dcamera_sink_handler.cpp @@ -57,12 +57,11 @@ int32_t DCameraSinkHandler::InitSink(const std::string& params) return DCAMERA_INIT_ERR; } DHLOGI("DCameraSinkHandler InitSink end, result: %d", ret); - return ret; + return DCAMERA_OK; } void DCameraSinkHandler::FinishStartSA(const std::string ¶ms) { - state_ = DCAMERA_SA_STATE_START; DCameraSinkHandlerIpc::GetInstance().Init(); sptr dCameraSinkSrv = DCameraSinkHandlerIpc::GetInstance().GetSinkLocalDHMS(); if (dCameraSinkSrv == nullptr) { @@ -70,11 +69,16 @@ void DCameraSinkHandler::FinishStartSA(const std::string ¶ms) return; } dCameraSinkSrv->InitSink(params); + std::unique_lock lock(producerMutex_); + state_ = DCAMERA_SA_STATE_START; + producerCon_.notify_one(); } void DCameraSinkHandler::FinishStartSAFailed(int32_t systemAbilityId) { DHLOGI("SinkSA Start failed, systemAbilityId: %d.", systemAbilityId); + std::unique_lock lock(producerMutex_); + state_ = DCAMERA_SA_STATE_STOP; producerCon_.notify_one(); } @@ -94,7 +98,6 @@ int32_t DCameraSinkHandler::ReleaseSink() } DCameraSinkHandlerIpc::GetInstance().UnInit(); - producerCon_.notify_one(); DHLOGI("DCameraSinkHandler::ReleaseSink success"); return DCAMERA_OK; } diff --git a/interfaces/inner_kits/native_cpp/camera_source/BUILD.gn b/interfaces/inner_kits/native_cpp/camera_source/BUILD.gn index ac7d116d..011442db 100644 --- a/interfaces/inner_kits/native_cpp/camera_source/BUILD.gn +++ b/interfaces/inner_kits/native_cpp/camera_source/BUILD.gn @@ -36,8 +36,8 @@ ohos_shared_library("distributed_camera_source_sdk") { "src/callback/dcamera_source_callback_stub.cpp", "src/dcamera_source_handler.cpp", "src/dcamera_source_handler_ipc.cpp", - "src/distributed_camera_source_proxy.cpp", "src/dcamera_source_load_callback.cpp", + "src/distributed_camera_source_proxy.cpp", ] deps = [ diff --git a/interfaces/inner_kits/native_cpp/camera_source/include/dcamera_source_handler.h b/interfaces/inner_kits/native_cpp/camera_source/include/dcamera_source_handler.h index b6b6ddbb..0278578e 100644 --- a/interfaces/inner_kits/native_cpp/camera_source/include/dcamera_source_handler.h +++ b/interfaces/inner_kits/native_cpp/camera_source/include/dcamera_source_handler.h @@ -40,7 +40,7 @@ public: std::shared_ptr callback) override; int32_t ConfigDistributedHardware(const std::string& devId, const std::string& dhId, const std::string& key, const std::string& value) override; - void FinishStartSA(const std::string ¶ms, const sptr &remoteObject); + void FinishStartSA(const std::string ¶ms); void FinishStartSAFailed(int32_t systemAbilityId); private: typedef enum { diff --git a/interfaces/inner_kits/native_cpp/camera_source/src/dcamera_source_handler.cpp b/interfaces/inner_kits/native_cpp/camera_source/src/dcamera_source_handler.cpp index 0c7001bf..ef64130a 100644 --- a/interfaces/inner_kits/native_cpp/camera_source/src/dcamera_source_handler.cpp +++ b/interfaces/inner_kits/native_cpp/camera_source/src/dcamera_source_handler.cpp @@ -59,15 +59,14 @@ int32_t DCameraSourceHandler::InitSource(const std::string& params) return DCAMERA_INIT_ERR; } DHLOGI("DCameraSourceHandler InitSource end, result: %d", ret); - return ret; + return DCAMERA_OK; } -void DCameraSourceHandler::FinishStartSA(const std::string ¶ms, const sptr &remoteObject) +void DCameraSourceHandler::FinishStartSA(const std::string ¶ms) { - state_ = DCAMERA_SA_STATE_START; DCameraSourceHandlerIpc::GetInstance().Init(); - sptr dCameraSourceSrc = DCameraSourceHandlerIpc::GetInstance().GetSourceLocalDHMS(); - if (dCameraSourceSrc == nullptr) { + sptr dCameraSourceSrv = DCameraSourceHandlerIpc::GetInstance().GetSourceLocalDHMS(); + if (dCameraSourceSrv == nullptr) { DHLOGE("DCameraSourceHandler InitSource get Service failed"); return; } @@ -78,15 +77,16 @@ void DCameraSourceHandler::FinishStartSA(const std::string ¶ms, const sptrInitSource(params, callback_); - if ((!dCameraSourceSrc) || (!dCameraSourceSrc->AsObject())) { - DHLOGE("Failed to get dscreen source proxy."); - return; - } + std::unique_lock lock(producerMutex_); + state_ = DCAMERA_SA_STATE_START; + producerCon_.notify_one(); } void DCameraSourceHandler::FinishStartSAFailed(int32_t systemAbilityId) { DHLOGE("SourceSA Start failed, systemAbilityId: %d.", systemAbilityId); + std::unique_lock lock(producerMutex_); + state_ = DCAMERA_SA_STATE_STOP; producerCon_.notify_one(); } @@ -100,7 +100,6 @@ int32_t DCameraSourceHandler::ReleaseSource() } dCameraSourceSrv->ReleaseSource(); DCameraSourceHandlerIpc::GetInstance().UnInit(); - producerCon_.notify_one(); DHLOGI("DCameraSourceHandler ReleaseSource end"); return DCAMERA_OK; } diff --git a/services/cameraservice/sourceservice/BUILD.gn b/services/cameraservice/sourceservice/BUILD.gn index 0c9608b9..f2042b3e 100644 --- a/services/cameraservice/sourceservice/BUILD.gn +++ b/services/cameraservice/sourceservice/BUILD.gn @@ -109,8 +109,11 @@ ohos_shared_library("distributed_camera_source") { "safwk:system_ability_fwk", "samgr_standard:samgr_proxy", ] - part_name = "distributed_camera" + subsystem_name = "distributedhardware" + + part_name = "distributed_camera" + } ohos_prebuilt_etc("dcamerasrc.cfg") { relative_install_dir = "init" -- Gitee From 980badaf014877d8f9fd6d9342d87be2efe5098b Mon Sep 17 00:00:00 2001 From: wangchaole Date: Tue, 12 Apr 2022 21:05:56 +0800 Subject: [PATCH 13/18] =?UTF-8?q?=E5=88=86=E5=B8=83=E5=BC=8F=E7=9B=B8?= =?UTF-8?q?=E6=9C=BA=E6=8C=89=E9=9C=80=E5=90=AF=E5=8A=A8SA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangchaole --- .../native_cpp/camera_source/src/dcamera_source_handler.cpp | 2 +- .../camera_source/src/dcamera_source_load_callback.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/interfaces/inner_kits/native_cpp/camera_source/src/dcamera_source_handler.cpp b/interfaces/inner_kits/native_cpp/camera_source/src/dcamera_source_handler.cpp index ef64130a..244683c5 100644 --- a/interfaces/inner_kits/native_cpp/camera_source/src/dcamera_source_handler.cpp +++ b/interfaces/inner_kits/native_cpp/camera_source/src/dcamera_source_handler.cpp @@ -76,7 +76,7 @@ void DCameraSourceHandler::FinishStartSA(const std::string ¶ms) DHLOGE("DCameraSourceHandler InitSource init callback failed"); return; } - dCameraSourceSrc->InitSource(params, callback_); + dCameraSourceSrv->InitSource(params, callback_); std::unique_lock lock(producerMutex_); state_ = DCAMERA_SA_STATE_START; producerCon_.notify_one(); diff --git a/interfaces/inner_kits/native_cpp/camera_source/src/dcamera_source_load_callback.cpp b/interfaces/inner_kits/native_cpp/camera_source/src/dcamera_source_load_callback.cpp index 32bbed71..eb90e89c 100644 --- a/interfaces/inner_kits/native_cpp/camera_source/src/dcamera_source_load_callback.cpp +++ b/interfaces/inner_kits/native_cpp/camera_source/src/dcamera_source_load_callback.cpp @@ -33,7 +33,7 @@ void DCameraSourceLoadCallback::OnLoadSystemAbilitySuccess(int32_t systemAbility DHLOGE("remoteObject is null."); return; } - DCameraSourceHandler::GetInstance().FinishStartSA(params, remoteObject); + DCameraSourceHandler::GetInstance().FinishStartSA(params); } void DCameraSourceLoadCallback::OnLoadSystemAbilityFail(int32_t systemAbilityId) -- Gitee From 97a7b5e32c12fdeb808228fba2b7920d2cac83a1 Mon Sep 17 00:00:00 2001 From: wangchaole Date: Wed, 13 Apr 2022 12:48:24 +0800 Subject: [PATCH 14/18] =?UTF-8?q?=E5=88=86=E5=B8=83=E5=BC=8F=E7=9B=B8?= =?UTF-8?q?=E6=9C=BA=E6=8C=89=E9=9C=80=E5=90=AF=E5=8A=A8SA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangchaole --- .../native_cpp/camera_sink/src/dcamera_sink_load_callback.cpp | 1 + .../camera_source/src/dcamera_source_load_callback.cpp | 1 + 2 files changed, 2 insertions(+) diff --git a/interfaces/inner_kits/native_cpp/camera_sink/src/dcamera_sink_load_callback.cpp b/interfaces/inner_kits/native_cpp/camera_sink/src/dcamera_sink_load_callback.cpp index d0faf643..998af419 100644 --- a/interfaces/inner_kits/native_cpp/camera_sink/src/dcamera_sink_load_callback.cpp +++ b/interfaces/inner_kits/native_cpp/camera_sink/src/dcamera_sink_load_callback.cpp @@ -23,6 +23,7 @@ DCameraSinkLoadCallback::DCameraSinkLoadCallback(const std::string params) : par void DCameraSinkLoadCallback::OnLoadSystemAbilitySuccess(int32_t systemAbilityId, const sptr& remoteObject) { + DHLOGI("OnLoadSystemAbilitySuccess start systemAbilityId: %d.", systemAbilityId); if (systemAbilityId != DISTRIBUTED_HARDWARE_CAMERA_SINK_SA_ID) { DHLOGE("start aystemabilityId is not sinkSAId!"); return; diff --git a/interfaces/inner_kits/native_cpp/camera_source/src/dcamera_source_load_callback.cpp b/interfaces/inner_kits/native_cpp/camera_source/src/dcamera_source_load_callback.cpp index eb90e89c..fe344ceb 100644 --- a/interfaces/inner_kits/native_cpp/camera_source/src/dcamera_source_load_callback.cpp +++ b/interfaces/inner_kits/native_cpp/camera_source/src/dcamera_source_load_callback.cpp @@ -23,6 +23,7 @@ DCameraSourceLoadCallback::DCameraSourceLoadCallback(const std::string params) : void DCameraSourceLoadCallback::OnLoadSystemAbilitySuccess(int32_t systemAbilityId, const sptr& remoteObject) { + DHLOGI("OnLoadSystemAbilitySuccess start systemAbilityId: %d.", systemAbilityId); if (systemAbilityId != DISTRIBUTED_HARDWARE_CAMERA_SOURCE_SA_ID) { DHLOGE("start systemabilityId is not sourceSAId!"); return; -- Gitee From 19c9e45e6f54cb146eb182480f8fb08a3b0fcc57 Mon Sep 17 00:00:00 2001 From: wangchaole Date: Thu, 14 Apr 2022 10:09:32 +0800 Subject: [PATCH 15/18] =?UTF-8?q?=E5=88=86=E5=B8=83=E5=BC=8F=E7=9B=B8?= =?UTF-8?q?=E6=9C=BA=E6=8C=89=E9=9C=80=E5=90=AF=E5=8A=A8SA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangchaole --- .../camera_source/include/dcamera_source_handler.h | 1 - .../camera_source/src/dcamera_source_handler.cpp | 8 ++++---- services/cameraservice/sinkservice/BUILD.gn | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/interfaces/inner_kits/native_cpp/camera_source/include/dcamera_source_handler.h b/interfaces/inner_kits/native_cpp/camera_source/include/dcamera_source_handler.h index 0278578e..03dec216 100644 --- a/interfaces/inner_kits/native_cpp/camera_source/include/dcamera_source_handler.h +++ b/interfaces/inner_kits/native_cpp/camera_source/include/dcamera_source_handler.h @@ -54,7 +54,6 @@ private: std::mutex optLock_; sptr callback_; std::condition_variable producerCon_; - std::mutex producerMutex_; DCameraSAState state_ = DCAMERA_SA_STATE_STOP; }; diff --git a/interfaces/inner_kits/native_cpp/camera_source/src/dcamera_source_handler.cpp b/interfaces/inner_kits/native_cpp/camera_source/src/dcamera_source_handler.cpp index 244683c5..f4fdab13 100644 --- a/interfaces/inner_kits/native_cpp/camera_source/src/dcamera_source_handler.cpp +++ b/interfaces/inner_kits/native_cpp/camera_source/src/dcamera_source_handler.cpp @@ -51,7 +51,7 @@ int32_t DCameraSourceHandler::InitSource(const std::string& params) } uint32_t interval = 1; std::unique_lock lock(producerMutex_); - producerCon_.wait_for(lock, std::chrono::minutes(interval), [this] { + optLock_.wait_for(lock, std::chrono::minutes(interval), [this] { return (this->state_ == DCAMERA_SA_STATE_START); }); if (state_ == DCAMERA_SA_STATE_STOP) { @@ -77,9 +77,9 @@ void DCameraSourceHandler::FinishStartSA(const std::string ¶ms) return; } dCameraSourceSrv->InitSource(params, callback_); - std::unique_lock lock(producerMutex_); + std::unique_lock lock(optLock_); state_ = DCAMERA_SA_STATE_START; - producerCon_.notify_one(); + optLock_.notify_one(); } void DCameraSourceHandler::FinishStartSAFailed(int32_t systemAbilityId) @@ -87,7 +87,7 @@ void DCameraSourceHandler::FinishStartSAFailed(int32_t systemAbilityId) DHLOGE("SourceSA Start failed, systemAbilityId: %d.", systemAbilityId); std::unique_lock lock(producerMutex_); state_ = DCAMERA_SA_STATE_STOP; - producerCon_.notify_one(); + optLock_.notify_one(); } int32_t DCameraSourceHandler::ReleaseSource() diff --git a/services/cameraservice/sinkservice/BUILD.gn b/services/cameraservice/sinkservice/BUILD.gn index af74befb..c6f00f07 100644 --- a/services/cameraservice/sinkservice/BUILD.gn +++ b/services/cameraservice/sinkservice/BUILD.gn @@ -89,7 +89,7 @@ ohos_shared_library("distributed_camera_sink") { "src/distributedcameramgr/listener/dcamera_sink_output_channel_listener.cpp", ] - if (device_name == "baltimore") { + if ("${product_name}" == "m40") { sources += [ "src/distributedcameramgr/dcamera_sink_data_process.cpp" ] } else { sources += -- Gitee From 1ae4006b75d83825dc7590626da706b089f41f8f Mon Sep 17 00:00:00 2001 From: wangchaole Date: Thu, 14 Apr 2022 11:15:37 +0800 Subject: [PATCH 16/18] =?UTF-8?q?=E5=88=86=E5=B8=83=E5=BC=8F=E7=9B=B8?= =?UTF-8?q?=E6=9C=BA=E6=8C=89=E9=9C=80=E5=90=AF=E5=8A=A8SA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangchaole --- .../native_cpp/camera_source/src/dcamera_source_handler.cpp | 4 ++-- sa_profile/4803.xml | 2 +- sa_profile/4804.xml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/interfaces/inner_kits/native_cpp/camera_source/src/dcamera_source_handler.cpp b/interfaces/inner_kits/native_cpp/camera_source/src/dcamera_source_handler.cpp index f4fdab13..c487a4d7 100644 --- a/interfaces/inner_kits/native_cpp/camera_source/src/dcamera_source_handler.cpp +++ b/interfaces/inner_kits/native_cpp/camera_source/src/dcamera_source_handler.cpp @@ -50,7 +50,7 @@ int32_t DCameraSourceHandler::InitSource(const std::string& params) return DCAMERA_INIT_ERR; } uint32_t interval = 1; - std::unique_lock lock(producerMutex_); + std::unique_lock lock(optLock_); optLock_.wait_for(lock, std::chrono::minutes(interval), [this] { return (this->state_ == DCAMERA_SA_STATE_START); }); @@ -85,7 +85,7 @@ void DCameraSourceHandler::FinishStartSA(const std::string ¶ms) void DCameraSourceHandler::FinishStartSAFailed(int32_t systemAbilityId) { DHLOGE("SourceSA Start failed, systemAbilityId: %d.", systemAbilityId); - std::unique_lock lock(producerMutex_); + std::unique_lock lock(optLock_); state_ = DCAMERA_SA_STATE_STOP; optLock_.notify_one(); } diff --git a/sa_profile/4803.xml b/sa_profile/4803.xml index fb50166a..619eb13b 100644 --- a/sa_profile/4803.xml +++ b/sa_profile/4803.xml @@ -20,7 +20,7 @@ libdistributed_camera_source.z.so - false + true true 1 diff --git a/sa_profile/4804.xml b/sa_profile/4804.xml index a827ae53..0d20abc3 100644 --- a/sa_profile/4804.xml +++ b/sa_profile/4804.xml @@ -20,7 +20,7 @@ libdistributed_camera_sink.z.so - false + true true 1 -- Gitee From 38e38785302e92ae4c00834b4c4ed9d558627f4f Mon Sep 17 00:00:00 2001 From: wangchaole Date: Thu, 14 Apr 2022 11:33:52 +0800 Subject: [PATCH 17/18] =?UTF-8?q?=E5=88=86=E5=B8=83=E5=BC=8F=E7=9B=B8?= =?UTF-8?q?=E6=9C=BA=E6=8C=89=E9=9C=80=E5=90=AF=E5=8A=A8SA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangchaole --- .../camera_source/include/dcamera_source_handler.h | 1 + .../camera_source/src/dcamera_source_handler.cpp | 12 ++++++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/interfaces/inner_kits/native_cpp/camera_source/include/dcamera_source_handler.h b/interfaces/inner_kits/native_cpp/camera_source/include/dcamera_source_handler.h index 03dec216..0278578e 100644 --- a/interfaces/inner_kits/native_cpp/camera_source/include/dcamera_source_handler.h +++ b/interfaces/inner_kits/native_cpp/camera_source/include/dcamera_source_handler.h @@ -54,6 +54,7 @@ private: std::mutex optLock_; sptr callback_; std::condition_variable producerCon_; + std::mutex producerMutex_; DCameraSAState state_ = DCAMERA_SA_STATE_STOP; }; diff --git a/interfaces/inner_kits/native_cpp/camera_source/src/dcamera_source_handler.cpp b/interfaces/inner_kits/native_cpp/camera_source/src/dcamera_source_handler.cpp index c487a4d7..244683c5 100644 --- a/interfaces/inner_kits/native_cpp/camera_source/src/dcamera_source_handler.cpp +++ b/interfaces/inner_kits/native_cpp/camera_source/src/dcamera_source_handler.cpp @@ -50,8 +50,8 @@ int32_t DCameraSourceHandler::InitSource(const std::string& params) return DCAMERA_INIT_ERR; } uint32_t interval = 1; - std::unique_lock lock(optLock_); - optLock_.wait_for(lock, std::chrono::minutes(interval), [this] { + std::unique_lock lock(producerMutex_); + producerCon_.wait_for(lock, std::chrono::minutes(interval), [this] { return (this->state_ == DCAMERA_SA_STATE_START); }); if (state_ == DCAMERA_SA_STATE_STOP) { @@ -77,17 +77,17 @@ void DCameraSourceHandler::FinishStartSA(const std::string ¶ms) return; } dCameraSourceSrv->InitSource(params, callback_); - std::unique_lock lock(optLock_); + std::unique_lock lock(producerMutex_); state_ = DCAMERA_SA_STATE_START; - optLock_.notify_one(); + producerCon_.notify_one(); } void DCameraSourceHandler::FinishStartSAFailed(int32_t systemAbilityId) { DHLOGE("SourceSA Start failed, systemAbilityId: %d.", systemAbilityId); - std::unique_lock lock(optLock_); + std::unique_lock lock(producerMutex_); state_ = DCAMERA_SA_STATE_STOP; - optLock_.notify_one(); + producerCon_.notify_one(); } int32_t DCameraSourceHandler::ReleaseSource() -- Gitee From ffa024cb348c0212924bbd5ac2d323418315aa8b Mon Sep 17 00:00:00 2001 From: wangchaole Date: Thu, 14 Apr 2022 16:52:05 +0800 Subject: [PATCH 18/18] =?UTF-8?q?=E5=88=86=E5=B8=83=E5=BC=8F=E7=9B=B8?= =?UTF-8?q?=E6=9C=BA=E6=8C=89=E9=9C=80=E5=90=AF=E5=8A=A8SA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangchaole --- sa_profile/4803.xml | 2 +- sa_profile/4804.xml | 2 +- services/cameraservice/sinkservice/dcamerasink.cfg | 1 - services/cameraservice/sourceservice/dcamerasrc.cfg | 1 - 4 files changed, 2 insertions(+), 4 deletions(-) diff --git a/sa_profile/4803.xml b/sa_profile/4803.xml index 619eb13b..fb50166a 100644 --- a/sa_profile/4803.xml +++ b/sa_profile/4803.xml @@ -20,7 +20,7 @@ libdistributed_camera_source.z.so - true + false true 1 diff --git a/sa_profile/4804.xml b/sa_profile/4804.xml index 0d20abc3..a827ae53 100644 --- a/sa_profile/4804.xml +++ b/sa_profile/4804.xml @@ -20,7 +20,7 @@ libdistributed_camera_sink.z.so - true + false true 1 diff --git a/services/cameraservice/sinkservice/dcamerasink.cfg b/services/cameraservice/sinkservice/dcamerasink.cfg index 7ed7633d..ff208b80 100644 --- a/services/cameraservice/sinkservice/dcamerasink.cfg +++ b/services/cameraservice/sinkservice/dcamerasink.cfg @@ -1,7 +1,6 @@ { "services" : [{ "name" : "dcamerasink", - "dynamic" : true, "path" : ["/system/bin/sa_main","/system/profile/dcamerasink.xml"], "uid" : "system", "gid" : ["system"], diff --git a/services/cameraservice/sourceservice/dcamerasrc.cfg b/services/cameraservice/sourceservice/dcamerasrc.cfg index dddfbef8..74a11980 100644 --- a/services/cameraservice/sourceservice/dcamerasrc.cfg +++ b/services/cameraservice/sourceservice/dcamerasrc.cfg @@ -1,7 +1,6 @@ { "services" : [{ "name" : "dcamerasrc", - "dynamic" : true, "path" : ["/system/bin/sa_main","/system/profile/dcamerasrc.xml"], "uid" : "system", "gid" : ["system"], -- Gitee