1.Modify to use the sub scaler in case of the resource conflict. it looks like MJPEG... 90/245590/12
authorSungjae Pyo <sungjae.pyo@samsung.com>
Tue, 13 Oct 2020 01:54:33 +0000 (10:54 +0900)
committerJeongmo Yang <jm80.yang@samsung.com>
Mon, 19 Oct 2020 03:43:05 +0000 (12:43 +0900)
2.Set "device-scaler" of the videosink with the virtual device id, not the real device id
3.Modify to use the resource center in _mmcamcorder_rm_allocate()

[Version] 0.10.218

Change-Id: Ide1bdc76c986ea6b56ea681a7744ca30252380ff

configure.ac [changed mode: 0644->0755]
packaging/libmm-camcorder.spec [changed mode: 0644->0755]
src/Makefile.am [changed mode: 0644->0755]
src/include/mm_camcorder_internal.h [changed mode: 0644->0755]
src/mm_camcorder_gstcommon.c [changed mode: 0644->0755]
src/mm_camcorder_rm.c [changed mode: 0644->0755]

old mode 100644 (file)
new mode 100755 (executable)
index eae8065..d7afe31
@@ -116,6 +116,10 @@ AC_SUBST(AUL_LIBS)
 PKG_CHECK_MODULES(RI, tv-resource-information)
 AC_SUBST(RI_CFLAGS)
 AC_SUBST(RI_LIBS)
+
+PKG_CHECK_MODULES(RC, resource-center-api)
+AC_SUBST(RC_CFLAGS)
+AC_SUBST(RC_LIBS)
 fi
 AM_CONDITIONAL([RM_SUPPORT], [test "x$RM_SUPPORT" = "xyes"])
 
old mode 100644 (file)
new mode 100755 (executable)
index 6fe9b78..ca631af
@@ -1,6 +1,6 @@
 Name:       libmm-camcorder
 Summary:    Camera and recorder library
-Version:    0.10.217
+Version:    0.10.218
 Release:    0
 Group:      Multimedia/Libraries
 License:    Apache-2.0
@@ -26,6 +26,7 @@ BuildRequires:  pkgconfig(storage)
 BuildRequires:  pkgconfig(tv-resource-manager)
 BuildRequires:  pkgconfig(tv-resource-information)
 BuildRequires:  pkgconfig(aul)
+BuildRequires:  pkgconfig(resource-center-api)
 %if (("%{_vd_cfg_product_type}" != "AUDIO") && ("%{_vd_cfg_target_repository}" != "emulator"))
 BuildRequires:  pkgconfig(camera-conf-mgr-tv)
 %endif
old mode 100644 (file)
new mode 100755 (executable)
index e52f929..e04f1bf
@@ -86,8 +86,8 @@ libmmfcamcorder_la_LIBADD += $(MM_RESOURCE_MANAGER_LIBS)
 endif
 
 if RM_SUPPORT
-libmmfcamcorder_la_CFLAGS += $(RM_CFLAGS) $(RI_CFLAGS) $(AUL_CFLAGS) -D_MMCAMCORDER_RM_SUPPORT
-libmmfcamcorder_la_LIBADD += $(RM_LIBS) $(RI_LIBS) $(AUL_LIBS)
+libmmfcamcorder_la_CFLAGS += $(RM_CFLAGS) $(RI_CFLAGS) $(AUL_CFLAGS) $(RC_CFLAGS) -D_MMCAMCORDER_RM_SUPPORT
+libmmfcamcorder_la_LIBADD += $(RM_LIBS) $(RI_LIBS) $(AUL_LIBS) $(RC_LIBS)
 endif
 
 if CAMERA_CONF_MGR_SUPPORT
old mode 100644 (file)
new mode 100755 (executable)
index ecd7d51..de12b82
@@ -744,7 +744,8 @@ typedef struct mmf_camcorder {
        camera_conf *conf_main;                /**< Camera configure Main structure */
        camera_conf *conf_ctrl;                /**< Camera configure Control structure */
 #ifdef _MMCAMCORDER_RM_SUPPORT
-       int rm_handle;                        /**< Resource manager handle */
+       int rm_handle;                         /**< Resource manager handle */
+       rm_consumer_info rci;                  /**< Resource consumer info */
 #endif /* _MMCAMCORDER_RM_SUPPORT */
        guint pipeline_cb_event_id;            /**< Event source ID of pipeline message callback */
        guint encode_pipeline_cb_event_id;     /**< Event source ID of encode pipeline message callback */
old mode 100644 (file)
new mode 100755 (executable)
index 39c5285..5406da7
@@ -1743,9 +1743,6 @@ int _mmcamcorder_videosink_window_set(MMHandleType handle, type_element* Videosi
        int zoom_attr = 0;
        int zoom_level = 0;
        int do_scaling = FALSE;
-#ifdef _MMCAMCORDER_RM_SUPPORT
-       int display_scaler = 0;
-#endif /* _MMCAMCORDER_RM_SUPPORT */
        int *dp_handle = NULL;
        MMCamWindowInfo *window_info = NULL;
        gulong xid;
@@ -1814,10 +1811,8 @@ int _mmcamcorder_videosink_window_set(MMHandleType handle, type_element* Videosi
                        gst_video_overlay_set_window_handle(GST_VIDEO_OVERLAY(vsink), 0);
                }
 #ifdef _MMCAMCORDER_RM_SUPPORT
-               if (hcamcorder->request_resources.category_id[0] == RM_CATEGORY_VIDEO_DECODER_SUB)
-                       display_scaler = 1;
-
-               MMCAMCORDER_G_OBJECT_SET(vsink, "device-scaler", display_scaler);
+               /* set the videosink using the virtual device id instead of the real id (main=0, sub=1) */
+               MMCAMCORDER_G_OBJECT_SET(vsink, "device-scaler", hcamcorder->returned_devices.device_id[1]);
 #endif /* _MMCAMCORDER_RM_SUPPORT */
        } else if (!strcmp(videosink_name, "evasimagesink") || !strcmp(videosink_name, "evaspixmapsink")) {
                MMCAM_LOG_INFO("videosink : %s, handle : %p", videosink_name, dp_handle);
@@ -1856,9 +1851,9 @@ int _mmcamcorder_videosink_window_set(MMHandleType handle, type_element* Videosi
                        MMCAM_LOG_WARNING("dp_handle is null");
                }
 #ifdef _MMCAMCORDER_RM_SUPPORT
-               if (hcamcorder->request_resources.category_id[0] == RM_CATEGORY_VIDEO_DECODER_SUB)
-                       display_scaler = 1;
-               MMCAMCORDER_G_OBJECT_SET(vsink, "device-scaler", display_scaler);
+               /* set the videosink using the virtual device id instead of the real id (main=0, sub=1) */
+               MMCAM_LOG_INFO("device-scaler : %d", hcamcorder->returned_devices.device_id[1]);
+               MMCAMCORDER_G_OBJECT_SET(vsink, "device-scaler", hcamcorder->returned_devices.device_id[1]);
 #endif /* _MMCAMCORDER_RM_SUPPORT */
        } else {
                MMCAM_LOG_WARNING("Who are you?? (Videosink: %s)", videosink_name);
old mode 100644 (file)
new mode 100755 (executable)
index 024baaf..b3e1d12
@@ -27,6 +27,7 @@
 #include <rm_api.h>
 #include <ri-api.h>
 #include <ri-module-api.h>
+#include <resource_center.h>
 #include "mm_camcorder_rm.h"
 #include "mm_camcorder_internal.h"
 
@@ -63,34 +64,28 @@ static rm_cb_result __mmcamcorder_rm_callback(int handle, rm_callback_type event
        return cb_res;
 }
 
-
-
 int _mmcamcorder_rm_create(MMHandleType handle)
 {
        int ret = RM_OK;
-       rm_consumer_info rci;
-       int app_pid = 0;
 
        mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
        if (!hcamcorder) {
                MMCAM_LOG_ERROR("Not initialized");
                return MM_ERROR_CAMCORDER_NOT_INITIALIZED;
        }
-
-       memset(&rci, 0x00, sizeof(rm_consumer_info));
-
+       memset(&hcamcorder->rci, 0x00, sizeof(rm_consumer_info));
        mm_camcorder_get_attributes(handle, NULL,
-               MMCAM_CLIENT_PID, &app_pid,
+               MMCAM_CLIENT_PID, &hcamcorder->rci.app_pid,
                NULL);
-       rci.app_pid = app_pid;
-       aul_app_get_appid_bypid(rci.app_pid, rci.app_id, sizeof(rci.app_id));
+       aul_app_get_appid_bypid(hcamcorder->rci.app_pid, hcamcorder->rci.app_id, sizeof(hcamcorder->rci.app_id));
 
        /* RM register */
+       /* NULL should be passed for the rci parameter if the application does not have "visibility" */
        if (hcamcorder->rm_handle == 0) {
                ret = rm_register((rm_resource_cb)__mmcamcorder_rm_callback,
                        (void*)hcamcorder,
                        &(hcamcorder->rm_handle),
-                       (rci.app_id[0] != '\0') ? &rci : NULL);
+                       (hcamcorder->rci.app_id[0] != '\0') ? &hcamcorder->rci : NULL);
                if (ret != RM_OK) {
                        MMCAM_LOG_ERROR("rm_register fail ret = %d",ret);
                        return MM_ERROR_RESOURCE_INTERNAL;
@@ -115,6 +110,11 @@ int _mmcamcorder_rm_allocate(MMHandleType handle)
                return MM_ERROR_CAMCORDER_NOT_INITIALIZED;
        }
 
+       MMCAM_LOG_INFO("app id : %s", hcamcorder->rci.app_id);
+       /* if the app_id is null,
+          In the multiview mode, the rc_get_capable_category_id returns the error(RI_CATEGORY_NOT_PERMITTED).
+          In the normal mode, it returns the category itself which is passed in the parameter. */
+
        mm_camcorder_get_attributes(handle, NULL,
                MMCAM_DISPLAY_SURFACE, &display_surface_type,
                NULL);
@@ -131,7 +131,7 @@ int _mmcamcorder_rm_allocate(MMHandleType handle)
                if (preview_format == MM_PIXEL_FORMAT_ENCODED_H264) {
                        hcamcorder->request_resources.state[resource_count] = RM_STATE_EXCLUSIVE;
                        hcamcorder->request_resources.category_id[resource_count] = RM_CATEGORY_VIDEO_DECODER;
-
+                       hcamcorder->request_resources.category_option[resource_count] = rc_get_capable_category_id(hcamcorder->rm_handle, hcamcorder->rci.app_id, RM_CATEGORY_VIDEO_DECODER);
                        MMCAM_LOG_INFO("request dec rsc - category 0x%x", RM_CATEGORY_VIDEO_DECODER);
 
                        resource_count++;
@@ -139,16 +139,16 @@ int _mmcamcorder_rm_allocate(MMHandleType handle)
                        mm_camcorder_get_attributes(handle, NULL,
                                MMCAM_CAMERA_WIDTH, &camera_width,
                                NULL);
-
                        hcamcorder->request_resources.state[resource_count] = RM_STATE_EXCLUSIVE;
                        hcamcorder->request_resources.category_id[resource_count] = RM_CATEGORY_MJPEG_DECODER;
-                       hcamcorder->request_resources.category_option[resource_count] = ri_get_jpeg_category_id("MJPEG", camera_width);
+                       hcamcorder->request_resources.category_option[resource_count] = rc_get_capable_category_id(hcamcorder->rm_handle, hcamcorder->rci.app_id, ri_get_jpeg_category_id("MJPEG", camera_width));
                        MMCAM_LOG_INFO("request dec rsc - category 0x%x, option width [%d]", RM_CATEGORY_MJPEG_DECODER, camera_width);
                        resource_count++;
                }
                if (display_surface_type == MM_DISPLAY_SURFACE_OVERLAY) {
                        hcamcorder->request_resources.state[resource_count] = RM_STATE_EXCLUSIVE;
                        hcamcorder->request_resources.category_id[resource_count] = RM_CATEGORY_SCALER;
+                       hcamcorder->request_resources.category_option[resource_count] = rc_get_capable_category_id(hcamcorder->rm_handle, hcamcorder->rci.app_id, RM_CATEGORY_SCALER);
                        MMCAM_LOG_INFO("request scaler rsc - category 0x%x", RM_CATEGORY_SCALER);
                        resource_count++;
                }
@@ -159,7 +159,6 @@ int _mmcamcorder_rm_allocate(MMHandleType handle)
                        qret = rm_query(hcamcorder->rm_handle, RM_QUERY_ALLOCATION, &(hcamcorder->request_resources), &qret_avail);
                        if (qret != RM_OK || qret_avail != 1) {
                                MMCAM_LOG_INFO("rm query failed. retry with sub devices");
-
                                resource_count = 0;
                                memset(&hcamcorder->request_resources, 0x0, sizeof(rm_category_request_s));
                                memset(&hcamcorder->returned_devices, 0x0, sizeof(rm_device_return_s));
@@ -167,27 +166,23 @@ int _mmcamcorder_rm_allocate(MMHandleType handle)
                                if (preview_format == MM_PIXEL_FORMAT_ENCODED_H264) {
                                        hcamcorder->request_resources.state[resource_count] = RM_STATE_EXCLUSIVE;
                                        hcamcorder->request_resources.category_id[resource_count] = RM_CATEGORY_VIDEO_DECODER_SUB;
+                                       hcamcorder->request_resources.category_option[resource_count] = rc_get_capable_category_id(hcamcorder->rm_handle, hcamcorder->rci.app_id, RM_DEVICE_OPT_SUB);
                                        MMCAM_LOG_INFO("request dec rsc - category 0x%x", RM_CATEGORY_VIDEO_DECODER_SUB);
                                        resource_count++;
                                } else if (preview_format == MM_PIXEL_FORMAT_ENCODED_MJPEG) {
                                        hcamcorder->request_resources.state[resource_count] = RM_STATE_EXCLUSIVE;
                                        hcamcorder->request_resources.category_id[resource_count] = RM_CATEGORY_MJPEG_DECODER;
-                                       hcamcorder->request_resources.category_option[resource_count] = ri_get_jpeg_category_id("MJPEG", camera_width);
+                                       hcamcorder->request_resources.category_option[resource_count] = rc_get_capable_category_id(hcamcorder->rm_handle, hcamcorder->rci.app_id, ri_get_jpeg_category_id("MJPEG", camera_width));
                                        MMCAM_LOG_INFO("request dec rsc - category 0x%x", RM_CATEGORY_MJPEG_DECODER);
                                        resource_count++;
                                }
-                               if (display_surface_type == MM_DISPLAY_SURFACE_OVERLAY) {
-                                       if (preview_format == MM_PIXEL_FORMAT_ENCODED_H264) {
-                                               hcamcorder->request_resources.state[resource_count] = RM_STATE_EXCLUSIVE;
-                                               hcamcorder->request_resources.category_id[resource_count] = RM_CATEGORY_SCALER_SUB;
-                                               MMCAM_LOG_INFO("request scaler rsc - category 0x%x", RM_CATEGORY_SCALER_SUB);
-                                               resource_count++;
-                                       } else if (preview_format == MM_PIXEL_FORMAT_ENCODED_MJPEG) {
-                                               hcamcorder->request_resources.state[resource_count] = RM_STATE_EXCLUSIVE;
-                                               hcamcorder->request_resources.category_id[resource_count] = RM_CATEGORY_SCALER;
-                                               MMCAM_LOG_INFO("request scaler rsc - category 0x%x", RM_CATEGORY_SCALER);
-                                               resource_count++;
-                                       }
+                               if ((display_surface_type == MM_DISPLAY_SURFACE_OVERLAY) &&
+                                       (preview_format == MM_PIXEL_FORMAT_ENCODED_H264 || preview_format == MM_PIXEL_FORMAT_ENCODED_MJPEG)) {
+                                       hcamcorder->request_resources.state[resource_count] = RM_STATE_EXCLUSIVE;
+                                       hcamcorder->request_resources.category_id[resource_count] = RM_CATEGORY_SCALER_SUB;
+                                       hcamcorder->request_resources.category_option[resource_count] = rc_get_capable_category_id(hcamcorder->rm_handle, hcamcorder->rci.app_id, RM_DEVICE_OPT_SUB);
+                                       MMCAM_LOG_INFO("request scaler rsc - category 0x%x", RM_CATEGORY_SCALER_SUB);
+                                       resource_count++;
                                }
                        }
                }
@@ -195,6 +190,7 @@ int _mmcamcorder_rm_allocate(MMHandleType handle)
 
        hcamcorder->request_resources.state[resource_count] = RM_STATE_EXCLUSIVE;
        hcamcorder->request_resources.category_id[resource_count] = RM_CATEGORY_CAMERA;
+       hcamcorder->request_resources.category_option[resource_count] = rc_get_capable_category_id(hcamcorder->rm_handle, hcamcorder->rci.app_id, RM_CATEGORY_CAMERA);
 
        hcamcorder->request_resources.request_num = resource_count + 1;
        MMCAM_LOG_INFO("request camera rsc - category 0x%x", RM_CATEGORY_CAMERA);