diff --git a/camera_hdf/hdi_impl/src/dcamera_device/dmetadata_processor.cpp b/camera_hdf/hdi_impl/src/dcamera_device/dmetadata_processor.cpp index 6ffae69adfd4888cfb95078e9fb4a0f6acb56218..93ab314268911daed56ab5f7bbf191fea4ed63e0 100644 --- a/camera_hdf/hdi_impl/src/dcamera_device/dmetadata_processor.cpp +++ b/camera_hdf/hdi_impl/src/dcamera_device/dmetadata_processor.cpp @@ -14,6 +14,9 @@ */ #include "dmetadata_processor.h" + +#include + #include "dbuffer_manager.h" #include "dcamera_utils_tools.h" #include "distributed_hardware_log.h" @@ -34,7 +37,13 @@ DCamRetCode DMetadataProcessor::InitDCameraAbility(const std::string &abilityInf if (rootValue.isMember("MetaData") && rootValue["MetaData"].isString()) { std::string metadataStr = rootValue["MetaData"].asString(); if (!metadataStr.empty()) { - dCameraAbility_ = CameraStandard::MetadataUtils::DecodeFromString(Base64Decode(metadataStr)); + std::hash h; + DHLOGI("Decode distributed camera metadata from base64, hash: %zu, length: %zu", + h(metadataStr), metadataStr.length()); + std::string decodeString = Base64Decode(metadataStr); + DHLOGI("Decode distributed camera metadata from string, hash: %zu, length: %zu", + h(decodeString), decodeString.length()); + dCameraAbility_ = CameraStandard::MetadataUtils::DecodeFromString(decodeString); DHLOGI("Decode distributed camera metadata from string success."); } } diff --git a/services/cameraservice/cameraoperator/handler/src/dcamera_handler.cpp b/services/cameraservice/cameraoperator/handler/src/dcamera_handler.cpp index 742034f9540aac74c8e47363c6d10619fbd31041..cd3355714a24f1ded9fcd869614380ddcbebf189 100644 --- a/services/cameraservice/cameraoperator/handler/src/dcamera_handler.cpp +++ b/services/cameraservice/cameraoperator/handler/src/dcamera_handler.cpp @@ -15,6 +15,8 @@ #include "dcamera_handler.h" +#include + #include "anonymous_string.h" #include "avcodec_info.h" #include "avcodec_list.h" @@ -173,9 +175,15 @@ DHItem DCameraHandler::CreateDHItem(sptr& info) root[CAMERA_FORMAT_KEY] = outputFormat; root[CAMERA_RESOLUTION_KEY] = resolution; + std::hash h; std::string abilityString = cameraInput->GetCameraSettings(); + DHLOGI("DCameraHandler::CreateDHItem abilityString hash: %zu, length: %zu", + h(abilityString), abilityString.length()); + std::string encodeString = Base64Encode(reinterpret_cast(abilityString.c_str()), - abilityString.length()); + abilityString.length()); + DHLOGI("DCameraHandler::CreateDHItem encodeString hash: %zu, length: %zu", + h(encodeString), encodeString.length()); root[CAMERA_METADATA_KEY] = Json::Value(encodeString); item.attrs = root.toStyledString(); diff --git a/services/cameraservice/cameraoperator/handler/src/dcamera_handler_common.cpp b/services/cameraservice/cameraoperator/handler/src/dcamera_handler_common.cpp index 0c5c29ab2e87a3b30131a208874ac35dbe1e0a08..414fc97c9963378fca0869328ab454203beb598f 100644 --- a/services/cameraservice/cameraoperator/handler/src/dcamera_handler_common.cpp +++ b/services/cameraservice/cameraoperator/handler/src/dcamera_handler_common.cpp @@ -15,6 +15,8 @@ #include "dcamera_handler.h" +#include + #include "anonymous_string.h" #include "avcodec_info.h" #include "avcodec_list.h" @@ -168,9 +170,15 @@ DHItem DCameraHandler::CreateDHItem(sptr& info) root[CAMERA_FORMAT_KEY] = outputFormat; root[CAMERA_RESOLUTION_KEY] = resolution; + std::hash h; std::string abilityString = cameraInput->GetCameraSettings(); + DHLOGI("DCameraHandlerCommon::CreateDHItem abilityString hash: %zu, length: %zu", + h(abilityString), abilityString.length()); + std::string encodeString = Base64Encode(reinterpret_cast(abilityString.c_str()), - abilityString.length()); + abilityString.length()); + DHLOGI("DCameraHandlerCommon::CreateDHItem encodeString hash: %zu, length: %zu", + h(encodeString), encodeString.length()); root[CAMERA_METADATA_KEY] = Json::Value(encodeString); item.attrs = root.toStyledString(); diff --git a/services/cameraservice/sourceservice/include/distributedcamera/distributed_camera_source_service.h b/services/cameraservice/sourceservice/include/distributedcamera/distributed_camera_source_service.h index 01749e6ba4c57212fca27526abed15d55136c8c7..112030674402abb94e8564b3d72983aa64d18da8 100644 --- a/services/cameraservice/sourceservice/include/distributedcamera/distributed_camera_source_service.h +++ b/services/cameraservice/sourceservice/include/distributedcamera/distributed_camera_source_service.h @@ -24,6 +24,7 @@ #include "ipc_object_stub.h" #include "dcamera_index.h" +#include "dcamera_service_state_listener.h" #include "dcamera_source_dev.h" #include "distributed_camera_constants.h" #include "distributed_camera_source_stub.h" @@ -60,7 +61,7 @@ private: bool registerToService_ = false; DCameraServiceState state_ = DCameraServiceState::DCAMERA_SRV_STATE_NOT_START; - sptr callbackProxy_; + std::shared_ptr listener_; std::string sourceVer_; }; } // namespace DistributedHardware diff --git a/services/cameraservice/sourceservice/src/distributedcamera/dcamera_service_state_listener.cpp b/services/cameraservice/sourceservice/src/distributedcamera/dcamera_service_state_listener.cpp index 18eb54755794b0cb88b275c8335d7adee76be13e..12f337685893bf13deb63752f7598a529c0f373f 100644 --- a/services/cameraservice/sourceservice/src/distributedcamera/dcamera_service_state_listener.cpp +++ b/services/cameraservice/sourceservice/src/distributedcamera/dcamera_service_state_listener.cpp @@ -47,19 +47,20 @@ int32_t DCameraServiceStateListener::OnRegisterNotify(const std::string& devId, return DCAMERA_BAD_VALUE; } - int32_t ret = callbackProxy_->OnNotifyRegResult(devId, dhId, reqId, status, data); - if (ret != DCAMERA_OK) { - DHLOGE("DCameraServiceStateListener OnRegisterNotify OnNotifyRegResult failed: %d", ret); - } if (status != DCAMERA_OK) { - std::thread([devId, dhId]() { + std::thread([=]() mutable { DHLOGI("DCameraServiceStateListener OnRegisterNotify thread delete devId: %s dhId: %s", GetAnonyString(devId).c_str(), GetAnonyString(dhId).c_str()); DCameraIndex camIndex(devId, dhId); DistributedCameraSourceService::camerasMap_.erase(camIndex); + + int32_t ret = callbackProxy_->OnNotifyRegResult(devId, dhId, reqId, status, data); + if (ret != DCAMERA_OK) { + DHLOGE("DCameraServiceStateListener OnRegisterNotify OnNotifyRegResult failed: %d", ret); + } }).detach(); } - return ret; + return DCAMERA_OK; } int32_t DCameraServiceStateListener::OnUnregisterNotify(const std::string& devId, const std::string& dhId, @@ -72,21 +73,21 @@ int32_t DCameraServiceStateListener::OnUnregisterNotify(const std::string& devId return DCAMERA_BAD_VALUE; } - int32_t ret = callbackProxy_->OnNotifyUnregResult(devId, dhId, reqId, status, data); - if (ret != DCAMERA_OK) { - DHLOGE("DCameraServiceStateListener OnUnregisterNotify failed, ret: %d", ret); - } - if (status == DCAMERA_OK) { - std::thread([devId, dhId]() { + std::thread([=]() mutable { DHLOGI("DCameraServiceStateListener OnUnregisterNotify thread delete devId: %s dhId: %s", GetAnonyString(devId).c_str(), GetAnonyString(dhId).c_str()); DCameraIndex camIndex(devId, dhId); DistributedCameraSourceService::camerasMap_.erase(camIndex); + + int32_t ret = callbackProxy_->OnNotifyUnregResult(devId, dhId, reqId, status, data); + if (ret != DCAMERA_OK) { + DHLOGE("DCameraServiceStateListener OnUnregisterNotify failed, ret: %d", ret); + } }).detach(); } - return ret; + return DCAMERA_OK; } } // namespace DistributedHardware } // namespace OHOS 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 1119e87b61d8fbf5bd5e4a0b905bf643d38f6fdb..e0ea205c992f1972659f841580819ca93b24666c 100644 --- a/services/cameraservice/sourceservice/src/distributedcamera/distributed_camera_source_service.cpp +++ b/services/cameraservice/sourceservice/src/distributedcamera/distributed_camera_source_service.cpp @@ -23,7 +23,6 @@ #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" @@ -89,7 +88,7 @@ int32_t DistributedCameraSourceService::InitSource(const std::string& params, return ret; } sourceVer_ = params; - callbackProxy_ = callback; + listener_ = std::make_shared(callback); return DCAMERA_OK; } @@ -101,7 +100,7 @@ int32_t DistributedCameraSourceService::ReleaseSource() DHLOGE("DistributedCameraSourceService ReleaseSource UnLoadHDF failed, ret: %d", ret); return ret; } - callbackProxy_ = nullptr; + listener_ = nullptr; return DCAMERA_OK; } @@ -117,8 +116,7 @@ int32_t DistributedCameraSourceService::RegisterDistributedHardware(const std::s if (iter == camerasMap_.end()) { DHLOGI("DistributedCameraSourceService RegisterDistributedHardware new dev devId: %s, dhId: %s, version: %s", GetAnonyString(devId).c_str(), GetAnonyString(dhId).c_str(), param.version.c_str()); - std::shared_ptr listener = std::make_shared(callbackProxy_); - camDev = std::make_shared(devId, dhId, listener); + camDev = std::make_shared(devId, dhId, listener_); if (camDev == nullptr) { return DCAMERA_MEMORY_OPT_ERROR; }