Add new configuration for video filter element 27/285927/2 accepted/tizen/unified/20221230.183554
authorJeongmo Yang <jm80.yang@samsung.com>
Thu, 22 Dec 2022 10:06:37 +0000 (19:06 +0900)
committerJeongmo Yang <jm80.yang@samsung.com>
Thu, 22 Dec 2022 11:34:47 +0000 (20:34 +0900)
- Added list
 : VideoFilterCropX, VideoFilterCropY, VideoFilterCropW, VideoFilterCropH

[Version] 0.10.284
[Issue Type] New feature

Change-Id: I69d3dedeb14ae12c96ccc639979aa50f1186cab8
Signed-off-by: Jeongmo Yang <jm80.yang@samsung.com>
packaging/libmm-camcorder.spec
src/include/mm_camcorder_util.h
src/mm_camcorder_configure.c
src/mm_camcorder_gstcommon.c
src/mm_camcorder_util.c

index 9acfe8a..e9fcbf1 100755 (executable)
@@ -1,6 +1,6 @@
 Name:       libmm-camcorder
 Summary:    Camera and recorder library
-Version:    0.10.283
+Version:    0.10.284
 Release:    0
 Group:      Multimedia/Libraries
 License:    Apache-2.0
index 5cdd5f6..b322f68 100644 (file)
@@ -372,6 +372,9 @@ int _mmcamcorder_get_log_level(void);
 /* profiling */
 void _mmcamcorder_measure_fps(void *data);
 
+/* property */
+void _mmcamcorder_set_property_array_int(GstElement *element, const char *property_name, int *array, unsigned int array_length);
+
 
 #ifdef __cplusplus
 }
index 0537fff..54d2b3d 100644 (file)
@@ -826,7 +826,11 @@ int _mmcamcorder_conf_init(MMHandleType handle, int type, camera_conf *configure
                { "ExtraPreviewMode",     CONFIGURE_VALUE_INT,            {.value_int = MM_CAMCORDER_EXTRA_PREVIEW_MODE_CAMERA_CONTROL} },
                { "AltVideosrcElement",   CONFIGURE_VALUE_ELEMENT,        {NULL} }, /* The alternative of videosrc element, it will be used instead of "VideosrcElement" if exists. */
                { "AltUseZeroCopyFormat", CONFIGURE_VALUE_INT,            {.value_int = -1} }, /* The alternative of "UseZeroCopyFormat", it will be used if it's not default(-1) value. */
-               { "VideoFilterElement",   CONFIGURE_VALUE_ELEMENT,        {NULL} } /* The video filter element which is placed between videosrc and videosink elements. */
+               { "VideoFilterElement",   CONFIGURE_VALUE_ELEMENT,        {NULL} }, /* The video filter element which is placed between videosrc and videosink elements. */
+               { "VideoFilterCropX",     CONFIGURE_VALUE_INT,            {.value_int = 0} }, /* The VideoFilterElement is existed and these values are valid, they will be set to "crop" property. */
+               { "VideoFilterCropY",     CONFIGURE_VALUE_INT,            {.value_int = 0} },
+               { "VideoFilterCropW",     CONFIGURE_VALUE_INT,            {.value_int = 0} },
+               { "VideoFilterCropH",     CONFIGURE_VALUE_INT,            {.value_int = 0} }
        };
 
        /* [Strobe] matching table */
index 41e8b52..6f2bf75 100644 (file)
@@ -130,6 +130,7 @@ static gboolean videocodec_fileformat_compatibility_table[MM_VIDEO_CODEC_NUM][MM
 #define _MMCAMCORDER_NANOSEC_PER_1SEC             1000000000
 #define _MMCAMCORDER_NANOSEC_PER_1MILISEC         1000
 #define _MMCAMCORDER_SIGNAL_REQUEST_CODEC_CONFIG  "request-codec-config"
+#define _MMCAMCORDER_CROP_ARRAY_LENGTH            4
 
 
 /*-----------------------------------------------------------------------
@@ -705,8 +706,28 @@ int _mmcamcorder_create_preview_elements(MMHandleType handle)
                hcamcorder->conf_ctrl, CONFIGURE_CATEGORY_CTRL_CAMERA, "VideoFilterElement",
                &videofilt_element, &videofilt_name);
        if (videofilt_element && videofilt_name) {
+               int videofilt_crop_rect[_MMCAMCORDER_CROP_ARRAY_LENGTH] = {0, };
+               const char *conf_name[_MMCAMCORDER_CROP_ARRAY_LENGTH] = {
+                       "VideoFilterCropX",
+                       "VideoFilterCropY",
+                       "VideoFilterCropW",
+                       "VideoFilterCropH"
+               };
+
                _MMCAMCORDER_ELEMENT_MAKE(sc, sc->element, _MMCAMCORDER_VIDEOSRC_FILT, videofilt_name, "vsrc_f", element_list, err);
                _mmcamcorder_conf_set_value_element_property(sc->element[_MMCAMCORDER_VIDEOSRC_FILT].gst, videofilt_element);
+
+               for (i = 0 ; i < _MMCAMCORDER_CROP_ARRAY_LENGTH ; i++) {
+                       _mmcamcorder_conf_get_value_int((MMHandleType)hcamcorder, hcamcorder->conf_ctrl,
+                               CONFIGURE_CATEGORY_CTRL_CAMERA,
+                               conf_name[i], &videofilt_crop_rect[i]);
+               }
+
+               if (videofilt_crop_rect[0] >= 0 && videofilt_crop_rect[1] >= 0 &&
+                       videofilt_crop_rect[2] > 0 && videofilt_crop_rect[3] > 0) {
+                       _mmcamcorder_set_property_array_int(sc->element[_MMCAMCORDER_VIDEOSRC_FILT].gst,
+                               "crop", videofilt_crop_rect, _MMCAMCORDER_CROP_ARRAY_LENGTH);
+               }
        }
 
        _MMCAMCORDER_ELEMENT_MAKE(sc, sc->element, _MMCAMCORDER_VIDEOSRC_QUE, "queue", "vsrc_q", element_list, err);
index 8514490..42afe2d 100644 (file)
@@ -2647,3 +2647,33 @@ void _mmcamcorder_measure_fps(void *data)
 
        MMCAM_LOG_INFO("current fps[%d], average[%d]", kpi->current_fps, kpi->average_fps);
 }
+
+void _mmcamcorder_set_property_array_int(GstElement *element, const char *property_name, int *array, unsigned int array_length)
+{
+       unsigned int i = 0;
+       GValue value = G_VALUE_INIT;
+       GValue tmp = G_VALUE_INIT;
+
+       mmf_return_if_fail(element);
+       mmf_return_if_fail(property_name);
+       mmf_return_if_fail(array);
+
+       g_value_init(&value, GST_TYPE_ARRAY);
+       g_value_init(&tmp, G_TYPE_INT);
+
+       MMCAM_LOG_INFO("set element[%s], property[%s], array_length[%d]",
+               GST_ELEMENT_NAME(element), property_name, array_length);
+
+       gst_value_array_init(&value, array_length);
+
+       for (i = 0 ; i < array_length ; i++) {
+               MMCAM_LOG_INFO("array[%u] %d", i, array[i]);
+               g_value_set_int(&tmp, array[i]);
+               gst_value_array_append_value(&value, &tmp);
+       }
+
+       g_object_set_property(G_OBJECT(element), property_name, &value);
+
+       g_value_unset(&tmp);
+       g_value_unset(&value);
+}