/*-----------------------------------------------------------------------
| MACRO DEFINITIONS: |
-----------------------------------------------------------------------*/
-#define CONFIGURE_PATH "/usr/etc"
-#define CONFIGURE_PATH_RETRY "/opt/etc"
/*-----------------------------------------------------------------------
| GLOBAL VARIABLE DEFINITIONS |
char *get_new_string(char* src_string)
{
- return strdup(src_string);
+ return g_strdup(src_string);
}
void _mmcamcorder_conf_init(MMHandleType handle, int type, camera_conf** configure_info)
/* [Camera] matching table */
static conf_info_table conf_ctrl_camera_table[] = {
- { "InputIndex", CONFIGURE_VALUE_INT_ARRAY, {NULL} },
- { "DeviceName", CONFIGURE_VALUE_STRING, {NULL} },
- { "PreviewResolution", CONFIGURE_VALUE_INT_PAIR_ARRAY, {NULL} },
- { "CaptureResolution", CONFIGURE_VALUE_INT_PAIR_ARRAY, {NULL} },
- { "VideoResolution", CONFIGURE_VALUE_INT_PAIR_ARRAY, {NULL} },
- { "FPS0", CONFIGURE_VALUE_INT_ARRAY, {NULL} },
- { "FPS1", CONFIGURE_VALUE_INT_ARRAY, {NULL} },
- { "FPS2", CONFIGURE_VALUE_INT_ARRAY, {NULL} },
- { "FPS3", CONFIGURE_VALUE_INT_ARRAY, {NULL} },
- { "FPS4", CONFIGURE_VALUE_INT_ARRAY, {NULL} },
- { "FPS5", CONFIGURE_VALUE_INT_ARRAY, {NULL} },
- { "FPS6", CONFIGURE_VALUE_INT_ARRAY, {NULL} },
- { "FPS7", CONFIGURE_VALUE_INT_ARRAY, {NULL} },
- { "FPS8", CONFIGURE_VALUE_INT_ARRAY, {NULL} },
- { "FPS9", CONFIGURE_VALUE_INT_ARRAY, {NULL} },
- { "PictureFormat", CONFIGURE_VALUE_INT_ARRAY, {NULL} },
- { "Overlay", CONFIGURE_VALUE_INT_RANGE, {NULL} },
+ { "InputIndex", CONFIGURE_VALUE_INT_ARRAY, {NULL} },
+ { "DeviceName", CONFIGURE_VALUE_STRING, {NULL} },
+ { "PreviewResolution", CONFIGURE_VALUE_INT_PAIR_ARRAY, {NULL} },
+ { "CaptureResolution", CONFIGURE_VALUE_INT_PAIR_ARRAY, {NULL} },
+ { "VideoResolution", CONFIGURE_VALUE_INT_PAIR_ARRAY, {NULL} },
+ { "FPS0", CONFIGURE_VALUE_INT_ARRAY, {NULL} },
+ { "FPS1", CONFIGURE_VALUE_INT_ARRAY, {NULL} },
+ { "FPS2", CONFIGURE_VALUE_INT_ARRAY, {NULL} },
+ { "FPS3", CONFIGURE_VALUE_INT_ARRAY, {NULL} },
+ { "FPS4", CONFIGURE_VALUE_INT_ARRAY, {NULL} },
+ { "FPS5", CONFIGURE_VALUE_INT_ARRAY, {NULL} },
+ { "FPS6", CONFIGURE_VALUE_INT_ARRAY, {NULL} },
+ { "FPS7", CONFIGURE_VALUE_INT_ARRAY, {NULL} },
+ { "FPS8", CONFIGURE_VALUE_INT_ARRAY, {NULL} },
+ { "FPS9", CONFIGURE_VALUE_INT_ARRAY, {NULL} },
+ { "PictureFormat", CONFIGURE_VALUE_INT_ARRAY, {NULL} },
+ { "Overlay", CONFIGURE_VALUE_INT_RANGE, {NULL} },
{ "RecommendDisplayRotation", CONFIGURE_VALUE_INT, {.value_int = 3} },
{ "RecommendPreviewFormatCapture", CONFIGURE_VALUE_INT, {.value_int = MM_PIXEL_FORMAT_YUYV} },
{ "RecommendPreviewFormatRecord", CONFIGURE_VALUE_INT, {.value_int = MM_PIXEL_FORMAT_NV12} },
{ "RecommendPreviewResolution", CONFIGURE_VALUE_INT_PAIR_ARRAY, {NULL} },
- { "FacingDirection", CONFIGURE_VALUE_INT, {.value_int = MM_CAMCORDER_CAMERA_FACING_DIRECTION_REAR} },
+ { "FacingDirection", CONFIGURE_VALUE_INT, {.value_int = MM_CAMCORDER_CAMERA_FACING_DIRECTION_REAR} },
};
/* [Strobe] matching table */
{ "VideoStabilization", CONFIGURE_VALUE_INT_ARRAY, {NULL} },
{ "FaceZoomMode", CONFIGURE_VALUE_INT_ARRAY, {NULL} },
{ "FaceZoomLevel", CONFIGURE_VALUE_INT_RANGE, {NULL} },
+ { "PanMecha", CONFIGURE_VALUE_INT_RANGE, {NULL} },
+ { "PanElec", CONFIGURE_VALUE_INT_RANGE, {NULL} },
+ { "TiltMecha", CONFIGURE_VALUE_INT_RANGE, {NULL} },
+ { "TiltElec", CONFIGURE_VALUE_INT_RANGE, {NULL} },
};
/* [Capture] matching table */
/* [Detect] matching table */
static conf_info_table conf_ctrl_detect_table[] = {
- { "DetectMode", CONFIGURE_VALUE_INT_ARRAY, {NULL} },
- { "DetectNumber", CONFIGURE_VALUE_INT_RANGE, {NULL} },
- { "DetectSelect", CONFIGURE_VALUE_INT_RANGE, {NULL} },
- { "DetectSelectNumber", CONFIGURE_VALUE_INT_RANGE, {NULL} },
+ { "DetectMode", CONFIGURE_VALUE_INT_ARRAY, {NULL} },
+ { "DetectNumber", CONFIGURE_VALUE_INT_RANGE, {NULL} },
+ { "DetectSelect", CONFIGURE_VALUE_INT_RANGE, {NULL} },
+ { "DetectSelectNumber", CONFIGURE_VALUE_INT_RANGE, {NULL} },
};
if (hcamcorder == NULL) {
}
-int _mmcamcorder_conf_get_info(MMHandleType handle, int type, const char* ConfFile, camera_conf** configure_info)
+int _mmcamcorder_conf_get_info(MMHandleType handle, int type, const char *ConfFile, camera_conf **configure_info)
{
- int ret = MM_ERROR_NONE;
- FILE* fd = NULL;
- char* conf_path = NULL;
+ int ret = MM_ERROR_NONE;
+ FILE *fd = NULL;
+ char conf_path[60] = {'\0',};
- _mmcam_dbg_log( "Opening...[%s]", ConfFile );
+ _mmcam_dbg_log("Opening...[%s]", ConfFile);
- mmf_return_val_if_fail( ConfFile, FALSE );
+ mmf_return_val_if_fail(ConfFile, FALSE);
- conf_path = (char*)malloc( strlen(ConfFile)+strlen(CONFIGURE_PATH)+3 );
+ snprintf(conf_path, sizeof(conf_path), "%s/multimedia/%s", SYSCONFDIR, ConfFile);
+ _mmcam_dbg_log("Try open Configure File[%s]", conf_path);
- if( conf_path == NULL )
- {
- _mmcam_dbg_err( "malloc failed." );
- return MM_ERROR_CAMCORDER_LOW_MEMORY;
- }
-
- snprintf( conf_path, strlen(ConfFile)+strlen(CONFIGURE_PATH)+2, "%s/%s", CONFIGURE_PATH, ConfFile );
- _mmcam_dbg_log( "Try open Configure File[%s]", conf_path );
+ fd = fopen(conf_path, "r");
+ if (fd == NULL) {
+ _mmcam_dbg_warn("File open failed.[%s] retry...", conf_path);
- fd = fopen( conf_path, "r" );
- if( fd == NULL )
- {
- _mmcam_dbg_warn( "File open failed.[%s] retry...", conf_path );
- snprintf( conf_path, strlen(ConfFile)+strlen(CONFIGURE_PATH_RETRY)+2, "%s/%s", CONFIGURE_PATH_RETRY, ConfFile );
- _mmcam_dbg_log( "Try open Configure File[%s]", conf_path );
- fd = fopen( conf_path, "r" );
- if( fd == NULL )
- {
- _mmcam_dbg_warn("open failed.[%s] But keep going... Type[%d]", conf_path, type);
+ snprintf(conf_path, sizeof(conf_path), "%s/multimedia/%s", TZ_SYS_ETC, ConfFile);
+ _mmcam_dbg_log("Try open Configure File[%s]", conf_path);
+ fd = fopen(conf_path, "r");
+ if (fd == NULL) {
+ _mmcam_dbg_warn("open failed.[%s] errno [%d]", conf_path, errno);
}
}
- if( fd != NULL )
- {
- ret = _mmcamcorder_conf_parse_info( handle, type, fd, configure_info );
- fclose( fd );
- }
- else
- {
- ret = MM_ERROR_CAMCORDER_CREATE_CONFIGURE;
- }
-
- if( conf_path != NULL )
- {
- free( conf_path );
- conf_path = NULL;
+ if (fd != NULL) {
+ ret = _mmcamcorder_conf_parse_info(handle, type, fd, configure_info);
+ fclose(fd);
+ } else {
+ if (errno == ENOENT) {
+ ret = MM_ERROR_CAMCORDER_NOT_SUPPORTED;
+ } else {
+ ret = MM_ERROR_CAMCORDER_CREATE_CONFIGURE;
+ }
}
- _mmcam_dbg_log( "Leave..." );
+ _mmcam_dbg_log("Leave...");
return ret;
}
+
int _mmcamcorder_conf_parse_info(MMHandleType handle, int type, FILE* fd, camera_conf** configure_info)
{
const unsigned int BUFFER_NUM_DETAILS = 256;
if (buffer_string == NULL) {
_mmcam_dbg_err("buffer_string alloc failed : %d", sizeof(char) * BUFFER_LENGTH_STRING);
*configure_info = NULL;
- g_free(new_conf);
+ SAFE_G_FREE(new_conf);
return MM_ERROR_CAMCORDER_LOW_MEMORY;
}
if (fd == NULL) {
_mmcam_dbg_err("failed file descriptor fail");
*configure_info = NULL;
- g_free(buffer_string);
- g_free(new_conf);
+ SAFE_G_FREE(buffer_string);
+ SAFE_G_FREE(new_conf);
return MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
}
{
read_main = 1;
buffer_token[0] = token;
- SAFE_FREE( detail_string );
+ SAFE_G_FREE( detail_string );
break;
}
}
else
{
- SAFE_FREE( detail_string );
+ SAFE_G_FREE( detail_string );
}
}
if( count_details == 0 )
{
_mmcam_dbg_warn( "category %s has no detail value... skip this category...", category_name );
- SAFE_FREE(category_name);
+ SAFE_G_FREE(category_name);
continue;
}
for( i = 0 ; i < count_details ; i++ )
{
- SAFE_FREE( buffer_details[i] );
+ SAFE_G_FREE( buffer_details[i] );
}
}
}
- SAFE_FREE(category_name);
+ SAFE_G_FREE(category_name);
}
//(*configure_info) = new_conf;
- SAFE_FREE( buffer_string );
+ SAFE_G_FREE( buffer_string );
/*_mmcam_dbg_log( "Done." );*/
switch (type) {
case CONFIGURE_VALUE_INT:
temp_int = (type_int2*)(temp_conf->info[i]->detail_info[j]);
- SAFE_FREE(temp_int->name);
+ SAFE_G_FREE(temp_int->name);
break;
case CONFIGURE_VALUE_INT_RANGE:
temp_int_range = (type_int_range*)(temp_conf->info[i]->detail_info[j]);
- SAFE_FREE(temp_int_range->name);
+ SAFE_G_FREE(temp_int_range->name);
break;
case CONFIGURE_VALUE_INT_ARRAY:
temp_int_array = (type_int_array*)(temp_conf->info[i]->detail_info[j]);
- SAFE_FREE(temp_int_array->name);
- SAFE_FREE(temp_int_array->value);
+ SAFE_G_FREE(temp_int_array->name);
+ SAFE_G_FREE(temp_int_array->value);
break;
case CONFIGURE_VALUE_INT_PAIR_ARRAY:
temp_int_pair_array = (type_int_pair_array*)(temp_conf->info[i]->detail_info[j]);
- SAFE_FREE(temp_int_pair_array->name);
- SAFE_FREE(temp_int_pair_array->value[0]);
- SAFE_FREE(temp_int_pair_array->value[1]);
+ SAFE_G_FREE(temp_int_pair_array->name);
+ SAFE_G_FREE(temp_int_pair_array->value[0]);
+ SAFE_G_FREE(temp_int_pair_array->value[1]);
break;
case CONFIGURE_VALUE_STRING:
temp_string = (type_string2*)(temp_conf->info[i]->detail_info[j]);
- SAFE_FREE(temp_string->name);
- SAFE_FREE(temp_string->value);
+ SAFE_G_FREE(temp_string->name);
+ SAFE_G_FREE(temp_string->value);
break;
case CONFIGURE_VALUE_STRING_ARRAY:
temp_string_array = (type_string_array*)(temp_conf->info[i]->detail_info[j]);
- SAFE_FREE(temp_string_array->name);
+ SAFE_G_FREE(temp_string_array->name);
if (temp_string_array->value) {
count = temp_string_array->count;
for (k = 0 ; k < count ; k++) {
- SAFE_FREE(temp_string_array->value[k]);
+ SAFE_G_FREE(temp_string_array->value[k]);
}
- g_free(temp_string_array->value);
- temp_string_array->value = NULL;
+ SAFE_G_FREE(temp_string_array->value);
}
- SAFE_FREE(temp_string_array->default_value);
+ SAFE_G_FREE(temp_string_array->default_value);
break;
case CONFIGURE_VALUE_ELEMENT:
temp_element = (type_element2*)(temp_conf->info[i]->detail_info[j]);
- SAFE_FREE(temp_element->name);
- SAFE_FREE(temp_element->element_name);
+ SAFE_G_FREE(temp_element->name);
+ SAFE_G_FREE(temp_element->element_name);
if (temp_element->value_int) {
count = temp_element->count_int;
for (k = 0 ; k < count ; k++) {
- SAFE_FREE(temp_element->value_int[k]->name);
- SAFE_FREE(temp_element->value_int[k]);
+ SAFE_G_FREE(temp_element->value_int[k]->name);
+ SAFE_G_FREE(temp_element->value_int[k]);
}
- g_free(temp_element->value_int);
+ SAFE_G_FREE(temp_element->value_int);
}
if (temp_element->value_string) {
count = temp_element->count_string;
for (k = 0 ; k < count ; k++) {
- SAFE_FREE(temp_element->value_string[k]->name);
- SAFE_FREE(temp_element->value_string[k]->value);
- SAFE_FREE(temp_element->value_string[k]);
+ SAFE_G_FREE(temp_element->value_string[k]->name);
+ SAFE_G_FREE(temp_element->value_string[k]->value);
+ SAFE_G_FREE(temp_element->value_string[k]);
}
- g_free(temp_element->value_string);
+ SAFE_G_FREE(temp_element->value_string);
}
break;
default:
}
}
- SAFE_FREE(temp_conf->info[i]->detail_info[j]);
- temp_conf->info[i]->detail_info[j] = NULL;
+ SAFE_G_FREE(temp_conf->info[i]->detail_info[j]);
}
- SAFE_FREE(temp_conf->info[i]->detail_info);
- temp_conf->info[i]->detail_info = NULL;
+ SAFE_G_FREE(temp_conf->info[i]->detail_info);
- SAFE_FREE(temp_conf->info[i]);
+ SAFE_G_FREE(temp_conf->info[i]);
temp_conf->info[i] = NULL;
}
}
- SAFE_FREE((*configure_info)->info);
- SAFE_FREE((*configure_info));
+ SAFE_G_FREE((*configure_info)->info);
+ SAFE_G_FREE((*configure_info));
_mmcam_dbg_log("Done.");
}
new_int_array->name = get_new_string( buffer_token[0] );
new_int_array->value = (int*)g_malloc0( sizeof(int)*count_value );
if (new_int_array->value == NULL) {
- if (new_int_array->name) {
- free(new_int_array->name);
- new_int_array->name = NULL;
- }
- free(new_int_array);
- new_int_array = NULL;
+ SAFE_G_FREE(new_int_array->name);
+ SAFE_G_FREE(new_int_array);
_mmcam_dbg_err("allocation failed");
break;
}
break;
}
new_int_pair_array->name = get_new_string( buffer_token[0] );
- new_int_pair_array->value[0] = (int*)g_malloc( sizeof(int)*(count_value) );
+ new_int_pair_array->value[0] = (int*)g_malloc0( sizeof(int)*(count_value) );
if ( new_int_pair_array->value[0] == NULL ) {
- if (new_int_pair_array->name) {
- free( new_int_pair_array->name );
- new_int_pair_array->name = NULL;
- }
- g_free( new_int_pair_array );
- new_int_pair_array = NULL;
+ SAFE_G_FREE(new_int_pair_array->name);
+ SAFE_G_FREE(new_int_pair_array);
_mmcam_dbg_err("allocation failed");
break;
}
- new_int_pair_array->value[1] = (int*)g_malloc( sizeof(int)*(count_value) );
+ new_int_pair_array->value[1] = (int*)g_malloc0( sizeof(int)*(count_value) );
if ( new_int_pair_array->value[1] == NULL ) {
- g_free( new_int_pair_array->value[0] );
- new_int_pair_array->value[0] = NULL;
- if (new_int_pair_array->name) {
- free( new_int_pair_array->name );
- new_int_pair_array->name = NULL;
- }
- g_free( new_int_pair_array );
- new_int_pair_array = NULL;
+ SAFE_G_FREE(new_int_pair_array->value[0]);
+ SAFE_G_FREE(new_int_pair_array->name);
+ SAFE_G_FREE(new_int_pair_array);
_mmcam_dbg_err("allocation failed");
break;
}
new_string_array->count = count_value;
new_string_array->value = (char**)g_malloc0( sizeof(char*)*count_value );
if ( new_string_array->value == NULL ) {
- if (new_string_array->name) {
- free(new_string_array->name);
- new_string_array->name = NULL;
- }
- free(new_string_array);
- new_string_array = NULL;
+ SAFE_G_FREE(new_string_array->name);
+ SAFE_G_FREE(new_string_array);
_mmcam_dbg_err("allocation failed");
break;
}
new_element->value_int = (type_int2**)g_malloc0( sizeof(type_int2*)*(new_element->count_int) );
if ( new_element->value_int) {
for ( j = 0 ; j < new_element->count_int ; j++ ) {
- new_element->value_int[j] = (type_int2*)g_malloc( sizeof(type_int2) );
+ new_element->value_int[j] = (type_int2*)g_malloc0( sizeof(type_int2) );
if ( new_element->value_int[j] ) {
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)] );
} else {
_mmcam_dbg_err("allocation failed");
}
- }
- else
- {
- _mmcam_dbg_err("invalid count - %d", new_element->count_int);
+ } else {
+ /*_mmcam_dbg_err("invalid count - %d", new_element->count_int);*/
new_element->value_int = NULL;
}
_mmcam_dbg_err("malloc failed : %d", sizeof(type_string2*)*(new_element->count_string));
}
} else {
- _mmcam_dbg_err("invalid count - %d", new_element->count_string);
+ /*_mmcam_dbg_err("invalid count - %d", new_element->count_string);*/
new_element->value_string = NULL;
}