diff --git a/common/include/dscreen_constants.h b/common/include/dscreen_constants.h index 671a9ccc84fbb6323b480547cd99c82db0c8dda2..31c5364a3016125cecde9e1aeabc30adc0baab06 100644 --- a/common/include/dscreen_constants.h +++ b/common/include/dscreen_constants.h @@ -84,7 +84,7 @@ constexpr uint32_t DSCREEN_MAX_SCREEN_DATA_HEIGHT = 2772; /* YUV420 buffer size max size */ constexpr int64_t MAX_YUV420_BUFFER_SIZE = 2560 * 1600 * (3 / 2) * 2; -constexpr int32_t LOG_MAX_LEN = 4096; +constexpr int32_t DSCREEN_MAX_LEN = 4096; constexpr int32_t INVALID_WINDOW_ID = -1; diff --git a/common/src/dscreen_log.cpp b/common/src/dscreen_log.cpp index ec34b603e0021e976697619e77a3c05747ca98d3..edbb85b305c99131e8a0afe611ba5b3ba9e25117 100644 --- a/common/src/dscreen_log.cpp +++ b/common/src/dscreen_log.cpp @@ -70,7 +70,7 @@ static void DHLogOut(DHLogLevel logLevel, const char *logBuf) void DHLog(DHLogLevel logLevel, const char *fmt, ...) { - char logBuf[LOG_MAX_LEN] = {0}; + char logBuf[DSCREEN_MAX_LEN] = {0}; va_list arg; (void)memset_s(&arg, sizeof(va_list), 0, sizeof(va_list)); diff --git a/distributedscreen.gni b/distributedscreen.gni index b1791497deedecb64ae81ca38c7ae10aacff2999..5c4a7ba9a939ceed4acc42bcf9ce367d84488720 100644 --- a/distributedscreen.gni +++ b/distributedscreen.gni @@ -16,6 +16,7 @@ distributedhardwarefwk_path = "//foundation/distributedhardware/distributed_hardware_fwk" windowmanager_path = "//foundation/window/window_manager" mediastandard_path = "//foundation/multimedia/player_framework" +ipc_path = "//foundation/communication/ipc" graphicstandard_path = "//foundation/graphic/graphic_2d" common_path = "${distributedscreen_path}/common" services_path = "${distributedscreen_path}/services" @@ -23,4 +24,6 @@ interfaces_path = "${distributedscreen_path}/interfaces" fwk_utils_path = "${distributedhardwarefwk_path}/utils" fwk_common_path = "${distributedhardwarefwk_path}/common" fwk_services_path = "${distributedhardwarefwk_path}/services" +fwk_interfaces_path = "${distributedhardwarefwk_path}/interfaces" +ipc_interfaces_path = "${ipc_path}/interfaces" build_flags = [ "-Werror" ] diff --git a/services/common/utils/include/dscreen_fwkkit.h b/services/common/utils/include/dscreen_fwkkit.h index a1f7502b20721b8515ac0d80167a55f230db808f..ff873fb6ed3f82d074bc37d79b67a27e6bc9f406 100644 --- a/services/common/utils/include/dscreen_fwkkit.h +++ b/services/common/utils/include/dscreen_fwkkit.h @@ -18,11 +18,22 @@ #include +#include "constants.h" +#include "device_type.h" #include "distributed_hardware_fwk_kit.h" +#include "nlohmann/json.hpp" #include "single_instance.h" namespace OHOS { namespace DistributedHardware { +const nlohmann::json ENABLE_LOW_LATENCY = { + {DH_TYPE, DHType::SCREEN}, + {LOW_LATENCY_ENABLE, true}, +}; +const nlohmann::json DISABLE_LOW_LATENCY = { + {DH_TYPE, DHType::SCREEN}, + {LOW_LATENCY_ENABLE, false}, +}; class DScreenFwkKit { DECLARE_SINGLE_INSTANCE_BASE(DScreenFwkKit); public: diff --git a/services/screenservice/sinkservice/BUILD.gn b/services/screenservice/sinkservice/BUILD.gn index d75c40184f4ab7ccb5c959a2ffb812c62e580ec2..e7b4ad805b238567168453000579aa0362967b21 100644 --- a/services/screenservice/sinkservice/BUILD.gn +++ b/services/screenservice/sinkservice/BUILD.gn @@ -16,71 +16,62 @@ import("//build/ohos_var.gni") import( "//foundation/distributedhardware/distributed_screen/distributedscreen.gni") -ohos_shared_library("distributed_screen_sink") { +ohos_shared_library("distributed_screen_sinktrans") { include_dirs = [ "//base/hiviewdfx/hisysevent/interfaces/native/innerkits/hisysevent/include", "//third_party/json/include", - "//commonlibrary/c_utils/base/include", - "//utils/system/safwk/native/include", - "//foundation/graphic/graphic_2d/interfaces/inner_api/surface", - "//foundation/graphic/graphic_2d/interfaces/inner_api/common", - "//foundation/graphic/graphic_2d/utils/buffer_handle/export", - "${windowmanager_path}/interfaces/innerkits/dm", + "//foundation/graphic/graphic_2d/interfaces/innerkits/surface", "${fwk_common_path}/utils/include", - "${distributedhardwarefwk_path}/interfaces/inner_kits/include", + "//base/hiviewdfx/hitrace/interfaces/native/innerkits/include/hitrace_meter", + "${fwk_interfaces_path}/inner_kits/include", + "${ipc_interfaces_path}/innerkits/ipc_core/include", + "${services_path}/common/utils/include", ] include_dirs += [ - "./dscreenservice/include", - "./screenregionmgr/include", - "${interfaces_path}/innerkits/native_cpp/screen_sink/include", - "${interfaces_path}/innerkits/native_cpp/screen_sink/include/callback", - "${interfaces_path}/innerkits/native_cpp/screen_source/include", - "${interfaces_path}/innerkits/native_cpp/screen_source/include/callback", + "./include", "${common_path}/include", - "${services_path}/common/utils/include", "${services_path}/common/databuffer/include", "${services_path}/common/screen_channel/include", + "${services_path}/common/utils/include", + "${services_path}/screentransport/screendatachannel/include", "${services_path}/screentransport/screensinktrans/include", "${services_path}/screentransport/screensinkprocessor/include", "${services_path}/screentransport/screensinkprocessor/decoder/include", - "${services_path}/screenclient/include/", - "//foundation/multimedia/image_framework/interfaces/innerkits/include", - "//drivers/peripheral/display/interfaces/include", - "//drivers/peripheral/base", + "${services_path}/softbusadapter/include", ] sources = [ - "${interfaces_path}/innerkits/native_cpp/screen_sink/src/dscreen_sink_proxy.cpp", - "${interfaces_path}/innerkits/native_cpp/screen_source/src/dscreen_source_proxy.cpp", + "${services_path}/common/databuffer/src/data_buffer.cpp", "${services_path}/common/utils/src/dscreen_fwkkit.cpp", - "${services_path}/common/utils/src/dscreen_maprelation.cpp", "${services_path}/common/utils/src/video_param.cpp", - "./dscreenservice/src/dscreen_sink_service.cpp", - "./dscreenservice/src/dscreen_sink_stub.cpp", - "./screenregionmgr/src/screenregion.cpp", - "./screenregionmgr/src/screenregionmgr.cpp", + "${services_path}/screentransport/screendatachannel/src/screen_data_channel_impl.cpp", + "${services_path}/screentransport/screensinkprocessor/decoder/src/image_decoder_callback.cpp", + "${services_path}/screentransport/screensinkprocessor/decoder/src/image_sink_decoder.cpp", + "${services_path}/screentransport/screensinkprocessor/src/image_sink_processor.cpp", + "${services_path}/softbusadapter/src/softbus_adapter.cpp", + "./src/screen_sink_trans.cpp", ] deps = [ "${common_path}:distributed_screen_utils", "${distributedhardwarefwk_path}/interfaces/inner_kits:libdhfwk_sdk", - "${services_path}/screenclient:distributed_screen_client", - "${services_path}/screentransport/screensinktrans:distributed_screen_sinktrans", - "${windowmanager_path}/dm:libdm", + "//foundation/graphic/graphic_2d/frameworks/surface:surface", ] defines = [ "HI_LOG_ENABLE", - "DH_LOG_TAG=\"dscreensink\"", + "DH_LOG_TAG=\"dscreensinktrans\"", "LOG_DOMAIN=0xD004100", ] external_deps = [ "c_utils:utils", - "ipc:ipc_core", - "safwk:system_ability_fwk", - "samgr:samgr_proxy", + "dsoftbus:softbus_client", + "hisysevent_native:libhisysevent", + "hitrace_native:hitrace_meter", + "hiviewdfx_hilog_native:libhilog", + "multimedia_player_framework:media_client", ] subsystem_name = "distributedhardware" diff --git a/services/screenservice/sourceservice/BUILD.gn b/services/screenservice/sourceservice/BUILD.gn index c861b69bc1757c56ff57b6e635b4b49bc9b832a4..e9893e8c797dc91dd038694a3903c06652684dfb 100644 --- a/services/screenservice/sourceservice/BUILD.gn +++ b/services/screenservice/sourceservice/BUILD.gn @@ -16,73 +16,61 @@ import("//build/ohos_var.gni") import( "//foundation/distributedhardware/distributed_screen/distributedscreen.gni") -ohos_shared_library("distributed_screen_source") { +ohos_shared_library("distributed_screen_sourcetrans") { include_dirs = [ "//base/hiviewdfx/hisysevent/interfaces/native/innerkits/hisysevent/include", "//third_party/json/include", - "${windowmanager_path}/interfaces/innerkits/dm", - "//commonlibrary/c_utils/base/include", - "//utils/system/safwk/native/include", "//foundation/graphic/graphic_2d/interfaces/innerkits/surface", "${fwk_common_path}/utils/include", - "${mediastandard_path}/interfaces/inner_api/native", - "${distributedhardwarefwk_path}/interfaces/inner_kits/include", + "//base/hiviewdfx/hitrace/interfaces/native/innerkits/include/hitrace_meter", + "${fwk_interfaces_path}/inner_kits/include", + "${ipc_interfaces_path}/innerkits/ipc_core/include", + "${services_path}/common/utils/include", ] include_dirs += [ - "./dscreenservice/include", - "./dscreenservice/include/callback", - "./dscreenmgr/include", - "${interfaces_path}/innerkits/native_cpp/screen_sink/include", - "${interfaces_path}/innerkits/native_cpp/screen_sink/include/callback", - "${interfaces_path}/innerkits/native_cpp/screen_source/include", - "${interfaces_path}/innerkits/native_cpp/screen_source/include/callback", + "./include", "${common_path}/include", - "${services_path}/common/utils/include", "${services_path}/common/databuffer/include", "${services_path}/common/screen_channel/include", + "${services_path}/common/utils/include", + "${services_path}/screentransport/screendatachannel/include", "${services_path}/screentransport/screensourceprocessor/include", "${services_path}/screentransport/screensourceprocessor/encoder/include", - "${services_path}/screentransport/screensourcetrans/include", - "//drivers/peripheral/display/interfaces/include", - "//drivers/peripheral/base", - "//foundation/graphic/graphic_2d/rosen/modules/render_service_base/include", - "//foundation/graphic/graphic_2d/utils/buffer_handle/export", + "${services_path}/softbusadapter/include", ] sources = [ - "${interfaces_path}/innerkits/native_cpp/screen_sink/src/dscreen_sink_proxy.cpp", - "${interfaces_path}/innerkits/native_cpp/screen_source/src/dscreen_source_proxy.cpp", + "${services_path}/common/databuffer/src/data_buffer.cpp", "${services_path}/common/utils/src/dscreen_fwkkit.cpp", - "${services_path}/common/utils/src/dscreen_maprelation.cpp", "${services_path}/common/utils/src/video_param.cpp", - "./dscreenmgr/src/dscreen.cpp", - "./dscreenmgr/src/dscreen_manager.cpp", - "./dscreenmgr/src/screen_manager_adapter.cpp", - "./dscreenservice/src/callback/dscreen_source_callback_proxy.cpp", - "./dscreenservice/src/dscreen_source_service.cpp", - "./dscreenservice/src/dscreen_source_stub.cpp", + "${services_path}/screentransport/screendatachannel/src/screen_data_channel_impl.cpp", + "${services_path}/screentransport/screensourceprocessor/encoder/src/image_encoder_callback.cpp", + "${services_path}/screentransport/screensourceprocessor/encoder/src/image_source_encoder.cpp", + "${services_path}/screentransport/screensourceprocessor/src/image_source_processor.cpp", + "${services_path}/softbusadapter/src/softbus_adapter.cpp", + "./src/screen_source_trans.cpp", ] deps = [ "${common_path}:distributed_screen_utils", "${distributedhardwarefwk_path}/interfaces/inner_kits:libdhfwk_sdk", - "${mediastandard_path}/interfaces/inner_api/native:media_client", - "${services_path}/screentransport/screensourcetrans:distributed_screen_sourcetrans", - "${windowmanager_path}/dm:libdm", + "//foundation/graphic/graphic_2d/frameworks/surface:surface", ] defines = [ "HI_LOG_ENABLE", - "DH_LOG_TAG=\"dscreensource\"", + "DH_LOG_TAG=\"dscreensourcetrans\"", "LOG_DOMAIN=0xD004100", ] external_deps = [ "c_utils:utils", - "ipc:ipc_core", - "safwk:system_ability_fwk", - "samgr:samgr_proxy", + "dsoftbus:softbus_client", + "hisysevent_native:libhisysevent", + "hitrace_native:hitrace_meter", + "hiviewdfx_hilog_native:libhilog", + "multimedia_player_framework:media_client", ] subsystem_name = "distributedhardware" diff --git a/services/screentransport/screensinktrans/BUILD.gn b/services/screentransport/screensinktrans/BUILD.gn index 698a50fec546ae486e54dbd0f0b39c41d179fe90..e7b4ad805b238567168453000579aa0362967b21 100644 --- a/services/screentransport/screensinktrans/BUILD.gn +++ b/services/screentransport/screensinktrans/BUILD.gn @@ -23,6 +23,9 @@ ohos_shared_library("distributed_screen_sinktrans") { "//foundation/graphic/graphic_2d/interfaces/innerkits/surface", "${fwk_common_path}/utils/include", "//base/hiviewdfx/hitrace/interfaces/native/innerkits/include/hitrace_meter", + "${fwk_interfaces_path}/inner_kits/include", + "${ipc_interfaces_path}/innerkits/ipc_core/include", + "${services_path}/common/utils/include", ] include_dirs += [ @@ -40,6 +43,7 @@ ohos_shared_library("distributed_screen_sinktrans") { sources = [ "${services_path}/common/databuffer/src/data_buffer.cpp", + "${services_path}/common/utils/src/dscreen_fwkkit.cpp", "${services_path}/common/utils/src/video_param.cpp", "${services_path}/screentransport/screendatachannel/src/screen_data_channel_impl.cpp", "${services_path}/screentransport/screensinkprocessor/decoder/src/image_decoder_callback.cpp", @@ -51,6 +55,7 @@ ohos_shared_library("distributed_screen_sinktrans") { deps = [ "${common_path}:distributed_screen_utils", + "${distributedhardwarefwk_path}/interfaces/inner_kits:libdhfwk_sdk", "//foundation/graphic/graphic_2d/frameworks/surface:surface", ] diff --git a/services/screentransport/screensinktrans/src/screen_sink_trans.cpp b/services/screentransport/screensinktrans/src/screen_sink_trans.cpp index 8cbcc9dc6b705d55b5a3d6fa6ae5ee5450fd3859..5f6d4373a82f61dcc581dcf6c53f8ced3aa82060 100644 --- a/services/screentransport/screensinktrans/src/screen_sink_trans.cpp +++ b/services/screentransport/screensinktrans/src/screen_sink_trans.cpp @@ -16,6 +16,7 @@ #include "screen_sink_trans.h" #include "dscreen_errcode.h" +#include "dscreen_fwkkit.h" #include "dscreen_hisysevent.h" #include "dscreen_hitrace.h" #include "dscreen_log.h" @@ -280,11 +281,22 @@ int32_t ScreenSinkTrans::RegisterProcessorListener(const VideoParam &localParam, void ScreenSinkTrans::OnSessionOpened() { DHLOGI("%s: OnChannelSessionOpened.", LOG_TAG); + DHLOGD("%s: Sink start enable low latency.", LOG_TAG); + std::shared_ptr dhFwkKit = DScreenFwkKit::GetInstance().GetDHFwkKit(); + if (dhFwkKit != nullptr) { + dhFwkKit->PublishMessage(DHTopic::TOPIC_LOW_LATENCY, ENABLE_LOW_LATENCY.dump()); + } } void ScreenSinkTrans::OnSessionClosed() { DHLOGI("%s:OnChannelSessionClosed.", LOG_TAG); + DHLOGD("%s: Sink stop enable low latency.", LOG_TAG); + std::shared_ptr dhFwkKit = DScreenFwkKit::GetInstance().GetDHFwkKit(); + if (dhFwkKit != nullptr) { + dhFwkKit->PublishMessage(DHTopic::TOPIC_LOW_LATENCY, DISABLE_LOW_LATENCY.dump()); + } + std::shared_ptr callback = transCallback_.lock(); if (callback == nullptr) { DHLOGE("%s: Trans callback is null.", LOG_TAG); diff --git a/services/screentransport/screensourcetrans/BUILD.gn b/services/screentransport/screensourcetrans/BUILD.gn index 3ab2f9b781d7b861bbce60b7351931ff4d022cd0..e9893e8c797dc91dd038694a3903c06652684dfb 100644 --- a/services/screentransport/screensourcetrans/BUILD.gn +++ b/services/screentransport/screensourcetrans/BUILD.gn @@ -23,6 +23,9 @@ ohos_shared_library("distributed_screen_sourcetrans") { "//foundation/graphic/graphic_2d/interfaces/innerkits/surface", "${fwk_common_path}/utils/include", "//base/hiviewdfx/hitrace/interfaces/native/innerkits/include/hitrace_meter", + "${fwk_interfaces_path}/inner_kits/include", + "${ipc_interfaces_path}/innerkits/ipc_core/include", + "${services_path}/common/utils/include", ] include_dirs += [ @@ -39,6 +42,7 @@ ohos_shared_library("distributed_screen_sourcetrans") { sources = [ "${services_path}/common/databuffer/src/data_buffer.cpp", + "${services_path}/common/utils/src/dscreen_fwkkit.cpp", "${services_path}/common/utils/src/video_param.cpp", "${services_path}/screentransport/screendatachannel/src/screen_data_channel_impl.cpp", "${services_path}/screentransport/screensourceprocessor/encoder/src/image_encoder_callback.cpp", @@ -50,6 +54,7 @@ ohos_shared_library("distributed_screen_sourcetrans") { deps = [ "${common_path}:distributed_screen_utils", + "${distributedhardwarefwk_path}/interfaces/inner_kits:libdhfwk_sdk", "//foundation/graphic/graphic_2d/frameworks/surface:surface", ] diff --git a/services/screentransport/screensourcetrans/src/screen_source_trans.cpp b/services/screentransport/screensourcetrans/src/screen_source_trans.cpp index 5491cb3e049183b95b6d972659cfeb900a880af0..986c0651379dc9d1ebcc66d813b15e7c0cbf1027 100644 --- a/services/screentransport/screensourcetrans/src/screen_source_trans.cpp +++ b/services/screentransport/screensourcetrans/src/screen_source_trans.cpp @@ -19,6 +19,7 @@ #include "dscreen_constants.h" #include "dscreen_errcode.h" +#include "dscreen_fwkkit.h" #include "dscreen_hisysevent.h" #include "dscreen_hitrace.h" #include "dscreen_log.h" @@ -102,6 +103,12 @@ int32_t ScreenSourceTrans::Start() return ERR_DH_SCREEN_TRANS_TIMEOUT; } + DHLOGI("%s: Source start enable low latency.", LOG_TAG); + std::shared_ptr dhFwkKit = DScreenFwkKit::GetInstance().GetDHFwkKit(); + if (dhFwkKit != nullptr) { + dhFwkKit->PublishMessage(DHTopic::TOPIC_LOW_LATENCY, ENABLE_LOW_LATENCY.dump()); + } + DHLOGI("%s: Start success.", LOG_TAG); FinishTrace(DSCREEN_HITRACE_LABEL); return DH_SUCCESS; @@ -122,6 +129,12 @@ int32_t ScreenSourceTrans::Stop() stopStatus = false; } + DHLOGI("%s: Source stop enable low latency.", LOG_TAG); + std::shared_ptr dhFwkKit = DScreenFwkKit::GetInstance().GetDHFwkKit(); + if (dhFwkKit != nullptr) { + dhFwkKit->PublishMessage(DHTopic::TOPIC_LOW_LATENCY, DISABLE_LOW_LATENCY.dump()); + } + StartTrace(DSCREEN_HITRACE_LABEL, DSCREEN_SOURCE_CLOSE_SESSION_START); ret = screenChannel_->CloseSession(); FinishTrace(DSCREEN_HITRACE_LABEL);