Support white balance setting for latest v4l2src plugin 49/244749/6
authorJeongmo Yang <jm80.yang@samsung.com>
Thu, 24 Sep 2020 03:52:30 +0000 (12:52 +0900)
committerJeongmo Yang <jm80.yang@samsung.com>
Fri, 25 Sep 2020 08:54:30 +0000 (17:54 +0900)
[Version] 0.10.216
[Issue Type] Update

Change-Id: Ic9a6e39af8fb6888169c552ba847f782f99b15d7
Signed-off-by: Jeongmo Yang <jm80.yang@samsung.com>
packaging/libmm-camcorder.spec
src/include/mm_camcorder.h
src/mm_camcorder_attribute.c

index 5568f89..164aaf6 100644 (file)
@@ -1,6 +1,6 @@
 Name:       libmm-camcorder
 Summary:    Camera and recorder library
-Version:    0.10.215
+Version:    0.10.216
 Release:    0
 Group:      Multimedia/Libraries
 License:    Apache-2.0
index a458ddb..dc30893 100644 (file)
@@ -1423,7 +1423,7 @@ enum MMCamcorderWhiteBalanceType {
        MM_CAMCORDER_WHITE_BALANCE_AUTOMATIC,           /**< Automatic */
        MM_CAMCORDER_WHITE_BALANCE_DAYLIGHT,            /**< Daylight */
        MM_CAMCORDER_WHITE_BALANCE_CLOUDY,              /**< Cloudy */
-       MM_CAMCORDER_WHITE_BALANCE_FLUOROSCENT,         /**< Fluorescent */
+       MM_CAMCORDER_WHITE_BALANCE_FLUORESCENT,         /**< Fluorescent */
        MM_CAMCORDER_WHITE_BALANCE_INCANDESCENT,        /**< Incandescent */
        MM_CAMCORDER_WHITE_BALANCE_SHADE,               /**< Shade */
        MM_CAMCORDER_WHITE_BALANCE_HORIZON,             /**< Horizon */
index c466d2b..faff126 100644 (file)
@@ -3522,14 +3522,21 @@ bool _mmcamcorder_commit_recording_max_limit(MMHandleType handle, int attr_idx,
 }
 
 
+static int __color_channel_item_compare_func(gconstpointer data, gconstpointer user_data)
+{
+       GstColorBalanceChannel *Colorchannel = (GstColorBalanceChannel *)data;
+       MMCAM_LOG_VERBOSE("check[%s], input[%s]", Colorchannel->label, (char *)user_data);
+       return strcmp(Colorchannel->label, user_data);
+}
+
 bool _mmcamcorder_commit_filter(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
 {
        GstColorBalance *balance = NULL;
        GstColorBalanceChannel *Colorchannel = NULL;
-       const GList *controls = NULL;
-       const GList *item = NULL;
+       GList *controls = NULL;
+       GList *item = NULL;
        int newVal = 0;
-       int mslNewVal = 0;
+       int mslVal = 0;
        int current_state = MM_CAMCORDER_STATE_NONE;
        const char *control_label = NULL;
        mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
@@ -3538,6 +3545,15 @@ bool _mmcamcorder_commit_filter(MMHandleType handle, int attr_idx, const MMAttrs
        int scene_mode = MM_CAMCORDER_SCENE_MODE_NORMAL;
        gboolean check_scene_mode = FALSE;
 
+       int wb_temp_table[] = {
+               [MM_CAMCORDER_WHITE_BALANCE_DAYLIGHT] = 5200,
+               [MM_CAMCORDER_WHITE_BALANCE_CLOUDY] = 6000,
+               [MM_CAMCORDER_WHITE_BALANCE_FLUORESCENT] = 4000,
+               [MM_CAMCORDER_WHITE_BALANCE_INCANDESCENT] = 3200,
+               [MM_CAMCORDER_WHITE_BALANCE_SHADE] = 7000,
+               [MM_CAMCORDER_WHITE_BALANCE_FLASH] = 6000
+       };
+
        mmf_return_val_if_fail(hcamcorder && value, FALSE);
 
        sc = MMF_CAMCORDER_SUBCONTEXT(handle);
@@ -3563,38 +3579,32 @@ bool _mmcamcorder_commit_filter(MMHandleType handle, int attr_idx, const MMAttrs
        if (value->type != MM_ATTRS_TYPE_INT) {
                MMCAM_LOG_WARNING("Mismatched value type (%d)", value->type);
                return FALSE;
-       } else {
-               mslNewVal = value->value.i_val;
        }
 
+       mslVal = value->value.i_val;
+
        switch (attr_idx) {
        case MM_CAM_FILTER_BRIGHTNESS:
                control_label = "brightness";
                check_scene_mode = TRUE;
                break;
-
        case MM_CAM_FILTER_CONTRAST:
                control_label = "contrast";
                break;
-
        case MM_CAM_FILTER_WB:
                control_label = "white balance";
                check_scene_mode = TRUE;
                break;
-
        case MM_CAM_FILTER_COLOR_TONE:
                control_label = "color tone";
                break;
-
        case MM_CAM_FILTER_SATURATION:
                control_label = "saturation";
                check_scene_mode = TRUE;
                break;
-
        case MM_CAM_FILTER_HUE:
                control_label = "hue";
                break;
-
        case MM_CAM_FILTER_SHARPNESS:
                control_label = "sharpness";
                check_scene_mode = TRUE;
@@ -3612,12 +3622,10 @@ bool _mmcamcorder_commit_filter(MMHandleType handle, int attr_idx, const MMAttrs
                }
        }
 
-       newVal = _mmcamcorder_convert_msl_to_sensor(handle, attr_idx, mslNewVal);
+       newVal = _mmcamcorder_convert_msl_to_sensor(handle, attr_idx, mslVal);
        if (newVal == _MMCAMCORDER_SENSOR_ENUM_NONE)
                return FALSE;
 
-       /*MMCAM_LOG_INFO("label(%s): MSL(%d)->Sensor(%d)", control_label, mslNewVal, newVal);*/
-
        if (!GST_IS_COLOR_BALANCE(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
                MMCAM_LOG_INFO("Can't cast Video source into color balance.");
                return TRUE;
@@ -3629,29 +3637,39 @@ bool _mmcamcorder_commit_filter(MMHandleType handle, int attr_idx, const MMAttrs
                return FALSE;
        }
 
-       controls = gst_color_balance_list_channels(balance);
+       controls = (GList *)gst_color_balance_list_channels(balance);
        if (controls == NULL) {
                MMCAM_LOG_INFO("There is no list of colorbalance controls");
                return FALSE;
        }
 
-       for (item = controls ; item && item->data ; item = item->next) {
+_CHECK_AGAIN:
+       MMCAM_LOG_DEBUG("attr[%d] label[%s]: MSL[%d] -> Sensor[%d]",
+               attr_idx, control_label, mslVal, newVal);
+
+       item = g_list_find_custom(controls, control_label, __color_channel_item_compare_func);
+       if (item) {
                Colorchannel = item->data;
-               /*MMCAM_LOG_INFO("Getting name of CID=(%s), input CID=(%s)", Colorchannel->label, control_label);*/
+               gst_color_balance_set_value(balance, Colorchannel, newVal);
+               MMCAM_LOG_INFO("Set complete - %s[msl:%d,real:%d]", Colorchannel->label, mslVal, newVal);
+               return TRUE;
+       }
 
-               if (!strcmp(Colorchannel->label, control_label)) {
-                       gst_color_balance_set_value(balance, Colorchannel, newVal);
-                       MMCAM_LOG_INFO("Set complete - %s[msl:%d,real:%d]", Colorchannel->label, mslNewVal, newVal);
-                       break;
+       if (attr_idx == MM_CAM_FILTER_WB && !strcmp(control_label, "white balance")) {
+               if (mslVal == MM_CAMCORDER_WHITE_BALANCE_AUTOMATIC) {
+                       newVal = 1;
+                       control_label = "white_balance_temperature_auto";
+                       goto _CHECK_AGAIN;
+               } else {
+                       newVal = wb_temp_table[mslVal];
+                       control_label = "white_balance_temperature";
+                       goto _CHECK_AGAIN;
                }
        }
 
-       if (item == NULL) {
-               MMCAM_LOG_ERROR("failed to find color channel item");
-               return FALSE;
-       }
+       MMCAM_LOG_ERROR("failed to find color channel item");
 
-       return TRUE;
+       return FALSE;
 }