From fe9cffdefc2e0eaa8052effa1a4cd98148f45add Mon Sep 17 00:00:00 2001 From: wangchaole Date: Mon, 18 Jul 2022 15:23:12 +0800 Subject: [PATCH] fix: modify log title Signed-off-by: wangchaole --- .../constants/distributed_camera_constants.h | 4 + common/include/utils/dh_log.h | 43 +++++++++ .../include/utils/distributed_hardware_log.h | 38 ++++++++ common/src/utils/dh_log.cpp | 87 +++++++++++++++++++ .../native_cpp/camera_sink/BUILD.gn | 2 - .../native_cpp/camera_source/BUILD.gn | 2 - .../cameraoperator/client/BUILD.gn | 3 - .../cameraoperator/handler/BUILD.gn | 2 - services/cameraservice/sinkservice/BUILD.gn | 2 - services/cameraservice/sourceservice/BUILD.gn | 2 - services/channel/BUILD.gn | 2 - services/data_process/BUILD.gn | 11 ++- 12 files changed, 179 insertions(+), 19 deletions(-) create mode 100644 common/include/utils/dh_log.h create mode 100644 common/include/utils/distributed_hardware_log.h create mode 100644 common/src/utils/dh_log.cpp diff --git a/common/include/constants/distributed_camera_constants.h b/common/include/constants/distributed_camera_constants.h index bf517f2f..071d54d1 100644 --- a/common/include/constants/distributed_camera_constants.h +++ b/common/include/constants/distributed_camera_constants.h @@ -22,6 +22,10 @@ namespace OHOS { namespace DistributedHardware { + +const std::string DH_LOG_TITLE_TAG = "DCAMERA"; +constexpr int32_t LOG_MAX_LEN = 4096; + typedef enum { DCAMERA_SRV_STATE_NOT_START, DCAMERA_SRV_STATE_RUNNING diff --git a/common/include/utils/dh_log.h b/common/include/utils/dh_log.h new file mode 100644 index 00000000..6a8e3801 --- /dev/null +++ b/common/include/utils/dh_log.h @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_DCAMERA_LOG_H +#define OHOS_DCAMERA_LOG_H + +namespace OHOS { +namespace DistributedHardware { +typedef enum { + DH_LOG_DEBUG, + DH_LOG_INFO, + DH_LOG_WARN, + DH_LOG_ERROR, +} DHLogLevel; + +void DHLog(DHLogLevel logLevel, const char *fmt, ...); + +#define ULOGD(fmt, ...) DHLog(DH_LOG_DEBUG, \ + (std::string("[") + DH_LOG_TAG + "][" + __FUNCTION__ + "]:" + fmt).c_str(), ##__VA_ARGS__) + +#define ULOGI(fmt, ...) DHLog(DH_LOG_INFO, \ + (std::string("[") + DH_LOG_TAG + "][" + __FUNCTION__ + "]:" + fmt).c_str(), ##__VA_ARGS__) + +#define ULOGW(fmt, ...) DHLog(DH_LOG_WARN, \ + (std::string("[") + DH_LOG_TAG + "][" + __FUNCTION__ + "]:" + fmt).c_str(), ##__VA_ARGS__) + +#define ULOGE(fmt, ...) DHLog(DH_LOG_ERROR, \ + (std::string("[") + DH_LOG_TAG + "][" + __FUNCTION__ + "]:" + fmt).c_str(), ##__VA_ARGS__) +} // namespace DistributedHardware +} // namespace OHOS +#endif // OHOS_DCAMERA_LOG_H diff --git a/common/include/utils/distributed_hardware_log.h b/common/include/utils/distributed_hardware_log.h new file mode 100644 index 00000000..d7e1c1ee --- /dev/null +++ b/common/include/utils/distributed_hardware_log.h @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_DISTRIBUTED_CAMERA_LOG_H +#define OHOS_DISTRIBUTED_CAMERA_LOG_H + +#include + +#include "dh_log.h" + +namespace OHOS { +namespace DistributedHardware { +#define DHLOGD(fmt, ...) DHLog(DH_LOG_DEBUG, \ + (std::string("[") + DH_LOG_TAG + "][" + __FUNCTION__ + "]:" + fmt).c_str(), ##__VA_ARGS__) + +#define DHLOGI(fmt, ...) DHLog(DH_LOG_INFO, \ + (std::string("[") + DH_LOG_TAG + "][" + __FUNCTION__ + "]:" + fmt).c_str(), ##__VA_ARGS__) + +#define DHLOGW(fmt, ...) DHLog(DH_LOG_WARN, \ + (std::string("[") + DH_LOG_TAG + "][" + __FUNCTION__ + "]:" + fmt).c_str(), ##__VA_ARGS__) + +#define DHLOGE(fmt, ...) DHLog(DH_LOG_ERROR, \ + (std::string("[") + DH_LOG_TAG + "][" + __FUNCTION__ + "]:" + fmt).c_str(), ##__VA_ARGS__) +} // namespace DistributedHardware +} // namespace OHOS +#endif // OHOS_DISTRIBUTED_CAMERA_LOG_H diff --git a/common/src/utils/dh_log.cpp b/common/src/utils/dh_log.cpp new file mode 100644 index 00000000..c5eb4bec --- /dev/null +++ b/common/src/utils/dh_log.cpp @@ -0,0 +1,87 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "dh_log.h" + +#include "securec.h" + +#include "distributed_camera_constants.h" + +#ifdef HI_LOG_ENABLE +#include "hilog/log.h" +#else +#include +#endif + +namespace OHOS { +namespace DistributedHardware { +static void DHLogOut(DHLogLevel logLevel, const char *logBuf) +{ +#ifdef HI_LOG_ENABLE + LogLevel hiLogLevel = LOG_INFO; + switch (logLevel) { + case DH_LOG_DEBUG: + hiLogLevel = LOG_DEBUG; + break; + case DH_LOG_INFO: + hiLogLevel = LOG_INFO; + break; + case DH_LOG_WARN: + hiLogLevel = LOG_WARN; + break; + case DH_LOG_ERROR: + hiLogLevel = LOG_ERROR; + break; + default: + break; + } + (void)HiLogPrint(LOG_CORE, hiLogLevel, LOG_DOMAIN, DH_LOG_TITLE_TAG.c_str(), "%{public}s", logBuf); +#else + switch (logLevel) { + case DH_LOG_DEBUG: + printf("[D]%s\n", logBuf); + break; + case DH_LOG_INFO: + printf("[I]%s\n", logBuf); + break; + case DH_LOG_WARN: + printf("[W]%s\n", logBuf); + break; + case DH_LOG_ERROR: + printf("[E]%s\n", logBuf); + break; + default: + break; + } +#endif +} + +void DHLog(DHLogLevel logLevel, const char *fmt, ...) +{ + char logBuf[LOG_MAX_LEN] = {0}; + va_list arg; + + (void)memset_s(&arg, sizeof(va_list), 0, sizeof(va_list)); + va_start(arg, fmt); + int32_t ret = vsprintf_s(logBuf, sizeof(logBuf), fmt, arg); + va_end(arg); + if (ret < 0) { + DHLogOut(logLevel, "DH log length error."); + return; + } + DHLogOut(logLevel, logBuf); +} +} // namespace DistributedHardware +} // namespace OHOS diff --git a/interfaces/inner_kits/native_cpp/camera_sink/BUILD.gn b/interfaces/inner_kits/native_cpp/camera_sink/BUILD.gn index 08504b1b..ef651f5d 100644 --- a/interfaces/inner_kits/native_cpp/camera_sink/BUILD.gn +++ b/interfaces/inner_kits/native_cpp/camera_sink/BUILD.gn @@ -19,9 +19,7 @@ ohos_shared_library("distributed_camera_sink_sdk") { include_dirs = [ "//utils/native/base/include", "//utils/system/safwk/native/include", - "${fwk_utils_path}/include/log", "${fwk_utils_path}/include", - "${fwk_common_path}/log/include", "${fwk_common_path}/utils/include", ] diff --git a/interfaces/inner_kits/native_cpp/camera_source/BUILD.gn b/interfaces/inner_kits/native_cpp/camera_source/BUILD.gn index 756242d9..a07075a6 100644 --- a/interfaces/inner_kits/native_cpp/camera_source/BUILD.gn +++ b/interfaces/inner_kits/native_cpp/camera_source/BUILD.gn @@ -19,9 +19,7 @@ ohos_shared_library("distributed_camera_source_sdk") { include_dirs = [ "//utils/native/base/include", "//utils/system/safwk/native/include", - "${fwk_utils_path}/include/log", "${fwk_utils_path}/include", - "${fwk_common_path}/log/include", "${fwk_common_path}/utils/include", ] diff --git a/services/cameraservice/cameraoperator/client/BUILD.gn b/services/cameraservice/cameraoperator/client/BUILD.gn index 753351ff..93f0c749 100644 --- a/services/cameraservice/cameraoperator/client/BUILD.gn +++ b/services/cameraservice/cameraoperator/client/BUILD.gn @@ -32,9 +32,6 @@ ohos_shared_library("distributed_camera_client") { "${camerastandard_path}/services/camera_service/binder/client/include", "${camerastandard_path}/services/camera_service/binder/server/include", "${camerastandard_path}/services/camera_service/include", - "${fwk_common_path}/log/include", - "${fwk_common_path}/utils/include", - "${fwk_utils_path}/include/log", "${fwk_utils_path}/include", ] diff --git a/services/cameraservice/cameraoperator/handler/BUILD.gn b/services/cameraservice/cameraoperator/handler/BUILD.gn index a1e100f9..2cbce658 100644 --- a/services/cameraservice/cameraoperator/handler/BUILD.gn +++ b/services/cameraservice/cameraoperator/handler/BUILD.gn @@ -32,9 +32,7 @@ ohos_shared_library("distributed_camera_handler") { "${camerastandard_path}/services/camera_service/binder/server/include", "${camerastandard_path}/services/camera_service/include", "${mediastandard_path}/interfaces/innerkits/native/media/include", - "${fwk_common_path}/log/include", "${fwk_common_path}/utils/include", - "${fwk_utils_path}/include/log", "${fwk_utils_path}/include", ] diff --git a/services/cameraservice/sinkservice/BUILD.gn b/services/cameraservice/sinkservice/BUILD.gn index 6780bc1a..42178f46 100644 --- a/services/cameraservice/sinkservice/BUILD.gn +++ b/services/cameraservice/sinkservice/BUILD.gn @@ -30,10 +30,8 @@ ohos_shared_library("distributed_camera_sink") { "${camerastandard_path}/services/camera_service/binder/client/include", "${camerastandard_path}/services/camera_service/binder/server/include", "${camerastandard_path}/services/camera_service/include", - "${fwk_common_path}/log/include", "${fwk_common_path}/utils/include", "${fwk_utils_path}/include/eventbus", - "${fwk_utils_path}/include/log", "${fwk_utils_path}/include", "//third_party/jsoncpp/include", ] diff --git a/services/cameraservice/sourceservice/BUILD.gn b/services/cameraservice/sourceservice/BUILD.gn index 1929f4e8..12b63f27 100644 --- a/services/cameraservice/sourceservice/BUILD.gn +++ b/services/cameraservice/sourceservice/BUILD.gn @@ -20,10 +20,8 @@ ohos_shared_library("distributed_camera_source") { include_dirs = [ "//utils/native/base/include", "//utils/system/safwk/native/include", - "${fwk_common_path}/log/include", "${fwk_common_path}/utils/include", "${fwk_utils_path}/include/eventbus", - "${fwk_utils_path}/include/log", "${fwk_utils_path}/include", "//third_party/jsoncpp/include", "//drivers/peripheral/base", diff --git a/services/channel/BUILD.gn b/services/channel/BUILD.gn index 75cab6f2..c5a55dd2 100644 --- a/services/channel/BUILD.gn +++ b/services/channel/BUILD.gn @@ -20,9 +20,7 @@ ohos_shared_library("distributed_camera_channel") { include_dirs = [ "//utils/native/base/include", "//utils/system/safwk/native/include", - "${fwk_common_path}/log/include", "${fwk_common_path}/utils/include", - "${fwk_utils_path}/include/log", "${fwk_utils_path}/include", ] diff --git a/services/data_process/BUILD.gn b/services/data_process/BUILD.gn index afa18474..c22614ce 100644 --- a/services/data_process/BUILD.gn +++ b/services/data_process/BUILD.gn @@ -18,15 +18,14 @@ import( ohos_shared_library("distributed_camera_data_process") { include_dirs = [ + "//third_party/ffmpeg/", "//utils/native/base/include", "//utils/system/safwk/native/include", "//foundation/graphic/graphic_2d/interfaces/innerkits/common", "//foundation/graphic/graphic_2d/interfaces/innerkits/surface", "//drivers/peripheral/display/interfaces/include", "//foundation/multimedia/media_standard/interfaces/innerkits/native/media/include", - "${fwk_common_path}/log/include", - "${fwk_common_path}/utils/include", - "${fwk_utils_path}/include/log", + "//foundation/multimedia/player_framework/interfaces/innerkits/native/media/include", "${fwk_utils_path}/include/eventbus", "${fwk_utils_path}/include", ] @@ -40,6 +39,7 @@ ohos_shared_library("distributed_camera_data_process") { "include/pipeline_node/multimedia_codec/encoder", "include/pipeline_node/colorspace_conversion", "include/pipeline_node/fpscontroller", + "include/pipeline_node/scale_conversion", "${common_path}/include/constants", "${common_path}/include/utils", "${innerkits_path}/native_cpp/camera_source/include", @@ -54,6 +54,7 @@ ohos_shared_library("distributed_camera_data_process") { "src/pipeline_node/multimedia_codec/decoder/decode_surface_listener.cpp", "src/pipeline_node/multimedia_codec/decoder/decode_video_callback.cpp", "src/pipeline_node/multimedia_codec/encoder/encode_video_callback.cpp", + "src/pipeline_node/scale_conversion/scale_convert_process.cpp", "src/utils/image_common_type.cpp", ] @@ -86,9 +87,11 @@ ohos_shared_library("distributed_camera_data_process") { "eventhandler:libeventhandler", "hitrace_native:hitrace_meter", "hiviewdfx_hilog_native:libhilog", - "multimedia_media_standard:media_client", + "multimedia_player_framework:media_client", ] + public_deps = [ "//third_party/ffmpeg:libohosffmpeg" ] + subsystem_name = "distributedhardware" part_name = "distributed_camera" -- Gitee