diff --git a/common/include/dscreen_constants.h b/common/include/dscreen_constants.h index 083d0b44d4ac2a7ab59a21433a5efa0ecda9bd25..fab00764aef836957f3c39a3d902914db19d9de6 100644 --- a/common/include/dscreen_constants.h +++ b/common/include/dscreen_constants.h @@ -150,6 +150,7 @@ const std::string KEY_ERR_CODE = "errCode"; const std::string KEY_ERR_CONTENT = "errContent"; const std::string KEY_VIDEO_PARAM = "videoParam"; const std::string KEY_MAPRELATION = "mapRelation"; +const std::string KEY_PARTIALREFREAH = "PartialRefresh"; const std::string CODEC_NAME_H264 = "OMX_hisi_video_encoder_avc"; const std::string CODEC_NAME_H265 = "OMX_hisi_video_encoder_hevc"; const std::string CODEC_NAME_MPEG4 = "avenc_mpeg4"; diff --git a/services/common/utils/include/video_param.h b/services/common/utils/include/video_param.h index 3db42ee2ea917249a464f4a0252bd2de1d99dfec..5f1122a13862940963b3eec152638adac34cac56 100644 --- a/services/common/utils/include/video_param.h +++ b/services/common/utils/include/video_param.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * Copyright (c) 2022-2023 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 @@ -40,6 +40,8 @@ public: uint8_t GetCodecType() const; void SetVideoFormat(uint8_t videoFormat); uint8_t GetVideoFormat() const; + void SetPartialRefreshFlag(bool flag); + bool GetPartialRefreshFlag() const; private: friend void to_json(json &j, const VideoParam &videoParam); friend void from_json(const json &j, VideoParam &videoParam); @@ -51,6 +53,7 @@ private: uint32_t fps_ = DEFAULT_FPS; uint8_t codecType_ = DEFAULT_CODECTYPE; uint8_t videoFormat_ = DEFAULT_VIDEO_FORMAT; + bool isPartialRefresh_ = false; }; void to_json(json &j, const VideoParam &videoParam); void from_json(const json &j, VideoParam &videoParam); diff --git a/services/common/utils/src/video_param.cpp b/services/common/utils/src/video_param.cpp index 561c7ac2b0dab2270ce4f94d8f88d480c9c13803..4a4ebb2229c468afcebab6ac2c19e525051b9d8e 100644 --- a/services/common/utils/src/video_param.cpp +++ b/services/common/utils/src/video_param.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * Copyright (c) 2022-2023 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 @@ -51,6 +51,16 @@ uint32_t VideoParam::GetVideoWidth() const return videoWidth_; } +void VideoParam::SetPartialRefreshFlag(bool flag) +{ + isPartialRefresh_ = flag; +} + +bool VideoParam::GetPartialRefreshFlag() const +{ + return isPartialRefresh_; +} + void VideoParam::SetVideoHeight(uint32_t videoHeight) { videoHeight_ = videoHeight; @@ -100,7 +110,8 @@ void to_json(json &j, const DistributedHardware::VideoParam &videoParam) {KEY_VIDEO_HEIGHT, videoParam.videoHeight_}, {KEY_FPS, videoParam.fps_}, {KEY_CODECTYPE, videoParam.codecType_}, - {KEY_COLOR_FORMAT, videoParam.videoFormat_} + {KEY_COLOR_FORMAT, videoParam.videoFormat_}, + {KEY_PARTIALREFREAH, videoParam.isPartialRefresh_} }; } @@ -108,7 +119,8 @@ void from_json(const json &j, DistributedHardware::VideoParam &videoParam) { if (!IsUInt32(j, KEY_SCREEN_WIDTH) || !IsUInt32(j, KEY_SCREEN_HEIGHT) || !IsUInt32(j, KEY_VIDEO_WIDTH) || !IsUInt32(j, KEY_VIDEO_HEIGHT) || - !IsUInt32(j, KEY_FPS) || !IsUInt8(j, KEY_CODECTYPE) || !IsUInt8(j, KEY_COLOR_FORMAT)) { + !IsBool(j, KEY_PARTIALREFREAH) || !IsUInt32(j, KEY_FPS) || + !IsUInt8(j, KEY_CODECTYPE) || !IsUInt8(j, KEY_COLOR_FORMAT)) { return; } @@ -119,6 +131,7 @@ void from_json(const json &j, DistributedHardware::VideoParam &videoParam) videoParam.fps_ = j[KEY_FPS].get(); videoParam.codecType_ = j[KEY_CODECTYPE].get(); videoParam.videoFormat_ = j[KEY_COLOR_FORMAT].get(); + videoParam.isPartialRefresh_ = j[KEY_PARTIALREFREAH].get(); } } // namespace DistributedHardware } // namespace OHOS diff --git a/services/screenservice/sourceservice/dscreenmgr/src/dscreen.cpp b/services/screenservice/sourceservice/dscreenmgr/src/dscreen.cpp index b7a4e704a959bd7b0c8c59fef54da77dddda4634..1b91c09926e0b396348561c8df4f01200f05d655 100644 --- a/services/screenservice/sourceservice/dscreenmgr/src/dscreen.cpp +++ b/services/screenservice/sourceservice/dscreenmgr/src/dscreen.cpp @@ -309,10 +309,12 @@ int32_t DScreen::NegotiateCodecType(const std::string &remoteCodecInfoStr) CODEC_NAME_H265) != codecTypeCandidates.end()) { videoParam_->SetCodecType(VIDEO_CODEC_TYPE_VIDEO_H265); videoParam_->SetVideoFormat(VIDEO_DATA_FORMAT_NV12); + videoParam_->SetPartialRefreshFlag(true); } else if (std::find(codecTypeCandidates.begin(), codecTypeCandidates.end(), CODEC_NAME_H264) != codecTypeCandidates.end()) { videoParam_->SetCodecType(VIDEO_CODEC_TYPE_VIDEO_H264); videoParam_->SetVideoFormat(VIDEO_DATA_FORMAT_NV12); + videoParam_->SetPartialRefreshFlag(true); } else if (std::find(codecTypeCandidates.begin(), codecTypeCandidates.end(), CODEC_NAME_MPEG4) != codecTypeCandidates.end()) { videoParam_->SetCodecType(VIDEO_CODEC_TYPE_VIDEO_MPEG4); diff --git a/services/screentransport/screensinkprocessor/decoder/src/image_sink_decoder.cpp b/services/screentransport/screensinkprocessor/decoder/src/image_sink_decoder.cpp index b93c98285296c493981bdd4912ce6d74f8736027..9b380a39b248df134ae107f21605a2fb9274d56b 100644 --- a/services/screentransport/screensinkprocessor/decoder/src/image_sink_decoder.cpp +++ b/services/screentransport/screensinkprocessor/decoder/src/image_sink_decoder.cpp @@ -380,7 +380,7 @@ int32_t ImageSinkDecoder::SetOutputSurface(sptr &surface) return ERR_DH_SCREEN_TRANS_NULL_VALUE; } windowSurface_ = surface; - if (consumerSurface_ == nullptr || producerSurface_ == nullptr) { + if (consumerSurface_ == nullptr || producerSurface_ == nullptr || !configParam_.GetPartialRefreshFlag()) { int32_t ret = videoDecoder_->SetOutputSurface(surface); if (ret != Media::MSERR_OK) { DHLOGE("%s: SetOutputSurface failed.", LOG_TAG); diff --git a/services/screentransport/screensourceprocessor/encoder/src/image_source_encoder.cpp b/services/screentransport/screensourceprocessor/encoder/src/image_source_encoder.cpp index b3df636f46077108d69a2b30b951be5b3676554a..d5318e91065ccd7f310196d558d86097bf3785e5 100644 --- a/services/screentransport/screensourceprocessor/encoder/src/image_source_encoder.cpp +++ b/services/screentransport/screensourceprocessor/encoder/src/image_source_encoder.cpp @@ -173,7 +173,7 @@ sptr ImageSourceEncoder::GetConsumerSurface() sptr &ImageSourceEncoder::GetInputSurface() { DHLOGI("%s: GetInputSurface.", LOG_TAG); - if (producerSurface_ == nullptr) { + if (producerSurface_ == nullptr || !configParam_.GetPartialRefreshFlag()) { return encoderSurface_; } return producerSurface_;