webrtc_ini: Add new category for resource acquisition 57/259957/5
authorSangchul Lee <sc11.lee@samsung.com>
Thu, 17 Jun 2021 02:52:25 +0000 (11:52 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Fri, 18 Jun 2021 05:34:10 +0000 (14:34 +0900)
'resource acquisition' category is added.
'camera', 'video encoder', 'video decoder' and 'video overlay'
items are added for this category.

e.g.)
[resource acquisition]
camera = yes
video encoder = no
video decoder = no
video overlay = no

The previous 'video overlay resource required' item is migrated
to this new 'video overlay' item.

Now it is possible to determine whether these resources must be
acquired or not by the configuration file.

[Version] 0.2.18
[Issue Type] Improvement

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

index c636ee8c599b7e7996bb05d4ba4f505513ff51bc..c4c56a174b8c1e5188283b109be850e0387933cb 100644 (file)
@@ -292,6 +292,13 @@ typedef struct _ini_item_rendering_sink_s {
        bool v_overlay_resource_required;
 } ini_item_rendering_sink_s;
 
+typedef struct _ini_item_resource_acquisition_s {
+       bool camera;
+       bool video_encoder;
+       bool video_decoder;
+       bool video_overlay;
+} ini_item_resource_acquisition_s;
+
 typedef struct _ini_item_vpxenc_params_s {
        int threads;
        int end_usage;
@@ -308,6 +315,7 @@ typedef struct _webrtc_ini_s {
        ini_item_general_s general;
        ini_item_media_source_s media_source;
        ini_item_rendering_sink_s rendering_sink;
+       ini_item_resource_acquisition_s resource_acquisition;
        ini_item_vpxenc_params_s vpxenc_params;
        GHashTable *sources;
 } webrtc_ini_s;
index 6a18747df87f0a4f8c0ce16412c037bd9cf13c97..7aade4961b704c981fb9c69635c1cd6a50642835 100644 (file)
@@ -1,6 +1,6 @@
 Name:       capi-media-webrtc
 Summary:    A WebRTC library in Tizen Native API
-Version:    0.2.17
+Version:    0.2.18
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
index 17fdf3e0cededdb6d5b340ea2ff6d23a2894b6c5..89cbcb94375b575580e334883213b7374f823dc1 100644 (file)
@@ -35,6 +35,7 @@
 #define INI_CATEGORY_SOURCE_SCREEN        "source screen"
 #define INI_CATEGORY_SOURCE_FILE          "source file"
 #define INI_CATEGORY_RENDERING_SINK       "rendering sink"
+#define INI_CATEGORY_RESOURCE_ACQUISITION "resource acquisition"
 #define INI_CATEGORY_VPXENC_PARAMS        "vpxenc params"
 
 /* items for general */
 #define INI_ITEM_VIDEO_SINK_ELEMENT               "video sink element"
 #define INI_ITEM_AUDIO_HW_DECODER_ELEMENTS        "audio hw decoder elements"
 #define INI_ITEM_VIDEO_HW_DECODER_ELEMENTS        "video hw decoder elements"
-#define INI_ITEM_VIDEO_OVERLAY_RESOURCE_REQUIRED  "video overlay resource required"
 
 #define DEFAULT_VIDEO_SINK_ELEMENT                "tizenwlsink"
 #define DEFAULT_AUDIO_SINK_ELEMENT                "pulsesink"
-#define DEFAULT_VIDEO_OVERLAY_RESOURCE_REQUIRED   false
+
+/* items for resource acquisition */
+#define INI_ITEM_RESOURCE_CAMERA                "camera"
+#define INI_ITEM_RESOURCE_VIDEO_ENCODER         "video encoder"
+#define INI_ITEM_RESOURCE_VIDEO_DECODER         "video decoder"
+#define INI_ITEM_RESOURCE_VIDEO_OVERLAY         "video overlay"
+
+#define DEFAULT_RESOURCE_CAMERA_REQUIRED         false
+#define DEFAULT_RESOURCE_VIDEO_ENCODER_REQUIRED  false
+#define DEFAULT_RESOURCE_VIDEO_DECODER_REQUIRED  false
+#define DEFAULT_RESOURCE_VIDEO_OVERLAY_REQUIRED  false
 
 /* items for vpxenc parameters */
 #define INI_ITEM_VPXENC_THREADS             "threads"
@@ -213,7 +223,12 @@ static void __dump_ini(webrtc_ini_s *ini)
        __dump_item(INI_ITEM_VIDEO_SINK_ELEMENT, INI_ITEM_TYPE_STRING, (void *)ini->rendering_sink.v_sink_element);
        __dump_item(INI_ITEM_AUDIO_HW_DECODER_ELEMENTS, INI_ITEM_TYPE_STRINGS, ini->rendering_sink.a_hw_decoder_elements);
        __dump_item(INI_ITEM_VIDEO_HW_DECODER_ELEMENTS, INI_ITEM_TYPE_STRINGS, ini->rendering_sink.v_hw_decoder_elements);
-       __dump_item(INI_ITEM_VIDEO_OVERLAY_RESOURCE_REQUIRED, INI_ITEM_TYPE_BOOL, &ini->rendering_sink.v_overlay_resource_required);
+
+       LOG_INFO("[%s]", INI_CATEGORY_RESOURCE_ACQUISITION);
+       __dump_item(INI_ITEM_RESOURCE_CAMERA, INI_ITEM_TYPE_BOOL, &ini->resource_acquisition.camera);
+       __dump_item(INI_ITEM_RESOURCE_VIDEO_ENCODER, INI_ITEM_TYPE_BOOL, &ini->resource_acquisition.video_encoder);
+       __dump_item(INI_ITEM_RESOURCE_VIDEO_DECODER, INI_ITEM_TYPE_BOOL, &ini->resource_acquisition.video_decoder);
+       __dump_item(INI_ITEM_RESOURCE_VIDEO_OVERLAY, INI_ITEM_TYPE_BOOL, &ini->resource_acquisition.video_overlay);
 
        LOG_INFO("[%s]", INI_CATEGORY_VPXENC_PARAMS);
        __dump_item(INI_ITEM_VPXENC_THREADS, INI_ITEM_TYPE_INT, &ini->vpxenc_params.threads);
@@ -439,8 +454,15 @@ int _load_ini(webrtc_s *webrtc)
        ini->rendering_sink.v_sink_element = __ini_get_string(ini->dict, INI_CATEGORY_RENDERING_SINK, INI_ITEM_VIDEO_SINK_ELEMENT, DEFAULT_VIDEO_SINK_ELEMENT);
        __ini_read_list(ini->dict, INI_CATEGORY_RENDERING_SINK, INI_ITEM_AUDIO_HW_DECODER_ELEMENTS, &ini->rendering_sink.a_hw_decoder_elements);
        __ini_read_list(ini->dict, INI_CATEGORY_RENDERING_SINK, INI_ITEM_VIDEO_HW_DECODER_ELEMENTS, &ini->rendering_sink.v_hw_decoder_elements);
-       ini->rendering_sink.v_overlay_resource_required = __ini_get_boolean(ini->dict, INI_CATEGORY_RENDERING_SINK,
-               INI_ITEM_VIDEO_OVERLAY_RESOURCE_REQUIRED, DEFAULT_VIDEO_OVERLAY_RESOURCE_REQUIRED);
+
+       ini->resource_acquisition.camera = __ini_get_boolean(ini->dict, INI_CATEGORY_RESOURCE_ACQUISITION,
+               INI_ITEM_RESOURCE_CAMERA, DEFAULT_RESOURCE_CAMERA_REQUIRED);
+       ini->resource_acquisition.video_encoder = __ini_get_boolean(ini->dict, INI_CATEGORY_RESOURCE_ACQUISITION,
+               INI_ITEM_RESOURCE_VIDEO_ENCODER, DEFAULT_RESOURCE_VIDEO_ENCODER_REQUIRED);
+       ini->resource_acquisition.video_decoder = __ini_get_boolean(ini->dict, INI_CATEGORY_RESOURCE_ACQUISITION,
+               INI_ITEM_RESOURCE_VIDEO_DECODER, DEFAULT_RESOURCE_VIDEO_DECODER_REQUIRED);
+       ini->resource_acquisition.video_overlay = __ini_get_boolean(ini->dict, INI_CATEGORY_RESOURCE_ACQUISITION,
+               INI_ITEM_RESOURCE_VIDEO_OVERLAY, DEFAULT_RESOURCE_VIDEO_OVERLAY_REQUIRED);
 
        if (__is_vpx(ini->media_source.v_codec))
                __apply_vpxenc_params_setting(ini, &ini->vpxenc_params, INI_CATEGORY_VPXENC_PARAMS);
index 2218039ac2264ff1dc9614d2d7e7ceb4ade482fc..86a29dac5d7d4731ef424265a0a17cd9f66010e0 100644 (file)
@@ -77,24 +77,13 @@ int _create_resource_manager(webrtc_s *webrtc)
        return WEBRTC_ERROR_NONE;
 }
 
-static bool __is_valid_resource_type(mm_resource_manager_res_type_e type)
-{
-       if (type < MM_RESOURCE_MANAGER_RES_TYPE_VIDEO_DECODER || type >= RESOURCE_TYPE_MAX) {
-               LOG_ERROR("Type[%d] is a invalid resource type", type);
-               return false;
-       }
-       return true;
-}
-
 int _acquire_resource_for_type(webrtc_s *webrtc, mm_resource_manager_res_type_e type)
 {
        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(!__is_valid_resource_type(type), WEBRTC_ERROR_INVALID_PARAMETER,
-                       "type is wrong");
+       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.res[type] != NULL) {
                LOG_ERROR("type[%d] resource was already acquired", type);
index 2a12c1b5392772ae0e8e05c4f953f10fa9df3acb..287e8857288868904b751bfe83fa360acf563d85 100644 (file)
@@ -136,8 +136,7 @@ static int __build_videosink(webrtc_s *webrtc, GstElement *decodebin, GstPad *sr
                return WEBRTC_ERROR_INVALID_OPERATION;
        }
 #ifndef TIZEN_TV
-       if (sink->display->type == WEBRTC_DISPLAY_TYPE_OVERLAY && webrtc->ini.rendering_sink.v_overlay_resource_required) {
-               webrtc->resource.need_to_acquire[MM_RESOURCE_MANAGER_RES_TYPE_VIDEO_OVERLAY] = true;
+       if (sink->display->type == WEBRTC_DISPLAY_TYPE_OVERLAY && webrtc->ini.resource_acquisition.video_overlay) {
                if ((ret =_acquire_resource_for_type(webrtc, MM_RESOURCE_MANAGER_RES_TYPE_VIDEO_OVERLAY)))
                        return ret;
        }
@@ -389,9 +388,10 @@ static int __decodebin_autoplug_select_cb(GstElement *decodebin, GstPad *pad, Gs
                        return GST_AUTOPLUG_SELECT_SKIP;
 #ifndef TIZEN_TV
                } else {
-                       webrtc->resource.need_to_acquire[MM_RESOURCE_MANAGER_RES_TYPE_VIDEO_DECODER] = true;
-                       if (_acquire_resource_for_type(webrtc, MM_RESOURCE_MANAGER_RES_TYPE_VIDEO_DECODER) != WEBRTC_ERROR_NONE)
-                               return GST_AUTOPLUG_SELECT_SKIP;
+                       if (webrtc->ini.resource_acquisition.video_decoder) {
+                               if (_acquire_resource_for_type(webrtc, MM_RESOURCE_MANAGER_RES_TYPE_VIDEO_DECODER) != WEBRTC_ERROR_NONE)
+                                       return GST_AUTOPLUG_SELECT_SKIP;
+                       }
 #endif
                }
        }
index 5441407878796fc4221a8f9719fdc36162bde2b5..a20c76798c1f2832cf51fe99b9273a4f6f16e7e4 100644 (file)
@@ -644,7 +644,8 @@ static GstElement *__get_hw_encoder_element(webrtc_s *webrtc, webrtc_gst_slot_s
 
        if (encoder) {
 #ifndef TIZEN_TV
-               webrtc->resource.need_to_acquire[MM_RESOURCE_MANAGER_RES_TYPE_VIDEO_ENCODER] = true;
+               if (webrtc->ini.resource_acquisition.video_encoder)
+                       webrtc->resource.need_to_acquire[MM_RESOURCE_MANAGER_RES_TYPE_VIDEO_ENCODER] = true;
 #endif
                LOG_WARNING("hw encoder element [%s]", GST_ELEMENT_NAME(encoder));
                return encoder;
@@ -1133,7 +1134,8 @@ static int __build_camerasrc(webrtc_s *webrtc, webrtc_gst_slot_s *source)
        source->media_types = MEDIA_TYPE_VIDEO;
        source->zerocopy_enabled = __is_hw_encoder_used(webrtc, source->type, source->media_types);
 #ifndef TIZEN_TV
-       webrtc->resource.need_to_acquire[MM_RESOURCE_MANAGER_RES_TYPE_CAMERA] = true;
+       if (webrtc->ini.resource_acquisition.camera)
+               webrtc->resource.need_to_acquire[MM_RESOURCE_MANAGER_RES_TYPE_CAMERA] = true;
 #endif
        if (!(camerasrc = _create_element(__get_source_element(webrtc, WEBRTC_MEDIA_SOURCE_TYPE_CAMERA), ELEMENT_NAME_VIDEO_SRC)))
                return WEBRTC_ERROR_INVALID_OPERATION;