From: Sangchul Lee Date: Tue, 19 Oct 2021 08:30:02 +0000 (+0900) Subject: Skip creating resource manager handle if any resources required in ini file X-Git-Tag: submit/tizen/20211028.055213~12 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=335f0acb12644cf794ad3429745472bc8ad5e6ec;p=platform%2Fcore%2Fapi%2Fwebrtc.git Skip creating resource manager handle if any resources required in ini file [Version] 0.2.131 [Issue Type] Improvement Change-Id: I1648153301ef56f27c5d07f83d2b8a781baf81d2 Signed-off-by: Sangchul Lee --- diff --git a/include/webrtc_private.h b/include/webrtc_private.h index d1ef4a1d..03f60e8d 100644 --- a/include/webrtc_private.h +++ b/include/webrtc_private.h @@ -542,6 +542,7 @@ typedef struct webrtc_signaling_client_s { int _load_ini(webrtc_s *webrtc); void _unload_ini(webrtc_s *webrtc); ini_item_media_source_s* _ini_get_source_by_type(webrtc_ini_s *ini, int type); +bool _is_resource_required(webrtc_ini_s *ini); int _webrtc_stop(webrtc_s *webrtc); int _gst_init(webrtc_s *webrtc); diff --git a/packaging/capi-media-webrtc.spec b/packaging/capi-media-webrtc.spec index 57162315..2012fba1 100644 --- a/packaging/capi-media-webrtc.spec +++ b/packaging/capi-media-webrtc.spec @@ -1,6 +1,6 @@ Name: capi-media-webrtc Summary: A WebRTC library in Tizen Native API -Version: 0.2.130 +Version: 0.2.131 Release: 0 Group: Multimedia/API License: Apache-2.0 diff --git a/src/webrtc.c b/src/webrtc.c index 05bcc568..540d9f2f 100644 --- a/src/webrtc.c +++ b/src/webrtc.c @@ -81,14 +81,6 @@ int webrtc_create(webrtc_h *webrtc) _webrtc = g_new0(webrtc_s, 1); -#ifndef TIZEN_TV - ret = _create_resource_manager(_webrtc); - if (ret != WEBRTC_ERROR_NONE) { - LOG_ERROR("failed to create resource manager"); - g_free(_webrtc); - return ret; - } -#endif g_mutex_init(&_webrtc->mutex); g_mutex_lock(&_webrtc->mutex); @@ -96,6 +88,20 @@ int webrtc_create(webrtc_h *webrtc) g_cond_init(&_webrtc->desc_cond); _load_ini(_webrtc); + if (_is_resource_required(&_webrtc->ini)) { +#ifndef TIZEN_TV + ret = _create_resource_manager(_webrtc); + if (ret != WEBRTC_ERROR_NONE) { + LOG_ERROR("failed to create resource manager"); + _unload_ini(_webrtc); + g_mutex_unlock(&_webrtc->mutex); + g_free(_webrtc); + return ret; + } +#else + LOG_WARNING("no resource manager integration yet"); +#endif + } _gst_init(_webrtc); _gst_build_pipeline(_webrtc); _init_data_channels(_webrtc); diff --git a/src/webrtc_ini.c b/src/webrtc_ini.c index 2b4b5dc5..efc778f1 100644 --- a/src/webrtc_ini.c +++ b/src/webrtc_ini.c @@ -499,6 +499,16 @@ ini_item_media_source_s* _ini_get_source_by_type(webrtc_ini_s *ini, int type) return (ini_item_media_source_s*)g_hash_table_lookup(ini->sources, category_source_names[type]); } +bool _is_resource_required(webrtc_ini_s *ini) +{ + RET_VAL_IF(ini == NULL, false, "ini is NULL"); + + return (ini->resource_acquisition.camera || + ini->resource_acquisition.video_encoder || + ini->resource_acquisition.video_decoder || + ini->resource_acquisition.video_overlay); +} + void _unload_ini(webrtc_s *webrtc) { RET_IF(webrtc == NULL, "webrtc is NULL"); diff --git a/src/webrtc_resource.c b/src/webrtc_resource.c index 53603f39..08608548 100644 --- a/src/webrtc_resource.c +++ b/src/webrtc_resource.c @@ -82,9 +82,11 @@ int _acquire_resource_for_type(webrtc_s *webrtc, mm_resource_manager_res_type_e int ret = MM_RESOURCE_MANAGER_ERROR_NONE; RET_VAL_IF(webrtc == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "webrtc is NULL"); - RET_VAL_IF(webrtc->resource.mgr == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "resource manager is NULL"); RET_VAL_IF(type >= RESOURCE_TYPE_MAX, WEBRTC_ERROR_INVALID_PARAMETER, "invalid type(%d)", type); + if (!webrtc->resource.mgr) + return WEBRTC_ERROR_NONE; + if (webrtc->resource.res[type] != NULL) { LOG_ERROR("type[%d] resource was already acquired", type); return WEBRTC_ERROR_RESOURCE_FAILED; @@ -114,8 +116,9 @@ int _release_all_resources(webrtc_s *webrtc) int ret = MM_RESOURCE_MANAGER_ERROR_NONE; RET_VAL_IF(webrtc == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "webrtc is NULL"); - RET_VAL_IF(webrtc->resource.mgr == NULL, WEBRTC_ERROR_INVALID_PARAMETER, - "resource manager is NULL"); + + if (!webrtc->resource.mgr) + return WEBRTC_ERROR_NONE; if (webrtc->resource.release_cb_is_calling) { LOG_INFO("__resource_release_cb is calling, so skip"); @@ -147,8 +150,9 @@ int _destroy_resource_manager(webrtc_s *webrtc) int ret = MM_RESOURCE_MANAGER_ERROR_NONE; RET_VAL_IF(webrtc == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "webrtc is NULL"); - RET_VAL_IF(webrtc->resource.mgr == NULL, WEBRTC_ERROR_INVALID_PARAMETER, - "resource manager is NULL"); + + if (!webrtc->resource.mgr) + return WEBRTC_ERROR_NONE; ret = mm_resource_manager_destroy(webrtc->resource.mgr); if (ret != MM_RESOURCE_MANAGER_ERROR_NONE) {