Change flag for some attributes
[platform/core/multimedia/libmm-camcorder.git] / src / mm_camcorder_configure.c
1 /*
2  * libmm-camcorder
3  *
4  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: Jeongmo Yang <jm80.yang@samsung.com>
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  *
20  */
21
22 /*=======================================================================================
23 |  INCLUDE FILES                                                                        |
24 =======================================================================================*/
25 #include <stdio.h>
26 #include <string.h>
27 #include <stdlib.h>
28 #include <unistd.h>
29
30 #include "mm_camcorder_internal.h"
31 #include "mm_camcorder_configure.h"
32
33 /*-----------------------------------------------------------------------
34 |    MACRO DEFINITIONS:                                                 |
35 -----------------------------------------------------------------------*/
36
37 /*-----------------------------------------------------------------------
38 |    GLOBAL VARIABLE DEFINITIONS                                        |
39 -----------------------------------------------------------------------*/
40
41 /*-----------------------------------------------------------------------
42 |    LOCAL VARIABLE DEFINITIONS                                         |
43 -----------------------------------------------------------------------*/
44 #define DEFAULT_AUDIO_BUFFER_INTERVAL   50
45
46
47 char *get_new_string(char* src_string)
48 {
49         return g_strdup(src_string);
50 }
51
52 int _mmcamcorder_conf_init(MMHandleType handle, int type, camera_conf *configure_info)
53 {
54         int category_num = 0;
55         int info_table_size = sizeof(conf_info_table);
56
57         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
58
59         mmf_return_val_if_fail(hcamcorder && configure_info, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
60
61         /* Videosrc element default value */
62         static type_element _videosrc_element_default = {
63                 "VideosrcElement",
64                 "videotestsrc",
65                 NULL,
66                 0,
67                 NULL,
68                 0,
69         };
70
71         /* Audiosrc element default value */
72         static type_int  ___audiosrc_default_channel = {"Channel", 1};
73         static type_int  ___audiosrc_default_bitrate = {"BitRate", 8000};
74         static type_int  ___audiosrc_default_depth = {"Depth", 16};
75         static type_int  ___audiosrc_default_blocksize = {"BlockSize", 1280};
76         static type_int* __audiosrc_default_int_array[] = {
77                 &___audiosrc_default_channel,
78                 &___audiosrc_default_bitrate,
79                 &___audiosrc_default_depth,
80                 &___audiosrc_default_blocksize,
81         };
82         static type_string  ___audiosrc_default_device = {"Device", "default"};
83         static type_string* __audiosrc_default_string_array[] = {
84                 &___audiosrc_default_device,
85         };
86         static type_element _audiosrc_element_default = {
87                 "AudiosrcElement",
88                 "audiotestsrc",
89                 __audiosrc_default_int_array,
90                 sizeof(__audiosrc_default_int_array) / sizeof(type_int*),
91                 __audiosrc_default_string_array,
92                 sizeof(__audiosrc_default_string_array) / sizeof(type_string*),
93         };
94
95         static type_element _audiomodemsrc_element_default = {
96                 "AudiomodemsrcElement",
97                 "audiotestsrc",
98                 __audiosrc_default_int_array,
99                 sizeof(__audiosrc_default_int_array) / sizeof(type_int*),
100                 __audiosrc_default_string_array,
101                 sizeof(__audiosrc_default_string_array) / sizeof(type_string*),
102         };
103
104
105         /* Videosink element default value */
106         static type_int  ___videosink_default_display_id = {"display-id", 3};
107         static type_int  ___videosink_default_x = {"x", 0};
108         static type_int  ___videosink_default_y = {"y", 0};
109         static type_int  ___videosink_default_width = {"width", 800};
110         static type_int  ___videosink_default_height = {"height", 480};
111         static type_int  ___videosink_default_rotation = {"rotation", 1};
112         static type_int* __videosink_default_int_array[] = {
113                 &___videosink_default_display_id,
114                 &___videosink_default_x,
115                 &___videosink_default_y,
116                 &___videosink_default_width,
117                 &___videosink_default_height,
118                 &___videosink_default_rotation,
119         };
120         static type_string* __videosink_default_string_array[] = {NULL};
121         static type_element _videosink_element_overlay_default = {
122                 "VideosinkElementOverlay",
123                 "tizenwlsink",
124                 __videosink_default_int_array,
125                 sizeof(__videosink_default_int_array) / sizeof(type_int*),
126                 __videosink_default_string_array,
127                 sizeof(__videosink_default_string_array) / sizeof(type_string*),
128         };
129         static type_element _videosink_element_evas_default = {
130                 "VideosinkElementEvas",
131                 "evasimagesink",
132                 __videosink_default_int_array,
133                 sizeof(__videosink_default_int_array) / sizeof(type_int*),
134                 __videosink_default_string_array,
135                 sizeof(__videosink_default_string_array) / sizeof(type_string*),
136         };
137         static type_element _videosink_element_gl_default = {
138                 "VideosinkElementGL",
139                 "glimagesink",
140                 __videosink_default_int_array,
141                 sizeof(__videosink_default_int_array) / sizeof(type_int*),
142                 __videosink_default_string_array,
143                 sizeof(__videosink_default_string_array) / sizeof(type_string*),
144         };
145         static type_element _videosink_element_remote_default = {
146                 "VideosinkElementRemote",
147                 "shmsink",
148                 __videosink_default_int_array,
149                 sizeof(__videosink_default_int_array) / sizeof(type_int*),
150                 __videosink_default_string_array,
151                 sizeof(__videosink_default_string_array) / sizeof(type_string*),
152         };
153         static type_element _videosink_element_null_default = {
154                 "VideosinkElementNull",
155                 "fakesink",
156                 __videosink_default_int_array,
157                 sizeof(__videosink_default_int_array) / sizeof(type_int*),
158                 __videosink_default_string_array,
159                 sizeof(__videosink_default_string_array) / sizeof(type_string*),
160         };
161
162         /* Videoscale element default value */
163         static type_element _videoscale_element_default = {
164                 "VideoscaleElement",
165                 "videoscale",
166                 NULL,
167                 0,
168                 NULL,
169                 0,
170         };
171
172         /* Videoconvert element default value */
173         static type_element _videoconvert_element_default = {
174                 "VideoconvertElement",
175                 "videoconvert",
176                 NULL,
177                 0,
178                 NULL,
179                 0,
180         };
181
182         /* H.264 decoder element default value */
183         static type_element _videodecoder_element_h264_default = {
184                 "VideodecoderElementH264",
185                 "avdec_h264",
186                 NULL,
187                 0,
188                 NULL,
189                 0,
190         };
191
192         /* Record sink element default value */
193         static type_element _recordsink_element_default = {
194                 "RecordsinkElement",
195                 "fakesink",
196                 NULL,
197                 0,
198                 NULL,
199                 0,
200         };
201
202         /* H263 element default value */
203         static type_element _h263_element_default = {
204                 "H263",
205                 "avenc_h263",
206                 NULL,
207                 0,
208                 NULL,
209                 0,
210         };
211
212         /* H264 element default value */
213         static type_element _h264_element_default = {
214                 "H264",
215                 NULL,
216                 NULL,
217                 0,
218                 NULL,
219                 0,
220         };
221
222         /* H26L element default value */
223         static type_element _h26l_element_default = {
224                 "H26L",
225                 NULL,
226                 NULL,
227                 0,
228                 NULL,
229                 0,
230         };
231
232         /* MPEG4 element default value */
233         static type_element _mpeg4_element_default = {
234                 "MPEG4",
235                 "avenc_mpeg4",
236                 NULL,
237                 0,
238                 NULL,
239                 0,
240         };
241
242         /* MPEG1 element default value */
243         static type_element _mpeg1_element_default = {
244                 "MPEG1",
245                 "avenc_mpeg1video",
246                 NULL,
247                 0,
248                 NULL,
249                 0,
250         };
251
252         /* THEORA element default value */
253         static type_element _theora_element_default = {
254                 "THEORA",
255                 "theoraenc",
256                 NULL,
257                 0,
258                 NULL,
259                 0,
260         };
261
262         /* AMR element default value */
263         static type_element _amr_element_default = {
264                 "AMR",
265                 "amrnbenc",
266                 NULL,
267                 0,
268                 NULL,
269                 0,
270         };
271
272         /* G723_1 element default value */
273         static type_element _g723_1_element_default = {
274                 "G723_1",
275                 NULL,
276                 NULL,
277                 0,
278                 NULL,
279                 0,
280         };
281
282         /* MP3 element default value */
283         static type_element _mp3_element_default = {
284                 "MP3",
285                 "lamemp3enc",
286                 NULL,
287                 0,
288                 NULL,
289                 0,
290         };
291
292         /* AAC element default value */
293         static type_element _aac_element_default = {
294                 "AAC",
295                 NULL,
296                 NULL,
297                 0,
298                 NULL,
299                 0,
300         };
301
302         /* MMF element default value */
303         static type_element _mmf_element_default = {
304                 "MMF",
305                 NULL,
306                 NULL,
307                 0,
308                 NULL,
309                 0,
310         };
311
312         /* ADPCM element default value */
313         static type_element _adpcm_element_default = {
314                 "ADPCM",
315                 "avenc_adpcm_ima_qt",
316                 NULL,
317                 0,
318                 NULL,
319                 0,
320         };
321
322         /* WAVE element default value */
323         static type_element _wave_element_default = {
324                 "WAVE",
325                 "wavenc",
326                 NULL,
327                 0,
328                 NULL,
329                 0,
330         };
331
332         /* VORBIS element default value */
333         static type_element _vorbis_element_default = {
334                 "VORBIS",
335                 "vorbisenc",
336                 NULL,
337                 0,
338                 NULL,
339                 0,
340         };
341
342         /* MIDI element default value */
343         static type_element _midi_element_default = {
344                 "MIDI",
345                 NULL,
346                 NULL,
347                 0,
348                 NULL,
349                 0,
350         };
351
352         /* IMELODY element default value */
353         static type_element _imelody_element_default = {
354                 "IMELODY",
355                 NULL,
356                 NULL,
357                 0,
358                 NULL,
359                 0,
360         };
361
362         /* JPEG element default value */
363         static type_element _jpeg_element_default = {
364                 "JPEG",
365                 "jpegenc",
366                 NULL,
367                 0,
368                 NULL,
369                 0,
370         };
371
372         /* PNG element default value */
373         static type_element _png_element_default = {
374                 "PNG",
375                 "pngenc",
376                 NULL,
377                 0,
378                 NULL,
379                 0,
380         };
381
382         /* BMP element default value */
383         static type_element _bmp_element_default = {
384                 "BMP",
385                 NULL,
386                 NULL,
387                 0,
388                 NULL,
389                 0,
390         };
391
392         /* WBMP element default value */
393         static type_element _wbmp_element_default = {
394                 "WBMP",
395                 NULL,
396                 NULL,
397                 0,
398                 NULL,
399                 0,
400         };
401
402         /* TIFF element default value */
403         static type_element _tiff_element_default = {
404                 "TIFF",
405                 NULL,
406                 NULL,
407                 0,
408                 NULL,
409                 0,
410         };
411
412         /* PCX element default value */
413         static type_element _pcx_element_default = {
414                 "PCX",
415                 NULL,
416                 NULL,
417                 0,
418                 NULL,
419                 0,
420         };
421
422         /* GIF element default value */
423         static type_element _gif_element_default = {
424                 "GIF",
425                 NULL,
426                 NULL,
427                 0,
428                 NULL,
429                 0,
430         };
431
432         /* ICO element default value */
433         static type_element _ico_element_default = {
434                 "ICO",
435                 NULL,
436                 NULL,
437                 0,
438                 NULL,
439                 0,
440         };
441
442         /* RAS element default value */
443         static type_element _ras_element_default = {
444                 "RAS",
445                 NULL,
446                 NULL,
447                 0,
448                 NULL,
449                 0,
450         };
451
452         /* TGA element default value */
453         static type_element _tga_element_default = {
454                 "TGA",
455                 NULL,
456                 NULL,
457                 0,
458                 NULL,
459                 0,
460         };
461
462         /* XBM element default value */
463         static type_element _xbm_element_default = {
464                 "XBM",
465                 NULL,
466                 NULL,
467                 0,
468                 NULL,
469                 0,
470         };
471
472         /* XPM element default value */
473         static type_element _xpm_element_default = {
474                 "XPM",
475                 NULL,
476                 NULL,
477                 0,
478                 NULL,
479                 0,
480         };
481
482         /* 3GP element default value */
483         static type_element _3gp_element_default = {
484                 "3GP",
485                 "avmux_3gp",
486                 NULL,
487                 0,
488                 NULL,
489                 0,
490         };
491
492         /* AMR mux element default value */
493         static type_element _amrmux_element_default = {
494                 "AMR",
495                 "avmux_amr",
496                 NULL,
497                 0,
498                 NULL,
499                 0,
500         };
501
502         /* MP4 element default value */
503         static type_element _mp4_element_default = {
504                 "MP4",
505                 "avmux_mp4",
506                 NULL,
507                 0,
508                 NULL,
509                 0,
510         };
511
512         /* AAC mux element default value */
513         static type_element _aacmux_element_default = {
514                 "AAC",
515                 NULL,
516                 NULL,
517                 0,
518                 NULL,
519                 0,
520         };
521
522         /* MP3 mux element default value */
523         static type_element _mp3mux_element_default = {
524                 "MP3",
525                 NULL,
526                 NULL,
527                 0,
528                 NULL,
529                 0,
530         };
531
532         /* OGG element default value */
533         static type_element _ogg_element_default = {
534                 "OGG",
535                 "oggmux",
536                 NULL,
537                 0,
538                 NULL,
539                 0,
540         };
541
542         /* WAV element default value */
543         static type_element _wav_element_default = {
544                 "WAV",
545                 NULL,
546                 NULL,
547                 0,
548                 NULL,
549                 0,
550         };
551
552         /* AVI element default value */
553         static type_element _avi_element_default = {
554                 "AVI",
555                 "avimux",
556                 NULL,
557                 0,
558                 NULL,
559                 0,
560         };
561
562         /* WMA element default value */
563         static type_element _wma_element_default = {
564                 "WMA",
565                 NULL,
566                 NULL,
567                 0,
568                 NULL,
569                 0,
570         };
571
572         /* WMV element default value */
573         static type_element _wmv_element_default = {
574                 "WMV",
575                 NULL,
576                 NULL,
577                 0,
578                 NULL,
579                 0,
580         };
581
582         /* MID element default value */
583         static type_element _mid_element_default = {
584                 "MID",
585                 NULL,
586                 NULL,
587                 0,
588                 NULL,
589                 0,
590         };
591
592         /* MMF mux element default value */
593         static type_element _mmfmux_element_default = {
594                 "MMF",
595                 "avmux_mmf",
596                 NULL,
597                 0,
598                 NULL,
599                 0,
600         };
601
602         /* MATROSKA element default value */
603         static type_element _matroska_element_default = {
604                 "MATROSKA",
605                 "matroskamux",
606                 NULL,
607                 0,
608                 NULL,
609                 0,
610         };
611
612         /* M2TS element default value */
613         static type_element _m2ts_element_default = {
614                 "M2TS",
615                 "mpegtsmux",
616                 NULL,
617                 0,
618                 NULL,
619                 0,
620         };
621
622         /* [General] matching table */
623         static conf_info_table conf_main_general_table[] = {
624                 { "SyncStateChange", CONFIGURE_VALUE_INT,           {.value_int = 1} },
625                 { "GSTInitOption",   CONFIGURE_VALUE_STRING_ARRAY,  {NULL} },
626                 { "ModelName",       CONFIGURE_VALUE_STRING,        {NULL} },
627                 { "DisabledAttributes", CONFIGURE_VALUE_STRING_ARRAY,  {NULL} },
628         };
629
630         /* [VideoInput] matching table */
631         static conf_info_table conf_main_video_input_table[] = {
632                 { "VideosrcElement",    CONFIGURE_VALUE_ELEMENT,        {&_videosrc_element_default} },
633                 { "UseVideoscale",      CONFIGURE_VALUE_INT,            {.value_int = 0} },
634                 { "VideoscaleElement",  CONFIGURE_VALUE_ELEMENT,        {&_videoscale_element_default} },
635                 { "UseZeroCopyFormat",  CONFIGURE_VALUE_INT,            {.value_int = 0} },
636                 { "DeviceCount",        CONFIGURE_VALUE_INT,            {.value_int = MM_VIDEO_DEVICE_NUM} },
637                 { "SupportMediaPacketPreviewCb",  CONFIGURE_VALUE_INT,  {.value_int = 0} },
638         };
639
640         /* [AudioInput] matching table */
641         static conf_info_table conf_main_audio_input_table[] = {
642                 { "AudioDevice",          CONFIGURE_VALUE_INT_ARRAY, {NULL} },
643                 { "AudiosrcElement",      CONFIGURE_VALUE_ELEMENT, {&_audiosrc_element_default} },
644                 { "AudiomodemsrcElement", CONFIGURE_VALUE_ELEMENT, {&_audiomodemsrc_element_default} },
645                 { "AudioBufferInterval",  CONFIGURE_VALUE_INT,     {.value_int = DEFAULT_AUDIO_BUFFER_INTERVAL} },
646         };
647
648         /* [VideoOutput] matching table */
649         static conf_info_table conf_main_video_output_table[] = {
650                 { "DisplayDevice",           CONFIGURE_VALUE_INT_ARRAY, {NULL} },
651                 { "DisplayMode",             CONFIGURE_VALUE_INT_ARRAY, {NULL} },
652                 { "Videosink",               CONFIGURE_VALUE_INT_ARRAY, {NULL} },
653                 { "VideosinkElementOverlay", CONFIGURE_VALUE_ELEMENT,   {&_videosink_element_overlay_default} },
654                 { "VideosinkElementEvas",    CONFIGURE_VALUE_ELEMENT,   {&_videosink_element_evas_default} },
655                 { "VideosinkElementGL",      CONFIGURE_VALUE_ELEMENT,   {&_videosink_element_gl_default} },
656                 { "VideosinkElementRemote",  CONFIGURE_VALUE_ELEMENT,   {&_videosink_element_remote_default} },
657                 { "VideosinkElementNull",    CONFIGURE_VALUE_ELEMENT,   {&_videosink_element_null_default} },
658                 { "UseVideoscale",           CONFIGURE_VALUE_INT,       {.value_int = 0} },
659                 { "VideoscaleElement",       CONFIGURE_VALUE_ELEMENT,   {&_videoscale_element_default} },
660                 { "UseVideoconvert",         CONFIGURE_VALUE_INT,       {.value_int = 0} },
661                 { "VideoconvertElement",     CONFIGURE_VALUE_ELEMENT,   {&_videoconvert_element_default} },
662                 { "VideodecoderElementH264", CONFIGURE_VALUE_ELEMENT,   {&_videodecoder_element_h264_default} },
663                 { "RecreateDecoder",         CONFIGURE_VALUE_INT,       {.value_int = 0} }
664         };
665
666         /* [Capture] matching table */
667         static conf_info_table conf_main_capture_table[] = {
668                 { "UseEncodebin",           CONFIGURE_VALUE_INT,     {.value_int = 0} },
669                 { "UseCaptureMode",         CONFIGURE_VALUE_INT,     {.value_int = 0} },
670                 { "VideoscaleElement",      CONFIGURE_VALUE_ELEMENT, {&_videoscale_element_default} },
671                 { "PlayCaptureSound",       CONFIGURE_VALUE_INT,     {.value_int = 1} },
672         };
673
674         /* [Record] matching table */
675         static conf_info_table conf_main_record_table[] = {
676                 { "UseAudioEncoderQueue",   CONFIGURE_VALUE_INT,     {.value_int = 1} },
677                 { "UseVideoEncoderQueue",   CONFIGURE_VALUE_INT,     {.value_int = 1} },
678                 { "VideoProfile",           CONFIGURE_VALUE_INT,     {.value_int = 0} },
679                 { "VideoAutoAudioConvert",  CONFIGURE_VALUE_INT,     {.value_int = 0} },
680                 { "VideoAutoAudioResample", CONFIGURE_VALUE_INT,     {.value_int = 0} },
681                 { "VideoAutoColorSpace",    CONFIGURE_VALUE_INT,     {.value_int = 0} },
682                 { "AudioProfile",           CONFIGURE_VALUE_INT,     {.value_int = 0} },
683                 { "AudioAutoAudioConvert",  CONFIGURE_VALUE_INT,     {.value_int = 0} },
684                 { "AudioAutoAudioResample", CONFIGURE_VALUE_INT,     {.value_int = 0} },
685                 { "AudioAutoColorSpace",    CONFIGURE_VALUE_INT,     {.value_int = 0} },
686                 { "ImageProfile",           CONFIGURE_VALUE_INT,     {.value_int = 0} },
687                 { "ImageAutoAudioConvert",  CONFIGURE_VALUE_INT,     {.value_int = 0} },
688                 { "ImageAutoAudioResample", CONFIGURE_VALUE_INT,     {.value_int = 0} },
689                 { "ImageAutoColorSpace",    CONFIGURE_VALUE_INT,     {.value_int = 0} },
690                 { "RecordsinkElement",      CONFIGURE_VALUE_ELEMENT, {&_recordsink_element_default} },
691                 { "UseNoiseSuppressor",     CONFIGURE_VALUE_INT,     {.value_int = 0} },
692                 { "DropVideoFrame",         CONFIGURE_VALUE_INT,     {.value_int = 0} },
693                 { "PassFirstVideoFrame",    CONFIGURE_VALUE_INT,     {.value_int = 0} },
694                 { "SupportDualStream",      CONFIGURE_VALUE_INT,     {.value_int = FALSE} },
695         };
696
697         /* [VideoEncoder] matching table */
698         static conf_info_table conf_main_video_encoder_table[] = {
699                 { "H263",    CONFIGURE_VALUE_ELEMENT, {&_h263_element_default} },
700                 { "H264",    CONFIGURE_VALUE_ELEMENT, {&_h264_element_default} },
701                 { "H26L",    CONFIGURE_VALUE_ELEMENT, {&_h26l_element_default} },
702                 { "MPEG4",   CONFIGURE_VALUE_ELEMENT, {&_mpeg4_element_default} },
703                 { "MPEG1",   CONFIGURE_VALUE_ELEMENT, {&_mpeg1_element_default} },
704                 { "THEORA",  CONFIGURE_VALUE_ELEMENT, {&_theora_element_default} },
705         };
706
707         /* [AudioEncoder] matching table */
708         static conf_info_table conf_main_audio_encoder_table[] = {
709                 { "AMR",     CONFIGURE_VALUE_ELEMENT, {&_amr_element_default} },
710                 { "G723_1",  CONFIGURE_VALUE_ELEMENT, {&_g723_1_element_default} },
711                 { "MP3",     CONFIGURE_VALUE_ELEMENT, {&_mp3_element_default} },
712                 { "AAC",     CONFIGURE_VALUE_ELEMENT, {&_aac_element_default} },
713                 { "MMF",     CONFIGURE_VALUE_ELEMENT, {&_mmf_element_default} },
714                 { "ADPCM",   CONFIGURE_VALUE_ELEMENT, {&_adpcm_element_default} },
715                 { "WAVE",    CONFIGURE_VALUE_ELEMENT, {&_wave_element_default} },
716                 { "MIDI",    CONFIGURE_VALUE_ELEMENT, {&_midi_element_default} },
717                 { "IMELODY", CONFIGURE_VALUE_ELEMENT, {&_imelody_element_default} },
718                 { "VORBIS",  CONFIGURE_VALUE_ELEMENT, {&_vorbis_element_default} },
719         };
720
721         /* [ImageEncoder] matching table */
722         static conf_info_table conf_main_image_encoder_table[] = {
723                 { "JPEG", CONFIGURE_VALUE_ELEMENT, {&_jpeg_element_default} },
724                 { "PNG",  CONFIGURE_VALUE_ELEMENT, {&_png_element_default} },
725                 { "BMP",  CONFIGURE_VALUE_ELEMENT, {&_bmp_element_default} },
726                 { "WBMP", CONFIGURE_VALUE_ELEMENT, {&_wbmp_element_default} },
727                 { "TIFF", CONFIGURE_VALUE_ELEMENT, {&_tiff_element_default} },
728                 { "PCX",  CONFIGURE_VALUE_ELEMENT, {&_pcx_element_default} },
729                 { "GIF",  CONFIGURE_VALUE_ELEMENT, {&_gif_element_default} },
730                 { "ICO",  CONFIGURE_VALUE_ELEMENT, {&_ico_element_default} },
731                 { "RAS",  CONFIGURE_VALUE_ELEMENT, {&_ras_element_default} },
732                 { "TGA",  CONFIGURE_VALUE_ELEMENT, {&_tga_element_default} },
733                 { "XBM",  CONFIGURE_VALUE_ELEMENT, {&_xbm_element_default} },
734                 { "XPM",  CONFIGURE_VALUE_ELEMENT, {&_xpm_element_default} },
735         };
736
737         /* [Mux] matching table */
738         static conf_info_table conf_main_mux_table[] = {
739                 { "3GP",      CONFIGURE_VALUE_ELEMENT, {&_3gp_element_default} },
740                 { "AMR",      CONFIGURE_VALUE_ELEMENT, {&_amrmux_element_default} },
741                 { "MP4",      CONFIGURE_VALUE_ELEMENT, {&_mp4_element_default} },
742                 { "AAC",      CONFIGURE_VALUE_ELEMENT, {&_aacmux_element_default} },
743                 { "MP3",      CONFIGURE_VALUE_ELEMENT, {&_mp3mux_element_default} },
744                 { "OGG",      CONFIGURE_VALUE_ELEMENT, {&_ogg_element_default} },
745                 { "WAV",      CONFIGURE_VALUE_ELEMENT, {&_wav_element_default} },
746                 { "AVI",      CONFIGURE_VALUE_ELEMENT, {&_avi_element_default} },
747                 { "WMA",      CONFIGURE_VALUE_ELEMENT, {&_wma_element_default} },
748                 { "WMV",      CONFIGURE_VALUE_ELEMENT, {&_wmv_element_default} },
749                 { "MID",      CONFIGURE_VALUE_ELEMENT, {&_mid_element_default} },
750                 { "MMF",      CONFIGURE_VALUE_ELEMENT, {&_mmfmux_element_default} },
751                 { "MATROSKA", CONFIGURE_VALUE_ELEMENT, {&_matroska_element_default} },
752                 { "M2TS",     CONFIGURE_VALUE_ELEMENT, {&_m2ts_element_default} },
753         };
754
755
756         /*******************
757         *  Camera control *
758         *******************/
759
760         /* [Camera] matching table */
761         static conf_info_table conf_ctrl_camera_table[] = {
762                 { "InputIndex",           CONFIGURE_VALUE_INT_ARRAY,      {NULL} },
763                 { "DeviceName",           CONFIGURE_VALUE_STRING,         {NULL} },
764                 { "PreviewResolution",    CONFIGURE_VALUE_INT_PAIR_ARRAY, {NULL} },
765                 { "CaptureResolution",    CONFIGURE_VALUE_INT_PAIR_ARRAY, {NULL} },
766                 { "VideoResolution",      CONFIGURE_VALUE_INT_PAIR_ARRAY, {NULL} },
767                 { "FPS0",                 CONFIGURE_VALUE_INT_ARRAY,      {NULL} },
768                 { "FPS1",                 CONFIGURE_VALUE_INT_ARRAY,      {NULL} },
769                 { "FPS2",                 CONFIGURE_VALUE_INT_ARRAY,      {NULL} },
770                 { "FPS3",                 CONFIGURE_VALUE_INT_ARRAY,      {NULL} },
771                 { "FPS4",                 CONFIGURE_VALUE_INT_ARRAY,      {NULL} },
772                 { "FPS5",                 CONFIGURE_VALUE_INT_ARRAY,      {NULL} },
773                 { "FPS6",                 CONFIGURE_VALUE_INT_ARRAY,      {NULL} },
774                 { "FPS7",                 CONFIGURE_VALUE_INT_ARRAY,      {NULL} },
775                 { "FPS8",                 CONFIGURE_VALUE_INT_ARRAY,      {NULL} },
776                 { "FPS9",                 CONFIGURE_VALUE_INT_ARRAY,      {NULL} },
777                 { "PictureFormat",        CONFIGURE_VALUE_INT_ARRAY,      {NULL} },
778                 { "Overlay",              CONFIGURE_VALUE_INT_RANGE,      {NULL} },
779                 { "RecommendDisplayRotation", CONFIGURE_VALUE_INT,     {.value_int = 3} },
780                 { "RecommendPreviewFormatCapture", CONFIGURE_VALUE_INT, {.value_int = MM_PIXEL_FORMAT_YUYV} },
781                 { "RecommendPreviewFormatRecord",  CONFIGURE_VALUE_INT, {.value_int = MM_PIXEL_FORMAT_NV12} },
782                 { "RecommendPreviewResolution", CONFIGURE_VALUE_INT_PAIR_ARRAY, {NULL} },
783                 { "FacingDirection",      CONFIGURE_VALUE_INT, {.value_int = MM_CAMCORDER_CAMERA_FACING_DIRECTION_REAR} },
784                 { "FrameStabilityCount",  CONFIGURE_VALUE_INT,     {.value_int = 0} },
785         };
786
787         /* [Strobe] matching table */
788         static conf_info_table conf_ctrl_strobe_table[] = {
789                 { "StrobeControl",        CONFIGURE_VALUE_INT_ARRAY, {NULL} },
790                 { "StrobeMode",           CONFIGURE_VALUE_INT_ARRAY, {NULL} },
791                 { "StrobeEV",             CONFIGURE_VALUE_INT_RANGE, {NULL} },
792         };
793
794         /* [Effect] matching table */
795         static conf_info_table conf_ctrl_effect_table[] = {
796                 { "Brightness",           CONFIGURE_VALUE_INT_RANGE, {NULL} },
797                 { "BrightnessStepDenominator", CONFIGURE_VALUE_INT, {.value_int = 2} },
798                 { "Contrast",             CONFIGURE_VALUE_INT_RANGE, {NULL} },
799                 { "Saturation",           CONFIGURE_VALUE_INT_RANGE, {NULL} },
800                 { "Sharpness",            CONFIGURE_VALUE_INT_RANGE, {NULL} },
801                 { "Hue",                  CONFIGURE_VALUE_INT_RANGE, {NULL} },
802                 { "WhiteBalance",         CONFIGURE_VALUE_INT_ARRAY, {NULL} },
803                 { "ColorTone",            CONFIGURE_VALUE_INT_ARRAY, {NULL} },
804                 { "Flip",                 CONFIGURE_VALUE_INT_ARRAY, {NULL} },
805                 { "Rotation",             CONFIGURE_VALUE_INT_ARRAY, {NULL} },
806                 { "WDR",                  CONFIGURE_VALUE_INT_ARRAY, {NULL} },
807                 { "PartColorMode",        CONFIGURE_VALUE_INT_ARRAY, {NULL} },
808                 { "PartColor",            CONFIGURE_VALUE_INT_ARRAY, {NULL} },
809         };
810
811         /* [Photograph] matching table */
812         static conf_info_table conf_ctrl_photograph_table[] = {
813                 { "LensInit",             CONFIGURE_VALUE_INT_ARRAY, {NULL} },
814                 { "DigitalZoom",          CONFIGURE_VALUE_INT_RANGE, {NULL} },
815                 { "OpticalZoom",          CONFIGURE_VALUE_INT_RANGE, {NULL} },
816                 { "FocusMode",            CONFIGURE_VALUE_INT_ARRAY, {NULL} },
817                 { "AFType",               CONFIGURE_VALUE_INT_ARRAY, {NULL} },
818                 { "AEType",               CONFIGURE_VALUE_INT_ARRAY, {NULL} },
819                 { "ExposureValue",        CONFIGURE_VALUE_INT_RANGE, {NULL} },
820                 { "FNumber",              CONFIGURE_VALUE_INT_ARRAY, {NULL} },
821                 { "ShutterSpeed",         CONFIGURE_VALUE_INT_ARRAY, {NULL} },
822                 { "ISO",                  CONFIGURE_VALUE_INT_ARRAY, {NULL} },
823                 { "ProgramMode",          CONFIGURE_VALUE_INT_ARRAY, {NULL} },
824                 { "AntiHandshake",        CONFIGURE_VALUE_INT_ARRAY, {NULL} },
825                 { "VideoStabilization",   CONFIGURE_VALUE_INT_ARRAY, {NULL} },
826                 { "FaceZoomMode",         CONFIGURE_VALUE_INT_ARRAY, {NULL} },
827                 { "FaceZoomLevel",        CONFIGURE_VALUE_INT_RANGE, {NULL} },
828                 { "PanMecha",             CONFIGURE_VALUE_INT_RANGE, {NULL} },
829                 { "PanElec",              CONFIGURE_VALUE_INT_RANGE, {NULL} },
830                 { "TiltMecha",            CONFIGURE_VALUE_INT_RANGE, {NULL} },
831                 { "TiltElec",             CONFIGURE_VALUE_INT_RANGE, {NULL} },
832         };
833
834         /* [Capture] matching table */
835         static conf_info_table conf_ctrl_capture_table[] = {
836                 { "OutputMode",           CONFIGURE_VALUE_INT_ARRAY, {NULL} },
837                 { "JpegQuality",          CONFIGURE_VALUE_INT_RANGE, {NULL} },
838                 { "MultishotNumber",      CONFIGURE_VALUE_INT_RANGE, {NULL} },
839                 { "SensorEncodedCapture", CONFIGURE_VALUE_INT,       {.value_int = 1} },
840                 { "SupportHDR",           CONFIGURE_VALUE_INT_ARRAY, {NULL} },
841                 { "SupportZSL",           CONFIGURE_VALUE_INT,       {.value_int = FALSE} },
842                 { "FrameStabilityCount",  CONFIGURE_VALUE_INT,       {.value_int = 0} },
843         };
844
845         /* [Detect] matching table */
846         static conf_info_table conf_ctrl_detect_table[] = {
847                 { "DetectMode",           CONFIGURE_VALUE_INT_ARRAY, {NULL} },
848                 { "DetectNumber",         CONFIGURE_VALUE_INT_RANGE, {NULL} },
849                 { "DetectSelect",         CONFIGURE_VALUE_INT_RANGE, {NULL} },
850                 { "DetectSelectNumber",   CONFIGURE_VALUE_INT_RANGE, {NULL} },
851         };
852
853         _mmcam_dbg_log("Entered...");
854
855         if (type == CONFIGURE_TYPE_MAIN) {
856                 hcamcorder->conf_main_info_table[CONFIGURE_CATEGORY_MAIN_GENERAL]       = conf_main_general_table;
857                 hcamcorder->conf_main_info_table[CONFIGURE_CATEGORY_MAIN_VIDEO_INPUT]   = conf_main_video_input_table;
858                 hcamcorder->conf_main_info_table[CONFIGURE_CATEGORY_MAIN_AUDIO_INPUT]   = conf_main_audio_input_table;
859                 hcamcorder->conf_main_info_table[CONFIGURE_CATEGORY_MAIN_VIDEO_OUTPUT]  = conf_main_video_output_table;
860                 hcamcorder->conf_main_info_table[CONFIGURE_CATEGORY_MAIN_CAPTURE]       = conf_main_capture_table;
861                 hcamcorder->conf_main_info_table[CONFIGURE_CATEGORY_MAIN_RECORD]        = conf_main_record_table;
862                 hcamcorder->conf_main_info_table[CONFIGURE_CATEGORY_MAIN_VIDEO_ENCODER] = conf_main_video_encoder_table;
863                 hcamcorder->conf_main_info_table[CONFIGURE_CATEGORY_MAIN_AUDIO_ENCODER] = conf_main_audio_encoder_table;
864                 hcamcorder->conf_main_info_table[CONFIGURE_CATEGORY_MAIN_IMAGE_ENCODER] = conf_main_image_encoder_table;
865                 hcamcorder->conf_main_info_table[CONFIGURE_CATEGORY_MAIN_MUX]           = conf_main_mux_table;
866
867                 hcamcorder->conf_main_category_size[CONFIGURE_CATEGORY_MAIN_GENERAL]       = sizeof(conf_main_general_table) / info_table_size;
868                 hcamcorder->conf_main_category_size[CONFIGURE_CATEGORY_MAIN_VIDEO_INPUT]   = sizeof(conf_main_video_input_table) / info_table_size;
869                 hcamcorder->conf_main_category_size[CONFIGURE_CATEGORY_MAIN_AUDIO_INPUT]   = sizeof(conf_main_audio_input_table) / info_table_size;
870                 hcamcorder->conf_main_category_size[CONFIGURE_CATEGORY_MAIN_VIDEO_OUTPUT]  = sizeof(conf_main_video_output_table) / info_table_size;
871                 hcamcorder->conf_main_category_size[CONFIGURE_CATEGORY_MAIN_CAPTURE]       = sizeof(conf_main_capture_table) / info_table_size;
872                 hcamcorder->conf_main_category_size[CONFIGURE_CATEGORY_MAIN_RECORD]        = sizeof(conf_main_record_table) / info_table_size;
873                 hcamcorder->conf_main_category_size[CONFIGURE_CATEGORY_MAIN_VIDEO_ENCODER] = sizeof(conf_main_video_encoder_table) / info_table_size;
874                 hcamcorder->conf_main_category_size[CONFIGURE_CATEGORY_MAIN_AUDIO_ENCODER] = sizeof(conf_main_audio_encoder_table) / info_table_size;
875                 hcamcorder->conf_main_category_size[CONFIGURE_CATEGORY_MAIN_IMAGE_ENCODER] = sizeof(conf_main_image_encoder_table) / info_table_size;
876                 hcamcorder->conf_main_category_size[CONFIGURE_CATEGORY_MAIN_MUX]           = sizeof(conf_main_mux_table) / info_table_size;
877
878                 category_num = CONFIGURE_CATEGORY_MAIN_NUM;
879         } else {
880                 hcamcorder->conf_ctrl_info_table[CONFIGURE_CATEGORY_CTRL_CAMERA]     = conf_ctrl_camera_table;
881                 hcamcorder->conf_ctrl_info_table[CONFIGURE_CATEGORY_CTRL_STROBE]     = conf_ctrl_strobe_table;
882                 hcamcorder->conf_ctrl_info_table[CONFIGURE_CATEGORY_CTRL_EFFECT]     = conf_ctrl_effect_table;
883                 hcamcorder->conf_ctrl_info_table[CONFIGURE_CATEGORY_CTRL_PHOTOGRAPH] = conf_ctrl_photograph_table;
884                 hcamcorder->conf_ctrl_info_table[CONFIGURE_CATEGORY_CTRL_CAPTURE]    = conf_ctrl_capture_table;
885                 hcamcorder->conf_ctrl_info_table[CONFIGURE_CATEGORY_CTRL_DETECT]     = conf_ctrl_detect_table;
886
887                 hcamcorder->conf_ctrl_category_size[CONFIGURE_CATEGORY_CTRL_CAMERA]     = sizeof(conf_ctrl_camera_table) / info_table_size;
888                 hcamcorder->conf_ctrl_category_size[CONFIGURE_CATEGORY_CTRL_STROBE]     = sizeof(conf_ctrl_strobe_table) / info_table_size;
889                 hcamcorder->conf_ctrl_category_size[CONFIGURE_CATEGORY_CTRL_EFFECT]     = sizeof(conf_ctrl_effect_table) / info_table_size;
890                 hcamcorder->conf_ctrl_category_size[CONFIGURE_CATEGORY_CTRL_PHOTOGRAPH] = sizeof(conf_ctrl_photograph_table) / info_table_size;
891                 hcamcorder->conf_ctrl_category_size[CONFIGURE_CATEGORY_CTRL_CAPTURE]    = sizeof(conf_ctrl_capture_table) / info_table_size;
892                 hcamcorder->conf_ctrl_category_size[CONFIGURE_CATEGORY_CTRL_DETECT]     = sizeof(conf_ctrl_detect_table) / info_table_size;
893
894                 category_num = CONFIGURE_CATEGORY_CTRL_NUM;
895         }
896
897         configure_info->info = (conf_detail **)g_malloc0(sizeof(conf_detail *) * category_num);
898         if (configure_info->info == NULL) {
899                 _mmcam_dbg_err("category info alloc failed : type %d", type);
900                 return MM_ERROR_CAMCORDER_LOW_MEMORY;
901         }
902
903         _mmcam_dbg_log("Done.");
904
905         return MM_ERROR_NONE;
906 }
907
908
909 int _mmcamcorder_conf_get_info(MMHandleType handle, int type, const char *ConfFile, camera_conf **configure_info)
910 {
911         int ret = MM_ERROR_NONE;
912         FILE *fp = NULL;
913         char conf_path[60] = {'\0',};
914
915         _mmcam_dbg_log("Opening...[%s]", ConfFile);
916
917         mmf_return_val_if_fail(ConfFile, FALSE);
918
919         snprintf(conf_path, sizeof(conf_path), "%s/multimedia/%s", SYSCONFDIR, ConfFile);
920         _mmcam_dbg_log("Try open Configure File[%s]", conf_path);
921
922         fp = fopen(conf_path, "r");
923         if (!fp) {
924                 _mmcam_dbg_warn("File open failed.[%s] retry...", conf_path);
925
926                 snprintf(conf_path, sizeof(conf_path), "%s/multimedia/%s", TZ_SYS_ETC, ConfFile);
927                 _mmcam_dbg_log("Try open Configure File[%s]", conf_path);
928                 fp = fopen(conf_path, "r");
929                 if (!fp) {
930                         _mmcam_dbg_warn("open failed.[%s] errno [%d]", conf_path, errno);
931                         ret = MM_ERROR_CAMCORDER_NOT_SUPPORTED;
932                 }
933         }
934
935         if (fp) {
936                 ret = _mmcamcorder_conf_parse_info(handle, type, fp, configure_info);
937                 fclose(fp);
938         }
939
940         _mmcam_dbg_log("Leave [0x%x]", ret);
941
942         return ret;
943 }
944
945
946 int _mmcamcorder_conf_parse_info(MMHandleType handle, int type, FILE *fp, camera_conf **configure_info)
947 {
948         const unsigned int BUFFER_NUM_DETAILS = 256;
949         const unsigned int BUFFER_NUM_TOKEN = 20;
950         size_t BUFFER_LENGTH_STRING = 256;
951         const char* delimiters = " |=,\t\n";
952
953         int i = 0;
954         int ret = MM_ERROR_NONE;
955         int category = 0;
956         int count_main_category = 0;
957         int count_details = 0;
958         int length_read = 0;
959         int count_token = 0;
960         int read_main = 0;
961
962         char *buffer_string = NULL;
963         char *buffer_details[BUFFER_NUM_DETAILS];
964         char *buffer_token[BUFFER_NUM_TOKEN];
965         char *token = NULL;
966         char *category_name = NULL;
967         char *detail_string = NULL;
968         char *user_ptr = NULL;
969
970         camera_conf *new_conf = NULL;
971
972         _mmcam_dbg_log("");
973
974         mmf_return_val_if_fail(handle && fp && configure_info, MM_ERROR_INVALID_ARGUMENT);
975
976         *configure_info = NULL;
977
978         new_conf = (camera_conf *)g_malloc0(sizeof(camera_conf));
979         if (new_conf == NULL) {
980                 _mmcam_dbg_err("new_conf alloc failed : %zu", sizeof(camera_conf));
981                 return MM_ERROR_CAMCORDER_LOW_MEMORY;
982         }
983
984         buffer_string = (char*)g_malloc0(sizeof(char) * BUFFER_LENGTH_STRING);
985         if (buffer_string == NULL) {
986                 _mmcam_dbg_err("buffer_string alloc failed : %zu", sizeof(char) * BUFFER_LENGTH_STRING);
987                 g_free(new_conf);
988                 return MM_ERROR_CAMCORDER_LOW_MEMORY;
989         }
990
991         new_conf->type  = type;
992
993         ret = _mmcamcorder_conf_init(handle, type, new_conf);
994         if (ret != MM_ERROR_NONE) {
995                 _mmcam_dbg_err("conf init failed 0x%x", ret);
996                 g_free(new_conf);
997                 g_free(buffer_string);
998                 return ret;
999         }
1000
1001         *configure_info = new_conf;
1002
1003         read_main = 0;
1004         count_main_category = 0;
1005
1006         while (!feof(fp)) {
1007                 if (read_main == 0) {
1008                         length_read = getline(&buffer_string, &BUFFER_LENGTH_STRING, fp);
1009                         /*_mmcam_dbg_log( "Read Line : [%s]", buffer_string );*/
1010
1011                         count_token = 0;
1012                         token = strtok_r(buffer_string, delimiters, &user_ptr);
1013
1014                         if ((token) && (token[0] == ';') && (length_read > -1)) {
1015                                 /*_mmcam_dbg_log( "Comment - Nothing to do" );*/
1016                                 continue;
1017                         }
1018
1019                         while (token) {
1020                                 /*_mmcam_dbg_log("token : [%s]", token);*/
1021                                 buffer_token[count_token] = token;
1022                                 count_token++;
1023                                 token = strtok_r(NULL, delimiters, &user_ptr);
1024                         }
1025
1026                         if (count_token == 0)
1027                                 continue;
1028                 }
1029
1030                 read_main = 0;
1031
1032                 if (*buffer_token[0] == ';') {
1033                         /* Comment */
1034                         /*_mmcam_dbg_log( "Comment - Nothing to do" );*/
1035                 } else if (*buffer_token[0] == '[') {
1036                         /* Main Category */
1037                         category_name = get_new_string(buffer_token[0]);
1038                         if (category_name == NULL) {
1039                                 _mmcam_dbg_err("strdup failed for [%s]", buffer_token[0]);
1040                                 continue;
1041                         }
1042
1043                         count_main_category++;
1044                         count_details = 0;
1045
1046                         while (!feof(fp)) {
1047                                 length_read = getline(&buffer_string, &BUFFER_LENGTH_STRING, fp);
1048                                 /*_mmcam_dbg_log("Read Detail Line : [%s], read length : [%d]", buffer_string, length_read);*/
1049
1050                                 detail_string = get_new_string(buffer_string);
1051
1052                                 token = strtok_r(buffer_string, delimiters, &user_ptr);
1053
1054                                 if (token && token[0] != ';' && length_read > -1) {
1055                                         /*_mmcam_dbg_log("token : [%s]", token);*/
1056                                         if (token[0] == '[') {
1057                                                 read_main = 1;
1058                                                 buffer_token[0] = token;
1059                                                 SAFE_G_FREE(detail_string);
1060                                                 break;
1061                                         }
1062
1063                                         buffer_details[count_details++] = detail_string;
1064                                 } else {
1065                                         SAFE_G_FREE(detail_string);
1066                                 }
1067                         }
1068
1069                         /*_mmcam_dbg_log("type : %d, category_name : %s, count : [%d]", type, category_name, count_details);*/
1070
1071                         if (count_details == 0) {
1072                                 _mmcam_dbg_warn("category %s has no detail value... skip this category...", category_name);
1073                                 SAFE_G_FREE(category_name);
1074                                 continue;
1075                         }
1076
1077                         category = -1;
1078
1079                         /* Details */
1080                         if (type == CONFIGURE_TYPE_MAIN) {
1081                                 if (!strcmp("[General]", category_name))
1082                                         category = CONFIGURE_CATEGORY_MAIN_GENERAL;
1083                                 else if (!strcmp("[VideoInput]", category_name))
1084                                         category = CONFIGURE_CATEGORY_MAIN_VIDEO_INPUT;
1085                                 else if (!strcmp("[AudioInput]", category_name))
1086                                         category = CONFIGURE_CATEGORY_MAIN_AUDIO_INPUT;
1087                                 else if (!strcmp("[VideoOutput]", category_name))
1088                                         category = CONFIGURE_CATEGORY_MAIN_VIDEO_OUTPUT;
1089                                 else if (!strcmp("[Capture]", category_name))
1090                                         category = CONFIGURE_CATEGORY_MAIN_CAPTURE;
1091                                 else if (!strcmp("[Record]", category_name))
1092                                         category = CONFIGURE_CATEGORY_MAIN_RECORD;
1093                                 else if (!strcmp("[VideoEncoder]", category_name))
1094                                         category = CONFIGURE_CATEGORY_MAIN_VIDEO_ENCODER;
1095                                 else if (!strcmp("[AudioEncoder]", category_name))
1096                                         category = CONFIGURE_CATEGORY_MAIN_AUDIO_ENCODER;
1097                                 else if (!strcmp("[ImageEncoder]", category_name))
1098                                         category = CONFIGURE_CATEGORY_MAIN_IMAGE_ENCODER;
1099                                 else if (!strcmp("[Mux]", category_name))
1100                                         category = CONFIGURE_CATEGORY_MAIN_MUX;
1101                         } else {
1102                                 if (!strcmp("[Camera]", category_name))
1103                                         category = CONFIGURE_CATEGORY_CTRL_CAMERA;
1104                                 else if (!strcmp("[Strobe]", category_name))
1105                                         category = CONFIGURE_CATEGORY_CTRL_STROBE;
1106                                 else if (!strcmp("[Effect]", category_name))
1107                                         category = CONFIGURE_CATEGORY_CTRL_EFFECT;
1108                                 else if (!strcmp("[Photograph]", category_name))
1109                                         category = CONFIGURE_CATEGORY_CTRL_PHOTOGRAPH;
1110                                 else if (!strcmp("[Capture]", category_name))
1111                                         category = CONFIGURE_CATEGORY_CTRL_CAPTURE;
1112                                 else if (!strcmp("[Detect]", category_name))
1113                                         category = CONFIGURE_CATEGORY_CTRL_DETECT;
1114                         }
1115
1116                         if (category != -1) {
1117                                 _mmcamcorder_conf_add_info(handle, type, &(new_conf->info[category]),
1118                                                                                         buffer_details, category, count_details);
1119                         } else {
1120                                 _mmcam_dbg_warn("No matched category[%s],type[%d]... check it.", category_name, type);
1121                         }
1122
1123                         /* Free memory */
1124                         for (i = 0 ; i < count_details ; i++)
1125                                 SAFE_G_FREE(buffer_details[i]);
1126                 }
1127
1128                 SAFE_G_FREE(category_name);
1129         }
1130
1131         /* (*configure_info) = new_conf; */
1132
1133         SAFE_G_FREE(buffer_string);
1134
1135         /*_mmcam_dbg_log("Done.");*/
1136
1137         return MM_ERROR_NONE;
1138 }
1139
1140
1141 void _mmcamcorder_conf_release_info(MMHandleType handle, camera_conf **configure_info)
1142 {
1143         int i = 0;
1144         int j = 0;
1145         int k = 0;
1146         int type = CONFIGURE_VALUE_INT;
1147         int count = 0;
1148         int category_num = CONFIGURE_CATEGORY_MAIN_NUM;
1149         camera_conf *temp_conf = (*configure_info);
1150
1151         type_int2 *temp_int = NULL;
1152         type_int_range *temp_int_range = NULL;
1153         type_int_array *temp_int_array = NULL;
1154         type_int_pair_array *temp_int_pair_array = NULL;
1155         type_string2 *temp_string = NULL;
1156         type_string_array *temp_string_array = NULL;
1157         type_element2 *temp_element = NULL;
1158
1159         _mmcam_dbg_log("Entered...");
1160
1161         mmf_return_if_fail(temp_conf);
1162
1163         if ((*configure_info)->type == CONFIGURE_TYPE_MAIN)
1164                 category_num = CONFIGURE_CATEGORY_MAIN_NUM;
1165         else
1166                 category_num = CONFIGURE_CATEGORY_CTRL_NUM;
1167
1168         for (i = 0 ; i < category_num ; i++) {
1169                 if (temp_conf->info[i]) {
1170                         for (j = 0 ; j < temp_conf->info[i]->count ; j++) {
1171                                 if (temp_conf->info[i]->detail_info[j] == NULL)
1172                                         continue;
1173
1174                                 if (_mmcamcorder_conf_get_value_type(handle, temp_conf->type, i, ((type_element*)(temp_conf->info[i]->detail_info[j]))->name, &type)) {
1175                                         switch (type) {
1176                                         case CONFIGURE_VALUE_INT:
1177                                                 temp_int = (type_int2*)(temp_conf->info[i]->detail_info[j]);
1178                                                 SAFE_G_FREE(temp_int->name);
1179                                                 break;
1180                                         case CONFIGURE_VALUE_INT_RANGE:
1181                                                 temp_int_range = (type_int_range*)(temp_conf->info[i]->detail_info[j]);
1182                                                 SAFE_G_FREE(temp_int_range->name);
1183                                                 break;
1184                                         case CONFIGURE_VALUE_INT_ARRAY:
1185                                                 temp_int_array = (type_int_array*)(temp_conf->info[i]->detail_info[j]);
1186                                                 SAFE_G_FREE(temp_int_array->name);
1187                                                 SAFE_G_FREE(temp_int_array->value);
1188                                                 break;
1189                                         case CONFIGURE_VALUE_INT_PAIR_ARRAY:
1190                                                 temp_int_pair_array = (type_int_pair_array*)(temp_conf->info[i]->detail_info[j]);
1191                                                 SAFE_G_FREE(temp_int_pair_array->name);
1192                                                 SAFE_G_FREE(temp_int_pair_array->value[0]);
1193                                                 SAFE_G_FREE(temp_int_pair_array->value[1]);
1194                                                 break;
1195                                         case CONFIGURE_VALUE_STRING:
1196                                                 temp_string = (type_string2*)(temp_conf->info[i]->detail_info[j]);
1197                                                 SAFE_G_FREE(temp_string->name);
1198                                                 SAFE_G_FREE(temp_string->value);
1199                                                 break;
1200                                         case CONFIGURE_VALUE_STRING_ARRAY:
1201                                                 temp_string_array = (type_string_array*)(temp_conf->info[i]->detail_info[j]);
1202                                                 SAFE_G_FREE(temp_string_array->name);
1203                                                 if (temp_string_array->value) {
1204                                                         count = temp_string_array->count;
1205
1206                                                         for (k = 0 ; k < count ; k++)
1207                                                                 SAFE_G_FREE(temp_string_array->value[k]);
1208
1209                                                         SAFE_G_FREE(temp_string_array->value);
1210                                                 }
1211                                                 SAFE_G_FREE(temp_string_array->default_value);
1212                                                 break;
1213                                         case CONFIGURE_VALUE_ELEMENT:
1214                                                 temp_element = (type_element2*)(temp_conf->info[i]->detail_info[j]);
1215                                                 SAFE_G_FREE(temp_element->name);
1216                                                 SAFE_G_FREE(temp_element->element_name);
1217
1218                                                 if (temp_element->value_int) {
1219                                                         count = temp_element->count_int;
1220                                                         for (k = 0 ; k < count ; k++) {
1221                                                                 SAFE_G_FREE(temp_element->value_int[k]->name);
1222                                                                 SAFE_G_FREE(temp_element->value_int[k]);
1223                                                         }
1224                                                         SAFE_G_FREE(temp_element->value_int);
1225                                                 }
1226
1227                                                 if (temp_element->value_string) {
1228                                                         count = temp_element->count_string;
1229                                                         for (k = 0 ; k < count ; k++) {
1230                                                                 SAFE_G_FREE(temp_element->value_string[k]->name);
1231                                                                 SAFE_G_FREE(temp_element->value_string[k]->value);
1232                                                                 SAFE_G_FREE(temp_element->value_string[k]);
1233                                                         }
1234                                                         SAFE_G_FREE(temp_element->value_string);
1235                                                 }
1236                                                 break;
1237                                         default:
1238                                                 _mmcam_dbg_warn("unknown type %d", type);
1239                                                 break;
1240                                         }
1241                                 }
1242
1243                                 SAFE_G_FREE(temp_conf->info[i]->detail_info[j]);
1244                         }
1245
1246                         SAFE_G_FREE(temp_conf->info[i]->detail_info);
1247
1248                         SAFE_G_FREE(temp_conf->info[i]);
1249                         temp_conf->info[i] = NULL;
1250                 }
1251         }
1252
1253         SAFE_G_FREE((*configure_info)->info);
1254         SAFE_G_FREE((*configure_info));
1255
1256         _mmcam_dbg_log("Done.");
1257 }
1258
1259 int _mmcamcorder_conf_get_value_type(MMHandleType handle, int type, int category, const char* name, int* value_type)
1260 {
1261         int i = 0;
1262         int count_value = 0;
1263
1264         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
1265
1266         if (hcamcorder == NULL) {
1267                 _mmcam_dbg_err("handle is NULL");
1268                 return FALSE;
1269         }
1270
1271         /*_mmcam_dbg_log("Entered...");*/
1272
1273         mmf_return_val_if_fail(name, FALSE);
1274
1275         if (!_mmcamcorder_conf_get_category_size(handle, type, category, &count_value)) {
1276                 _mmcam_dbg_warn("No matched category... check it... categoty[%d]", category);
1277                 return FALSE;
1278         }
1279
1280         /*_mmcam_dbg_log("Number of value : [%d]", count_value);*/
1281
1282         if (type == CONFIGURE_TYPE_MAIN) {
1283                 for (i = 0 ; i < count_value ; i++) {
1284                         if (!strcmp(hcamcorder->conf_main_info_table[category][i].name, name)) {
1285                                 *value_type = hcamcorder->conf_main_info_table[category][i].value_type;
1286                                 /*_mmcam_dbg_log("Category[%d],Name[%s],Type[%d]", category, name, *value_type);*/
1287                                 return TRUE;
1288                         }
1289                 }
1290         } else {
1291                 for (i = 0 ; i < count_value ; i++) {
1292                         if (!strcmp(hcamcorder->conf_ctrl_info_table[category][i].name, name)) {
1293                                 *value_type = hcamcorder->conf_ctrl_info_table[category][i].value_type;
1294                                 /*_mmcam_dbg_log("Category[%d],Name[%s],Type[%d]", category, name, *value_type);*/
1295                                 return TRUE;
1296                         }
1297                 }
1298         }
1299
1300         return FALSE;
1301 }
1302
1303
1304 int _mmcamcorder_conf_add_info(MMHandleType handle, int type, conf_detail **info, char **buffer_details, int category, int count_details)
1305 {
1306         const int BUFFER_NUM_TOKEN = 256;
1307
1308         int i = 0;
1309         int j = 0;
1310         int count_token;
1311         int value_type;
1312         char *token = NULL;
1313         char *buffer_token[BUFFER_NUM_TOKEN];
1314         char *user_ptr = NULL;
1315
1316         const char *delimiters     = " |=,\t\n";
1317         const char *delimiters_sub = " |\t\n";
1318         const char *delimiters_3rd = "|\n";
1319
1320         mmf_return_val_if_fail(info && buffer_details, FALSE);
1321
1322         (*info) = (conf_detail*)g_malloc0(sizeof(conf_detail));
1323         if (*info == NULL) {
1324                 _mmcam_dbg_err("info allo failed");
1325                 return FALSE;
1326         }
1327         (*info)->detail_info = (void**)g_malloc0(sizeof(void*) * count_details);
1328         (*info)->count = count_details;
1329
1330         if ((*info)->detail_info == NULL) {
1331                 _mmcam_dbg_err("detail_info alloc failed");
1332                 g_free(*info);
1333                 *info = NULL;
1334                 return FALSE;
1335         }
1336
1337         for (i = 0 ; i < count_details ; i++) {
1338                 /*_mmcam_dbg_log("Read line\"%s\"", buffer_details[i]);*/
1339                 count_token = 0;
1340                 token = strtok_r(buffer_details[i], delimiters, &user_ptr);
1341
1342                 if (token) {
1343                         buffer_token[count_token] = token;
1344                         count_token++;
1345                 } else {
1346                         (*info)->detail_info[i] = NULL;
1347                         _mmcam_dbg_warn("No token... check it.[%s]", buffer_details[i]);
1348                         continue;
1349                 }
1350
1351                 if (!_mmcamcorder_conf_get_value_type(handle, type, category, buffer_token[0], &value_type)) {
1352                         (*info)->detail_info[i] = NULL;
1353                         _mmcam_dbg_warn("Failed to get value type... check it. Category[%d],Name[%s]", category, buffer_token[0]);
1354                         continue;
1355                 }
1356
1357                 if (value_type != CONFIGURE_VALUE_STRING && value_type != CONFIGURE_VALUE_STRING_ARRAY) {
1358                         token = strtok_r(NULL, delimiters, &user_ptr);
1359                         while (token) {
1360                                 buffer_token[count_token] = token;
1361                                 /*_mmcam_dbg_log("token : [%s]", buffer_token[count_token]);*/
1362                                 count_token++;
1363                                 token = strtok_r(NULL, delimiters, &user_ptr);
1364                         }
1365
1366                         if (count_token < 2) {
1367                                 (*info)->detail_info[i] = NULL;
1368                                 _mmcam_dbg_warn("Number of token is too small... check it.[%s]", buffer_details[i]);
1369                                 continue;
1370                         }
1371                 } else { /* CONFIGURE_VALUE_STRING or CONFIGURE_VALUE_STRING_ARRAY */
1372                         /* skip "=" */
1373                         strtok_r(NULL, delimiters_sub, &user_ptr);
1374
1375                         if (value_type == CONFIGURE_VALUE_STRING_ARRAY) {
1376                                 token = strtok_r(NULL, delimiters_sub, &user_ptr);
1377                                 while (token) {
1378                                         buffer_token[count_token] = token;
1379                                         /*_mmcam_dbg_log("token : [%s]", buffer_token[count_token]);*/
1380                                         count_token++;
1381                                         token = strtok_r(NULL, delimiters_sub, &user_ptr);
1382                                 }
1383                         } else { /* CONFIGURE_VALUE_STRING */
1384                                 token = strtok_r(NULL, delimiters_3rd, &user_ptr);
1385                                 if (token) {
1386                                         g_strchug(token);
1387                                         buffer_token[count_token] = token;
1388                                         /*_mmcam_dbg_log("token : [%s]", buffer_token[count_token]);*/
1389                                         count_token++;
1390                                 }
1391                         }
1392
1393                         if (count_token < 2) {
1394                                 (*info)->detail_info[i] = NULL;
1395                                 _mmcam_dbg_warn("No string value... check it.[%s]", buffer_details[i]);
1396                                 continue;
1397                         }
1398                 }
1399
1400                 switch (value_type) {
1401                 case CONFIGURE_VALUE_INT:
1402                 {
1403                         type_int2* new_int;
1404
1405                         new_int = (type_int2*)g_malloc0(sizeof(type_int2));
1406                         if (new_int == NULL) {
1407                                 _mmcam_dbg_err("allocation failed");
1408                                 break;
1409                         }
1410                         new_int->name  = get_new_string(buffer_token[0]);
1411                         new_int->value = atoi(buffer_token[1]);
1412                         (*info)->detail_info[i] = (void*)new_int;
1413                         /*_mmcam_dbg_log("INT - name[%s],value[%d]", new_int->name, new_int->value);*/
1414                         break;
1415                 }
1416                 case CONFIGURE_VALUE_INT_RANGE:
1417                 {
1418                         type_int_range* new_int_range;
1419
1420                         new_int_range = (type_int_range*)g_malloc0(sizeof(type_int_range));
1421                         if (new_int_range == NULL) {
1422                                 _mmcam_dbg_err("allocation failed");
1423                                 break;
1424                         }
1425                         new_int_range->name          = get_new_string(buffer_token[0]);
1426                         new_int_range->min           = atoi(buffer_token[1]);
1427                         new_int_range->max           = atoi(buffer_token[2]);
1428                         new_int_range->default_value = atoi(buffer_token[3]);
1429                         (*info)->detail_info[i]      = (void*)new_int_range;
1430                         /*
1431                         _mmcam_dbg_log("INT RANGE - name[%s],min[%d],max[%d],default[%d]",
1432                                 new_int_range->name,
1433                                 new_int_range->min,
1434                                 new_int_range->max,
1435                                 new_int_range->default_value);
1436                         */
1437                         break;
1438                 }
1439                 case CONFIGURE_VALUE_INT_ARRAY:
1440                 {
1441                         int count_value = count_token - 2;
1442                         type_int_array* new_int_array;
1443
1444                         new_int_array = (type_int_array*)g_malloc0(sizeof(type_int_array));
1445                         if (new_int_array == NULL) {
1446                                 _mmcam_dbg_err("allocation failed");
1447                                 break;
1448                         }
1449                         new_int_array->name = get_new_string(buffer_token[0]);
1450                         new_int_array->value = (int*)g_malloc0(sizeof(int)*count_value);
1451                         if (new_int_array->value == NULL) {
1452                                 SAFE_G_FREE(new_int_array->name);
1453                                 SAFE_G_FREE(new_int_array);
1454                                 _mmcam_dbg_err("allocation failed");
1455                                 break;
1456                         }
1457                         new_int_array->count = count_value;
1458
1459                         /*_mmcam_dbg_log("INT ARRAY - name[%s]", new_int_array->name);*/
1460                         for (j = 0 ; j < count_value ; j++) {
1461                                 new_int_array->value[j] = atoi(buffer_token[j+1]);
1462                                 /*_mmcam_dbg_log("   index[%d] - value[%d]", j, new_int_array->value[j]);*/
1463                         }
1464
1465                         new_int_array->default_value = atoi(buffer_token[count_token-1]);
1466                         /*_mmcam_dbg_log("   default value[%d]", new_int_array->default_value);*/
1467
1468                         (*info)->detail_info[i] = (void*)new_int_array;
1469                         break;
1470                 }
1471                 case CONFIGURE_VALUE_INT_PAIR_ARRAY:
1472                 {
1473                         int count_value = (count_token - 3) >> 1;
1474                         type_int_pair_array* new_int_pair_array;
1475
1476                         new_int_pair_array = (type_int_pair_array*)g_malloc0(sizeof(type_int_pair_array));
1477                         if (new_int_pair_array == NULL) {
1478                                 _mmcam_dbg_err("allocation failed");
1479                                 break;
1480                         }
1481                         new_int_pair_array->name = get_new_string(buffer_token[0]);
1482                         new_int_pair_array->value[0] = (int*)g_malloc0(sizeof(int)*(count_value));
1483                         if (new_int_pair_array->value[0] == NULL) {
1484                                 SAFE_G_FREE(new_int_pair_array->name);
1485                                 SAFE_G_FREE(new_int_pair_array);
1486                                 _mmcam_dbg_err("allocation failed");
1487                                 break;
1488                         }
1489                         new_int_pair_array->value[1] = (int*)g_malloc0(sizeof(int)*(count_value));
1490                         if (new_int_pair_array->value[1] == NULL) {
1491                                 SAFE_G_FREE(new_int_pair_array->value[0]);
1492                                 SAFE_G_FREE(new_int_pair_array->name);
1493                                 SAFE_G_FREE(new_int_pair_array);
1494                                 _mmcam_dbg_err("allocation failed");
1495                                 break;
1496                         }
1497                         new_int_pair_array->count    = count_value;
1498
1499                         /*_mmcam_dbg_log("INT PAIR ARRAY - name[%s],count[%d]", new_int_pair_array->name, count_value);*/
1500                         for (j = 0 ; j < count_value ; j++) {
1501                                 new_int_pair_array->value[0][j] = atoi(buffer_token[(j<<1)+1]);
1502                                 new_int_pair_array->value[1][j] = atoi(buffer_token[(j<<1)+2]);
1503                                 /*
1504                                 _mmcam_dbg_log("   index[%d] - value[%d,%d]", j,
1505                                         new_int_pair_array->value[0][j],
1506                                         new_int_pair_array->value[1][j]);
1507                                 */
1508                         }
1509
1510                         new_int_pair_array->default_value[0] = atoi(buffer_token[count_token-2]);
1511                         new_int_pair_array->default_value[1] = atoi(buffer_token[count_token-1]);
1512                         /*
1513                         _mmcam_dbg_log("   default value[%d,%d]",
1514                                 new_int_pair_array->default_value[0],
1515                                 new_int_pair_array->default_value[1]);
1516                         */
1517                         (*info)->detail_info[i] = (void*)new_int_pair_array;
1518                         break;
1519                 }
1520                 case CONFIGURE_VALUE_STRING:
1521                 {
1522                         type_string2* new_string;
1523
1524                         new_string = (type_string2*)g_malloc0(sizeof(type_string2));
1525                         if (new_string == NULL) {
1526                                 _mmcam_dbg_err("allocation failed");
1527                                 break;
1528                         }
1529                         new_string->name  = get_new_string(buffer_token[0]);
1530                         new_string->value = get_new_string(buffer_token[1]);
1531                         (*info)->detail_info[i] = (void*)new_string;
1532
1533                         /*_mmcam_dbg_log("STRING - name[%s],value[%s]", new_string->name, new_string->value);*/
1534                         break;
1535                 }
1536                 case CONFIGURE_VALUE_STRING_ARRAY:
1537                 {
1538                         int count_value = count_token - 2;
1539                         type_string_array* new_string_array;
1540
1541                         new_string_array = (type_string_array*)g_malloc0(sizeof(type_string_array));
1542                         if (new_string_array == NULL)
1543                                 break;
1544
1545                         new_string_array->name  = get_new_string(buffer_token[0]);
1546                         new_string_array->count = count_value;
1547                         new_string_array->value = (char**)g_malloc0(sizeof(char*)*count_value);
1548                         if (new_string_array->value == NULL) {
1549                                 SAFE_G_FREE(new_string_array->name);
1550                                 SAFE_G_FREE(new_string_array);
1551                                 _mmcam_dbg_err("allocation failed");
1552                                 break;
1553                         }
1554                         /*_mmcam_dbg_log("STRING ARRAY - name[%s]", new_string_array->name);*/
1555                         for (j = 0 ; j < count_value ; j++) {
1556                                 new_string_array->value[j] = get_new_string(buffer_token[j+1]);
1557                                 /*_mmcam_dbg_log("   index[%d] - value[%s]", j, new_string_array->value[j]);*/
1558                         }
1559
1560                         new_string_array->default_value = get_new_string(buffer_token[count_token-1]);
1561                         /*_mmcam_dbg_log("   default value[%s]", new_string_array->default_value);*/
1562                         (*info)->detail_info[i] = (void*)new_string_array;
1563                         break;
1564                 }
1565                 case CONFIGURE_VALUE_ELEMENT:
1566                 {
1567                         type_element2* new_element;
1568
1569                         new_element = (type_element2*)g_malloc0(sizeof(type_element2));
1570                         if (new_element == NULL) {
1571                                 _mmcam_dbg_err("allocation failed");
1572                                 break;
1573                         }
1574                         new_element->name         = get_new_string(buffer_token[0]);
1575                         new_element->element_name = get_new_string(buffer_token[1]);
1576                         new_element->count_int    = atoi(buffer_token[2]);
1577                         new_element->value_int    = NULL;
1578                         new_element->count_string = atoi(buffer_token[3]);
1579                         new_element->value_string = NULL;
1580                         /*
1581                         _mmcam_dbg_log("Element - name[%s],element_name[%s],count_int[%d],count_string[%d]",
1582                                 new_element->name, new_element->element_name, new_element->count_int, new_element->count_string);
1583                         */
1584
1585                         /* add int values */
1586                         if (new_element->count_int > 0 && new_element->count_int <= 30) {
1587                                 new_element->value_int = (type_int2**)g_malloc0(sizeof(type_int2*)*(new_element->count_int));
1588                                 if (new_element->value_int) {
1589                                         for (j = 0 ; j < new_element->count_int ; j++) {
1590                                                 new_element->value_int[j] = (type_int2*)g_malloc0(sizeof(type_int2));
1591                                                 if (new_element->value_int[j]) {
1592                                                         new_element->value_int[j]->name  = get_new_string(buffer_token[4+(j<<1)]);
1593                                                         new_element->value_int[j]->value = atoi(buffer_token[5+(j<<1)]);
1594                                                 } else {
1595                                                         _mmcam_dbg_err("allocation failed");
1596                                                 }
1597                                                 /*
1598                                                 _mmcam_dbg_log("   Element INT[%d] - name[%s],value[%d]",
1599                                                         j, new_element->value_int[j]->name, new_element->value_int[j]->value);
1600                                                 */
1601                                         }
1602                                 } else {
1603                                         _mmcam_dbg_err("allocation failed");
1604                                 }
1605                         } else {
1606                                 /*_mmcam_dbg_err("invalid count - %d", new_element->count_int);*/
1607                                 new_element->value_int = NULL;
1608                         }
1609
1610                         /* add string values */
1611                         if (new_element->count_string > 0 && new_element->count_string <= 30 &&
1612                                 new_element->count_int >= 0 && new_element->count_int <= 30) {
1613                                 new_element->value_string = (type_string2**)g_malloc0(sizeof(type_string2*)*(new_element->count_string));
1614                                 if (new_element->value_string) {
1615                                         for ( ; j < new_element->count_string + new_element->count_int ; j++) {
1616                                                 new_element->value_string[j-new_element->count_int]     = (type_string2*)g_malloc0(sizeof(type_string2));
1617                                                 if (new_element->value_string[j-new_element->count_int]) {
1618                                                         new_element->value_string[j-new_element->count_int]->name       = get_new_string(buffer_token[4+(j<<1)]);
1619                                                         new_element->value_string[j-new_element->count_int]->value      = get_new_string(buffer_token[5+(j<<1)]);
1620                                                         /*
1621                                                         _mmcam_dbg_log("   Element STRING[%d] - name[%s],value[%s]",
1622                                                                 j-new_element->count_int, new_element->value_string[j-new_element->count_int]->name, new_element->value_string[j-new_element->count_int]->value);
1623                                                         */
1624                                                 } else {
1625                                                         _mmcam_dbg_err("allocation failed");
1626                                                 }
1627                                         }
1628                                 } else {
1629                                         _mmcam_dbg_err("malloc failed : %zu", sizeof(type_string2*)*(new_element->count_string));
1630                                 }
1631                         } else {
1632                                 /*_mmcam_dbg_err("invalid count - %d", new_element->count_string);*/
1633                                 new_element->value_string = NULL;
1634                         }
1635
1636                         (*info)->detail_info[i] = (void*)new_element;
1637                         break;
1638                 }
1639                 default:
1640                         break;
1641                 }
1642         }
1643
1644         return TRUE;
1645 }
1646
1647
1648 int _mmcamcorder_conf_get_value_int(MMHandleType handle, camera_conf* configure_info, int category, const char* name, int* value)
1649 {
1650         int i, count;
1651         conf_detail* info;
1652
1653         /* _mmcam_dbg_log("Entered... category[%d],name[%s]", category, name); */
1654
1655         mmf_return_val_if_fail(configure_info, FALSE);
1656         mmf_return_val_if_fail(name, FALSE);
1657
1658         if (configure_info->info[category]) {
1659                 count = configure_info->info[category]->count;
1660                 info = configure_info->info[category];
1661
1662                 for (i = 0 ; i < count ; i++) {
1663                         if (info->detail_info[i] == NULL)
1664                                 continue;
1665
1666                         if (!strcmp(((type_int*)(info->detail_info[i]))->name , name)) {
1667                                 *value = ((type_int*)(info->detail_info[i]))->value;
1668                                 /* _mmcam_dbg_log("Get[%s] int[%d]", name, *value); */
1669                                 return TRUE;
1670                         }
1671                 }
1672         }
1673
1674         if (_mmcamcorder_conf_get_default_value_int(handle, configure_info->type, category, name, value)) {
1675                  /*_mmcam_dbg_log("Get[%s] int[%d]", name, *value);*/
1676                 return TRUE;
1677         }
1678
1679         _mmcam_dbg_err("Faild to get int... check it...Category[%d],Name[%s]", category, name);
1680
1681         return FALSE;
1682 }
1683
1684 int
1685 _mmcamcorder_conf_get_value_int_range(camera_conf* configure_info, int category, const char* name, type_int_range** value)
1686 {
1687         int i, count;
1688         conf_detail* info;
1689
1690         /* _mmcam_dbg_log("Entered... category[%d],name[%s]", category, name); */
1691
1692         mmf_return_val_if_fail(configure_info, FALSE);
1693         mmf_return_val_if_fail(name, FALSE);
1694
1695         if (configure_info->info[category]) {
1696                 count = configure_info->info[category]->count;
1697                 info = configure_info->info[category];
1698
1699                 for (i = 0 ; i < count ; i++) {
1700                         if (info->detail_info[i] == NULL)
1701                                 continue;
1702
1703                         if (!strcmp(((type_int_range*)(info->detail_info[i]))->name , name)) {
1704                                 *value = (type_int_range*)(info->detail_info[i]);
1705                                 /*
1706                                 _mmcam_dbg_log("Get[%s] int range - min[%d],max[%d],default[%d]",
1707                                         name, (*value)->min, (*value)->max, (*value)->default_value);
1708                                 */
1709                                 return TRUE;
1710                         }
1711                 }
1712         }
1713
1714         *value = NULL;
1715
1716         /*_mmcam_dbg_warn( "Faild to get int range... check it...Category[%d],Name[%s]", category, name );*/
1717
1718         return FALSE;
1719 }
1720
1721 int
1722 _mmcamcorder_conf_get_value_int_array(camera_conf* configure_info, int category, const char* name, type_int_array** value)
1723 {
1724         int i, count;
1725         conf_detail* info;
1726
1727         /*_mmcam_dbg_log("Entered... category[%d],name[%s]", category, name);*/
1728
1729         mmf_return_val_if_fail(configure_info, FALSE);
1730         mmf_return_val_if_fail(name, FALSE);
1731
1732         if (configure_info->info[category]) {
1733                 count   = configure_info->info[category]->count;
1734                 info    = configure_info->info[category];
1735
1736                 for (i = 0 ; i < count ; i++) {
1737                         if (info->detail_info[i] == NULL)
1738                                 continue;
1739
1740                         if (!strcmp(((type_int_array*)(info->detail_info[i]))->name , name)) {
1741                                 *value = (type_int_array*)(info->detail_info[i]);
1742                                 /*
1743                                 _mmcam_dbg_log("Get[%s] int array - [%x],count[%d],default[%d]",
1744                                         name, (*value)->value, (*value)->count, (*value)->default_value);
1745                                 */
1746                                 return TRUE;
1747                         }
1748                 }
1749         }
1750
1751         *value = NULL;
1752
1753         /*_mmcam_dbg_warn( "Faild to get int array... check it...Category[%d],Name[%s]", category, name );*/
1754
1755         return FALSE;
1756 }
1757
1758 int
1759 _mmcamcorder_conf_get_value_int_pair_array(camera_conf* configure_info, int category, const char* name, type_int_pair_array** value)
1760 {
1761         int i, count;
1762         conf_detail* info;
1763
1764         /* _mmcam_dbg_log("Entered... category[%d],name[%s]", category, name); */
1765
1766         mmf_return_val_if_fail(configure_info, FALSE);
1767         mmf_return_val_if_fail(name, FALSE);
1768
1769         if (configure_info->info[category]) {
1770                 count = configure_info->info[category]->count;
1771                 info = configure_info->info[category];
1772
1773                 for (i = 0 ; i < count ; i++) {
1774                         if (info->detail_info[i] == NULL)
1775                                 continue;
1776
1777                         if (!strcmp(((type_int_pair_array*)(info->detail_info[i]))->name , name)) {
1778                                 *value = (type_int_pair_array*)(info->detail_info[i]);
1779                                 /*
1780                                 _mmcam_dbg_log("Get[%s] int pair array - [%x][%x],count[%d],default[%d][%d]",
1781                                         name, (*value)->value[0], (*value)->value[1], (*value)->count,
1782                                         (*value)->default_value[0], (*value)->default_value[1]);
1783                                 */
1784                                 return TRUE;
1785                         }
1786                 }
1787         }
1788
1789         *value = NULL;
1790
1791         /*_mmcam_dbg_warn("Faild to get int pair array... check it...Category[%d],Name[%s]", category, name);*/
1792
1793         return FALSE;
1794 }
1795
1796 int _mmcamcorder_conf_get_value_string(MMHandleType handle, camera_conf* configure_info, int category, const char* name, const char** value)
1797 {
1798         int i, count;
1799         conf_detail* info;
1800
1801         /* _mmcam_dbg_log("Entered... category[%d],name[%s]", category, name); */
1802
1803         mmf_return_val_if_fail(configure_info, FALSE);
1804         mmf_return_val_if_fail(name, FALSE);
1805
1806         if (configure_info->info[category]) {
1807                 count = configure_info->info[category]->count;
1808                 info = configure_info->info[category];
1809
1810                 for (i = 0 ; i < count ; i++) {
1811                         if (info->detail_info[i] == NULL)
1812                                 continue;
1813
1814                         if (!strcmp(((type_string*)(info->detail_info[i]))->name , name)) {
1815                                 *value = ((type_string*)(info->detail_info[i]))->value;
1816                                  /*_mmcam_dbg_log( "Get[%s] string[%s]", name, *value ? *value : "NULL" );*/
1817                                 return TRUE;
1818                         }
1819                 }
1820         }
1821
1822         if (_mmcamcorder_conf_get_default_value_string(handle, configure_info->type, category, name, value)) {
1823                 /*_mmcam_dbg_log( "Get[%s] string[%s]", name, *value ? *value : "NULL" );*/
1824                 return TRUE;
1825         }
1826
1827         _mmcam_dbg_err("Faild to get string... check it...Category[%d],Name[%s]", category, name);
1828
1829         return FALSE;
1830 }
1831
1832 int
1833 _mmcamcorder_conf_get_value_string_array(camera_conf* configure_info, int category, const char* name, type_string_array** value)
1834 {
1835         int i, count;
1836         conf_detail* info;
1837
1838         /* _mmcam_dbg_log("Entered... category[%d],name[%s]", category, name); */
1839
1840         mmf_return_val_if_fail(configure_info, FALSE);
1841         mmf_return_val_if_fail(name, FALSE);
1842
1843         if (configure_info->info[category]) {
1844                 count = configure_info->info[category]->count;
1845                 info = configure_info->info[category];
1846
1847                 for (i = 0 ; i < count ; i++) {
1848                         if (info->detail_info[i] == NULL)
1849                                 continue;
1850
1851                         if (!strcmp(((type_string_array*)(info->detail_info[i]))->name , name)) {
1852                                 *value = (type_string_array*)(info->detail_info[i]);
1853                                 /*
1854                                 _mmcam_dbg_log("Get[%s] string array - [%x],count[%d],default[%s]",
1855                                         name, (*value)->value, (*value)->count, (*value)->default_value);
1856                                 */
1857                                 return TRUE;
1858                         }
1859                 }
1860         }
1861
1862         *value = NULL;
1863
1864         /*_mmcam_dbg_warn("Faild to get string array... check it...Category[%d],Name[%s]", category, name);*/
1865
1866         return FALSE;
1867 }
1868
1869 int _mmcamcorder_conf_get_element(MMHandleType handle, camera_conf* configure_info, int category, const char* name, type_element** element)
1870 {
1871         int i, count;
1872         conf_detail* info;
1873
1874         /* _mmcam_dbg_log("Entered... category[%d], ame[%s]", category, name); */
1875
1876         mmf_return_val_if_fail(configure_info, FALSE);
1877         mmf_return_val_if_fail(name, FALSE);
1878
1879         if (configure_info->info[category]) {
1880                 count = configure_info->info[category]->count;
1881                 info = configure_info->info[category];
1882
1883                 for (i = 0 ; i < count ; i++) {
1884                         if (info->detail_info[i] == NULL)
1885                                 continue;
1886
1887                         if (!strcmp(((type_element*)(info->detail_info[i]))->name , name)) {
1888                                 *element = (type_element*)(info->detail_info[i]);
1889                                 /* _mmcam_dbg_log("Get[%s] element[%x]", name, *element); */
1890                                 return TRUE;
1891                         }
1892                 }
1893         }
1894
1895         if (_mmcamcorder_conf_get_default_element(handle, configure_info->type, category, name, element)) {
1896                 /* _mmcam_dbg_log("Get[%s] element[%x]", name, *element); */
1897                 return TRUE;
1898         }
1899
1900         _mmcam_dbg_warn("Faild to get element name... check it...Category[%d],Name[%s]", category, name);
1901
1902         return FALSE;
1903 }
1904
1905 int
1906 _mmcamcorder_conf_get_value_element_name(type_element* element, const char** value)
1907 {
1908         /* _mmcam_dbg_log("Entered..."); */
1909
1910         mmf_return_val_if_fail(element, FALSE);
1911
1912         *value = element->element_name;
1913
1914         /* _mmcam_dbg_log("Get element name : [%s]", *value); */
1915
1916         return TRUE;
1917 }
1918
1919 int
1920 _mmcamcorder_conf_get_value_element_int(type_element* element, const char* name, int* value)
1921 {
1922         int i;
1923
1924         /* _mmcam_dbg_log( "Entered..." ); */
1925
1926         mmf_return_val_if_fail(element, FALSE);
1927         mmf_return_val_if_fail(name, FALSE);
1928
1929         for (i = 0 ; i < element->count_int ; i++) {
1930                 if (!strcmp(element->value_int[i]->name, name)) {
1931                         *value = element->value_int[i]->value;
1932                         /* _mmcam_dbg_log("Get[%s] element int[%d]", name, *value); */
1933                         return TRUE;
1934                 }
1935         }
1936
1937         _mmcam_dbg_warn("Faild to get int in element... ElementName[%p],Name[%s],Count[%d]",
1938                 element->name, name, element->count_int);
1939
1940         return FALSE;
1941 }
1942
1943 int
1944 _mmcamcorder_conf_get_value_element_string(type_element* element, const char* name, const char** value)
1945 {
1946         int i;
1947
1948         /* _mmcam_dbg_log("Entered..."); */
1949
1950         mmf_return_val_if_fail(element, FALSE);
1951         mmf_return_val_if_fail(name, FALSE);
1952
1953         for (i = 0 ; i < element->count_string ; i++) {
1954                 if (!strcmp(element->value_string[i]->name, name)) {
1955                         *value = element->value_string[i]->value;
1956                         /*_mmcam_dbg_log("Get[%s] element string[%s]", name, *value);*/
1957                         return TRUE;
1958                 }
1959         }
1960
1961         _mmcam_dbg_warn("Faild to get int in element... ElementName[%p],Name[%s],Count[%d]",
1962                 element->name, name, element->count_string);
1963
1964         return FALSE;
1965 }
1966
1967 int
1968 _mmcamcorder_conf_set_value_element_property(GstElement* gst, type_element* element)
1969 {
1970         int i;
1971
1972         /* _mmcam_dbg_log("Entered..."); */
1973
1974         mmf_return_val_if_fail(gst, FALSE);
1975         mmf_return_val_if_fail(element, FALSE);
1976
1977         if (element->count_int == 0) {
1978                 /*_mmcam_dbg_log( "There is no integer property to set in INI file[%s].", element->name );*/
1979         } else {
1980                 if (element->value_int == NULL) {
1981                         _mmcam_dbg_warn("count_int[%d] is NOT zero, but value_int is NULL", element->count_int);
1982                         return FALSE;
1983                 }
1984
1985                 for (i = 0 ; i < element->count_int ; i++) {
1986                         MMCAMCORDER_G_OBJECT_SET(gst, element->value_int[i]->name, element->value_int[i]->value);
1987
1988                         /*
1989                         _mmcam_dbg_log("Element[%s] Set[%s] -> integer[%d]",
1990                                 element->element_name,
1991                                 element->value_int[i]->name,
1992                                 element->value_int[i]->value);
1993                         */
1994                 }
1995         }
1996
1997         if (element->count_string == 0) {
1998                 _mmcam_dbg_log("There is no string property to set in INI file[%s].", element->name);
1999         } else {
2000                 if (element->value_string == NULL) {
2001                         _mmcam_dbg_warn("count_string[%d] is NOT zero, but value_string is NULL", element->count_string);
2002                         return FALSE;
2003                 }
2004
2005                 for (i = 0 ; i < element->count_string ; i++) {
2006                         MMCAMCORDER_G_OBJECT_SET_POINTER(gst, element->value_string[i]->name, element->value_string[i]->value);
2007
2008                         _mmcam_dbg_log("Element[%s] Set[%s] -> string[%s]",
2009                                 element->element_name,
2010                                 element->value_string[i]->name,
2011                                 element->value_string[i]->value);
2012                 }
2013         }
2014
2015         /* _mmcam_dbg_log( "Done." ); */
2016
2017         return TRUE;
2018 }
2019
2020 int
2021 _mmcamcorder_conf_get_default_value_int(MMHandleType handle, int type, int category, const char* name, int* value)
2022 {
2023         int i = 0;
2024         int count_value = 0;
2025
2026         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2027
2028         if (hcamcorder == NULL) {
2029                 _mmcam_dbg_err("handle is NULL");
2030                 return FALSE;
2031         }
2032
2033         /* _mmcam_dbg_log("Entered..."); */
2034
2035         mmf_return_val_if_fail(name, FALSE);
2036
2037         if (!_mmcamcorder_conf_get_category_size(handle, type, category, &count_value)) {
2038                 _mmcam_dbg_warn("No matched category... check it... categoty[%d]", category);
2039                 return FALSE;
2040         }
2041
2042         if (type == CONFIGURE_TYPE_MAIN) {
2043                 for (i = 0 ; i < count_value ; i++) {
2044                         if (!strcmp(hcamcorder->conf_main_info_table[category][i].name, name)) {
2045                                 *value = hcamcorder->conf_main_info_table[category][i].value_int;
2046                                 return TRUE;
2047                         }
2048                 }
2049         } else {
2050                 for (i = 0 ; i < count_value ; i++) {
2051                         if (!strcmp(hcamcorder->conf_ctrl_info_table[category][i].name, name)) {
2052                                 *value = hcamcorder->conf_ctrl_info_table[category][i].value_int;
2053                                 return TRUE;
2054                         }
2055                 }
2056         }
2057
2058         _mmcam_dbg_err("Failed to get default int... check it... Type[%d],Category[%d],Name[%s]", type, category, name);
2059
2060         return FALSE;
2061 }
2062
2063 int _mmcamcorder_conf_get_default_value_string(MMHandleType handle, int type, int category, const char* name, const char** value)
2064 {
2065         int i = 0;
2066         int count_value = 0;
2067
2068         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2069
2070         if (hcamcorder == NULL) {
2071                 _mmcam_dbg_err("handle is NULL");
2072                 return FALSE;
2073         }
2074
2075         /* _mmcam_dbg_log("Entered..."); */
2076
2077         mmf_return_val_if_fail(name, FALSE);
2078
2079         if (!_mmcamcorder_conf_get_category_size(handle, type, category, &count_value)) {
2080                 _mmcam_dbg_warn("No matched category... check it... categoty[%d]", category);
2081                 return FALSE;
2082         }
2083
2084         if (type == CONFIGURE_TYPE_MAIN) {
2085                 for (i = 0 ; i < count_value ; i++) {
2086                         if (!strcmp(hcamcorder->conf_main_info_table[category][i].name, name)) {
2087                                 *value = hcamcorder->conf_main_info_table[category][i].value_string;
2088                                 /*_mmcam_dbg_log("Get[%s] default string[%s]", name, *value ? *value : "NULL");*/
2089                                 return TRUE;
2090                         }
2091                 }
2092         } else {
2093                 for (i = 0 ; i < count_value ; i++) {
2094                         if (!strcmp(hcamcorder->conf_ctrl_info_table[category][i].name, name)) {
2095                                 *value = hcamcorder->conf_ctrl_info_table[category][i].value_string;
2096                                 /*_mmcam_dbg_log("Get[%s] default string[%s]", name, *value ? *value : "NULL");*/
2097                                 return TRUE;
2098                         }
2099                 }
2100         }
2101
2102         _mmcam_dbg_warn("Failed to get default string... check it... Type[%d],Category[%d],Name[%s]", type, category, name);
2103
2104         return FALSE;
2105 }
2106
2107 int _mmcamcorder_conf_get_default_element(MMHandleType handle, int type, int category, const char* name, type_element** element)
2108 {
2109         int i = 0;
2110         int count_value = 0;
2111
2112         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2113
2114         if (hcamcorder == NULL) {
2115                 _mmcam_dbg_err("handle is NULL");
2116                 return FALSE;
2117         }
2118
2119         /* _mmcam_dbg_log("Entered..."); */
2120
2121         mmf_return_val_if_fail(name, FALSE);
2122
2123         if (!_mmcamcorder_conf_get_category_size(handle, type, category, &count_value)) {
2124                 _mmcam_dbg_warn("No matched category... check it... categoty[%d]", category);
2125                 return FALSE;
2126         }
2127
2128         if (type == CONFIGURE_TYPE_MAIN) {
2129                 for (i = 0 ; i < count_value ; i++) {
2130                         if (!strcmp(hcamcorder->conf_main_info_table[category][i].name, name)) {
2131                                 *element = hcamcorder->conf_main_info_table[category][i].value_element;
2132                                 _mmcam_dbg_log("Get[%s] element[%p]", name, *element);
2133                                 return TRUE;
2134                         }
2135                 }
2136         } else {
2137                 for (i = 0 ; i < count_value ; i++) {
2138                         if (!strcmp(hcamcorder->conf_ctrl_info_table[category][i].name, name)) {
2139                                 *element = hcamcorder->conf_ctrl_info_table[category][i].value_element;
2140                                 _mmcam_dbg_log("Get[%s] element[%p]", name, *element);
2141                                 return TRUE;
2142                         }
2143                 }
2144         }
2145
2146         _mmcam_dbg_warn("Failed to get default element... check it... Type[%d],Category[%d],Name[%s]", type, category, name);
2147
2148         return FALSE;
2149 }
2150
2151 int _mmcamcorder_conf_get_category_size(MMHandleType handle, int type, int category, int* size)
2152 {
2153         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2154
2155         if (hcamcorder == NULL) {
2156                 _mmcam_dbg_err("handle is NULL");
2157                 return FALSE;
2158         }
2159
2160         /*
2161         mmf_return_val_if_fail(conf_main_category_size, FALSE);
2162         mmf_return_val_if_fail(conf_ctrl_category_size, FALSE);
2163         */
2164
2165         if (type == CONFIGURE_TYPE_MAIN) {
2166                 mmf_return_val_if_fail(category < CONFIGURE_CATEGORY_MAIN_NUM, FALSE);
2167
2168                 *size = (int)hcamcorder->conf_main_category_size[category];
2169         } else {
2170                 mmf_return_val_if_fail(category < CONFIGURE_CATEGORY_CTRL_NUM, FALSE);
2171
2172                 *size = (int)hcamcorder->conf_ctrl_category_size[category];
2173         }
2174
2175         return TRUE;
2176 }
2177
2178 void
2179 _mmcamcorder_conf_print_info(MMHandleType handle, camera_conf** configure_info)
2180 {
2181         int i, j, k, type, category_type;
2182
2183         type_int                *temp_int;
2184         type_int_range          *temp_int_range;
2185         type_int_array          *temp_int_array;
2186         type_int_pair_array     *temp_int_pair_array;
2187         type_string             *temp_string;
2188         type_element            *temp_element;
2189
2190         g_print("[ConfigureInfoPrint] : Entered.\n");
2191
2192         mmf_return_if_fail(*configure_info);
2193
2194         if ((*configure_info)->type == CONFIGURE_TYPE_MAIN)
2195                 category_type = CONFIGURE_CATEGORY_MAIN_NUM;
2196         else
2197                 category_type = CONFIGURE_CATEGORY_CTRL_NUM;
2198
2199         for (i = 0 ; i < category_type ; i++) {
2200
2201                 if ((*configure_info)->info[i]) {
2202                         g_print("[ConfigureInfo] : Category [%d]\n", i);
2203
2204                         for (j = 0 ; j < (*configure_info)->info[i]->count ; j++) {
2205
2206                                 if (_mmcamcorder_conf_get_value_type(handle, (*configure_info)->type, i, ((type_int*)((*configure_info)->info[i]->detail_info[j]))->name, &type)) {
2207                                         switch (type) {
2208                                         case CONFIGURE_VALUE_INT:
2209                                                 temp_int = (type_int*)((*configure_info)->info[i]->detail_info[j]);
2210                                                 g_print("[ConfigureInfo] : INT - Name[%s],Value [%d]\n", temp_int->name, temp_int->value);
2211                                                 break;
2212                                         case CONFIGURE_VALUE_INT_RANGE:
2213                                                 temp_int_range = (type_int_range*)((*configure_info)->info[i]->detail_info[j]);
2214                                                 g_print("[ConfigureInfo] : INT_RANGE - Name[%s],Value [%d]~[%d], default [%d]\n",
2215                                                         temp_int_range->name, temp_int_range->min, temp_int_range->max, temp_int_range->default_value);
2216                                                 break;
2217                                         case CONFIGURE_VALUE_INT_ARRAY:
2218                                                 temp_int_array = (type_int_array*)((*configure_info)->info[i]->detail_info[j]);
2219                                                 g_print("[ConfigureInfo] : INT_ARRAY - Name[%s], default [%d]\n                            - ",
2220                                                         temp_int_array->name, temp_int_array->default_value);
2221
2222                                                 for (k = 0 ; k < temp_int_array->count ; k++)
2223                                                         g_print("[%d] ", temp_int_array->value[k]);
2224
2225                                                 g_print("\n");
2226                                                 break;
2227                                         case CONFIGURE_VALUE_INT_PAIR_ARRAY:
2228                                                 temp_int_pair_array = (type_int_pair_array*)((*configure_info)->info[i]->detail_info[j]);
2229                                                 g_print("[ConfigureInfo] : INT_PAIR_ARRAY - Name[%s], default [%d][%d]\n                            - ",
2230                                                         temp_int_pair_array->name, temp_int_pair_array->default_value[0], temp_int_pair_array->default_value[0]);
2231
2232                                                 for (k = 0 ; k < temp_int_pair_array->count ; k++)
2233                                                         g_print("[%d,%d] ", temp_int_pair_array->value[0][k], temp_int_pair_array->value[1][k]);
2234
2235                                                 g_print("\n");
2236                                                 break;
2237                                         case CONFIGURE_VALUE_STRING:
2238                                                 temp_string = (type_string*)((*configure_info)->info[i]->detail_info[j]);
2239                                                 g_print("[ConfigureInfo] : STRING - Name[%s],Value[%s]\n", temp_string->name, temp_string->value);
2240                                                 break;
2241                                         case CONFIGURE_VALUE_ELEMENT:
2242                                                 temp_element = (type_element*)((*configure_info)->info[i]->detail_info[j]);
2243                                                 g_print("[ConfigureInfo] : Element - Name[%s],Element_Name[%s]\n", temp_element->name, temp_element->element_name);
2244
2245                                                 for (k = 0 ; k < temp_element->count_int ; k++)
2246                                                         g_print("                          - INT[%d] Name[%s],Value[%d]\n", k, temp_element->value_int[k]->name, temp_element->value_int[k]->value);
2247
2248                                                 for (k = 0 ; k < temp_element->count_string ; k++)
2249                                                         g_print("                          - STRING[%d] Name[%s],Value[%s]\n", k, temp_element->value_string[k]->name, temp_element->value_string[k]->value);
2250
2251                                                 break;
2252                                         default:
2253                                                 g_print("[ConfigureInfo] : Not matched value type... So can not print data... check it... Name[%s],type[%d]\n", ((type_int*)((*configure_info)->info[i]->detail_info[j]))->name, type);
2254                                                 break;
2255                                         }
2256                                 } else {
2257                                         g_print("[ConfigureInfo] : Failed to get value type.");
2258                                 }
2259                         }
2260                 }
2261         }
2262
2263         g_print("[ConfigureInfoPrint] : Done.\n");
2264 }
2265
2266
2267 static type_element *
2268 __mmcamcorder_get_audio_codec_element(MMHandleType handle)
2269 {
2270         type_element *telement = NULL;
2271         const char *codec_type_str = NULL;
2272         int codec_type = MM_AUDIO_CODEC_INVALID;
2273         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2274         _MMCamcorderSubContext *sc = NULL;
2275
2276         mmf_return_val_if_fail(hcamcorder, NULL);
2277         sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2278
2279         mmf_return_val_if_fail(sc, NULL);
2280
2281         _mmcam_dbg_log("");
2282
2283         /* Check element availability */
2284         mm_camcorder_get_attributes(handle, NULL, MMCAM_AUDIO_ENCODER, &codec_type, NULL);
2285
2286         switch (codec_type) {
2287         case MM_AUDIO_CODEC_AMR:
2288                 codec_type_str = "AMR";
2289                 break;
2290         case MM_AUDIO_CODEC_G723_1:
2291                 codec_type_str = "G723_1";
2292                 break;
2293         case MM_AUDIO_CODEC_MP3:
2294                 codec_type_str = "MP3";
2295                 break;
2296         case MM_AUDIO_CODEC_AAC:
2297                 codec_type_str = "AAC";
2298                 break;
2299         case MM_AUDIO_CODEC_MMF:
2300                 codec_type_str = "MMF";
2301                 break;
2302         case MM_AUDIO_CODEC_ADPCM:
2303                 codec_type_str = "ADPCM";
2304                 break;
2305         case MM_AUDIO_CODEC_WAVE:
2306                 codec_type_str = "WAVE";
2307                 break;
2308         case MM_AUDIO_CODEC_MIDI:
2309                 codec_type_str = "MIDI";
2310                 break;
2311         case MM_AUDIO_CODEC_IMELODY:
2312                 codec_type_str = "IMELODY";
2313                 break;
2314         case MM_AUDIO_CODEC_VORBIS:
2315                 codec_type_str = "VORBIS";
2316                 break;
2317         default:
2318                 _mmcam_dbg_err("Not supported audio codec[%d]", codec_type);
2319                 return NULL;
2320         }
2321
2322         _mmcamcorder_conf_get_element(handle, hcamcorder->conf_main,
2323                 CONFIGURE_CATEGORY_MAIN_AUDIO_ENCODER,
2324                 codec_type_str,
2325                 &telement);
2326
2327         return telement;
2328 }
2329
2330
2331 static type_element *
2332 __mmcamcorder_get_video_codec_element(MMHandleType handle)
2333 {
2334         type_element *telement = NULL;
2335         const char *codec_type_str = NULL;
2336         int codec_type = MM_VIDEO_CODEC_INVALID;
2337         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2338         _MMCamcorderSubContext *sc = NULL;
2339
2340         mmf_return_val_if_fail(hcamcorder, NULL);
2341         sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2342
2343         mmf_return_val_if_fail(sc, NULL);
2344
2345         _mmcam_dbg_log("");
2346
2347         /* Check element availability */
2348         mm_camcorder_get_attributes(handle, NULL, MMCAM_VIDEO_ENCODER, &codec_type, NULL);
2349
2350         switch (codec_type) {
2351         case MM_VIDEO_CODEC_H263:
2352                 codec_type_str = "H263";
2353                 break;
2354         case MM_VIDEO_CODEC_H264:
2355                 codec_type_str = "H264";
2356                 break;
2357         case MM_VIDEO_CODEC_H26L:
2358                 codec_type_str = "H26L";
2359                 break;
2360         case MM_VIDEO_CODEC_MPEG4:
2361                 codec_type_str = "MPEG4";
2362                 break;
2363         case MM_VIDEO_CODEC_MPEG1:
2364                 codec_type_str = "MPEG1";
2365                 break;
2366         case MM_VIDEO_CODEC_THEORA:
2367                 codec_type_str = "THEORA";
2368                 break;
2369         default:
2370                 _mmcam_dbg_err("Not supported video codec[%d]", codec_type);
2371                 return NULL;
2372         }
2373
2374         _mmcamcorder_conf_get_element(handle, hcamcorder->conf_main,
2375                 CONFIGURE_CATEGORY_MAIN_VIDEO_ENCODER,
2376                 codec_type_str,
2377                 &telement);
2378
2379         return telement;
2380 }
2381
2382
2383 static type_element *
2384 __mmcamcorder_get_image_codec_element(MMHandleType handle)
2385 {
2386         type_element *telement = NULL;
2387         const char *codec_type_str = NULL;
2388         int codec_type = MM_IMAGE_CODEC_INVALID;
2389         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2390         _MMCamcorderSubContext *sc = NULL;
2391
2392         mmf_return_val_if_fail(hcamcorder, NULL);
2393         sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2394
2395         mmf_return_val_if_fail(sc, NULL);
2396
2397         _mmcam_dbg_log("");
2398
2399         /* Check element availability */
2400         mm_camcorder_get_attributes(handle, NULL, MMCAM_IMAGE_ENCODER, &codec_type, NULL);
2401
2402         switch (codec_type) {
2403         case MM_IMAGE_CODEC_JPEG:
2404                 codec_type_str = "JPEG";
2405                 break;
2406         case MM_IMAGE_CODEC_SRW:
2407                 codec_type_str = "SRW";
2408                 break;
2409         case MM_IMAGE_CODEC_JPEG_SRW:
2410                 codec_type_str = "JPEG_SRW";
2411                 break;
2412         case MM_IMAGE_CODEC_PNG:
2413                 codec_type_str = "PNG";
2414                 break;
2415         case MM_IMAGE_CODEC_BMP:
2416                 codec_type_str = "BMP";
2417                 break;
2418         case MM_IMAGE_CODEC_WBMP:
2419                 codec_type_str = "WBMP";
2420                 break;
2421         case MM_IMAGE_CODEC_TIFF:
2422                 codec_type_str = "TIFF";
2423                 break;
2424         case MM_IMAGE_CODEC_PCX:
2425                 codec_type_str = "PCX";
2426                 break;
2427         case MM_IMAGE_CODEC_GIF:
2428                 codec_type_str = "GIF";
2429                 break;
2430         case MM_IMAGE_CODEC_ICO:
2431                 codec_type_str = "ICO";
2432                 break;
2433         case MM_IMAGE_CODEC_RAS:
2434                 codec_type_str = "RAS";
2435                 break;
2436         case MM_IMAGE_CODEC_TGA:
2437                 codec_type_str = "TGA";
2438                 break;
2439         case MM_IMAGE_CODEC_XBM:
2440                 codec_type_str = "XBM";
2441                 break;
2442         case MM_IMAGE_CODEC_XPM:
2443                 codec_type_str = "XPM";
2444                 break;
2445         default:
2446                 _mmcam_dbg_err("Not supported image codec[%d]", codec_type);
2447                 return NULL;
2448         }
2449
2450         _mmcamcorder_conf_get_element(handle, hcamcorder->conf_main,
2451                 CONFIGURE_CATEGORY_MAIN_IMAGE_ENCODER,
2452                 codec_type_str,
2453                 &telement);
2454
2455         return telement;
2456 }
2457
2458
2459 static type_element *
2460 __mmcamcorder_get_file_format_element(MMHandleType handle)
2461 {
2462         type_element *telement = NULL;
2463         const char *mux_type_str = NULL;
2464         int file_type = MM_FILE_FORMAT_INVALID;
2465         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2466         _MMCamcorderSubContext *sc = NULL;
2467
2468         mmf_return_val_if_fail(hcamcorder, NULL);
2469         sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2470
2471         mmf_return_val_if_fail(sc, NULL);
2472
2473         _mmcam_dbg_log("");
2474
2475         /* Check element availability */
2476         mm_camcorder_get_attributes(handle, NULL, MMCAM_FILE_FORMAT, &file_type, NULL);
2477
2478         switch (file_type) {
2479         case MM_FILE_FORMAT_3GP:
2480                 mux_type_str = "3GP";
2481                 break;
2482         case MM_FILE_FORMAT_AMR:
2483                 mux_type_str = "AMR";
2484                 break;
2485         case MM_FILE_FORMAT_MP4:
2486                 mux_type_str = "MP4";
2487                 break;
2488         case MM_FILE_FORMAT_AAC:
2489                 mux_type_str = "AAC";
2490                 break;
2491         case MM_FILE_FORMAT_MP3:
2492                 mux_type_str = "MP3";
2493                 break;
2494         case MM_FILE_FORMAT_OGG:
2495                 mux_type_str = "OGG";
2496                 break;
2497         case MM_FILE_FORMAT_WAV:
2498                 mux_type_str = "WAV";
2499                 break;
2500         case MM_FILE_FORMAT_AVI:
2501                 mux_type_str = "AVI";
2502                 break;
2503         case MM_FILE_FORMAT_WMA:
2504                 mux_type_str = "WMA";
2505                 break;
2506         case MM_FILE_FORMAT_WMV:
2507                 mux_type_str = "WMV";
2508                 break;
2509         case MM_FILE_FORMAT_MID:
2510                 mux_type_str = "MID";
2511                 break;
2512         case MM_FILE_FORMAT_MMF:
2513                 mux_type_str = "MMF";
2514                 break;
2515         case MM_FILE_FORMAT_MATROSKA:
2516                 mux_type_str = "MATROSKA";
2517                 break;
2518         case MM_FILE_FORMAT_M2TS:
2519                 mux_type_str = "M2TS";
2520                 break;
2521         default:
2522                 _mmcam_dbg_err("Not supported file format[%d]", file_type);
2523                 return NULL;
2524         }
2525
2526         _mmcamcorder_conf_get_element(handle, hcamcorder->conf_main,
2527                 CONFIGURE_CATEGORY_MAIN_MUX,
2528                 mux_type_str,
2529                 &telement);
2530
2531         return telement;
2532 }
2533
2534
2535 type_element *
2536 _mmcamcorder_get_type_element(MMHandleType handle, int type)
2537 {
2538         type_element *telement = NULL;
2539
2540         _mmcam_dbg_log("type:%d", type);
2541
2542         switch (type) {
2543         case MM_CAM_AUDIO_ENCODER:
2544                 telement = __mmcamcorder_get_audio_codec_element(handle);
2545                 break;
2546         case MM_CAM_VIDEO_ENCODER:
2547                 telement = __mmcamcorder_get_video_codec_element(handle);
2548                 break;
2549         case MM_CAM_IMAGE_ENCODER:
2550                 telement = __mmcamcorder_get_image_codec_element(handle);
2551                 break;
2552         case MM_CAM_FILE_FORMAT:
2553                 telement = __mmcamcorder_get_file_format_element(handle);
2554                 break;
2555         default:
2556                 _mmcam_dbg_log("Can't get element type form this profile.(%d)", type);
2557         }
2558
2559         return telement;
2560 }
2561
2562
2563 int _mmcamcorder_get_audio_codec_format(MMHandleType handle, const char *name)
2564 {
2565         int codec_index = MM_AUDIO_CODEC_INVALID;
2566
2567         if (!name) {
2568                 _mmcam_dbg_err("name is NULL");
2569                 return MM_AUDIO_CODEC_INVALID;
2570         }
2571
2572         if (!strcmp(name, "AMR"))
2573                 codec_index = MM_AUDIO_CODEC_AMR;
2574         else if (!strcmp(name, "G723_1"))
2575                 codec_index = MM_AUDIO_CODEC_G723_1;
2576         else if (!strcmp(name, "MP3"))
2577                 codec_index = MM_AUDIO_CODEC_MP3;
2578         else if (!strcmp(name, "AAC"))
2579                 codec_index = MM_AUDIO_CODEC_AAC;
2580         else if (!strcmp(name, "MMF"))
2581                 codec_index = MM_AUDIO_CODEC_MMF;
2582         else if (!strcmp(name, "ADPCM"))
2583                 codec_index = MM_AUDIO_CODEC_ADPCM;
2584         else if (!strcmp(name, "WAVE"))
2585                 codec_index = MM_AUDIO_CODEC_WAVE;
2586         else if (!strcmp(name, "MIDI"))
2587                 codec_index = MM_AUDIO_CODEC_MIDI;
2588         else if (!strcmp(name, "IMELODY"))
2589                 codec_index = MM_AUDIO_CODEC_IMELODY;
2590         else if (!strcmp(name, "VORBIS"))
2591                 codec_index = MM_AUDIO_CODEC_VORBIS;
2592
2593         /*_mmcam_dbg_log("audio codec index %d", codec_index);*/
2594
2595         return codec_index;
2596 }
2597
2598
2599
2600 int _mmcamcorder_get_video_codec_format(MMHandleType handle, const char *name)
2601 {
2602         int codec_index = MM_VIDEO_CODEC_INVALID;
2603
2604         if (!name) {
2605                 _mmcam_dbg_err("name is NULL");
2606                 return MM_VIDEO_CODEC_INVALID;
2607         }
2608
2609         if (!strcmp(name, "H263"))
2610                 codec_index = MM_VIDEO_CODEC_H263;
2611         else if (!strcmp(name, "H264"))
2612                 codec_index = MM_VIDEO_CODEC_H264;
2613         else if (!strcmp(name, "H26L"))
2614                 codec_index = MM_VIDEO_CODEC_H26L;
2615         else if (!strcmp(name, "MPEG4"))
2616                 codec_index = MM_VIDEO_CODEC_MPEG4;
2617         else if (!strcmp(name, "MPEG1"))
2618                 codec_index = MM_VIDEO_CODEC_MPEG1;
2619         else if (!strcmp(name, "THEORA"))
2620                 codec_index = MM_VIDEO_CODEC_THEORA;
2621
2622         /*_mmcam_dbg_log("video codec index %d", codec_index);*/
2623
2624         return codec_index;
2625 }
2626
2627
2628
2629 int _mmcamcorder_get_image_codec_format(MMHandleType handle, const char *name)
2630 {
2631         int codec_index = MM_IMAGE_CODEC_INVALID;
2632
2633         if (!name) {
2634                 _mmcam_dbg_err("name is NULL");
2635                 return MM_IMAGE_CODEC_INVALID;
2636         }
2637
2638         if (!strcmp(name, "JPEG"))
2639                 codec_index = MM_IMAGE_CODEC_JPEG;
2640         else if (!strcmp(name, "PNG"))
2641                 codec_index = MM_IMAGE_CODEC_PNG;
2642         else if (!strcmp(name, "BMP"))
2643                 codec_index = MM_IMAGE_CODEC_BMP;
2644         else if (!strcmp(name, "WBMP"))
2645                 codec_index = MM_IMAGE_CODEC_WBMP;
2646         else if (!strcmp(name, "TIFF"))
2647                 codec_index = MM_IMAGE_CODEC_TIFF;
2648         else if (!strcmp(name, "PCX"))
2649                 codec_index = MM_IMAGE_CODEC_PCX;
2650         else if (!strcmp(name, "GIF"))
2651                 codec_index = MM_IMAGE_CODEC_GIF;
2652         else if (!strcmp(name, "ICO"))
2653                 codec_index = MM_IMAGE_CODEC_ICO;
2654         else if (!strcmp(name, "RAS"))
2655                 codec_index = MM_IMAGE_CODEC_RAS;
2656         else if (!strcmp(name, "TGA"))
2657                 codec_index = MM_IMAGE_CODEC_TGA;
2658         else if (!strcmp(name, "XBM"))
2659                 codec_index = MM_IMAGE_CODEC_XBM;
2660         else if (!strcmp(name, "XPM"))
2661                 codec_index = MM_IMAGE_CODEC_XPM;
2662
2663         _mmcam_dbg_log("image codec index %d", codec_index);
2664
2665         return codec_index;
2666 }
2667
2668
2669 int _mmcamcorder_get_mux_format(MMHandleType handle, const char *name)
2670 {
2671         int mux_index = MM_FILE_FORMAT_INVALID;
2672
2673         if (!name) {
2674                 _mmcam_dbg_err("name is NULL");
2675                 return MM_FILE_FORMAT_INVALID;
2676         }
2677
2678         if (!strcmp(name, "3GP"))
2679                 mux_index = MM_FILE_FORMAT_3GP;
2680         else if (!strcmp(name, "AMR"))
2681                 mux_index = MM_FILE_FORMAT_AMR;
2682         else if (!strcmp(name, "MP4"))
2683                 mux_index = MM_FILE_FORMAT_MP4;
2684         else if (!strcmp(name, "AAC"))
2685                 mux_index = MM_FILE_FORMAT_AAC;
2686         else if (!strcmp(name, "MP3"))
2687                 mux_index = MM_FILE_FORMAT_MP3;
2688         else if (!strcmp(name, "OGG"))
2689                 mux_index = MM_FILE_FORMAT_OGG;
2690         else if (!strcmp(name, "WAV"))
2691                 mux_index = MM_FILE_FORMAT_WAV;
2692         else if (!strcmp(name, "AVI"))
2693                 mux_index = MM_FILE_FORMAT_AVI;
2694         else if (!strcmp(name, "WMA"))
2695                 mux_index = MM_FILE_FORMAT_WMA;
2696         else if (!strcmp(name, "WMV"))
2697                 mux_index = MM_FILE_FORMAT_WMV;
2698         else if (!strcmp(name, "MID"))
2699                 mux_index = MM_FILE_FORMAT_MID;
2700         else if (!strcmp(name, "MMF"))
2701                 mux_index = MM_FILE_FORMAT_MMF;
2702         else if (!strcmp(name, "MATROSKA"))
2703                 mux_index = MM_FILE_FORMAT_MATROSKA;
2704         else if (!strcmp(name, "M2TS"))
2705                 mux_index = MM_FILE_FORMAT_M2TS;
2706
2707         /*_mmcam_dbg_log("mux index %d", mux_index);*/
2708
2709         return mux_index;
2710 }
2711
2712
2713 int
2714 _mmcamcorder_get_format(MMHandleType handle, int conf_category, const char *name)
2715 {
2716         int fmt = -1;
2717
2718         mmf_return_val_if_fail(name, -1);
2719
2720         switch (conf_category) {
2721         case CONFIGURE_CATEGORY_MAIN_AUDIO_ENCODER:
2722                 fmt = _mmcamcorder_get_audio_codec_format(handle, name);
2723                 break;
2724         case CONFIGURE_CATEGORY_MAIN_VIDEO_ENCODER:
2725                 fmt = _mmcamcorder_get_video_codec_format(handle, name);
2726                 break;
2727         case CONFIGURE_CATEGORY_MAIN_IMAGE_ENCODER:
2728                 fmt = _mmcamcorder_get_image_codec_format(handle, name);
2729                 break;
2730         case CONFIGURE_CATEGORY_MAIN_MUX:
2731                 fmt = _mmcamcorder_get_mux_format(handle, name);
2732                 break;
2733         default:
2734                 _mmcam_dbg_log("Can't get format from this category.(%d)", conf_category);
2735         }
2736
2737         return fmt;
2738 }
2739
2740 int
2741 _mmcamcorder_get_available_format(MMHandleType handle, int conf_category, int ** format)
2742 {
2743         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2744         camera_conf* configure_info = NULL;
2745         int *arr = NULL;
2746         int total_count = 0;
2747
2748         mmf_return_val_if_fail(hcamcorder, 0);
2749
2750         /*_mmcam_dbg_log("conf_category:%d", conf_category);*/
2751
2752         configure_info = hcamcorder->conf_main;
2753
2754         if (configure_info->info[conf_category]) {
2755                 int i = 0;
2756                 int fmt = 0;
2757                 const char *name = NULL;
2758                 int count = configure_info->info[conf_category]->count;
2759                 conf_detail *info = configure_info->info[conf_category];
2760
2761                 /*_mmcam_dbg_log("count[%d], info[%p]", count, info);*/
2762
2763                 if (count <= 0 || !info)
2764                         return total_count;
2765
2766                 arr = (int*) g_malloc0(count * sizeof(int));
2767                 if (arr == NULL) {
2768                         _mmcam_dbg_err("malloc failed : %zu", count * sizeof(int));
2769                         return 0;
2770                 }
2771
2772                 for (i = 0 ; i < count ; i++) {
2773                         if (info->detail_info[i] == NULL)
2774                                 continue;
2775
2776                         name = ((type_element*)(info->detail_info[i]))->name;
2777                         fmt = _mmcamcorder_get_format(handle, conf_category, name);
2778                         if (fmt >= 0)
2779                                 arr[total_count++] = fmt;
2780
2781                         /*_mmcam_dbg_log("name:%s, fmt:%d", name, fmt);*/
2782                 }
2783         }
2784
2785         *format = arr;
2786
2787         return total_count;
2788 }