From a57f6bd213dc1e1fa8ef72539c04bfd64a4a8e05 Mon Sep 17 00:00:00 2001 From: gaoqiang_strong Date: Fri, 18 Mar 2022 09:44:06 +0800 Subject: [PATCH] Rectification code Signed-off-by: gaoqiang_strong --- .../screen_sink/src/dscreen_sink_handler.cpp | 20 ++++++------- .../src/dscreen_source_handler.cpp | 20 ++++++------- screenhandler/src/dscreen_handler.cpp | 2 +- .../screenregionmgr/src/screenregion.cpp | 14 ++++++---- .../screenregionmgr/src/screenregionmgr.cpp | 4 +-- .../dscreenmgr/include/dscreen.h | 2 ++ .../sourceservice/dscreenmgr/src/dscreen.cpp | 22 ++++++++------- .../dscreenmgr/src/dscreen_manager.cpp | 16 +++++------ .../dscreenmgr/src/screen_manager_adapter.cpp | 4 +++ .../src/screen_data_channel_impl.cpp | 12 ++++---- .../decoder/src/image_sink_decoder.cpp | 16 +++++------ .../screensinktrans/src/screen_sink_trans.cpp | 28 +++++++++---------- .../encoder/src/image_source_encoder.cpp | 18 ++++++------ .../src/image_source_processor.cpp | 8 +++--- .../src/screen_source_trans.cpp | 28 +++++++++---------- .../softbusadapter/src/softbus_adapter.cpp | 8 +++--- 16 files changed, 117 insertions(+), 105 deletions(-) diff --git a/interfaces/innerkits/native_cpp/screen_sink/src/dscreen_sink_handler.cpp b/interfaces/innerkits/native_cpp/screen_sink/src/dscreen_sink_handler.cpp index 8f4472cc..d9f41df3 100644 --- a/interfaces/innerkits/native_cpp/screen_sink/src/dscreen_sink_handler.cpp +++ b/interfaces/innerkits/native_cpp/screen_sink/src/dscreen_sink_handler.cpp @@ -30,7 +30,7 @@ DScreenSinkHandler::DScreenSinkHandler() { DHLOGI("DScreenSinkHandler construct."); std::lock_guard lock(mutex_); - if (!sinkSvrRecipient_) { + if (sinkSvrRecipient_ == nullptr) { sinkSvrRecipient_ = new DScreenSinkSvrRecipient(); } } @@ -45,22 +45,22 @@ int32_t DScreenSinkHandler::InitSink(const std::string ¶ms) DHLOGD("InitSink"); std::lock_guard lock(mutex_); - if (!dScreenSinkProxy_) { + if (dScreenSinkProxy_ == nullptr) { sptr samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); - if (!samgr) { + if (samgr == nullptr) { DHLOGE("Failed to get system ability mgr."); return ERR_DH_SCREEN_SA_GET_SAMGR_FAIL; } sptr remoteObject = samgr->GetSystemAbility(DISTRIBUTED_HARDWARE_SCREEN_SINK_SA_ID); - if (!remoteObject) { + if (remoteObject == nullptr) { DHLOGE("Failed to get dscreen sink service."); return ERR_DH_SCREEN_SA_GET_SINKSERVICE_FAIL; } remoteObject->AddDeathRecipient(sinkSvrRecipient_); dScreenSinkProxy_ = iface_cast(remoteObject); - if ((!dScreenSinkProxy_) || (!dScreenSinkProxy_->AsObject())) { + if ((dScreenSinkProxy_== nullptr) || (dScreenSinkProxy_->AsObject() == nullptr)) { DHLOGE("Failed to get dscreen sink proxy."); return ERR_DH_SCREEN_SA_GET_SINKPROXY_FAIL; } @@ -73,7 +73,7 @@ int32_t DScreenSinkHandler::ReleaseSink() { DHLOGD("ReleaseSink"); std::lock_guard lock(mutex_); - if (!dScreenSinkProxy_) { + if (dScreenSinkProxy_ == nullptr) { DHLOGE("screen sink proxy not init."); return ERR_DH_SCREEN_SA_SINKPROXY_NOT_INIT; } @@ -86,7 +86,7 @@ int32_t DScreenSinkHandler::SubscribeLocalHardware(const std::string &dhId, cons { DHLOGD("SubscribeLocalHardware"); std::lock_guard lock(mutex_); - if (!dScreenSinkProxy_) { + if (dScreenSinkProxy_ == nullptr) { DHLOGE("screen sink proxy not init."); return ERR_DH_SCREEN_SA_SINKPROXY_NOT_INIT; } @@ -98,7 +98,7 @@ int32_t DScreenSinkHandler::UnsubscribeLocalHardware(const std::string &dhId) { DHLOGD("UnsubscribeLocalHardware"); std::lock_guard lock(mutex_); - if (!dScreenSinkProxy_) { + if (dScreenSinkProxy_ == nullptr) { DHLOGE("screen sink proxy not init."); return ERR_DH_SCREEN_SA_SINKPROXY_NOT_INIT; } @@ -116,12 +116,12 @@ void DScreenSinkHandler::OnRemoteSinkSvrDied(const wptr &remote) { DHLOGI("OnRemoteSinkSvrDied"); sptr remoteObject = remote.promote(); - if (!remoteObject) { + if (remoteObject == nullptr) { DHLOGE("OnRemoteDied remote promoted failed"); return; } std::lock_guard lock(mutex_); - if (!dScreenSinkProxy_) { + if (dScreenSinkProxy_ == nullptr) { dScreenSinkProxy_->AsObject()->RemoveDeathRecipient(sinkSvrRecipient_); dScreenSinkProxy_ = nullptr; } diff --git a/interfaces/innerkits/native_cpp/screen_source/src/dscreen_source_handler.cpp b/interfaces/innerkits/native_cpp/screen_source/src/dscreen_source_handler.cpp index ed5e3c0f..bf6066c4 100644 --- a/interfaces/innerkits/native_cpp/screen_source/src/dscreen_source_handler.cpp +++ b/interfaces/innerkits/native_cpp/screen_source/src/dscreen_source_handler.cpp @@ -31,11 +31,11 @@ DScreenSourceHandler::DScreenSourceHandler() { DHLOGI("DScreenSourceHandler construct."); std::lock_guard lock(mutex_); - if (!sourceSvrRecipient_) { + if (sourceSvrRecipient_ == nullptr) { sourceSvrRecipient_ = new DScreenSourceSvrRecipient(); } - if (!dScreenSourceCallback_) { + if (dScreenSourceCallback_ == nullptr) { dScreenSourceCallback_ = new DScreenSourceCallback(); } } @@ -50,7 +50,7 @@ int32_t DScreenSourceHandler::InitSource(const std::string ¶ms) DHLOGD("InitSource"); std::lock_guard lock(mutex_); - if (!dScreenSourceProxy_) { + if (dScreenSourceProxy_ == nullptr) { sptr samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); if (!samgr) { @@ -79,7 +79,7 @@ int32_t DScreenSourceHandler::ReleaseSource() { DHLOGD("ReleaseSource"); std::lock_guard lock(mutex_); - if (!dScreenSourceProxy_) { + if (dScreenSourceProxy_ == nullptr) { DHLOGE("screen source proxy not init."); return ERR_DH_SCREEN_SA_SOURCEPROXY_NOT_INIT; } @@ -93,11 +93,11 @@ int32_t DScreenSourceHandler::RegisterDistributedHardware(const std::string &dev DHLOGD("RegisterDistributedHardware, devId: %s, dhId: %s", GetAnonyString(devId).c_str(), GetAnonyString(dhId).c_str()); std::lock_guard lock(mutex_); - if (!dScreenSourceProxy_) { + if (dScreenSourceProxy_ == nullptr) { DHLOGE("screen source proxy not init."); return ERR_DH_SCREEN_SA_SOURCEPROXY_NOT_INIT; } - if (!dScreenSourceCallback_) { + if (dScreenSourceCallback_ == nullptr) { DHLOGE("screen source callback is null."); return ERR_DH_SCREEN_SA_SOURCEPCALLBACK_NOT_INIT; } @@ -114,11 +114,11 @@ int32_t DScreenSourceHandler::UnregisterDistributedHardware(const std::string &d DHLOGD("UnregisterDistributedHardware, devId: %s, dhId: %s", GetAnonyString(devId).c_str(), GetAnonyString(dhId).c_str()); std::lock_guard lock(mutex_); - if (!dScreenSourceProxy_) { + if (dScreenSourceProxy_ == nullptr) { DHLOGE("screen source proxy not init."); return ERR_DH_SCREEN_SA_SOURCEPROXY_NOT_INIT; } - if (!dScreenSourceCallback_) { + if (dScreenSourceCallback_ == nullptr) { DHLOGE("screen source callback is null."); return ERR_DH_SCREEN_SA_SOURCEPCALLBACK_NOT_INIT; } @@ -146,12 +146,12 @@ void DScreenSourceHandler::OnRemoteSourceSvrDied(const wptr &remo { DHLOGI("OnRemoteSourceSvrDied"); sptr remoteObject = remote.promote(); - if (!remoteObject) { + if (remoteObject == nullptr) { DHLOGE("OnRemoteDied remote promoted failed"); return; } std::lock_guard lock(mutex_); - if (!dScreenSourceProxy_) { + if (dScreenSourceProxy_ == nullptr) { dScreenSourceProxy_->AsObject()->RemoveDeathRecipient(sourceSvrRecipient_); dScreenSourceProxy_ = nullptr; } diff --git a/screenhandler/src/dscreen_handler.cpp b/screenhandler/src/dscreen_handler.cpp index 1f632682..ed384e44 100644 --- a/screenhandler/src/dscreen_handler.cpp +++ b/screenhandler/src/dscreen_handler.cpp @@ -45,7 +45,7 @@ DScreenHandler::~DScreenHandler() int32_t DScreenHandler::Initialize() { DHLOGI("DScreenHandler Initialize"); - if (!screenListener_) { + if (screenListener_ == nullptr) { screenListener_ = new ScreenListener(); } bool ret = Rosen::ScreenManager::GetInstance().RegisterScreenListener(screenListener_); diff --git a/services/screenservice/sinkservice/screenregionmgr/src/screenregion.cpp b/services/screenservice/sinkservice/screenregionmgr/src/screenregion.cpp index 9fdf73b1..770ad316 100644 --- a/services/screenservice/sinkservice/screenregionmgr/src/screenregion.cpp +++ b/services/screenservice/sinkservice/screenregionmgr/src/screenregion.cpp @@ -37,7 +37,7 @@ ScreenRegion::ScreenRegion(const std::string &remoteDevId, uint64_t screenId, ui ScreenRegion::~ScreenRegion() { DHLOGD("ScreenRegion deConstruct"); - if (!sinkTrans_) { + if (sinkTrans_ == nullptr) { sinkTrans_->Release(); } } @@ -78,6 +78,10 @@ int32_t ScreenRegion::SetUp() DHLOGI("ScreenRegion::SetUp, remoteDevId: %s", GetAnonyString(remoteDevId_).c_str()); std::shared_ptr windowProperty = std::make_shared(); + if (windowProperty == nullptr) { + DHLOGE("windowProperty is nullptr."); + return ERR_DH_SCREEN_SA_DSCREEN_SCREENGION_SETUP_FAILED; + } windowProperty->displayId = displayId_; ScreenRect screenRect = mapRelation_->GetScreenRect(); @@ -98,14 +102,14 @@ int32_t ScreenRegion::SetUp() } sptr surface = ScreenClient::GetInstance().GetSurface(windowId_); - if (!surface) { + if (surface == nullptr) { DHLOGE("get window surface failed."); return ERR_DH_SCREEN_SA_DSCREEN_SCREENGION_SETUP_FAILED; } surface_ = surface; - if (!sinkTrans_) { + if (sinkTrans_ == nullptr) { sinkTrans_ = std::make_shared(); } @@ -123,7 +127,7 @@ int32_t ScreenRegion::SetUp() int32_t ScreenRegion::Start() { DHLOGI("ScreenRegion::Start remoteDevId: %s", GetAnonyString(remoteDevId_).c_str()); - if (!sinkTrans_) { + if (sinkTrans_ == nullptr) { DHLOGE("sink trans not init."); return ERR_DH_SCREEN_SA_SINKTRANS_NOT_INIT; } @@ -145,7 +149,7 @@ int32_t ScreenRegion::Stop() return DH_SUCCESS; } - if (!sinkTrans_) { + if (sinkTrans_ == nullptr) { DHLOGE("sink trans not init."); return ERR_DH_SCREEN_SA_SINKTRANS_NOT_INIT; } diff --git a/services/screenservice/sinkservice/screenregionmgr/src/screenregionmgr.cpp b/services/screenservice/sinkservice/screenregionmgr/src/screenregionmgr.cpp index 48457eeb..5878656e 100644 --- a/services/screenservice/sinkservice/screenregionmgr/src/screenregionmgr.cpp +++ b/services/screenservice/sinkservice/screenregionmgr/src/screenregionmgr.cpp @@ -50,7 +50,7 @@ int32_t ScreenRegionManager::ReleaseAllRegions() std::lock_guard lock(screenRegionsMtx_); for (const auto &item : screenRegions_) { std::shared_ptr screenRegion = item.second; - if (!screenRegion) { + if (screenRegion == nullptr) { continue; } int32_t ret = screenRegion->Stop(); @@ -159,7 +159,7 @@ int32_t ScreenRegionManager::NotifyRemoteScreenService(const std::string &remote DHLOGI("Notify remote source screen service, remote devId: %s, eventCode: %d", GetAnonyString(remoteDevId).c_str(), eventCode); sptr remoteSourceSA = GetDScreenSourceSA(remoteDevId); - if (!remoteSourceSA) { + if (remoteSourceSA == nullptr) { DHLOGE("get remote source sa failed."); return ERR_DH_SCREEN_SA_GET_REMOTE_SOURCE_SERVICE_FAIL; } diff --git a/services/screenservice/sourceservice/dscreenmgr/include/dscreen.h b/services/screenservice/sourceservice/dscreenmgr/include/dscreen.h index 961ef1e3..606890c6 100644 --- a/services/screenservice/sourceservice/dscreenmgr/include/dscreen.h +++ b/services/screenservice/sourceservice/dscreenmgr/include/dscreen.h @@ -97,6 +97,8 @@ private: void HandleDisable(const std::string &taskId); void HandleConnect(); void HandleDisconnect(); + int32_t InitDScreen(); + int32_t UnInitDScreen(); int32_t SetUp(); int32_t Start(); int32_t Stop(); diff --git a/services/screenservice/sourceservice/dscreenmgr/src/dscreen.cpp b/services/screenservice/sourceservice/dscreenmgr/src/dscreen.cpp index 2986ad13..d0e20a9a 100644 --- a/services/screenservice/sourceservice/dscreenmgr/src/dscreen.cpp +++ b/services/screenservice/sourceservice/dscreenmgr/src/dscreen.cpp @@ -47,7 +47,7 @@ DScreen::~DScreen() taskQueueThread_.join(); } int32_t ret = DH_SUCCESS; - if (sourceTrans_) { + if (sourceTrans_ != nullptr) { ret = sourceTrans_->Release(); } if (ret != DH_SUCCESS) { @@ -113,7 +113,7 @@ int32_t DScreen::AddTask(const std::shared_ptr &task) { DHLOGI("DScreen::AddTask, devId: %s, dhId: %s", GetAnonyString(devId_).c_str(), GetAnonyString(dhId_).c_str()); - if (!task) { + if (task == nullptr) { DHLOGE("AddTask, task is invalid."); return ERR_DH_SCREEN_SA_DSCREEN_TASK_NOT_VALID; } @@ -186,7 +186,7 @@ void DScreen::HandleEnable(const std::string ¶m, const std::string &taskId) } SetState(ENABLING); - if (!videoParam_) { + if (videoParam_ == nullptr) { videoParam_ = std::make_shared(); } @@ -207,10 +207,12 @@ void DScreen::HandleEnable(const std::string ¶m, const std::string &taskId) return; } - videoParam_->SetScreenWidth(attrJson[KEY_SCREEN_WIDTH]); - videoParam_->SetScreenHeight(attrJson[KEY_SCREEN_HEIGHT]); - videoParam_->SetVideoFormat(VIDEO_DATA_FORMAT_NV21); - videoParam_->SetCodecType(VIDEO_CODEC_TYPE_VIDEO_H264); + if (videoParam_ != nullptr) { + videoParam_->SetScreenWidth(attrJson[KEY_SCREEN_WIDTH]); + videoParam_->SetScreenHeight(attrJson[KEY_SCREEN_HEIGHT]); + videoParam_->SetVideoFormat(VIDEO_DATA_FORMAT_NV21); + videoParam_->SetCodecType(VIDEO_CODEC_TYPE_VIDEO_H264); + } uint64_t screenId = ScreenMgrAdapter::GetInstance().CreateVirtualScreen(devId_, dhId_, videoParam_); if (screenId == SCREEN_ID_INVALID) { @@ -285,7 +287,7 @@ int32_t DScreen::SetUp() DHLOGD("SetUp, devId: %s, dhId: %s", GetAnonyString(devId_).c_str(), GetAnonyString(dhId_).c_str()); - if (!sourceTrans_) { + if (sourceTrans_ == nullptr) { sourceTrans_ = std::make_shared(); } @@ -307,7 +309,7 @@ int32_t DScreen::Start() { DHLOGD("Start, devId: %s, dhId: %s", GetAnonyString(devId_).c_str(), GetAnonyString(dhId_).c_str()); - if (!sourceTrans_) { + if (sourceTrans_ == nullptr) { DHLOGE("source trans not init."); return ERR_DH_SCREEN_SA_SOURCETRANS_NOT_INIT; } @@ -324,7 +326,7 @@ int32_t DScreen::Stop() { DHLOGD("Stop, devId: %s, dhId: %s", GetAnonyString(devId_).c_str(), GetAnonyString(dhId_).c_str()); - if (!sourceTrans_) { + if (sourceTrans_ == nullptr) { DHLOGE("source trans not init."); return ERR_DH_SCREEN_SA_SOURCETRANS_NOT_INIT; } diff --git a/services/screenservice/sourceservice/dscreenmgr/src/dscreen_manager.cpp b/services/screenservice/sourceservice/dscreenmgr/src/dscreen_manager.cpp index 1b5ceb49..374a3de1 100644 --- a/services/screenservice/sourceservice/dscreenmgr/src/dscreen_manager.cpp +++ b/services/screenservice/sourceservice/dscreenmgr/src/dscreen_manager.cpp @@ -51,7 +51,7 @@ int32_t DScreenManager::Init() if (ret != DH_SUCCESS) { DHLOGE("DScreenManager Init failed, err: %d", ret); } - if (!dScreenCallback_) { + if (dScreenCallback_ == nullptr) { dScreenCallback_ = std::make_shared(); } return ret; @@ -91,7 +91,7 @@ void DScreenGroupListener::OnChange(const std::vector &screenIds, Rose for (uint64_t screenId : screenIds) { std::shared_ptr changedScreen = nullptr; changedScreen = DScreenManager::GetInstance().FindDScreenByScreenId(screenId); - if (!changedScreen) { + if (changedScreen == nullptr) { DHLOGD("screen change not about remote screen, screenId: %ulld", screenId); continue; } @@ -102,7 +102,7 @@ void DScreenGroupListener::OnChange(const std::vector &screenIds, Rose void DScreenManager::HandleScreenChange(const std::shared_ptr &changedScreen, Rosen::ScreenGroupChangeEvent event) { - if (!changedScreen) { + if (changedScreen == nullptr) { DHLOGE("DScreenManager::HandleScreenChange, dScreen is null."); return; } @@ -175,7 +175,7 @@ void DScreenManager::OnRegResult(const std::shared_ptr &dScreen, { DHLOGI("DScreenManager::OnRegResult, devId: %s, dhId: %s, reqId: %s", GetAnonyString(dScreen->GetDevId()).c_str(), GetAnonyString(dScreen->GetDHId()).c_str(), reqId.c_str()); - if (!dScreenSourceCallbackProxy_) { + if (dScreenSourceCallbackProxy_ == nullptr) { DHLOGE("dScreenSourceCallbackProxy is null"); return; } @@ -187,7 +187,7 @@ void DScreenManager::OnUnregResult(const std::shared_ptr &dScreen, { DHLOGI("DScreenManager::OnUnregResult, devId: %s, dhId: %s, reqId: %s", GetAnonyString(dScreen->GetDevId()).c_str(), GetAnonyString(dScreen->GetDHId()).c_str(), reqId.c_str()); - if (!dScreenSourceCallbackProxy_) { + if (dScreenSourceCallbackProxy_ == nullptr) { DHLOGE("dScreenSourceCallbackProxy is null"); return; } @@ -276,7 +276,7 @@ std::shared_ptr DScreenManager::FindDScreenByScreenId(uint64_t screenId std::lock_guard lock(dScreenMapMtx_); for (const auto &iter : dScreens_) { std::shared_ptr dScreen = iter.second; - if (!dScreen) { + if (dScreen == nullptr) { continue; } @@ -306,7 +306,7 @@ int32_t DScreenManager::NotifyRemoteScreenService(const std::string &devId, int3 DHLOGI("Notify remote sink screen service, remote devId: %s, eventCode: %d", GetAnonyString(devId).c_str(), eventCode); sptr remoteSinkSA = GetDScreenSinkSA(devId); - if (!remoteSinkSA) { + if (remoteSinkSA == nullptr) { DHLOGE("get remote sink sa failed."); return ERR_DH_SCREEN_SA_GET_REMOTE_SINK_SERVICE_FAIL; } @@ -325,7 +325,7 @@ sptr DScreenManager::GetDScreenSinkSA(const std::string &devId) DHLOGI("GetDScreenSinkSA, devId: %s", GetAnonyString(devId).c_str()); sptr samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); - if (!samgr) { + if (samgr == nullptr) { DHLOGE("Failed to get system ability mgr."); return nullptr; } diff --git a/services/screenservice/sourceservice/dscreenmgr/src/screen_manager_adapter.cpp b/services/screenservice/sourceservice/dscreenmgr/src/screen_manager_adapter.cpp index 4f0850bf..ed59bb1d 100644 --- a/services/screenservice/sourceservice/dscreenmgr/src/screen_manager_adapter.cpp +++ b/services/screenservice/sourceservice/dscreenmgr/src/screen_manager_adapter.cpp @@ -115,6 +115,10 @@ std::shared_ptr ScreenMgrAdapter::GetMapRelation(uint64_t sc { DHLOGI("GetMapRelation"); std::shared_ptr mapRelation = std::make_shared(); + if (mapRelation == nullptr) { + DHLOGE("mapRelation is nullptr."); + return nullptr; + } sptr screen = Rosen::ScreenManager::GetInstance().GetScreenById(screenId); sptr display = Rosen::DisplayManager::GetInstance().GetDefaultDisplay(); mapRelation->SetDisplayId(display->GetId()); diff --git a/services/screentransport/screendatachannel/src/screen_data_channel_impl.cpp b/services/screentransport/screendatachannel/src/screen_data_channel_impl.cpp index 6097c4a5..a6d46d95 100644 --- a/services/screentransport/screendatachannel/src/screen_data_channel_impl.cpp +++ b/services/screentransport/screendatachannel/src/screen_data_channel_impl.cpp @@ -27,7 +27,7 @@ namespace DistributedHardware { int32_t ScreenDataChannelImpl::CreateSession(const std::shared_ptr &listener) { DHLOGI("%s: CreateSession, peerDevId(%s)", LOG_TAG, GetAnonyString(peerDevId_).c_str()); - if (!listener) { + if (listener == nullptr) { DHLOGE("%s: Channel listener is null", LOG_TAG); return ERR_DH_SCREEN_TRANS_NULL_VALUE; } @@ -107,7 +107,7 @@ int32_t ScreenDataChannelImpl::CloseSession() int32_t ScreenDataChannelImpl::SendData(const std::shared_ptr &screenData) { DHLOGD("%s: SendData, sessionId(%d)", LOG_TAG, sessionId_); - if (!screenData) { + if (screenData == nullptr) { DHLOGE("%s: Screen data is null", LOG_TAG); return ERR_DH_SCREEN_TRANS_NULL_VALUE; } @@ -134,7 +134,7 @@ void ScreenDataChannelImpl::OnSessionOpened(int32_t sessionId, int32_t result) } std::shared_ptr listener = channelListener_.lock(); - if (!listener) { + if (listener == nullptr) { DHLOGE("%s: Channel listener is null", LOG_TAG); return; } @@ -146,7 +146,7 @@ void ScreenDataChannelImpl::OnSessionClosed(int32_t sessionId) { DHLOGI("%s: OnScreenSessionClosed, sessionId(%d).", LOG_TAG, sessionId); std::shared_ptr listener = channelListener_.lock(); - if (!listener) { + if (listener == nullptr) { DHLOGE("%s: Channel listener is null", LOG_TAG); return; } @@ -174,14 +174,14 @@ void ScreenDataChannelImpl::OnStreamReceived(int32_t sessionId, const StreamData } std::shared_ptr listener = channelListener_.lock(); - if (!listener) { + if (listener == nullptr) { DHLOGE("%s: Channel listener is null.", LOG_TAG); return; } DHLOGI("%s: OnScreenStreamReceived, sessionId(%d) dataSize(%zu).", LOG_TAG, sessionId, data->bufLen); auto dataBuffer = std::make_shared(data->bufLen); - if (!dataBuffer) { + if (dataBuffer == nullptr) { DHLOGE("%s: DataBuffer is null.", LOG_TAG); return; } diff --git a/services/screentransport/screensinkprocessor/decoder/src/image_sink_decoder.cpp b/services/screentransport/screensinkprocessor/decoder/src/image_sink_decoder.cpp index 93a52ab5..15504ed6 100644 --- a/services/screentransport/screensinkprocessor/decoder/src/image_sink_decoder.cpp +++ b/services/screentransport/screensinkprocessor/decoder/src/image_sink_decoder.cpp @@ -45,7 +45,7 @@ int32_t ImageSinkDecoder::ConfigureDecoder(const VideoParam &configParam) int32_t ImageSinkDecoder::ReleaseDecoder() { DHLOGI("%s: ReleaseDecoder.", LOG_TAG); - if (!videoDecoder_) { + if (videoDecoder_ == nullptr) { DHLOGE("%s: Decoder is null.", LOG_TAG); return ERR_DH_SCREEN_TRANS_NULL_VALUE; } @@ -64,7 +64,7 @@ int32_t ImageSinkDecoder::ReleaseDecoder() int32_t ImageSinkDecoder::StartDecoder() { DHLOGI("%s: StartDecoder.", LOG_TAG); - if (!videoDecoder_) { + if (videoDecoder_ == nullptr) { DHLOGE("%s: Decoder is null.", LOG_TAG); return ERR_DH_SCREEN_TRANS_NULL_VALUE; } @@ -88,7 +88,7 @@ int32_t ImageSinkDecoder::StartDecoder() int32_t ImageSinkDecoder::StopDecoder() { DHLOGI("%s: StopDecoder.", LOG_TAG); - if (!videoDecoder_) { + if (videoDecoder_ == nullptr) { DHLOGE("%s: Decoder is null.", LOG_TAG); return ERR_DH_SCREEN_TRANS_NULL_VALUE; } @@ -142,7 +142,7 @@ int32_t ImageSinkDecoder::InitVideoDecoder(const VideoParam &configParam) int32_t ImageSinkDecoder::SetDecoderFormat(const VideoParam &configParam) { DHLOGI("%s: SetDecoderFormat.", LOG_TAG); - if (!videoDecoder_) { + if (videoDecoder_ == nullptr) { DHLOGE("%s: Decoder is null.", LOG_TAG); return ERR_DH_SCREEN_TRANS_NULL_VALUE; } @@ -190,7 +190,7 @@ int32_t ImageSinkDecoder::SetDecoderFormat(const VideoParam &configParam) int32_t ImageSinkDecoder::SetOutputSurface(sptr &surface) { DHLOGI("%s: SetOutputSurface.", LOG_TAG); - if (!videoDecoder_) { + if (videoDecoder_ == nullptr) { DHLOGE("%s: Decoder is null.", LOG_TAG); return ERR_DH_SCREEN_TRANS_NULL_VALUE; } @@ -222,7 +222,7 @@ void ImageSinkDecoder::OnError(Media::AVCodecErrorType errorType, int32_t errorC { DHLOGI("%s: OnImageDecodeError, errorType(%d), errorCode(%d)", LOG_TAG, errorType, errorCode); std::shared_ptr listener = imageProcessorListener_.lock(); - if (!listener) { + if (listener == nullptr) { DHLOGE("%s: Listener is null.", LOG_TAG); return; } @@ -240,7 +240,7 @@ void ImageSinkDecoder::OnOutputBufferAvailable(uint32_t index, Media::AVCodecBuf Media::AVCodecBufferFlag flag) { DHLOGI("%s: OnDecodeOutputBufferAvailable.", LOG_TAG); - if (!videoDecoder_) { + if (videoDecoder_ == nullptr) { DHLOGE("%s: Decoder is null.", LOG_TAG); return; } @@ -313,7 +313,7 @@ void ImageSinkDecoder::DecodeScreenData() int32_t ImageSinkDecoder::ProcessData(const std::shared_ptr &screenData, const int32_t bufferIndex) { - if (!videoDecoder_) { + if (videoDecoder_ == nullptr) { DHLOGE("%s: Decoder is null.", LOG_TAG); return ERR_DH_SCREEN_TRANS_NULL_VALUE; } diff --git a/services/screentransport/screensinktrans/src/screen_sink_trans.cpp b/services/screentransport/screensinktrans/src/screen_sink_trans.cpp index 83b10eee..d3342252 100644 --- a/services/screentransport/screensinktrans/src/screen_sink_trans.cpp +++ b/services/screentransport/screensinktrans/src/screen_sink_trans.cpp @@ -45,8 +45,8 @@ int32_t ScreenSinkTrans::SetUp(const VideoParam &localParam, const VideoParam &r int32_t ScreenSinkTrans::Release() { DHLOGI("%s: Release.", LOG_TAG); - if (!imageProcessor_ || !screenChannel_) { - DHLOGE("%s: Processor or channel is null, Setup first.", LOG_TAG); + if (imageProcessor_ == nullptr || screenChannel_ == nullptr) { + DHLOGE("%s: Processor or channel is null, Release failed.", LOG_TAG); return ERR_DH_SCREEN_TRANS_NULL_VALUE; } @@ -69,8 +69,8 @@ int32_t ScreenSinkTrans::Release() int32_t ScreenSinkTrans::Start() { DHLOGI("%s: Start.", LOG_TAG); - if (!imageProcessor_ || !screenChannel_) { - DHLOGE("%s: Processor or channel is null, Setup first.", LOG_TAG); + if (imageProcessor_ == nullptr || screenChannel_ == nullptr) { + DHLOGE("%s: Processor or channel is null, Start failed.", LOG_TAG); return ERR_DH_SCREEN_TRANS_NULL_VALUE; } @@ -87,8 +87,8 @@ int32_t ScreenSinkTrans::Start() int32_t ScreenSinkTrans::Stop() { DHLOGI("%s: Stop.", LOG_TAG); - if (!imageProcessor_ || !screenChannel_) { - DHLOGE("%s: Processor or channel is null, Setup first.", LOG_TAG); + if (imageProcessor_ == nullptr || screenChannel_ == nullptr) { + DHLOGE("%s: Processor or channel is null, Stop failed.", LOG_TAG); return ERR_DH_SCREEN_TRANS_NULL_VALUE; } @@ -117,7 +117,7 @@ int32_t ScreenSinkTrans::Stop() int32_t ScreenSinkTrans::RegisterStateCallback(const std::shared_ptr &callback) { DHLOGI("%s:RegisterStateCallback.", LOG_TAG); - if (!callback) { + if (callback == nullptr) { DHLOGE("%s: Trans callback is null.", LOG_TAG); return ERR_DH_SCREEN_TRANS_NULL_VALUE; } @@ -128,7 +128,7 @@ int32_t ScreenSinkTrans::RegisterStateCallback(const std::shared_ptr &surface) { - if (!surface) { + if (surface == nullptr) { DHLOGE("%s: Image surface is null.", LOG_TAG); return ERR_DH_SCREEN_TRANS_NULL_VALUE; } @@ -200,7 +200,7 @@ int32_t ScreenSinkTrans::InitScreenTrans(const VideoParam &localParam, const Vid const std::string &peerDevId) { screenChannel_ = std::make_shared(peerDevId); - if (!screenChannel_) { + if (screenChannel_ == nullptr) { DHLOGE("%s: Create screen data channel failed.", LOG_TAG); return ERR_DH_SCREEN_TRANS_NULL_VALUE; } @@ -212,7 +212,7 @@ int32_t ScreenSinkTrans::InitScreenTrans(const VideoParam &localParam, const Vid } imageProcessor_ = std::make_shared(); - if (!imageProcessor_) { + if (imageProcessor_ == nullptr) { DHLOGE("%s: Create image processor failed.", LOG_TAG); screenChannel_ = nullptr; return ERR_DH_SCREEN_TRANS_NULL_VALUE; @@ -232,7 +232,7 @@ int32_t ScreenSinkTrans::RegisterChannelListner() { DHLOGI("%s: RegisterChannelListner.", LOG_TAG); std::shared_ptr listener = shared_from_this(); - if (!listener) { + if (listener == nullptr) { DHLOGE("%s: Channel Listener is null.", LOG_TAG); return ERR_DH_SCREEN_TRANS_NULL_VALUE; } @@ -251,7 +251,7 @@ int32_t ScreenSinkTrans::RegisterProcessorListner(const VideoParam &localParam, { DHLOGI("%s: RegisterProcessorListner.", LOG_TAG); std::shared_ptr listener = shared_from_this(); - if (!listener) { + if (listener == nullptr) { DHLOGE("%s: Channel listener to null.", LOG_TAG); return ERR_DH_SCREEN_TRANS_NULL_VALUE; } @@ -279,7 +279,7 @@ void ScreenSinkTrans::OnSessionClosed() { DHLOGI("%s:OnChannelSessionClosed.", LOG_TAG); std::shared_ptr callback = transCallback_.lock(); - if (!callback) { + if (callback == nullptr) { DHLOGE("%s: Trans callback is null.", LOG_TAG); return; } @@ -299,7 +299,7 @@ void ScreenSinkTrans::OnProcessorStateNotify(int32_t state) { DHLOGI("%s: OnProcessorStateNotify.", LOG_TAG); std::shared_ptr callback = transCallback_.lock(); - if (!callback) { + if (callback == nullptr) { DHLOGE("%s: Trans callback is null.", LOG_TAG); return; } diff --git a/services/screentransport/screensourceprocessor/encoder/src/image_source_encoder.cpp b/services/screentransport/screensourceprocessor/encoder/src/image_source_encoder.cpp index bd3c5667..e4657798 100644 --- a/services/screentransport/screensourceprocessor/encoder/src/image_source_encoder.cpp +++ b/services/screentransport/screensourceprocessor/encoder/src/image_source_encoder.cpp @@ -51,7 +51,7 @@ int32_t ImageSourceEncoder::ConfigureEncoder(const VideoParam &configParam) int32_t ImageSourceEncoder::ReleaseEncoder() { DHLOGI("%s: ReleaseEncoder.", LOG_TAG); - if (!videoEncoder_) { + if (videoEncoder_ == nullptr) { DHLOGE("%s: Encoder is null.", LOG_TAG); return ERR_DH_SCREEN_TRANS_NULL_VALUE; } @@ -70,7 +70,7 @@ int32_t ImageSourceEncoder::ReleaseEncoder() int32_t ImageSourceEncoder::StartEncoder() { DHLOGI("%s: StartEncoder.", LOG_TAG); - if (!videoEncoder_) { + if (videoEncoder_ == nullptr) { DHLOGE("%s: Encoder is null.", LOG_TAG); return ERR_DH_SCREEN_TRANS_NULL_VALUE; } @@ -93,7 +93,7 @@ int32_t ImageSourceEncoder::StartEncoder() int32_t ImageSourceEncoder::StopEncoder() { DHLOGI("%s: StopEncoder.", LOG_TAG); - if (!videoEncoder_) { + if (videoEncoder_ == nullptr) { DHLOGE("%s: Encoder is null.", LOG_TAG); return ERR_DH_SCREEN_TRANS_NULL_VALUE; } @@ -145,7 +145,7 @@ int32_t ImageSourceEncoder::InitVideoEncoder(const VideoParam &configParam) int32_t ImageSourceEncoder::SetEncoderFormat(const VideoParam &configParam) { DHLOGI("%s: SetEncoderFormat.", LOG_TAG); - if (!videoEncoder_) { + if (videoEncoder_ == nullptr) { DHLOGE("%s: Encoder is null.", LOG_TAG); return ERR_DH_SCREEN_TRANS_NULL_VALUE; } @@ -192,7 +192,7 @@ void ImageSourceEncoder::OnError(Media::AVCodecErrorType errorType, int32_t erro { DHLOGI("%s: Encoder error, errorType(%d), errorCode(%d)", LOG_TAG, errorType, errorCode); std::shared_ptr listener = imageProcessorListener_.lock(); - if (!listener) { + if (listener == nullptr) { DHLOGE("%s: Processor listener is null", LOG_TAG); return; } @@ -204,25 +204,25 @@ void ImageSourceEncoder::OnOutputBufferAvailable(uint32_t index, Media::AVCodecB { DHLOGD("%s: OnOutputBufferAvailable.", LOG_TAG); std::shared_ptr listener = imageProcessorListener_.lock(); - if (!listener) { + if (listener == nullptr) { DHLOGE("%s: Processor listener is null", LOG_TAG); return; } - if (!videoEncoder_) { + if (videoEncoder_ == nullptr) { DHLOGE("%s: Encoder is null.", LOG_TAG); return; } encoderBufferInfo_ = info; videoSharedMemory_ = videoEncoder_->GetOutputBuffer(index); - if (!videoSharedMemory_) { + if (videoSharedMemory_ == nullptr) { DHLOGE("%s: GetOutputBuffer failed.", LOG_TAG); return; } size_t dataSize = static_cast(info.size); auto dataBuf = std::make_shared(dataSize); - if (!dataBuf) { + if (dataBuf == nullptr) { DHLOGE("%s: Create buffer failed.", LOG_TAG); return; } diff --git a/services/screentransport/screensourceprocessor/src/image_source_processor.cpp b/services/screentransport/screensourceprocessor/src/image_source_processor.cpp index 68e74783..840d30aa 100644 --- a/services/screentransport/screensourceprocessor/src/image_source_processor.cpp +++ b/services/screentransport/screensourceprocessor/src/image_source_processor.cpp @@ -25,7 +25,7 @@ int32_t ImageSourceProcessor::ConfigureImageProcessor(const VideoParam &localPar { DHLOGI("%s: ConfigureImageProcessor.", LOG_TAG); imageEncoder_ = std::make_shared(listener); - if (!imageEncoder_) { + if (imageEncoder_ == nullptr) { DHLOGE("%s: Create screen encoder failed.", LOG_TAG); return ERR_DH_SCREEN_TRANS_NULL_VALUE; } @@ -44,7 +44,7 @@ int32_t ImageSourceProcessor::ConfigureImageProcessor(const VideoParam &localPar int32_t ImageSourceProcessor::ReleaseImageProcessor() { DHLOGI("%s: ReleaseImageProcessor.", LOG_TAG); - if (!imageEncoder_) { + if (imageEncoder_ == nullptr) { DHLOGE("%s: Create screen encoder failed.", LOG_TAG); return ERR_DH_SCREEN_TRANS_NULL_VALUE; } @@ -61,7 +61,7 @@ int32_t ImageSourceProcessor::ReleaseImageProcessor() int32_t ImageSourceProcessor::StartImageProcessor() { DHLOGI("%s: StartImageProcessor.", LOG_TAG); - if (!imageEncoder_) { + if (imageEncoder_ == nullptr) { DHLOGE("%s: Create screen encoder failed.", LOG_TAG); return ERR_DH_SCREEN_TRANS_NULL_VALUE; } @@ -78,7 +78,7 @@ int32_t ImageSourceProcessor::StartImageProcessor() int32_t ImageSourceProcessor::StopImageProcessor() { DHLOGI("%s: StopImageProcessor.", LOG_TAG); - if (!imageEncoder_) { + if (imageEncoder_ == nullptr) { DHLOGE("%s: Create screen encoder failed.", LOG_TAG); return ERR_DH_SCREEN_TRANS_NULL_VALUE; } diff --git a/services/screentransport/screensourcetrans/src/screen_source_trans.cpp b/services/screentransport/screensourcetrans/src/screen_source_trans.cpp index 13faed9b..656a654f 100644 --- a/services/screentransport/screensourcetrans/src/screen_source_trans.cpp +++ b/services/screentransport/screensourcetrans/src/screen_source_trans.cpp @@ -47,8 +47,8 @@ int32_t ScreenSourceTrans::SetUp(const VideoParam &localParam, const VideoParam int32_t ScreenSourceTrans::Release() { DHLOGI("%s: Release.", LOG_TAG); - if (!imageProcessor_ || !screenChannel_) { - DHLOGE("%s: Processor or channel is null, Setup first.", LOG_TAG); + if (imageProcessor_ == nullptr || screenChannel_ == nullptr) { + DHLOGE("%s: Processor or channel is null, Release failed.", LOG_TAG); return ERR_DH_SCREEN_TRANS_NULL_VALUE; } @@ -76,8 +76,8 @@ int32_t ScreenSourceTrans::Release() int32_t ScreenSourceTrans::Start() { DHLOGI("%s: Start.", LOG_TAG); - if (!imageProcessor_ || !screenChannel_) { - DHLOGE("%s: Processor or channel is null, Setup first.", LOG_TAG); + if (imageProcessor_ == nullptr || screenChannel == nullptr) { + DHLOGE("%s: Processor or channel is null, Start failed.", LOG_TAG); return ERR_DH_SCREEN_TRANS_NULL_VALUE; } @@ -103,8 +103,8 @@ int32_t ScreenSourceTrans::Start() int32_t ScreenSourceTrans::Stop() { DHLOGI("%s: Stop.", LOG_TAG); - if (!imageProcessor_ || !screenChannel_) { - DHLOGE("%s: Processor or channel is null, Setup first.", LOG_TAG); + if (imageProcessor_ == nullptr || screenChannel_ == nullptr) { + DHLOGE("%s: Processor or channel is null, Stop failed.", LOG_TAG); return ERR_DH_SCREEN_TRANS_NULL_VALUE; } @@ -134,7 +134,7 @@ int32_t ScreenSourceTrans::Stop() int32_t ScreenSourceTrans::RegisterStateCallback(const std::shared_ptr &callback) { DHLOGI("%s:RegisterStateCallback.", LOG_TAG); - if (!callback) { + if (callback == nullptr) { DHLOGE("%s: Trans callback is null.", LOG_TAG); return ERR_DH_SCREEN_TRANS_NULL_VALUE; } @@ -212,7 +212,7 @@ int32_t ScreenSourceTrans::InitScreenTrans(const VideoParam &localParam, const V const std::string &peerDevId) { screenChannel_ = std::make_shared(peerDevId); - if (!screenChannel_) { + if (screenChannel_ == nullptr) { DHLOGE("%s: Create screen data channel failed.", LOG_TAG); return ERR_DH_SCREEN_TRANS_NULL_VALUE; } @@ -224,7 +224,7 @@ int32_t ScreenSourceTrans::InitScreenTrans(const VideoParam &localParam, const V } imageProcessor_ = std::make_shared(); - if (!imageProcessor_) { + if (imageProcessor_ == nullptr) { DHLOGE("%s: Create image processor failed.", LOG_TAG); screenChannel_ = nullptr; return ERR_DH_SCREEN_TRANS_NULL_VALUE; @@ -244,7 +244,7 @@ int32_t ScreenSourceTrans::RegisterChannelListner() { DHLOGI("%s: RegisterChannelListner.", LOG_TAG); std::shared_ptr listener = shared_from_this(); - if (!listener) { + if (listener == nullptr) { DHLOGE("%s: Channel listener is null", LOG_TAG); return ERR_DH_SCREEN_TRANS_NULL_VALUE; } @@ -266,7 +266,7 @@ int32_t ScreenSourceTrans::RegisterProcessorListner(const VideoParam &localParam { DHLOGI("%s: RegisterProcessorListner.", LOG_TAG); std::shared_ptr listener = shared_from_this(); - if (!listener) { + if (listener == nullptr) { DHLOGE("%s: Processor listener is null", LOG_TAG); return ERR_DH_SCREEN_TRANS_ERROR; } @@ -278,7 +278,7 @@ int32_t ScreenSourceTrans::RegisterProcessorListner(const VideoParam &localParam } encoderSurface_ = imageProcessor_->GetImageSurface(); - if (!encoderSurface_) { + if (encoderSurface_ == nullptr) { DHLOGE("%s: Surface is null.", LOG_TAG); return ERR_DH_SCREEN_TRANS_NULL_VALUE; } @@ -310,7 +310,7 @@ void ScreenSourceTrans::OnSessionClosed() sendDataThread_.join(); std::shared_ptr callback = transCallback_.lock(); - if (!callback) { + if (callback == nullptr) { DHLOGE("%s: Trans callback is null.", LOG_TAG); return; } @@ -339,7 +339,7 @@ void ScreenSourceTrans::OnProcessorStateNotify(int32_t state) { DHLOGI("%s:OnProcessorStateNotify.", LOG_TAG); std::shared_ptr callback = transCallback_.lock(); - if (!callback) { + if (callback == nullptr) { DHLOGE("%s: Trans callback is null.", LOG_TAG); return; } diff --git a/services/softbusadapter/src/softbus_adapter.cpp b/services/softbusadapter/src/softbus_adapter.cpp index 540590b0..9b7ceed4 100644 --- a/services/softbusadapter/src/softbus_adapter.cpp +++ b/services/softbusadapter/src/softbus_adapter.cpp @@ -264,7 +264,7 @@ int32_t SoftbusAdapter::OnSoftbusSessionOpened(int32_t sessionId, int32_t result } std::shared_ptr &listener = GetSoftbusListenerByName(sessionId); - if (!listener) { + if (listener == nullptr) { DHLOGE("Get softbus listener failed."); return ERR_DH_SCREEN_TRANS_ERROR; } @@ -280,7 +280,7 @@ void SoftbusAdapter::OnSoftbusSessionClosed(int32_t sessionId) { DHLOGI("%s: OnSessionClosed sessionId:%d.", LOG_TAG, sessionId); std::shared_ptr &listener = GetSoftbusListenerById(sessionId); - if (!listener) { + if (listener == nullptr) { DHLOGE("Get softbus listener failed."); return; } @@ -303,7 +303,7 @@ void SoftbusAdapter::OnBytesReceived(int32_t sessionId, const void *data, uint32 } std::shared_ptr &listener = GetSoftbusListenerByName(sessionId); - if (!listener) { + if (listener == nullptr) { DHLOGE("Get softbus listener failed."); return; } @@ -324,7 +324,7 @@ void SoftbusAdapter::OnStreamReceived(int32_t sessionId, const StreamData *data, } std::shared_ptr &listener = GetSoftbusListenerByName(sessionId); - if (!listener) { + if (listener == nullptr) { DHLOGE("Get softbus listener failed."); return; } -- Gitee