已开启
l1可预览 #969
zhangmengxuan创建于 26 天前
l1可预览 #969
已开启
共 178 个文件变更+5513-424
| @@ -22,7 +22,8 @@ | |||
| 22 | "distributed_camera_open_stabile" | 22 | "distributed_camera_open_stabile" |
| 23 | ], | 23 | ], |
| 24 | "adapted_system_type": [ | 24 | "adapted_system_type": [ |
| 25 | - "standard" | 25 | + "standard", |
| 26 | + "small" | ||
| 26 | ], | 27 | ], |
| 27 | "rom": "5120KB", | 28 | "rom": "5120KB", |
| 28 | "ram": "66560KB", | 29 | "ram": "66560KB", |
| @@ -59,7 +60,8 @@ | |||
| 59 | "access_token", | 60 | "access_token", |
| 60 | "av_codec", | 61 | "av_codec", |
| 61 | "os_account", | 62 | "os_account", |
| 62 | - "sensor" | 63 | + "sensor", |
| 64 | + "hilog_lite" | ||
| 63 | ] | 65 | ] |
| 64 | }, | 66 | }, |
| 65 | "build": { | 67 | "build": { |
| @@ -70,6 +72,7 @@ | |||
| 70 | "//foundation/distributedhardware/distributed_camera/services/cameraservice/cameraoperator/client:distributed_camera_client", | 72 | "//foundation/distributedhardware/distributed_camera/services/cameraservice/cameraoperator/client:distributed_camera_client", |
| 71 | "//foundation/distributedhardware/distributed_camera/services/cameraservice/cameraoperator/handler:distributed_camera_handler", | 73 | "//foundation/distributedhardware/distributed_camera/services/cameraservice/cameraoperator/handler:distributed_camera_handler", |
| 72 | "//foundation/distributedhardware/distributed_camera/services/cameraservice/sinkservice:distributed_camera_sink", | 74 | "//foundation/distributedhardware/distributed_camera/services/cameraservice/sinkservice:distributed_camera_sink", |
| 75 | + "//foundation/distributedhardware/distributed_camera/services/cameraservice/sinkservice/test/lite_host:dcamera_sink_host", | ||
| 73 | "//foundation/distributedhardware/distributed_camera/services/cameraservice/sourceservice:distributed_camera_source", | 76 | "//foundation/distributedhardware/distributed_camera/services/cameraservice/sourceservice:distributed_camera_source", |
| 74 | "//foundation/distributedhardware/distributed_camera/services/data_process:distributed_camera_data_process", | 77 | "//foundation/distributedhardware/distributed_camera/services/data_process:distributed_camera_data_process", |
| 75 | "//foundation/distributedhardware/distributed_camera/sa_profile:dcamera_sa_profile", | 78 | "//foundation/distributedhardware/distributed_camera/sa_profile:dcamera_sa_profile", |
| @@ -93,4 +96,4 @@ | |||
| 93 | ] | 96 | ] |
| 94 | } | 97 | } |
| 95 | } | 98 | } |
| 96 | -} | 99 | +} |
| @@ -17,7 +17,8 @@ import( | |||
| 17 | 17 | ||
| 18 | ohos_shared_library("distributed_camera_utils") { | 18 | ohos_shared_library("distributed_camera_utils") { |
| 19 | branch_protector_ret = "pac_ret" | 19 | branch_protector_ret = "pac_ret" |
| 20 | - sanitize = { | 20 | + if (!defined(ohos_lite)) { |
| 21 | + sanitize = { | ||
| 21 | cfi = true | 22 | cfi = true |
| 22 | cfi_cross_dso = true | 23 | cfi_cross_dso = true |
| 23 | debug = false | 24 | debug = false |
| @@ -25,6 +26,7 @@ ohos_shared_library("distributed_camera_utils") { | |||
| 25 | integer_overflow = true | 26 | integer_overflow = true |
| 26 | ubsan = true | 27 | ubsan = true |
| 27 | } | 28 | } |
| 29 | + } | ||
| 28 | stack_protector_ret = true | 30 | stack_protector_ret = true |
| 29 | include_dirs = [ | 31 | include_dirs = [ |
| 30 | "include/constants", | 32 | "include/constants", |
| @@ -46,42 +48,75 @@ ohos_shared_library("distributed_camera_utils") { | |||
| 46 | sources = [ | 48 | sources = [ |
| 47 | "src/utils/anonymous_string.cpp", | 49 | "src/utils/anonymous_string.cpp", |
| 48 | "src/utils/data_buffer.cpp", | 50 | "src/utils/data_buffer.cpp", |
| 49 | - "src/utils/dcamera_buffer_handle.cpp", | ||
| 50 | - "src/utils/dcamera_hidumper.cpp", | ||
| 51 | - "src/utils/dcamera_hisysevent_adapter.cpp", | ||
| 52 | - "src/utils/dcamera_hitrace_adapter.cpp", | ||
| 53 | - "src/utils/dcamera_radar.cpp", | ||
| 54 | "src/utils/dcamera_utils_tools.cpp", | 51 | "src/utils/dcamera_utils_tools.cpp", |
| 55 | "src/utils/dh_log.cpp", | 52 | "src/utils/dh_log.cpp", |
| 56 | ] | 53 | ] |
| 57 | 54 | ||
| 55 | + if (!defined(ohos_lite)) { | ||
| 56 | + sources += [ "src/utils/dcamera_buffer_handle.cpp" ] | ||
| 57 | + } | ||
| 58 | + | ||
| 59 | + if (!defined(ohos_lite)) { | ||
| 60 | + sources += [ | ||
| 61 | + "src/utils/dcamera_hidumper.cpp", | ||
| 62 | + "src/utils/standard/dcamera_hisysevent_adapter.cpp", | ||
| 63 | + "src/utils/dcamera_hitrace_adapter.cpp", | ||
| 64 | + "src/utils/dcamera_radar.cpp", | ||
| 65 | + ] | ||
| 66 | + } else { | ||
| 67 | + sources += [ "src/utils/lite/dcamera_hisysevent_adapter.cpp" ] | ||
| 68 | + } | ||
| 69 | + | ||
| 58 | defines = [ | 70 | defines = [ |
| 59 | "HI_LOG_ENABLE", | 71 | "HI_LOG_ENABLE", |
| 60 | "DH_LOG_TAG=\"distributedcamerautils\"", | 72 | "DH_LOG_TAG=\"distributedcamerautils\"", |
| 61 | "LOG_DOMAIN=0xD004150", | 73 | "LOG_DOMAIN=0xD004150", |
| 62 | ] | 74 | ] |
| 63 | 75 | ||
| 76 | + if (defined(ohos_lite)) { | ||
| 77 | + defines += [ "OHOS_LITE" ] | ||
| 78 | + } | ||
| 79 | + | ||
| 64 | ldflags = [ | 80 | ldflags = [ |
| 65 | "-fpie", | 81 | "-fpie", |
| 66 | "-Wl,-z,relro", | 82 | "-Wl,-z,relro", |
| 67 | "-Wl,-z,now", | 83 | "-Wl,-z,now", |
| 68 | ] | 84 | ] |
| 69 | 85 | ||
| 86 | + deps = [] | ||
| 87 | + | ||
| 70 | external_deps = [ | 88 | external_deps = [ |
| 71 | - "c_utils:utils", | ||
| 72 | "distributed_hardware_fwk:distributedhardwareutils", | 89 | "distributed_hardware_fwk:distributedhardwareutils", |
| 73 | - "dsoftbus:softbus_client", | ||
| 74 | - "ffrt:libffrt", | ||
| 75 | "hdf_core:libhdi", | 90 | "hdf_core:libhdi", |
| 76 | - "hilog:libhilog", | ||
| 77 | - "hisysevent:libhisysevent", | ||
| 78 | - "hitrace:hitrace_meter", | ||
| 79 | "init:libbegetutil", | 91 | "init:libbegetutil", |
| 80 | - "ipc:ipc_core", | ||
| 81 | - "safwk:system_ability_fwk", | ||
| 82 | - "samgr:samgr_proxy", | ||
| 83 | ] | 92 | ] |
| 84 | 93 | ||
| 94 | + if (defined(ohos_lite)) { | ||
| 95 | + external_deps += [ "hilog_lite:hilog_shared" ] | ||
| 96 | + } else { | ||
| 97 | + external_deps += [ | ||
| 98 | + "c_utils:utils", | ||
| 99 | + "hilog:libhilog", | ||
| 100 | + ] | ||
| 101 | + } | ||
| 102 | + | ||
| 103 | + if (!defined(ohos_lite)) { | ||
| 104 | + external_deps += [ | ||
| 105 | + "dsoftbus:softbus_client", | ||
| 106 | + "ffrt:libffrt", | ||
| 107 | + "hisysevent:libhisysevent", | ||
| 108 | + "hitrace:hitrace_meter", | ||
| 109 | + "ipc:ipc_core", | ||
| 110 | + "safwk:system_ability_fwk", | ||
| 111 | + "samgr:samgr_proxy", | ||
| 112 | + ] | ||
| 113 | + } else { | ||
| 114 | + } | ||
| 115 | + | ||
| 116 | + if (defined(ohos_lite)) { | ||
| 117 | + deps += [ "//foundation/communication/dsoftbus/sdk:softbus_client" ] | ||
| 118 | + } | ||
| 119 | + | ||
| 85 | cflags_cc = cflags | 120 | cflags_cc = cflags |
| 86 | subsystem_name = "distributedhardware" | 121 | subsystem_name = "distributedhardware" |
| 87 | 122 | ||
| @@ -77,6 +77,19 @@ typedef enum { | |||
| 77 | OHOS_CAMERA_FORMAT_YCBCB_P010, | 77 | OHOS_CAMERA_FORMAT_YCBCB_P010, |
| 78 | } DCameraFormat; | 78 | } DCameraFormat; |
| 79 | 79 | ||
| 80 | + | ||
| 81 | +typedef enum { | ||
| 82 | + CONTINUOUS_FRAME = 0, | ||
| 83 | + SNAPSHOT_FRAME = 1, | ||
| 84 | +} DCStreamType; | ||
| 85 | + | ||
| 86 | +typedef enum { | ||
| 87 | + ENCODE_TYPE_H264 = 0, | ||
| 88 | + ENCODE_TYPE_H265 = 1, | ||
| 89 | + ENCODE_TYPE_JPEG = 2, | ||
| 90 | +} DCEncodeType; | ||
| 91 | + | ||
| 92 | + | ||
| 80 | const uint32_t DCAMERA_MAX_NUM = 1; | 93 | const uint32_t DCAMERA_MAX_NUM = 1; |
| 81 | const uint32_t DCAMERA_PRODUCER_ONE_MINUTE_MS = 1000; | 94 | const uint32_t DCAMERA_PRODUCER_ONE_MINUTE_MS = 1000; |
| 82 | const uint32_t DCAMERA_PRODUCER_FPS_DEFAULT = 30; | 95 | const uint32_t DCAMERA_PRODUCER_FPS_DEFAULT = 30; |
| @@ -123,9 +123,9 @@ class DCameraAccessConfigManager { | |||
| 123 | FWK_DECLARE_SINGLE_INSTANCE(DCameraAccessConfigManager); | 123 | FWK_DECLARE_SINGLE_INSTANCE(DCameraAccessConfigManager); |
| 124 | 124 | ||
| 125 | public: | 125 | public: |
| 126 | - int32_t SetAccessConfig(const sptr<IAccessListener>& listener, int32_t timeOut, | 126 | + int32_t SetAccessConfig(const IAccessListenerPtr& listener, int32_t timeOut, |
| 127 | const std::string& pkgName); | 127 | const std::string& pkgName); |
| 128 | - sptr<IAccessListener> GetAccessListener(); | 128 | + IAccessListenerPtr GetAccessListener(); |
| 129 | int32_t GetAccessTimeOut(); | 129 | int32_t GetAccessTimeOut(); |
| 130 | std::string GetAccessPkgName(); | 130 | std::string GetAccessPkgName(); |
| 131 | void ClearAccessConfig(); | 131 | void ClearAccessConfig(); |
| @@ -141,7 +141,7 @@ public: | |||
| 141 | private: | 141 | private: |
| 142 | std::mutex mtxLock_; | 142 | std::mutex mtxLock_; |
| 143 | std::condition_variable authCondVar_; | 143 | std::condition_variable authCondVar_; |
| 144 | - sptr<IAccessListener> listener_ = nullptr; | 144 | + IAccessListenerPtr listener_ = nullptr; |
| 145 | int32_t timeOut_ = 0; | 145 | int32_t timeOut_ = 0; |
| 146 | std::string pkgName_ = ""; | 146 | std::string pkgName_ = ""; |
| 147 | std::string currentNetworkId_ = ""; | 147 | std::string currentNetworkId_ = ""; |
| @@ -154,4 +154,4 @@ std::string CreateMsg(const char *format, ...) | |||
| 154 | return msg; | 154 | return msg; |
| 155 | } | 155 | } |
| 156 | } // namespace DistributedHardware | 156 | } // namespace DistributedHardware |
| 157 | -} // namespace OHOS | 157 | +} // namespace OHOS |
| @@ -464,7 +464,7 @@ int32_t DCameraSystemSwitchInfo::GetSystemSwitchRotation(std::string devId) | |||
| 464 | 464 | ||
| 465 | FWK_IMPLEMENT_SINGLE_INSTANCE(DCameraAccessConfigManager); | 465 | FWK_IMPLEMENT_SINGLE_INSTANCE(DCameraAccessConfigManager); |
| 466 | 466 | ||
| 467 | -int32_t DCameraAccessConfigManager::SetAccessConfig(const sptr<IAccessListener>& listener, | 467 | +int32_t DCameraAccessConfigManager::SetAccessConfig(const IAccessListenerPtr& listener, |
| 468 | int32_t timeOut, const std::string& pkgName) | 468 | int32_t timeOut, const std::string& pkgName) |
| 469 | { | 469 | { |
| 470 | DHLOGI("SetAccessConfig, timeOut: %{public}d, pkgName: %{public}s", timeOut, pkgName.c_str()); | 470 | DHLOGI("SetAccessConfig, timeOut: %{public}d, pkgName: %{public}s", timeOut, pkgName.c_str()); |
| @@ -487,7 +487,7 @@ int32_t DCameraAccessConfigManager::SetAccessConfig(const sptr<IAccessListener>& | |||
| 487 | return DCAMERA_OK; | 487 | return DCAMERA_OK; |
| 488 | } | 488 | } |
| 489 | 489 | ||
| 490 | -sptr<IAccessListener> DCameraAccessConfigManager::GetAccessListener() | 490 | +IAccessListenerPtr DCameraAccessConfigManager::GetAccessListener() |
| 491 | { | 491 | { |
| 492 | std::lock_guard<std::mutex> lock(mtxLock_); | 492 | std::lock_guard<std::mutex> lock(mtxLock_); |
| 493 | return listener_; | 493 | return listener_; |
| @@ -0,0 +1,99 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) 2022-2024 Huawei Device Co., Ltd. | ||
| 3 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 4 | + * you may not use this file except in compliance with the License. | ||
| 5 | + * You may obtain a copy of the License at | ||
| 6 | + * | ||
| 7 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 8 | + * | ||
| 9 | + * Unless required by applicable law or agreed to in writing, software | ||
| 10 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 11 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 12 | + * See the License for the specific language governing permissions and | ||
| 13 | + * limitations under the License. | ||
| 14 | + */ | ||
| 15 | + | ||
| 16 | + | ||
| 17 | + | ||
| 18 | + | ||
| 19 | + | ||
| 20 | + | ||
| 21 | + | ||
| 22 | +namespace OHOS { | ||
| 23 | +namespace DistributedHardware { | ||
| 24 | +namespace { | ||
| 25 | +constexpr int32_t MSG_MAX_LEN = 2048; | ||
| 26 | +} | ||
| 27 | + | ||
| 28 | +void ReportDcamerInitFail(const std::string& eventName, int32_t errCode, const std::string& errMsg) | ||
| 29 | +{ | ||
| 30 | + (void)eventName; | ||
| 31 | + (void)errCode; | ||
| 32 | + (void)errMsg; | ||
| 33 | +} | ||
| 34 | + | ||
| 35 | +void ReportRegisterCameraFail(const std::string& eventName, const std::string& devId, const std::string& dhId, | ||
| 36 | + std::string version, const std::string& errMsg) | ||
| 37 | +{ | ||
| 38 | + (void)eventName; | ||
| 39 | + (void)devId; | ||
| 40 | + (void)dhId; | ||
| 41 | + (void)version; | ||
| 42 | + (void)errMsg; | ||
| 43 | +} | ||
| 44 | + | ||
| 45 | +void ReportDcamerOptFail(const std::string& eventName, int32_t errCode, const std::string& errMsg) | ||
| 46 | +{ | ||
| 47 | + (void)eventName; | ||
| 48 | + (void)errCode; | ||
| 49 | + (void)errMsg; | ||
| 50 | +} | ||
| 51 | + | ||
| 52 | +void ReportSaEvent(const std::string& eventName, int32_t saId, const std::string& errMsg) | ||
| 53 | +{ | ||
| 54 | + (void)eventName; | ||
| 55 | + (void)saId; | ||
| 56 | + (void)errMsg; | ||
| 57 | +} | ||
| 58 | + | ||
| 59 | +void ReportRegisterCameraEvent(const std::string& eventName, const std::string& devId, const std::string& dhId, | ||
| 60 | + std::string version, const std::string& errMsg) | ||
| 61 | +{ | ||
| 62 | + (void)eventName; | ||
| 63 | + (void)devId; | ||
| 64 | + (void)dhId; | ||
| 65 | + (void)version; | ||
| 66 | + (void)errMsg; | ||
| 67 | +} | ||
| 68 | + | ||
| 69 | +void ReportCameraOperaterEvent(const std::string& eventName, const std::string& devId, const std::string& dhId, | ||
| 70 | + const std::string& errMsg) | ||
| 71 | +{ | ||
| 72 | + (void)eventName; | ||
| 73 | + (void)devId; | ||
| 74 | + (void)dhId; | ||
| 75 | + (void)errMsg; | ||
| 76 | +} | ||
| 77 | + | ||
| 78 | +void ReportStartCaptureEvent(const std::string& eventName, EventCaptureInfo& capture, const std::string& errMsg) | ||
| 79 | +{ | ||
| 80 | + (void)eventName; | ||
| 81 | + (void)capture; | ||
| 82 | + (void)errMsg; | ||
| 83 | +} | ||
| 84 | + | ||
| 85 | +std::string CreateMsg(const char *format, ...) | ||
| 86 | +{ | ||
| 87 | + va_list args; | ||
| 88 | + va_start(args, format); | ||
| 89 | + char msg[MSG_MAX_LEN] = {0}; | ||
| 90 | + if (vsnprintf_s(msg, sizeof(msg), sizeof(msg) - 1, format, args) < 0) { | ||
| 91 | + DHLOGE("failed to call vsnprintf_s"); | ||
| 92 | + va_end(args); | ||
| 93 | + return ""; | ||
| 94 | + } | ||
| 95 | + va_end(args); | ||
| 96 | + return msg; | ||
| 97 | +} | ||
| 98 | +} // namespace DistributedHardware | ||
| 99 | +} // namespace OHOS | ||
| @@ -0,0 +1,157 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) 2022-2024 Huawei Device Co., Ltd. | ||
| 3 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 4 | + * you may not use this file except in compliance with the License. | ||
| 5 | + * You may obtain a copy of the License at | ||
| 6 | + * | ||
| 7 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 8 | + * | ||
| 9 | + * Unless required by applicable law or agreed to in writing, software | ||
| 10 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 11 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 12 | + * See the License for the specific language governing permissions and | ||
| 13 | + * limitations under the License. | ||
| 14 | + */ | ||
| 15 | + | ||
| 16 | + | ||
| 17 | + | ||
| 18 | + | ||
| 19 | + | ||
| 20 | + | ||
| 21 | + | ||
| 22 | + | ||
| 23 | + | ||
| 24 | + | ||
| 25 | +namespace OHOS { | ||
| 26 | +namespace DistributedHardware { | ||
| 27 | +namespace { | ||
| 28 | +constexpr int32_t MSG_MAX_LEN = 2048; | ||
| 29 | +constexpr int32_t ENUM_STREAMTYPE_LEN = 2; | ||
| 30 | +constexpr int32_t ENUM_ENCODETYPE_LEN = 4; | ||
| 31 | +using HiSysEventNameSpace = OHOS::HiviewDFX::HiSysEvent; | ||
| 32 | +const std::string ENUM_STREAMTYPE_STRINGS[] = { | ||
| 33 | + "CONTINUOUS_FRAME", "SNAPSHOT_FRAME" | ||
| 34 | +}; | ||
| 35 | +const std::string ENUM_ENCODETYPE_STRINGS[] = { | ||
| 36 | + "ENCODE_TYPE_NULL", "ENCODE_TYPE_H264", "ENCODE_TYPE_H265", "ENCODE_TYPE_JPEG" | ||
| 37 | +}; | ||
| 38 | +} | ||
| 39 | + | ||
| 40 | +void ReportDcamerInitFail(const std::string& eventName, int32_t errCode, const std::string& errMsg) | ||
| 41 | +{ | ||
| 42 | + int32_t ret = HiSysEventWrite(HiSysEventNameSpace::Domain::DISTRIBUTED_CAMERA, | ||
| 43 | + eventName, | ||
| 44 | + HiSysEventNameSpace::EventType::FAULT, | ||
| 45 | + "ERRCODE", errCode, | ||
| 46 | + "MSG", errMsg); | ||
| 47 | + if (ret != DCAMERA_OK) { | ||
| 48 | + DHLOGE("Write HiSysEvent error ret %{public}d, errMsg %{public}s.", ret, errMsg.c_str()); | ||
| 49 | + } | ||
| 50 | +} | ||
| 51 | + | ||
| 52 | +void ReportRegisterCameraFail(const std::string& eventName, const std::string& devId, const std::string& dhId, | ||
| 53 | + std::string version, const std::string& errMsg) | ||
| 54 | +{ | ||
| 55 | + int32_t ret = HiSysEventWrite(HiSysEventNameSpace::Domain::DISTRIBUTED_CAMERA, | ||
| 56 | + eventName, | ||
| 57 | + HiSysEventNameSpace::EventType::FAULT, | ||
| 58 | + "DEVID", devId, | ||
| 59 | + "DHID", dhId, | ||
| 60 | + "VERSION", version, | ||
| 61 | + "MSG", errMsg); | ||
| 62 | + if (ret != DCAMERA_OK) { | ||
| 63 | + DHLOGE("Write HiSysEvent error ret %d, devId %s, dhId %s, errMsg %s.", ret, GetAnonyString(devId).c_str(), | ||
| 64 | + dhId.c_str(), errMsg.c_str()); | ||
| 65 | + } | ||
| 66 | +} | ||
| 67 | + | ||
| 68 | +void ReportDcamerOptFail(const std::string& eventName, int32_t errCode, const std::string& errMsg) | ||
| 69 | +{ | ||
| 70 | + int32_t ret = HiSysEventWrite(HiSysEventNameSpace::Domain::DISTRIBUTED_CAMERA, | ||
| 71 | + eventName, | ||
| 72 | + HiSysEventNameSpace::EventType::FAULT, | ||
| 73 | + "ERRCODE", errCode, | ||
| 74 | + "MSG", errMsg); | ||
| 75 | + if (ret != DCAMERA_OK) { | ||
| 76 | + DHLOGE("Write HiSysEvent error ret %{public}d, errMsg %{public}s.", ret, errMsg.c_str()); | ||
| 77 | + } | ||
| 78 | +} | ||
| 79 | + | ||
| 80 | +void ReportSaEvent(const std::string& eventName, int32_t saId, const std::string& errMsg) | ||
| 81 | +{ | ||
| 82 | + int32_t ret = HiSysEventWrite(HiSysEventNameSpace::Domain::DISTRIBUTED_CAMERA, | ||
| 83 | + eventName, | ||
| 84 | + HiSysEventNameSpace::EventType::BEHAVIOR, | ||
| 85 | + "SAID", saId, | ||
| 86 | + "MSG", errMsg); | ||
| 87 | + if (ret != DCAMERA_OK) { | ||
| 88 | + DHLOGE("Write HiSysEvent error, ret:%{public}d, errMsg %{public}s.", ret, errMsg.c_str()); | ||
| 89 | + } | ||
| 90 | +} | ||
| 91 | + | ||
| 92 | +void ReportRegisterCameraEvent(const std::string& eventName, const std::string& devId, const std::string& dhId, | ||
| 93 | + std::string version, const std::string& errMsg) | ||
| 94 | +{ | ||
| 95 | + int32_t ret = HiSysEventWrite(HiSysEventNameSpace::Domain::DISTRIBUTED_CAMERA, | ||
| 96 | + eventName, | ||
| 97 | + HiSysEventNameSpace::EventType::BEHAVIOR, | ||
| 98 | + "DEVID", devId, | ||
| 99 | + "DHID", dhId, | ||
| 100 | + "VERSION", version, | ||
| 101 | + "MSG", errMsg); | ||
| 102 | + if (ret != DCAMERA_OK) { | ||
| 103 | + DHLOGE("Write HiSysEvent error, ret:%{public}d, errMsg %{public}s.", ret, errMsg.c_str()); | ||
| 104 | + } | ||
| 105 | +} | ||
| 106 | + | ||
| 107 | +void ReportCameraOperaterEvent(const std::string& eventName, const std::string& devId, const std::string& dhId, | ||
| 108 | + const std::string& errMsg) | ||
| 109 | +{ | ||
| 110 | + int32_t ret = HiSysEventWrite(HiSysEventNameSpace::Domain::DISTRIBUTED_CAMERA, | ||
| 111 | + eventName, | ||
| 112 | + HiSysEventNameSpace::EventType::BEHAVIOR, | ||
| 113 | + "DEVID", devId, | ||
| 114 | + "DHID", dhId, | ||
| 115 | + "MSG", errMsg); | ||
| 116 | + if (ret != DCAMERA_OK) { | ||
| 117 | + DHLOGE("Write HiSysEvent error, ret:%{public}d, errMsg %{public}s.", ret, errMsg.c_str()); | ||
| 118 | + } | ||
| 119 | +} | ||
| 120 | + | ||
| 121 | +void ReportStartCaptureEvent(const std::string& eventName, EventCaptureInfo& capture, const std::string& errMsg) | ||
| 122 | +{ | ||
| 123 | + if (capture.encodeType_ < 0 || capture.encodeType_ >= ENUM_ENCODETYPE_LEN || | ||
| 124 | + capture.type_ < 0 || capture.type_ >= ENUM_STREAMTYPE_LEN) { | ||
| 125 | + DHLOGE("Invalid capture parameters."); | ||
| 126 | + return; | ||
| 127 | + } | ||
| 128 | + int32_t ret = HiSysEventWrite(HiSysEventNameSpace::Domain::DISTRIBUTED_CAMERA, | ||
| 129 | + eventName, | ||
| 130 | + HiSysEventNameSpace::EventType::BEHAVIOR, | ||
| 131 | + "WIDTH", capture.width_, | ||
| 132 | + "HEIGHT", capture.height_, | ||
| 133 | + "FORMAT", capture.format_, | ||
| 134 | + "ISCAPTURE", capture.isCapture_ ? "true" : "false", | ||
| 135 | + "ENCODETYPE", ENUM_ENCODETYPE_STRINGS[capture.encodeType_], | ||
| 136 | + "STREAMTYPE", ENUM_STREAMTYPE_STRINGS[capture.type_], | ||
| 137 | + "MSG", errMsg); | ||
| 138 | + if (ret != DCAMERA_OK) { | ||
| 139 | + DHLOGE("Write HiSysEvent error, ret:%{public}d, errMsg %{public}s.", ret, errMsg.c_str()); | ||
| 140 | + } | ||
| 141 | +} | ||
| 142 | + | ||
| 143 | +std::string CreateMsg(const char *format, ...) | ||
| 144 | +{ | ||
| 145 | + va_list args; | ||
| 146 | + va_start(args, format); | ||
| 147 | + char msg[MSG_MAX_LEN] = {0}; | ||
| 148 | + if (vsnprintf_s(msg, sizeof(msg), sizeof(msg) - 1, format, args) < 0) { | ||
| 149 | + DHLOGE("failed to call vsnprintf_s"); | ||
| 150 | + va_end(args); | ||
| 151 | + return ""; | ||
| 152 | + } | ||
| 153 | + va_end(args); | ||
| 154 | + return msg; | ||
| 155 | +} | ||
| 156 | +} // namespace DistributedHardware | ||
| 157 | +} // namespace OHOS | ||
| @@ -11,7 +11,12 @@ | |||
| 11 | # See the License for the specific language governing permissions and | 11 | # See the License for the specific language governing permissions and |
| 12 | # limitations under the License. | 12 | # limitations under the License. |
| 13 | 13 | ||
| 14 | +if (!defined(ohos_lite)) { | ||
| 14 | group("common_utils_test") { | 15 | group("common_utils_test") { |
| 15 | testonly = true | 16 | testonly = true |
| 16 | deps = [ "common/utils:utils_test" ] | 17 | deps = [ "common/utils:utils_test" ] |
| 17 | } | 18 | } |
| 19 | +} else { | ||
| 20 | + group("common_utils_test") { | ||
| 21 | + } | ||
| 22 | +} | ||
| @@ -15,6 +15,7 @@ import("//build/test.gni") | |||
| 15 | import( | 15 | import( |
| 16 | "//foundation/distributedhardware/distributed_camera/distributedcamera.gni") | 16 | "//foundation/distributedhardware/distributed_camera/distributedcamera.gni") |
| 17 | 17 | ||
| 18 | +if (!defined(ohos_lite)) { | ||
| 18 | module_out_path = "${unittest_output_path}/utils_test" | 19 | module_out_path = "${unittest_output_path}/utils_test" |
| 19 | 20 | ||
| 20 | config("module_private_config") { | 21 | config("module_private_config") { |
| @@ -75,8 +76,11 @@ ohos_unittest("CommonUtilsTest") { | |||
| 75 | ] | 76 | ] |
| 76 | cflags_cc = cflags | 77 | cflags_cc = cflags |
| 77 | } | 78 | } |
| 79 | +} | ||
| 78 | 80 | ||
| 79 | group("utils_test") { | 81 | group("utils_test") { |
| 80 | testonly = true | 82 | testonly = true |
| 83 | +if (!defined(ohos_lite)) { | ||
| 81 | deps = [ ":CommonUtilsTest" ] | 84 | deps = [ ":CommonUtilsTest" ] |
| 82 | } | 85 | } |
| 86 | +} | ||
| @@ -15,7 +15,8 @@ import("//build/ohos.gni") | |||
| 15 | import( | 15 | import( |
| 16 | "//foundation/distributedhardware/distributed_camera/distributedcamera.gni") | 16 | "//foundation/distributedhardware/distributed_camera/distributedcamera.gni") |
| 17 | 17 | ||
| 18 | -ohos_shared_library("distributed_camera_sink_sdk") { | 18 | +if (!defined(ohos_lite)) { |
| 19 | + ohos_shared_library("distributed_camera_sink_sdk") { | ||
| 19 | branch_protector_ret = "pac_ret" | 20 | branch_protector_ret = "pac_ret" |
| 20 | sanitize = { | 21 | sanitize = { |
| 21 | cfi = true | 22 | cfi = true |
| @@ -28,19 +29,19 @@ ohos_shared_library("distributed_camera_sink_sdk") { | |||
| 28 | stack_protector_ret = true | 29 | stack_protector_ret = true |
| 29 | 30 | ||
| 30 | include_dirs = [ | 31 | include_dirs = [ |
| 31 | - "include", | ||
| 32 | - "include/callback", | ||
| 33 | "${common_path}/include/constants", | 32 | "${common_path}/include/constants", |
| 34 | "${common_path}/include/utils", | 33 | "${common_path}/include/utils", |
| 34 | + "include/standard", | ||
| 35 | + "include/standard/callback", | ||
| 35 | ] | 36 | ] |
| 36 | 37 | ||
| 37 | sources = [ | 38 | sources = [ |
| 38 | - "src/callback/dcamera_sink_callback.cpp", | 39 | + "src/standard/callback/dcamera_sink_callback.cpp", |
| 39 | - "src/callback/dcamera_sink_callback_stub.cpp", | 40 | + "src/standard/callback/dcamera_sink_callback_stub.cpp", |
| 40 | - "src/dcamera_sink_handler.cpp", | 41 | + "src/standard/dcamera_sink_handler.cpp", |
| 41 | - "src/dcamera_sink_handler_ipc.cpp", | 42 | + "src/standard/dcamera_sink_handler_ipc.cpp", |
| 42 | - "src/dcamera_sink_load_callback.cpp", | 43 | + "src/standard/dcamera_sink_load_callback.cpp", |
| 43 | - "src/distributed_camera_sink_proxy.cpp", | 44 | + "src/standard/distributed_camera_sink_proxy.cpp", |
| 44 | ] | 45 | ] |
| 45 | 46 | ||
| 46 | ldflags = [ | 47 | ldflags = [ |
| @@ -68,4 +69,54 @@ ohos_shared_library("distributed_camera_sink_sdk") { | |||
| 68 | subsystem_name = "distributedhardware" | 69 | subsystem_name = "distributedhardware" |
| 69 | 70 | ||
| 70 | part_name = "distributed_camera" | 71 | part_name = "distributed_camera" |
| 72 | + } | ||
| 73 | +} else { | ||
| 74 | + ohos_shared_library("distributed_camera_sink_sdk") { | ||
| 75 | + branch_protector_ret = "pac_ret" | ||
| 76 | + stack_protector_ret = true | ||
| 77 | + | ||
| 78 | + include_dirs = [ | ||
| 79 | + "${common_path}/include/constants", | ||
| 80 | + "${common_path}/include/utils", | ||
| 81 | + "include/lite", | ||
| 82 | + "include/lite/callback", | ||
| 83 | + ] | ||
| 84 | + | ||
| 85 | + sources = [ | ||
| 86 | + "src/lite/callback/dcamera_sink_callback.cpp", | ||
| 87 | + "src/lite/dcamera_sink_handler.cpp", | ||
| 88 | + "src/lite/distributed_camera_sink.cpp", | ||
| 89 | + ] | ||
| 90 | + | ||
| 91 | + ldflags = [ | ||
| 92 | + "-fpie", | ||
| 93 | + "-Wl,-z,relro", | ||
| 94 | + "-Wl,-z,now", | ||
| 95 | + ] | ||
| 96 | + | ||
| 97 | + defines = [ | ||
| 98 | + "HI_LOG_ENABLE", | ||
| 99 | + "DH_LOG_TAG=\"dcamerasinkkits\"", | ||
| 100 | + "LOG_DOMAIN=0xD004150", | ||
| 101 | + "OHOS_LITE", | ||
| 102 | + ] | ||
| 103 | + | ||
| 104 | + deps = [ | ||
| 105 | + "${common_path}:distributed_camera_utils", | ||
| 106 | + "${services_path}/cameraservice/sinkservice:distributed_camera_sink", | ||
| 107 | + ] | ||
| 108 | + | ||
| 109 | + external_deps = [ | ||
| 110 | + "distributed_hardware_fwk:distributedhardwareutils", | ||
| 111 | + "hilog_lite:hilog_shared", | ||
| 112 | + ] | ||
| 113 | + | ||
| 114 | + public_configs = [ | ||
| 115 | + "${services_path}/cameraservice/sinkservice:distributed_camera_sink_public_config", | ||
| 116 | + ] | ||
| 117 | + | ||
| 118 | + subsystem_name = "distributedhardware" | ||
| 119 | + | ||
| 120 | + part_name = "distributed_camera" | ||
| 121 | + } | ||
| 71 | } | 122 | } |
| @@ -0,0 +1,49 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) 2023-2025 Huawei Device Co., Ltd. | ||
| 3 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 4 | + * you may not use this file except in compliance with the License. | ||
| 5 | + * You may obtain a copy of the License at | ||
| 6 | + * | ||
| 7 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 8 | + * | ||
| 9 | + * Unless required by applicable law or agreed to in writing, software | ||
| 10 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 11 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 12 | + * See the License for the specific language governing permissions and | ||
| 13 | + * limitations under the License. | ||
| 14 | + */ | ||
| 15 | + | ||
| 16 | + | ||
| 17 | + | ||
| 18 | + | ||
| 19 | + | ||
| 20 | + | ||
| 21 | + | ||
| 22 | + | ||
| 23 | + | ||
| 24 | + | ||
| 25 | +namespace OHOS { | ||
| 26 | +namespace DistributedHardware { | ||
| 27 | +class DCameraSinkCallback : public IDCameraSinkCallback { | ||
| 28 | +public: | ||
| 29 | + DCameraSinkCallback() = default; | ||
| 30 | + ~DCameraSinkCallback() override; | ||
| 31 | + | ||
| 32 | + int32_t OnNotifyResourceInfo(const ResourceEventType &type, const std::string &subtype, | ||
| 33 | + const std::string &networkId, bool &isSensitive, bool &isSameAccout) override; | ||
| 34 | + int32_t OnHardwareStateChanged(const std::string &devId, const std::string &dhId, int32_t status) override; | ||
| 35 | + | ||
| 36 | + void PushPrivacyResCallback(const std::shared_ptr<PrivacyResourcesListener> &listener); | ||
| 37 | + void RegisterStateListener(const std::shared_ptr<DistributedHardwareSinkStateListener> listener); | ||
| 38 | + void UnRegisterStateListener(); | ||
| 39 | + | ||
| 40 | +private: | ||
| 41 | + std::mutex privacyResMutex_; | ||
| 42 | + std::vector<std::shared_ptr<PrivacyResourcesListener>> privacyResCallback_; | ||
| 43 | + std::shared_ptr<DistributedHardwareSinkStateListener> stateListener_ = nullptr; | ||
| 44 | + std::mutex stateListenerMtx_; | ||
| 45 | + const size_t DID_MAX_SIZE = 256; | ||
| 46 | +}; | ||
| 47 | +} // namespace DistributedHardware | ||
| 48 | +} // namespace OHOS | ||
| 49 | + | ||
| @@ -0,0 +1,38 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) 2023-2025 Huawei Device Co., Ltd. | ||
| 3 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 4 | + * you may not use this file except in compliance with the License. | ||
| 5 | + * You may obtain a copy of the License at | ||
| 6 | + * | ||
| 7 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 8 | + * | ||
| 9 | + * Unless required by applicable law or agreed to in writing, software | ||
| 10 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 11 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 12 | + * See the License for the specific language governing permissions and | ||
| 13 | + * limitations under the License. | ||
| 14 | + */ | ||
| 15 | + | ||
| 16 | + | ||
| 17 | + | ||
| 18 | + | ||
| 19 | + | ||
| 20 | + | ||
| 21 | +namespace OHOS { | ||
| 22 | +namespace DistributedHardware { | ||
| 23 | +class IDCameraSinkCallback { | ||
| 24 | +public: | ||
| 25 | + enum { | ||
| 26 | + NOTIFY_RESOURCEINFO = 0, | ||
| 27 | + NOTIFY_STATE_CHANGEINFO = 1, | ||
| 28 | + }; | ||
| 29 | + | ||
| 30 | + virtual ~IDCameraSinkCallback() {} | ||
| 31 | + virtual int32_t OnNotifyResourceInfo(const ResourceEventType &type, const std::string &subtype, | ||
| 32 | + const std::string &networkId, bool &isSensitive, bool &isSameAccout) = 0; | ||
| 33 | + virtual int32_t OnHardwareStateChanged(const std::string &devId, const std::string &dhId, int32_t status) = 0; | ||
| 34 | +}; | ||
| 35 | +using IDCameraSinkCallbackPtr = IDCameraSinkCallback*; | ||
| 36 | +} // namespace DistributedHardware | ||
| 37 | +} // namespace OHOS | ||
| 38 | + | ||
| @@ -0,0 +1,66 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) 2021-2025 Huawei Device Co., Ltd. | ||
| 3 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 4 | + * you may not use this file except in compliance with the License. | ||
| 5 | + * You may obtain a copy of the License at | ||
| 6 | + * | ||
| 7 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 8 | + * | ||
| 9 | + * Unless required by applicable law or agreed to in writing, software | ||
| 10 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 11 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 12 | + * See the License for the specific language governing permissions and | ||
| 13 | + * limitations under the License. | ||
| 14 | + */ | ||
| 15 | + | ||
| 16 | + | ||
| 17 | + | ||
| 18 | + | ||
| 19 | + | ||
| 20 | + | ||
| 21 | + | ||
| 22 | + | ||
| 23 | + | ||
| 24 | + | ||
| 25 | + | ||
| 26 | + | ||
| 27 | +namespace OHOS { | ||
| 28 | +namespace DistributedHardware { | ||
| 29 | +class DCameraSinkHandler : public IDistributedHardwareSink { | ||
| 30 | +FWK_DECLARE_SINGLE_INSTANCE_BASE(DCameraSinkHandler); | ||
| 31 | +public: | ||
| 32 | + int32_t InitSink(const std::string& params) override; | ||
| 33 | + int32_t ReleaseSink() override; | ||
| 34 | + int32_t SubscribeLocalHardware(const std::string& dhId, const std::string& parameters) override; | ||
| 35 | + int32_t UnsubscribeLocalHardware(const std::string& dhId) override; | ||
| 36 | + int32_t RegisterPrivacyResources(std::shared_ptr<PrivacyResourcesListener> listener) override; | ||
| 37 | + int32_t PauseDistributedHardware(const std::string &networkId) override; | ||
| 38 | + int32_t ResumeDistributedHardware(const std::string &networkId) override; | ||
| 39 | + int32_t StopDistributedHardware(const std::string &networkId) override; | ||
| 40 | + void SetSAState(); | ||
| 41 | +private: | ||
| 42 | + typedef enum { | ||
| 43 | + DCAMERA_SA_STATE_STOP = 0, | ||
| 44 | + DCAMERA_SA_STATE_START = 1, | ||
| 45 | + } DCameraSAState; | ||
| 46 | + DCameraSinkHandler(); | ||
| 47 | + ~DCameraSinkHandler(); | ||
| 48 | + void FinishStartSA(const std::string ¶ms); | ||
| 49 | + void FinishStartSAFailed(const int32_t systemAbilityId); | ||
| 50 | +private: | ||
| 51 | + std::condition_variable producerCon_; | ||
| 52 | + std::mutex producerMutex_; | ||
| 53 | + DCameraSAState state_ = DCAMERA_SA_STATE_STOP; | ||
| 54 | + DCameraSinkCallback* dCameraSinkCallback_ = nullptr; | ||
| 55 | +}; | ||
| 56 | + | ||
| 57 | + | ||
| 58 | +extern "C" { | ||
| 59 | + | ||
| 60 | +__attribute__((visibility("default"))) IDistributedHardwareSink *GetSinkHardwareHandler(); | ||
| 61 | + | ||
| 62 | +} | ||
| 63 | + | ||
| 64 | +} // namespace DistributedHardware | ||
| 65 | +} // namespace OHOS | ||
| 66 | + | ||
| @@ -0,0 +1,50 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) 2021-2025 Huawei Device Co., Ltd. | ||
| 3 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 4 | + * you may not use this file except in compliance with the License. | ||
| 5 | + * You may obtain a copy of the License at | ||
| 6 | + * | ||
| 7 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 8 | + * | ||
| 9 | + * Unless required by applicable law or agreed to in writing, software | ||
| 10 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 11 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 12 | + * See the License for the specific language governing permissions and | ||
| 13 | + * limitations under the License. | ||
| 14 | + */ | ||
| 15 | + | ||
| 16 | + | ||
| 17 | + | ||
| 18 | + | ||
| 19 | + | ||
| 20 | + | ||
| 21 | + | ||
| 22 | + | ||
| 23 | + | ||
| 24 | + | ||
| 25 | +namespace OHOS { | ||
| 26 | +namespace DistributedHardware { | ||
| 27 | + | ||
| 28 | +class DistributedCameraSinkService; | ||
| 29 | + | ||
| 30 | +class DistributedCameraSink { | ||
| 31 | +FWK_DECLARE_SINGLE_INSTANCE_BASE(DistributedCameraSink); | ||
| 32 | +public: | ||
| 33 | + int32_t InitSink(const std::string& params, IDCameraSinkCallback* callback); | ||
| 34 | + int32_t ReleaseSink(); | ||
| 35 | + int32_t SubscribeLocalHardware(const std::string& dhId, const std::string& parameters); | ||
| 36 | + int32_t UnsubscribeLocalHardware(const std::string& dhId); | ||
| 37 | + int32_t PauseDistributedHardware(const std::string &networkId); | ||
| 38 | + int32_t ResumeDistributedHardware(const std::string &networkId); | ||
| 39 | + int32_t StopDistributedHardware(const std::string &networkId); | ||
| 40 | + | ||
| 41 | +private: | ||
| 42 | + DistributedCameraSink(); | ||
| 43 | + ~DistributedCameraSink(); | ||
| 44 | + | ||
| 45 | + DistributedCameraSinkService* sinkService_ = nullptr; | ||
| 46 | +}; | ||
| 47 | +} // namespace DistributedHardware | ||
| 48 | +} // namespace OHOS | ||
| 49 | + | ||
| 50 | + | ||
| @@ -0,0 +1,47 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. | ||
| 3 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 4 | + * you may not use this file except in compliance with the License. | ||
| 5 | + * You may obtain a copy of the License at | ||
| 6 | + * | ||
| 7 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 8 | + * | ||
| 9 | + * Unless required by applicable law or agreed to in writing, software | ||
| 10 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 11 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 12 | + * See the License for the specific language governing permissions and | ||
| 13 | + * limitations under the License. | ||
| 14 | + */ | ||
| 15 | + | ||
| 16 | + | ||
| 17 | + | ||
| 18 | + | ||
| 19 | + | ||
| 20 | + | ||
| 21 | + | ||
| 22 | +namespace OHOS { | ||
| 23 | +namespace DistributedHardware { | ||
| 24 | +class IDistributedCameraSink { | ||
| 25 | +public: | ||
| 26 | + IDistributedCameraSink() = default; | ||
| 27 | + virtual ~IDistributedCameraSink() = default; | ||
| 28 | + virtual int32_t InitSink(const std::string& params, const IDCameraSinkCallbackPtr &sinkCallback) = 0; | ||
| 29 | + virtual int32_t ReleaseSink() = 0; | ||
| 30 | + virtual int32_t SubscribeLocalHardware(const std::string& dhId, const std::string& parameters) = 0; | ||
| 31 | + virtual int32_t UnsubscribeLocalHardware(const std::string& dhId) = 0; | ||
| 32 | + virtual int32_t StopCapture(const std::string& dhId) = 0; | ||
| 33 | + virtual int32_t ChannelNeg(const std::string& dhId, std::string& channelInfo) = 0; | ||
| 34 | + virtual int32_t GetCameraInfo(const std::string& dhId, std::string& cameraInfo) = 0; | ||
| 35 | + virtual int32_t OpenChannel(const std::string& dhId, std::string& openInfo) = 0; | ||
| 36 | + virtual int32_t CloseChannel(const std::string& dhId) = 0; | ||
| 37 | + virtual int32_t PauseDistributedHardware(const std::string &networkId) = 0; | ||
| 38 | + virtual int32_t ResumeDistributedHardware(const std::string &networkId) = 0; | ||
| 39 | + virtual int32_t StopDistributedHardware(const std::string &networkId) = 0; | ||
| 40 | + virtual int32_t SetAccessListener(const IAccessListenerPtr &listener, int32_t timeOut, | ||
| 41 | + const std::string &pkgName) = 0; | ||
| 42 | + virtual int32_t RemoveAccessListener(const std::string &pkgName) = 0; | ||
| 43 | + virtual int32_t SetAuthorizationResult(const std::string &requestId, bool granted) = 0; | ||
| 44 | +}; | ||
| 45 | +} // namespace DistributedHardware | ||
| 46 | +} // namespace OHOS | ||
| 47 | + | ||
Rinterfaces/inner_kits/native_cpp/camera_sink/include/callback/dcamera_sink_callback.h→interfaces/inner_kits/native_cpp/camera_sink/include/standard/callback/dcamera_sink_callback.h+0-0
文件重命名但无更改。
Rinterfaces/inner_kits/native_cpp/camera_sink/include/callback/dcamera_sink_callback_stub.h→interfaces/inner_kits/native_cpp/camera_sink/include/standard/callback/dcamera_sink_callback_stub.h+4-0
| @@ -18,7 +18,9 @@ | |||
| 18 | 18 | ||
| 19 | 19 | ||
| 20 | 20 | ||
| 21 | + | ||
| 21 | 22 | ||
| 23 | + | ||
| 22 | 24 | ||
| 23 | 25 | ||
| 24 | namespace OHOS { class MessageOption; } | 26 | namespace OHOS { class MessageOption; } |
| @@ -26,6 +28,7 @@ namespace OHOS { class MessageParcel; } | |||
| 26 | 28 | ||
| 27 | namespace OHOS { | 29 | namespace OHOS { |
| 28 | namespace DistributedHardware { | 30 | namespace DistributedHardware { |
| 31 | + | ||
| 29 | class DCameraSinkCallbackStub : public IRemoteStub<IDCameraSinkCallback> { | 32 | class DCameraSinkCallbackStub : public IRemoteStub<IDCameraSinkCallback> { |
| 30 | public: | 33 | public: |
| 31 | DCameraSinkCallbackStub(); | 34 | DCameraSinkCallbackStub(); |
| @@ -39,6 +42,7 @@ private: | |||
| 39 | using DCameraFunc = int32_t (DCameraSinkCallbackStub::*)(MessageParcel &data, MessageParcel &reply); | 42 | using DCameraFunc = int32_t (DCameraSinkCallbackStub::*)(MessageParcel &data, MessageParcel &reply); |
| 40 | std::map<uint32_t, DCameraFunc> memberFuncMap_; | 43 | std::map<uint32_t, DCameraFunc> memberFuncMap_; |
| 41 | }; | 44 | }; |
| 45 | + | ||
| 42 | } // namespace DistributedHardware | 46 | } // namespace DistributedHardware |
| 43 | } // namespace OHOS | 47 | } // namespace OHOS |
| 44 | 48 | ||
Rinterfaces/inner_kits/native_cpp/camera_sink/include/callback/idcamera_sink_callback.h→interfaces/inner_kits/native_cpp/camera_sink/include/standard/callback/idcamera_sink_callback.h+1-0
| @@ -34,6 +34,7 @@ public: | |||
| 34 | const std::string &networkId, bool &isSensitive, bool &isSameAccout) = 0; | 34 | const std::string &networkId, bool &isSensitive, bool &isSameAccout) = 0; |
| 35 | virtual int32_t OnHardwareStateChanged(const std::string &devId, const std::string &dhId, int32_t status) = 0; | 35 | virtual int32_t OnHardwareStateChanged(const std::string &devId, const std::string &dhId, int32_t status) = 0; |
| 36 | }; | 36 | }; |
| 37 | +using IDCameraSinkCallbackPtr = sptr<IDCameraSinkCallback>; | ||
| 37 | } // namespace DistributedHardware | 38 | } // namespace DistributedHardware |
| 38 | } // namespace OHOS | 39 | } // namespace OHOS |
| 39 | 40 | ||
Rinterfaces/inner_kits/native_cpp/camera_sink/include/dcamera_sink_handler.h→interfaces/inner_kits/native_cpp/camera_sink/include/standard/dcamera_sink_handler.h+1-1
| @@ -37,7 +37,7 @@ public: | |||
| 37 | int32_t PauseDistributedHardware(const std::string &networkId) override; | 37 | int32_t PauseDistributedHardware(const std::string &networkId) override; |
| 38 | int32_t ResumeDistributedHardware(const std::string &networkId) override; | 38 | int32_t ResumeDistributedHardware(const std::string &networkId) override; |
| 39 | int32_t StopDistributedHardware(const std::string &networkId) override; | 39 | int32_t StopDistributedHardware(const std::string &networkId) override; |
| 40 | - int32_t SetAccessListener(sptr<IAccessListener> listener, int32_t &timeOut, | 40 | + int32_t SetAccessListener(IAccessListenerPtr listener, int32_t &timeOut, |
| 41 | const std::string &pkgName) override; | 41 | const std::string &pkgName) override; |
| 42 | int32_t RemoveAccessListener(const std::string &pkgName) override; | 42 | int32_t RemoveAccessListener(const std::string &pkgName) override; |
| 43 | int32_t SetAuthorizationResult(const std::string &requestId, bool granted) override; | 43 | int32_t SetAuthorizationResult(const std::string &requestId, bool granted) override; |
Rinterfaces/inner_kits/native_cpp/camera_sink/include/dcamera_sink_handler_ipc.h→interfaces/inner_kits/native_cpp/camera_sink/include/standard/dcamera_sink_handler_ipc.h+0-0
文件重命名但无更改。
Rinterfaces/inner_kits/native_cpp/camera_sink/include/dcamera_sink_load_callback.h→interfaces/inner_kits/native_cpp/camera_sink/include/standard/dcamera_sink_load_callback.h+0-0
文件重命名但无更改。
Rinterfaces/inner_kits/native_cpp/camera_sink/include/distributed_camera_sink_proxy.h→interfaces/inner_kits/native_cpp/camera_sink/include/standard/distributed_camera_sink_proxy.h+4-3
| @@ -18,9 +18,10 @@ | |||
| 18 | 18 | ||
| 19 | 19 | ||
| 20 | 20 | ||
| 21 | + | ||
| 21 | 22 | ||
| 22 | 23 | ||
| 23 | -#include "refbase.h" | 24 | +#endif |
| 24 | 25 | ||
| 25 | namespace OHOS { | 26 | namespace OHOS { |
| 26 | namespace DistributedHardware { | 27 | namespace DistributedHardware { |
| @@ -32,7 +33,7 @@ public: | |||
| 32 | } | 33 | } |
| 33 | 34 | ||
| 34 | ~DistributedCameraSinkProxy() {} | 35 | ~DistributedCameraSinkProxy() {} |
| 35 | - int32_t InitSink(const std::string& params, const sptr<IDCameraSinkCallback> &sinkCallback) override; | 36 | + int32_t InitSink(const std::string& params, const IDCameraSinkCallbackPtr &sinkCallback) override; |
| 36 | int32_t ReleaseSink() override; | 37 | int32_t ReleaseSink() override; |
| 37 | int32_t SubscribeLocalHardware(const std::string& dhId, const std::string& parameters) override; | 38 | int32_t SubscribeLocalHardware(const std::string& dhId, const std::string& parameters) override; |
| 38 | int32_t UnsubscribeLocalHardware(const std::string& dhId) override; | 39 | int32_t UnsubscribeLocalHardware(const std::string& dhId) override; |
| @@ -44,7 +45,7 @@ public: | |||
| 44 | int32_t PauseDistributedHardware(const std::string &networkId) override; | 45 | int32_t PauseDistributedHardware(const std::string &networkId) override; |
| 45 | int32_t ResumeDistributedHardware(const std::string &networkId) override; | 46 | int32_t ResumeDistributedHardware(const std::string &networkId) override; |
| 46 | int32_t StopDistributedHardware(const std::string &networkId) override; | 47 | int32_t StopDistributedHardware(const std::string &networkId) override; |
| 47 | - int32_t SetAccessListener(const sptr<IAccessListener> &listener, int32_t timeOut, | 48 | + int32_t SetAccessListener(const IAccessListenerPtr &listener, int32_t timeOut, |
| 48 | const std::string &pkgName) override; | 49 | const std::string &pkgName) override; |
| 49 | int32_t RemoveAccessListener(const std::string &pkgName) override; | 50 | int32_t RemoveAccessListener(const std::string &pkgName) override; |
| 50 | int32_t SetAuthorizationResult(const std::string &requestId, bool granted) override; | 51 | int32_t SetAuthorizationResult(const std::string &requestId, bool granted) override; |
Rinterfaces/inner_kits/native_cpp/camera_sink/include/idistributed_camera_sink.h→interfaces/inner_kits/native_cpp/camera_sink/include/standard/idistributed_camera_sink.h+2-2
| @@ -28,7 +28,7 @@ public: | |||
| 28 | 28 | ||
| 29 | IDistributedCameraSink() = default; | 29 | IDistributedCameraSink() = default; |
| 30 | virtual ~IDistributedCameraSink() = default; | 30 | virtual ~IDistributedCameraSink() = default; |
| 31 | - virtual int32_t InitSink(const std::string& params, const sptr<IDCameraSinkCallback> &sinkCallback) = 0; | 31 | + virtual int32_t InitSink(const std::string& params, const IDCameraSinkCallbackPtr &sinkCallback) = 0; |
| 32 | virtual int32_t ReleaseSink() = 0; | 32 | virtual int32_t ReleaseSink() = 0; |
| 33 | virtual int32_t SubscribeLocalHardware(const std::string& dhId, const std::string& parameters) = 0; | 33 | virtual int32_t SubscribeLocalHardware(const std::string& dhId, const std::string& parameters) = 0; |
| 34 | virtual int32_t UnsubscribeLocalHardware(const std::string& dhId) = 0; | 34 | virtual int32_t UnsubscribeLocalHardware(const std::string& dhId) = 0; |
| @@ -40,7 +40,7 @@ public: | |||
| 40 | virtual int32_t PauseDistributedHardware(const std::string &networkId) = 0; | 40 | virtual int32_t PauseDistributedHardware(const std::string &networkId) = 0; |
| 41 | virtual int32_t ResumeDistributedHardware(const std::string &networkId) = 0; | 41 | virtual int32_t ResumeDistributedHardware(const std::string &networkId) = 0; |
| 42 | virtual int32_t StopDistributedHardware(const std::string &networkId) = 0; | 42 | virtual int32_t StopDistributedHardware(const std::string &networkId) = 0; |
| 43 | - virtual int32_t SetAccessListener(const sptr<IAccessListener> &listener, int32_t timeOut, | 43 | + virtual int32_t SetAccessListener(const IAccessListenerPtr &listener, int32_t timeOut, |
| 44 | const std::string &pkgName) = 0; | 44 | const std::string &pkgName) = 0; |
| 45 | virtual int32_t RemoveAccessListener(const std::string &pkgName) = 0; | 45 | virtual int32_t RemoveAccessListener(const std::string &pkgName) = 0; |
| 46 | virtual int32_t SetAuthorizationResult(const std::string &requestId, bool granted) = 0; | 46 | virtual int32_t SetAuthorizationResult(const std::string &requestId, bool granted) = 0; |
Rinterfaces/inner_kits/native_cpp/camera_sink/src/callback/dcamera_sink_callback.cpp→interfaces/inner_kits/native_cpp/camera_sink/src/lite/callback/dcamera_sink_callback.cpp+0-0
文件重命名但无更改。
| @@ -0,0 +1,144 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) 2021-2025 Huawei Device Co., Ltd. | ||
| 3 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 4 | + * you may not use this file except in compliance with the License. | ||
| 5 | + * You may obtain a copy of the License at | ||
| 6 | + * | ||
| 7 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 8 | + * | ||
| 9 | + * Unless required by applicable law or agreed to in writing, software | ||
| 10 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 11 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 12 | + * See the License for the specific language governing permissions and | ||
| 13 | + * limitations under the License. | ||
| 14 | + */ | ||
| 15 | + | ||
| 16 | + | ||
| 17 | + | ||
| 18 | + | ||
| 19 | + | ||
| 20 | + | ||
| 21 | + | ||
| 22 | + | ||
| 23 | + | ||
| 24 | + | ||
| 25 | + | ||
| 26 | + | ||
| 27 | +namespace OHOS { | ||
| 28 | +namespace DistributedHardware { | ||
| 29 | + | ||
| 30 | +FWK_IMPLEMENT_SINGLE_INSTANCE(DCameraSinkHandler); | ||
| 31 | + | ||
| 32 | +DCameraSinkHandler::DCameraSinkHandler() | ||
| 33 | +{ | ||
| 34 | + DHLOGI("DCameraSinkHandler ctor."); | ||
| 35 | + if (!dCameraSinkCallback_) { | ||
| 36 | + dCameraSinkCallback_ = new DCameraSinkCallback(); | ||
| 37 | + } | ||
| 38 | +} | ||
| 39 | + | ||
| 40 | +DCameraSinkHandler::~DCameraSinkHandler() | ||
| 41 | +{ | ||
| 42 | + DHLOGI("~DCameraSinkHandler"); | ||
| 43 | + delete dCameraSinkCallback_; | ||
| 44 | + dCameraSinkCallback_ = nullptr; | ||
| 45 | +} | ||
| 46 | + | ||
| 47 | +int32_t DCameraSinkHandler::InitSink(const std::string& params) | ||
| 48 | +{ | ||
| 49 | + DHLOGI("start"); | ||
| 50 | + { | ||
| 51 | + std::lock_guard<std::mutex> autoLock(producerMutex_); | ||
| 52 | + if (state_ == DCAMERA_SA_STATE_START) { | ||
| 53 | + return DCAMERA_OK; | ||
| 54 | + } | ||
| 55 | + } | ||
| 56 | + | ||
| 57 | + ReportSaEvent(INIT_SA_EVENT, DISTRIBUTED_HARDWARE_CAMERA_SINK_SA_ID, "init sink sa event."); | ||
| 58 | + int32_t ret = DistributedCameraSink::GetInstance().InitSink(params, dCameraSinkCallback_); | ||
| 59 | + if (ret != DCAMERA_OK) { | ||
| 60 | + DHLOGE("distributed camera sink init failed, ret: %{public}d", ret); | ||
| 61 | + return ret; | ||
| 62 | + } | ||
| 63 | + std::unique_lock<std::mutex> lock(producerMutex_); | ||
| 64 | + state_ = DCAMERA_SA_STATE_START; | ||
| 65 | + DHLOGI("end, result: %{public}d", ret); | ||
| 66 | + return DCAMERA_OK; | ||
| 67 | +} | ||
| 68 | + | ||
| 69 | +void DCameraSinkHandler::FinishStartSA(const std::string& params) | ||
| 70 | +{ | ||
| 71 | + DistributedCameraSink::GetInstance().InitSink(params, dCameraSinkCallback_); | ||
| 72 | + std::unique_lock<std::mutex> lock(producerMutex_); | ||
| 73 | + state_ = DCAMERA_SA_STATE_START; | ||
| 74 | + producerCon_.notify_one(); | ||
| 75 | +} | ||
| 76 | + | ||
| 77 | +void DCameraSinkHandler::FinishStartSAFailed(const int32_t systemAbilityId) | ||
| 78 | +{ | ||
| 79 | + DHLOGI("SinkSA Start failed, systemAbilityId: %{public}d.", systemAbilityId); | ||
| 80 | + std::unique_lock<std::mutex> lock(producerMutex_); | ||
| 81 | + state_ = DCAMERA_SA_STATE_STOP; | ||
| 82 | + producerCon_.notify_one(); | ||
| 83 | +} | ||
| 84 | + | ||
| 85 | +int32_t DCameraSinkHandler::ReleaseSink() | ||
| 86 | +{ | ||
| 87 | + DHLOGI("start"); | ||
| 88 | + return DCAMERA_OK; | ||
| 89 | +} | ||
| 90 | + | ||
| 91 | +int32_t DCameraSinkHandler::SubscribeLocalHardware(const std::string& dhId, const std::string& parameters) | ||
| 92 | +{ | ||
| 93 | + DHLOGI("dhId: %{public}s", GetAnonyString(dhId).c_str()); | ||
| 94 | + (void)parameters; | ||
| 95 | + return DCAMERA_OK; | ||
| 96 | +} | ||
| 97 | + | ||
| 98 | +int32_t DCameraSinkHandler::UnsubscribeLocalHardware(const std::string& dhId) | ||
| 99 | +{ | ||
| 100 | + DHLOGI("dhId: %{public}s", GetAnonyString(dhId).c_str()); | ||
| 101 | + return DCAMERA_OK; | ||
| 102 | +} | ||
| 103 | + | ||
| 104 | +int32_t DCameraSinkHandler::RegisterPrivacyResources(std::shared_ptr<PrivacyResourcesListener> listener) | ||
| 105 | +{ | ||
| 106 | + DHLOGI("RegisterPrivacyResources start."); | ||
| 107 | + (void)listener; | ||
| 108 | + return DCAMERA_OK; | ||
| 109 | +} | ||
| 110 | + | ||
| 111 | +int32_t DCameraSinkHandler::PauseDistributedHardware(const std::string &networkId) | ||
| 112 | +{ | ||
| 113 | + DHLOGI("pause distributed hardware."); | ||
| 114 | + (void)networkId; | ||
| 115 | + return DCAMERA_OK; | ||
| 116 | +} | ||
| 117 | + | ||
| 118 | +int32_t DCameraSinkHandler::ResumeDistributedHardware(const std::string &networkId) | ||
| 119 | +{ | ||
| 120 | + DHLOGI("resume distributed hardware."); | ||
| 121 | + (void)networkId; | ||
| 122 | + return DCAMERA_OK; | ||
| 123 | +} | ||
| 124 | + | ||
| 125 | +int32_t DCameraSinkHandler::StopDistributedHardware(const std::string &networkId) | ||
| 126 | +{ | ||
| 127 | + DHLOGI("stop distributed hardware."); | ||
| 128 | + (void)networkId; | ||
| 129 | + return DCAMERA_OK; | ||
| 130 | +} | ||
| 131 | + | ||
| 132 | +void DCameraSinkHandler::SetSAState() | ||
| 133 | +{ | ||
| 134 | + std::unique_lock<std::mutex> lock(producerMutex_); | ||
| 135 | + state_ = DCAMERA_SA_STATE_STOP; | ||
| 136 | +} | ||
| 137 | + | ||
| 138 | +IDistributedHardwareSink *GetSinkHardwareHandler() | ||
| 139 | +{ | ||
| 140 | + DHLOGI("DCameraSinkHandler::GetSinkHardwareHandler"); | ||
| 141 | + return &DCameraSinkHandler::GetInstance(); | ||
| 142 | +} | ||
| 143 | +} // namespace DistributedHardware | ||
| 144 | +} // namespace OHOS | ||
| @@ -0,0 +1,98 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) 2021-2025 Huawei Device Co., Ltd. | ||
| 3 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 4 | + * you may not use this file except in compliance with the License. | ||
| 5 | + * You may obtain a copy of the License at | ||
| 6 | + * | ||
| 7 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 8 | + * | ||
| 9 | + * Unless required by applicable law or agreed to in writing, software | ||
| 10 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 11 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 12 | + * See the License for the specific language governing permissions and | ||
| 13 | + * limitations under the License. | ||
| 14 | + */ | ||
| 15 | + | ||
| 16 | + | ||
| 17 | + | ||
| 18 | + | ||
| 19 | + | ||
| 20 | + | ||
| 21 | + | ||
| 22 | + | ||
| 23 | +namespace OHOS { | ||
| 24 | +namespace DistributedHardware { | ||
| 25 | + | ||
| 26 | +FWK_IMPLEMENT_SINGLE_INSTANCE(DistributedCameraSink); | ||
| 27 | + | ||
| 28 | +DistributedCameraSink::DistributedCameraSink() | ||
| 29 | +{ | ||
| 30 | + DHLOGI("DistributedCameraSink ctor."); | ||
| 31 | + sinkService_ = &DistributedCameraSinkService::GetInstance(); | ||
| 32 | +} | ||
| 33 | + | ||
| 34 | +DistributedCameraSink::~DistributedCameraSink() | ||
| 35 | +{ | ||
| 36 | + DHLOGI("~DistributedCameraSink"); | ||
| 37 | + sinkService_ = nullptr; | ||
| 38 | +} | ||
| 39 | + | ||
| 40 | +int32_t DistributedCameraSink::InitSink(const std::string& params, IDCameraSinkCallback* callback) | ||
| 41 | +{ | ||
| 42 | + DHLOGI("start"); | ||
| 43 | + if (sinkService_ == nullptr) { | ||
| 44 | + DHLOGE("sink service is nullptr"); | ||
| 45 | + return DCAMERA_INIT_ERR; | ||
| 46 | + } | ||
| 47 | + sinkService_->Start(); | ||
| 48 | + int32_t ret = sinkService_->InitSink(params, callback); | ||
| 49 | + if (ret != DCAMERA_OK) { | ||
| 50 | + DHLOGE("sink service init failed, ret: %{public}d", ret); | ||
| 51 | + return ret; | ||
| 52 | + } | ||
| 53 | + DHLOGI("end, result: %{public}d", ret); | ||
| 54 | + return DCAMERA_OK; | ||
| 55 | +} | ||
| 56 | + | ||
| 57 | +int32_t DistributedCameraSink::ReleaseSink() | ||
| 58 | +{ | ||
| 59 | + DHLOGI("start"); | ||
| 60 | + return DCAMERA_OK; | ||
| 61 | +} | ||
| 62 | + | ||
| 63 | +int32_t DistributedCameraSink::SubscribeLocalHardware(const std::string& dhId, const std::string& parameters) | ||
| 64 | +{ | ||
| 65 | + DHLOGI("dhId: %{public}s", dhId.c_str()); | ||
| 66 | + (void)parameters; | ||
| 67 | + return DCAMERA_OK; | ||
| 68 | +} | ||
| 69 | + | ||
| 70 | +int32_t DistributedCameraSink::UnsubscribeLocalHardware(const std::string& dhId) | ||
| 71 | +{ | ||
| 72 | + DHLOGI("dhId: %{public}s", dhId.c_str()); | ||
| 73 | + return DCAMERA_OK; | ||
| 74 | +} | ||
| 75 | + | ||
| 76 | +int32_t DistributedCameraSink::PauseDistributedHardware(const std::string &networkId) | ||
| 77 | +{ | ||
| 78 | + DHLOGI("pause distributed hardware."); | ||
| 79 | + (void)networkId; | ||
| 80 | + return DCAMERA_OK; | ||
| 81 | +} | ||
| 82 | + | ||
| 83 | +int32_t DistributedCameraSink::ResumeDistributedHardware(const std::string &networkId) | ||
| 84 | +{ | ||
| 85 | + DHLOGI("resume distributed hardware."); | ||
| 86 | + (void)networkId; | ||
| 87 | + return DCAMERA_OK; | ||
| 88 | +} | ||
| 89 | + | ||
| 90 | +int32_t DistributedCameraSink::StopDistributedHardware(const std::string &networkId) | ||
| 91 | +{ | ||
| 92 | + DHLOGI("stop distributed hardware."); | ||
| 93 | + (void)networkId; | ||
| 94 | + return DCAMERA_OK; | ||
| 95 | +} | ||
| 96 | + | ||
| 97 | +} // namespace DistributedHardware | ||
| 98 | +} // namespace OHOS | ||
| @@ -0,0 +1,90 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) 2023-2025 Huawei Device Co., Ltd. | ||
| 3 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 4 | + * you may not use this file except in compliance with the License. | ||
| 5 | + * You may obtain a copy of the License at | ||
| 6 | + * | ||
| 7 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 8 | + * | ||
| 9 | + * Unless required by applicable law or agreed to in writing, software | ||
| 10 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 11 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 12 | + * See the License for the specific language governing permissions and | ||
| 13 | + * limitations under the License. | ||
| 14 | + */ | ||
| 15 | + | ||
| 16 | + | ||
| 17 | + | ||
| 18 | + | ||
| 19 | + | ||
| 20 | + | ||
| 21 | + | ||
| 22 | +namespace OHOS { | ||
| 23 | +namespace DistributedHardware { | ||
| 24 | +DCameraSinkCallback::~DCameraSinkCallback() | ||
| 25 | +{ | ||
| 26 | + privacyResCallback_.clear(); | ||
| 27 | +} | ||
| 28 | + | ||
| 29 | +int32_t DCameraSinkCallback::OnNotifyResourceInfo(const ResourceEventType &type, const std::string &subtype, | ||
| 30 | + const std::string &networkId, bool &isSensitive, bool &isSameAccout) | ||
| 31 | +{ | ||
| 32 | + DHLOGI("DCameraSinkCallback OnNotifyResourceInfo type: %{public}d, subtype: %{public}s, networkId: %{public}s, " | ||
| 33 | + "isSensitive: %{public}d, isSameAccout: %{public}d", (uint32_t)type, subtype.c_str(), | ||
| 34 | + GetAnonyString(networkId).c_str(), isSensitive, isSameAccout); | ||
| 35 | + int32_t ret = DCAMERA_OK; | ||
| 36 | + std::lock_guard<std::mutex> lock(privacyResMutex_); | ||
| 37 | + auto iter = privacyResCallback_.begin(); | ||
| 38 | + if (iter != privacyResCallback_.end()) { | ||
| 39 | + if (*iter != nullptr) { | ||
| 40 | + ret = (*iter)->OnPrivaceResourceMessage(type, subtype, networkId, isSensitive, isSameAccout); | ||
| 41 | + } | ||
| 42 | + } | ||
| 43 | + return ret; | ||
| 44 | +} | ||
| 45 | + | ||
| 46 | +int32_t DCameraSinkCallback::OnHardwareStateChanged(const std::string &devId, const std::string &dhId, | ||
| 47 | + int32_t status) | ||
| 48 | +{ | ||
| 49 | + DHLOGI("On hardware state changed, devId: %{public}s, dhId: %{public}s, status: %{public}d", | ||
| 50 | + GetAnonyString(devId).c_str(), dhId.c_str(), status); | ||
| 51 | + std::lock_guard<std::mutex> stateLck(stateListenerMtx_); | ||
| 52 | + if (stateListener_ == nullptr) { | ||
| 53 | + DHLOGE("State listener is null."); | ||
| 54 | + return DCAMERA_BAD_VALUE; | ||
| 55 | + } | ||
| 56 | + if (devId.empty() || devId.size() > DID_MAX_SIZE || dhId.empty() || dhId.size() > DID_MAX_SIZE) { | ||
| 57 | + DHLOGE("devId or dhId is invalid"); | ||
| 58 | + return DCAMERA_BAD_VALUE; | ||
| 59 | + } | ||
| 60 | + if (status < 0) { | ||
| 61 | + DHLOGE("status in invalid."); | ||
| 62 | + return DCAMERA_BAD_VALUE; | ||
| 63 | + } | ||
| 64 | + BusinessSinkState currentState = static_cast<BusinessSinkState>(status); | ||
| 65 | + stateListener_->OnStateChanged(devId, dhId, currentState); | ||
| 66 | + return DCAMERA_OK; | ||
| 67 | +} | ||
| 68 | + | ||
| 69 | +void DCameraSinkCallback::PushPrivacyResCallback(const std::shared_ptr<PrivacyResourcesListener> &listener) | ||
| 70 | +{ | ||
| 71 | + DHLOGI("push resource info callback."); | ||
| 72 | + std::lock_guard<std::mutex> lock(privacyResMutex_); | ||
| 73 | + privacyResCallback_.push_back(listener); | ||
| 74 | +} | ||
| 75 | + | ||
| 76 | +void DCameraSinkCallback::RegisterStateListener(const std::shared_ptr<DistributedHardwareSinkStateListener> listener) | ||
| 77 | +{ | ||
| 78 | + DHLOGD("Register sink state listener."); | ||
| 79 | + std::lock_guard<std::mutex> stateLck(stateListenerMtx_); | ||
| 80 | + stateListener_ = listener; | ||
| 81 | +} | ||
| 82 | + | ||
| 83 | +void DCameraSinkCallback::UnRegisterStateListener() | ||
| 84 | +{ | ||
| 85 | + DHLOGD("UnRegister sink state listener."); | ||
| 86 | + std::lock_guard<std::mutex> stateLck(stateListenerMtx_); | ||
| 87 | + stateListener_ = nullptr; | ||
| 88 | +} | ||
| 89 | +} // namespace DistributedHardware | ||
| 90 | +} // namespace OHOS | ||
Rinterfaces/inner_kits/native_cpp/camera_sink/src/callback/dcamera_sink_callback_stub.cpp→interfaces/inner_kits/native_cpp/camera_sink/src/standard/callback/dcamera_sink_callback_stub.cpp+2-0
| @@ -16,7 +16,9 @@ | |||
| 16 | 16 | ||
| 17 | 17 | ||
| 18 | 18 | ||
| 19 | + | ||
| 19 | 20 | ||
| 21 | + | ||
| 20 | 22 | ||
| 21 | 23 | ||
| 22 | namespace OHOS { class MessageOption; } | 24 | namespace OHOS { class MessageOption; } |
Rinterfaces/inner_kits/native_cpp/camera_sink/src/dcamera_sink_handler.cpp→interfaces/inner_kits/native_cpp/camera_sink/src/standard/dcamera_sink_handler.cpp+2-2
| @@ -195,8 +195,8 @@ int32_t DCameraSinkHandler::StopDistributedHardware(const std::string &networkId | |||
| 195 | return dCameraSinkSrv->StopDistributedHardware(networkId); | 195 | return dCameraSinkSrv->StopDistributedHardware(networkId); |
| 196 | } | 196 | } |
| 197 | 197 | ||
| 198 | -int32_t DCameraSinkHandler::SetAccessListener(sptr<IAccessListener> listener, int32_t &timeOut, | 198 | + int32_t DCameraSinkHandler::SetAccessListener(sptr<IAccessListener> listener, int32_t &timeOut, |
| 199 | - const std::string &pkgName) | 199 | + const std::string &pkgName) |
| 200 | { | 200 | { |
| 201 | DHLOGI("Set access listener"); | 201 | DHLOGI("Set access listener"); |
| 202 | if (listener == nullptr) { | 202 | if (listener == nullptr) { |
Rinterfaces/inner_kits/native_cpp/camera_sink/src/dcamera_sink_handler_ipc.cpp→interfaces/inner_kits/native_cpp/camera_sink/src/standard/dcamera_sink_handler_ipc.cpp+2-0
| @@ -23,7 +23,9 @@ | |||
| 23 | 23 | ||
| 24 | 24 | ||
| 25 | 25 | ||
| 26 | + | ||
| 26 | 27 | ||
| 28 | + | ||
| 27 | 29 | ||
| 28 | namespace OHOS { | 30 | namespace OHOS { |
| 29 | namespace DistributedHardware { | 31 | namespace DistributedHardware { |
Rinterfaces/inner_kits/native_cpp/camera_sink/src/dcamera_sink_load_callback.cpp→interfaces/inner_kits/native_cpp/camera_sink/src/standard/dcamera_sink_load_callback.cpp+0-0
文件重命名但无更改。
Rinterfaces/inner_kits/native_cpp/camera_sink/src/distributed_camera_sink_proxy.cpp→interfaces/inner_kits/native_cpp/camera_sink/src/standard/distributed_camera_sink_proxy.cpp+2-2
| @@ -24,7 +24,7 @@ | |||
| 24 | 24 | ||
| 25 | namespace OHOS { | 25 | namespace OHOS { |
| 26 | namespace DistributedHardware { | 26 | namespace DistributedHardware { |
| 27 | -int32_t DistributedCameraSinkProxy::InitSink(const std::string& params, const sptr<IDCameraSinkCallback> &sinkCallback) | 27 | +int32_t DistributedCameraSinkProxy::InitSink(const std::string& params, const IDCameraSinkCallbackPtr &sinkCallback) |
| 28 | { | 28 | { |
| 29 | DHLOGI("start"); | 29 | DHLOGI("start"); |
| 30 | if (params.empty() || params.size() > PARAM_MAX_SIZE) { | 30 | if (params.empty() || params.size() > PARAM_MAX_SIZE) { |
| @@ -451,7 +451,7 @@ int32_t DistributedCameraSinkProxy::StopDistributedHardware(const std::string &n | |||
| 451 | return result; | 451 | return result; |
| 452 | } | 452 | } |
| 453 | 453 | ||
| 454 | -int32_t DistributedCameraSinkProxy::SetAccessListener(const sptr<IAccessListener> &listener, | 454 | +int32_t DistributedCameraSinkProxy::SetAccessListener(const IAccessListenerPtr &listener, |
| 455 | int32_t timeOut, const std::string &pkgName) | 455 | int32_t timeOut, const std::string &pkgName) |
| 456 | { | 456 | { |
| 457 | DHLOGI("SetAccessListener start, pkgName: %{public}s, timeOut: %{public}d", pkgName.c_str(), timeOut); | 457 | DHLOGI("SetAccessListener start, pkgName: %{public}s, timeOut: %{public}d", pkgName.c_str(), timeOut); |
| @@ -15,7 +15,8 @@ import("//build/ohos.gni") | |||
| 15 | import( | 15 | import( |
| 16 | "//foundation/distributedhardware/distributed_camera/distributedcamera.gni") | 16 | "//foundation/distributedhardware/distributed_camera/distributedcamera.gni") |
| 17 | 17 | ||
| 18 | -ohos_shared_library("distributed_camera_source_sdk") { | 18 | +if (!defined(ohos_lite)) { |
| 19 | + ohos_shared_library("distributed_camera_source_sdk") { | ||
| 19 | branch_protector_ret = "pac_ret" | 20 | branch_protector_ret = "pac_ret" |
| 20 | sanitize = { | 21 | sanitize = { |
| 21 | cfi = true | 22 | cfi = true |
| @@ -73,4 +74,8 @@ ohos_shared_library("distributed_camera_source_sdk") { | |||
| 73 | subsystem_name = "distributedhardware" | 74 | subsystem_name = "distributedhardware" |
| 74 | 75 | ||
| 75 | part_name = "distributed_camera" | 76 | part_name = "distributed_camera" |
| 77 | + } | ||
| 78 | +} else { | ||
| 79 | +group("distributed_camera_source_sdk") { | ||
| 80 | +} | ||
| 76 | } | 81 | } |
| @@ -19,7 +19,9 @@ | |||
| 19 | 19 | ||
| 20 | 20 | ||
| 21 | 21 | ||
| 22 | + | ||
| 22 | 23 | ||
| 24 | + | ||
| 23 | 25 | ||
| 24 | 26 | ||
| 25 | namespace OHOS { class MessageOption; } | 27 | namespace OHOS { class MessageOption; } |
| @@ -27,6 +29,7 @@ namespace OHOS { class MessageParcel; } | |||
| 27 | 29 | ||
| 28 | namespace OHOS { | 30 | namespace OHOS { |
| 29 | namespace DistributedHardware { | 31 | namespace DistributedHardware { |
| 32 | + | ||
| 30 | class DCameraSourceCallbackStub : public IRemoteStub<IDCameraSourceCallback> { | 33 | class DCameraSourceCallbackStub : public IRemoteStub<IDCameraSourceCallback> { |
| 31 | public: | 34 | public: |
| 32 | DCameraSourceCallbackStub(); | 35 | DCameraSourceCallbackStub(); |
| @@ -46,6 +49,7 @@ private: | |||
| 46 | const size_t PARAM_MAX_SIZE = 50 * 1024 * 1024; | 49 | const size_t PARAM_MAX_SIZE = 50 * 1024 * 1024; |
| 47 | const size_t DID_MAX_SIZE = 256; | 50 | const size_t DID_MAX_SIZE = 256; |
| 48 | }; | 51 | }; |
| 52 | + | ||
| 49 | } // namespace DistributedHardware | 53 | } // namespace DistributedHardware |
| 50 | } // namespace OHOS | 54 | } // namespace OHOS |
| 51 | 55 | ||
| @@ -16,13 +16,22 @@ | |||
| 16 | 16 | ||
| 17 | 17 | ||
| 18 | 18 | ||
| 19 | + | ||
| 19 | 20 | ||
| 21 | + | ||
| 22 | + | ||
| 23 | + | ||
| 20 | 24 | ||
| 21 | namespace OHOS { | 25 | namespace OHOS { |
| 22 | namespace DistributedHardware { | 26 | namespace DistributedHardware { |
| 27 | + | ||
| 23 | class IDCameraSourceCallback : public OHOS::IRemoteBroker { | 28 | class IDCameraSourceCallback : public OHOS::IRemoteBroker { |
| 24 | public: | 29 | public: |
| 25 | DECLARE_INTERFACE_DESCRIPTOR(u"ohos.distributedhardware.dcamerasourcecallback"); | 30 | DECLARE_INTERFACE_DESCRIPTOR(u"ohos.distributedhardware.dcamerasourcecallback"); |
| 31 | + | ||
| 32 | +class IDCameraSourceCallback : public RefBase { | ||
| 33 | +public: | ||
| 34 | + | ||
| 26 | enum { | 35 | enum { |
| 27 | NOTIFY_REG_RESULT = 0, | 36 | NOTIFY_REG_RESULT = 0, |
| 28 | NOTIFY_UNREG_RESULT = 1, | 37 | NOTIFY_UNREG_RESULT = 1, |
| @@ -19,8 +19,10 @@ | |||
| 19 | 19 | ||
| 20 | 20 | ||
| 21 | 21 | ||
| 22 | + | ||
| 22 | 23 | ||
| 23 | 24 | ||
| 25 | + | ||
| 24 | 26 | ||
| 25 | 27 | ||
| 26 | 28 | ||
| @@ -17,8 +17,10 @@ | |||
| 17 | 17 | ||
| 18 | 18 | ||
| 19 | 19 | ||
| 20 | + | ||
| 20 | 21 | ||
| 21 | 22 | ||
| 23 | + | ||
| 22 | 24 | ||
| 23 | 25 | ||
| 24 | 26 | ||
| @@ -16,17 +16,25 @@ | |||
| 16 | 16 | ||
| 17 | 17 | ||
| 18 | 18 | ||
| 19 | + | ||
| 19 | 20 | ||
| 21 | + | ||
| 22 | + | ||
| 23 | + | ||
| 20 | 24 | ||
| 21 | 25 | ||
| 22 | 26 | ||
| 23 | 27 | ||
| 24 | namespace OHOS { | 28 | namespace OHOS { |
| 25 | namespace DistributedHardware { | 29 | namespace DistributedHardware { |
| 30 | + | ||
| 26 | class IDistributedCameraSource : public OHOS::IRemoteBroker { | 31 | class IDistributedCameraSource : public OHOS::IRemoteBroker { |
| 27 | public: | 32 | public: |
| 28 | - DECLARE_INTERFACE_DESCRIPTOR(u"ohos.distributedhardware.distributedcamerasource"); | 33 | + DECLARE_INTERFACE_DESCRIPTOR(u"ohos.distributedhardware.dcamerasource"); |
| 29 | - | 34 | +#else |
| 35 | +class IDistributedCameraSource : public RefBase { | ||
| 36 | +public: | ||
| 37 | + | ||
| 30 | ~IDistributedCameraSource() override {} | 38 | ~IDistributedCameraSource() override {} |
| 31 | virtual int32_t InitSource(const std::string& params, const sptr<IDCameraSourceCallback>& callback) = 0; | 39 | virtual int32_t InitSource(const std::string& params, const sptr<IDCameraSourceCallback>& callback) = 0; |
| 32 | virtual int32_t ReleaseSource() = 0; | 40 | virtual int32_t ReleaseSource() = 0; |
| @@ -16,7 +16,9 @@ | |||
| 16 | 16 | ||
| 17 | 17 | ||
| 18 | 18 | ||
| 19 | + | ||
| 19 | 20 | ||
| 21 | + | ||
| 20 | 22 | ||
| 21 | 23 | ||
| 22 | namespace OHOS { class MessageOption; } | 24 | namespace OHOS { class MessageOption; } |
| @@ -23,7 +23,9 @@ | |||
| 23 | 23 | ||
| 24 | 24 | ||
| 25 | 25 | ||
| 26 | + | ||
| 26 | 27 | ||
| 28 | + | ||
| 27 | 29 | ||
| 28 | namespace OHOS { | 30 | namespace OHOS { |
| 29 | namespace DistributedHardware { | 31 | namespace DistributedHardware { |
| @@ -11,6 +11,7 @@ | |||
| 11 | # See the License for the specific language governing permissions and | 11 | # See the License for the specific language governing permissions and |
| 12 | # limitations under the License. | 12 | # limitations under the License. |
| 13 | 13 | ||
| 14 | +if (!defined(ohos_lite)) { | ||
| 14 | group("fuzztest") { | 15 | group("fuzztest") { |
| 15 | testonly = true | 16 | testonly = true |
| 16 | 17 | ||
| @@ -66,3 +67,7 @@ group("fuzztest") { | |||
| 66 | "softbusonsinkstreamreceived_fuzzer:fuzztest", | 67 | "softbusonsinkstreamreceived_fuzzer:fuzztest", |
| 67 | ] | 68 | ] |
| 68 | } | 69 | } |
| 70 | +} else { | ||
| 71 | + group("fuzztest") { | ||
| 72 | + } | ||
| 73 | +} | ||
Minterfaces/inner_kits/native_cpp/test/sinkfuzztest/callbackonnotifyresourceinfo_fuzzer/BUILD.gn+3-3
| @@ -24,14 +24,14 @@ ohos_fuzztest("CallbackOnNotifyResourceInfoFuzzTest") { | |||
| 24 | 24 | ||
| 25 | fuzz_config_file = "${innerkits_path}/native_cpp/test/sinkfuzztest/callbackonnotifyresourceinfo_fuzzer" | 25 | fuzz_config_file = "${innerkits_path}/native_cpp/test/sinkfuzztest/callbackonnotifyresourceinfo_fuzzer" |
| 26 | 26 | ||
| 27 | - include_dirs = [ "${innerkits_path}/native_cpp/camera_sink/include/callback" ] | 27 | + include_dirs = [ "${innerkits_path}/native_cpp/camera_sink/include/standard/callback" ] |
| 28 | 28 | ||
| 29 | include_dirs += [ | 29 | include_dirs += [ |
| 30 | "include", | 30 | "include", |
| 31 | "${common_path}/include", | 31 | "${common_path}/include", |
| 32 | "${common_path}/include/constants", | 32 | "${common_path}/include/constants", |
| 33 | - "${innerkits_path}/native_cpp/camera_sink/include", | 33 | + "${innerkits_path}/native_cpp/camera_sink/include/standard", |
| 34 | - "${innerkits_path}/native_cpp/camera_sink/include/callback", | 34 | + "${innerkits_path}/native_cpp/camera_sink/include/standard/callback", |
| 35 | "${innerkits_path}/native_cpp/test/include", | 35 | "${innerkits_path}/native_cpp/test/include", |
| 36 | ] | 36 | ] |
| 37 | 37 | ||
| @@ -24,14 +24,14 @@ ohos_fuzztest("CallbackSinkOnHardwareStateChangedInnerFuzzTest") { | |||
| 24 | 24 | ||
| 25 | fuzz_config_file = "${innerkits_path}/native_cpp/test/sinkfuzztest/callbacksinkonhardwarestatechangedinner_fuzzer" | 25 | fuzz_config_file = "${innerkits_path}/native_cpp/test/sinkfuzztest/callbacksinkonhardwarestatechangedinner_fuzzer" |
| 26 | 26 | ||
| 27 | - include_dirs = [ "${innerkits_path}/native_cpp/camera_sink/include/callback" ] | 27 | + include_dirs = [ "${innerkits_path}/native_cpp/camera_sink/include/standard/callback" ] |
| 28 | 28 | ||
| 29 | include_dirs += [ | 29 | include_dirs += [ |
| 30 | "include", | 30 | "include", |
| 31 | "${common_path}/include", | 31 | "${common_path}/include", |
| 32 | "${common_path}/include/constants", | 32 | "${common_path}/include/constants", |
| 33 | - "${innerkits_path}/native_cpp/camera_sink/include", | 33 | + "${innerkits_path}/native_cpp/camera_sink/include/standard", |
| 34 | - "${innerkits_path}/native_cpp/camera_sink/include/callback", | 34 | + "${innerkits_path}/native_cpp/camera_sink/include/standard/callback", |
| 35 | "${innerkits_path}/native_cpp/test/include", | 35 | "${innerkits_path}/native_cpp/test/include", |
| 36 | ] | 36 | ] |
| 37 | 37 | ||
| @@ -24,14 +24,14 @@ ohos_fuzztest("CallbackSinkOnRemoteRequestFuzzTest") { | |||
| 24 | 24 | ||
| 25 | fuzz_config_file = "${innerkits_path}/native_cpp/test/sinkfuzztest/callbacksinkonremoterequest_fuzzer" | 25 | fuzz_config_file = "${innerkits_path}/native_cpp/test/sinkfuzztest/callbacksinkonremoterequest_fuzzer" |
| 26 | 26 | ||
| 27 | - include_dirs = [ "${innerkits_path}/native_cpp/camera_sink/include/callback" ] | 27 | + include_dirs = [ "${innerkits_path}/native_cpp/camera_sink/include/standard/callback" ] |
| 28 | 28 | ||
| 29 | include_dirs += [ | 29 | include_dirs += [ |
| 30 | "include", | 30 | "include", |
| 31 | "${common_path}/include", | 31 | "${common_path}/include", |
| 32 | "${common_path}/include/constants", | 32 | "${common_path}/include/constants", |
| 33 | - "${innerkits_path}/native_cpp/camera_sink/include", | 33 | + "${innerkits_path}/native_cpp/camera_sink/include/standard", |
| 34 | - "${innerkits_path}/native_cpp/camera_sink/include/callback", | 34 | + "${innerkits_path}/native_cpp/camera_sink/include/standard/callback", |
| 35 | "${innerkits_path}/native_cpp/test/include", | 35 | "${innerkits_path}/native_cpp/test/include", |
| 36 | ] | 36 | ] |
| 37 | 37 | ||
| @@ -27,8 +27,8 @@ ohos_fuzztest("OnSinkLocalCamSrvDiedFuzzTest") { | |||
| 27 | "include", | 27 | "include", |
| 28 | "${common_path}/include", | 28 | "${common_path}/include", |
| 29 | "${common_path}/include/constants", | 29 | "${common_path}/include/constants", |
| 30 | - "${innerkits_path}/native_cpp/camera_sink/include", | 30 | + "${innerkits_path}/native_cpp/camera_sink/include/standard", |
| 31 | - "${innerkits_path}/native_cpp/camera_sink/include/callback", | 31 | + "${innerkits_path}/native_cpp/camera_sink/include/standard/callback", |
| 32 | ] | 32 | ] |
| 33 | 33 | ||
| 34 | cflags = [ | 34 | cflags = [ |
| @@ -29,8 +29,8 @@ ohos_fuzztest("SinkHandlerInitSinkFuzzTest") { | |||
| 29 | "include", | 29 | "include", |
| 30 | "${common_path}/include", | 30 | "${common_path}/include", |
| 31 | "${common_path}/include/constants", | 31 | "${common_path}/include/constants", |
| 32 | - "${innerkits_path}/native_cpp/camera_sink/include", | 32 | + "${innerkits_path}/native_cpp/camera_sink/include/standard", |
| 33 | - "${innerkits_path}/native_cpp/camera_sink/include/callback", | 33 | + "${innerkits_path}/native_cpp/camera_sink/include/standard/callback", |
| 34 | ] | 34 | ] |
| 35 | 35 | ||
| 36 | cflags = [ | 36 | cflags = [ |
| @@ -31,8 +31,8 @@ ohos_fuzztest("SinkHandlerPauseDistributedHardwareFuzzTest") { | |||
| 31 | "include", | 31 | "include", |
| 32 | "${common_path}/include", | 32 | "${common_path}/include", |
| 33 | "${common_path}/include/constants", | 33 | "${common_path}/include/constants", |
| 34 | - "${innerkits_path}/native_cpp/camera_sink/include", | 34 | + "${innerkits_path}/native_cpp/camera_sink/include/standard", |
| 35 | - "${innerkits_path}/native_cpp/camera_sink/include/callback", | 35 | + "${innerkits_path}/native_cpp/camera_sink/include/standard/callback", |
| 36 | ] | 36 | ] |
| 37 | 37 | ||
| 38 | cflags = [ | 38 | cflags = [ |
| @@ -31,8 +31,8 @@ ohos_fuzztest("SinkHandlerRegisterPrivacyResourcesFuzzTest") { | |||
| 31 | "include", | 31 | "include", |
| 32 | "${common_path}/include", | 32 | "${common_path}/include", |
| 33 | "${common_path}/include/constants", | 33 | "${common_path}/include/constants", |
| 34 | - "${innerkits_path}/native_cpp/camera_sink/include", | 34 | + "${innerkits_path}/native_cpp/camera_sink/include/standard", |
| 35 | - "${innerkits_path}/native_cpp/camera_sink/include/callback", | 35 | + "${innerkits_path}/native_cpp/camera_sink/include/standard/callback", |
| 36 | "${innerkits_path}/native_cpp/test/include", | 36 | "${innerkits_path}/native_cpp/test/include", |
| 37 | ] | 37 | ] |
| 38 | 38 | ||
| @@ -30,8 +30,8 @@ ohos_fuzztest("SinkHandlerReleaseSinkFuzzTest") { | |||
| 30 | "include", | 30 | "include", |
| 31 | "${common_path}/include", | 31 | "${common_path}/include", |
| 32 | "${common_path}/include/constants", | 32 | "${common_path}/include/constants", |
| 33 | - "${innerkits_path}/native_cpp/camera_sink/include", | 33 | + "${innerkits_path}/native_cpp/camera_sink/include/standard", |
| 34 | - "${innerkits_path}/native_cpp/camera_sink/include/callback", | 34 | + "${innerkits_path}/native_cpp/camera_sink/include/standard/callback", |
| 35 | ] | 35 | ] |
| 36 | 36 | ||
| 37 | cflags = [ | 37 | cflags = [ |
| @@ -31,8 +31,8 @@ ohos_fuzztest("SinkHandlerResumeDistributedHardwareFuzzTest") { | |||
| 31 | "include", | 31 | "include", |
| 32 | "${common_path}/include", | 32 | "${common_path}/include", |
| 33 | "${common_path}/include/constants", | 33 | "${common_path}/include/constants", |
| 34 | - "${innerkits_path}/native_cpp/camera_sink/include", | 34 | + "${innerkits_path}/native_cpp/camera_sink/include/standard", |
| 35 | - "${innerkits_path}/native_cpp/camera_sink/include/callback", | 35 | + "${innerkits_path}/native_cpp/camera_sink/include/standard/callback", |
| 36 | ] | 36 | ] |
| 37 | 37 | ||
| 38 | cflags = [ | 38 | cflags = [ |
| @@ -31,8 +31,8 @@ ohos_fuzztest("SinkHandlerStopDistributedHardwareFuzzTest") { | |||
| 31 | "include", | 31 | "include", |
| 32 | "${common_path}/include", | 32 | "${common_path}/include", |
| 33 | "${common_path}/include/constants", | 33 | "${common_path}/include/constants", |
| 34 | - "${innerkits_path}/native_cpp/camera_sink/include", | 34 | + "${innerkits_path}/native_cpp/camera_sink/include/standard", |
| 35 | - "${innerkits_path}/native_cpp/camera_sink/include/callback", | 35 | + "${innerkits_path}/native_cpp/camera_sink/include/standard/callback", |
| 36 | ] | 36 | ] |
| 37 | 37 | ||
| 38 | cflags = [ | 38 | cflags = [ |
Minterfaces/inner_kits/native_cpp/test/sinkfuzztest/sinkhandlersubscribelocalhardware_fuzzer/BUILD.gn+2-2
| @@ -29,8 +29,8 @@ ohos_fuzztest("SinkHandlerSubscribeLocalHardwareFuzzTest") { | |||
| 29 | "include", | 29 | "include", |
| 30 | "${common_path}/include", | 30 | "${common_path}/include", |
| 31 | "${common_path}/include/constants", | 31 | "${common_path}/include/constants", |
| 32 | - "${innerkits_path}/native_cpp/camera_sink/include", | 32 | + "${innerkits_path}/native_cpp/camera_sink/include/standard", |
| 33 | - "${innerkits_path}/native_cpp/camera_sink/include/callback", | 33 | + "${innerkits_path}/native_cpp/camera_sink/include/standard/callback", |
| 34 | ] | 34 | ] |
| 35 | 35 | ||
| 36 | cflags = [ | 36 | cflags = [ |
| @@ -30,8 +30,8 @@ ohos_fuzztest("SinkHandlerUnsubscribeLocalHardwareFuzzTest") { | |||
| 30 | "include", | 30 | "include", |
| 31 | "${common_path}/include", | 31 | "${common_path}/include", |
| 32 | "${common_path}/include/constants", | 32 | "${common_path}/include/constants", |
| 33 | - "${innerkits_path}/native_cpp/camera_sink/include", | 33 | + "${innerkits_path}/native_cpp/camera_sink/include/standard", |
| 34 | - "${innerkits_path}/native_cpp/camera_sink/include/callback", | 34 | + "${innerkits_path}/native_cpp/camera_sink/include/standard/callback", |
| 35 | ] | 35 | ] |
| 36 | 36 | ||
| 37 | cflags = [ | 37 | cflags = [ |
| @@ -27,8 +27,8 @@ ohos_fuzztest("SinkOnLoadSystemAbilityFailFuzzTest") { | |||
| 27 | "include", | 27 | "include", |
| 28 | "${common_path}/include", | 28 | "${common_path}/include", |
| 29 | "${common_path}/include/constants", | 29 | "${common_path}/include/constants", |
| 30 | - "${innerkits_path}/native_cpp/camera_sink/include", | 30 | + "${innerkits_path}/native_cpp/camera_sink/include/standard", |
| 31 | - "${innerkits_path}/native_cpp/camera_sink/include/callback", | 31 | + "${innerkits_path}/native_cpp/camera_sink/include/standard/callback", |
| 32 | ] | 32 | ] |
| 33 | 33 | ||
| 34 | cflags = [ | 34 | cflags = [ |
Minterfaces/inner_kits/native_cpp/test/sinkfuzztest/sinkonloadsystemabilitysuccess_fuzzer/BUILD.gn+2-2
| @@ -27,8 +27,8 @@ ohos_fuzztest("SinkOnLoadSystemAbilitySuccessFuzzTest") { | |||
| 27 | "include", | 27 | "include", |
| 28 | "${common_path}/include", | 28 | "${common_path}/include", |
| 29 | "${common_path}/include/constants", | 29 | "${common_path}/include/constants", |
| 30 | - "${innerkits_path}/native_cpp/camera_sink/include", | 30 | + "${innerkits_path}/native_cpp/camera_sink/include/standard", |
| 31 | - "${innerkits_path}/native_cpp/camera_sink/include/callback", | 31 | + "${innerkits_path}/native_cpp/camera_sink/include/standard/callback", |
| 32 | ] | 32 | ] |
| 33 | 33 | ||
| 34 | cflags = [ | 34 | cflags = [ |
| @@ -27,8 +27,8 @@ ohos_fuzztest("SinkProxyChannelNegFuzzTest") { | |||
| 27 | "include", | 27 | "include", |
| 28 | "${common_path}/include", | 28 | "${common_path}/include", |
| 29 | "${common_path}/include/constants", | 29 | "${common_path}/include/constants", |
| 30 | - "${innerkits_path}/native_cpp/camera_sink/include", | 30 | + "${innerkits_path}/native_cpp/camera_sink/include/standard", |
| 31 | - "${innerkits_path}/native_cpp/camera_sink/include/callback", | 31 | + "${innerkits_path}/native_cpp/camera_sink/include/standard/callback", |
| 32 | ] | 32 | ] |
| 33 | 33 | ||
| 34 | cflags = [ | 34 | cflags = [ |
| @@ -27,8 +27,8 @@ ohos_fuzztest("SinkProxyCloseChannelFuzzTest") { | |||
| 27 | "include", | 27 | "include", |
| 28 | "${common_path}/include", | 28 | "${common_path}/include", |
| 29 | "${common_path}/include/constants", | 29 | "${common_path}/include/constants", |
| 30 | - "${innerkits_path}/native_cpp/camera_sink/include", | 30 | + "${innerkits_path}/native_cpp/camera_sink/include/standard", |
| 31 | - "${innerkits_path}/native_cpp/camera_sink/include/callback", | 31 | + "${innerkits_path}/native_cpp/camera_sink/include/standard/callback", |
| 32 | ] | 32 | ] |
| 33 | 33 | ||
| 34 | cflags = [ | 34 | cflags = [ |
| @@ -27,8 +27,8 @@ ohos_fuzztest("SinkProxyGetCameraInfoFuzzTest") { | |||
| 27 | "include", | 27 | "include", |
| 28 | "${common_path}/include", | 28 | "${common_path}/include", |
| 29 | "${common_path}/include/constants", | 29 | "${common_path}/include/constants", |
| 30 | - "${innerkits_path}/native_cpp/camera_sink/include", | 30 | + "${innerkits_path}/native_cpp/camera_sink/include/standard", |
| 31 | - "${innerkits_path}/native_cpp/camera_sink/include/callback", | 31 | + "${innerkits_path}/native_cpp/camera_sink/include/standard/callback", |
| 32 | ] | 32 | ] |
| 33 | 33 | ||
| 34 | cflags = [ | 34 | cflags = [ |
| @@ -28,8 +28,8 @@ ohos_fuzztest("SinkProxyInitSinkFuzzTest") { | |||
| 28 | "include", | 28 | "include", |
| 29 | "${common_path}/include", | 29 | "${common_path}/include", |
| 30 | "${common_path}/include/constants", | 30 | "${common_path}/include/constants", |
| 31 | - "${innerkits_path}/native_cpp/camera_sink/include", | 31 | + "${innerkits_path}/native_cpp/camera_sink/include/standard", |
| 32 | - "${innerkits_path}/native_cpp/camera_sink/include/callback", | 32 | + "${innerkits_path}/native_cpp/camera_sink/include/standard/callback", |
| 33 | ] | 33 | ] |
| 34 | 34 | ||
| 35 | cflags = [ | 35 | cflags = [ |
| @@ -27,8 +27,8 @@ ohos_fuzztest("SinkProxyOpenChannelFuzzTest") { | |||
| 27 | "include", | 27 | "include", |
| 28 | "${common_path}/include", | 28 | "${common_path}/include", |
| 29 | "${common_path}/include/constants", | 29 | "${common_path}/include/constants", |
| 30 | - "${innerkits_path}/native_cpp/camera_sink/include", | 30 | + "${innerkits_path}/native_cpp/camera_sink/include/standard", |
| 31 | - "${innerkits_path}/native_cpp/camera_sink/include/callback", | 31 | + "${innerkits_path}/native_cpp/camera_sink/include/standard/callback", |
| 32 | ] | 32 | ] |
| 33 | 33 | ||
| 34 | cflags = [ | 34 | cflags = [ |
| @@ -28,8 +28,8 @@ ohos_fuzztest("SinkProxyReleaseSinkFuzzTest") { | |||
| 28 | "include", | 28 | "include", |
| 29 | "${common_path}/include", | 29 | "${common_path}/include", |
| 30 | "${common_path}/include/constants", | 30 | "${common_path}/include/constants", |
| 31 | - "${innerkits_path}/native_cpp/camera_sink/include", | 31 | + "${innerkits_path}/native_cpp/camera_sink/include/standard", |
| 32 | - "${innerkits_path}/native_cpp/camera_sink/include/callback", | 32 | + "${innerkits_path}/native_cpp/camera_sink/include/standard/callback", |
| 33 | ] | 33 | ] |
| 34 | 34 | ||
| 35 | cflags = [ | 35 | cflags = [ |
| @@ -27,8 +27,8 @@ ohos_fuzztest("SinkProxyStopCaptureFuzzTest") { | |||
| 27 | "include", | 27 | "include", |
| 28 | "${common_path}/include", | 28 | "${common_path}/include", |
| 29 | "${common_path}/include/constants", | 29 | "${common_path}/include/constants", |
| 30 | - "${innerkits_path}/native_cpp/camera_sink/include", | 30 | + "${innerkits_path}/native_cpp/camera_sink/include/standard", |
| 31 | - "${innerkits_path}/native_cpp/camera_sink/include/callback", | 31 | + "${innerkits_path}/native_cpp/camera_sink/include/standard/callback", |
| 32 | ] | 32 | ] |
| 33 | 33 | ||
| 34 | cflags = [ | 34 | cflags = [ |
Minterfaces/inner_kits/native_cpp/test/sinkfuzztest/sinkproxysubscribelocalhardware_fuzzer/BUILD.gn+2-2
| @@ -27,8 +27,8 @@ ohos_fuzztest("SinkProxySubscribeLocalHardwareFuzzTest") { | |||
| 27 | "include", | 27 | "include", |
| 28 | "${common_path}/include", | 28 | "${common_path}/include", |
| 29 | "${common_path}/include/constants", | 29 | "${common_path}/include/constants", |
| 30 | - "${innerkits_path}/native_cpp/camera_sink/include", | 30 | + "${innerkits_path}/native_cpp/camera_sink/include/standard", |
| 31 | - "${innerkits_path}/native_cpp/camera_sink/include/callback", | 31 | + "${innerkits_path}/native_cpp/camera_sink/include/standard/callback", |
| 32 | ] | 32 | ] |
| 33 | 33 | ||
| 34 | cflags = [ | 34 | cflags = [ |
Minterfaces/inner_kits/native_cpp/test/sinkfuzztest/sinkproxyunsubscribelocalhardware_fuzzer/BUILD.gn+2-2
| @@ -27,8 +27,8 @@ ohos_fuzztest("SinkProxyUnsubscribeLocalHardwareFuzzTest") { | |||
| 27 | "include", | 27 | "include", |
| 28 | "${common_path}/include", | 28 | "${common_path}/include", |
| 29 | "${common_path}/include/constants", | 29 | "${common_path}/include/constants", |
| 30 | - "${innerkits_path}/native_cpp/camera_sink/include", | 30 | + "${innerkits_path}/native_cpp/camera_sink/include/standard", |
| 31 | - "${innerkits_path}/native_cpp/camera_sink/include/callback", | 31 | + "${innerkits_path}/native_cpp/camera_sink/include/standard/callback", |
| 32 | ] | 32 | ] |
| 33 | 33 | ||
| 34 | cflags = [ | 34 | cflags = [ |
| @@ -27,8 +27,8 @@ ohos_fuzztest("SinkServiceChannelNegFuzzTest") { | |||
| 27 | "include", | 27 | "include", |
| 28 | "${common_path}/include/constants", | 28 | "${common_path}/include/constants", |
| 29 | "${common_path}/include/utils", | 29 | "${common_path}/include/utils", |
| 30 | - "${innerkits_path}/native_cpp/camera_sink/include", | 30 | + "${innerkits_path}/native_cpp/camera_sink/include/standard", |
| 31 | - "${innerkits_path}/native_cpp/camera_sink/include/callback", | 31 | + "${innerkits_path}/native_cpp/camera_sink/include/standard/callback", |
| 32 | "${services_path}/cameraservice/base/include", | 32 | "${services_path}/cameraservice/base/include", |
| 33 | "${services_path}/cameraservice/cameraoperator/client/include", | 33 | "${services_path}/cameraservice/cameraoperator/client/include", |
| 34 | "${services_path}/cameraservice/sinkservice/include/distributedcamera", | 34 | "${services_path}/cameraservice/sinkservice/include/distributedcamera", |
| @@ -27,8 +27,8 @@ ohos_fuzztest("SinkServiceCloseChannelFuzzTest") { | |||
| 27 | "include", | 27 | "include", |
| 28 | "${common_path}/include/constants", | 28 | "${common_path}/include/constants", |
| 29 | "${common_path}/include/utils", | 29 | "${common_path}/include/utils", |
| 30 | - "${innerkits_path}/native_cpp/camera_sink/include", | 30 | + "${innerkits_path}/native_cpp/camera_sink/include/standard", |
| 31 | - "${innerkits_path}/native_cpp/camera_sink/include/callback", | 31 | + "${innerkits_path}/native_cpp/camera_sink/include/standard/callback", |
| 32 | "${innerkits_path}/native_cpp/test/include", | 32 | "${innerkits_path}/native_cpp/test/include", |
| 33 | "${services_path}/cameraservice/base/include", | 33 | "${services_path}/cameraservice/base/include", |
| 34 | "${services_path}/cameraservice/cameraoperator/client/include", | 34 | "${services_path}/cameraservice/cameraoperator/client/include", |
| @@ -27,8 +27,8 @@ ohos_fuzztest("SinkServiceDumpFuzzTest") { | |||
| 27 | "include", | 27 | "include", |
| 28 | "${common_path}/include/constants", | 28 | "${common_path}/include/constants", |
| 29 | "${common_path}/include/utils", | 29 | "${common_path}/include/utils", |
| 30 | - "${innerkits_path}/native_cpp/camera_sink/include", | 30 | + "${innerkits_path}/native_cpp/camera_sink/include/standard", |
| 31 | - "${innerkits_path}/native_cpp/camera_sink/include/callback", | 31 | + "${innerkits_path}/native_cpp/camera_sink/include/standard/callback", |
| 32 | "${services_path}/cameraservice/base/include", | 32 | "${services_path}/cameraservice/base/include", |
| 33 | "${services_path}/cameraservice/cameraoperator/client/include", | 33 | "${services_path}/cameraservice/cameraoperator/client/include", |
| 34 | "${services_path}/cameraservice/sinkservice/include/distributedcamera", | 34 | "${services_path}/cameraservice/sinkservice/include/distributedcamera", |
| @@ -27,8 +27,8 @@ ohos_fuzztest("SinkServiceGetCameraInfoFuzzTest") { | |||
| 27 | "include", | 27 | "include", |
| 28 | "${common_path}/include/constants", | 28 | "${common_path}/include/constants", |
| 29 | "${common_path}/include/utils", | 29 | "${common_path}/include/utils", |
| 30 | - "${innerkits_path}/native_cpp/camera_sink/include", | 30 | + "${innerkits_path}/native_cpp/camera_sink/include/standard", |
| 31 | - "${innerkits_path}/native_cpp/camera_sink/include/callback", | 31 | + "${innerkits_path}/native_cpp/camera_sink/include/standard/callback", |
| 32 | "${services_path}/cameraservice/base/include", | 32 | "${services_path}/cameraservice/base/include", |
| 33 | "${services_path}/cameraservice/cameraoperator/client/include", | 33 | "${services_path}/cameraservice/cameraoperator/client/include", |
| 34 | "${services_path}/cameraservice/sinkservice/include/distributedcamera", | 34 | "${services_path}/cameraservice/sinkservice/include/distributedcamera", |
| @@ -27,8 +27,8 @@ ohos_fuzztest("SinkServiceGetDumpInfoFuzzTest") { | |||
| 27 | "include", | 27 | "include", |
| 28 | "${common_path}/include/constants", | 28 | "${common_path}/include/constants", |
| 29 | "${common_path}/include/utils", | 29 | "${common_path}/include/utils", |
| 30 | - "${innerkits_path}/native_cpp/camera_sink/include", | 30 | + "${innerkits_path}/native_cpp/camera_sink/include/standard", |
| 31 | - "${innerkits_path}/native_cpp/camera_sink/include/callback", | 31 | + "${innerkits_path}/native_cpp/camera_sink/include/standard/callback", |
| 32 | "${services_path}/cameraservice/base/include", | 32 | "${services_path}/cameraservice/base/include", |
| 33 | "${services_path}/cameraservice/cameraoperator/client/include", | 33 | "${services_path}/cameraservice/cameraoperator/client/include", |
| 34 | "${services_path}/cameraservice/sinkservice/include/distributedcamera", | 34 | "${services_path}/cameraservice/sinkservice/include/distributedcamera", |
| @@ -27,8 +27,8 @@ ohos_fuzztest("SinkServiceInitSinkFuzzTest") { | |||
| 27 | "include", | 27 | "include", |
| 28 | "${common_path}/include/constants", | 28 | "${common_path}/include/constants", |
| 29 | "${common_path}/include/utils", | 29 | "${common_path}/include/utils", |
| 30 | - "${innerkits_path}/native_cpp/camera_sink/include", | 30 | + "${innerkits_path}/native_cpp/camera_sink/include/standard", |
| 31 | - "${innerkits_path}/native_cpp/camera_sink/include/callback", | 31 | + "${innerkits_path}/native_cpp/camera_sink/include/standard/callback", |
| 32 | "${services_path}/cameraservice/base/include", | 32 | "${services_path}/cameraservice/base/include", |
| 33 | "${services_path}/cameraservice/cameraoperator/client/include", | 33 | "${services_path}/cameraservice/cameraoperator/client/include", |
| 34 | "${services_path}/cameraservice/sinkservice/include/distributedcamera", | 34 | "${services_path}/cameraservice/sinkservice/include/distributedcamera", |
| @@ -27,8 +27,8 @@ ohos_fuzztest("SinkServiceOpenChannelFuzzTest") { | |||
| 27 | "include", | 27 | "include", |
| 28 | "${common_path}/include/constants", | 28 | "${common_path}/include/constants", |
| 29 | "${common_path}/include/utils", | 29 | "${common_path}/include/utils", |
| 30 | - "${innerkits_path}/native_cpp/camera_sink/include", | 30 | + "${innerkits_path}/native_cpp/camera_sink/include/standard", |
| 31 | - "${innerkits_path}/native_cpp/camera_sink/include/callback", | 31 | + "${innerkits_path}/native_cpp/camera_sink/include/standard/callback", |
| 32 | "${services_path}/cameraservice/base/include", | 32 | "${services_path}/cameraservice/base/include", |
| 33 | "${services_path}/cameraservice/cameraoperator/client/include", | 33 | "${services_path}/cameraservice/cameraoperator/client/include", |
| 34 | "${services_path}/cameraservice/sinkservice/include/distributedcamera", | 34 | "${services_path}/cameraservice/sinkservice/include/distributedcamera", |
| @@ -27,8 +27,8 @@ ohos_fuzztest("SinkServicePauseDistributedHardwareFuzzTest") { | |||
| 27 | "include", | 27 | "include", |
| 28 | "${common_path}/include/constants", | 28 | "${common_path}/include/constants", |
| 29 | "${common_path}/include/utils", | 29 | "${common_path}/include/utils", |
| 30 | - "${innerkits_path}/native_cpp/camera_sink/include", | 30 | + "${innerkits_path}/native_cpp/camera_sink/include/standard", |
| 31 | - "${innerkits_path}/native_cpp/camera_sink/include/callback", | 31 | + "${innerkits_path}/native_cpp/camera_sink/include/standard/callback", |
| 32 | "${services_path}/cameraservice/base/include", | 32 | "${services_path}/cameraservice/base/include", |
| 33 | "${services_path}/cameraservice/cameraoperator/client/include", | 33 | "${services_path}/cameraservice/cameraoperator/client/include", |
| 34 | "${services_path}/cameraservice/sinkservice/include/distributedcamera", | 34 | "${services_path}/cameraservice/sinkservice/include/distributedcamera", |
| @@ -27,8 +27,8 @@ ohos_fuzztest("SinkServiceReleaseSinkFuzzTest") { | |||
| 27 | "include", | 27 | "include", |
| 28 | "${common_path}/include/constants", | 28 | "${common_path}/include/constants", |
| 29 | "${common_path}/include/utils", | 29 | "${common_path}/include/utils", |
| 30 | - "${innerkits_path}/native_cpp/camera_sink/include", | 30 | + "${innerkits_path}/native_cpp/camera_sink/include/standard", |
| 31 | - "${innerkits_path}/native_cpp/camera_sink/include/callback", | 31 | + "${innerkits_path}/native_cpp/camera_sink/include/standard/callback", |
| 32 | "${services_path}/cameraservice/base/include", | 32 | "${services_path}/cameraservice/base/include", |
| 33 | "${services_path}/cameraservice/cameraoperator/client/include", | 33 | "${services_path}/cameraservice/cameraoperator/client/include", |
| 34 | "${services_path}/cameraservice/sinkservice/include/distributedcamera", | 34 | "${services_path}/cameraservice/sinkservice/include/distributedcamera", |
Minterfaces/inner_kits/native_cpp/test/sinkfuzztest/sinkserviceremoveaccesslistener_fuzzer/BUILD.gn+2-2
| @@ -27,8 +27,8 @@ ohos_fuzztest("SinkServiceRemoveAccessListenerFuzzTest") { | |||
| 27 | "include", | 27 | "include", |
| 28 | "${common_path}/include/constants", | 28 | "${common_path}/include/constants", |
| 29 | "${common_path}/include/utils", | 29 | "${common_path}/include/utils", |
| 30 | - "${innerkits_path}/native_cpp/camera_sink/include", | 30 | + "${innerkits_path}/native_cpp/camera_sink/include/standard", |
| 31 | - "${innerkits_path}/native_cpp/camera_sink/include/callback", | 31 | + "${innerkits_path}/native_cpp/camera_sink/include/standard/callback", |
| 32 | "${services_path}/cameraservice/base/include", | 32 | "${services_path}/cameraservice/base/include", |
| 33 | "${services_path}/cameraservice/cameraoperator/client/include", | 33 | "${services_path}/cameraservice/cameraoperator/client/include", |
| 34 | "${services_path}/cameraservice/sinkservice/include/distributedcamera", | 34 | "${services_path}/cameraservice/sinkservice/include/distributedcamera", |
| @@ -27,8 +27,8 @@ ohos_fuzztest("SinkServiceResumeDistributedHardwareFuzzTest") { | |||
| 27 | "include", | 27 | "include", |
| 28 | "${common_path}/include/constants", | 28 | "${common_path}/include/constants", |
| 29 | "${common_path}/include/utils", | 29 | "${common_path}/include/utils", |
| 30 | - "${innerkits_path}/native_cpp/camera_sink/include", | 30 | + "${innerkits_path}/native_cpp/camera_sink/include/standard", |
| 31 | - "${innerkits_path}/native_cpp/camera_sink/include/callback", | 31 | + "${innerkits_path}/native_cpp/camera_sink/include/standard/callback", |
| 32 | "${services_path}/cameraservice/base/include", | 32 | "${services_path}/cameraservice/base/include", |
| 33 | "${services_path}/cameraservice/cameraoperator/client/include", | 33 | "${services_path}/cameraservice/cameraoperator/client/include", |
| 34 | "${services_path}/cameraservice/sinkservice/include/distributedcamera", | 34 | "${services_path}/cameraservice/sinkservice/include/distributedcamera", |
Minterfaces/inner_kits/native_cpp/test/sinkfuzztest/sinkservicesetaccesslistener_fuzzer/BUILD.gn+2-2
| @@ -27,8 +27,8 @@ ohos_fuzztest("SinkServiceSetAccessListenerFuzzTest") { | |||
| 27 | "include", | 27 | "include", |
| 28 | "${common_path}/include/constants", | 28 | "${common_path}/include/constants", |
| 29 | "${common_path}/include/utils", | 29 | "${common_path}/include/utils", |
| 30 | - "${innerkits_path}/native_cpp/camera_sink/include", | 30 | + "${innerkits_path}/native_cpp/camera_sink/include/standard", |
| 31 | - "${innerkits_path}/native_cpp/camera_sink/include/callback", | 31 | + "${innerkits_path}/native_cpp/camera_sink/include/standard/callback", |
| 32 | "${services_path}/cameraservice/base/include", | 32 | "${services_path}/cameraservice/base/include", |
| 33 | "${services_path}/cameraservice/cameraoperator/client/include", | 33 | "${services_path}/cameraservice/cameraoperator/client/include", |
| 34 | "${services_path}/cameraservice/sinkservice/include/distributedcamera", | 34 | "${services_path}/cameraservice/sinkservice/include/distributedcamera", |
| @@ -27,8 +27,8 @@ ohos_fuzztest("SinkServiceStopCaptureFuzzTest") { | |||
| 27 | "include", | 27 | "include", |
| 28 | "${common_path}/include/constants", | 28 | "${common_path}/include/constants", |
| 29 | "${common_path}/include/utils", | 29 | "${common_path}/include/utils", |
| 30 | - "${innerkits_path}/native_cpp/camera_sink/include", | 30 | + "${innerkits_path}/native_cpp/camera_sink/include/standard", |
| 31 | - "${innerkits_path}/native_cpp/camera_sink/include/callback", | 31 | + "${innerkits_path}/native_cpp/camera_sink/include/standard/callback", |
| 32 | "${services_path}/cameraservice/base/include", | 32 | "${services_path}/cameraservice/base/include", |
| 33 | "${services_path}/cameraservice/cameraoperator/client/include", | 33 | "${services_path}/cameraservice/cameraoperator/client/include", |
| 34 | "${services_path}/cameraservice/sinkservice/include/distributedcamera", | 34 | "${services_path}/cameraservice/sinkservice/include/distributedcamera", |
| @@ -27,8 +27,8 @@ ohos_fuzztest("SinkServiceStopDistributedHardwareFuzzTest") { | |||
| 27 | "include", | 27 | "include", |
| 28 | "${common_path}/include/constants", | 28 | "${common_path}/include/constants", |
| 29 | "${common_path}/include/utils", | 29 | "${common_path}/include/utils", |
| 30 | - "${innerkits_path}/native_cpp/camera_sink/include", | 30 | + "${innerkits_path}/native_cpp/camera_sink/include/standard", |
| 31 | - "${innerkits_path}/native_cpp/camera_sink/include/callback", | 31 | + "${innerkits_path}/native_cpp/camera_sink/include/standard/callback", |
| 32 | "${services_path}/cameraservice/base/include", | 32 | "${services_path}/cameraservice/base/include", |
| 33 | "${services_path}/cameraservice/cameraoperator/client/include", | 33 | "${services_path}/cameraservice/cameraoperator/client/include", |
| 34 | "${services_path}/cameraservice/sinkservice/include/distributedcamera", | 34 | "${services_path}/cameraservice/sinkservice/include/distributedcamera", |
Minterfaces/inner_kits/native_cpp/test/sinkfuzztest/sinkservicesubscribelocalhardware_fuzzer/BUILD.gn+2-2
| @@ -27,8 +27,8 @@ ohos_fuzztest("SinkServiceSubscribeLocalHardwareFuzzTest") { | |||
| 27 | "include", | 27 | "include", |
| 28 | "${common_path}/include/constants", | 28 | "${common_path}/include/constants", |
| 29 | "${common_path}/include/utils", | 29 | "${common_path}/include/utils", |
| 30 | - "${innerkits_path}/native_cpp/camera_sink/include", | 30 | + "${innerkits_path}/native_cpp/camera_sink/include/standard", |
| 31 | - "${innerkits_path}/native_cpp/camera_sink/include/callback", | 31 | + "${innerkits_path}/native_cpp/camera_sink/include/standard/callback", |
| 32 | "${services_path}/cameraservice/base/include", | 32 | "${services_path}/cameraservice/base/include", |
| 33 | "${services_path}/cameraservice/cameraoperator/client/include", | 33 | "${services_path}/cameraservice/cameraoperator/client/include", |
| 34 | "${services_path}/cameraservice/sinkservice/include/distributedcamera", | 34 | "${services_path}/cameraservice/sinkservice/include/distributedcamera", |
| @@ -28,8 +28,8 @@ ohos_fuzztest("SinkServiceUnsubscribeLocalHardwareFuzzTest") { | |||
| 28 | "include", | 28 | "include", |
| 29 | "${common_path}/include/constants", | 29 | "${common_path}/include/constants", |
| 30 | "${common_path}/include/utils", | 30 | "${common_path}/include/utils", |
| 31 | - "${innerkits_path}/native_cpp/camera_sink/include", | 31 | + "${innerkits_path}/native_cpp/camera_sink/include/standard", |
| 32 | - "${innerkits_path}/native_cpp/camera_sink/include/callback", | 32 | + "${innerkits_path}/native_cpp/camera_sink/include/standard/callback", |
| 33 | "${services_path}/cameraservice/base/include", | 33 | "${services_path}/cameraservice/base/include", |
| 34 | "${services_path}/cameraservice/cameraoperator/client/include", | 34 | "${services_path}/cameraservice/cameraoperator/client/include", |
| 35 | "${services_path}/cameraservice/sinkservice/include/distributedcamera", | 35 | "${services_path}/cameraservice/sinkservice/include/distributedcamera", |
| @@ -11,6 +11,7 @@ | |||
| 11 | # See the License for the specific language governing permissions and | 11 | # See the License for the specific language governing permissions and |
| 12 | # limitations under the License. | 12 | # limitations under the License. |
| 13 | 13 | ||
| 14 | +if (!defined(ohos_lite)) { | ||
| 14 | group("fuzztest") { | 15 | group("fuzztest") { |
| 15 | testonly = true | 16 | testonly = true |
| 16 | 17 | ||
| @@ -51,3 +52,7 @@ group("fuzztest") { | |||
| 51 | "sourceserviceupdateworkmode_fuzzer:fuzztest", | 52 | "sourceserviceupdateworkmode_fuzzer:fuzztest", |
| 52 | ] | 53 | ] |
| 53 | } | 54 | } |
| 55 | +} else { | ||
| 56 | + group("fuzztest") { | ||
| 57 | + } | ||
| 58 | +} | ||
| @@ -11,6 +11,7 @@ | |||
| 11 | # See the License for the specific language governing permissions and | 11 | # See the License for the specific language governing permissions and |
| 12 | # limitations under the License. | 12 | # limitations under the License. |
| 13 | 13 | ||
| 14 | +if (!defined(ohos_lite)) { | ||
| 14 | group("dcamera_handler_test") { | 15 | group("dcamera_handler_test") { |
| 15 | testonly = true | 16 | testonly = true |
| 16 | deps = [ | 17 | deps = [ |
| @@ -18,3 +19,7 @@ group("dcamera_handler_test") { | |||
| 18 | "common/camera_source:dcamera_source_handler_test", | 19 | "common/camera_source:dcamera_source_handler_test", |
| 19 | ] | 20 | ] |
| 20 | } | 21 | } |
| 22 | +} else { | ||
| 23 | + group("dcamera_handler_test") { | ||
| 24 | + } | ||
| 25 | +} | ||
| @@ -24,8 +24,8 @@ config("module_private_config") { | |||
| 24 | "${common_path}/include", | 24 | "${common_path}/include", |
| 25 | "${common_path}/include/constants", | 25 | "${common_path}/include/constants", |
| 26 | "${common_path}/include/utils", | 26 | "${common_path}/include/utils", |
| 27 | - "${innerkits_path}/native_cpp/camera_sink/include", | 27 | + "${innerkits_path}/native_cpp/camera_sink/include/standard", |
| 28 | - "${innerkits_path}/native_cpp/camera_sink/include/callback", | 28 | + "${innerkits_path}/native_cpp/camera_sink/include/standard/callback", |
| 29 | ] | 29 | ] |
| 30 | } | 30 | } |
| 31 | 31 | ||
| @@ -18,11 +18,15 @@ | |||
| 18 | 18 | ||
| 19 | 19 | ||
| 20 | 20 | ||
| 21 | + | ||
| 21 | 22 | ||
| 23 | + | ||
| 22 | 24 | ||
| 23 | namespace OHOS { | 25 | namespace OHOS { |
| 24 | namespace DistributedHardware { | 26 | namespace DistributedHardware { |
| 27 | + | ||
| 25 | using namespace OHOS::HDI::DistributedCamera::V1_1; | 28 | using namespace OHOS::HDI::DistributedCamera::V1_1; |
| 29 | + | ||
| 26 | class DCameraCaptureInfo { | 30 | class DCameraCaptureInfo { |
| 27 | public: | 31 | public: |
| 28 | int32_t width_; | 32 | int32_t width_; |
| @@ -32,7 +36,9 @@ public: | |||
| 32 | bool isCapture_; | 36 | bool isCapture_; |
| 33 | DCEncodeType encodeType_; | 37 | DCEncodeType encodeType_; |
| 34 | DCStreamType streamType_; | 38 | DCStreamType streamType_; |
| 39 | + | ||
| 35 | std::vector<std::shared_ptr<DCameraSettings>> captureSettings_; | 40 | std::vector<std::shared_ptr<DCameraSettings>> captureSettings_; |
| 41 | + | ||
| 36 | }; | 42 | }; |
| 37 | 43 | ||
| 38 | class DCameraCaptureInfoCmd { | 44 | class DCameraCaptureInfoCmd { |
| @@ -20,11 +20,16 @@ | |||
| 20 | 20 | ||
| 21 | 21 | ||
| 22 | 22 | ||
| 23 | + | ||
| 24 | + | ||
| 23 | 25 | ||
| 26 | + | ||
| 24 | 27 | ||
| 25 | namespace OHOS { | 28 | namespace OHOS { |
| 26 | namespace DistributedHardware { | 29 | namespace DistributedHardware { |
| 30 | + | ||
| 27 | using namespace OHOS::HDI::DistributedCamera::V1_1; | 31 | using namespace OHOS::HDI::DistributedCamera::V1_1; |
| 32 | + | ||
| 28 | class DCameraChannelDetail { | 33 | class DCameraChannelDetail { |
| 29 | public: | 34 | public: |
| 30 | DCameraChannelDetail() = default; | 35 | DCameraChannelDetail() = default; |
| @@ -39,7 +39,7 @@ struct DCameraFrameInfo { | |||
| 39 | int32_t offset = 0; | 39 | int32_t offset = 0; |
| 40 | int64_t pts = 0; | 40 | int64_t pts = 0; |
| 41 | int64_t rawTime = 0; | 41 | int64_t rawTime = 0; |
| 42 | - DCameraFrameProcessTimePoint timePonit {0}; | 42 | + DCameraFrameProcessTimePoint timePonit = {}; |
| 43 | }; | 43 | }; |
| 44 | } // namespace DistributedHardware | 44 | } // namespace DistributedHardware |
| 45 | } // namespace OHOS | 45 | } // namespace OHOS |
| @@ -16,10 +16,13 @@ | |||
| 16 | 16 | ||
| 17 | 17 | ||
| 18 | 18 | ||
| 19 | + | ||
| 19 | 20 | ||
| 21 | + | ||
| 20 | 22 | ||
| 21 | namespace OHOS { | 23 | namespace OHOS { |
| 22 | namespace DistributedHardware { | 24 | namespace DistributedHardware { |
| 25 | + | ||
| 23 | using namespace OHOS::HDI::DistributedCamera::V1_1; | 26 | using namespace OHOS::HDI::DistributedCamera::V1_1; |
| 24 | class DCameraMetadataSettingCmd { | 27 | class DCameraMetadataSettingCmd { |
| 25 | public: | 28 | public: |
| @@ -32,6 +35,7 @@ public: | |||
| 32 | int32_t Marshal(std::string& jsonStr); | 35 | int32_t Marshal(std::string& jsonStr); |
| 33 | int32_t Unmarshal(const std::string& jsonStr); | 36 | int32_t Unmarshal(const std::string& jsonStr); |
| 34 | }; | 37 | }; |
| 38 | + | ||
| 35 | } // namespace DistributedHardware | 39 | } // namespace DistributedHardware |
| 36 | } // namespace OHOS | 40 | } // namespace OHOS |
| 37 | 41 | ||
| @@ -35,7 +35,9 @@ public: | |||
| 35 | virtual int32_t StopCapture() = 0; | 35 | virtual int32_t StopCapture() = 0; |
| 36 | virtual int32_t ChannelNeg(std::shared_ptr<DCameraChannelInfo>& info) = 0; | 36 | virtual int32_t ChannelNeg(std::shared_ptr<DCameraChannelInfo>& info) = 0; |
| 37 | virtual int32_t DCameraNotify(std::shared_ptr<DCameraEvent>& events) = 0; | 37 | virtual int32_t DCameraNotify(std::shared_ptr<DCameraEvent>& events) = 0; |
| 38 | + | ||
| 38 | virtual int32_t UpdateSettings(std::vector<std::shared_ptr<DCameraSettings>>& settings) = 0; | 39 | virtual int32_t UpdateSettings(std::vector<std::shared_ptr<DCameraSettings>>& settings) = 0; |
| 40 | + | ||
| 39 | virtual int32_t GetCameraInfo(std::shared_ptr<DCameraInfo>& camInfo) = 0; | 41 | virtual int32_t GetCameraInfo(std::shared_ptr<DCameraInfo>& camInfo) = 0; |
| 40 | virtual int32_t OpenChannel(std::shared_ptr<DCameraOpenInfo>& openInfo) = 0; | 42 | virtual int32_t OpenChannel(std::shared_ptr<DCameraOpenInfo>& openInfo) = 0; |
| 41 | virtual int32_t CloseChannel() = 0; | 43 | virtual int32_t CloseChannel() = 0; |
| @@ -44,6 +44,7 @@ int32_t DCameraCaptureInfoCmd::Marshal(std::string& jsonStr) | |||
| 44 | cJSON_AddNumberToObject(captureInfo, "Format", capture->format_); | 44 | cJSON_AddNumberToObject(captureInfo, "Format", capture->format_); |
| 45 | cJSON_AddNumberToObject(captureInfo, "DataSpace", capture->dataspace_); | 45 | cJSON_AddNumberToObject(captureInfo, "DataSpace", capture->dataspace_); |
| 46 | cJSON_AddBoolToObject(captureInfo, "IsCapture", capture->isCapture_); | 46 | cJSON_AddBoolToObject(captureInfo, "IsCapture", capture->isCapture_); |
| 47 | + | ||
| 47 | cJSON_AddNumberToObject(captureInfo, "EncodeType", capture->encodeType_); | 48 | cJSON_AddNumberToObject(captureInfo, "EncodeType", capture->encodeType_); |
| 48 | cJSON_AddNumberToObject(captureInfo, "StreamType", capture->streamType_); | 49 | cJSON_AddNumberToObject(captureInfo, "StreamType", capture->streamType_); |
| 49 | cJSON *captureSettings = cJSON_CreateArray(); | 50 | cJSON *captureSettings = cJSON_CreateArray(); |
| @@ -57,6 +58,7 @@ int32_t DCameraCaptureInfoCmd::Marshal(std::string& jsonStr) | |||
| 57 | cJSON_AddStringToObject(captureSetting, "SettingValue", (*settingIter)->value_.c_str()); | 58 | cJSON_AddStringToObject(captureSetting, "SettingValue", (*settingIter)->value_.c_str()); |
| 58 | cJSON_AddItemToArray(captureSettings, captureSetting); | 59 | cJSON_AddItemToArray(captureSettings, captureSetting); |
| 59 | } | 60 | } |
| 61 | + | ||
| 60 | } | 62 | } |
| 61 | cJSON_AddNumberToObject(rootValue, "mode", sceneMode_); | 63 | cJSON_AddNumberToObject(rootValue, "mode", sceneMode_); |
| 62 | cJSON_AddNumberToObject(rootValue, "userId", userId_); | 64 | cJSON_AddNumberToObject(rootValue, "userId", userId_); |
| @@ -160,6 +162,7 @@ int32_t DCameraCaptureInfoCmd::UmarshalValue(cJSON *rootValue) | |||
| 160 | CHECK_NULL_RETURN((isCapture == nullptr || !cJSON_IsBool(isCapture)), DCAMERA_BAD_VALUE); | 162 | CHECK_NULL_RETURN((isCapture == nullptr || !cJSON_IsBool(isCapture)), DCAMERA_BAD_VALUE); |
| 161 | captureInfo->isCapture_ = cJSON_IsTrue(isCapture); | 163 | captureInfo->isCapture_ = cJSON_IsTrue(isCapture); |
| 162 | 164 | ||
| 165 | + | ||
| 163 | cJSON *encodeType = cJSON_GetObjectItemCaseSensitive(capInfo, "EncodeType"); | 166 | cJSON *encodeType = cJSON_GetObjectItemCaseSensitive(capInfo, "EncodeType"); |
| 164 | CHECK_NULL_RETURN((encodeType == nullptr || !cJSON_IsNumber(encodeType)), DCAMERA_BAD_VALUE); | 167 | CHECK_NULL_RETURN((encodeType == nullptr || !cJSON_IsNumber(encodeType)), DCAMERA_BAD_VALUE); |
| 165 | captureInfo->encodeType_ = static_cast<DCEncodeType>(encodeType->valueint); | 168 | captureInfo->encodeType_ = static_cast<DCEncodeType>(encodeType->valueint); |
| @@ -174,11 +177,13 @@ int32_t DCameraCaptureInfoCmd::UmarshalValue(cJSON *rootValue) | |||
| 174 | if (ret != DCAMERA_OK) { | 177 | if (ret != DCAMERA_OK) { |
| 175 | return ret; | 178 | return ret; |
| 176 | } | 179 | } |
| 180 | + | ||
| 177 | value_.push_back(captureInfo); | 181 | value_.push_back(captureInfo); |
| 178 | } | 182 | } |
| 179 | return DCAMERA_OK; | 183 | return DCAMERA_OK; |
| 180 | } | 184 | } |
| 181 | 185 | ||
| 186 | + | ||
| 182 | int32_t DCameraCaptureInfoCmd::UmarshalSettings(cJSON *valueJson, | 187 | int32_t DCameraCaptureInfoCmd::UmarshalSettings(cJSON *valueJson, |
| 183 | std::shared_ptr<DCameraCaptureInfo>& captureInfo) | 188 | std::shared_ptr<DCameraCaptureInfo>& captureInfo) |
| 184 | { | 189 | { |
| @@ -204,5 +209,6 @@ int32_t DCameraCaptureInfoCmd::UmarshalSettings(cJSON *valueJson, | |||
| 204 | } | 209 | } |
| 205 | return DCAMERA_OK; | 210 | return DCAMERA_OK; |
| 206 | } | 211 | } |
| 212 | + | ||
| 207 | } // namespace DistributedHardware | 213 | } // namespace DistributedHardware |
| 208 | } // namespace OHOS | 214 | } // namespace OHOS |
| @@ -21,6 +21,7 @@ | |||
| 21 | 21 | ||
| 22 | namespace OHOS { | 22 | namespace OHOS { |
| 23 | namespace DistributedHardware { | 23 | namespace DistributedHardware { |
| 24 | + | ||
| 24 | int32_t DCameraChannelInfoCmd::Marshal(std::string& jsonStr) | 25 | int32_t DCameraChannelInfoCmd::Marshal(std::string& jsonStr) |
| 25 | { | 26 | { |
| 26 | cJSON *rootValue = cJSON_CreateObject(); | 27 | cJSON *rootValue = cJSON_CreateObject(); |
| @@ -68,6 +69,7 @@ int32_t DCameraChannelInfoCmd::Marshal(std::string& jsonStr) | |||
| 68 | cJSON_free(data); | 69 | cJSON_free(data); |
| 69 | return DCAMERA_OK; | 70 | return DCAMERA_OK; |
| 70 | } | 71 | } |
| 72 | + | ||
| 71 | 73 | ||
| 72 | int32_t DCameraChannelInfoCmd::Unmarshal(const std::string& jsonStr) | 74 | int32_t DCameraChannelInfoCmd::Unmarshal(const std::string& jsonStr) |
| 73 | { | 75 | { |
| @@ -93,6 +95,7 @@ int32_t DCameraChannelInfoCmd::Unmarshal(const std::string& jsonStr) | |||
| 93 | return DCAMERA_BAD_VALUE; | 95 | return DCAMERA_BAD_VALUE; |
| 94 | } | 96 | } |
| 95 | command_ = command->valuestring; | 97 | command_ = command->valuestring; |
| 98 | + | ||
| 96 | cJSON *valueJson = cJSON_GetObjectItemCaseSensitive(rootValue, "Value"); | 99 | cJSON *valueJson = cJSON_GetObjectItemCaseSensitive(rootValue, "Value"); |
| 97 | if (valueJson == nullptr || !cJSON_IsObject(valueJson)) { | 100 | if (valueJson == nullptr || !cJSON_IsObject(valueJson)) { |
| 98 | cJSON_Delete(rootValue); | 101 | cJSON_Delete(rootValue); |
| @@ -115,10 +118,12 @@ int32_t DCameraChannelInfoCmd::Unmarshal(const std::string& jsonStr) | |||
| 115 | return DCAMERA_BAD_VALUE; | 118 | return DCAMERA_BAD_VALUE; |
| 116 | } | 119 | } |
| 117 | value_ = channelInfo; | 120 | value_ = channelInfo; |
| 121 | + | ||
| 118 | cJSON_Delete(rootValue); | 122 | cJSON_Delete(rootValue); |
| 119 | return DCAMERA_OK; | 123 | return DCAMERA_OK; |
| 120 | } | 124 | } |
| 121 | 125 | ||
| 126 | + | ||
| 122 | int32_t DCameraChannelInfoCmd::UnmarshalDetails(cJSON *details, std::shared_ptr<DCameraChannelInfo> channelInfo) | 127 | int32_t DCameraChannelInfoCmd::UnmarshalDetails(cJSON *details, std::shared_ptr<DCameraChannelInfo> channelInfo) |
| 123 | { | 128 | { |
| 124 | CHECK_AND_RETURN_RET_LOG(details == nullptr, DCAMERA_BAD_VALUE, "details is nullptr"); | 129 | CHECK_AND_RETURN_RET_LOG(details == nullptr, DCAMERA_BAD_VALUE, "details is nullptr"); |
| @@ -141,5 +146,6 @@ int32_t DCameraChannelInfoCmd::UnmarshalDetails(cJSON *details, std::shared_ptr< | |||
| 141 | } | 146 | } |
| 142 | return DCAMERA_OK; | 147 | return DCAMERA_OK; |
| 143 | } | 148 | } |
| 149 | + | ||
| 144 | } // namespace DistributedHardware | 150 | } // namespace DistributedHardware |
| 145 | } // namespace OHOS | 151 | } // namespace OHOS |
| @@ -22,6 +22,7 @@ | |||
| 22 | 22 | ||
| 23 | namespace OHOS { | 23 | namespace OHOS { |
| 24 | namespace DistributedHardware { | 24 | namespace DistributedHardware { |
| 25 | + | ||
| 25 | int32_t DCameraMetadataSettingCmd::Marshal(std::string& jsonStr) | 26 | int32_t DCameraMetadataSettingCmd::Marshal(std::string& jsonStr) |
| 26 | { | 27 | { |
| 27 | cJSON *rootValue = cJSON_CreateObject(); | 28 | cJSON *rootValue = cJSON_CreateObject(); |
| @@ -113,5 +114,6 @@ int32_t DCameraMetadataSettingCmd::Unmarshal(const std::string& jsonStr) | |||
| 113 | cJSON_Delete(rootValue); | 114 | cJSON_Delete(rootValue); |
| 114 | return DCAMERA_OK; | 115 | return DCAMERA_OK; |
| 115 | } | 116 | } |
| 117 | + | ||
| 116 | } // namespace DistributedHardware | 118 | } // namespace DistributedHardware |
| 117 | } // namespace OHOS | 119 | } // namespace OHOS |
| @@ -11,7 +11,12 @@ | |||
| 11 | # See the License for the specific language governing permissions and | 11 | # See the License for the specific language governing permissions and |
| 12 | # limitations under the License. | 12 | # limitations under the License. |
| 13 | 13 | ||
| 14 | +if (!defined(ohos_lite)) { | ||
| 14 | group("services_base_test") { | 15 | group("services_base_test") { |
| 15 | testonly = true | 16 | testonly = true |
| 16 | deps = [ "common/base:dcamera_services_base_test" ] | 17 | deps = [ "common/base:dcamera_services_base_test" ] |
| 17 | } | 18 | } |
| 19 | +} else { | ||
| 20 | + group("services_base_test") { | ||
| 21 | + } | ||
| 22 | +} | ||
| @@ -22,7 +22,7 @@ config("module_private_config") { | |||
| 22 | 22 | ||
| 23 | include_dirs = [ | 23 | include_dirs = [ |
| 24 | "${innerkits_path}/native_cpp/camera_source/include", | 24 | "${innerkits_path}/native_cpp/camera_source/include", |
| 25 | - "${innerkits_path}/native_cpp/camera_sink/include", | 25 | + "${innerkits_path}/native_cpp/camera_sink/include/standard", |
| 26 | "${innerkits_path}/native_cpp/camera_source/include/callback", | 26 | "${innerkits_path}/native_cpp/camera_source/include/callback", |
| 27 | "${services_path}/cameraservice/base/include", | 27 | "${services_path}/cameraservice/base/include", |
| 28 | "${common_path}/include/constants", | 28 | "${common_path}/include/constants", |
| @@ -18,7 +18,8 @@ import( | |||
| 18 | 18 | ||
| 19 | ohos_shared_library("distributed_camera_client") { | 19 | ohos_shared_library("distributed_camera_client") { |
| 20 | branch_protector_ret = "pac_ret" | 20 | branch_protector_ret = "pac_ret" |
| 21 | - sanitize = { | 21 | + if (!defined(ohos_lite)) { |
| 22 | + sanitize = { | ||
| 22 | cfi = true | 23 | cfi = true |
| 23 | cfi_cross_dso = true | 24 | cfi_cross_dso = true |
| 24 | debug = false | 25 | debug = false |
| @@ -26,31 +27,107 @@ ohos_shared_library("distributed_camera_client") { | |||
| 26 | integer_overflow = true | 27 | integer_overflow = true |
| 27 | ubsan = true | 28 | ubsan = true |
| 28 | } | 29 | } |
| 30 | + } | ||
| 29 | stack_protector_ret = true | 31 | stack_protector_ret = true |
| 30 | 32 | ||
| 31 | - include_dirs = [ | 33 | + deps = [ "${common_path}:distributed_camera_utils" ] |
| 32 | - "include", | ||
| 33 | - "include/callback", | ||
| 34 | - "include/listener", | ||
| 35 | - "${common_path}/include/constants", | ||
| 36 | - "${common_path}/include/utils", | ||
| 37 | - "${services_path}/cameraservice/base/include", | ||
| 38 | - "${feeding_smoother_path}/base", | ||
| 39 | - "${feeding_smoother_path}/derived", | ||
| 40 | - "${feeding_smoother_path}/utils", | ||
| 41 | - ] | ||
| 42 | 34 | ||
| 43 | - sources = [ | 35 | + if (defined(ohos_lite)) { |
| 44 | - "src/callback/dcamera_input_callback.cpp", | 36 | + include_dirs = [ |
| 45 | - "src/callback/dcamera_manager_callback.cpp", | 37 | + "include", |
| 46 | - "src/callback/dcamera_photo_callback.cpp", | 38 | + "include/lite", |
| 47 | - "src/callback/dcamera_preview_callback.cpp", | 39 | + "${common_path}/include/constants", |
| 48 | - "src/callback/dcamera_session_callback.cpp", | 40 | + "${common_path}/include/utils", |
| 49 | - "src/callback/dcamera_video_callback.cpp", | 41 | + "${services_path}/cameraservice/base/include", |
| 50 | - "src/listener/dcamera_photo_surface_listener.cpp", | 42 | + "${feeding_smoother_path}/base", |
| 51 | - ] | 43 | + "${feeding_smoother_path}/derived", |
| 44 | + "${feeding_smoother_path}/utils", | ||
| 45 | + "//foundation/multimedia/camera_lite/interfaces/kits", | ||
| 46 | + "//foundation/multimedia/media_utils_lite/interfaces/kits", | ||
| 47 | + "//foundation/graphic/surface_lite/interfaces/kits", | ||
| 48 | + "//foundation/graphic/graphic_utils_lite/interfaces/kits", | ||
| 49 | + ] | ||
| 52 | 50 | ||
| 53 | - sources += [ "src/dcamera_client.cpp" ] | 51 | + sources = [ |
| 52 | + "src/lite/dcamera_client.cpp", | ||
| 53 | + "src/lite/dcamera_lite_surface_listener.cpp", | ||
| 54 | + ] | ||
| 55 | + | ||
| 56 | + external_deps = [ | ||
| 57 | + "cJSON:cjson", | ||
| 58 | + "distributed_hardware_fwk:distributedhardwareutils", | ||
| 59 | + "hilog_lite:hilog_shared", | ||
| 60 | + ] | ||
| 61 | + | ||
| 62 | + deps += [ | ||
| 63 | + "//foundation/multimedia/camera_lite/frameworks:camera_lite", | ||
| 64 | + "//foundation/multimedia/camera_lite/services:camera_service_impl", | ||
| 65 | + "//foundation/graphic/surface_lite:surface_lite", | ||
| 66 | + ] | ||
| 67 | + | ||
| 68 | + defines = [ | ||
| 69 | + "HI_LOG_ENABLE", | ||
| 70 | + "DH_LOG_TAG=\"dcameraclient\"", | ||
| 71 | + "LOG_DOMAIN=0xD004150", | ||
| 72 | + "DCAMERA_LITE", | ||
| 73 | + "OHOS_LITE", | ||
| 74 | + ] | ||
| 75 | + | ||
| 76 | + include_dirs += [ "//third_party/cJSON" ] | ||
| 77 | + } else { | ||
| 78 | + include_dirs = [ | ||
| 79 | + "include", | ||
| 80 | + "include/standard", | ||
| 81 | + "include/callback", | ||
| 82 | + "include/listener", | ||
| 83 | + "${common_path}/include/constants", | ||
| 84 | + "${common_path}/include/utils", | ||
| 85 | + "${services_path}/cameraservice/base/include", | ||
| 86 | + "${feeding_smoother_path}/base", | ||
| 87 | + "${feeding_smoother_path}/derived", | ||
| 88 | + "${feeding_smoother_path}/utils", | ||
| 89 | + ] | ||
| 90 | + | ||
| 91 | + sources = [ | ||
| 92 | + "src/standard/callback/dcamera_input_callback.cpp", | ||
| 93 | + "src/standard/callback/dcamera_manager_callback.cpp", | ||
| 94 | + "src/standard/callback/dcamera_photo_callback.cpp", | ||
| 95 | + "src/standard/callback/dcamera_preview_callback.cpp", | ||
| 96 | + "src/standard/callback/dcamera_session_callback.cpp", | ||
| 97 | + "src/standard/callback/dcamera_video_callback.cpp", | ||
| 98 | + "src/standard/listener/dcamera_photo_surface_listener.cpp", | ||
| 99 | + "src/standard/dcamera_client.cpp", | ||
| 100 | + ] | ||
| 101 | + | ||
| 102 | + external_deps = [ | ||
| 103 | + "cJSON:cjson", | ||
| 104 | + "c_utils:utils", | ||
| 105 | + "camera_framework:camera_framework", | ||
| 106 | + "distributed_hardware_fwk:distributedhardwareutils", | ||
| 107 | + "drivers_interface_camera:libbuffer_handle_sequenceable_1.0", | ||
| 108 | + "drivers_interface_camera:libbuffer_producer_sequenceable_1.0", | ||
| 109 | + "drivers_interface_camera:libcamera_proxy_1.0", | ||
| 110 | + "drivers_interface_camera:libmap_data_sequenceable_1.0", | ||
| 111 | + "drivers_interface_camera:metadata", | ||
| 112 | + "drivers_interface_distributed_camera:libdistributed_camera_provider_proxy_1.1", | ||
| 113 | + "graphic_surface:surface", | ||
| 114 | + "hdf_core:libhdf_utils", | ||
| 115 | + "hilog:libhilog", | ||
| 116 | + "ipc:ipc_core", | ||
| 117 | + "safwk:system_ability_fwk", | ||
| 118 | + "samgr:samgr_proxy", | ||
| 119 | + ] | ||
| 120 | + | ||
| 121 | + defines = [ | ||
| 122 | + "HI_LOG_ENABLE", | ||
| 123 | + "DH_LOG_TAG=\"dcameraclient\"", | ||
| 124 | + "LOG_DOMAIN=0xD004150", | ||
| 125 | + ] | ||
| 126 | + } | ||
| 127 | + | ||
| 128 | + if (build_variant == "root") { | ||
| 129 | + defines += [ "DUMP_DCAMERA_FILE" ] | ||
| 130 | + } | ||
| 54 | 131 | ||
| 55 | ldflags = [ | 132 | ldflags = [ |
| 56 | "-fpie", | 133 | "-fpie", |
| @@ -58,36 +135,12 @@ ohos_shared_library("distributed_camera_client") { | |||
| 58 | "-Wl,-z,now", | 135 | "-Wl,-z,now", |
| 59 | ] | 136 | ] |
| 60 | 137 | ||
| 61 | - deps = [ "${common_path}:distributed_camera_utils" ] | 138 | + cflags = [ |
| 62 | - | 139 | + "-fPIC", |
| 63 | - defines = [ | 140 | + "-Wall", |
| 64 | - "HI_LOG_ENABLE", | ||
| 65 | - "DH_LOG_TAG=\"dcameraclient\"", | ||
| 66 | - "LOG_DOMAIN=0xD004150", | ||
| 67 | ] | 141 | ] |
| 68 | 142 | ||
| 69 | - if (build_variant == "root") { | 143 | + cflags_cc = cflags |
| 70 | - defines += [ "DUMP_DCAMERA_FILE" ] | ||
| 71 | - } | ||
| 72 | - | ||
| 73 | - external_deps = [ | ||
| 74 | - "cJSON:cjson", | ||
| 75 | - "c_utils:utils", | ||
| 76 | - "camera_framework:camera_framework", | ||
| 77 | - "distributed_hardware_fwk:distributedhardwareutils", | ||
| 78 | - "drivers_interface_camera:libbuffer_handle_sequenceable_1.0", | ||
| 79 | - "drivers_interface_camera:libbuffer_producer_sequenceable_1.0", | ||
| 80 | - "drivers_interface_camera:libcamera_proxy_1.0", | ||
| 81 | - "drivers_interface_camera:libmap_data_sequenceable_1.0", | ||
| 82 | - "drivers_interface_camera:metadata", | ||
| 83 | - "drivers_interface_distributed_camera:libdistributed_camera_provider_proxy_1.1", | ||
| 84 | - "graphic_surface:surface", | ||
| 85 | - "hdf_core:libhdf_utils", | ||
| 86 | - "hilog:libhilog", | ||
| 87 | - "ipc:ipc_core", | ||
| 88 | - "safwk:system_ability_fwk", | ||
| 89 | - "samgr:samgr_proxy", | ||
| 90 | - ] | ||
| 91 | 144 | ||
| 92 | subsystem_name = "distributedhardware" | 145 | subsystem_name = "distributedhardware" |
| 93 | 146 | ||
| @@ -24,21 +24,30 @@ | |||
| 24 | 24 | ||
| 25 | 25 | ||
| 26 | 26 | ||
| 27 | + | ||
| 27 | 28 | ||
| 29 | + | ||
| 30 | + | ||
| 31 | + | ||
| 32 | + | ||
| 33 | + | ||
| 28 | 34 | ||
| 29 | 35 | ||
| 30 | - | ||
| 31 | 36 | ||
| 32 | namespace OHOS { | 37 | namespace OHOS { |
| 33 | namespace DistributedHardware { | 38 | namespace DistributedHardware { |
| 39 | + | ||
| 34 | using namespace OHOS::HDI::DistributedCamera::V1_1; | 40 | using namespace OHOS::HDI::DistributedCamera::V1_1; |
| 41 | + | ||
| 35 | class StateCallback { | 42 | class StateCallback { |
| 36 | public: | 43 | public: |
| 37 | StateCallback() = default; | 44 | StateCallback() = default; |
| 38 | virtual ~StateCallback() = default; | 45 | virtual ~StateCallback() = default; |
| 39 | 46 | ||
| 40 | virtual void OnStateChanged(std::shared_ptr<DCameraEvent>& event) = 0; | 47 | virtual void OnStateChanged(std::shared_ptr<DCameraEvent>& event) = 0; |
| 48 | + | ||
| 41 | virtual void OnMetadataResult(std::vector<std::shared_ptr<DCameraSettings>>& settings) = 0; | 49 | virtual void OnMetadataResult(std::vector<std::shared_ptr<DCameraSettings>>& settings) = 0; |
| 50 | + | ||
| 42 | }; | 51 | }; |
| 43 | 52 | ||
| 44 | class ResultCallback { | 53 | class ResultCallback { |
| @@ -57,17 +66,31 @@ public: | |||
| 57 | 66 | ||
| 58 | virtual int32_t Init() = 0; | 67 | virtual int32_t Init() = 0; |
| 59 | virtual int32_t UnInit() = 0; | 68 | virtual int32_t UnInit() = 0; |
| 69 | + | ||
| 60 | virtual int32_t UpdateSettings(std::vector<std::shared_ptr<DCameraSettings>>& settings) = 0; | 70 | virtual int32_t UpdateSettings(std::vector<std::shared_ptr<DCameraSettings>>& settings) = 0; |
| 71 | + | ||
| 72 | + | ||
| 61 | virtual int32_t StartCapture(std::vector<std::shared_ptr<DCameraCaptureInfo>>& captureInfos, | 73 | virtual int32_t StartCapture(std::vector<std::shared_ptr<DCameraCaptureInfo>>& captureInfos, |
| 62 | sptr<Surface>& surface, int32_t sceneMode) = 0; | 74 | sptr<Surface>& surface, int32_t sceneMode) = 0; |
| 75 | + | ||
| 76 | + virtual int32_t StartCapture(std::vector<std::shared_ptr<DCameraCaptureInfo>>& captureInfos, | ||
| 77 | + int32_t sceneMode) = 0; | ||
| 78 | + | ||
| 63 | virtual int32_t PrepareCapture(std::vector<std::shared_ptr<DCameraCaptureInfo>>& captureInfos, int32_t sceneMode) | 79 | virtual int32_t PrepareCapture(std::vector<std::shared_ptr<DCameraCaptureInfo>>& captureInfos, int32_t sceneMode) |
| 64 | { | 80 | { |
| 65 | return DCAMERA_BAD_OPERATE; | 81 | return DCAMERA_BAD_OPERATE; |
| 66 | } | 82 | } |
| 83 | + | ||
| 67 | virtual int32_t CommitCapture(sptr<Surface>& surface) | 84 | virtual int32_t CommitCapture(sptr<Surface>& surface) |
| 68 | { | 85 | { |
| 69 | return DCAMERA_BAD_OPERATE; | 86 | return DCAMERA_BAD_OPERATE; |
| 70 | } | 87 | } |
| 88 | + | ||
| 89 | + virtual int32_t CommitCapture() | ||
| 90 | + { | ||
| 91 | + return DCAMERA_BAD_OPERATE; | ||
| 92 | + } | ||
| 93 | + | ||
| 71 | virtual int32_t StopCapture() = 0; | 94 | virtual int32_t StopCapture() = 0; |
| 72 | virtual int32_t SetStateCallback(std::shared_ptr<StateCallback>& callback) = 0; | 95 | virtual int32_t SetStateCallback(std::shared_ptr<StateCallback>& callback) = 0; |
| 73 | virtual int32_t SetResultCallback(std::shared_ptr<ResultCallback>& callback) = 0; | 96 | virtual int32_t SetResultCallback(std::shared_ptr<ResultCallback>& callback) = 0; |
| @@ -0,0 +1,88 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) 2021-2026 Huawei Device Co., Ltd. | ||
| 3 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 4 | + * you may not use this file except in compliance with the License. | ||
| 5 | + * You may obtain a copy of the License at | ||
| 6 | + * | ||
| 7 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 8 | + * | ||
| 9 | + * Unless required by applicable law or agreed to in writing, software | ||
| 10 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 11 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 12 | + * See the License for the specific language governing permissions and | ||
| 13 | + * limitations under the License. | ||
| 14 | + */ | ||
| 15 | + | ||
| 16 | + | ||
| 17 | + | ||
| 18 | + | ||
| 19 | + | ||
| 20 | + | ||
| 21 | + | ||
| 22 | + | ||
| 23 | + | ||
| 24 | + | ||
| 25 | + | ||
| 26 | + | ||
| 27 | + | ||
| 28 | + | ||
| 29 | + | ||
| 30 | + | ||
| 31 | + | ||
| 32 | +namespace OHOS { | ||
| 33 | +namespace DistributedHardware { | ||
| 34 | +class DCameraLiteSurfaceListener; | ||
| 35 | + | ||
| 36 | +class DCameraClient : public ICameraOperator { | ||
| 37 | +public: | ||
| 38 | + explicit DCameraClient(const std::string& dhId); | ||
| 39 | + ~DCameraClient() override; | ||
| 40 | + | ||
| 41 | + int32_t Init() override; | ||
| 42 | + int32_t UnInit() override; | ||
| 43 | + | ||
| 44 | + int32_t UpdateSettings(std::vector<std::shared_ptr<DCameraSettings>>& settings) override; | ||
| 45 | + | ||
| 46 | + int32_t StartCapture(std::vector<std::shared_ptr<DCameraCaptureInfo>>& captureInfos, | ||
| 47 | + int32_t sceneMode) override; | ||
| 48 | + int32_t PrepareCapture(std::vector<std::shared_ptr<DCameraCaptureInfo>>& captureInfos, int32_t sceneMode) override; | ||
| 49 | + int32_t CommitCapture() override; | ||
| 50 | + int32_t StopCapture() override; | ||
| 51 | + int32_t SetStateCallback(std::shared_ptr<StateCallback>& callback) override; | ||
| 52 | + int32_t SetResultCallback(std::shared_ptr<ResultCallback>& callback) override; | ||
| 53 | + int32_t PauseCapture() override; | ||
| 54 | + int32_t ResumeCapture() override; | ||
| 55 | + void SetCallerInfo(const std::string& srcDevId, const std::string& deviceName) override; | ||
| 56 | + | ||
| 57 | +private: | ||
| 58 | + int32_t CreateCameraDevice(); | ||
| 59 | + int32_t CreateVideoOutput(std::shared_ptr<DCameraCaptureInfo>& info); | ||
| 60 | + int32_t CreatePhotoOutput(std::shared_ptr<DCameraCaptureInfo>& info); | ||
| 61 | + int32_t StartVideoOutput(); | ||
| 62 | + int32_t StartPhotoOutput(); | ||
| 63 | + void ReleaseCamera(); | ||
| 64 | + void ReleaseOutputs(); | ||
| 65 | + int32_t ConvertToLiteImageFormat(DCEncodeType encodeType); | ||
| 66 | + int32_t GetMaxFrameRate(std::shared_ptr<DCameraCaptureInfo>& captureInfo); | ||
| 67 | + | ||
| 68 | + bool isInit_ = false; | ||
| 69 | + std::string cameraId_; | ||
| 70 | + std::string srcDevId_; | ||
| 71 | + | ||
| 72 | + OHOS::Media::CameraService *cameraService_ = nullptr; | ||
| 73 | + OHOS::Media::CameraDevice *cameraDevice_ = nullptr; | ||
| 74 | + uint32_t videoStreamId_ = 0; | ||
| 75 | + uint32_t photoStreamId_ = 0; | ||
| 76 | + | ||
| 77 | + std::vector<std::shared_ptr<DCameraCaptureInfo>> captureInfosCache_; | ||
| 78 | + | ||
| 79 | + std::map<DCStreamType, OHOS::Surface *> surfaces_; | ||
| 80 | + std::map<DCStreamType, std::shared_ptr<DCameraLiteSurfaceListener>> surfaceListeners_; | ||
| 81 | + std::map<DCStreamType, std::shared_ptr<OHOS::Media::FrameConfig>> frameConfigs_; | ||
| 82 | + | ||
| 83 | + std::shared_ptr<StateCallback> stateCallback_; | ||
| 84 | + std::shared_ptr<ResultCallback> resultCallback_; | ||
| 85 | +}; | ||
| 86 | +} // namespace DistributedHardware | ||
| 87 | +} // namespace OHOS | ||
| 88 | + | ||
Rservices/cameraservice/cameraoperator/client/include/dcamera_client.h→services/cameraservice/cameraoperator/client/include/standard/dcamera_client.h+0-0
文件重命名但无更改。
| @@ -0,0 +1,378 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) 2021-2026 Huawei Device Co., Ltd. | ||
| 3 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 4 | + * you may not use this file except in compliance with the License. | ||
| 5 | + * You may obtain a copy of the License at | ||
| 6 | + * | ||
| 7 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 8 | + * | ||
| 9 | + * Unless required by applicable law or agreed to in writing, software | ||
| 10 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 11 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 12 | + * See the License for the specific language governing permissions and | ||
| 13 | + * limitations under the License. | ||
| 14 | + */ | ||
| 15 | + | ||
| 16 | + | ||
| 17 | + | ||
| 18 | + | ||
| 19 | + | ||
| 20 | + | ||
| 21 | + | ||
| 22 | + | ||
| 23 | + | ||
| 24 | +namespace OHOS { | ||
| 25 | +namespace DistributedHardware { | ||
| 26 | +namespace { | ||
| 27 | +constexpr int32_t DEFAULT_VIDEO_FPS = 30; | ||
| 28 | +constexpr uint32_t SURFACE_QUEUE_SIZE = 3; | ||
| 29 | +constexpr uint32_t SURFACE_BUFFER_DIVIDEND = 3; | ||
| 30 | +constexpr uint32_t SURFACE_BUFFER_DIVISOR = 4; | ||
| 31 | +constexpr uint32_t PHOTO_SURFACE_BUFFER_MULTIPLIER = 2; | ||
| 32 | +} // namespace | ||
| 33 | + | ||
| 34 | +DCameraClient::DCameraClient(const std::string& dhId) | ||
| 35 | +{ | ||
| 36 | + DHLOGI("DCameraClient Constructor dhId: %{public}s", GetAnonyString(dhId).c_str()); | ||
| 37 | + if (dhId.size() >= CAMERA_ID_PREFIX.size()) { | ||
| 38 | + cameraId_ = dhId.substr(CAMERA_ID_PREFIX.size()); | ||
| 39 | + } else { | ||
| 40 | + cameraId_ = dhId; | ||
| 41 | + } | ||
| 42 | +} | ||
| 43 | + | ||
| 44 | +DCameraClient::~DCameraClient() | ||
| 45 | +{ | ||
| 46 | + if (isInit_) { | ||
| 47 | + UnInit(); | ||
| 48 | + } | ||
| 49 | +} | ||
| 50 | + | ||
| 51 | +int32_t DCameraClient::Init() | ||
| 52 | +{ | ||
| 53 | + DHLOGI("Init cameraId: %{public}s", GetAnonyString(cameraId_).c_str()); | ||
| 54 | + cameraService_ = OHOS::Media::CameraService::GetInstance(); | ||
| 55 | + if (cameraService_ == nullptr) { | ||
| 56 | + DHLOGE("CameraService getInstance failed"); | ||
| 57 | + return DCAMERA_BAD_VALUE; | ||
| 58 | + } | ||
| 59 | + int32_t halRet = cameraService_->Initialize(); | ||
| 60 | + if (halRet != 0) { | ||
| 61 | + DHLOGE("camera HAL init failed, ret: %{public}d", halRet); | ||
| 62 | + return DCAMERA_BAD_VALUE; | ||
| 63 | + } | ||
| 64 | + | ||
| 65 | + std::list<std::string> cameraIds = cameraService_->GetCameraIdList(); | ||
| 66 | + if (cameraIds.empty()) { | ||
| 67 | + DHLOGE("no camera device"); | ||
| 68 | + return DCAMERA_BAD_VALUE; | ||
| 69 | + } | ||
| 70 | + | ||
| 71 | + bool found = false; | ||
| 72 | + for (const auto& id : cameraIds) { | ||
| 73 | + if (id == cameraId_) { | ||
| 74 | + found = true; | ||
| 75 | + break; | ||
| 76 | + } | ||
| 77 | + } | ||
| 78 | + if (!found) { | ||
| 79 | + DHLOGE("cameraId %{public}s not found", GetAnonyString(cameraId_).c_str()); | ||
| 80 | + return DCAMERA_BAD_VALUE; | ||
| 81 | + } | ||
| 82 | + | ||
| 83 | + int32_t ret = CreateCameraDevice(); | ||
| 84 | + if (ret != DCAMERA_OK) { | ||
| 85 | + return ret; | ||
| 86 | + } | ||
| 87 | + | ||
| 88 | + isInit_ = true; | ||
| 89 | + DHLOGI("Init %{public}s success", GetAnonyString(cameraId_).c_str()); | ||
| 90 | + return DCAMERA_OK; | ||
| 91 | +} | ||
| 92 | + | ||
| 93 | +int32_t DCameraClient::CreateCameraDevice() | ||
| 94 | +{ | ||
| 95 | + int32_t ret = cameraService_->CreateCamera(cameraId_); | ||
| 96 | + if (ret != OHOS::Media::CameraServiceCallback::CAMERA_STATUS_CREATED) { | ||
| 97 | + DHLOGE("CreateCamera failed, cameraId: %{public}s, ret: %{public}d", | ||
| 98 | + GetAnonyString(cameraId_).c_str(), ret); | ||
| 99 | + return DCAMERA_BAD_VALUE; | ||
| 100 | + } | ||
| 101 | + | ||
| 102 | + cameraDevice_ = cameraService_->GetCameraDevice(cameraId_); | ||
| 103 | + if (cameraDevice_ == nullptr) { | ||
| 104 | + DHLOGE("GetCameraDevice failed, cameraId: %{public}s", GetAnonyString(cameraId_).c_str()); | ||
| 105 | + return DCAMERA_BAD_VALUE; | ||
| 106 | + } | ||
| 107 | + | ||
| 108 | + DHLOGI("CreateCameraDevice %{public}s success", GetAnonyString(cameraId_).c_str()); | ||
| 109 | + return DCAMERA_OK; | ||
| 110 | +} | ||
| 111 | + | ||
| 112 | +int32_t DCameraClient::UnInit() | ||
| 113 | +{ | ||
| 114 | + DHLOGI("UnInit cameraId: %{public}s", GetAnonyString(cameraId_).c_str()); | ||
| 115 | + StopCapture(); | ||
| 116 | + ReleaseCamera(); | ||
| 117 | + isInit_ = false; | ||
| 118 | + DHLOGI("UnInit %{public}s success", GetAnonyString(cameraId_).c_str()); | ||
| 119 | + return DCAMERA_OK; | ||
| 120 | +} | ||
| 121 | + | ||
| 122 | +void DCameraClient::ReleaseCamera() | ||
| 123 | +{ | ||
| 124 | + ReleaseOutputs(); | ||
| 125 | + if (cameraService_ != nullptr) { | ||
| 126 | + cameraService_->CloseCamera(cameraId_); | ||
| 127 | + } | ||
| 128 | + cameraDevice_ = nullptr; | ||
| 129 | + cameraService_ = nullptr; | ||
| 130 | +} | ||
| 131 | + | ||
| 132 | +void DCameraClient::ReleaseOutputs() | ||
| 133 | +{ | ||
| 134 | + for (auto& iter : surfaceListeners_) { | ||
| 135 | + if (iter.second != nullptr && iter.first == CONTINUOUS_FRAME) { | ||
| 136 | + auto fcIter = frameConfigs_.find(CONTINUOUS_FRAME); | ||
| 137 | + if (fcIter != frameConfigs_.end() && cameraDevice_ != nullptr) { | ||
| 138 | + cameraDevice_->StopLoopingCapture(OHOS::Media::FRAME_CONFIG_RECORD); | ||
| 139 | + } | ||
| 140 | + } | ||
| 141 | + } | ||
| 142 | + surfaceListeners_.clear(); | ||
| 143 | + frameConfigs_.clear(); | ||
| 144 | + for (auto& iter : surfaces_) { | ||
| 145 | + delete iter.second; | ||
| 146 | + } | ||
| 147 | + surfaces_.clear(); | ||
| 148 | + videoStreamId_ = 0; | ||
| 149 | + photoStreamId_ = 0; | ||
| 150 | +} | ||
| 151 | + | ||
| 152 | +int32_t DCameraClient::StartCapture(std::vector<std::shared_ptr<DCameraCaptureInfo>>& captureInfos, | ||
| 153 | + int32_t sceneMode) | ||
| 154 | +{ | ||
| 155 | + DHLOGI("StartCapture legacy entry cameraId: %{public}s", GetAnonyString(cameraId_).c_str()); | ||
| 156 | + (void)sceneMode; | ||
| 157 | + int32_t ret = PrepareCapture(captureInfos, sceneMode); | ||
| 158 | + if (ret != DCAMERA_OK) { | ||
| 159 | + DHLOGE("StartCapture PrepareCapture failed, ret: %{public}d", ret); | ||
| 160 | + return ret; | ||
| 161 | + } | ||
| 162 | + return CommitCapture(); | ||
| 163 | +} | ||
| 164 | + | ||
| 165 | +int32_t DCameraClient::PrepareCapture(std::vector<std::shared_ptr<DCameraCaptureInfo>>& captureInfos, | ||
| 166 | + int32_t sceneMode) | ||
| 167 | +{ | ||
| 168 | + (void)sceneMode; | ||
| 169 | + DHLOGI("PrepareCapture cameraId: %{public}s", GetAnonyString(cameraId_).c_str()); | ||
| 170 | + if (cameraDevice_ == nullptr) { | ||
| 171 | + DHLOGE("cameraDevice is null"); | ||
| 172 | + return DCAMERA_BAD_VALUE; | ||
| 173 | + } | ||
| 174 | + | ||
| 175 | + captureInfosCache_ = captureInfos; | ||
| 176 | + for (auto& info : captureInfos) { | ||
| 177 | + if (info == nullptr) { | ||
| 178 | + continue; | ||
| 179 | + } | ||
| 180 | + if (info->streamType_ == SNAPSHOT_FRAME) { | ||
| 181 | + int32_t ret = CreatePhotoOutput(info); | ||
| 182 | + if (ret != DCAMERA_OK) { | ||
| 183 | + return ret; | ||
| 184 | + } | ||
| 185 | + } else if (info->streamType_ == CONTINUOUS_FRAME) { | ||
| 186 | + int32_t ret = CreateVideoOutput(info); | ||
| 187 | + if (ret != DCAMERA_OK) { | ||
| 188 | + return ret; | ||
| 189 | + } | ||
| 190 | + } | ||
| 191 | + } | ||
| 192 | + return DCAMERA_OK; | ||
| 193 | +} | ||
| 194 | + | ||
| 195 | +int32_t DCameraClient::CreateVideoOutput(std::shared_ptr<DCameraCaptureInfo>& info) | ||
| 196 | +{ | ||
| 197 | + DHLOGI("CreateVideoOutput cameraId: %{public}s, width: %{public}d, height: %{public}d, encode: %{public}d", | ||
| 198 | + GetAnonyString(cameraId_).c_str(), info->width_, info->height_, info->encodeType_); | ||
| 199 | + OHOS::Surface *surface = OHOS::Surface::CreateSurface(); | ||
| 200 | + if (surface == nullptr) { | ||
| 201 | + DHLOGE("CreateVideoOutput create surface failed"); | ||
| 202 | + return DCAMERA_BAD_VALUE; | ||
| 203 | + } | ||
| 204 | + surface->SetQueueSize(SURFACE_QUEUE_SIZE); | ||
| 205 | + surface->SetWidthAndHeight(static_cast<uint32_t>(info->width_), static_cast<uint32_t>(info->height_)); | ||
| 206 | + surface->SetSize(static_cast<uint32_t>(info->width_ * info->height_ * SURFACE_BUFFER_DIVIDEND / | ||
| 207 | + SURFACE_BUFFER_DIVISOR)); | ||
| 208 | + | ||
| 209 | + auto listener = std::make_shared<DCameraLiteSurfaceListener>(surface, CONTINUOUS_FRAME, resultCallback_); | ||
| 210 | + surface->RegisterConsumerListener(*listener); | ||
| 211 | + | ||
| 212 | + std::shared_ptr<OHOS::Media::FrameConfig> frameConfig = | ||
| 213 | + std::make_shared<OHOS::Media::FrameConfig>(OHOS::Media::FRAME_CONFIG_RECORD); | ||
| 214 | + frameConfig->AddSurface(*surface); | ||
| 215 | + uint32_t imageFormat = static_cast<uint32_t>(ConvertToLiteImageFormat(info->encodeType_)); | ||
| 216 | + frameConfig->SetParameter(CAM_IMAGE_FORMAT, imageFormat); | ||
| 217 | + uint8_t vendorParam[OHOS::Media::PRIVATE_TAG_LEN] = {0}; | ||
| 218 | + frameConfig->SetVendorParameter(vendorParam, sizeof(vendorParam)); | ||
| 219 | + | ||
| 220 | + surfaces_[CONTINUOUS_FRAME] = surface; | ||
| 221 | + surfaceListeners_[CONTINUOUS_FRAME] = listener; | ||
| 222 | + frameConfigs_[CONTINUOUS_FRAME] = frameConfig; | ||
| 223 | + return DCAMERA_OK; | ||
| 224 | +} | ||
| 225 | + | ||
| 226 | +int32_t DCameraClient::CreatePhotoOutput(std::shared_ptr<DCameraCaptureInfo>& info) | ||
| 227 | +{ | ||
| 228 | + DHLOGI("CreatePhotoOutput cameraId: %{public}s, width: %{public}d, height: %{public}d", | ||
| 229 | + GetAnonyString(cameraId_).c_str(), info->width_, info->height_); | ||
| 230 | + OHOS::Surface *surface = OHOS::Surface::CreateSurface(); | ||
| 231 | + if (surface == nullptr) { | ||
| 232 | + DHLOGE("CreatePhotoOutput create surface failed"); | ||
| 233 | + return DCAMERA_BAD_VALUE; | ||
| 234 | + } | ||
| 235 | + surface->SetQueueSize(1); | ||
| 236 | + surface->SetWidthAndHeight(static_cast<uint32_t>(info->width_), static_cast<uint32_t>(info->height_)); | ||
| 237 | + surface->SetSize(static_cast<uint32_t>(info->width_ * info->height_ * PHOTO_SURFACE_BUFFER_MULTIPLIER)); | ||
| 238 | + | ||
| 239 | + auto listener = std::make_shared<DCameraLiteSurfaceListener>(surface, SNAPSHOT_FRAME, resultCallback_); | ||
| 240 | + surface->RegisterConsumerListener(*listener); | ||
| 241 | + | ||
| 242 | + std::shared_ptr<OHOS::Media::FrameConfig> frameConfig = | ||
| 243 | + std::make_shared<OHOS::Media::FrameConfig>(OHOS::Media::FRAME_CONFIG_CAPTURE); | ||
| 244 | + frameConfig->AddSurface(*surface); | ||
| 245 | + uint32_t imageFormat = static_cast<uint32_t>(CAM_FORMAT_JPEG); | ||
| 246 | + frameConfig->SetParameter(CAM_IMAGE_FORMAT, imageFormat); | ||
| 247 | + | ||
| 248 | + surfaces_[SNAPSHOT_FRAME] = surface; | ||
| 249 | + surfaceListeners_[SNAPSHOT_FRAME] = listener; | ||
| 250 | + frameConfigs_[SNAPSHOT_FRAME] = frameConfig; | ||
| 251 | + return DCAMERA_OK; | ||
| 252 | +} | ||
| 253 | + | ||
| 254 | +int32_t DCameraClient::CommitCapture() | ||
| 255 | +{ | ||
| 256 | + DHLOGI("CommitCapture cameraId: %{public}s", GetAnonyString(cameraId_).c_str()); | ||
| 257 | + int32_t ret = StartVideoOutput(); | ||
| 258 | + if (ret != DCAMERA_OK) { | ||
| 259 | + return ret; | ||
| 260 | + } | ||
| 261 | + ret = StartPhotoOutput(); | ||
| 262 | + if (ret != DCAMERA_OK) { | ||
| 263 | + return ret; | ||
| 264 | + } | ||
| 265 | + return DCAMERA_OK; | ||
| 266 | +} | ||
| 267 | + | ||
| 268 | +int32_t DCameraClient::StartVideoOutput() | ||
| 269 | +{ | ||
| 270 | + auto iter = frameConfigs_.find(CONTINUOUS_FRAME); | ||
| 271 | + if (iter == frameConfigs_.end()) { | ||
| 272 | + return DCAMERA_OK; | ||
| 273 | + } | ||
| 274 | + if (cameraDevice_ == nullptr) { | ||
| 275 | + DHLOGE("StartVideoOutput cameraDevice is null"); | ||
| 276 | + return DCAMERA_BAD_VALUE; | ||
| 277 | + } | ||
| 278 | + uint32_t streamId = 0; | ||
| 279 | + int32_t ret = cameraDevice_->TriggerLoopingCapture(*(iter->second), &streamId); | ||
| 280 | + if (ret != DCAMERA_OK) { | ||
| 281 | + DHLOGE("StartVideoOutput TriggerLoopingCapture failed, ret: %{public}d", ret); | ||
| 282 | + return ret; | ||
| 283 | + } | ||
| 284 | + videoStreamId_ = streamId; | ||
| 285 | + DHLOGI("StartVideoOutput %{public}s success, streamId: %{public}u", | ||
| 286 | + GetAnonyString(cameraId_).c_str(), streamId); | ||
| 287 | + return DCAMERA_OK; | ||
| 288 | +} | ||
| 289 | + | ||
| 290 | +int32_t DCameraClient::StartPhotoOutput() | ||
| 291 | +{ | ||
| 292 | + auto iter = frameConfigs_.find(SNAPSHOT_FRAME); | ||
| 293 | + if (iter == frameConfigs_.end()) { | ||
| 294 | + return DCAMERA_OK; | ||
| 295 | + } | ||
| 296 | + if (cameraDevice_ == nullptr) { | ||
| 297 | + DHLOGE("StartPhotoOutput cameraDevice is null"); | ||
| 298 | + return DCAMERA_BAD_VALUE; | ||
| 299 | + } | ||
| 300 | + for (auto& info : captureInfosCache_) { | ||
| 301 | + if (info != nullptr && info->streamType_ == SNAPSHOT_FRAME && info->isCapture_) { | ||
| 302 | + uint32_t streamId = 0; | ||
| 303 | + int32_t ret = cameraDevice_->TriggerSingleCapture(*(iter->second), &streamId); | ||
| 304 | + if (ret != DCAMERA_OK) { | ||
| 305 | + DHLOGE("StartPhotoOutput TriggerSingleCapture failed, ret: %{public}d", ret); | ||
| 306 | + return ret; | ||
| 307 | + } | ||
| 308 | + photoStreamId_ = streamId; | ||
| 309 | + } | ||
| 310 | + } | ||
| 311 | + DHLOGI("StartPhotoOutput %{public}s success", GetAnonyString(cameraId_).c_str()); | ||
| 312 | + return DCAMERA_OK; | ||
| 313 | +} | ||
| 314 | + | ||
| 315 | +int32_t DCameraClient::StopCapture() | ||
| 316 | +{ | ||
| 317 | + DHLOGI("StopCapture cameraId: %{public}s", GetAnonyString(cameraId_).c_str()); | ||
| 318 | + if (cameraDevice_ != nullptr) { | ||
| 319 | + cameraDevice_->StopLoopingCapture(OHOS::Media::FRAME_CONFIG_RECORD); | ||
| 320 | + cameraDevice_->StopLoopingCapture(OHOS::Media::FRAME_CONFIG_CAPTURE); | ||
| 321 | + } | ||
| 322 | + ReleaseOutputs(); | ||
| 323 | + return DCAMERA_OK; | ||
| 324 | +} | ||
| 325 | + | ||
| 326 | +int32_t DCameraClient::PauseCapture() | ||
| 327 | +{ | ||
| 328 | + if (cameraDevice_ == nullptr) { | ||
| 329 | + return DCAMERA_BAD_VALUE; | ||
| 330 | + } | ||
| 331 | + cameraDevice_->StopLoopingCapture(OHOS::Media::FRAME_CONFIG_RECORD); | ||
| 332 | + return DCAMERA_OK; | ||
| 333 | +} | ||
| 334 | + | ||
| 335 | +int32_t DCameraClient::ResumeCapture() | ||
| 336 | +{ | ||
| 337 | + return StartVideoOutput(); | ||
| 338 | +} | ||
| 339 | + | ||
| 340 | +int32_t DCameraClient::SetStateCallback(std::shared_ptr<StateCallback>& callback) | ||
| 341 | +{ | ||
| 342 | + stateCallback_ = callback; | ||
| 343 | + return DCAMERA_OK; | ||
| 344 | +} | ||
| 345 | + | ||
| 346 | +int32_t DCameraClient::SetResultCallback(std::shared_ptr<ResultCallback>& callback) | ||
| 347 | +{ | ||
| 348 | + resultCallback_ = callback; | ||
| 349 | + return DCAMERA_OK; | ||
| 350 | +} | ||
| 351 | + | ||
| 352 | +void DCameraClient::SetCallerInfo(const std::string& srcDevId, const std::string& deviceName) | ||
| 353 | +{ | ||
| 354 | + srcDevId_ = srcDevId; | ||
| 355 | + (void)deviceName; | ||
| 356 | +} | ||
| 357 | + | ||
| 358 | +int32_t DCameraClient::ConvertToLiteImageFormat(DCEncodeType encodeType) | ||
| 359 | +{ | ||
| 360 | + switch (encodeType) { | ||
| 361 | + case ENCODE_TYPE_H264: | ||
| 362 | + return CAM_FORMAT_H264; | ||
| 363 | + case ENCODE_TYPE_H265: | ||
| 364 | + return CAM_FORMAT_H265; | ||
| 365 | + case ENCODE_TYPE_JPEG: | ||
| 366 | + return CAM_FORMAT_JPEG; | ||
| 367 | + default: | ||
| 368 | + return CAM_FORMAT_H264; | ||
| 369 | + } | ||
| 370 | +} | ||
| 371 | + | ||
| 372 | +int32_t DCameraClient::GetMaxFrameRate(std::shared_ptr<DCameraCaptureInfo>& captureInfo) | ||
| 373 | +{ | ||
| 374 | + (void)captureInfo; | ||
| 375 | + return DEFAULT_VIDEO_FPS; | ||
| 376 | +} | ||
| 377 | +} // namespace DistributedHardware | ||
| 378 | +} // namespace OHOS | ||
| @@ -0,0 +1,95 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) 2021-2026 Huawei Device Co., Ltd. | ||
| 3 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 4 | + * you may not use this file except in compliance with the License. | ||
| 5 | + * You may obtain a copy of the License at | ||
| 6 | + * | ||
| 7 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 8 | + * | ||
| 9 | + * Unless required by applicable law or agreed to in writing, software | ||
| 10 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 11 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 12 | + * See the License for the specific language governing permissions and | ||
| 13 | + * limitations under the License. | ||
| 14 | + */ | ||
| 15 | + | ||
| 16 | + | ||
| 17 | + | ||
| 18 | + | ||
| 19 | + | ||
| 20 | + | ||
| 21 | + | ||
| 22 | + | ||
| 23 | + | ||
| 24 | + | ||
| 25 | + | ||
| 26 | + | ||
| 27 | +namespace OHOS { | ||
| 28 | +namespace DistributedHardware { | ||
| 29 | + | ||
| 30 | +namespace { | ||
| 31 | +constexpr uint32_t KEY_IS_SYNC_FRAME = 1; | ||
| 32 | +constexpr uint32_t KEY_TIME_US = 2; | ||
| 33 | +} // namespace | ||
| 34 | + | ||
| 35 | +DCameraLiteSurfaceListener::DCameraLiteSurfaceListener(OHOS::Surface *surface, DCStreamType streamType, | ||
| 36 | + const std::shared_ptr<ResultCallback>& callback) | ||
| 37 | + : surface_(surface), streamType_(streamType), callback_(callback) | ||
| 38 | +{ | ||
| 39 | +} | ||
| 40 | + | ||
| 41 | +void DCameraLiteSurfaceListener::OnBufferAvailable() | ||
| 42 | +{ | ||
| 43 | + if (surface_ == nullptr) { | ||
| 44 | + DHLOGE("DCameraLiteSurfaceListener surface is null"); | ||
| 45 | + return; | ||
| 46 | + } | ||
| 47 | + SurfaceBuffer *buffer = surface_->AcquireBuffer(); | ||
| 48 | + if (buffer == nullptr) { | ||
| 49 | + DHLOGE("DCameraLiteSurfaceListener AcquireBuffer failed"); | ||
| 50 | + return; | ||
| 51 | + } | ||
| 52 | + | ||
| 53 | + do { | ||
| 54 | + void *addr = buffer->GetVirAddr(); | ||
| 55 | + uint32_t size = buffer->GetSize(); | ||
| 56 | + if (addr == nullptr || size == 0 || size > static_cast<uint32_t>(SURFACE_BUFFER_MAX_SIZE)) { | ||
| 57 | + DHLOGE("DCameraLiteSurfaceListener invalid buffer, size: %{public}u", size); | ||
| 58 | + break; | ||
| 59 | + } | ||
| 60 | + | ||
| 61 | + std::shared_ptr<DataBuffer> dataBuffer = std::make_shared<DataBuffer>(size); | ||
| 62 | + int32_t ret = memcpy_s(dataBuffer->Data(), dataBuffer->Capacity(), addr, size); | ||
| 63 | + if (ret != EOK) { | ||
| 64 | + DHLOGE("DCameraLiteSurfaceListener memcpy_s failed, ret: %{public}d", ret); | ||
| 65 | + break; | ||
| 66 | + } | ||
| 67 | + dataBuffer->SetInt32(INDEX, index_++); | ||
| 68 | + int64_t timeUs = 0; | ||
| 69 | + if (buffer->GetInt64(KEY_TIME_US, timeUs) != 0 || timeUs <= 0) { | ||
| 70 | + timeUs = GetNowTimeStampUs(); | ||
| 71 | + } | ||
| 72 | + int32_t isSyncFrame = 0; | ||
| 73 | + if (buffer->GetInt32(KEY_IS_SYNC_FRAME, isSyncFrame) != 0) { | ||
| 74 | + isSyncFrame = 0; | ||
| 75 | + } | ||
| 76 | + dataBuffer->SetInt64(TIME_STAMP_US, timeUs); | ||
| 77 | + dataBuffer->SetInt32(FRAME_TYPE, isSyncFrame); | ||
| 78 | + | ||
| 79 | + auto callback = callback_.lock(); | ||
| 80 | + if (callback == nullptr) { | ||
| 81 | + DHLOGE("DCameraLiteSurfaceListener callback is null"); | ||
| 82 | + break; | ||
| 83 | + } | ||
| 84 | + if (streamType_ == SNAPSHOT_FRAME) { | ||
| 85 | + callback->OnPhotoResult(dataBuffer); | ||
| 86 | + } else { | ||
| 87 | + callback->OnVideoResult(dataBuffer); | ||
| 88 | + } | ||
| 89 | + } while (0); | ||
| 90 | + | ||
| 91 | + surface_->ReleaseBuffer(buffer); | ||
| 92 | +} | ||
| 93 | + | ||
| 94 | +} // namespace DistributedHardware | ||
| 95 | +} // namespace OHOS | ||
| @@ -0,0 +1,46 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) 2021-2026 Huawei Device Co., Ltd. | ||
| 3 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 4 | + * you may not use this file except in compliance with the License. | ||
| 5 | + * You may obtain a copy of the License at | ||
| 6 | + * | ||
| 7 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 8 | + * | ||
| 9 | + * Unless required by applicable law or agreed to in writing, software | ||
| 10 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 11 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 12 | + * See the License for the specific language governing permissions and | ||
| 13 | + * limitations under the License. | ||
| 14 | + */ | ||
| 15 | + | ||
| 16 | + | ||
| 17 | + | ||
| 18 | + | ||
| 19 | + | ||
| 20 | + | ||
| 21 | + | ||
| 22 | + | ||
| 23 | + | ||
| 24 | +namespace OHOS { | ||
| 25 | +namespace DistributedHardware { | ||
| 26 | + | ||
| 27 | +class DCameraLiteSurfaceListener : public IBufferConsumerListener { | ||
| 28 | +public: | ||
| 29 | + DCameraLiteSurfaceListener(OHOS::Surface *surface, DCStreamType streamType, | ||
| 30 | + const std::shared_ptr<ResultCallback>& callback); | ||
| 31 | + virtual ~DCameraLiteSurfaceListener() = default; | ||
| 32 | + | ||
| 33 | + void OnBufferAvailable() override; | ||
| 34 | + | ||
| 35 | +private: | ||
| 36 | + static constexpr int32_t SURFACE_BUFFER_MAX_SIZE = 50 * 1024 * 1024; | ||
| 37 | + | ||
| 38 | + OHOS::Surface *surface_ = nullptr; | ||
| 39 | + DCStreamType streamType_; | ||
| 40 | + std::weak_ptr<ResultCallback> callback_; | ||
| 41 | + int32_t index_ = 0; | ||
| 42 | +}; | ||
| 43 | + | ||
| 44 | +} // namespace DistributedHardware | ||
| 45 | +} // namespace OHOS | ||
| 46 | + | ||
Rservices/cameraservice/cameraoperator/client/src/callback/dcamera_input_callback.cpp→services/cameraservice/cameraoperator/client/src/standard/callback/dcamera_input_callback.cpp+0-0
文件重命名但无更改。
Rservices/cameraservice/cameraoperator/client/src/callback/dcamera_manager_callback.cpp→services/cameraservice/cameraoperator/client/src/standard/callback/dcamera_manager_callback.cpp+0-0
文件重命名但无更改。
Rservices/cameraservice/cameraoperator/client/src/callback/dcamera_photo_callback.cpp→services/cameraservice/cameraoperator/client/src/standard/callback/dcamera_photo_callback.cpp+0-0
文件重命名但无更改。
Rservices/cameraservice/cameraoperator/client/src/callback/dcamera_preview_callback.cpp→services/cameraservice/cameraoperator/client/src/standard/callback/dcamera_preview_callback.cpp+0-0
文件重命名但无更改。
Rservices/cameraservice/cameraoperator/client/src/callback/dcamera_session_callback.cpp→services/cameraservice/cameraoperator/client/src/standard/callback/dcamera_session_callback.cpp+0-0
文件重命名但无更改。
Rservices/cameraservice/cameraoperator/client/src/callback/dcamera_video_callback.cpp→services/cameraservice/cameraoperator/client/src/standard/callback/dcamera_video_callback.cpp+0-0
文件重命名但无更改。
Rservices/cameraservice/cameraoperator/client/src/dcamera_client.cpp→services/cameraservice/cameraoperator/client/src/standard/dcamera_client.cpp+0-0
文件重命名但无更改。
Rservices/cameraservice/cameraoperator/client/src/listener/dcamera_photo_surface_listener.cpp→services/cameraservice/cameraoperator/client/src/standard/listener/dcamera_photo_surface_listener.cpp+0-0
文件重命名但无更改。
| @@ -27,63 +27,68 @@ config("module_private_config") { | |||
| 27 | ] | 27 | ] |
| 28 | } | 28 | } |
| 29 | 29 | ||
| 30 | -ohos_executable("dcamera_client_demo") { | 30 | +if (!defined(ohos_lite)) { |
| 31 | - testonly = true | 31 | + ohos_executable("dcamera_client_demo") { |
| 32 | - branch_protector_ret = "pac_ret" | 32 | + testonly = true |
| 33 | - sanitize = { | 33 | + branch_protector_ret = "pac_ret" |
| 34 | - cfi = true | 34 | + sanitize = { |
| 35 | - cfi_cross_dso = true | 35 | + cfi = true |
| 36 | - debug = false | 36 | + cfi_cross_dso = true |
| 37 | + debug = false | ||
| 38 | + } | ||
| 39 | + | ||
| 40 | + install_enable = false | ||
| 41 | + | ||
| 42 | + sources = [ "main.cpp" ] | ||
| 43 | + | ||
| 44 | + configs = [ ":module_private_config" ] | ||
| 45 | + | ||
| 46 | + cflags = [ | ||
| 47 | + "-fPIC", | ||
| 48 | + "-Wall", | ||
| 49 | + ] | ||
| 50 | + | ||
| 51 | + if (!distributed_camera_common) { | ||
| 52 | + cflags += [ "-DDCAMERA_YUV" ] | ||
| 53 | + } | ||
| 54 | + | ||
| 55 | + deps = [ | ||
| 56 | + "${common_path}:distributed_camera_utils", | ||
| 57 | + "${services_path}/cameraservice/cameraoperator/client:distributed_camera_client", | ||
| 58 | + "${services_path}/cameraservice/sinkservice:distributed_camera_sink", | ||
| 59 | + ] | ||
| 60 | + | ||
| 61 | + external_deps = [ | ||
| 62 | + "access_token:libaccesstoken_sdk", | ||
| 63 | + "access_token:libnativetoken_shared", | ||
| 64 | + "access_token:libtokensetproc_shared", | ||
| 65 | + "av_codec:av_codec_client", | ||
| 66 | + "cJSON:cjson", | ||
| 67 | + "c_utils:utils", | ||
| 68 | + "camera_framework:camera_framework", | ||
| 69 | + "distributed_hardware_fwk:distributedhardwareutils", | ||
| 70 | + "drivers_interface_camera:metadata", | ||
| 71 | + "drivers_interface_distributed_camera:libdistributed_camera_provider_proxy_1.1", | ||
| 72 | + "graphic_surface:surface", | ||
| 73 | + "hilog:libhilog", | ||
| 74 | + "ipc:ipc_core", | ||
| 75 | + "media_foundation:media_foundation", | ||
| 76 | + "samgr:samgr_proxy", | ||
| 77 | + ] | ||
| 78 | + | ||
| 79 | + defines = [ | ||
| 80 | + "HI_LOG_ENABLE", | ||
| 81 | + "DH_LOG_TAG=\"DCameraClientDemo\"", | ||
| 82 | + "LOG_DOMAIN=0xD004150", | ||
| 83 | + ] | ||
| 84 | + | ||
| 85 | + cflags_cc = cflags | ||
| 86 | + | ||
| 87 | + subsystem_name = "distributedhardware" | ||
| 88 | + | ||
| 89 | + part_name = "distributed_camera" | ||
| 37 | } | 90 | } |
| 38 | - | 91 | +} else { |
| 39 | - install_enable = false | 92 | + group("dcamera_client_demo") { |
| 40 | - | ||
| 41 | - sources = [ "main.cpp" ] | ||
| 42 | - | ||
| 43 | - configs = [ ":module_private_config" ] | ||
| 44 | - | ||
| 45 | - cflags = [ | ||
| 46 | - "-fPIC", | ||
| 47 | - "-Wall", | ||
| 48 | - ] | ||
| 49 | - | ||
| 50 | - if (!distributed_camera_common) { | ||
| 51 | - cflags += [ "-DDCAMERA_YUV" ] | ||
| 52 | } | 93 | } |
| 53 | - | ||
| 54 | - deps = [ | ||
| 55 | - "${common_path}:distributed_camera_utils", | ||
| 56 | - "${services_path}/cameraservice/cameraoperator/client:distributed_camera_client", | ||
| 57 | - "${services_path}/cameraservice/sinkservice:distributed_camera_sink", | ||
| 58 | - ] | ||
| 59 | - | ||
| 60 | - external_deps = [ | ||
| 61 | - "access_token:libaccesstoken_sdk", | ||
| 62 | - "access_token:libnativetoken_shared", | ||
| 63 | - "access_token:libtokensetproc_shared", | ||
| 64 | - "av_codec:av_codec_client", | ||
| 65 | - "cJSON:cjson", | ||
| 66 | - "c_utils:utils", | ||
| 67 | - "camera_framework:camera_framework", | ||
| 68 | - "distributed_hardware_fwk:distributedhardwareutils", | ||
| 69 | - "drivers_interface_camera:metadata", | ||
| 70 | - "drivers_interface_distributed_camera:libdistributed_camera_provider_proxy_1.1", | ||
| 71 | - "graphic_surface:surface", | ||
| 72 | - "hilog:libhilog", | ||
| 73 | - "ipc:ipc_core", | ||
| 74 | - "media_foundation:media_foundation", | ||
| 75 | - "samgr:samgr_proxy", | ||
| 76 | - ] | ||
| 77 | - | ||
| 78 | - defines = [ | ||
| 79 | - "HI_LOG_ENABLE", | ||
| 80 | - "DH_LOG_TAG=\"DCameraClientDemo\"", | ||
| 81 | - "LOG_DOMAIN=0xD004150", | ||
| 82 | - ] | ||
| 83 | - | ||
| 84 | - cflags_cc = cflags | ||
| 85 | - | ||
| 86 | - subsystem_name = "distributedhardware" | ||
| 87 | - | ||
| 88 | - part_name = "distributed_camera" | ||
| 89 | } | 94 | } |
| @@ -11,7 +11,12 @@ | |||
| 11 | # See the License for the specific language governing permissions and | 11 | # See the License for the specific language governing permissions and |
| 12 | # limitations under the License. | 12 | # limitations under the License. |
| 13 | 13 | ||
| 14 | +if (!defined(ohos_lite)) { | ||
| 14 | group("camera_client_test") { | 15 | group("camera_client_test") { |
| 15 | testonly = true | 16 | testonly = true |
| 16 | deps = [ "common/cameraoperator:dcamera_client_test" ] | 17 | deps = [ "common/cameraoperator:dcamera_client_test" ] |
| 17 | } | 18 | } |
| 19 | +} else { | ||
| 20 | + group("camera_client_test") { | ||
| 21 | + } | ||
| 22 | +} | ||
| @@ -30,7 +30,7 @@ config("module_private_config") { | |||
| 30 | "${services_path}/cameraservice/cameraoperator/client/include", | 30 | "${services_path}/cameraservice/cameraoperator/client/include", |
| 31 | "${services_path}/cameraservice/cameraoperator/client/include/callback", | 31 | "${services_path}/cameraservice/cameraoperator/client/include/callback", |
| 32 | "${services_path}/cameraservice/cameraoperator/client/include/listener", | 32 | "${services_path}/cameraservice/cameraoperator/client/include/listener", |
| 33 | - "${services_path}/cameraservice/cameraoperator/handler/include", | 33 | + "${services_path}/cameraservice/cameraoperator/handler/include/standard", |
| 34 | ] | 34 | ] |
| 35 | } | 35 | } |
| 36 | 36 | ||
| @@ -18,7 +18,8 @@ import( | |||
| 18 | 18 | ||
| 19 | ohos_shared_library("distributed_camera_handler") { | 19 | ohos_shared_library("distributed_camera_handler") { |
| 20 | branch_protector_ret = "pac_ret" | 20 | branch_protector_ret = "pac_ret" |
| 21 | - sanitize = { | 21 | + if (!defined(ohos_lite)) { |
| 22 | + sanitize = { | ||
| 22 | cfi = true | 23 | cfi = true |
| 23 | cfi_cross_dso = true | 24 | cfi_cross_dso = true |
| 24 | debug = false | 25 | debug = false |
| @@ -26,19 +27,35 @@ ohos_shared_library("distributed_camera_handler") { | |||
| 26 | integer_overflow = true | 27 | integer_overflow = true |
| 27 | ubsan = true | 28 | ubsan = true |
| 28 | } | 29 | } |
| 30 | + } | ||
| 29 | stack_protector_ret = true | 31 | stack_protector_ret = true |
| 30 | 32 | ||
| 31 | - include_dirs = [ | 33 | + if (defined(ohos_lite)) { |
| 32 | - "include", | 34 | + include_dirs = [ |
| 33 | - "${common_path}/include/constants", | 35 | + "include/lite", |
| 34 | - "${common_path}/include/utils", | 36 | + "${common_path}/include/constants", |
| 35 | - "${services_path}/cameraservice/cameraoperator/client/include/callback", | 37 | + "${common_path}/include/utils", |
| 36 | - ] | 38 | + "//foundation/multimedia/camera_lite/frameworks", |
| 37 | - | 39 | + "//foundation/multimedia/camera_lite/services/impl/include", |
| 38 | - sources = [ | 40 | + "//foundation/multimedia/media_utils_lite/interfaces/kits", |
| 39 | - "${services_path}/cameraservice/cameraoperator/client/src/callback/dcamera_manager_callback.cpp", | 41 | + "//foundation/graphic/graphic_utils_lite/interfaces/kits", |
| 40 | - "src/dcamera_handler.cpp", | 42 | + "//third_party/cJSON", |
| 41 | - ] | 43 | + ] |
| 44 | + sources = [ | ||
| 45 | + "src/dcamera_handler/lite/dcamera_handler.cpp", | ||
| 46 | + ] | ||
| 47 | + } else { | ||
| 48 | + include_dirs = [ | ||
| 49 | + "include/standard", | ||
| 50 | + "${common_path}/include/constants", | ||
| 51 | + "${common_path}/include/utils", | ||
| 52 | + "${services_path}/cameraservice/cameraoperator/client/include/callback", | ||
| 53 | + ] | ||
| 54 | + sources = [ | ||
| 55 | + "${services_path}/cameraservice/cameraoperator/client/src/standard/callback/dcamera_manager_callback.cpp", | ||
| 56 | + "src/dcamera_handler/standard/dcamera_handler.cpp", | ||
| 57 | + ] | ||
| 58 | + } | ||
| 42 | 59 | ||
| 43 | ldflags = [ | 60 | ldflags = [ |
| 44 | "-fpie", | 61 | "-fpie", |
| @@ -54,6 +71,10 @@ ohos_shared_library("distributed_camera_handler") { | |||
| 54 | "LOG_DOMAIN=0xD004150", | 71 | "LOG_DOMAIN=0xD004150", |
| 55 | ] | 72 | ] |
| 56 | 73 | ||
| 74 | + if (defined(ohos_lite)) { | ||
| 75 | + defines += [ "OHOS_LITE" ] | ||
| 76 | + } | ||
| 77 | + | ||
| 57 | cflags = [] | 78 | cflags = [] |
| 58 | 79 | ||
| 59 | if (distributed_camera_filter_front) { | 80 | if (distributed_camera_filter_front) { |
| @@ -64,21 +85,33 @@ ohos_shared_library("distributed_camera_handler") { | |||
| 64 | cflags += [ "-DDCAMERA_OPEN_STABILE" ] | 85 | cflags += [ "-DDCAMERA_OPEN_STABILE" ] |
| 65 | } | 86 | } |
| 66 | 87 | ||
| 67 | - external_deps = [ | 88 | + if (defined(ohos_lite)) { |
| 68 | - "av_codec:av_codec_client", | 89 | + external_deps = [ |
| 69 | - "cJSON:cjson", | 90 | + "cJSON:cjson", |
| 70 | - "c_utils:utils", | 91 | + "distributed_hardware_fwk:distributedhardwareutils", |
| 71 | - "camera_framework:camera_framework", | 92 | + "hilog_lite:hilog_shared", |
| 72 | - "distributed_hardware_fwk:distributedhardwareutils", | 93 | + ] |
| 73 | - "drivers_interface_camera:metadata", | 94 | + deps += [ |
| 74 | - "drivers_interface_distributed_camera:libdistributed_camera_provider_proxy_1.1", | 95 | + "//foundation/multimedia/camera_lite/frameworks:camera_lite", |
| 75 | - "graphic_surface:surface", | 96 | + "//foundation/multimedia/camera_lite/services:camera_service_impl", |
| 76 | - "hdf_core:libhdf_utils", | 97 | + ] |
| 77 | - "hilog:libhilog", | 98 | + } else { |
| 78 | - "ipc:ipc_core", | 99 | + external_deps = [ |
| 79 | - "media_foundation:media_foundation", | 100 | + "av_codec:av_codec_client", |
| 80 | - "samgr:samgr_proxy", | 101 | + "cJSON:cjson", |
| 81 | - ] | 102 | + "c_utils:utils", |
| 103 | + "camera_framework:camera_framework", | ||
| 104 | + "distributed_hardware_fwk:distributedhardwareutils", | ||
| 105 | + "drivers_interface_camera:metadata", | ||
| 106 | + "drivers_interface_distributed_camera:libdistributed_camera_provider_proxy_1.1", | ||
| 107 | + "graphic_surface:surface", | ||
| 108 | + "hdf_core:libhdf_utils", | ||
| 109 | + "hilog:libhilog", | ||
| 110 | + "ipc:ipc_core", | ||
| 111 | + "media_foundation:media_foundation", | ||
| 112 | + "samgr:samgr_proxy", | ||
| 113 | + ] | ||
| 114 | + } | ||
| 82 | 115 | ||
| 83 | subsystem_name = "distributedhardware" | 116 | subsystem_name = "distributedhardware" |
| 84 | 117 | ||
| @@ -0,0 +1,79 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) 2021-2025 Huawei Device Co., Ltd. | ||
| 3 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 4 | + * you may not use this file except in compliance with the License. | ||
| 5 | + * You may obtain a copy of the License at | ||
| 6 | + * | ||
| 7 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 8 | + * | ||
| 9 | + * Unless required by applicable law or agreed to in writing, software | ||
| 10 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 11 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 12 | + * See the License for the specific language governing permissions and | ||
| 13 | + * limitations under the License. | ||
| 14 | + */ | ||
| 15 | + | ||
| 16 | + | ||
| 17 | + | ||
| 18 | + | ||
| 19 | + | ||
| 20 | + | ||
| 21 | + | ||
| 22 | + | ||
| 23 | + | ||
| 24 | + | ||
| 25 | + | ||
| 26 | + | ||
| 27 | + | ||
| 28 | + | ||
| 29 | + | ||
| 30 | + | ||
| 31 | + | ||
| 32 | + | ||
| 33 | +namespace OHOS { | ||
| 34 | +namespace Media { | ||
| 35 | +class CameraService; | ||
| 36 | +} | ||
| 37 | +namespace DistributedHardware { | ||
| 38 | + | ||
| 39 | +using namespace OHOS::HDI::DistributedCamera::V1_1; | ||
| 40 | + | ||
| 41 | + | ||
| 42 | +class DCameraHandler : public IHardwareHandler { | ||
| 43 | +FWK_DECLARE_SINGLE_INSTANCE_BASE(DCameraHandler); | ||
| 44 | +public: | ||
| 45 | + int32_t Initialize() override; | ||
| 46 | + std::vector<DHItem> QueryMeta() override; | ||
| 47 | + std::vector<DHItem> Query() override; | ||
| 48 | + std::map<std::string, std::string> QueryExtraInfo() override; | ||
| 49 | + bool IsSupportPlugin() override; | ||
| 50 | + void RegisterPluginListener(std::shared_ptr<PluginListener> listener) override; | ||
| 51 | + void UnRegisterPluginListener() override; | ||
| 52 | + | ||
| 53 | + std::vector<std::string> GetCameras(); | ||
| 54 | + | ||
| 55 | +private: | ||
| 56 | + DCameraHandler() = default; | ||
| 57 | + ~DCameraHandler(); | ||
| 58 | + | ||
| 59 | + std::string GetCameraPosition(OHOS::Media::FacingType facingType); | ||
| 60 | + void AddCodecType(cJSON *root); | ||
| 61 | + void AddFormatNode(cJSON *root, const std::string &nodeName, int dcFormat, | ||
| 62 | + const std::list<CameraPicSize> &sizes); | ||
| 63 | + int32_t CreateDHItem(const std::string &cameraId, | ||
| 64 | + const OHOS::Media::CameraAbility *ability, const OHOS::Media::CameraInfo *cameraInfo, DHItem &item); | ||
| 65 | + | ||
| 66 | + OHOS::Media::CameraService *cameraService_ = nullptr; | ||
| 67 | + std::shared_ptr<PluginListener> pluginListener_; | ||
| 68 | +}; | ||
| 69 | + | ||
| 70 | + | ||
| 71 | +extern "C" { | ||
| 72 | + | ||
| 73 | +__attribute__((visibility("default"))) IHardwareHandler* GetHardwareHandler(); | ||
| 74 | + | ||
| 75 | +} | ||
| 76 | + | ||
| 77 | +} // namespace DistributedHardware | ||
| 78 | +} // namespace OHOS | ||
| 79 | + | ||
Rservices/cameraservice/cameraoperator/handler/include/dcamera_handler.h→services/cameraservice/cameraoperator/handler/include/standard/dcamera_handler.h+0-0
文件重命名但无更改。
| @@ -0,0 +1,304 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) 2021-2025 Huawei Device Co., Ltd. | ||
| 3 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 4 | + * you may not use this file except in compliance with the License. | ||
| 5 | + * You may obtain a copy of the License at | ||
| 6 | + * | ||
| 7 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 8 | + * | ||
| 9 | + * Unless required by applicable law or agreed to in writing, software | ||
| 10 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 11 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 12 | + * See the License for the specific language governing permissions and | ||
| 13 | + * limitations under the License. | ||
| 14 | + */ | ||
| 15 | + | ||
| 16 | + | ||
| 17 | + | ||
| 18 | + | ||
| 19 | + | ||
| 20 | + | ||
| 21 | + | ||
| 22 | + | ||
| 23 | + | ||
| 24 | + | ||
| 25 | +namespace OHOS { | ||
| 26 | +namespace DistributedHardware { | ||
| 27 | +FWK_IMPLEMENT_SINGLE_INSTANCE(DCameraHandler); | ||
| 28 | + | ||
| 29 | +namespace { | ||
| 30 | + // camera_lite 内部格式枚举 | ||
| 31 | + constexpr int LITE_FORMAT_YVU420 = 0; | ||
| 32 | + constexpr int LITE_FORMAT_JPEG = 1; | ||
| 33 | + constexpr int LITE_FORMAT_H264 = 2; | ||
| 34 | + | ||
| 35 | + // HDI/source 侧 camera_format_t 枚举值(OHOS_CAMERA_FORMAT_*) | ||
| 36 | + constexpr int DCAMERA_FORMAT_YCRCB_420_SP = 3; // NV21 | ||
| 37 | + constexpr int DCAMERA_FORMAT_JPEG = 5; | ||
| 38 | + | ||
| 39 | + constexpr int DEFAULT_FPS = 30; | ||
| 40 | +} | ||
| 41 | + | ||
| 42 | +DCameraHandler::~DCameraHandler() | ||
| 43 | +{ | ||
| 44 | + DHLOGI("~DCameraHandler lite"); | ||
| 45 | +} | ||
| 46 | + | ||
| 47 | +int32_t DCameraHandler::Initialize() | ||
| 48 | +{ | ||
| 49 | + DHLOGI("lite handler initialize start"); | ||
| 50 | + DHLOGI("lite handler about to call CameraService::GetInstance()"); | ||
| 51 | + cameraService_ = OHOS::Media::CameraService::GetInstance(); | ||
| 52 | + DHLOGI("lite handler CameraService::GetInstance() returned, service=%{public}p", cameraService_); | ||
| 53 | + if (cameraService_ == nullptr) { | ||
| 54 | + DHLOGE("cameraService getInstance failed"); | ||
| 55 | + return DCAMERA_INIT_ERR; | ||
| 56 | + } | ||
| 57 | + cameraService_->Initialize(); | ||
| 58 | + DHLOGI("lite handler initialize success"); | ||
| 59 | + return DCAMERA_OK; | ||
| 60 | +} | ||
| 61 | + | ||
| 62 | +std::vector<DHItem> DCameraHandler::QueryMeta() | ||
| 63 | +{ | ||
| 64 | + DHLOGI("lite handler QueryMeta"); | ||
| 65 | + return Query(); | ||
| 66 | +} | ||
| 67 | + | ||
| 68 | +std::vector<DHItem> DCameraHandler::Query() | ||
| 69 | +{ | ||
| 70 | + std::vector<DHItem> itemList; | ||
| 71 | + CHECK_AND_RETURN_RET_LOG(cameraService_ == nullptr, itemList, "cameraService is null."); | ||
| 72 | + | ||
| 73 | + std::list<std::string> cameraIds = cameraService_->GetCameraIdList(); | ||
| 74 | + DHLOGI("lite handler get %{public}zu cameras", cameraIds.size()); | ||
| 75 | + if (cameraIds.empty()) { | ||
| 76 | + DHLOGE("lite handler no camera device"); | ||
| 77 | + return itemList; | ||
| 78 | + } | ||
| 79 | + | ||
| 80 | + for (auto &cameraId : cameraIds) { | ||
| 81 | + DHLOGI("lite handler process camera id: %{public}s", GetAnonyString(cameraId).c_str()); | ||
| 82 | + | ||
| 83 | + std::string cameraIdStr = cameraId; | ||
| 84 | + const OHOS::Media::CameraAbility *ability = cameraService_->GetCameraAbility(cameraIdStr); | ||
| 85 | + if (ability == nullptr) { | ||
| 86 | + DHLOGE("lite handler get camera ability failed, id: %{public}s", GetAnonyString(cameraId).c_str()); | ||
| 87 | + continue; | ||
| 88 | + } | ||
| 89 | + | ||
| 90 | + const OHOS::Media::CameraInfo *cameraInfo = cameraService_->GetCameraInfo(cameraIdStr); | ||
| 91 | + if (cameraInfo == nullptr) { | ||
| 92 | + DHLOGE("lite handler get camera info failed, id: %{public}s", GetAnonyString(cameraId).c_str()); | ||
| 93 | + continue; | ||
| 94 | + } | ||
| 95 | + | ||
| 96 | + int32_t cameraType = cameraInfo->GetCameraType(); | ||
| 97 | + if (cameraType != OHOS::Media::WIDE_ANGLE) { | ||
| 98 | + DHLOGI("lite handler skip camera id: %{public}s, type: %{public}d", GetAnonyString(cameraId).c_str(), cameraType); | ||
| 99 | + continue; | ||
| 100 | + } | ||
| 101 | + | ||
| 102 | + DHItem item; | ||
| 103 | + if (CreateDHItem(cameraId, ability, cameraInfo, item) == DCAMERA_OK) { | ||
| 104 | + itemList.emplace_back(item); | ||
| 105 | + } | ||
| 106 | + } | ||
| 107 | + DHLOGI("lite handler success, get %{public}zu items", itemList.size()); | ||
| 108 | + return itemList; | ||
| 109 | +} | ||
| 110 | + | ||
| 111 | +std::map<std::string, std::string> DCameraHandler::QueryExtraInfo() | ||
| 112 | +{ | ||
| 113 | + DHLOGI("lite handler QueryExtraInfo"); | ||
| 114 | + return {}; | ||
| 115 | +} | ||
| 116 | + | ||
| 117 | +bool DCameraHandler::IsSupportPlugin() | ||
| 118 | +{ | ||
| 119 | + DHLOGI("lite handler IsSupportPlugin"); | ||
| 120 | + return false; | ||
| 121 | +} | ||
| 122 | + | ||
| 123 | +void DCameraHandler::RegisterPluginListener(std::shared_ptr<PluginListener> listener) | ||
| 124 | +{ | ||
| 125 | + DHLOGI("lite handler RegisterPluginListener"); | ||
| 126 | + if (listener == nullptr) { | ||
| 127 | + DHLOGE("DCameraHandler unregistering plugin listener"); | ||
| 128 | + } | ||
| 129 | + pluginListener_ = listener; | ||
| 130 | +} | ||
| 131 | + | ||
| 132 | +void DCameraHandler::UnRegisterPluginListener() | ||
| 133 | +{ | ||
| 134 | + DHLOGI("lite handler UnRegisterPluginListener"); | ||
| 135 | + pluginListener_ = nullptr; | ||
| 136 | +} | ||
| 137 | + | ||
| 138 | +std::vector<std::string> DCameraHandler::GetCameras() | ||
| 139 | +{ | ||
| 140 | + std::vector<std::string> cameras; | ||
| 141 | + CHECK_AND_RETURN_RET_LOG(cameraService_ == nullptr, cameras, "cameraService is null."); | ||
| 142 | + | ||
| 143 | + std::list<std::string> cameraIds = cameraService_->GetCameraIdList(); | ||
| 144 | + DHLOGI("lite handler GetCameras get %{public}zu cameras", cameraIds.size()); | ||
| 145 | + for (auto &cameraId : cameraIds) { | ||
| 146 | + std::string cameraIdStr = cameraId; | ||
| 147 | + const OHOS::Media::CameraAbility *ability = cameraService_->GetCameraAbility(cameraIdStr); | ||
| 148 | + if (ability == nullptr) { | ||
| 149 | + DHLOGE("lite handler GetCameras get camera ability failed, id: %{public}s", | ||
| 150 | + GetAnonyString(cameraId).c_str()); | ||
| 151 | + continue; | ||
| 152 | + } | ||
| 153 | + | ||
| 154 | + const OHOS::Media::CameraInfo *cameraInfo = cameraService_->GetCameraInfo(cameraIdStr); | ||
| 155 | + if (cameraInfo == nullptr) { | ||
| 156 | + DHLOGE("lite handler GetCameras get camera info failed, id: %{public}s", | ||
| 157 | + GetAnonyString(cameraId).c_str()); | ||
| 158 | + continue; | ||
| 159 | + } | ||
| 160 | + | ||
| 161 | + int32_t cameraType = cameraInfo->GetCameraType(); | ||
| 162 | + if (cameraType != OHOS::Media::WIDE_ANGLE) { | ||
| 163 | + DHLOGI("lite handler GetCameras skip camera id: %{public}s, type: %{public}d", | ||
| 164 | + GetAnonyString(cameraId).c_str(), cameraType); | ||
| 165 | + continue; | ||
| 166 | + } | ||
| 167 | + | ||
| 168 | + cameras.emplace_back(CAMERA_ID_PREFIX + cameraId); | ||
| 169 | + } | ||
| 170 | + DHLOGI("lite handler GetCameras get camera success, get %{public}zu items", | ||
| 171 | + cameraIds.size()); | ||
| 172 | + return cameras; | ||
| 173 | +} | ||
| 174 | + | ||
| 175 | +std::string DCameraHandler::GetCameraPosition(OHOS::Media::FacingType facingType) | ||
| 176 | +{ | ||
| 177 | + switch (facingType) { | ||
| 178 | + case OHOS::Media::CAMERA_FACING_BACK: | ||
| 179 | + return CAMERA_POSITION_BACK; | ||
| 180 | + case OHOS::Media::CAMERA_FACING_FRONT: | ||
| 181 | + return CAMERA_POSITION_FRONT; | ||
| 182 | + case OHOS::Media::CAMERA_FACING_OTHERS: | ||
| 183 | + default: | ||
| 184 | + return CAMERA_POSITION_UNSPECIFIED; | ||
| 185 | + } | ||
| 186 | +} | ||
| 187 | + | ||
| 188 | +void DCameraHandler::AddCodecType(cJSON *root) | ||
| 189 | +{ | ||
| 190 | + cJSON *array = cJSON_CreateArray(); | ||
| 191 | + if (array == nullptr) { | ||
| 192 | + return; | ||
| 193 | + } | ||
| 194 | + cJSON_AddItemToArray(array, cJSON_CreateString("video/avc")); | ||
| 195 | + cJSON_AddItemToObject(root, CAMERA_CODEC_TYPE_KEY.c_str(), array); | ||
| 196 | +} | ||
| 197 | + | ||
| 198 | +void DCameraHandler::AddFormatNode(cJSON *root, const std::string &nodeName, int dcFormat, | ||
| 199 | + const std::list<CameraPicSize> &sizes) | ||
| 200 | +{ | ||
| 201 | + cJSON *nodeObj = cJSON_CreateObject(); | ||
| 202 | + if (nodeObj == nullptr) { | ||
| 203 | + return; | ||
| 204 | + } | ||
| 205 | + cJSON_AddItemToObject(root, nodeName.c_str(), nodeObj); | ||
| 206 | + | ||
| 207 | + // OutputFormat | ||
| 208 | + cJSON *formatArray = cJSON_CreateArray(); | ||
| 209 | + if (formatArray != nullptr) { | ||
| 210 | + cJSON_AddItemToArray(formatArray, cJSON_CreateNumber(dcFormat)); | ||
| 211 | + cJSON_AddItemToObject(nodeObj, CAMERA_FORMAT_KEY.c_str(), formatArray); | ||
| 212 | + } | ||
| 213 | + | ||
| 214 | + std::string formatStr = std::to_string(dcFormat); | ||
| 215 | + | ||
| 216 | + // Resolution | ||
| 217 | + cJSON *resolutionObj = cJSON_CreateObject(); | ||
| 218 | + if (resolutionObj != nullptr) { | ||
| 219 | + cJSON *sizeArray = cJSON_CreateArray(); | ||
| 220 | + for (auto &size : sizes) { | ||
| 221 | + std::string reso = std::to_string(size.width) + "*" + std::to_string(size.height); | ||
| 222 | + cJSON_AddItemToArray(sizeArray, cJSON_CreateString(reso.c_str())); | ||
| 223 | + } | ||
| 224 | + cJSON_AddItemToObject(resolutionObj, formatStr.c_str(), sizeArray); | ||
| 225 | + cJSON_AddItemToObject(nodeObj, CAMERA_RESOLUTION_KEY.c_str(), resolutionObj); | ||
| 226 | + } | ||
| 227 | + | ||
| 228 | + // Fps,camera_lite 无 Fps API,固定写 30 30 30 | ||
| 229 | + cJSON *fpsObj = cJSON_CreateObject(); | ||
| 230 | + if (fpsObj != nullptr) { | ||
| 231 | + cJSON *fpsArray = cJSON_CreateArray(); | ||
| 232 | + std::string fps = std::to_string(DEFAULT_FPS) + " " + | ||
| 233 | + std::to_string(DEFAULT_FPS) + " " + std::to_string(DEFAULT_FPS); | ||
| 234 | + for (size_t i = 0; i < sizes.size(); ++i) { | ||
| 235 | + cJSON_AddItemToArray(fpsArray, cJSON_CreateString(fps.c_str())); | ||
| 236 | + } | ||
| 237 | + cJSON_AddItemToObject(fpsObj, formatStr.c_str(), fpsArray); | ||
| 238 | + cJSON_AddItemToObject(nodeObj, CAMERA_FPS_KEY.c_str(), fpsObj); | ||
| 239 | + } | ||
| 240 | +} | ||
| 241 | + | ||
| 242 | +int32_t DCameraHandler::CreateDHItem(const std::string &cameraId, | ||
| 243 | + const OHOS::Media::CameraAbility *ability, const OHOS::Media::CameraInfo *cameraInfo, DHItem &item) | ||
| 244 | +{ | ||
| 245 | + item.dhId = CAMERA_ID_PREFIX + cameraId; | ||
| 246 | + item.subtype = "camera"; | ||
| 247 | + DHLOGI("lite handler create dh item, camera id: %{public}s", GetAnonyString(cameraId).c_str()); | ||
| 248 | + | ||
| 249 | + cJSON *root = cJSON_CreateObject(); | ||
| 250 | + CHECK_AND_RETURN_RET_LOG(root == nullptr, DCAMERA_BAD_VALUE, "Create cJSON object failed"); | ||
| 251 | + | ||
| 252 | + // ProtocolVer | ||
| 253 | + cJSON_AddStringToObject(root, CAMERA_PROTOCOL_VERSION_KEY.c_str(), CAMERA_PROTOCOL_VERSION_VALUE.c_str()); | ||
| 254 | + | ||
| 255 | + // Position | ||
| 256 | + std::string position = CAMERA_POSITION_UNSPECIFIED; | ||
| 257 | + if (cameraInfo != nullptr) { | ||
| 258 | + position = GetCameraPosition(static_cast<OHOS::Media::FacingType>(cameraInfo->GetCameraFacingType())); | ||
| 259 | + } | ||
| 260 | + cJSON_AddStringToObject(root, CAMERA_POSITION_KEY.c_str(), position.c_str()); | ||
| 261 | + | ||
| 262 | + // CodecType | ||
| 263 | + AddCodecType(root); | ||
| 264 | + | ||
| 265 | + // Photo / Preview / Video | ||
| 266 | + if (ability == nullptr) { | ||
| 267 | + DHLOGE("lite handler camera ability is null, id: %{public}s", GetAnonyString(cameraId).c_str()); | ||
| 268 | + cJSON_Delete(root); | ||
| 269 | + return DCAMERA_BAD_VALUE; | ||
| 270 | + } | ||
| 271 | + | ||
| 272 | + std::list<CameraPicSize> jpegSizes = ability->GetSupportedSizes(LITE_FORMAT_JPEG); | ||
| 273 | + AddFormatNode(root, CAMERA_FORMAT_PHOTO, DCAMERA_FORMAT_JPEG, jpegSizes); | ||
| 274 | + | ||
| 275 | + std::list<CameraPicSize> yuvSizes = ability->GetSupportedSizes(LITE_FORMAT_YVU420); | ||
| 276 | + AddFormatNode(root, CAMERA_FORMAT_PREVIEW, DCAMERA_FORMAT_YCRCB_420_SP, yuvSizes); | ||
| 277 | + | ||
| 278 | + // Video 分辨率使用 H264 能力(用户 B 方案),格式值仍用 YUV420(H264 不是 HDI 像素格式) | ||
| 279 | + std::list<CameraPicSize> h264Sizes = ability->GetSupportedSizes(LITE_FORMAT_H264); | ||
| 280 | + AddFormatNode(root, CAMERA_FORMAT_VIDEO, DCAMERA_FORMAT_YCRCB_420_SP, h264Sizes); | ||
| 281 | + | ||
| 282 | + // MetaData:先写空字符串,后续从标准设备抓真实 base64 | ||
| 283 | + cJSON_AddStringToObject(root, CAMERA_METADATA_KEY.c_str(), ""); | ||
| 284 | + | ||
| 285 | + char *jsonstr = cJSON_Print(root); | ||
| 286 | + if (jsonstr == nullptr) { | ||
| 287 | + cJSON_Delete(root); | ||
| 288 | + return DCAMERA_BAD_VALUE; | ||
| 289 | + } | ||
| 290 | + // print jsonstr | ||
| 291 | + DHLOGE("zmx attrs, json: %{public}s", jsonstr); | ||
| 292 | + item.attrs = jsonstr; | ||
| 293 | + cJSON_free(jsonstr); | ||
| 294 | + cJSON_Delete(root); | ||
| 295 | + return DCAMERA_OK; | ||
| 296 | +} | ||
| 297 | + | ||
| 298 | +IHardwareHandler* GetHardwareHandler() | ||
| 299 | +{ | ||
| 300 | + DHLOGI("DCameraHandler::GetHardwareHandler lite"); | ||
| 301 | + return &DCameraHandler::GetInstance(); | ||
| 302 | +} | ||
| 303 | +} // namespace DistributedHardware | ||
| 304 | +} // namespace OHOS | ||
Rservices/cameraservice/cameraoperator/handler/src/dcamera_handler.cpp→services/cameraservice/cameraoperator/handler/src/dcamera_handler/standard/dcamera_handler.cpp+0-0
文件重命名但无更改。
| @@ -11,7 +11,12 @@ | |||
| 11 | # See the License for the specific language governing permissions and | 11 | # See the License for the specific language governing permissions and |
| 12 | # limitations under the License. | 12 | # limitations under the License. |
| 13 | 13 | ||
| 14 | +if (!defined(ohos_lite)) { | ||
| 14 | group("camera_handler_test") { | 15 | group("camera_handler_test") { |
| 15 | testonly = true | 16 | testonly = true |
| 16 | deps = [ "common/dcamerahandler:dcamera_handler_test" ] | 17 | deps = [ "common/dcamerahandler:dcamera_handler_test" ] |
| 17 | } | 18 | } |
| 19 | +} else { | ||
| 20 | + group("camera_handler_test") { | ||
| 21 | + } | ||
| 22 | +} | ||
| @@ -25,7 +25,7 @@ config("module_private_config") { | |||
| 25 | "${common_path}/include/utils", | 25 | "${common_path}/include/utils", |
| 26 | "${services_path}/cameraservice/base/include", | 26 | "${services_path}/cameraservice/base/include", |
| 27 | "${services_path}/cameraservice/cameraoperator/client/include/callback", | 27 | "${services_path}/cameraservice/cameraoperator/client/include/callback", |
| 28 | - "${services_path}/cameraservice/cameraoperator/handler/include", | 28 | + "${services_path}/cameraservice/cameraoperator/handler/include/standard", |
| 29 | ] | 29 | ] |
| 30 | } | 30 | } |
| 31 | 31 | ||
| @@ -16,18 +16,7 @@ import("//build/ohos_var.gni") | |||
| 16 | import( | 16 | import( |
| 17 | "//foundation/distributedhardware/distributed_camera/distributedcamera.gni") | 17 | "//foundation/distributedhardware/distributed_camera/distributedcamera.gni") |
| 18 | 18 | ||
| 19 | -ohos_shared_library("distributed_camera_sink") { | 19 | +config("distributed_camera_sink_public_config") { |
| 20 | - branch_protector_ret = "pac_ret" | ||
| 21 | - sanitize = { | ||
| 22 | - cfi = true | ||
| 23 | - cfi_cross_dso = true | ||
| 24 | - debug = false | ||
| 25 | - boundary_sanitize = true | ||
| 26 | - integer_overflow = true | ||
| 27 | - ubsan = true | ||
| 28 | - } | ||
| 29 | - stack_protector_ret = true | ||
| 30 | - | ||
| 31 | include_dirs = [ | 20 | include_dirs = [ |
| 32 | "include/distributedcamera", | 21 | "include/distributedcamera", |
| 33 | "include/distributedcameramgr", | 22 | "include/distributedcameramgr", |
| @@ -37,15 +26,9 @@ ohos_shared_library("distributed_camera_sink") { | |||
| 37 | "include/distributedcameramgr/listener", | 26 | "include/distributedcameramgr/listener", |
| 38 | "${common_path}/include/constants", | 27 | "${common_path}/include/constants", |
| 39 | "${common_path}/include/utils", | 28 | "${common_path}/include/utils", |
| 40 | - "${innerkits_path}/native_cpp/camera_sink/include", | ||
| 41 | - "${innerkits_path}/native_cpp/camera_sink/include/callback", | ||
| 42 | "${innerkits_path}/native_cpp/camera_source/include", | 29 | "${innerkits_path}/native_cpp/camera_source/include", |
| 43 | "${innerkits_path}/native_cpp/camera_source/include/callback", | 30 | "${innerkits_path}/native_cpp/camera_source/include/callback", |
| 44 | "${services_path}/cameraservice/base/include", | 31 | "${services_path}/cameraservice/base/include", |
| 45 | - "${services_path}/cameraservice/cameraoperator/client/include", | ||
| 46 | - "${services_path}/cameraservice/cameraoperator/client/include/callback", | ||
| 47 | - "${services_path}/cameraservice/cameraoperator/client/include/listener", | ||
| 48 | - "${services_path}/cameraservice/cameraoperator/handler/include", | ||
| 49 | "${services_path}/channel/include", | 32 | "${services_path}/channel/include", |
| 50 | "${services_path}/channel/include/allconnect", | 33 | "${services_path}/channel/include/allconnect", |
| 51 | "${services_path}/data_process/include/eventbus", | 34 | "${services_path}/data_process/include/eventbus", |
| @@ -57,31 +40,98 @@ ohos_shared_library("distributed_camera_sink") { | |||
| 57 | "${feeding_smoother_path}/utils", | 40 | "${feeding_smoother_path}/utils", |
| 58 | ] | 41 | ] |
| 59 | 42 | ||
| 60 | - sources = [ | 43 | + if (defined(ohos_lite)) { |
| 61 | - "${innerkits_path}/native_cpp/camera_source/src/distributed_camera_source_proxy.cpp", | 44 | + include_dirs += [ |
| 45 | + "include/distributedcameramgr/lite", | ||
| 46 | + "${innerkits_path}/native_cpp/camera_sink/include/lite", | ||
| 47 | + "${innerkits_path}/native_cpp/camera_sink/include/lite/callback", | ||
| 48 | + "${services_path}/cameraservice/cameraoperator/client/include", | ||
| 49 | + "${services_path}/cameraservice/cameraoperator/client/include/lite", | ||
| 50 | + "${services_path}/cameraservice/cameraoperator/handler/include/lite", | ||
| 51 | + "//third_party/cJSON", | ||
| 52 | + "//foundation/multimedia/camera_lite/frameworks", | ||
| 53 | + "//foundation/multimedia/camera_lite/services/impl/include", | ||
| 54 | + "//foundation/multimedia/camera_lite/interfaces/kits", | ||
| 55 | + "//foundation/multimedia/media_utils_lite/interfaces/kits", | ||
| 56 | + "//foundation/graphic/surface_lite/interfaces/kits", | ||
| 57 | + "//foundation/graphic/graphic_utils_lite/interfaces/kits", | ||
| 58 | + "//drivers/peripheral/codec/interfaces/include", | ||
| 59 | + "//drivers/peripheral/display/interfaces/include", | ||
| 60 | + "//drivers/peripheral/base", | ||
| 61 | + "//commonlibrary/c_utils/base/include", | ||
| 62 | + "//foundation/distributedhardware/device_manager/interfaces/inner_kits/native_cpp/include", | ||
| 63 | + ] | ||
| 64 | + } else { | ||
| 65 | + include_dirs += [ | ||
| 66 | + "${innerkits_path}/native_cpp/camera_sink/include/standard", | ||
| 67 | + "${innerkits_path}/native_cpp/camera_sink/include/standard/callback", | ||
| 68 | + "${services_path}/cameraservice/cameraoperator/client/include", | ||
| 69 | + "${services_path}/cameraservice/cameraoperator/client/include/standard", | ||
| 70 | + "${services_path}/cameraservice/cameraoperator/client/include/callback", | ||
| 71 | + "${services_path}/cameraservice/cameraoperator/client/include/listener", | ||
| 72 | + "${services_path}/cameraservice/cameraoperator/handler/include/standard", | ||
| 73 | + ] | ||
| 74 | + } | ||
| 75 | +} | ||
| 76 | + | ||
| 77 | +ohos_shared_library("distributed_camera_sink") { | ||
| 78 | + branch_protector_ret = "pac_ret" | ||
| 79 | + if (!defined(ohos_lite)) { | ||
| 80 | + sanitize = { | ||
| 81 | + cfi = true | ||
| 82 | + cfi_cross_dso = true | ||
| 83 | + debug = false | ||
| 84 | + boundary_sanitize = true | ||
| 85 | + integer_overflow = true | ||
| 86 | + ubsan = true | ||
| 87 | + } | ||
| 88 | + } | ||
| 89 | + stack_protector_ret = true | ||
| 90 | + | ||
| 91 | + public_configs = [ ":distributed_camera_sink_public_config" ] | ||
| 92 | + | ||
| 93 | + common_sources = [ | ||
| 62 | "${services_path}/cameraservice/base/src/dcamera_capture_info_cmd.cpp", | 94 | "${services_path}/cameraservice/base/src/dcamera_capture_info_cmd.cpp", |
| 63 | "${services_path}/cameraservice/base/src/dcamera_channel_info_cmd.cpp", | 95 | "${services_path}/cameraservice/base/src/dcamera_channel_info_cmd.cpp", |
| 64 | "${services_path}/cameraservice/base/src/dcamera_event_cmd.cpp", | 96 | "${services_path}/cameraservice/base/src/dcamera_event_cmd.cpp", |
| 65 | "${services_path}/cameraservice/base/src/dcamera_info_cmd.cpp", | 97 | "${services_path}/cameraservice/base/src/dcamera_info_cmd.cpp", |
| 66 | "${services_path}/cameraservice/base/src/dcamera_metadata_setting_cmd.cpp", | 98 | "${services_path}/cameraservice/base/src/dcamera_metadata_setting_cmd.cpp", |
| 67 | "${services_path}/cameraservice/base/src/dcamera_open_info_cmd.cpp", | 99 | "${services_path}/cameraservice/base/src/dcamera_open_info_cmd.cpp", |
| 68 | - "src/distributedcamera/dcamera_sink_callback_proxy.cpp", | ||
| 69 | - "src/distributedcamera/dcamera_sink_hidumper.cpp", | ||
| 70 | - "src/distributedcamera/distributed_camera_sink_service.cpp", | ||
| 71 | - "src/distributedcamera/distributed_camera_sink_stub.cpp", | ||
| 72 | - "src/distributedcameramgr/callback/dcamera_sink_controller_state_callback.cpp", | ||
| 73 | "src/distributedcameramgr/callback/dcamera_sink_output_result_callback.cpp", | 100 | "src/distributedcameramgr/callback/dcamera_sink_output_result_callback.cpp", |
| 74 | "src/distributedcameramgr/dcamera_sink_access_control.cpp", | 101 | "src/distributedcameramgr/dcamera_sink_access_control.cpp", |
| 75 | - "src/distributedcameramgr/dcamera_sink_controller.cpp", | ||
| 76 | - "src/distributedcameramgr/dcamera_sink_data_process.cpp", | ||
| 77 | - "src/distributedcameramgr/dcamera_sink_dev.cpp", | ||
| 78 | "src/distributedcameramgr/dcamera_sink_output.cpp", | 102 | "src/distributedcameramgr/dcamera_sink_output.cpp", |
| 79 | - "src/distributedcameramgr/dcamera_sink_service_ipc.cpp", | ||
| 80 | - "src/distributedcameramgr/listener/dcamera_sink_controller_channel_listener.cpp", | ||
| 81 | - "src/distributedcameramgr/listener/dcamera_sink_data_process_listener.cpp", | ||
| 82 | "src/distributedcameramgr/listener/dcamera_sink_output_channel_listener.cpp", | 103 | "src/distributedcameramgr/listener/dcamera_sink_output_channel_listener.cpp", |
| 83 | ] | 104 | ] |
| 84 | 105 | ||
| 106 | + if (defined(ohos_lite)) { | ||
| 107 | + sources = common_sources + [ | ||
| 108 | + "src/distributedcamera/lite/distributed_camera_sink_service.cpp", | ||
| 109 | + "src/distributedcameramgr/callback/dcamera_sink_controller_state_callback.cpp", | ||
| 110 | + "src/distributedcameramgr/dcamera_sink_dev.cpp", | ||
| 111 | + "src/distributedcameramgr/lite/dcamera_lite_event_handler.cpp", | ||
| 112 | + "src/distributedcameramgr/lite/dcamera_sink_controller.cpp", | ||
| 113 | + "src/distributedcameramgr/lite/dcamera_sink_data_process.cpp", | ||
| 114 | + "src/distributedcameramgr/listener/dcamera_sink_controller_channel_listener.cpp", | ||
| 115 | + ] | ||
| 116 | + } else { | ||
| 117 | + standard_only_sources = [ | ||
| 118 | + "src/distributedcamera/dcamera_sink_callback_proxy.cpp", | ||
| 119 | + "src/distributedcamera/dcamera_sink_hidumper.cpp", | ||
| 120 | + "src/distributedcamera/distributed_camera_sink_stub.cpp", | ||
| 121 | + "src/distributedcameramgr/callback/dcamera_sink_controller_state_callback.cpp", | ||
| 122 | + "src/distributedcameramgr/dcamera_sink_dev.cpp", | ||
| 123 | + "src/distributedcameramgr/dcamera_sink_service_ipc.cpp", | ||
| 124 | + "src/distributedcameramgr/listener/dcamera_sink_controller_channel_listener.cpp", | ||
| 125 | + "src/distributedcameramgr/listener/dcamera_sink_data_process_listener.cpp", | ||
| 126 | + ] | ||
| 127 | + sources = common_sources + standard_only_sources + [ | ||
| 128 | + "${innerkits_path}/native_cpp/camera_source/src/distributed_camera_source_proxy.cpp", | ||
| 129 | + "src/distributedcamera/standard/distributed_camera_sink_service.cpp", | ||
| 130 | + "src/distributedcameramgr/standard/dcamera_sink_controller.cpp", | ||
| 131 | + "src/distributedcameramgr/standard/dcamera_sink_data_process.cpp", | ||
| 132 | + ] | ||
| 133 | + } | ||
| 134 | + | ||
| 85 | if (distributed_camera_open_stabile) { | 135 | if (distributed_camera_open_stabile) { |
| 86 | sources += [ "src/distributedcameramgr/dcamera_sink_imu_sensor.cpp" ] | 136 | sources += [ "src/distributedcameramgr/dcamera_sink_imu_sensor.cpp" ] |
| 87 | } | 137 | } |
| @@ -106,6 +156,10 @@ ohos_shared_library("distributed_camera_sink") { | |||
| 106 | "LOG_DOMAIN=0xD004150", | 156 | "LOG_DOMAIN=0xD004150", |
| 107 | ] | 157 | ] |
| 108 | 158 | ||
| 159 | + if (defined(ohos_lite)) { | ||
| 160 | + defines += [ "OHOS_LITE" ] | ||
| 161 | + } | ||
| 162 | + | ||
| 109 | if (build_variant == "root") { | 163 | if (build_variant == "root") { |
| 110 | defines += [ "DUMP_DCAMERA_FILE" ] | 164 | defines += [ "DUMP_DCAMERA_FILE" ] |
| 111 | } | 165 | } |
| @@ -122,29 +176,44 @@ ohos_shared_library("distributed_camera_sink") { | |||
| 122 | cflags = [ "-DDCAMERA_OPEN_STABILE" ] | 176 | cflags = [ "-DDCAMERA_OPEN_STABILE" ] |
| 123 | } | 177 | } |
| 124 | 178 | ||
| 125 | - external_deps = [ | 179 | + if (defined(ohos_lite)) { |
| 126 | - "access_token:libaccesstoken_sdk", | 180 | + defines += [ "DCAMERA_LITE" ] |
| 127 | - "access_token:libtokenid_sdk", | 181 | + } |
| 128 | - "access_token:libtokensetproc_shared", | 182 | + |
| 129 | - "cJSON:cjson", | 183 | + if (!defined(ohos_lite)) { |
| 130 | - "c_utils:utils", | 184 | + external_deps = [ |
| 131 | - "camera_framework:camera_framework", | 185 | + "access_token:libaccesstoken_sdk", |
| 132 | - "device_manager:devicemanagersdk", | 186 | + "access_token:libtokenid_sdk", |
| 133 | - "distributed_hardware_fwk:distributed_av_receiver", | 187 | + "access_token:libtokensetproc_shared", |
| 134 | - "distributed_hardware_fwk:distributedhardwareutils", | 188 | + "cJSON:cjson", |
| 135 | - "drivers_interface_camera:metadata", | 189 | + "c_utils:utils", |
| 136 | - "drivers_interface_distributed_camera:libdistributed_camera_provider_proxy_1.1", | 190 | + "camera_framework:camera_framework", |
| 137 | - "dsoftbus:softbus_client", | 191 | + "device_manager:devicemanagersdk", |
| 138 | - "eventhandler:libeventhandler", | 192 | + "distributed_hardware_fwk:distributed_av_receiver", |
| 139 | - "ffrt:libffrt", | 193 | + "distributed_hardware_fwk:distributedhardwareutils", |
| 140 | - "graphic_surface:surface", | 194 | + "drivers_interface_camera:metadata", |
| 141 | - "hdf_core:libhdf_utils", | 195 | + "drivers_interface_distributed_camera:libdistributed_camera_provider_proxy_1.1", |
| 142 | - "hilog:libhilog", | 196 | + "dsoftbus:softbus_client", |
| 143 | - "ipc:ipc_core", | 197 | + "eventhandler:libeventhandler", |
| 144 | - "safwk:system_ability_fwk", | 198 | + "ffrt:libffrt", |
| 145 | - "samgr:samgr_proxy", | 199 | + "graphic_surface:surface", |
| 146 | - "sensor:sensor_interface_native", | 200 | + "hdf_core:libhdf_utils", |
| 147 | - ] | 201 | + "hilog:libhilog", |
| 202 | + "ipc:ipc_core", | ||
| 203 | + "safwk:system_ability_fwk", | ||
| 204 | + "samgr:samgr_proxy", | ||
| 205 | + "sensor:sensor_interface_native", | ||
| 206 | + ] | ||
| 207 | + } else { | ||
| 208 | + external_deps = [ | ||
| 209 | + "cJSON:cjson", | ||
| 210 | + "distributed_hardware_fwk:distributedhardwareutils", | ||
| 211 | + "hilog_lite:hilog_shared", | ||
| 212 | + ] | ||
| 213 | + deps += [ | ||
| 214 | + "//foundation/communication/dsoftbus/sdk:softbus_client", | ||
| 215 | + ] | ||
| 216 | + } | ||
| 148 | 217 | ||
| 149 | if (os_account_camera) { | 218 | if (os_account_camera) { |
| 150 | external_deps += [ | 219 | external_deps += [ |
| @@ -17,12 +17,15 @@ | |||
| 17 | 17 | ||
| 18 | 18 | ||
| 19 | 19 | ||
| 20 | + | ||
| 20 | 21 | ||
| 21 | 22 | ||
| 23 | + | ||
| 22 | 24 | ||
| 23 | 25 | ||
| 24 | 26 | ||
| 25 | 27 | ||
| 28 | + | ||
| 26 | namespace OHOS { | 29 | namespace OHOS { |
| 27 | namespace DistributedHardware { | 30 | namespace DistributedHardware { |
| 28 | class DCameraSinkCallbackProxy : public IRemoteProxy<IDCameraSinkCallback> { | 31 | class DCameraSinkCallbackProxy : public IRemoteProxy<IDCameraSinkCallback> { |
| @@ -43,4 +46,5 @@ private: | |||
| 43 | }; | 46 | }; |
| 44 | } // namespace DistributedHardware | 47 | } // namespace DistributedHardware |
| 45 | } // namespace OHOS | 48 | } // namespace OHOS |
| 49 | + | ||
| 46 | 50 | ||
Mservices/cameraservice/sinkservice/include/distributedcamera/distributed_camera_sink_service.h+53-3
| @@ -17,8 +17,10 @@ | |||
| 17 | 17 | ||
| 18 | 18 | ||
| 19 | 19 | ||
| 20 | + | ||
| 20 | 21 | ||
| 21 | 22 | ||
| 23 | + | ||
| 22 | 24 | ||
| 23 | 25 | ||
| 24 | 26 | ||
| @@ -28,6 +30,7 @@ | |||
| 28 | 30 | ||
| 29 | namespace OHOS { | 31 | namespace OHOS { |
| 30 | namespace DistributedHardware { | 32 | namespace DistributedHardware { |
| 33 | + | ||
| 31 | class DistributedCameraSinkService : public SystemAbility, public DistributedCameraSinkStub { | 34 | class DistributedCameraSinkService : public SystemAbility, public DistributedCameraSinkStub { |
| 32 | DECLARE_SYSTEM_ABILITY(DistributedCameraSinkService); | 35 | DECLARE_SYSTEM_ABILITY(DistributedCameraSinkService); |
| 33 | 36 | ||
| @@ -35,7 +38,7 @@ public: | |||
| 35 | DistributedCameraSinkService(int32_t saId, bool runOnCreate); | 38 | DistributedCameraSinkService(int32_t saId, bool runOnCreate); |
| 36 | ~DistributedCameraSinkService() override = default; | 39 | ~DistributedCameraSinkService() override = default; |
| 37 | 40 | ||
| 38 | - int32_t InitSink(const std::string& params, const sptr<IDCameraSinkCallback> &sinkCallback) override; | 41 | + int32_t InitSink(const std::string& params, const IDCameraSinkCallbackPtr &sinkCallback) override; |
| 39 | int32_t ReleaseSink() override; | 42 | int32_t ReleaseSink() override; |
| 40 | int32_t SubscribeLocalHardware(const std::string& dhId, const std::string& parameters) override; | 43 | int32_t SubscribeLocalHardware(const std::string& dhId, const std::string& parameters) override; |
| 41 | int32_t UnsubscribeLocalHardware(const std::string& dhId) override; | 44 | int32_t UnsubscribeLocalHardware(const std::string& dhId) override; |
| @@ -49,7 +52,7 @@ public: | |||
| 49 | int32_t PauseDistributedHardware(const std::string &networkId) override; | 52 | int32_t PauseDistributedHardware(const std::string &networkId) override; |
| 50 | int32_t ResumeDistributedHardware(const std::string &networkId) override; | 53 | int32_t ResumeDistributedHardware(const std::string &networkId) override; |
| 51 | int32_t StopDistributedHardware(const std::string &networkId) override; | 54 | int32_t StopDistributedHardware(const std::string &networkId) override; |
| 52 | - int32_t SetAccessListener(const sptr<IAccessListener> &listener, int32_t timeOut, | 55 | + int32_t SetAccessListener(const IAccessListenerPtr &listener, int32_t timeOut, |
| 53 | const std::string &pkgName) override; | 56 | const std::string &pkgName) override; |
| 54 | int32_t RemoveAccessListener(const std::string &pkgName) override; | 57 | int32_t RemoveAccessListener(const std::string &pkgName) override; |
| 55 | int32_t SetAuthorizationResult(const std::string &requestId, bool granted) override; | 58 | int32_t SetAuthorizationResult(const std::string &requestId, bool granted) override; |
| @@ -73,6 +76,53 @@ private: | |||
| 73 | static DistributedCameraSinkService* dcSinkService; | 76 | static DistributedCameraSinkService* dcSinkService; |
| 74 | const size_t DUMP_MAX_SIZE = 10 * 1024; | 77 | const size_t DUMP_MAX_SIZE = 10 * 1024; |
| 75 | }; | 78 | }; |
| 79 | + | ||
| 80 | + | ||
| 81 | + | ||
| 82 | +class DistributedCameraSinkService { | ||
| 83 | +FWK_DECLARE_SINGLE_INSTANCE_BASE(DistributedCameraSinkService); | ||
| 84 | +public: | ||
| 85 | + ~DistributedCameraSinkService() = default; | ||
| 86 | +private: | ||
| 87 | + DistributedCameraSinkService() = default; | ||
| 88 | + | ||
| 89 | +public: | ||
| 90 | + int32_t InitSink(const std::string& params, const IDCameraSinkCallbackPtr &sinkCallback); | ||
| 91 | + int32_t ReleaseSink(); | ||
| 92 | + int32_t SubscribeLocalHardware(const std::string& dhId, const std::string& parameters); | ||
| 93 | + int32_t UnsubscribeLocalHardware(const std::string& dhId); | ||
| 94 | + int32_t StopCapture(const std::string& dhId); | ||
| 95 | + int32_t ChannelNeg(const std::string& dhId, std::string& channelInfo); | ||
| 96 | + int32_t GetCameraInfo(const std::string& dhId, std::string& cameraInfo); | ||
| 97 | + int32_t OpenChannel(const std::string& dhId, std::string& openInfo); | ||
| 98 | + int32_t CloseChannel(const std::string& dhId); | ||
| 99 | + int Dump(int32_t fd, const std::vector<std::u16string>& args); | ||
| 100 | + static void GetCamDumpInfo(CameraDumpInfo& camDump); | ||
| 101 | + int32_t PauseDistributedHardware(const std::string &networkId); | ||
| 102 | + int32_t ResumeDistributedHardware(const std::string &networkId); | ||
| 103 | + int32_t StopDistributedHardware(const std::string &networkId); | ||
| 104 | + int32_t SetAccessListener(const IAccessListenerPtr &listener, int32_t timeOut, | ||
| 105 | + const std::string &pkgName); | ||
| 106 | + int32_t RemoveAccessListener(const std::string &pkgName); | ||
| 107 | + int32_t SetAuthorizationResult(const std::string &requestId, bool granted); | ||
| 108 | + | ||
| 109 | + void Start(); | ||
| 110 | + void OnStop(); | ||
| 111 | + | ||
| 112 | +private: | ||
| 113 | + bool IsCurSinkDev(std::shared_ptr<DCameraSinkDev> sinkDevice); | ||
| 114 | + | ||
| 115 | + bool Init(); | ||
| 116 | + void GetCamIds(); | ||
| 117 | + bool registerToService_ = false; | ||
| 118 | + DCameraServiceState state_ = DCameraServiceState::DCAMERA_SRV_STATE_NOT_START; | ||
| 119 | + | ||
| 120 | + std::string sinkVer_; | ||
| 121 | + std::mutex mapMutex_; | ||
| 122 | + std::map<std::string, std::shared_ptr<DCameraSinkDev>> camerasMap_; | ||
| 123 | + const size_t DUMP_MAX_SIZE = 10 * 1024; | ||
| 124 | +}; | ||
| 125 | + | ||
| 76 | } // namespace DistributedHardware | 126 | } // namespace DistributedHardware |
| 77 | } // namespace OHOS | 127 | } // namespace OHOS |
| 78 | -#endif // OHOS_DISTRIBUTED_CAMERA_SINK_SERVICE_H | 128 | +#endif // OHOS_DISTRIBUTED_CAMERA_SINK_SERVICE_H |
| @@ -17,12 +17,15 @@ | |||
| 17 | 17 | ||
| 18 | 18 | ||
| 19 | 19 | ||
| 20 | + | ||
| 20 | 21 | ||
| 22 | + | ||
| 21 | 23 | ||
| 22 | 24 | ||
| 23 | 25 | ||
| 24 | namespace OHOS { | 26 | namespace OHOS { |
| 25 | namespace DistributedHardware { | 27 | namespace DistributedHardware { |
| 28 | + | ||
| 26 | class DistributedCameraSinkStub : public IRemoteStub<IDistributedCameraSink> { | 29 | class DistributedCameraSinkStub : public IRemoteStub<IDistributedCameraSink> { |
| 27 | public: | 30 | public: |
| 28 | DistributedCameraSinkStub(); | 31 | DistributedCameraSinkStub(); |
| @@ -54,6 +57,7 @@ private: | |||
| 54 | const size_t DID_MAX_SIZE = 256; | 57 | const size_t DID_MAX_SIZE = 256; |
| 55 | const size_t PARAM_MAX_SIZE = 50 * 1024 * 1024; | 58 | const size_t PARAM_MAX_SIZE = 50 * 1024 * 1024; |
| 56 | }; | 59 | }; |
| 60 | + | ||
| 57 | } // namespace DistributedHardware | 61 | } // namespace DistributedHardware |
| 58 | } // namespace OHOS | 62 | } // namespace OHOS |
| 59 | 63 | ||
| @@ -28,7 +28,9 @@ public: | |||
| 28 | ~DCameraSinkControllerStateCallback() override = default; | 28 | ~DCameraSinkControllerStateCallback() override = default; |
| 29 | 29 | ||
| 30 | void OnStateChanged(std::shared_ptr<DCameraEvent>& event) override; | 30 | void OnStateChanged(std::shared_ptr<DCameraEvent>& event) override; |
| 31 | + | ||
| 31 | void OnMetadataResult(std::vector<std::shared_ptr<DCameraSettings>>& settings) override; | 32 | void OnMetadataResult(std::vector<std::shared_ptr<DCameraSettings>>& settings) override; |
| 33 | + | ||
| 32 | 34 | ||
| 33 | private: | 35 | private: |
| 34 | std::weak_ptr<DCameraSinkController> controller_; | 36 | std::weak_ptr<DCameraSinkController> controller_; |
| @@ -16,7 +16,9 @@ | |||
| 16 | 16 | ||
| 17 | 17 | ||
| 18 | 18 | ||
| 19 | + | ||
| 19 | 20 | ||
| 21 | + | ||
| 20 | 22 | ||
| 21 | 23 | ||
| 22 | 24 | ||
| @@ -25,8 +27,10 @@ | |||
| 25 | 27 | ||
| 26 | 28 | ||
| 27 | 29 | ||
| 30 | + | ||
| 28 | 31 | ||
| 29 | 32 | ||
| 33 | + | ||
| 30 | 34 | ||
| 31 | 35 | ||
| 32 | 36 | ||
| @@ -43,7 +47,7 @@ enum DcameraBusinessState : int32_t { | |||
| 43 | class DCameraSinkController : public ICameraController, public std::enable_shared_from_this<DCameraSinkController> { | 47 | class DCameraSinkController : public ICameraController, public std::enable_shared_from_this<DCameraSinkController> { |
| 44 | public: | 48 | public: |
| 45 | explicit DCameraSinkController(std::shared_ptr<ICameraSinkAccessControl>& accessControl, | 49 | explicit DCameraSinkController(std::shared_ptr<ICameraSinkAccessControl>& accessControl, |
| 46 | - const sptr<IDCameraSinkCallback> &sinkCallback); | 50 | + const IDCameraSinkCallbackPtr &sinkCallback); |
| 47 | ~DCameraSinkController() override; | 51 | ~DCameraSinkController() override; |
| 48 | 52 | ||
| 49 | int32_t StartCapture(std::vector<std::shared_ptr<DCameraCaptureInfo>>& captureInfos, int32_t sceneMode, | 53 | int32_t StartCapture(std::vector<std::shared_ptr<DCameraCaptureInfo>>& captureInfos, int32_t sceneMode, |
| @@ -51,7 +55,9 @@ public: | |||
| 51 | int32_t StopCapture() override; | 55 | int32_t StopCapture() override; |
| 52 | int32_t ChannelNeg(std::shared_ptr<DCameraChannelInfo>& info) override; | 56 | int32_t ChannelNeg(std::shared_ptr<DCameraChannelInfo>& info) override; |
| 53 | int32_t DCameraNotify(std::shared_ptr<DCameraEvent>& events) override; | 57 | int32_t DCameraNotify(std::shared_ptr<DCameraEvent>& events) override; |
| 58 | + | ||
| 54 | int32_t UpdateSettings(std::vector<std::shared_ptr<DCameraSettings>>& settings) override; | 59 | int32_t UpdateSettings(std::vector<std::shared_ptr<DCameraSettings>>& settings) override; |
| 60 | + | ||
| 55 | int32_t GetCameraInfo(std::shared_ptr<DCameraInfo>& camInfo) override; | 61 | int32_t GetCameraInfo(std::shared_ptr<DCameraInfo>& camInfo) override; |
| 56 | int32_t OpenChannel(std::shared_ptr<DCameraOpenInfo>& openInfo) override; | 62 | int32_t OpenChannel(std::shared_ptr<DCameraOpenInfo>& openInfo) override; |
| 57 | int32_t CloseChannel() override; | 63 | int32_t CloseChannel() override; |
| @@ -63,12 +69,15 @@ public: | |||
| 63 | void SetTokenId(uint64_t token) override; | 69 | void SetTokenId(uint64_t token) override; |
| 64 | 70 | ||
| 65 | void OnStateChanged(std::shared_ptr<DCameraEvent>& event); | 71 | void OnStateChanged(std::shared_ptr<DCameraEvent>& event); |
| 72 | + | ||
| 66 | void OnMetadataResult(std::vector<std::shared_ptr<DCameraSettings>>& settings); | 73 | void OnMetadataResult(std::vector<std::shared_ptr<DCameraSettings>>& settings); |
| 74 | + | ||
| 67 | 75 | ||
| 68 | void OnSessionState(int32_t state, std::string networkId); | 76 | void OnSessionState(int32_t state, std::string networkId); |
| 69 | void OnSessionError(int32_t eventType, int32_t eventReason, std::string detail); | 77 | void OnSessionError(int32_t eventType, int32_t eventReason, std::string detail); |
| 70 | void OnDataReceived(std::vector<std::shared_ptr<DataBuffer>>& buffers); | 78 | void OnDataReceived(std::vector<std::shared_ptr<DataBuffer>>& buffers); |
| 71 | 79 | ||
| 80 | + | ||
| 72 | class DCameraSinkContrEventHandler : public AppExecFwk::EventHandler { | 81 | class DCameraSinkContrEventHandler : public AppExecFwk::EventHandler { |
| 73 | public: | 82 | public: |
| 74 | DCameraSinkContrEventHandler(const std::shared_ptr<AppExecFwk::EventRunner> &runner, | 83 | DCameraSinkContrEventHandler(const std::shared_ptr<AppExecFwk::EventRunner> &runner, |
| @@ -83,36 +92,48 @@ public: | |||
| 83 | private: | 92 | private: |
| 84 | std::weak_ptr<DCameraSinkController> sinkContrWPtr_; | 93 | std::weak_ptr<DCameraSinkController> sinkContrWPtr_; |
| 85 | }; | 94 | }; |
| 95 | + | ||
| 86 | 96 | ||
| 87 | private: | 97 | private: |
| 88 | int32_t StartCaptureInner(std::vector<std::shared_ptr<DCameraCaptureInfo>>& captureInfos); | 98 | int32_t StartCaptureInner(std::vector<std::shared_ptr<DCameraCaptureInfo>>& captureInfos); |
| 89 | int32_t DCameraNotifyInner(int32_t type, int32_t result, std::string content); | 99 | int32_t DCameraNotifyInner(int32_t type, int32_t result, std::string content); |
| 90 | int32_t HandleReceivedData(std::shared_ptr<DataBuffer>& dataBuffer); | 100 | int32_t HandleReceivedData(std::shared_ptr<DataBuffer>& dataBuffer); |
| 91 | - void PostAuthorization(std::vector<std::shared_ptr<DCameraCaptureInfo>>& captureInfos); | 101 | + int32_t PostAuthorization(std::vector<std::shared_ptr<DCameraCaptureInfo>>& captureInfos); |
| 92 | bool CheckDeviceSecurityLevel(const std::string &srcDeviceId, const std::string &dstDeviceId); | 102 | bool CheckDeviceSecurityLevel(const std::string &srcDeviceId, const std::string &dstDeviceId); |
| 93 | int32_t GetDeviceSecurityLevel(const std::string &udid); | 103 | int32_t GetDeviceSecurityLevel(const std::string &udid); |
| 94 | std::string GetUdidByNetworkId(const std::string &networkId); | 104 | std::string GetUdidByNetworkId(const std::string &networkId); |
| 95 | int32_t PullUpPage(); | 105 | int32_t PullUpPage(); |
| 106 | + | ||
| 96 | void ProcessFrameTrigger(const AppExecFwk::InnerEvent::Pointer &event); | 107 | void ProcessFrameTrigger(const AppExecFwk::InnerEvent::Pointer &event); |
| 97 | void ProcessPostAuthorization(const AppExecFwk::InnerEvent::Pointer &event); | 108 | void ProcessPostAuthorization(const AppExecFwk::InnerEvent::Pointer &event); |
| 109 | + | ||
| 98 | int32_t CreateCtrlSession(); | 110 | int32_t CreateCtrlSession(); |
| 99 | int32_t CheckSensitive(); | 111 | int32_t CheckSensitive(); |
| 100 | bool CheckAclRight(); | 112 | bool CheckAclRight(); |
| 101 | bool IsIdenticalAccount(const std::string &networkId); | 113 | bool IsIdenticalAccount(const std::string &networkId); |
| 114 | + | ||
| 102 | class DCameraSurfaceHolder { | 115 | class DCameraSurfaceHolder { |
| 103 | public: | 116 | public: |
| 104 | DCameraSurfaceHolder(int32_t r, sptr<Surface> s) : result(r), surface(s) {} | 117 | DCameraSurfaceHolder(int32_t r, sptr<Surface> s) : result(r), surface(s) {} |
| 105 | int32_t result; | 118 | int32_t result; |
| 106 | sptr<Surface> surface; | 119 | sptr<Surface> surface; |
| 107 | }; | 120 | }; |
| 121 | + | ||
| 108 | void HandleCaptureError(int32_t errorCode, const std::string& errorMsg); | 122 | void HandleCaptureError(int32_t errorCode, const std::string& errorMsg); |
| 109 | void CheckAndCommitCapture(); | 123 | void CheckAndCommitCapture(); |
| 110 | 124 | ||
| 125 | + | ||
| 111 | std::atomic<bool> isEncoderReady_ {false}; | 126 | std::atomic<bool> isEncoderReady_ {false}; |
| 112 | std::atomic<bool> isCameraReady_ {false}; | 127 | std::atomic<bool> isCameraReady_ {false}; |
| 128 | + | ||
| 129 | + bool isEncoderReady_ = false; | ||
| 130 | + bool isCameraReady_ = false; | ||
| 131 | + | ||
| 113 | int32_t encoderResult_ = DCAMERA_OK; | 132 | int32_t encoderResult_ = DCAMERA_OK; |
| 114 | int32_t cameraResult_ = DCAMERA_OK; | 133 | int32_t cameraResult_ = DCAMERA_OK; |
| 134 | + | ||
| 115 | sptr<Surface> preparedSurface_ = nullptr; | 135 | sptr<Surface> preparedSurface_ = nullptr; |
| 136 | + | ||
| 116 | std::mutex stateMutex_; | 137 | std::mutex stateMutex_; |
| 117 | std::vector<std::shared_ptr<DCameraCaptureInfo>> captureInfosCache_; | 138 | std::vector<std::shared_ptr<DCameraCaptureInfo>> captureInfosCache_; |
| 118 | 139 | ||
| @@ -123,14 +144,22 @@ private: | |||
| 123 | std::mutex channelLock_; | 144 | std::mutex channelLock_; |
| 124 | std::string dhId_; | 145 | std::string dhId_; |
| 125 | std::string srcDevId_; | 146 | std::string srcDevId_; |
| 147 | + | ||
| 126 | std::shared_ptr<DCameraSinkContrEventHandler> sinkCotrEventHandler_; | 148 | std::shared_ptr<DCameraSinkContrEventHandler> sinkCotrEventHandler_; |
| 149 | + | ||
| 127 | std::shared_ptr<ICameraChannel> channel_; | 150 | std::shared_ptr<ICameraChannel> channel_; |
| 128 | std::shared_ptr<ICameraOperator> operator_; | 151 | std::shared_ptr<ICameraOperator> operator_; |
| 129 | std::shared_ptr<ICameraSinkAccessControl> accessControl_; | 152 | std::shared_ptr<ICameraSinkAccessControl> accessControl_; |
| 130 | std::shared_ptr<ICameraSinkOutput> output_; | 153 | std::shared_ptr<ICameraSinkOutput> output_; |
| 131 | - sptr<IDCameraSinkCallback> sinkCallback_; | 154 | + IDCameraSinkCallbackPtr sinkCallback_; |
| 155 | + | ||
| 132 | std::atomic<bool> isPageStatus_ = false; | 156 | std::atomic<bool> isPageStatus_ = false; |
| 157 | + | ||
| 158 | + bool isPageStatus_ = false; | ||
| 159 | + | ||
| 160 | + | ||
| 133 | std::shared_ptr<DmInitCallback> initCallback_; | 161 | std::shared_ptr<DmInitCallback> initCallback_; |
| 162 | + | ||
| 134 | bool isSensitive_ = false; | 163 | bool isSensitive_ = false; |
| 135 | bool isSameAccount_ = false; | 164 | bool isSameAccount_ = false; |
| 136 | bool isCheckSecLevel_ = false; | 165 | bool isCheckSecLevel_ = false; |
| @@ -157,9 +186,11 @@ private: | |||
| 157 | DcameraCaptureState captureState_ {CAPTURE_IDLE}; | 186 | DcameraCaptureState captureState_ {CAPTURE_IDLE}; |
| 158 | }; | 187 | }; |
| 159 | 188 | ||
| 189 | + | ||
| 160 | class DeviceInitCallback : public DmInitCallback { | 190 | class DeviceInitCallback : public DmInitCallback { |
| 161 | void OnRemoteDied() override; | 191 | void OnRemoteDied() override; |
| 162 | }; | 192 | }; |
| 193 | + | ||
| 163 | } // namespace DistributedHardware | 194 | } // namespace DistributedHardware |
| 164 | } // namespace OHOS | 195 | } // namespace OHOS |
| 165 | 196 | ||
| @@ -20,15 +20,23 @@ | |||
| 20 | 20 | ||
| 21 | 21 | ||
| 22 | 22 | ||
| 23 | + | ||
| 24 | + | ||
| 25 | + | ||
| 23 | 26 | ||
| 27 | + | ||
| 24 | 28 | ||
| 25 | 29 | ||
| 30 | + | ||
| 26 | 31 | ||
| 27 | 32 | ||
| 33 | + | ||
| 28 | 34 | ||
| 29 | 35 | ||
| 36 | + | ||
| 30 | 37 | ||
| 31 | 38 | ||
| 39 | + | ||
| 32 | 40 | ||
| 33 | namespace OHOS { | 41 | namespace OHOS { |
| 34 | namespace DistributedHardware { | 42 | namespace DistributedHardware { |
| @@ -44,7 +52,9 @@ public: | |||
| 44 | void Init() override; | 52 | void Init() override; |
| 45 | 53 | ||
| 46 | int32_t OnProcessedVideoBuffer(const std::shared_ptr<DataBuffer>& videoResult); | 54 | int32_t OnProcessedVideoBuffer(const std::shared_ptr<DataBuffer>& videoResult); |
| 55 | + | ||
| 47 | void OnError(DataProcessErrorType errorType); | 56 | void OnError(DataProcessErrorType errorType); |
| 57 | + | ||
| 48 | 58 | ||
| 49 | int32_t GetProperty(const std::string& propertyName, PropertyCarrier& propertyCarrier) override; | 59 | int32_t GetProperty(const std::string& propertyName, PropertyCarrier& propertyCarrier) override; |
| 50 | 60 | ||
| @@ -59,24 +69,34 @@ private: | |||
| 59 | SensorUser gyroUser = { "", nullptr, nullptr }; | 69 | SensorUser gyroUser = { "", nullptr, nullptr }; |
| 60 | 70 | ||
| 61 | 71 | ||
| 72 | + | ||
| 62 | int32_t FeedStreamInner(std::shared_ptr<DataBuffer>& dataBuffer); | 73 | int32_t FeedStreamInner(std::shared_ptr<DataBuffer>& dataBuffer); |
| 63 | VideoCodecType GetPipelineCodecType(DCEncodeType encodeType); | 74 | VideoCodecType GetPipelineCodecType(DCEncodeType encodeType); |
| 64 | Videoformat GetPipelineFormat(int32_t format); | 75 | Videoformat GetPipelineFormat(int32_t format); |
| 76 | + | ||
| 65 | void StartEventHandler(); | 77 | void StartEventHandler(); |
| 66 | void SendDataAsync(const std::shared_ptr<DataBuffer>& buffer); | 78 | void SendDataAsync(const std::shared_ptr<DataBuffer>& buffer); |
| 79 | + | ||
| 67 | int32_t GetMaxFrameRate(std::shared_ptr<DCameraCaptureInfo>& captureInfo); | 80 | int32_t GetMaxFrameRate(std::shared_ptr<DCameraCaptureInfo>& captureInfo); |
| 81 | + | ||
| 68 | 82 | ||
| 69 | const uint32_t DCAMERA_FPS_SIZE = 2; | 83 | const uint32_t DCAMERA_FPS_SIZE = 2; |
| 70 | 84 | ||
| 71 | std::string dhId_; | 85 | std::string dhId_; |
| 72 | std::shared_ptr<DCameraCaptureInfo> captureInfo_; | 86 | std::shared_ptr<DCameraCaptureInfo> captureInfo_; |
| 73 | std::shared_ptr<ICameraChannel> channel_; | 87 | std::shared_ptr<ICameraChannel> channel_; |
| 88 | + | ||
| 74 | std::shared_ptr<IDataProcessPipeline> pipeline_; | 89 | std::shared_ptr<IDataProcessPipeline> pipeline_; |
| 90 | + | ||
| 75 | 91 | ||
| 92 | + | ||
| 93 | + std::shared_ptr<DCameraLiteEventHandler> eventHandler_; | ||
| 94 | + | ||
| 76 | std::mutex eventMutex_; | 95 | std::mutex eventMutex_; |
| 77 | std::thread eventThread_; | 96 | std::thread eventThread_; |
| 78 | std::condition_variable eventCon_; | 97 | std::condition_variable eventCon_; |
| 79 | std::shared_ptr<AppExecFwk::EventHandler> eventHandler_; | 98 | std::shared_ptr<AppExecFwk::EventHandler> eventHandler_; |
| 99 | + | ||
| 80 | FILE *dumpFile_ = nullptr; | 100 | FILE *dumpFile_ = nullptr; |
| 81 | }; | 101 | }; |
| 82 | } // namespace DistributedHardware | 102 | } // namespace DistributedHardware |
Rservices/cameraservice/sinkservice/src/distributedcamera/distributed_camera_sink_service.cpp→services/cameraservice/sinkservice/src/distributedcamera/standard/distributed_camera_sink_service.cpp+2-2
Rservices/cameraservice/sinkservice/src/distributedcameramgr/dcamera_sink_controller.cpp→services/cameraservice/sinkservice/src/distributedcameramgr/standard/dcamera_sink_controller.cpp+1-1
Rservices/cameraservice/sinkservice/src/distributedcameramgr/dcamera_sink_data_process.cpp→services/cameraservice/sinkservice/src/distributedcameramgr/standard/dcamera_sink_data_process.cpp+0-0
Rservices/channel/src/dcamera_softbus_adapter.cpp→services/channel/src/standard/dcamera_softbus_adapter.cpp+5-0
【安全检视意见|自动扫描】【低危】测试程序暴露 test/lite_host 下的 dcamera_sink_host 宿主可执行程序加入正式 components 列表,BUILD.gn 中 ohos_executable 未显式设置 install_enable = false(默认安装),将随 lite 产线镜像默认部署。该程序启动分布式相机 sink 全链路(含远程取流控制面),部署位置与命名(test/)不符且无安装开关控制,存在被误编入定制版本的风险。 建议:若为功能必需组件,移出 test/ 目录并按正式组件管理;若仅调试用途,显式设置 install_enable = false。