Add new field to frame meta for lux index
[platform/core/multimedia/libmm-camcorder.git] / src / mm_camcorder_configure.c
index 2492109..b946112 100644 (file)
 /*-----------------------------------------------------------------------
 |    LOCAL VARIABLE DEFINITIONS                                                |
 -----------------------------------------------------------------------*/
-#define DEFAULT_AUDIO_BUFFER_INTERVAL   50
-#define DEFAULT_ENCODED_PREVIEW_BITRATE (1024*1024*4)
+#define DEFAULT_AUDIO_BUFFER_INTERVAL       50
+#define DEFAULT_ENCODED_PREVIEW_BITRATE     (1024*1024*4)
 
-#define MMCAMCORDER_CONF_FILEPATH_LENGTH 128
-#define MMCAMCORDER_BUFFER_LINE_MAX      256
+#define MMCAMCORDER_CONF_FILEPATH_LENGTH    128
+#define MMCAMCORDER_BUFFER_LINE_MAX         256
+
+#define BUFFER_NUM_DETAILS                  256
+#define BUFFER_NUM_TOKEN                    64
 
 char *get_new_string(char* src_string)
 {
@@ -55,7 +58,7 @@ char *get_new_string(char* src_string)
 int _mmcamcorder_conf_init(MMHandleType handle, int type, camera_conf *configure_info)
 {
        int category_num = 0;
-       int info_table_size = sizeof(conf_info_table);
+       size_t info_table_size = sizeof(conf_info_table);
 
        mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
 
@@ -671,6 +674,7 @@ int _mmcamcorder_conf_init(MMHandleType handle, int type, camera_conf *configure
                { "SupportUserBuffer",            CONFIGURE_VALUE_INT,          {.value_int = 0} },
                { "MeasurePreviewFPS",            CONFIGURE_VALUE_INT,          {.value_int = 0} },
                { "DefaultEncodedPreviewBitrate", CONFIGURE_VALUE_INT,          {.value_int = DEFAULT_ENCODED_PREVIEW_BITRATE} },
+               { "UpdateCapsByStreamRotation",   CONFIGURE_VALUE_INT,          {.value_int = 0} },
        };
 
        /* [AudioInput] matching table */
@@ -823,7 +827,19 @@ int _mmcamcorder_conf_init(MMHandleType handle, int type, camera_conf *configure
                { "FacingDirection",      CONFIGURE_VALUE_INT,            {.value_int = MM_CAMCORDER_CAMERA_FACING_DIRECTION_REAR} },
                { "FrameStabilityCount",  CONFIGURE_VALUE_INT,            {.value_int = 0} },
                { "SupportExtraPreview",  CONFIGURE_VALUE_INT,            {.value_int = 0} },
-               { "ExtraPreviewMode",     CONFIGURE_VALUE_INT,            {.value_int = MM_CAMCORDER_EXTRA_PREVIEW_MODE_CAMERA_CONTROL} }
+               { "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. */
+               { "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} },
+               { "VideoFilter2Element",  CONFIGURE_VALUE_ELEMENT,        {NULL} },
+               { "VideoFilter2CropX",    CONFIGURE_VALUE_INT,            {.value_int = 0} },
+               { "VideoFilter2CropY",    CONFIGURE_VALUE_INT,            {.value_int = 0} },
+               { "VideoFilter2CropW",    CONFIGURE_VALUE_INT,            {.value_int = 0} },
+               { "VideoFilter2CropH",    CONFIGURE_VALUE_INT,            {.value_int = 0} }
        };
 
        /* [Strobe] matching table */
@@ -836,19 +852,21 @@ int _mmcamcorder_conf_init(MMHandleType handle, int type, camera_conf *configure
 
        /* [Effect] matching table */
        static conf_info_table conf_ctrl_effect_table[] = {
-               { "Brightness",           CONFIGURE_VALUE_INT_RANGE, {NULL} },
-               { "BrightnessStepDenominator", CONFIGURE_VALUE_INT, {.value_int = 2} },
-               { "Contrast",             CONFIGURE_VALUE_INT_RANGE, {NULL} },
-               { "Saturation",           CONFIGURE_VALUE_INT_RANGE, {NULL} },
-               { "Sharpness",            CONFIGURE_VALUE_INT_RANGE, {NULL} },
-               { "Hue",                  CONFIGURE_VALUE_INT_RANGE, {NULL} },
-               { "WhiteBalance",         CONFIGURE_VALUE_INT_ARRAY, {NULL} },
-               { "ColorTone",            CONFIGURE_VALUE_INT_ARRAY, {NULL} },
-               { "Flip",                 CONFIGURE_VALUE_INT_ARRAY, {NULL} },
-               { "Rotation",             CONFIGURE_VALUE_INT_ARRAY, {NULL} },
-               { "WDR",                  CONFIGURE_VALUE_INT_ARRAY, {NULL} },
-               { "PartColorMode",        CONFIGURE_VALUE_INT_ARRAY, {NULL} },
-               { "PartColor",            CONFIGURE_VALUE_INT_ARRAY, {NULL} },
+               { "Brightness",                     CONFIGURE_VALUE_INT_RANGE, {NULL} },
+               { "BrightnessStepDenominator",      CONFIGURE_VALUE_INT, {.value_int = 2} },
+               { "Contrast",                       CONFIGURE_VALUE_INT_RANGE, {NULL} },
+               { "Saturation",                     CONFIGURE_VALUE_INT_RANGE, {NULL} },
+               { "Sharpness",                      CONFIGURE_VALUE_INT_RANGE, {NULL} },
+               { "Hue",                            CONFIGURE_VALUE_INT_RANGE, {NULL} },
+               { "WhiteBalance",                   CONFIGURE_VALUE_INT_ARRAY, {NULL} },
+               { "ColorTone",                      CONFIGURE_VALUE_INT_ARRAY, {NULL} },
+               { "Flip",                           CONFIGURE_VALUE_INT_ARRAY, {NULL} },
+               { "Rotation",                       CONFIGURE_VALUE_INT_ARRAY, {NULL} },
+               { "WDR",                            CONFIGURE_VALUE_INT_ARRAY, {NULL} },
+               { "PartColorMode",                  CONFIGURE_VALUE_INT_ARRAY, {NULL} },
+               { "PartColor",                      CONFIGURE_VALUE_INT_ARRAY, {NULL} },
+               { "WhiteBalanceTemperature",        CONFIGURE_VALUE_INT_RANGE, {NULL} },
+               { "WhiteBalanceTemperatureStep",    CONFIGURE_VALUE_INT, {.value_int = 1} }
        };
 
        /* [Photograph] matching table */
@@ -874,6 +892,8 @@ int _mmcamcorder_conf_init(MMHandleType handle, int type, camera_conf *configure
                { "PanElec",              CONFIGURE_VALUE_INT_RANGE, {NULL} },
                { "TiltMecha",            CONFIGURE_VALUE_INT_RANGE, {NULL} },
                { "TiltElec",             CONFIGURE_VALUE_INT_RANGE, {NULL} },
+               { "Gain",                 CONFIGURE_VALUE_INT_RANGE, {NULL} },
+               { "GainStep",             CONFIGURE_VALUE_INT, {.value_int = 1} }
        };
 
        /* [Capture] matching table */
@@ -985,8 +1005,6 @@ int _mmcamcorder_conf_get_info(MMHandleType handle, int type, const char *ConfFi
 
 int _mmcamcorder_conf_parse_info(MMHandleType handle, int type, FILE *fp, camera_conf **configure_info)
 {
-       const unsigned int BUFFER_NUM_DETAILS = 256;
-       const unsigned int BUFFER_NUM_TOKEN = 20;
        size_t buffer_line_size = MMCAMCORDER_BUFFER_LINE_MAX;
        const char* delimiters = " |=,\t\r\n";
 
@@ -1000,8 +1018,8 @@ int _mmcamcorder_conf_parse_info(MMHandleType handle, int type, FILE *fp, camera
        int read_main = 0;
 
        char *buffer_string = NULL;
-       char *buffer_details[BUFFER_NUM_DETAILS];
-       char *buffer_token[BUFFER_NUM_TOKEN];
+       char *buffer_details[BUFFER_NUM_DETAILS] = {NULL, };
+       char *buffer_token[BUFFER_NUM_TOKEN] = {NULL, };
        char *token = NULL;
        char *category_name = NULL;
        char *detail_string = NULL;
@@ -1213,8 +1231,10 @@ void _mmcamcorder_conf_release_info(MMHandleType handle, camera_conf **configure
        for (i = 0 ; i < category_num ; i++) {
                if (temp_conf->info[i]) {
                        for (j = 0 ; j < temp_conf->info[i]->count ; j++) {
-                               if (temp_conf->info[i]->detail_info[j] == NULL)
+                               if (temp_conf->info[i]->detail_info[j] == NULL) {
+                                       MMCAM_LOG_WARNING("[%d][%d][%d] -> NULL", temp_conf->type, i, j);
                                        continue;
+                               }
 
                                if (_mmcamcorder_conf_get_value_type(handle, temp_conf->type, i, ((type_element*)(temp_conf->info[i]->detail_info[j]))->name, &type)) {
                                        switch (type) {
@@ -1348,14 +1368,12 @@ int _mmcamcorder_conf_get_value_type(MMHandleType handle, int type, int category
 
 int _mmcamcorder_conf_add_info(MMHandleType handle, int type, conf_detail **info, char **buffer_details, int category, int count_details)
 {
-       const int BUFFER_NUM_TOKEN = 256;
-
        int i = 0;
        int j = 0;
        int count_token;
        int value_type;
        char *token = NULL;
-       char *buffer_token[BUFFER_NUM_TOKEN];
+       char *buffer_token[BUFFER_NUM_TOKEN] = {NULL, };
        char *user_ptr = NULL;
 
        const char *delimiters     = " |=,\t\r\n";
@@ -1369,6 +1387,11 @@ int _mmcamcorder_conf_add_info(MMHandleType handle, int type, conf_detail **info
        (*info)->count = count_details;
 
        for (i = 0 ; i < count_details ; i++) {
+               if (!buffer_details[i]) {
+                       MMCAM_LOG_WARNING("t[%d],cat[%d],index[%d]- NULL > skip", type, category, i);
+                       continue;
+               }
+
                MMCAM_LOG_VERBOSE("Read line \"%s\"", buffer_details[i]);
                count_token = 0;
                token = strtok_r(buffer_details[i], delimiters, &user_ptr);
@@ -1554,6 +1577,7 @@ int _mmcamcorder_conf_add_info(MMHandleType handle, int type, conf_detail **info
                {
                        type_element2* new_element;
 
+                       j = 0;
                        new_element = (type_element2*)g_malloc0(sizeof(type_element2));
                        new_element->name         = get_new_string(buffer_token[0]);
                        new_element->element_name = get_new_string(buffer_token[1]);
@@ -1568,7 +1592,7 @@ int _mmcamcorder_conf_add_info(MMHandleType handle, int type, conf_detail **info
                        /* add int values */
                        if (new_element->count_int > 0 && new_element->count_int <= 30) {
                                new_element->value_int = (type_int2**)g_malloc0(sizeof(type_int2*)*(new_element->count_int));
-                               for (j = 0 ; j < new_element->count_int ; j++) {
+                               for ( ; j < new_element->count_int ; j++) {
                                        new_element->value_int[j] = (type_int2*)g_malloc0(sizeof(type_int2));
                                        new_element->value_int[j]->name  = get_new_string(buffer_token[4+(j<<1)]);
                                        new_element->value_int[j]->value = atoi(buffer_token[5+(j<<1)]);
@@ -2090,6 +2114,32 @@ int _mmcamcorder_conf_get_category_size(MMHandleType handle, int type, int categ
        return TRUE;
 }
 
+void _mmcamcorder_conf_get_element_and_name(MMHandleType handle, camera_conf *conf, int category,
+       const char *name, type_element **element, const char **element_name)
+{
+       type_element *_element = NULL;
+       mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
+
+       if (!hcamcorder) {
+               MMCAM_LOG_ERROR("NULL handle");
+               return;
+       }
+
+       if (!_mmcamcorder_conf_get_element(handle, conf,
+               category, name, &_element)) {
+               MMCAM_LOG_WARNING("get [%s] failed", name);
+               return;
+       }
+
+       if (element)
+               *element = _element;
+
+       if (element_name) {
+               _mmcamcorder_conf_get_value_element_name(_element, element_name);
+               MMCAM_LOG_INFO("[%s] -> [%s]", name, *element_name);
+       }
+}
+
 void _mmcamcorder_conf_print_info(MMHandleType handle, camera_conf** configure_info)
 {
        int i, j, k, type, category_type;