From cac93e24e0832e641cd92cdb4c22fd37ec766648 Mon Sep 17 00:00:00 2001 From: yangwei_814916 Date: Tue, 16 May 2023 21:37:54 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E5=A4=8DRK=E6=8A=95=E5=B1=8F?= =?UTF-8?q?=E5=A4=B1=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: yangwei_814916 --- common/include/dscreen_constants.h | 1 + services/common/utils/include/video_param.h | 5 ++++- services/common/utils/src/video_param.cpp | 19 ++++++++++++++++--- .../sourceservice/dscreenmgr/src/dscreen.cpp | 2 ++ .../decoder/src/image_sink_decoder.cpp | 2 +- .../encoder/src/image_source_encoder.cpp | 2 +- 6 files changed, 25 insertions(+), 6 deletions(-) diff --git a/common/include/dscreen_constants.h b/common/include/dscreen_constants.h index 083d0b44..4aed9d75 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_PARTIALFREAH = "PartialFrash"; 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 3db42ee2..f691bbf8 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 SetPartialFreshFlag(bool flag); + bool GetPartialFreshFlag() 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 isPartialFresh_ = 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 561c7ac2..334d5508 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::SetPartialFreshFlag(bool flag) +{ + isPartialFresh_ = flag; +} + +bool VideoParam::GetPartialFreshFlag() const +{ + return isPartialFresh_; +} + 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_PARTIALFREAH, videoParam.isPartialFresh_} }; } @@ -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_PARTIALFREAH) || !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.isPartialFresh_ = j[KEY_PARTIALFREAH].get(); } } // namespace DistributedHardware } // namespace OHOS diff --git a/services/screenservice/sourceservice/dscreenmgr/src/dscreen.cpp b/services/screenservice/sourceservice/dscreenmgr/src/dscreen.cpp index b7a4e704..08a22643 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_->SetPartialFreshFlag(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_->SetPartialFreshFlag(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 b93c9828..d0d27a53 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_.GetPartialFreshFlag()) { 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 b3df636f..53720161 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_.GetPartialFreshFlag()) { return encoderSurface_; } return producerSurface_; -- Gitee From 861ca79f23504c2502b1246209d4f5541a33efad Mon Sep 17 00:00:00 2001 From: yangwei_814916 Date: Wed, 17 May 2023 11:10:59 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E5=A4=8DRK=E6=8A=95=E5=B1=8F?= =?UTF-8?q?=E5=A4=B1=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: yangwei_814916 --- common/include/dscreen_constants.h | 2 +- services/common/utils/include/video_param.h | 6 +++--- services/common/utils/src/video_param.cpp | 14 +++++++------- .../sourceservice/dscreenmgr/src/dscreen.cpp | 4 ++-- .../decoder/src/image_sink_decoder.cpp | 2 +- .../encoder/src/image_source_encoder.cpp | 2 +- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/common/include/dscreen_constants.h b/common/include/dscreen_constants.h index 4aed9d75..fab00764 100644 --- a/common/include/dscreen_constants.h +++ b/common/include/dscreen_constants.h @@ -150,7 +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_PARTIALFREAH = "PartialFrash"; +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 f691bbf8..5f1122a1 100644 --- a/services/common/utils/include/video_param.h +++ b/services/common/utils/include/video_param.h @@ -40,8 +40,8 @@ public: uint8_t GetCodecType() const; void SetVideoFormat(uint8_t videoFormat); uint8_t GetVideoFormat() const; - void SetPartialFreshFlag(bool flag); - bool GetPartialFreshFlag() 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); @@ -53,7 +53,7 @@ private: uint32_t fps_ = DEFAULT_FPS; uint8_t codecType_ = DEFAULT_CODECTYPE; uint8_t videoFormat_ = DEFAULT_VIDEO_FORMAT; - bool isPartialFresh_ = false; + 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 334d5508..4a4ebb22 100644 --- a/services/common/utils/src/video_param.cpp +++ b/services/common/utils/src/video_param.cpp @@ -51,14 +51,14 @@ uint32_t VideoParam::GetVideoWidth() const return videoWidth_; } -void VideoParam::SetPartialFreshFlag(bool flag) +void VideoParam::SetPartialRefreshFlag(bool flag) { - isPartialFresh_ = flag; + isPartialRefresh_ = flag; } -bool VideoParam::GetPartialFreshFlag() const +bool VideoParam::GetPartialRefreshFlag() const { - return isPartialFresh_; + return isPartialRefresh_; } void VideoParam::SetVideoHeight(uint32_t videoHeight) @@ -111,7 +111,7 @@ void to_json(json &j, const DistributedHardware::VideoParam &videoParam) {KEY_FPS, videoParam.fps_}, {KEY_CODECTYPE, videoParam.codecType_}, {KEY_COLOR_FORMAT, videoParam.videoFormat_}, - {KEY_PARTIALFREAH, videoParam.isPartialFresh_} + {KEY_PARTIALREFREAH, videoParam.isPartialRefresh_} }; } @@ -119,7 +119,7 @@ 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) || - !IsBool(j, KEY_PARTIALFREAH) || !IsUInt32(j, KEY_FPS) || + !IsBool(j, KEY_PARTIALREFREAH) || !IsUInt32(j, KEY_FPS) || !IsUInt8(j, KEY_CODECTYPE) || !IsUInt8(j, KEY_COLOR_FORMAT)) { return; } @@ -131,7 +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.isPartialFresh_ = j[KEY_PARTIALFREAH].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 08a22643..1b91c099 100644 --- a/services/screenservice/sourceservice/dscreenmgr/src/dscreen.cpp +++ b/services/screenservice/sourceservice/dscreenmgr/src/dscreen.cpp @@ -309,12 +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_->SetPartialFreshFlag(true); + 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_->SetPartialFreshFlag(true); + 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 d0d27a53..9b380a39 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 || !configParam_.GetPartialFreshFlag()) { + 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 53720161..d5318e91 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 || !configParam_.GetPartialFreshFlag()) { + if (producerSurface_ == nullptr || !configParam_.GetPartialRefreshFlag()) { return encoderSurface_; } return producerSurface_; -- Gitee