From 13160898daf131b8a1e2f50639106ba8e276ef1e Mon Sep 17 00:00:00 2001 From: wy19970731 Date: Fri, 15 Aug 2025 15:15:20 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E8=93=9D=E9=BB=84=E5=90=8C=E6=AD=A5=20Sign?= =?UTF-8?q?ed-off-by:=20luminous=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../session/src/napi_avcast_controller.cpp | 62 +++++-------------- frameworks/native/session/BUILD.gn | 8 ++- .../native/session/include/avsession_info.h | 4 +- services/session/BUILD.gn | 49 +++++++++++---- services/session/server/avrouter_impl.cpp | 2 +- services/session/server/avsession_item.cpp | 19 +++--- 6 files changed, 69 insertions(+), 75 deletions(-) diff --git a/frameworks/js/napi/session/src/napi_avcast_controller.cpp b/frameworks/js/napi/session/src/napi_avcast_controller.cpp index 8f76b6cf..5f4b7945 100755 --- a/frameworks/js/napi/session/src/napi_avcast_controller.cpp +++ b/frameworks/js/napi/session/src/napi_avcast_controller.cpp @@ -420,9 +420,7 @@ napi_value NapiAVCastController::GetDuration(napi_env env, napi_callback_info in } else if (ret == ERR_NO_PERMISSION) { context->errMessage = "GetDuration failed : native no permission"; } else { - context->errMessage = "GetDuration failed : native server exception, \ - you are advised to : 1.scheduled retry.\ - 2.destroy the current session or session controller and re-create it."; + context->errMessage = "GetDuration failed : native server exception"; } SLOGE("controller GetDuration failed:%{public}d", ret); context->status = napi_generic_failure; @@ -465,9 +463,7 @@ napi_value NapiAVCastController::GetCastAVPlaybackState(napi_env env, napi_callb } else if (ret == ERR_NO_PERMISSION) { context->errMessage = "GetCastAVPlaybackState failed : native no permission"; } else { - context->errMessage = "GetCastAVPlaybackState failed : native server exception, \ - you are advised to : 1.scheduled retry.\ - 2.destroy the current session or session controller and re-create it."; + context->errMessage = "GetCastAVPlaybackState failed : native server exception"; } SLOGE("controller GetCastAVPlaybackState failed:%{public}d", ret); context->status = napi_generic_failure; @@ -510,9 +506,7 @@ napi_value NapiAVCastController::GetSupportedDecoders(napi_env env, napi_callbac } else if (ret == ERR_NO_PERMISSION) { context->errMessage = "GetSupportedDecoders failed : native no permission"; } else { - context->errMessage = "GetSupportedDecoders failed : native server exception, \ - you are advised to : 1.scheduled retry.\ - 2.destroy the current session or session controller and re-create it."; + context->errMessage = "GetSupportedDecoders failed : native server exception"; } SLOGE("controller GetSupportedDecoders failed:%{public}d", ret); context->status = napi_generic_failure; @@ -565,9 +559,7 @@ napi_value NapiAVCastController::GetRecommendedResolutionLevel(napi_env env, nap } else if (ret == ERR_NO_PERMISSION) { context->errMessage = "GetRecommendedResolutionLevel failed : native no permission"; } else { - context->errMessage = "GetRecommendedResolutionLevel failed : native server exception, \ - you are advised to : 1.scheduled retry.\ - 2.destroy the current session or session controller and re-create it."; + context->errMessage = "GetRecommendedResolutionLevel failed : native server exception"; } SLOGE("controller GetRecommendedResolutionLevel failed:%{public}d", ret); context->status = napi_generic_failure; @@ -610,9 +602,7 @@ napi_value NapiAVCastController::GetSupportedHdrCapabilities(napi_env env, napi_ } else if (ret == ERR_NO_PERMISSION) { context->errMessage = "GetSupportedHdrCapabilities failed : native no permission"; } else { - context->errMessage = "GetSupportedHdrCapabilities failed : native server exception, \ - you are advised to : 1.scheduled retry.\ - 2.destroy the current session or session controller and re-create it."; + context->errMessage = "GetSupportedHdrCapabilities failed : native server exception"; } SLOGE("controller GetSupportedHdrCapabilities failed:%{public}d", ret); context->status = napi_generic_failure; @@ -655,9 +645,7 @@ napi_value NapiAVCastController::GetSupportedPlaySpeeds(napi_env env, napi_callb } else if (ret == ERR_NO_PERMISSION) { context->errMessage = "GetSupportedPlaySpeeds failed : native no permission"; } else { - context->errMessage = "GetSupportedPlaySpeeds failed : native server exception, \ - you are advised to : 1.scheduled retry.\ - 2.destroy the current session or session controller and re-create it."; + context->errMessage = "GetSupportedPlaySpeeds failed : native server exception"; } SLOGE("controller GetSupportedPlaySpeeds failed:%{public}d", ret); context->status = napi_generic_failure; @@ -700,9 +688,7 @@ napi_value NapiAVCastController::GetCurrentItem(napi_env env, napi_callback_info } else if (ret == ERR_NO_PERMISSION) { context->errMessage = "GetCurrentItem failed : native no permission"; } else { - context->errMessage = "GetCurrentItem failed : native server exception, \ - you are advised to : 1.scheduled retry.\ - 2.destroy the current session or session controller and re-create it."; + context->errMessage = "GetCurrentItem failed : native server exception"; } SLOGE("controller GetCurrentItem failed:%{public}d", ret); context->status = napi_generic_failure; @@ -746,9 +732,7 @@ napi_value NapiAVCastController::GetValidCommands(napi_env env, napi_callback_in } else if (ret == ERR_NO_PERMISSION) { context->errMessage = "GetValidCommands failed : native no permission"; } else { - context->errMessage = "GetValidCommands failed : native server exception, \ - you are advised to : 1.scheduled retry.\ - 2.destroy the current session or session controller and re-create it."; + context->errMessage = "GetValidCommands failed : native server exception"; } SLOGE("controller GetValidCommands failed:%{public}d", ret); context->status = napi_generic_failure; @@ -795,9 +779,7 @@ napi_value NapiAVCastController::Release(napi_env env, napi_callback_info info) } else if (ret == ERR_NO_PERMISSION) { context->errMessage = "release failed : native no permission"; } else { - context->errMessage = "release failed : native server exception, \ - you are advised to : 1.scheduled retry.\ - 2.destroy the current session or session controller and re-create it."; + context->errMessage = "release failed : native server exception"; } SLOGE("controller release failed:%{public}d", ret); context->status = napi_generic_failure; @@ -845,14 +827,11 @@ napi_value NapiAVCastController::SetDisplaySurface(napi_env env, napi_callback_i } else if (ret == ERR_COMMAND_NOT_SUPPORT) { context->errMessage = "SetDisplaySurface failed : native command not support"; } else if (ret == ERR_COMMAND_SEND_EXCEED_MAX) { - context->errMessage = "SetDisplaySurface failed : native command send nums overload, \ - controls the frequency of sending self-query and control commands"; + context->errMessage = "SetDisplaySurface failed : native command send nums overload"; } else if (ret == ERR_NO_PERMISSION) { context->errMessage = "SetDisplaySurface failed : native no permission"; } else { - context->errMessage = "SetDisplaySurface failed : native server exception, \ - you are advised to : 1.scheduled retry.\ - 2.destroy the current session or session controller and re-create it."; + context->errMessage = "SetDisplaySurface failed : native server exception"; } SLOGE("controller SetDisplaySurface failed:%{public}d", ret); context->status = napi_generic_failure; @@ -902,9 +881,7 @@ napi_value NapiAVCastController::ProcessMediaKeyResponse(napi_env env, napi_call } else if (ret == ERR_NO_PERMISSION) { context->errMessage = "ProcessMediaKeyResponse failed : native no permission"; } else { - context->errMessage = "ProcessMediaKeyResponse failed : native server exception, \ - you are advised to : 1.scheduled retry.\ - 2.destroy the current session or session controller and re-create it."; + context->errMessage = "ProcessMediaKeyResponse failed : native server exception"; } SLOGE("controller ProcessMediaKeyResponse failed:%{public}d", ret); context->status = napi_generic_failure; @@ -951,9 +928,7 @@ napi_status NapiAVCastController::RegisterCallback(napi_env env, const std::shar NapiUtils::ThrowError(env, "OnEvent failed : native no permission", NapiAVSessionManager::errcode_[ERR_NO_PERMISSION]); } else { - NapiUtils::ThrowError(env, "OnEvent failed : native server exception, \ - you are advised to : 1.scheduled retry.\ - 2.destroy the current session or session controller and re-create it.", + NapiUtils::ThrowError(env, "OnEvent failed : native server exception", NapiAVSessionManager::errcode_[ret]); } napiCastController->callback_ = nullptr; @@ -1497,9 +1472,7 @@ void NapiAVCastController::ErrCodeToMessage(int32_t errCode, std::string& messag message = "SetSessionEvent failed : native no permission"; break; default: - message = "SetSessionEvent failed : native server exception, \ - you are advised to : 1.scheduled retry.\ - 2.destroy the current session or session controller and re-create it."; + message = "SetSessionEvent failed : native server exception"; break; } } @@ -1552,13 +1525,10 @@ std::string NapiAVCastController::GetSendControlCommandErrMsg(int32_t error) msg = "SendControlCommand failed : native command not support"; break; case ERR_COMMAND_SEND_EXCEED_MAX: - msg = "SendControlCommand failed : native command send nums overload, \ - controls the frequency of sending self-query and control commands"; + msg = "SendControlCommand failed : native command send nums overload"; break; default: - msg = "SendControlCommand failed : native server exception, \ - you are advised to : 1.scheduled retry.\ - 2.destroy the current session or session controller and re-create it."; + msg = "SendControlCommand failed : native server exception"; break; } return msg; diff --git a/frameworks/native/session/BUILD.gn b/frameworks/native/session/BUILD.gn index 8083ba97..22c055d5 100644 --- a/frameworks/native/session/BUILD.gn +++ b/frameworks/native/session/BUILD.gn @@ -77,13 +77,14 @@ ohos_shared_library("avsession_client") { ] deps = [ - "../../common:avsession_common", "../../../services/session:libidl_avsession_service_interface_stub", "../../../services/session:libidl_avsession_service_interface_proxy", + "../../common:avsession_common", "../../../utils:avsession_utils", - "../session:avsession_cast_client", ] + public_deps = [] + external_deps = [ "ability_base:want", "ability_runtime:wantagent_innerkits", @@ -99,6 +100,7 @@ ohos_shared_library("avsession_client") { if (castplus_cast_engine_enable) { cflags += [ "-DCASTPLUS_CAST_ENGINE_ENABLE" ] + public_deps += [ "./../session:avsession_cast_client" ] } if (multimedia_av_session_enable_trace_control) { @@ -220,7 +222,7 @@ ohos_shared_library("avsession_cast_client") { deps = [ "../../../services/session:libidl_avsession_service_interface_stub", - "../../../services/session:libidl_avsession_service_interface_proxy", + "../../../services/session:libidl_avsession_service_interface_proxy", ] external_deps = [ diff --git a/interfaces/inner_api/native/session/include/avsession_info.h b/interfaces/inner_api/native/session/include/avsession_info.h index af68ea4c..79c2d93b 100644 --- a/interfaces/inner_api/native/session/include/avsession_info.h +++ b/interfaces/inner_api/native/session/include/avsession_info.h @@ -734,7 +734,7 @@ enum DeviceType { }; /** - * The defination of suggested resolution. + * The definition of suggested resolution. * @enum { number } * @syscap SystemCapability.Multimedia.AVSession.AVCast * @atomicservice @@ -750,7 +750,7 @@ enum ResolutionLevel { RESOLUTION_480P = 0, /** - * Defination of 720P which typically resolution is 1280*720. + * Definition of 720P which typically resolution is 1280*720. * @syscap SystemCapability.Multimedia.AVSession.AVCast * @atomicservice * @since 18 diff --git a/services/session/BUILD.gn b/services/session/BUILD.gn index 230c71bc..510a1c48 100644 --- a/services/session/BUILD.gn +++ b/services/session/BUILD.gn @@ -61,19 +61,19 @@ idl_gen_interface("idl_avsession_service_interface") { ] sources_cpp = [ - "../../frameworks/common/src/avsession_descriptor.cpp", - "../../frameworks/common/src/avplayback_state.cpp", - "../../frameworks/common/src/avqueue_item.cpp", - "../../frameworks/common/src/avmedia_description.cpp", - "../../frameworks/common/src/av_file_descriptor.cpp", "../../frameworks/common/src/av_data_src_descriptor.cpp", - "../../frameworks/common/src/avsession_pixel_map.cpp", + "../../frameworks/common/src/av_file_descriptor.cpp", "../../frameworks/common/src/avcall_meta_data.cpp", "../../frameworks/common/src/avcall_state.cpp", - "../../frameworks/common/src/avmeta_data.cpp", "../../frameworks/common/src/avcast_control_command.cpp", "../../frameworks/common/src/avcontrol_command.cpp", + "../../frameworks/common/src/avmedia_description.cpp", + "../../frameworks/common/src/avmeta_data.cpp", + "../../frameworks/common/src/avplayback_state.cpp", "../../frameworks/common/src/avqueue_info.cpp", + "../../frameworks/common/src/avqueue_item.cpp", + "../../frameworks/common/src/avsession_descriptor.cpp", + "../../frameworks/common/src/avsession_pixel_map.cpp", "../../frameworks/common/src/av_shared_memory_base.cpp", ] @@ -91,11 +91,22 @@ idl_gen_interface("idl_avsession_service_interface") { ] log_domainid = "0xD001315" - log_tag = "UriPermMgr" + log_tag = "AvsessionIdl" subsystem_name = "multimedia" part_name = "av_session" } +group("avsession_server_static") { + deps = [ + ":avsession_dynamic_insight", + ":avsession_item_static", + ":avsession_service_static", + "../../sa_profile:avsession_sa_profile", + "../etc:avsession_service.rc", + "../etc:ohos.para.dac", + ] +} + av_session_ohos_library("avsession_service") { stack_protector_ret = true install_enable = true @@ -195,14 +206,15 @@ av_session_ohos_library("avsession_service") { defines += [ "SYSTEM_LIB_PATH = ${system_lib_path}" ] deps = [ + "./../../frameworks/common:avsession_common", ":libidl_avsession_service_interface_proxy", ":libidl_avsession_service_interface_stub", - "./../../frameworks/common:avsession_common", "./../../utils:avsession_utils", "./../session:avsession_item", ] external_deps = [ + "relational_store:native_rdb", "ability_base:base", "ability_base:zuri", "ability_runtime:app_manager", @@ -215,7 +227,9 @@ av_session_ohos_library("avsession_service") { "background_task_mgr:bgtaskmgr_innerkits", "bundle_framework:appexecfwk_base", "bundle_framework:appexecfwk_core", + "cJSON:cjson", "c_utils:utils", + "data_object:distributeddataobject_impl", "device_manager:devicemanagersdk", "distributed_notification_service:ans_innerkits", "dsoftbus:softbus_client", @@ -224,6 +238,8 @@ av_session_ohos_library("avsession_service") { "init:libbegetutil", "input:libmmi-client", "ipc:ipc_single", + "openssl:libcrypto_shared", + "relational_store:native_rdb", "safwk:system_ability_fwk", "samgr:samgr_proxy", "window_manager:libdm_lite", @@ -378,6 +394,8 @@ if (castplus_cast_engine_enable) { "samgr:samgr_proxy", ] + public_configs = [":avsession_ipc_config"] + if (castplus_cast_engine_enable) { cflags += [ "-DCASTPLUS_CAST_ENGINE_ENABLE" ] external_deps += [ "cast_engine:cast_engine_client" ] @@ -395,7 +413,7 @@ if (castplus_cast_engine_enable) { subsystem_name = "multimedia" part_name = "av_session" - version_script = "avsession_router.versionscript" + #version_script = "avsession_router.versionscript" } } @@ -544,12 +562,12 @@ av_session_ohos_library("avsession_item") { deps = [ "../../frameworks/common:avsession_common", - "../../frameworks/native/session:avsession_client", - "../../utils:avsession_utils", ":libidl_avsession_service_interface_proxy", + "../../utils:avsession_utils", ] external_deps = [ + "relational_store:native_rdb", "ability_base:base", "ability_base:want", "ability_runtime:app_manager", @@ -563,11 +581,13 @@ av_session_ohos_library("avsession_item") { "bundle_framework:appexecfwk_core", "cJSON:cjson", "c_utils:utils", + "data_object:distributeddataobject_impl", "device_manager:devicemanagersdk", "graphic_surface:surface", "hilog:libhilog", "input:libmmi-client", "ipc:ipc_single", + "openssl:libcrypto_shared", "safwk:system_ability_fwk", "samgr:samgr_proxy", "window_manager:libdm_lite", @@ -708,6 +728,7 @@ av_session_ohos_library("avsession_cast_item") { "audio_framework:audio_client", "bundle_framework:appexecfwk_base", "bundle_framework:appexecfwk_core", + "cJSON:cjson", "c_utils:utils", "data_object:distributeddataobject_impl", "device_manager:devicemanagersdk", @@ -715,6 +736,8 @@ av_session_ohos_library("avsession_cast_item") { "hilog:libhilog", "input:libmmi-client", "ipc:ipc_single", + "json:nlohman_json", + "openssl:libcrypto_shared", "safwk:system_ability_fwk", "samgr:samgr_proxy", ] @@ -746,5 +769,5 @@ av_session_ohos_library("avsession_cast_item") { subsystem_name = "multimedia" part_name = "av_session" - version_script = "avsession_cast_item.versionscript" + #version_script = "avsession_cast_item.versionscript" } diff --git a/services/session/server/avrouter_impl.cpp b/services/session/server/avrouter_impl.cpp index 7845b0c2..449d17c7 100644 --- a/services/session/server/avrouter_impl.cpp +++ b/services/session/server/avrouter_impl.cpp @@ -166,7 +166,7 @@ int32_t AVRouterImpl::StopCastDiscovery() auto pid = IPCSkeleton::GetCallingPid(); CHECK_AND_RETURN_RET_LOG(IsStopCastDiscovery(pid), AVSESSION_SUCCESS, - "StopCastDiscovery is invalid"); + "StartCastDiscovery is still in use, no need to stop"); if (cacheStartDiscovery_) { SLOGI("clear cacheStartDiscovery when stop discovery"); cacheStartDiscovery_ = false; diff --git a/services/session/server/avsession_item.cpp b/services/session/server/avsession_item.cpp index 8ac23725..72582c82 100644 --- a/services/session/server/avsession_item.cpp +++ b/services/session/server/avsession_item.cpp @@ -36,8 +36,8 @@ #include "bool_wrapper.h" #include "string_wrapper.h" #include "int_wrapper.h" -#include "avsession_hianalytics_report.h" #include "want_agent_helper.h" +#include "avsession_hianalytics_report.h" #ifdef CASTPLUS_CAST_ENGINE_ENABLE #include "avcast_controller_proxy.h" @@ -100,10 +100,12 @@ AVSessionItem::~AVSessionItem() Deactivate(); } { - std::lock_guard callbackForCastCapLockGuard(callbackForCastCapLock_); - if (castControllerProxy_ != nullptr) { - castControllerProxy_->SetSessionCallbackForCastCap(nullptr); - } + #if CASTPLUS_CAST_ENGINE_ENABLE + std::lock_guard callbackForCastCapLockGuard(callbackForCastCapLock_); + if (castControllerProxy_ != nullptr) { + castControllerProxy_->SetSessionCallbackForCastCap(nullptr); + } + #endif } { std::lock_guard aliveLockGuard(isAliveLock_); @@ -137,8 +139,7 @@ void AVSessionItem::UpdateSessionElement(const AppExecFwk::ElementName& elementN int32_t AVSessionItem::Destroy() { - SLOGI("AVSessionItem %{public}d check service destroy event with service, check serviceCallback exist", - static_cast(GetPid())); + SLOGI("AVSessionItem check service destroy event with service, check serviceCallback exist"); { std::lock_guard lockGuard(destroyLock_); if (isDestroyed_) { @@ -207,7 +208,7 @@ int32_t AVSessionItem::DestroyTask(bool continuePlay) } #ifdef CASTPLUS_CAST_ENGINE_ENABLE - SLOGI("Session destroy with castHandle: %{public}lld", (long long)castHandle_); + SLOGI("Session destroy with castHandle: %{public}ld", castHandle_); if (descriptor_.sessionTag_ != "RemoteCast" && castHandle_ > 0) { CollaborationManager::GetInstance().PublishServiceState(collaborationNeedDeviceId_.c_str(), ServiceCollaborationManagerBussinessStatus::SCM_IDLE); @@ -324,7 +325,6 @@ void AVSessionItem::UpdateRecommendInfo(bool needRecommend) metaData_.GetAssetId(), -1); } } - } void AVSessionItem::HandleFrontSession() @@ -373,7 +373,6 @@ bool AVSessionItem::HasAvQueueInfo() SLOGD("current avqueueinfo is not playing"); return false; } - return true; } -- Gitee From d4e08777651e7483bb4a316cefac322297e257c0 Mon Sep 17 00:00:00 2001 From: wy19970731 Date: Wed, 20 Aug 2025 11:01:39 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E7=8B=AC=E7=AB=8B=E7=BC=96=E8=AF=91?= =?UTF-8?q?=EF=BC=9A=E9=85=8D=E5=90=88ability=5Fruntime=E5=88=A0=E9=99=A4p?= =?UTF-8?q?ublic=5Fdeps=20Signed-off-by:=20luminous=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frameworks/js/napi/session/BUILD.gn | 1 + 1 file changed, 1 insertion(+) diff --git a/frameworks/js/napi/session/BUILD.gn b/frameworks/js/napi/session/BUILD.gn index b712b6f5..28f4e80d 100644 --- a/frameworks/js/napi/session/BUILD.gn +++ b/frameworks/js/napi/session/BUILD.gn @@ -66,6 +66,7 @@ ohos_shared_library("avsession_napi") { "ability_runtime:ability_manager", "ability_runtime:abilitykit_native", "ability_runtime:app_manager", + "ability_runtime:extensionkit_native", "ability_runtime:napi_base_context", "ability_runtime:napi_common", "ability_runtime:ui_extension", -- Gitee