From 35ea7bc4cf50bbe2e0cef5f71b82842ab0dff452 Mon Sep 17 00:00:00 2001 From: Tome Date: Wed, 2 Jul 2025 19:31:45 +0800 Subject: [PATCH] modify log, modify ut Signed-off-by: Tome --- .../utils/dcamera_buffer_handle_test.cpp | 4 +- .../camera_source/src/dcamera_hdf_operate.cpp | 2 +- .../dcamera_source_dev.cpp | 4 +- ...mera_stream_data_process_producer_test.cpp | 6 +-- .../distributed_camera_allconnect_manager.cpp | 6 +-- .../channel/src/dcamera_softbus_adapter.cpp | 15 ++++---- .../channel/src/dcamera_softbus_session.cpp | 38 ++++++++++--------- .../decoder/decode_data_process.cpp | 5 ++- .../decoder/decode_data_process_common.cpp | 5 ++- .../dcamera_client_demo.cpp | 11 ++++-- 10 files changed, 53 insertions(+), 43 deletions(-) diff --git a/common/test/unittest/common/utils/dcamera_buffer_handle_test.cpp b/common/test/unittest/common/utils/dcamera_buffer_handle_test.cpp index 991456d1..5cf29c0a 100644 --- a/common/test/unittest/common/utils/dcamera_buffer_handle_test.cpp +++ b/common/test/unittest/common/utils/dcamera_buffer_handle_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Copyright (c) 2022-2025 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 @@ -63,6 +63,7 @@ HWTEST_F(DcameraBufferHandleTest, DCameraMemoryMap_001, TestSize.Level1) BufferHandle *handle = new BufferHandle(); void* viraddr = DCameraMemoryMap(handle); EXPECT_EQ(nullptr, viraddr); + delete handle; } /** @@ -76,6 +77,7 @@ HWTEST_F(DcameraBufferHandleTest, DCameraMemoryUnmap_001, TestSize.Level1) BufferHandle *handle = new BufferHandle(); DCameraMemoryUnmap(handle); EXPECT_EQ(nullptr, handle->virAddr); + delete handle; } /** * @tc.name: DCameraMemoryMap_002 diff --git a/interfaces/inner_kits/native_cpp/camera_source/src/dcamera_hdf_operate.cpp b/interfaces/inner_kits/native_cpp/camera_source/src/dcamera_hdf_operate.cpp index ed47e2ba..cb3ebe56 100644 --- a/interfaces/inner_kits/native_cpp/camera_source/src/dcamera_hdf_operate.cpp +++ b/interfaces/inner_kits/native_cpp/camera_source/src/dcamera_hdf_operate.cpp @@ -280,7 +280,7 @@ int32_t DCameraHdfOperate::MakeFwkDCameraHdfCallback() { std::lock_guard locker(fwkDCameraHdfCallbackMutex_); if (fwkDCameraHdfCallback_ == nullptr) { - fwkDCameraHdfCallback_ = new FwkDCameraHdfCallback(); + fwkDCameraHdfCallback_ = OHOS::sptr(new FwkDCameraHdfCallback()); if (fwkDCameraHdfCallback_ == nullptr) { return DCAMERA_BAD_VALUE; } diff --git a/services/cameraservice/sourceservice/src/distributedcameramgr/dcamera_source_dev.cpp b/services/cameraservice/sourceservice/src/distributedcameramgr/dcamera_source_dev.cpp index 595e2e7b..dcf91a8a 100644 --- a/services/cameraservice/sourceservice/src/distributedcameramgr/dcamera_source_dev.cpp +++ b/services/cameraservice/sourceservice/src/distributedcameramgr/dcamera_source_dev.cpp @@ -337,7 +337,7 @@ int32_t DCameraSourceDev::Register(std::shared_ptr& param) DCAMERA_SYNC_TRACE(DCAMERA_REGISTER_CAMERA); DHLOGI("DCameraSourceDev Execute Register devId: %{public}s dhId: %{public}s", GetAnonyString(devId_).c_str(), GetAnonyString(dhId_).c_str()); - ReportRegisterCameraEvent(REGIST_CAMERA_EVENT, GetAnonyString(devId_), dhId_, + ReportRegisterCameraEvent(REGIST_CAMERA_EVENT, GetAnonyString(devId_), GetAnonyString(dhId_), version_, "execute register event."); std::vector actualDevInfo; actualDevInfo.assign(actualDevInfo_.begin(), actualDevInfo_.end()); @@ -425,7 +425,7 @@ int32_t DCameraSourceDev::UnRegister(std::shared_ptr& param) DCAMERA_SYNC_TRACE(DCAMERA_UNREGISTER_CAMERA); DHLOGI("DCameraSourceDev Execute UnRegister devId: %{public}s dhId: %{public}s", GetAnonyString(devId_).c_str(), GetAnonyString(dhId_).c_str()); - ReportRegisterCameraEvent(UNREGIST_CAMERA_EVENT, GetAnonyString(devId_), dhId_, + ReportRegisterCameraEvent(UNREGIST_CAMERA_EVENT, GetAnonyString(devId_), GetAnonyString(dhId_), version_, "execute unregister event."); int32_t ret = controller_->UnInit(); if (ret != DCAMERA_OK) { diff --git a/services/cameraservice/sourceservice/test/unittest/common/distributedcameramgr/dcamera_stream_data_process_producer_test.cpp b/services/cameraservice/sourceservice/test/unittest/common/distributedcameramgr/dcamera_stream_data_process_producer_test.cpp index 6d4a44a9..bb6fe7c5 100644 --- a/services/cameraservice/sourceservice/test/unittest/common/distributedcameramgr/dcamera_stream_data_process_producer_test.cpp +++ b/services/cameraservice/sourceservice/test/unittest/common/distributedcameramgr/dcamera_stream_data_process_producer_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2024 Huawei Device Co., Ltd. + * Copyright (c) 2022-2025 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 @@ -216,8 +216,8 @@ HWTEST_F(DCameraStreamDataProcessProducerTest, dcamera_stream_data_process_produ sharedMemory.bufferHandle_ = sptr(new NativeBuffer()); ret = streamProcess1->CheckSharedMemory(sharedMemory, buffer); ret = streamProcess2->CheckSharedMemory(sharedMemory, buffer); - BufferHandle *bufferHandle = new BufferHandle(); - sharedMemory.bufferHandle_ = sptr(new NativeBuffer(bufferHandle)); + auto bufferHandle = std::make_unique(); + sharedMemory.bufferHandle_ = sptr(new NativeBuffer(bufferHandle.get())); ret = streamProcess1->CheckSharedMemory(sharedMemory, buffer); ret = streamProcess2->CheckSharedMemory(sharedMemory, buffer); DHBase dhBase; diff --git a/services/channel/src/allconnect/distributed_camera_allconnect_manager.cpp b/services/channel/src/allconnect/distributed_camera_allconnect_manager.cpp index 456288ed..cd01addb 100644 --- a/services/channel/src/allconnect/distributed_camera_allconnect_manager.cpp +++ b/services/channel/src/allconnect/distributed_camera_allconnect_manager.cpp @@ -1,5 +1,5 @@ /* -* Copyright (c) 2024 Huawei Device Co., Ltd. +* Copyright (c) 2024-2025 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 @@ -14,7 +14,7 @@ */ #include "distributed_camera_allconnect_manager.h" - +#include "anonymous_string.h" #include #include #include @@ -256,7 +256,7 @@ int32_t DCameraAllConnectManager::ApplyResult(int32_t errorcode, int32_t result, int32_t DCameraAllConnectManager::OnStop(const char *peerNetworkId) { - DHLOGI("DCamera allconnect OnStop begin peerNetworkId:%{public}s", peerNetworkId); + DHLOGI("DCamera allconnect OnStop begin peerNetworkId:%{public}s", GetAnonyString(peerNetworkId).c_str()); DCameraSoftbusAdapter::GetInstance().CloseSessionWithNetWorkId(peerNetworkId); return DistributedCameraErrno::DCAMERA_OK; diff --git a/services/channel/src/dcamera_softbus_adapter.cpp b/services/channel/src/dcamera_softbus_adapter.cpp index 673a95f8..eaccfb3e 100644 --- a/services/channel/src/dcamera_softbus_adapter.cpp +++ b/services/channel/src/dcamera_softbus_adapter.cpp @@ -135,14 +135,15 @@ DCameraSoftbusAdapter::~DCameraSoftbusAdapter() void DCameraSoftbusAdapter::ReplaceSuffix(std::string &mySessNmRep, const std::string &suffix, const std::string &replacement) { - DHLOGI("replacing suffix in mySessionName: %{public}s", mySessNmRep.c_str()); + DHLOGI("replacing suffix in mySessionName: %{public}s", GetAnonyString(mySessNmRep).c_str()); bool isModified = false; if (mySessNmRep.length() >= suffix.length() && mySessNmRep.compare(mySessNmRep.length() - suffix.length(), suffix.length(), suffix) == 0) { mySessNmRep.replace(mySessNmRep.length() - suffix.length(), suffix.length(), replacement); isModified = true; } - DHLOGI("suffix replaced? %{public}s - Modified: %{public}s", isModified ? "Y" : "N", mySessNmRep.c_str()); + DHLOGI("suffix replaced? %{public}s - Modified: %{public}s", + isModified ? "Y" : "N", GetAnonyString(mySessNmRep).c_str()); } int32_t DCameraSoftbusAdapter::CreatSoftBusSinkSocketServer(std::string mySessionName, DCAMERA_CHANNEL_ROLE role, @@ -245,7 +246,7 @@ int32_t DCameraSoftbusAdapter::CreateSoftBusSourceSocketClient(std::string myDhI DCameraAllConnectManager::SetSourceNetworkId(peerDevId, sourceSocketId_); } DHLOGI("DCamera allconnect create socket client publish scm connected success, dhId: %{public}s", - myDhId.c_str()); + GetAnonyString(myDhId).c_str()); DHLOGI("create socket client end, myDevId: %{public}s, peerSessionName: %{public}s", GetAnonyString(myDevId).c_str(), GetAnonyString(peerSessionName).c_str()); return socketId; @@ -368,7 +369,7 @@ int32_t DCameraSoftbusAdapter::SourceOnBind(int32_t socket, PeerSocketInfo info) DHLOGE("DCamera allconnect sourceonBind publish scm connected failed, ret: %{public}d", ret); } DHLOGI("DCamera allconnect sourceonBind publish scm connected success, dhId: %{public}s", - session->GetMyDhId().c_str()); + GetAnonyString(session->GetMyDhId()).c_str()); DCameraAllConnectManager::SetSourceNetworkId(info.networkId, socket); } DHLOGI("source bind socket end, socket: %{public}d end", socket); @@ -598,7 +599,7 @@ int32_t DCameraSoftbusAdapter::SinkOnBind(int32_t socket, PeerSocketInfo info) DHLOGE("DCamera allconnect sink on bind, publish service state failed %{public}d", ret); } DHLOGI("DCamera allconnect sink on bind publish scm connected success, dhId: %{public}s", - session->GetMyDhId().c_str()); + GetAnonyString(session->GetMyDhId()).c_str()); DCameraAllConnectManager::SetSinkNetWorkId(info.networkId, socket); } DHLOGI("sink bind socket end, socket: %{public}d", socket); @@ -661,7 +662,7 @@ void DCameraSoftbusAdapter::SinkOnShutDown(int32_t socket, ShutdownReason reason } } DHLOGI("DCamera allconnect sinkdown publish scm idle success, dhId: %{public}s", - session->GetMyDhId().c_str()); + GetAnonyString(session->GetMyDhId()).c_str()); DCameraAllConnectManager::RemoveSinkNetworkId(socket); } @@ -774,7 +775,7 @@ void DCameraSoftbusAdapter::CloseSessionWithNetWorkId(const std::string &network DHLOGE("DCamera allconnect CloseSessionWithNetworkId publish service state failed"); } DHLOGI("DCamera allconnect close session publish scm idle success, dhId: %{public}s", - session->GetMyDhId().c_str()); + GetAnonyString(session->GetMyDhId()).c_str()); } } diff --git a/services/channel/src/dcamera_softbus_session.cpp b/services/channel/src/dcamera_softbus_session.cpp index c8b434c6..62fe11ba 100644 --- a/services/channel/src/dcamera_softbus_session.cpp +++ b/services/channel/src/dcamera_softbus_session.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2024 Huawei Device Co., Ltd. + * Copyright (c) 2021-2025 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 @@ -137,7 +137,7 @@ void DCameraSoftbusSession::PackRecvData(std::shared_ptr& buffer) if (buffer->Size() < BINARY_HEADER_FRAG_LEN) { bufferSize = static_cast(buffer->Size()); DHLOGE("pack recv data error, size: %{public}" PRIu64", sess: %{public}s peerSess: %{public}s", - bufferSize, mySessionName_.c_str(), peerSessionName_.c_str()); + bufferSize, GetAnonyString(mySessionName_).c_str(), GetAnonyString(peerSessionName_).c_str()); return; } uint8_t *ptrPacket = buffer->Data(); @@ -148,7 +148,7 @@ void DCameraSoftbusSession::PackRecvData(std::shared_ptr& buffer) bufferSize = static_cast(buffer->Size()); DHLOGE("pack recv data failed, size: %{public}" PRIu64", dataLen: %{public}d, totalLen: %{public}d sess: " "%{public}s peerSess: %{public}s", bufferSize, headerPara.dataLen, headerPara.totalLen, - mySessionName_.c_str(), peerSessionName_.c_str()); + GetAnonyString(mySessionName_).c_str(), GetAnonyString(peerSessionName_).c_str()); return; } bufferSize = static_cast(buffer->Size()); @@ -168,8 +168,9 @@ void DCameraSoftbusSession::AssembleNoFrag(std::shared_ptr& buffer, { if (headerPara.dataLen != headerPara.totalLen) { DHLOGE("DCameraSoftbusSession PackRecvData failed, dataLen: %{public}d, totalLen: %{public}d, sess: " - "%{public}s peerSess: %{public}s", headerPara.dataLen, headerPara.totalLen, mySessionName_.c_str(), - peerSessionName_.c_str()); + "%{public}s peerSess: %{public}s", + headerPara.dataLen, headerPara.totalLen, GetAnonyString(mySessionName_).c_str(), + GetAnonyString(peerSessionName_).c_str()); return; } if (buffer == nullptr) { @@ -181,7 +182,7 @@ void DCameraSoftbusSession::AssembleNoFrag(std::shared_ptr& buffer, buffer->Size() - BINARY_HEADER_FRAG_LEN); if (ret != EOK) { DHLOGE("DCameraSoftbusSession PackRecvData failed, ret: %{public}d, sess: %{public}s peerSess: %{public}s", - ret, mySessionName_.c_str(), peerSessionName_.c_str()); + ret, GetAnonyString(mySessionName_).c_str(), GetAnonyString(peerSessionName_).c_str()); return; } PostData(postData); @@ -204,7 +205,7 @@ void DCameraSoftbusSession::AssembleFrag(std::shared_ptr& buffer, Se buffer->Size() - BINARY_HEADER_FRAG_LEN); if (ret != EOK) { DHLOGE("DCameraSoftbusSession AssembleFrag failed, ret: %{public}d, sess: %{public}s peerSess: %{public}s", - ret, mySessionName_.c_str(), peerSessionName_.c_str()); + ret, GetAnonyString(mySessionName_).c_str(), GetAnonyString(peerSessionName_).c_str()); ResetAssembleFrag(); return; } @@ -223,7 +224,7 @@ void DCameraSoftbusSession::AssembleFrag(std::shared_ptr& buffer, Se buffer->Data() + BINARY_HEADER_FRAG_LEN, buffer->Size() - BINARY_HEADER_FRAG_LEN); if (ret != EOK) { DHLOGE("DCameraSoftbusSession AssembleFrag failed, memcpy_s ret: %{public}d, sess: %{public}s peerSess: " - "%{public}s", ret, mySessionName_.c_str(), peerSessionName_.c_str()); + "%{public}s", ret, GetAnonyString(mySessionName_).c_str(), GetAnonyString(peerSessionName_).c_str()); ResetAssembleFrag(); return; } @@ -240,28 +241,29 @@ int32_t DCameraSoftbusSession::CheckUnPackBuffer(SessionDataHeader& headerPara) { if (!isWaiting_) { DHLOGE("DCameraSoftbusSession AssembleFrag failed, not start one, sess: %{public}s peerSess: %{public}s", - mySessionName_.c_str(), peerSessionName_.c_str()); + GetAnonyString(mySessionName_).c_str(), GetAnonyString(peerSessionName_).c_str()); return DCAMERA_BAD_VALUE; } if (nowSeq_ != headerPara.seqNum) { DHLOGE("DCameraSoftbusSession AssembleFrag seq error nowSeq: %{public}d actualSeq: %{public}d, sess: " - "%{public}s peerSess: %{public}s", nowSeq_, headerPara.seqNum, mySessionName_.c_str(), - peerSessionName_.c_str()); + "%{public}s peerSess: %{public}s", nowSeq_, headerPara.seqNum, GetAnonyString(mySessionName_).c_str(), + GetAnonyString(peerSessionName_).c_str()); return DCAMERA_BAD_VALUE; } if (nowSubSeq_ + 1 != headerPara.subSeq) { DHLOGE("DCameraSoftbusSession AssembleFrag subSeq error nowSeq: %{public}d actualSeq: %{public}d, " - "sess: %{public}s peerSess: %{public}s", nowSubSeq_, headerPara.subSeq, mySessionName_.c_str(), - peerSessionName_.c_str()); + "sess: %{public}s peerSess: %{public}s", + nowSubSeq_, headerPara.subSeq, GetAnonyString(mySessionName_).c_str(), + GetAnonyString(peerSessionName_).c_str()); return DCAMERA_BAD_VALUE; } if (totalLen_ < headerPara.dataLen + offset_) { DHLOGE("DCameraSoftbusSession AssembleFrag len error cap: %{public}d size: %{public}d, dataLen: " "%{public}d sess: %{public}s peerSess: %{public}s", totalLen_, offset_, headerPara.dataLen, - mySessionName_.c_str(), peerSessionName_.c_str()); + GetAnonyString(mySessionName_).c_str(), GetAnonyString(peerSessionName_).c_str()); return DCAMERA_BAD_VALUE; } return DCAMERA_OK; @@ -368,8 +370,8 @@ int32_t DCameraSoftbusSession::UnPackSendData(std::shared_ptr& buffe int32_t ret = memcpy_s(unpackData->Data() + BINARY_HEADER_FRAG_LEN, unpackData->Size() - BINARY_HEADER_FRAG_LEN, buffer->Data(), buffer->Size()); if (ret != EOK) { - DHLOGE("DCameraSoftbusSession UnPackSendData START_END memcpy_s failed, ret: %{public}d, sess: %{public}s " - "peerSess: %{public}s", ret, mySessionName_.c_str(), peerSessionName_.c_str()); + DHLOGE("UnPackSendData START_END memcpy_s failed, ret: %{public}d, sess: %{public}s peerSess: %{public}s", + ret, GetAnonyString(mySessionName_).c_str(), GetAnonyString(peerSessionName_).c_str()); return ret; } return SendBytes(unpackData); @@ -387,13 +389,13 @@ int32_t DCameraSoftbusSession::UnPackSendData(std::shared_ptr& buffe buffer->Data() + offset, headPara.dataLen); if (ret != EOK) { DHLOGE("DCameraSoftbusSession UnPackSendData memcpy_s failed, ret: %{public}d, sess: %{public}s peerSess: " - "%{public}s", ret, mySessionName_.c_str(), peerSessionName_.c_str()); + "%{public}s", ret, GetAnonyString(mySessionName_).c_str(), GetAnonyString(peerSessionName_).c_str()); return ret; } ret = SendBytes(unpackData); if (ret != DCAMERA_OK) { DHLOGE("DCameraSoftbusSession sendData failed, ret: %{public}d, sess: %{public}s peerSess: %{public}s", - ret, mySessionName_.c_str(), peerSessionName_.c_str()); + ret, GetAnonyString(mySessionName_).c_str(), GetAnonyString(peerSessionName_).c_str()); return ret; } DHLOGD("DCameraSoftbusSession UnPackSendData, size: %" PRIu64", dataLen: %{public}d, totalLen: %{public}d, " diff --git a/services/data_process/src/pipeline_node/multimedia_codec/decoder/decode_data_process.cpp b/services/data_process/src/pipeline_node/multimedia_codec/decoder/decode_data_process.cpp index 7c87f4fb..50ec3293 100644 --- a/services/data_process/src/pipeline_node/multimedia_codec/decoder/decode_data_process.cpp +++ b/services/data_process/src/pipeline_node/multimedia_codec/decoder/decode_data_process.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2024 Huawei Device Co., Ltd. + * Copyright (c) 2022-2025 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 @@ -211,7 +211,8 @@ int32_t DecodeDataProcess::SetDecoderOutputSurface() SurfaceBufferUsage::BUFFER_USAGE_CPU_READ); CHECK_AND_LOG(ret != GSERROR_OK || decodeConsumerSurface_ == nullptr, "%{public}s", "Set Usage failed."); - decodeSurfaceListener_ = new DecodeSurfaceListener(decodeConsumerSurface_, shared_from_this()); + decodeSurfaceListener_ = + OHOS::sptr(new DecodeSurfaceListener(decodeConsumerSurface_, shared_from_this())); if (decodeConsumerSurface_->RegisterConsumerListener(decodeSurfaceListener_) != SURFACE_ERROR_OK) { DHLOGE("Register consumer listener failed."); diff --git a/services/data_process/src/pipeline_node/multimedia_codec/decoder/decode_data_process_common.cpp b/services/data_process/src/pipeline_node/multimedia_codec/decoder/decode_data_process_common.cpp index fdbb0c43..215338ab 100644 --- a/services/data_process/src/pipeline_node/multimedia_codec/decoder/decode_data_process_common.cpp +++ b/services/data_process/src/pipeline_node/multimedia_codec/decoder/decode_data_process_common.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2024 Huawei Device Co., Ltd. + * Copyright (c) 2022-2025 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 @@ -243,7 +243,8 @@ int32_t DecodeDataProcess::SetDecoderOutputSurface() DHLOGE("Set Usage failed."); } - decodeSurfaceListener_ = new DecodeSurfaceListener(decodeConsumerSurface_, shared_from_this()); + decodeSurfaceListener_ = + OHOS::sptr(new DecodeSurfaceListener(decodeConsumerSurface_, shared_from_this())); if (decodeConsumerSurface_->RegisterConsumerListener(decodeSurfaceListener_) != SURFACE_ERROR_OK) { DHLOGE("Register consumer listener failed."); diff --git a/test/distributedcameraclienttest/dcamera_client_demo.cpp b/test/distributedcameraclienttest/dcamera_client_demo.cpp index 9a824869..c56eeeb3 100644 --- a/test/distributedcameraclienttest/dcamera_client_demo.cpp +++ b/test/distributedcameraclienttest/dcamera_client_demo.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2023-2025 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 @@ -156,7 +156,8 @@ void InitPhotoOutput(void) DHLOGI("Distributed Camera Demo: Create PhotoOutput, width = %{public}d, height = %{public}d, format = %{public}d", g_photoInfo->width_, g_photoInfo->height_, g_photoInfo->format_); sptr photoSurface = IConsumerSurface::Create(); - sptr photoListener = new DemoDCameraPhotoSurfaceListener(photoSurface); + sptr photoListener = + OHOS::sptr(new DemoDCameraPhotoSurfaceListener(photoSurface)); photoSurface->RegisterConsumerListener(photoListener); CameraFormat photoFormat = ConvertToCameraFormat(g_photoInfo->format_); Size photoSize = {g_photoInfo->width_, g_photoInfo->height_}; @@ -175,7 +176,8 @@ void InitPreviewOutput(void) DHLOGI("Distributed Camera Demo: Create PreviewOutput, width = %{public}d, height = %{public}d, format = " "%{public}d", g_previewInfo->width_, g_previewInfo->height_, g_previewInfo->format_); sptr previewSurface = IConsumerSurface::Create(); - sptr previewListener = new DemoDCameraPreviewSurfaceListener(previewSurface); + sptr previewListener = + OHOS::sptr(new DemoDCameraPreviewSurfaceListener(previewSurface)); previewSurface->RegisterConsumerListener(previewListener); CameraFormat previewFormat = ConvertToCameraFormat(g_previewInfo->format_); Size previewSize = {g_previewInfo->width_, g_previewInfo->height_}; @@ -196,7 +198,8 @@ void InitVideoOutput(void) DHLOGI("Distributed Camera Demo: Create VideoOutput, width = %{public}d, height = %{public}d, format = %{public}d", g_videoInfo->width_, g_videoInfo->height_, g_videoInfo->format_); sptr videoSurface = IConsumerSurface::Create(); - sptr videoListener = new DemoDCameraVideoSurfaceListener(videoSurface); + sptr videoListener = + OHOS::sptr(new DemoDCameraVideoSurfaceListener(videoSurface)); videoSurface->RegisterConsumerListener(videoListener); CameraFormat videoFormat = ConvertToCameraFormat(g_videoInfo->format_); Size videoSize = {g_videoInfo->width_, g_videoInfo->height_}; -- Gitee