From 80f0236842c4d36cc5da3aa74cdec9c0655ffdc7 Mon Sep 17 00:00:00 2001 From: wangchaole Date: Wed, 20 Apr 2022 09:17:14 +0800 Subject: [PATCH 01/15] =?UTF-8?q?=E5=8A=A8=E6=80=81=E6=8B=89=E8=B5=B7SA?= 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 | 45 ++++++++++++++++- .../src/dcamera_sink_load_callback.cpp | 50 +++++++++++++++++++ .../native_cpp/camera_source/BUILD.gn | 1 + .../include/dcamera_source_handler.h | 11 +++- .../include/dcamera_source_load_callback.h | 33 ++++++++++++ .../src/dcamera_source_handler.cpp | 49 ++++++++++++++++-- .../src/dcamera_source_load_callback.cpp | 50 +++++++++++++++++++ sa_profile/4803.xml | 4 +- sa_profile/4804.xml | 4 +- services/cameraservice/sinkservice/BUILD.gn | 8 +++ .../cameraservice/sinkservice/dcamerasink.cfg | 9 ++++ services/cameraservice/sourceservice/BUILD.gn | 8 +++ .../sourceservice/dcamerasrc.cfg | 9 ++++ 16 files changed, 316 insertions(+), 13 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 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_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..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 @@ -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,50 @@ 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; + } + 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 DCAMERA_OK; +} + +void DCameraSinkHandler::FinishStartSA(const std::string ¶ms) +{ DCameraSinkHandlerIpc::GetInstance().Init(); sptr dCameraSinkSrv = DCameraSinkHandlerIpc::GetInstance().GetSinkLocalDHMS(); if (dCameraSinkSrv == nullptr) { DHLOGE("DCameraSinkHandler::InitSink get Service failed"); - return DCAMERA_INIT_ERR; + return; } - return dCameraSinkSrv->InitSink(params); + 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(); } int32_t DCameraSinkHandler::ReleaseSink() 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..998af419 --- /dev/null +++ b/interfaces/inner_kits/native_cpp/camera_sink/src/dcamera_sink_load_callback.cpp @@ -0,0 +1,50 @@ +/* + * 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.h" +#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) +{ + DHLOGI("OnLoadSystemAbilitySuccess start systemAbilityId: %d.", systemAbilityId); + 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 50cc17a1..011442db 100644 --- a/interfaces/inner_kits/native_cpp/camera_source/BUILD.gn +++ b/interfaces/inner_kits/native_cpp/camera_source/BUILD.gn @@ -36,6 +36,7 @@ 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/dcamera_source_load_callback.cpp", "src/distributed_camera_source_proxy.cpp", ] 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..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 @@ -17,6 +17,7 @@ #define OHOS_DCAMERA_SOURCE_HANDLER_H #include +#include #include "iremote_proxy.h" #include "iremote_broker.h" @@ -39,14 +40,22 @@ 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); + 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 new file mode 100644 index 00000000..05f4d347 --- /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..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 @@ -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,21 +38,56 @@ DCameraSourceHandler::~DCameraSourceHandler() int32_t DCameraSourceHandler::InitSource(const std::string& params) { DHLOGI("DCameraSourceHandler InitSource Start"); + sptr loadCallback = new DCameraSourceLoadCallback(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_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; + } + 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("SourceSA Start failed!"); + return DCAMERA_INIT_ERR; + } + DHLOGI("DCameraSourceHandler InitSource end, result: %d", ret); + return DCAMERA_OK; +} + +void DCameraSourceHandler::FinishStartSA(const std::string ¶ms) +{ DCameraSourceHandlerIpc::GetInstance().Init(); sptr dCameraSourceSrv = DCameraSourceHandlerIpc::GetInstance().GetSourceLocalDHMS(); if (dCameraSourceSrv == nullptr) { DHLOGE("DCameraSourceHandler InitSource get Service failed"); - return DCAMERA_INIT_ERR; + return; } callback_ = new DCameraSourceCallback(); if (callback_ == nullptr) { DHLOGE("DCameraSourceHandler InitSource init callback failed"); - return DCAMERA_INIT_ERR; + return; } - int32_t ret = dCameraSourceSrv->InitSource(params, callback_); - DHLOGI("DCameraSourceHandler InitSource end, ret: %d", ret); - return ret; + dCameraSourceSrv->InitSource(params, callback_); + 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(); } int32_t DCameraSourceHandler::ReleaseSource() 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..fe344ceb --- /dev/null +++ b/interfaces/inner_kits/native_cpp/camera_source/src/dcamera_source_load_callback.cpp @@ -0,0 +1,50 @@ +/* + * 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.h" +#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) +{ + DHLOGI("OnLoadSystemAbilitySuccess start systemAbilityId: %d.", systemAbilityId); + 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); +} + +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/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 7a27e231..c6f00f07 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", + ":dcamerasink.cfg", ] defines = [ @@ -127,4 +128,11 @@ ohos_shared_library("distributed_camera_sink") { subsystem_name = "distributedhardware" part_name = "distributed_camera" + } +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 new file mode 100644 index 00000000..ff208b80 --- /dev/null +++ b/services/cameraservice/sinkservice/dcamerasink.cfg @@ -0,0 +1,9 @@ +{ + "services" : [{ + "name" : "dcamerasink", + "path" : ["/system/bin/sa_main","/system/profile/dcamerasink.xml"], + "uid" : "system", + "gid" : ["system"], + "ondemand" : true + }] +} \ No newline at end of file diff --git a/services/cameraservice/sourceservice/BUILD.gn b/services/cameraservice/sourceservice/BUILD.gn index 8f53c80d..f2042b3e 100644 --- a/services/cameraservice/sourceservice/BUILD.gn +++ b/services/cameraservice/sourceservice/BUILD.gn @@ -93,6 +93,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 = [ @@ -112,4 +113,11 @@ ohos_shared_library("distributed_camera_source") { 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" +} \ No newline at end of file diff --git a/services/cameraservice/sourceservice/dcamerasrc.cfg b/services/cameraservice/sourceservice/dcamerasrc.cfg new file mode 100644 index 00000000..74a11980 --- /dev/null +++ b/services/cameraservice/sourceservice/dcamerasrc.cfg @@ -0,0 +1,9 @@ +{ + "services" : [{ + "name" : "dcamerasrc", + "path" : ["/system/bin/sa_main","/system/profile/dcamerasrc.xml"], + "uid" : "system", + "gid" : ["system"], + "ondemand" : true + }] +} \ No newline at end of file -- Gitee From 70d1b9ceebf21185f556fa309b1c8d7d49bfee56 Mon Sep 17 00:00:00 2001 From: wangchaole Date: Wed, 20 Apr 2022 09:27:20 +0800 Subject: [PATCH 02/15] =?UTF-8?q?=E5=8A=A8=E6=80=81=E6=8B=89=E8=B5=B7SA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangchaole --- .../camera_source/src/distributed_camera_source_proxy.cpp | 2 +- .../src/distributedcamera/distributed_camera_sink_service.cpp | 1 + .../src/distributedcamera/distributed_camera_source_service.cpp | 2 ++ 3 files changed, 4 insertions(+), 1 deletion(-) 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/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/src/distributedcamera/distributed_camera_source_service.cpp b/services/cameraservice/sourceservice/src/distributedcamera/distributed_camera_source_service.cpp index e0ea205c..a7196fc4 100644 --- a/services/cameraservice/sourceservice/src/distributedcamera/distributed_camera_source_service.cpp +++ b/services/cameraservice/sourceservice/src/distributedcamera/distributed_camera_source_service.cpp @@ -23,6 +23,7 @@ #include "system_ability_definition.h" #include "anonymous_string.h" +#include "dcamera_service_state_listener.h" #include "dcamera_source_service_ipc.h" #include "distributed_camera_errno.h" #include "distributed_hardware_log.h" @@ -101,6 +102,7 @@ int32_t DistributedCameraSourceService::ReleaseSource() return ret; } listener_ = nullptr; + exit(0); return DCAMERA_OK; } -- Gitee From 5b0c4ae124e74c0a26154f97404e1fd35d191f15 Mon Sep 17 00:00:00 2001 From: wangchaole Date: Wed, 20 Apr 2022 10:27:47 +0800 Subject: [PATCH 03/15] =?UTF-8?q?=E5=8A=A8=E6=80=81=E6=8B=89=E8=B5=B7SA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangchaole --- bundle.json | 1 + common/include/constants/distributed_camera_constants.h | 2 +- sa_profile/4804.xml | 2 +- sa_profile/BUILD.gn | 6 ++++++ .../dcamerasrc.cfg => sa_profile/dcamera.cfg | 0 services/cameraservice/sinkservice/BUILD.gn | 8 -------- services/cameraservice/sinkservice/dcamerasink.cfg | 9 --------- services/cameraservice/sourceservice/BUILD.gn | 8 -------- services/channel/include/dcamera_softbus_adapter.h | 2 +- 9 files changed, 10 insertions(+), 28 deletions(-) rename services/cameraservice/sourceservice/dcamerasrc.cfg => sa_profile/dcamera.cfg (100%) delete mode 100644 services/cameraservice/sinkservice/dcamerasink.cfg diff --git a/bundle.json b/bundle.json index dfcb1b63..1450c5d7 100644 --- a/bundle.json +++ b/bundle.json @@ -56,6 +56,7 @@ "//foundation/distributedhardware/distributedcamera/services/cameraservice/sourceservice:distributed_camera_source", "//foundation/distributedhardware/distributedcamera/services/data_process:distributed_camera_data_process", "//foundation/distributedhardware/distributedcamera/sa_profile:dcamera_sa_profile", + "//foundation/distributedhardware/distributedcamera/sa_profile:dcamera.cfg", "//foundation/distributedhardware/distributedcamera/services/channel:distributed_camera_channel", "//foundation/distributedhardware/distributedcamera/camera_hdf/interfaces/hdi_ipc/config/host:distributed_camera_host_config", "//foundation/distributedhardware/distributedcamera/camera_hdf/interfaces/hdi_ipc/config/provider:distributed_camera_provider_config", diff --git a/common/include/constants/distributed_camera_constants.h b/common/include/constants/distributed_camera_constants.h index d89ffa24..5c60ea74 100644 --- a/common/include/constants/distributed_camera_constants.h +++ b/common/include/constants/distributed_camera_constants.h @@ -74,7 +74,7 @@ const uint32_t DCAMERA_PRODUCER_FPS_DEFAULT = 30; const uint32_t DCAMERA_MAX_RECV_DATA_LEN = 104857600; const uint32_t DISTRIBUTED_HARDWARE_CAMERA_SOURCE_SA_ID = 4803; const uint32_t DISTRIBUTED_HARDWARE_CAMERA_SINK_SA_ID = 4804; -const std::string DCAMERA_PKG_NAME = "ohos.dhardware"; +const std::string DCAMERA_PKG_NAME = "ohos.dhardware.dcamera"; const std::string SNAP_SHOT_SESSION_FLAG = "dataSnapshot"; const std::string CONTINUE_SESSION_FLAG = "dataContinue"; diff --git a/sa_profile/4804.xml b/sa_profile/4804.xml index a827ae53..22277134 100644 --- a/sa_profile/4804.xml +++ b/sa_profile/4804.xml @@ -14,7 +14,7 @@ * limitations under the License. --> - dcamerasink + dcamera 4804 libdistributed_camera_sink.z.so diff --git a/sa_profile/BUILD.gn b/sa_profile/BUILD.gn index 8d10ac4f..ed391eba 100644 --- a/sa_profile/BUILD.gn +++ b/sa_profile/BUILD.gn @@ -21,3 +21,9 @@ ohos_sa_profile("dcamera_sa_profile") { part_name = "distributed_camera" } +ohos_prebuilt_etc("dcamera.cfg") { + relative_install_dir = "init" + source = "dcamera.cfg" + part_name = "distributed_camera" + subsystem_name = "distributedhardware" +} \ No newline at end of file diff --git a/services/cameraservice/sourceservice/dcamerasrc.cfg b/sa_profile/dcamera.cfg similarity index 100% rename from services/cameraservice/sourceservice/dcamerasrc.cfg rename to sa_profile/dcamera.cfg diff --git a/services/cameraservice/sinkservice/BUILD.gn b/services/cameraservice/sinkservice/BUILD.gn index c6f00f07..6a296279 100644 --- a/services/cameraservice/sinkservice/BUILD.gn +++ b/services/cameraservice/sinkservice/BUILD.gn @@ -108,7 +108,6 @@ ohos_shared_library("distributed_camera_sink") { "${services_path}/data_process:distributed_camera_data_process", "//third_party/jsoncpp:jsoncpp", "//utils/native/base:utils", - ":dcamerasink.cfg", ] defines = [ @@ -128,11 +127,4 @@ ohos_shared_library("distributed_camera_sink") { subsystem_name = "distributedhardware" part_name = "distributed_camera" - -} -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 deleted file mode 100644 index ff208b80..00000000 --- a/services/cameraservice/sinkservice/dcamerasink.cfg +++ /dev/null @@ -1,9 +0,0 @@ -{ - "services" : [{ - "name" : "dcamerasink", - "path" : ["/system/bin/sa_main","/system/profile/dcamerasink.xml"], - "uid" : "system", - "gid" : ["system"], - "ondemand" : true - }] -} \ No newline at end of file diff --git a/services/cameraservice/sourceservice/BUILD.gn b/services/cameraservice/sourceservice/BUILD.gn index f2042b3e..270baf68 100644 --- a/services/cameraservice/sourceservice/BUILD.gn +++ b/services/cameraservice/sourceservice/BUILD.gn @@ -93,7 +93,6 @@ 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 = [ @@ -113,11 +112,4 @@ ohos_shared_library("distributed_camera_source") { 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" } \ No newline at end of file diff --git a/services/channel/include/dcamera_softbus_adapter.h b/services/channel/include/dcamera_softbus_adapter.h index c104f563..999838f2 100644 --- a/services/channel/include/dcamera_softbus_adapter.h +++ b/services/channel/include/dcamera_softbus_adapter.h @@ -73,7 +73,7 @@ private: private: std::mutex optLock_; - const string PKG_NAME = "ohos.dhardware"; + const string PKG_NAME = "ohos.dhardware.dcamera"; static const uint32_t DCAMERA_SESSION_NAME_MAX_LEN = 128; map sessListeners_; std::map sessionTotal_; -- Gitee From fe03631ccf69d3027d0c19f2fecf3b242bccd326 Mon Sep 17 00:00:00 2001 From: wangchaole Date: Wed, 20 Apr 2022 10:31:13 +0800 Subject: [PATCH 04/15] =?UTF-8?q?=E5=8A=A8=E6=80=81=E6=8B=89=E8=B5=B7SA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangchaole --- .../src/distributedcamera/distributed_camera_source_service.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 a7196fc4..2236c6ac 100644 --- a/services/cameraservice/sourceservice/src/distributedcamera/distributed_camera_source_service.cpp +++ b/services/cameraservice/sourceservice/src/distributedcamera/distributed_camera_source_service.cpp @@ -102,7 +102,7 @@ int32_t DistributedCameraSourceService::ReleaseSource() return ret; } listener_ = nullptr; - exit(0); + exit(0); return DCAMERA_OK; } -- Gitee From d1c9e1c14fb795e500586947587bfb897515281a Mon Sep 17 00:00:00 2001 From: wangchaole Date: Wed, 20 Apr 2022 11:17:47 +0800 Subject: [PATCH 05/15] =?UTF-8?q?=E5=8A=A8=E6=80=81=E6=8B=89=E8=B5=B7SA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangchaole --- bundle.json | 1 - sa_profile/BUILD.gn | 4 +++- sa_profile/dcamera.cfg | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/bundle.json b/bundle.json index 1450c5d7..dfcb1b63 100644 --- a/bundle.json +++ b/bundle.json @@ -56,7 +56,6 @@ "//foundation/distributedhardware/distributedcamera/services/cameraservice/sourceservice:distributed_camera_source", "//foundation/distributedhardware/distributedcamera/services/data_process:distributed_camera_data_process", "//foundation/distributedhardware/distributedcamera/sa_profile:dcamera_sa_profile", - "//foundation/distributedhardware/distributedcamera/sa_profile:dcamera.cfg", "//foundation/distributedhardware/distributedcamera/services/channel:distributed_camera_channel", "//foundation/distributedhardware/distributedcamera/camera_hdf/interfaces/hdi_ipc/config/host:distributed_camera_host_config", "//foundation/distributedhardware/distributedcamera/camera_hdf/interfaces/hdi_ipc/config/provider:distributed_camera_provider_config", diff --git a/sa_profile/BUILD.gn b/sa_profile/BUILD.gn index ed391eba..9daa3aa8 100644 --- a/sa_profile/BUILD.gn +++ b/sa_profile/BUILD.gn @@ -18,7 +18,9 @@ ohos_sa_profile("dcamera_sa_profile") { "4803.xml", "4804.xml", ] - + deps = [ + :dcamera.cfg, + ] part_name = "distributed_camera" } ohos_prebuilt_etc("dcamera.cfg") { diff --git a/sa_profile/dcamera.cfg b/sa_profile/dcamera.cfg index 74a11980..2f92f47f 100644 --- a/sa_profile/dcamera.cfg +++ b/sa_profile/dcamera.cfg @@ -1,7 +1,7 @@ { "services" : [{ - "name" : "dcamerasrc", - "path" : ["/system/bin/sa_main","/system/profile/dcamerasrc.xml"], + "name" : "dcamera", + "path" : ["/system/bin/sa_main","/system/profile/dcamera.xml"], "uid" : "system", "gid" : ["system"], "ondemand" : true -- Gitee From 1118dc181f4508d3fda920796adc16a11d4ce162 Mon Sep 17 00:00:00 2001 From: wangchaole Date: Wed, 20 Apr 2022 11:33:54 +0800 Subject: [PATCH 06/15] =?UTF-8?q?=E5=8A=A8=E6=80=81=E6=8B=89=E8=B5=B7SA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangchaole --- bundle.json | 1 + sa_profile/BUILD.gn | 4 +--- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/bundle.json b/bundle.json index dfcb1b63..1450c5d7 100644 --- a/bundle.json +++ b/bundle.json @@ -56,6 +56,7 @@ "//foundation/distributedhardware/distributedcamera/services/cameraservice/sourceservice:distributed_camera_source", "//foundation/distributedhardware/distributedcamera/services/data_process:distributed_camera_data_process", "//foundation/distributedhardware/distributedcamera/sa_profile:dcamera_sa_profile", + "//foundation/distributedhardware/distributedcamera/sa_profile:dcamera.cfg", "//foundation/distributedhardware/distributedcamera/services/channel:distributed_camera_channel", "//foundation/distributedhardware/distributedcamera/camera_hdf/interfaces/hdi_ipc/config/host:distributed_camera_host_config", "//foundation/distributedhardware/distributedcamera/camera_hdf/interfaces/hdi_ipc/config/provider:distributed_camera_provider_config", diff --git a/sa_profile/BUILD.gn b/sa_profile/BUILD.gn index 9daa3aa8..ed391eba 100644 --- a/sa_profile/BUILD.gn +++ b/sa_profile/BUILD.gn @@ -18,9 +18,7 @@ ohos_sa_profile("dcamera_sa_profile") { "4803.xml", "4804.xml", ] - deps = [ - :dcamera.cfg, - ] + part_name = "distributed_camera" } ohos_prebuilt_etc("dcamera.cfg") { -- Gitee From b653ec71cbf3ce9347db51b00c62bc60b060ff51 Mon Sep 17 00:00:00 2001 From: wangchaole Date: Wed, 20 Apr 2022 14:18:54 +0800 Subject: [PATCH 07/15] =?UTF-8?q?=E5=8A=A8=E6=80=81=E6=8B=89=E8=B5=B7SA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangchaole --- sa_profile/BUILD.gn | 1 + 1 file changed, 1 insertion(+) diff --git a/sa_profile/BUILD.gn b/sa_profile/BUILD.gn index ed391eba..2898d7db 100644 --- a/sa_profile/BUILD.gn +++ b/sa_profile/BUILD.gn @@ -11,6 +11,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +import("//build/ohos.gni") import("//build/ohos/sa_profile/sa_profile.gni") ohos_sa_profile("dcamera_sa_profile") { -- Gitee From 2ba03c988126a5c6dea29cbb82d4036bb02a2f80 Mon Sep 17 00:00:00 2001 From: wangchaole Date: Wed, 20 Apr 2022 15:38:20 +0800 Subject: [PATCH 08/15] =?UTF-8?q?=E5=8A=A8=E6=80=81=E6=8B=89=E8=B5=B7SA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangchaole --- sa_profile/4803.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sa_profile/4803.xml b/sa_profile/4803.xml index fb50166a..1908bec3 100644 --- a/sa_profile/4803.xml +++ b/sa_profile/4803.xml @@ -14,7 +14,7 @@ * limitations under the License. --> - dcamerasrc + dcamera 4803 libdistributed_camera_source.z.so -- Gitee From b29b5af3b6b0c3556e46dc26260509299bcdef7c Mon Sep 17 00:00:00 2001 From: wangchaole Date: Thu, 21 Apr 2022 18:39:22 +0800 Subject: [PATCH 09/15] =?UTF-8?q?=E5=8A=A8=E6=80=81=E6=8B=89=E8=B5=B7SA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangchaole --- .../camera_sink/include/dcamera_sink_load_callback.h | 7 +++---- .../camera_sink/src/dcamera_sink_handler.cpp | 2 +- .../camera_sink/src/dcamera_sink_load_callback.cpp | 9 ++++----- .../include/dcamera_source_load_callback.h | 7 +++---- .../camera_source/src/dcamera_source_handler.cpp | 8 ++++---- .../src/dcamera_source_load_callback.cpp | 11 +++++------ 6 files changed, 20 insertions(+), 24 deletions(-) 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 index 8230e097..cc2523f3 100644 --- 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 @@ -21,12 +21,11 @@ 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); + void OnLoadSystemAbilitySuccess(int32_t systemAbilityId, const sptr& remoteObject) override; + void OnLoadSystemAbilityFail(int32_t systemAbilityId) override; private: - std::string params; + std::string params_; }; } } 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 00a849e9..40725667 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,10 +14,10 @@ */ #include "dcamera_sink_handler.h" -#include "dcamera_sink_load_callback.h" #include "anonymous_string.h" #include "dcamera_sink_handler_ipc.h" +#include "dcamera_sink_load_callback.h" #include "distributed_camera_constants.h" #include "distributed_camera_errno.h" #include "distributed_hardware_log.h" 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 998af419..d3ca3c3a 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 @@ -19,22 +19,21 @@ namespace OHOS { namespace DistributedHardware { -DCameraSinkLoadCallback::DCameraSinkLoadCallback(const std::string params) : params(params) {} +DCameraSinkLoadCallback::DCameraSinkLoadCallback(const std::string params) : params_(params) {} void DCameraSinkLoadCallback::OnLoadSystemAbilitySuccess(int32_t systemAbilityId, const sptr& remoteObject) { - DHLOGI("OnLoadSystemAbilitySuccess start systemAbilityId: %d.", systemAbilityId); + DHLOGI("OnLoadSystemAbilitySuccess systemAbilityId: %d, IRmoteObject result: %s", + systemAbilityId, (remoteObject != nullptr) ? "true" : "false"); 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); + DCameraSinkHandler::GetInstance().FinishStartSA(params_); } void DCameraSinkLoadCallback::OnLoadSystemAbilityFail(int32_t systemAbilityId) 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 05f4d347..358723ad 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 @@ -21,12 +21,11 @@ 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); + void OnLoadSystemAbilitySuccess(int32_t systemAbilityId, const sptr& remoteObject) override; + void OnLoadSystemAbilityFail(int32_t systemAbilityId) override; private: - std::string params; + 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 244683c5..3c201d10 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 @@ -14,17 +14,17 @@ */ #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_callback.h" #include "dcamera_source_handler_ipc.h" +#include "dcamera_source_load_callback.h" #include "dh_utils_tool.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 { 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 fe344ceb..096387ea 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,27 +19,26 @@ namespace OHOS { namespace DistributedHardware { -DCameraSourceLoadCallback::DCameraSourceLoadCallback(const std::string params) : params(params) {} +DCameraSourceLoadCallback::DCameraSourceLoadCallback(const std::string params) : params_(params) {} void DCameraSourceLoadCallback::OnLoadSystemAbilitySuccess(int32_t systemAbilityId, const sptr& remoteObject) { - DHLOGI("OnLoadSystemAbilitySuccess start systemAbilityId: %d.", systemAbilityId); + DHLOGI("OnLoadSystemAbilitySuccess systemAbilityId: %d, IRmoteObject result: %s", + systemAbilityId, (remoteObject != nullptr) ? "true" : "false"); 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); + DCameraSourceHandler::GetInstance().FinishStartSA(params_); } void DCameraSourceLoadCallback::OnLoadSystemAbilityFail(int32_t systemAbilityId) { - DHLOGE("OnLoadSystemAbilityFail systemAbilityId: %d.", systemAbilityId); + DHLOGI("OnLoadSystemAbilityFail systemAbilityId: %d.", systemAbilityId); if (systemAbilityId != DISTRIBUTED_HARDWARE_CAMERA_SOURCE_SA_ID) { DHLOGE("start systemabilityId is not sourceSAId!"); return; -- Gitee From 5bedd8d7a0106e11f8f49ecefc3dd094f2f61d3b Mon Sep 17 00:00:00 2001 From: wangchaole Date: Thu, 21 Apr 2022 19:36:26 +0800 Subject: [PATCH 10/15] =?UTF-8?q?=E5=8A=A8=E6=80=81=E6=8B=89=E8=B5=B7SA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangchaole --- .../native_cpp/camera_sink/include/dcamera_sink_load_callback.h | 2 +- .../native_cpp/camera_sink/src/dcamera_sink_load_callback.cpp | 2 +- .../camera_source/include/dcamera_source_load_callback.h | 2 +- .../camera_source/src/dcamera_source_load_callback.cpp | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) 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 index cc2523f3..003f90d5 100644 --- 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 @@ -21,7 +21,7 @@ namespace OHOS { namespace DistributedHardware { class DCameraSinkLoadCallback : public SystemAbilityLoadCallbackStub { public: - explicit DCameraSinkLoadCallback(const std::string params); + explicit DCameraSinkLoadCallback(const std::string& params); void OnLoadSystemAbilitySuccess(int32_t systemAbilityId, const sptr& remoteObject) override; void OnLoadSystemAbilityFail(int32_t systemAbilityId) override; private: 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 d3ca3c3a..b701dec5 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 @@ -19,7 +19,7 @@ namespace OHOS { namespace DistributedHardware { -DCameraSinkLoadCallback::DCameraSinkLoadCallback(const std::string params) : params_(params) {} +DCameraSinkLoadCallback::DCameraSinkLoadCallback(const std::string& params) : params_(params) {} void DCameraSinkLoadCallback::OnLoadSystemAbilitySuccess(int32_t systemAbilityId, const sptr& remoteObject) { 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 358723ad..458f983a 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 @@ -21,7 +21,7 @@ namespace OHOS { namespace DistributedHardware { class DCameraSourceLoadCallback : public SystemAbilityLoadCallbackStub { public: - explicit DCameraSourceLoadCallback(const std::string params); + explicit DCameraSourceLoadCallback(const std::string& params); void OnLoadSystemAbilitySuccess(int32_t systemAbilityId, const sptr& remoteObject) override; void OnLoadSystemAbilityFail(int32_t systemAbilityId) override; private: 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 096387ea..73a7cf79 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,7 @@ namespace OHOS { namespace DistributedHardware { -DCameraSourceLoadCallback::DCameraSourceLoadCallback(const std::string params) : params_(params) {} +DCameraSourceLoadCallback::DCameraSourceLoadCallback(const std::string& params) : params_(params) {} void DCameraSourceLoadCallback::OnLoadSystemAbilitySuccess(int32_t systemAbilityId, const sptr& remoteObject) { -- Gitee From 41fd6debac22e0ab105f5e74678069871fd350d2 Mon Sep 17 00:00:00 2001 From: wangchaole Date: Fri, 22 Apr 2022 09:35:02 +0800 Subject: [PATCH 11/15] =?UTF-8?q?=E5=8A=A8=E6=80=81=E6=8B=89=E8=B5=B7SA?= 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_sink/src/dcamera_sink_load_callback.cpp | 2 +- .../native_cpp/camera_source/src/dcamera_source_handler.cpp | 2 +- .../src/distributedcamera/distributed_camera_sink_service.cpp | 1 + .../distributedcamera/distributed_camera_source_service.cpp | 1 + 5 files changed, 6 insertions(+), 4 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 40725667..805ec0f8 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,12 +36,12 @@ 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; } + sptr loadCallback = new DCameraSinkLoadCallback(params); 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); @@ -60,7 +60,7 @@ int32_t DCameraSinkHandler::InitSink(const std::string& params) return DCAMERA_OK; } -void DCameraSinkHandler::FinishStartSA(const std::string ¶ms) +void DCameraSinkHandler::FinishStartSA(const std::string& params) { DCameraSinkHandlerIpc::GetInstance().Init(); sptr dCameraSinkSrv = DCameraSinkHandlerIpc::GetInstance().GetSinkLocalDHMS(); 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 b701dec5..139241ab 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 @@ -38,7 +38,7 @@ void DCameraSinkLoadCallback::OnLoadSystemAbilitySuccess(int32_t systemAbilityId void DCameraSinkLoadCallback::OnLoadSystemAbilityFail(int32_t systemAbilityId) { - DHLOGE("OnLoadSystemAbilityFail systemAbilityId: %d.", systemAbilityId); + DHLOGI("OnLoadSystemAbilityFail 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_handler.cpp b/interfaces/inner_kits/native_cpp/camera_source/src/dcamera_source_handler.cpp index 3c201d10..e40358cc 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,12 +38,12 @@ DCameraSourceHandler::~DCameraSourceHandler() int32_t DCameraSourceHandler::InitSource(const std::string& params) { DHLOGI("DCameraSourceHandler InitSource Start"); - sptr loadCallback = new DCameraSourceLoadCallback(params); sptr sm = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); if (sm == nullptr) { DHLOGE("GetSourceLocalDHMS GetSystemAbilityManager failed"); return DCAMERA_INIT_ERR; } + sptr loadCallback = new DCameraSourceLoadCallback(params); 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); 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 d35bd197..71b8efcd 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"); + DHLOGI("DistributedCameraSinkService::exit source sa process."); exit(0); return DCAMERA_OK; } 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 2236c6ac..702bd46e 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; } listener_ = nullptr; + DHLOGI("DistributedCameraSourceService exit source sa process."); exit(0); return DCAMERA_OK; } -- Gitee From 8dc861b13817599a8eef998b3064a6d9fd9fe826 Mon Sep 17 00:00:00 2001 From: wangchaole Date: Fri, 22 Apr 2022 11:03:37 +0800 Subject: [PATCH 12/15] =?UTF-8?q?=E5=8A=A8=E6=80=81=E6=8B=89=E8=B5=B7SA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangchaole --- sa_profile/BUILD.gn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sa_profile/BUILD.gn b/sa_profile/BUILD.gn index 2898d7db..d78e0b2b 100644 --- a/sa_profile/BUILD.gn +++ b/sa_profile/BUILD.gn @@ -27,4 +27,4 @@ ohos_prebuilt_etc("dcamera.cfg") { source = "dcamera.cfg" part_name = "distributed_camera" subsystem_name = "distributedhardware" -} \ No newline at end of file +} -- Gitee From bac5c94f76090605a31619231e83b0a32bf2cafb Mon Sep 17 00:00:00 2001 From: wangchaole Date: Fri, 22 Apr 2022 11:41:36 +0800 Subject: [PATCH 13/15] =?UTF-8?q?=E5=8A=A8=E6=80=81=E6=8B=89=E8=B5=B7SA?= 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 6a296279..7a27e231 100644 --- a/services/cameraservice/sinkservice/BUILD.gn +++ b/services/cameraservice/sinkservice/BUILD.gn @@ -127,4 +127,4 @@ ohos_shared_library("distributed_camera_sink") { subsystem_name = "distributedhardware" part_name = "distributed_camera" -} \ No newline at end of file +} -- Gitee From 3dd511b6d0cddddb240af69e7de396ceeb1a7753 Mon Sep 17 00:00:00 2001 From: wangchaole Date: Fri, 22 Apr 2022 11:56:06 +0800 Subject: [PATCH 14/15] =?UTF-8?q?=E5=8A=A8=E6=80=81=E6=8B=89=E8=B5=B7SA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangchaole --- services/cameraservice/sourceservice/BUILD.gn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/cameraservice/sourceservice/BUILD.gn b/services/cameraservice/sourceservice/BUILD.gn index 270baf68..8f53c80d 100644 --- a/services/cameraservice/sourceservice/BUILD.gn +++ b/services/cameraservice/sourceservice/BUILD.gn @@ -112,4 +112,4 @@ ohos_shared_library("distributed_camera_source") { subsystem_name = "distributedhardware" part_name = "distributed_camera" -} \ No newline at end of file +} -- Gitee From 4eb67bf63f4bdbc6d511a15a5e6821c6ad864036 Mon Sep 17 00:00:00 2001 From: wangchaole Date: Fri, 22 Apr 2022 17:12:59 +0800 Subject: [PATCH 15/15] =?UTF-8?q?=E5=8A=A8=E6=80=81=E6=8B=89=E8=B5=B7SA?= 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 | 3 +-- .../distributedcamera/distributed_camera_source_service.cpp | 2 +- 2 files changed, 2 insertions(+), 3 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 71b8efcd..a968898c 100644 --- a/services/cameraservice/sinkservice/src/distributedcamera/distributed_camera_sink_service.cpp +++ b/services/cameraservice/sinkservice/src/distributedcamera/distributed_camera_sink_service.cpp @@ -116,8 +116,7 @@ int32_t DistributedCameraSinkService::ReleaseSink() } } camerasMap_.clear(); - DHLOGI("DistributedCameraSinkService::ReleaseSink success"); - DHLOGI("DistributedCameraSinkService::exit source sa process."); + DHLOGI("exit sink sa process."); exit(0); return DCAMERA_OK; } 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 702bd46e..3da2ed45 100644 --- a/services/cameraservice/sourceservice/src/distributedcamera/distributed_camera_source_service.cpp +++ b/services/cameraservice/sourceservice/src/distributedcamera/distributed_camera_source_service.cpp @@ -102,7 +102,7 @@ int32_t DistributedCameraSourceService::ReleaseSource() return ret; } listener_ = nullptr; - DHLOGI("DistributedCameraSourceService exit source sa process."); + DHLOGI("exit source sa process."); exit(0); return DCAMERA_OK; } -- Gitee