Skip creating resource manager handle if any resources required in ini file 32/265432/1
authorSangchul Lee <sc11.lee@samsung.com>
Tue, 19 Oct 2021 08:30:02 +0000 (17:30 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Tue, 19 Oct 2021 08:40:53 +0000 (17:40 +0900)
[Version] 0.2.131
[Issue Type] Improvement

Change-Id: I1648153301ef56f27c5d07f83d2b8a781baf81d2
Signed-off-by: Sangchul Lee <sc11.lee@samsung.com>
include/webrtc_private.h
packaging/capi-media-webrtc.spec
src/webrtc.c
src/webrtc_ini.c
src/webrtc_resource.c

index d1ef4a1d9edbaabbc38e8a70bcab5d15053c383d..03f60e8dedd0266ad2f3b653d694685def451247 100644 (file)
@@ -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);
index 571623154afea6e175595fe837f8621465ca9f0a..2012fba1ff5c2f6831b4c49c8ed40e842f284013 100644 (file)
@@ -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
index 05bcc568de3fe587621610a8b443a995e9f17836..540d9f2fb66aa167091827f3f86bd82083b9fb0f 100644 (file)
@@ -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);
index 2b4b5dc5b9b92234c7a7424b19735e19f775262c..efc778f19687cd6cc2852a6ef6ff266e5e239651 100644 (file)
@@ -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");
index 53603f398df4ad25672a3ea5f20285eba4e1295d..08608548603b6f8ee95f7aed3bb82209deeb9440 100644 (file)
@@ -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) {