e578ab8d44ca23920637fe496c55dec8da047f2a
[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                 { "SupportUserBuffer",  CONFIGURE_VALUE_INT,            {.value_int = 0} },
639         };
640
641         /* [AudioInput] matching table */
642         static conf_info_table conf_main_audio_input_table[] = {
643                 { "AudioDevice",          CONFIGURE_VALUE_INT_ARRAY, {NULL} },
644                 { "AudiosrcElement",      CONFIGURE_VALUE_ELEMENT, {&_audiosrc_element_default} },
645                 { "AudiomodemsrcElement", CONFIGURE_VALUE_ELEMENT, {&_audiomodemsrc_element_default} },
646                 { "AudioBufferInterval",  CONFIGURE_VALUE_INT,     {.value_int = DEFAULT_AUDIO_BUFFER_INTERVAL} },
647         };
648
649         /* [VideoOutput] matching table */
650         static conf_info_table conf_main_video_output_table[] = {
651                 { "DisplayDevice",           CONFIGURE_VALUE_INT_ARRAY, {NULL} },
652                 { "DisplayMode",             CONFIGURE_VALUE_INT_ARRAY, {NULL} },
653                 { "Videosink",               CONFIGURE_VALUE_INT_ARRAY, {NULL} },
654                 { "VideosinkElementOverlay", CONFIGURE_VALUE_ELEMENT,   {&_videosink_element_overlay_default} },
655                 { "VideosinkElementEvas",    CONFIGURE_VALUE_ELEMENT,   {&_videosink_element_evas_default} },
656                 { "VideosinkElementGL",      CONFIGURE_VALUE_ELEMENT,   {&_videosink_element_gl_default} },
657                 { "VideosinkElementRemote",  CONFIGURE_VALUE_ELEMENT,   {&_videosink_element_remote_default} },
658                 { "VideosinkElementNull",    CONFIGURE_VALUE_ELEMENT,   {&_videosink_element_null_default} },
659                 { "UseVideoscale",           CONFIGURE_VALUE_INT,       {.value_int = 0} },
660                 { "VideoscaleElement",       CONFIGURE_VALUE_ELEMENT,   {&_videoscale_element_default} },
661                 { "UseVideoconvert",         CONFIGURE_VALUE_INT,       {.value_int = 0} },
662                 { "VideoconvertElement",     CONFIGURE_VALUE_ELEMENT,   {&_videoconvert_element_default} },
663                 { "VideodecoderElementH264", CONFIGURE_VALUE_ELEMENT,   {&_videodecoder_element_h264_default} },
664                 { "RecreateDecoder",         CONFIGURE_VALUE_INT,       {.value_int = 0} }
665         };
666
667         /* [Capture] matching table */
668         static conf_info_table conf_main_capture_table[] = {
669                 { "UseEncodebin",           CONFIGURE_VALUE_INT,     {.value_int = 0} },
670                 { "UseCaptureMode",         CONFIGURE_VALUE_INT,     {.value_int = 0} },
671                 { "VideoscaleElement",      CONFIGURE_VALUE_ELEMENT, {&_videoscale_element_default} },
672                 { "PlayCaptureSound",       CONFIGURE_VALUE_INT,     {.value_int = 1} },
673         };
674
675         /* [Record] matching table */
676         static conf_info_table conf_main_record_table[] = {
677                 { "UseAudioEncoderQueue",   CONFIGURE_VALUE_INT,     {.value_int = 1} },
678                 { "UseVideoEncoderQueue",   CONFIGURE_VALUE_INT,     {.value_int = 1} },
679                 { "VideoProfile",           CONFIGURE_VALUE_INT,     {.value_int = 0} },
680                 { "VideoAutoAudioConvert",  CONFIGURE_VALUE_INT,     {.value_int = 0} },
681                 { "VideoAutoAudioResample", CONFIGURE_VALUE_INT,     {.value_int = 0} },
682                 { "VideoAutoColorSpace",    CONFIGURE_VALUE_INT,     {.value_int = 0} },
683                 { "AudioProfile",           CONFIGURE_VALUE_INT,     {.value_int = 0} },
684                 { "AudioAutoAudioConvert",  CONFIGURE_VALUE_INT,     {.value_int = 0} },
685                 { "AudioAutoAudioResample", CONFIGURE_VALUE_INT,     {.value_int = 0} },
686                 { "AudioAutoColorSpace",    CONFIGURE_VALUE_INT,     {.value_int = 0} },
687                 { "ImageProfile",           CONFIGURE_VALUE_INT,     {.value_int = 0} },
688                 { "ImageAutoAudioConvert",  CONFIGURE_VALUE_INT,     {.value_int = 0} },
689                 { "ImageAutoAudioResample", CONFIGURE_VALUE_INT,     {.value_int = 0} },
690                 { "ImageAutoColorSpace",    CONFIGURE_VALUE_INT,     {.value_int = 0} },
691                 { "RecordsinkElement",      CONFIGURE_VALUE_ELEMENT, {&_recordsink_element_default} },
692                 { "UseNoiseSuppressor",     CONFIGURE_VALUE_INT,     {.value_int = 0} },
693                 { "DropVideoFrame",         CONFIGURE_VALUE_INT,     {.value_int = 0} },
694                 { "PassFirstVideoFrame",    CONFIGURE_VALUE_INT,     {.value_int = 0} },
695                 { "SupportDualStream",      CONFIGURE_VALUE_INT,     {.value_int = FALSE} },
696         };
697
698         /* [VideoEncoder] matching table */
699         static conf_info_table conf_main_video_encoder_table[] = {
700                 { "H263",    CONFIGURE_VALUE_ELEMENT, {&_h263_element_default} },
701                 { "H264",    CONFIGURE_VALUE_ELEMENT, {&_h264_element_default} },
702                 { "H26L",    CONFIGURE_VALUE_ELEMENT, {&_h26l_element_default} },
703                 { "MPEG4",   CONFIGURE_VALUE_ELEMENT, {&_mpeg4_element_default} },
704                 { "MPEG1",   CONFIGURE_VALUE_ELEMENT, {&_mpeg1_element_default} },
705                 { "THEORA",  CONFIGURE_VALUE_ELEMENT, {&_theora_element_default} },
706         };
707
708         /* [AudioEncoder] matching table */
709         static conf_info_table conf_main_audio_encoder_table[] = {
710                 { "AMR",     CONFIGURE_VALUE_ELEMENT, {&_amr_element_default} },
711                 { "G723_1",  CONFIGURE_VALUE_ELEMENT, {&_g723_1_element_default} },
712                 { "MP3",     CONFIGURE_VALUE_ELEMENT, {&_mp3_element_default} },
713                 { "AAC",     CONFIGURE_VALUE_ELEMENT, {&_aac_element_default} },
714                 { "MMF",     CONFIGURE_VALUE_ELEMENT, {&_mmf_element_default} },
715                 { "ADPCM",   CONFIGURE_VALUE_ELEMENT, {&_adpcm_element_default} },
716                 { "WAVE",    CONFIGURE_VALUE_ELEMENT, {&_wave_element_default} },
717                 { "MIDI",    CONFIGURE_VALUE_ELEMENT, {&_midi_element_default} },
718                 { "IMELODY", CONFIGURE_VALUE_ELEMENT, {&_imelody_element_default} },
719                 { "VORBIS",  CONFIGURE_VALUE_ELEMENT, {&_vorbis_element_default} },
720         };
721
722         /* [ImageEncoder] matching table */
723         static conf_info_table conf_main_image_encoder_table[] = {
724                 { "JPEG", CONFIGURE_VALUE_ELEMENT, {&_jpeg_element_default} },
725                 { "PNG",  CONFIGURE_VALUE_ELEMENT, {&_png_element_default} },
726                 { "BMP",  CONFIGURE_VALUE_ELEMENT, {&_bmp_element_default} },
727                 { "WBMP", CONFIGURE_VALUE_ELEMENT, {&_wbmp_element_default} },
728                 { "TIFF", CONFIGURE_VALUE_ELEMENT, {&_tiff_element_default} },
729                 { "PCX",  CONFIGURE_VALUE_ELEMENT, {&_pcx_element_default} },
730                 { "GIF",  CONFIGURE_VALUE_ELEMENT, {&_gif_element_default} },
731                 { "ICO",  CONFIGURE_VALUE_ELEMENT, {&_ico_element_default} },
732                 { "RAS",  CONFIGURE_VALUE_ELEMENT, {&_ras_element_default} },
733                 { "TGA",  CONFIGURE_VALUE_ELEMENT, {&_tga_element_default} },
734                 { "XBM",  CONFIGURE_VALUE_ELEMENT, {&_xbm_element_default} },
735                 { "XPM",  CONFIGURE_VALUE_ELEMENT, {&_xpm_element_default} },
736         };
737
738         /* [Mux] matching table */
739         static conf_info_table conf_main_mux_table[] = {
740                 { "3GP",      CONFIGURE_VALUE_ELEMENT, {&_3gp_element_default} },
741                 { "AMR",      CONFIGURE_VALUE_ELEMENT, {&_amrmux_element_default} },
742                 { "MP4",      CONFIGURE_VALUE_ELEMENT, {&_mp4_element_default} },
743                 { "AAC",      CONFIGURE_VALUE_ELEMENT, {&_aacmux_element_default} },
744                 { "MP3",      CONFIGURE_VALUE_ELEMENT, {&_mp3mux_element_default} },
745                 { "OGG",      CONFIGURE_VALUE_ELEMENT, {&_ogg_element_default} },
746                 { "WAV",      CONFIGURE_VALUE_ELEMENT, {&_wav_element_default} },
747                 { "AVI",      CONFIGURE_VALUE_ELEMENT, {&_avi_element_default} },
748                 { "WMA",      CONFIGURE_VALUE_ELEMENT, {&_wma_element_default} },
749                 { "WMV",      CONFIGURE_VALUE_ELEMENT, {&_wmv_element_default} },
750                 { "MID",      CONFIGURE_VALUE_ELEMENT, {&_mid_element_default} },
751                 { "MMF",      CONFIGURE_VALUE_ELEMENT, {&_mmfmux_element_default} },
752                 { "MATROSKA", CONFIGURE_VALUE_ELEMENT, {&_matroska_element_default} },
753                 { "M2TS",     CONFIGURE_VALUE_ELEMENT, {&_m2ts_element_default} },
754         };
755
756
757         /*******************
758         *  Camera control *
759         *******************/
760
761         /* [Camera] matching table */
762         static conf_info_table conf_ctrl_camera_table[] = {
763                 { "InputIndex",           CONFIGURE_VALUE_INT_ARRAY,      {NULL} },
764                 { "DeviceName",           CONFIGURE_VALUE_STRING,         {NULL} },
765                 { "PreviewResolution",    CONFIGURE_VALUE_INT_PAIR_ARRAY, {NULL} },
766                 { "CaptureResolution",    CONFIGURE_VALUE_INT_PAIR_ARRAY, {NULL} },
767                 { "VideoResolution",      CONFIGURE_VALUE_INT_PAIR_ARRAY, {NULL} },
768                 { "FPS0",                 CONFIGURE_VALUE_INT_ARRAY,      {NULL} },
769                 { "FPS1",                 CONFIGURE_VALUE_INT_ARRAY,      {NULL} },
770                 { "FPS2",                 CONFIGURE_VALUE_INT_ARRAY,      {NULL} },
771                 { "FPS3",                 CONFIGURE_VALUE_INT_ARRAY,      {NULL} },
772                 { "FPS4",                 CONFIGURE_VALUE_INT_ARRAY,      {NULL} },
773                 { "FPS5",                 CONFIGURE_VALUE_INT_ARRAY,      {NULL} },
774                 { "FPS6",                 CONFIGURE_VALUE_INT_ARRAY,      {NULL} },
775                 { "FPS7",                 CONFIGURE_VALUE_INT_ARRAY,      {NULL} },
776                 { "FPS8",                 CONFIGURE_VALUE_INT_ARRAY,      {NULL} },
777                 { "FPS9",                 CONFIGURE_VALUE_INT_ARRAY,      {NULL} },
778                 { "PictureFormat",        CONFIGURE_VALUE_INT_ARRAY,      {NULL} },
779                 { "Overlay",              CONFIGURE_VALUE_INT_RANGE,      {NULL} },
780                 { "RecommendDisplayRotation", CONFIGURE_VALUE_INT,     {.value_int = 3} },
781                 { "RecommendPreviewFormatCapture", CONFIGURE_VALUE_INT, {.value_int = MM_PIXEL_FORMAT_YUYV} },
782                 { "RecommendPreviewFormatRecord",  CONFIGURE_VALUE_INT, {.value_int = MM_PIXEL_FORMAT_NV12} },
783                 { "RecommendPreviewResolution", CONFIGURE_VALUE_INT_PAIR_ARRAY, {NULL} },
784                 { "FacingDirection",      CONFIGURE_VALUE_INT, {.value_int = MM_CAMCORDER_CAMERA_FACING_DIRECTION_REAR} },
785                 { "FrameStabilityCount",  CONFIGURE_VALUE_INT,     {.value_int = 0} },
786         };
787
788         /* [Strobe] matching table */
789         static conf_info_table conf_ctrl_strobe_table[] = {
790                 { "StrobeControl",        CONFIGURE_VALUE_INT_ARRAY, {NULL} },
791                 { "StrobeMode",           CONFIGURE_VALUE_INT_ARRAY, {NULL} },
792                 { "StrobeEV",             CONFIGURE_VALUE_INT_RANGE, {NULL} },
793         };
794
795         /* [Effect] matching table */
796         static conf_info_table conf_ctrl_effect_table[] = {
797                 { "Brightness",           CONFIGURE_VALUE_INT_RANGE, {NULL} },
798                 { "BrightnessStepDenominator", CONFIGURE_VALUE_INT, {.value_int = 2} },
799                 { "Contrast",             CONFIGURE_VALUE_INT_RANGE, {NULL} },
800                 { "Saturation",           CONFIGURE_VALUE_INT_RANGE, {NULL} },
801                 { "Sharpness",            CONFIGURE_VALUE_INT_RANGE, {NULL} },
802                 { "Hue",                  CONFIGURE_VALUE_INT_RANGE, {NULL} },
803                 { "WhiteBalance",         CONFIGURE_VALUE_INT_ARRAY, {NULL} },
804                 { "ColorTone",            CONFIGURE_VALUE_INT_ARRAY, {NULL} },
805                 { "Flip",                 CONFIGURE_VALUE_INT_ARRAY, {NULL} },
806                 { "Rotation",             CONFIGURE_VALUE_INT_ARRAY, {NULL} },
807                 { "WDR",                  CONFIGURE_VALUE_INT_ARRAY, {NULL} },
808                 { "PartColorMode",        CONFIGURE_VALUE_INT_ARRAY, {NULL} },
809                 { "PartColor",            CONFIGURE_VALUE_INT_ARRAY, {NULL} },
810         };
811
812         /* [Photograph] matching table */
813         static conf_info_table conf_ctrl_photograph_table[] = {
814                 { "LensInit",             CONFIGURE_VALUE_INT_ARRAY, {NULL} },
815                 { "DigitalZoom",          CONFIGURE_VALUE_INT_RANGE, {NULL} },
816                 { "OpticalZoom",          CONFIGURE_VALUE_INT_RANGE, {NULL} },
817                 { "FocusMode",            CONFIGURE_VALUE_INT_ARRAY, {NULL} },
818                 { "AFType",               CONFIGURE_VALUE_INT_ARRAY, {NULL} },
819                 { "AEType",               CONFIGURE_VALUE_INT_ARRAY, {NULL} },
820                 { "ExposureValue",        CONFIGURE_VALUE_INT_RANGE, {NULL} },
821                 { "FNumber",              CONFIGURE_VALUE_INT_ARRAY, {NULL} },
822                 { "ShutterSpeed",         CONFIGURE_VALUE_INT_ARRAY, {NULL} },
823                 { "ISO",                  CONFIGURE_VALUE_INT_ARRAY, {NULL} },
824                 { "ProgramMode",          CONFIGURE_VALUE_INT_ARRAY, {NULL} },
825                 { "AntiHandshake",        CONFIGURE_VALUE_INT_ARRAY, {NULL} },
826                 { "VideoStabilization",   CONFIGURE_VALUE_INT_ARRAY, {NULL} },
827                 { "FaceZoomMode",         CONFIGURE_VALUE_INT_ARRAY, {NULL} },
828                 { "FaceZoomLevel",        CONFIGURE_VALUE_INT_RANGE, {NULL} },
829                 { "PtzType",              CONFIGURE_VALUE_INT_ARRAY, {NULL} },
830                 { "PanMecha",             CONFIGURE_VALUE_INT_RANGE, {NULL} },
831                 { "PanElec",              CONFIGURE_VALUE_INT_RANGE, {NULL} },
832                 { "TiltMecha",            CONFIGURE_VALUE_INT_RANGE, {NULL} },
833                 { "TiltElec",             CONFIGURE_VALUE_INT_RANGE, {NULL} },
834         };
835
836         /* [Capture] matching table */
837         static conf_info_table conf_ctrl_capture_table[] = {
838                 { "OutputMode",           CONFIGURE_VALUE_INT_ARRAY, {NULL} },
839                 { "JpegQuality",          CONFIGURE_VALUE_INT_RANGE, {NULL} },
840                 { "MultishotNumber",      CONFIGURE_VALUE_INT_RANGE, {NULL} },
841                 { "SensorEncodedCapture", CONFIGURE_VALUE_INT,       {.value_int = 1} },
842                 { "SupportHDR",           CONFIGURE_VALUE_INT_ARRAY, {NULL} },
843                 { "SupportZSL",           CONFIGURE_VALUE_INT,       {.value_int = FALSE} },
844                 { "FrameStabilityCount",  CONFIGURE_VALUE_INT,       {.value_int = 0} },
845         };
846
847         /* [Detect] matching table */
848         static conf_info_table conf_ctrl_detect_table[] = {
849                 { "DetectMode",           CONFIGURE_VALUE_INT_ARRAY, {NULL} },
850                 { "DetectNumber",         CONFIGURE_VALUE_INT_RANGE, {NULL} },
851                 { "DetectSelect",         CONFIGURE_VALUE_INT_RANGE, {NULL} },
852                 { "DetectSelectNumber",   CONFIGURE_VALUE_INT_RANGE, {NULL} },
853         };
854
855         _mmcam_dbg_log("Entered...");
856
857         if (type == CONFIGURE_TYPE_MAIN) {
858                 hcamcorder->conf_main_info_table[CONFIGURE_CATEGORY_MAIN_GENERAL]       = conf_main_general_table;
859                 hcamcorder->conf_main_info_table[CONFIGURE_CATEGORY_MAIN_VIDEO_INPUT]   = conf_main_video_input_table;
860                 hcamcorder->conf_main_info_table[CONFIGURE_CATEGORY_MAIN_AUDIO_INPUT]   = conf_main_audio_input_table;
861                 hcamcorder->conf_main_info_table[CONFIGURE_CATEGORY_MAIN_VIDEO_OUTPUT]  = conf_main_video_output_table;
862                 hcamcorder->conf_main_info_table[CONFIGURE_CATEGORY_MAIN_CAPTURE]       = conf_main_capture_table;
863                 hcamcorder->conf_main_info_table[CONFIGURE_CATEGORY_MAIN_RECORD]        = conf_main_record_table;
864                 hcamcorder->conf_main_info_table[CONFIGURE_CATEGORY_MAIN_VIDEO_ENCODER] = conf_main_video_encoder_table;
865                 hcamcorder->conf_main_info_table[CONFIGURE_CATEGORY_MAIN_AUDIO_ENCODER] = conf_main_audio_encoder_table;
866                 hcamcorder->conf_main_info_table[CONFIGURE_CATEGORY_MAIN_IMAGE_ENCODER] = conf_main_image_encoder_table;
867                 hcamcorder->conf_main_info_table[CONFIGURE_CATEGORY_MAIN_MUX]           = conf_main_mux_table;
868
869                 hcamcorder->conf_main_category_size[CONFIGURE_CATEGORY_MAIN_GENERAL]       = sizeof(conf_main_general_table) / info_table_size;
870                 hcamcorder->conf_main_category_size[CONFIGURE_CATEGORY_MAIN_VIDEO_INPUT]   = sizeof(conf_main_video_input_table) / info_table_size;
871                 hcamcorder->conf_main_category_size[CONFIGURE_CATEGORY_MAIN_AUDIO_INPUT]   = sizeof(conf_main_audio_input_table) / info_table_size;
872                 hcamcorder->conf_main_category_size[CONFIGURE_CATEGORY_MAIN_VIDEO_OUTPUT]  = sizeof(conf_main_video_output_table) / info_table_size;
873                 hcamcorder->conf_main_category_size[CONFIGURE_CATEGORY_MAIN_CAPTURE]       = sizeof(conf_main_capture_table) / info_table_size;
874                 hcamcorder->conf_main_category_size[CONFIGURE_CATEGORY_MAIN_RECORD]        = sizeof(conf_main_record_table) / info_table_size;
875                 hcamcorder->conf_main_category_size[CONFIGURE_CATEGORY_MAIN_VIDEO_ENCODER] = sizeof(conf_main_video_encoder_table) / info_table_size;
876                 hcamcorder->conf_main_category_size[CONFIGURE_CATEGORY_MAIN_AUDIO_ENCODER] = sizeof(conf_main_audio_encoder_table) / info_table_size;
877                 hcamcorder->conf_main_category_size[CONFIGURE_CATEGORY_MAIN_IMAGE_ENCODER] = sizeof(conf_main_image_encoder_table) / info_table_size;
878                 hcamcorder->conf_main_category_size[CONFIGURE_CATEGORY_MAIN_MUX]           = sizeof(conf_main_mux_table) / info_table_size;
879
880                 category_num = CONFIGURE_CATEGORY_MAIN_NUM;
881         } else {
882                 hcamcorder->conf_ctrl_info_table[CONFIGURE_CATEGORY_CTRL_CAMERA]     = conf_ctrl_camera_table;
883                 hcamcorder->conf_ctrl_info_table[CONFIGURE_CATEGORY_CTRL_STROBE]     = conf_ctrl_strobe_table;
884                 hcamcorder->conf_ctrl_info_table[CONFIGURE_CATEGORY_CTRL_EFFECT]     = conf_ctrl_effect_table;
885                 hcamcorder->conf_ctrl_info_table[CONFIGURE_CATEGORY_CTRL_PHOTOGRAPH] = conf_ctrl_photograph_table;
886                 hcamcorder->conf_ctrl_info_table[CONFIGURE_CATEGORY_CTRL_CAPTURE]    = conf_ctrl_capture_table;
887                 hcamcorder->conf_ctrl_info_table[CONFIGURE_CATEGORY_CTRL_DETECT]     = conf_ctrl_detect_table;
888
889                 hcamcorder->conf_ctrl_category_size[CONFIGURE_CATEGORY_CTRL_CAMERA]     = sizeof(conf_ctrl_camera_table) / info_table_size;
890                 hcamcorder->conf_ctrl_category_size[CONFIGURE_CATEGORY_CTRL_STROBE]     = sizeof(conf_ctrl_strobe_table) / info_table_size;
891                 hcamcorder->conf_ctrl_category_size[CONFIGURE_CATEGORY_CTRL_EFFECT]     = sizeof(conf_ctrl_effect_table) / info_table_size;
892                 hcamcorder->conf_ctrl_category_size[CONFIGURE_CATEGORY_CTRL_PHOTOGRAPH] = sizeof(conf_ctrl_photograph_table) / info_table_size;
893                 hcamcorder->conf_ctrl_category_size[CONFIGURE_CATEGORY_CTRL_CAPTURE]    = sizeof(conf_ctrl_capture_table) / info_table_size;
894                 hcamcorder->conf_ctrl_category_size[CONFIGURE_CATEGORY_CTRL_DETECT]     = sizeof(conf_ctrl_detect_table) / info_table_size;
895
896                 category_num = CONFIGURE_CATEGORY_CTRL_NUM;
897         }
898
899         configure_info->info = (conf_detail **)g_malloc0(sizeof(conf_detail *) * category_num);
900         if (configure_info->info == NULL) {
901                 _mmcam_dbg_err("category info alloc failed : type %d", type);
902                 return MM_ERROR_CAMCORDER_LOW_MEMORY;
903         }
904
905         _mmcam_dbg_log("Done.");
906
907         return MM_ERROR_NONE;
908 }
909
910
911 int _mmcamcorder_conf_get_info(MMHandleType handle, int type, const char *ConfFile, camera_conf **configure_info)
912 {
913         int ret = MM_ERROR_NONE;
914         FILE *fp = NULL;
915         char conf_path[60] = {'\0',};
916
917         _mmcam_dbg_log("Opening...[%s]", ConfFile);
918
919         mmf_return_val_if_fail(ConfFile, FALSE);
920
921         snprintf(conf_path, sizeof(conf_path), "%s/multimedia/%s", SYSCONFDIR, ConfFile);
922         _mmcam_dbg_log("Try open Configure File[%s]", conf_path);
923
924         fp = fopen(conf_path, "r");
925         if (!fp) {
926                 _mmcam_dbg_warn("File open failed.[%s] retry...", conf_path);
927
928                 snprintf(conf_path, sizeof(conf_path), "%s/multimedia/%s", TZ_SYS_ETC, ConfFile);
929                 _mmcam_dbg_log("Try open Configure File[%s]", conf_path);
930                 fp = fopen(conf_path, "r");
931                 if (!fp) {
932                         _mmcam_dbg_warn("open failed.[%s] errno [%d]", conf_path, errno);
933                         ret = MM_ERROR_CAMCORDER_NOT_SUPPORTED;
934                 }
935         }
936
937         if (fp) {
938                 ret = _mmcamcorder_conf_parse_info(handle, type, fp, configure_info);
939                 fclose(fp);
940         }
941
942         _mmcam_dbg_log("Leave [0x%x]", ret);
943
944         return ret;
945 }
946
947
948 int _mmcamcorder_conf_parse_info(MMHandleType handle, int type, FILE *fp, camera_conf **configure_info)
949 {
950         const unsigned int BUFFER_NUM_DETAILS = 256;
951         const unsigned int BUFFER_NUM_TOKEN = 20;
952         size_t BUFFER_LENGTH_STRING = 256;
953         const char* delimiters = " |=,\t\n";
954
955         int i = 0;
956         int ret = MM_ERROR_NONE;
957         int category = 0;
958         int count_main_category = 0;
959         int count_details = 0;
960         int length_read = 0;
961         int count_token = 0;
962         int read_main = 0;
963
964         char *buffer_string = NULL;
965         char *buffer_details[BUFFER_NUM_DETAILS];
966         char *buffer_token[BUFFER_NUM_TOKEN];
967         char *token = NULL;
968         char *category_name = NULL;
969         char *detail_string = NULL;
970         char *user_ptr = NULL;
971
972         camera_conf *new_conf = NULL;
973
974         _mmcam_dbg_log("");
975
976         mmf_return_val_if_fail(handle && fp && configure_info, MM_ERROR_INVALID_ARGUMENT);
977
978         *configure_info = NULL;
979
980         new_conf = (camera_conf *)g_malloc0(sizeof(camera_conf));
981         if (new_conf == NULL) {
982                 _mmcam_dbg_err("new_conf alloc failed : %zu", sizeof(camera_conf));
983                 return MM_ERROR_CAMCORDER_LOW_MEMORY;
984         }
985
986         buffer_string = (char*)g_malloc0(sizeof(char) * BUFFER_LENGTH_STRING);
987         if (buffer_string == NULL) {
988                 _mmcam_dbg_err("buffer_string alloc failed : %zu", sizeof(char) * BUFFER_LENGTH_STRING);
989                 g_free(new_conf);
990                 return MM_ERROR_CAMCORDER_LOW_MEMORY;
991         }
992
993         new_conf->type  = type;
994
995         ret = _mmcamcorder_conf_init(handle, type, new_conf);
996         if (ret != MM_ERROR_NONE) {
997                 _mmcam_dbg_err("conf init failed 0x%x", ret);
998                 g_free(new_conf);
999                 g_free(buffer_string);
1000                 return ret;
1001         }
1002
1003         *configure_info = new_conf;
1004
1005         read_main = 0;
1006         count_main_category = 0;
1007
1008         while (!feof(fp)) {
1009                 if (read_main == 0) {
1010                         length_read = getline(&buffer_string, &BUFFER_LENGTH_STRING, fp);
1011                         /*_mmcam_dbg_log( "Read Line : [%s]", buffer_string );*/
1012
1013                         count_token = 0;
1014                         token = strtok_r(buffer_string, delimiters, &user_ptr);
1015
1016                         if ((token) && (token[0] == ';') && (length_read > -1)) {
1017                                 /*_mmcam_dbg_log( "Comment - Nothing to do" );*/
1018                                 continue;
1019                         }
1020
1021                         while (token) {
1022                                 /*_mmcam_dbg_log("token : [%s]", token);*/
1023                                 buffer_token[count_token] = token;
1024                                 count_token++;
1025                                 token = strtok_r(NULL, delimiters, &user_ptr);
1026                         }
1027
1028                         if (count_token == 0)
1029                                 continue;
1030                 }
1031
1032                 read_main = 0;
1033
1034                 if (*buffer_token[0] == ';') {
1035                         /* Comment */
1036                         /*_mmcam_dbg_log( "Comment - Nothing to do" );*/
1037                 } else if (*buffer_token[0] == '[') {
1038                         /* Main Category */
1039                         category_name = get_new_string(buffer_token[0]);
1040                         if (category_name == NULL) {
1041                                 _mmcam_dbg_err("strdup failed for [%s]", buffer_token[0]);
1042                                 continue;
1043                         }
1044
1045                         count_main_category++;
1046                         count_details = 0;
1047
1048                         while (!feof(fp)) {
1049                                 length_read = getline(&buffer_string, &BUFFER_LENGTH_STRING, fp);
1050                                 /*_mmcam_dbg_log("Read Detail Line : [%s], read length : [%d]", buffer_string, length_read);*/
1051
1052                                 detail_string = get_new_string(buffer_string);
1053
1054                                 token = strtok_r(buffer_string, delimiters, &user_ptr);
1055
1056                                 if (token && token[0] != ';' && length_read > -1) {
1057                                         /*_mmcam_dbg_log("token : [%s]", token);*/
1058                                         if (token[0] == '[') {
1059                                                 read_main = 1;
1060                                                 buffer_token[0] = token;
1061                                                 SAFE_G_FREE(detail_string);
1062                                                 break;
1063                                         }
1064
1065                                         buffer_details[count_details++] = detail_string;
1066                                 } else {
1067                                         SAFE_G_FREE(detail_string);
1068                                 }
1069                         }
1070
1071                         /*_mmcam_dbg_log("type : %d, category_name : %s, count : [%d]", type, category_name, count_details);*/
1072
1073                         if (count_details == 0) {
1074                                 _mmcam_dbg_warn("category %s has no detail value... skip this category...", category_name);
1075                                 SAFE_G_FREE(category_name);
1076                                 continue;
1077                         }
1078
1079                         category = -1;
1080
1081                         /* Details */
1082                         if (type == CONFIGURE_TYPE_MAIN) {
1083                                 if (!strcmp("[General]", category_name))
1084                                         category = CONFIGURE_CATEGORY_MAIN_GENERAL;
1085                                 else if (!strcmp("[VideoInput]", category_name))
1086                                         category = CONFIGURE_CATEGORY_MAIN_VIDEO_INPUT;
1087                                 else if (!strcmp("[AudioInput]", category_name))
1088                                         category = CONFIGURE_CATEGORY_MAIN_AUDIO_INPUT;
1089                                 else if (!strcmp("[VideoOutput]", category_name))
1090                                         category = CONFIGURE_CATEGORY_MAIN_VIDEO_OUTPUT;
1091                                 else if (!strcmp("[Capture]", category_name))
1092                                         category = CONFIGURE_CATEGORY_MAIN_CAPTURE;
1093                                 else if (!strcmp("[Record]", category_name))
1094                                         category = CONFIGURE_CATEGORY_MAIN_RECORD;
1095                                 else if (!strcmp("[VideoEncoder]", category_name))
1096                                         category = CONFIGURE_CATEGORY_MAIN_VIDEO_ENCODER;
1097                                 else if (!strcmp("[AudioEncoder]", category_name))
1098                                         category = CONFIGURE_CATEGORY_MAIN_AUDIO_ENCODER;
1099                                 else if (!strcmp("[ImageEncoder]", category_name))
1100                                         category = CONFIGURE_CATEGORY_MAIN_IMAGE_ENCODER;
1101                                 else if (!strcmp("[Mux]", category_name))
1102                                         category = CONFIGURE_CATEGORY_MAIN_MUX;
1103                         } else {
1104                                 if (!strcmp("[Camera]", category_name))
1105                                         category = CONFIGURE_CATEGORY_CTRL_CAMERA;
1106                                 else if (!strcmp("[Strobe]", category_name))
1107                                         category = CONFIGURE_CATEGORY_CTRL_STROBE;
1108                                 else if (!strcmp("[Effect]", category_name))
1109                                         category = CONFIGURE_CATEGORY_CTRL_EFFECT;
1110                                 else if (!strcmp("[Photograph]", category_name))
1111                                         category = CONFIGURE_CATEGORY_CTRL_PHOTOGRAPH;
1112                                 else if (!strcmp("[Capture]", category_name))
1113                                         category = CONFIGURE_CATEGORY_CTRL_CAPTURE;
1114                                 else if (!strcmp("[Detect]", category_name))
1115                                         category = CONFIGURE_CATEGORY_CTRL_DETECT;
1116                         }
1117
1118                         if (category != -1) {
1119                                 _mmcamcorder_conf_add_info(handle, type, &(new_conf->info[category]),
1120                                                                                         buffer_details, category, count_details);
1121                         } else {
1122                                 _mmcam_dbg_warn("No matched category[%s],type[%d]... check it.", category_name, type);
1123                         }
1124
1125                         /* Free memory */
1126                         for (i = 0 ; i < count_details ; i++)
1127                                 SAFE_G_FREE(buffer_details[i]);
1128                 }
1129
1130                 SAFE_G_FREE(category_name);
1131         }
1132
1133         /* (*configure_info) = new_conf; */
1134
1135         SAFE_G_FREE(buffer_string);
1136
1137         /*_mmcam_dbg_log("Done.");*/
1138
1139         return MM_ERROR_NONE;
1140 }
1141
1142
1143 void _mmcamcorder_conf_release_info(MMHandleType handle, camera_conf **configure_info)
1144 {
1145         int i = 0;
1146         int j = 0;
1147         int k = 0;
1148         int type = CONFIGURE_VALUE_INT;
1149         int count = 0;
1150         int category_num = CONFIGURE_CATEGORY_MAIN_NUM;
1151         camera_conf *temp_conf = (*configure_info);
1152
1153         type_int2 *temp_int = NULL;
1154         type_int_range *temp_int_range = NULL;
1155         type_int_array *temp_int_array = NULL;
1156         type_int_pair_array *temp_int_pair_array = NULL;
1157         type_string2 *temp_string = NULL;
1158         type_string_array *temp_string_array = NULL;
1159         type_element2 *temp_element = NULL;
1160
1161         _mmcam_dbg_log("Entered...");
1162
1163         mmf_return_if_fail(temp_conf);
1164
1165         if ((*configure_info)->type == CONFIGURE_TYPE_MAIN)
1166                 category_num = CONFIGURE_CATEGORY_MAIN_NUM;
1167         else
1168                 category_num = CONFIGURE_CATEGORY_CTRL_NUM;
1169
1170         for (i = 0 ; i < category_num ; i++) {
1171                 if (temp_conf->info[i]) {
1172                         for (j = 0 ; j < temp_conf->info[i]->count ; j++) {
1173                                 if (temp_conf->info[i]->detail_info[j] == NULL)
1174                                         continue;
1175
1176                                 if (_mmcamcorder_conf_get_value_type(handle, temp_conf->type, i, ((type_element*)(temp_conf->info[i]->detail_info[j]))->name, &type)) {
1177                                         switch (type) {
1178                                         case CONFIGURE_VALUE_INT:
1179                                                 temp_int = (type_int2*)(temp_conf->info[i]->detail_info[j]);
1180                                                 SAFE_G_FREE(temp_int->name);
1181                                                 break;
1182                                         case CONFIGURE_VALUE_INT_RANGE:
1183                                                 temp_int_range = (type_int_range*)(temp_conf->info[i]->detail_info[j]);
1184                                                 SAFE_G_FREE(temp_int_range->name);
1185                                                 break;
1186                                         case CONFIGURE_VALUE_INT_ARRAY:
1187                                                 temp_int_array = (type_int_array*)(temp_conf->info[i]->detail_info[j]);
1188                                                 SAFE_G_FREE(temp_int_array->name);
1189                                                 SAFE_G_FREE(temp_int_array->value);
1190                                                 break;
1191                                         case CONFIGURE_VALUE_INT_PAIR_ARRAY:
1192                                                 temp_int_pair_array = (type_int_pair_array*)(temp_conf->info[i]->detail_info[j]);
1193                                                 SAFE_G_FREE(temp_int_pair_array->name);
1194                                                 SAFE_G_FREE(temp_int_pair_array->value[0]);
1195                                                 SAFE_G_FREE(temp_int_pair_array->value[1]);
1196                                                 break;
1197                                         case CONFIGURE_VALUE_STRING:
1198                                                 temp_string = (type_string2*)(temp_conf->info[i]->detail_info[j]);
1199                                                 SAFE_G_FREE(temp_string->name);
1200                                                 SAFE_G_FREE(temp_string->value);
1201                                                 break;
1202                                         case CONFIGURE_VALUE_STRING_ARRAY:
1203                                                 temp_string_array = (type_string_array*)(temp_conf->info[i]->detail_info[j]);
1204                                                 SAFE_G_FREE(temp_string_array->name);
1205                                                 if (temp_string_array->value) {
1206                                                         count = temp_string_array->count;
1207
1208                                                         for (k = 0 ; k < count ; k++)
1209                                                                 SAFE_G_FREE(temp_string_array->value[k]);
1210
1211                                                         SAFE_G_FREE(temp_string_array->value);
1212                                                 }
1213                                                 SAFE_G_FREE(temp_string_array->default_value);
1214                                                 break;
1215                                         case CONFIGURE_VALUE_ELEMENT:
1216                                                 temp_element = (type_element2*)(temp_conf->info[i]->detail_info[j]);
1217                                                 SAFE_G_FREE(temp_element->name);
1218                                                 SAFE_G_FREE(temp_element->element_name);
1219
1220                                                 if (temp_element->value_int) {
1221                                                         count = temp_element->count_int;
1222                                                         for (k = 0 ; k < count ; k++) {
1223                                                                 SAFE_G_FREE(temp_element->value_int[k]->name);
1224                                                                 SAFE_G_FREE(temp_element->value_int[k]);
1225                                                         }
1226                                                         SAFE_G_FREE(temp_element->value_int);
1227                                                 }
1228
1229                                                 if (temp_element->value_string) {
1230                                                         count = temp_element->count_string;
1231                                                         for (k = 0 ; k < count ; k++) {
1232                                                                 SAFE_G_FREE(temp_element->value_string[k]->name);
1233                                                                 SAFE_G_FREE(temp_element->value_string[k]->value);
1234                                                                 SAFE_G_FREE(temp_element->value_string[k]);
1235                                                         }
1236                                                         SAFE_G_FREE(temp_element->value_string);
1237                                                 }
1238                                                 break;
1239                                         default:
1240                                                 _mmcam_dbg_warn("unknown type %d", type);
1241                                                 break;
1242                                         }
1243                                 }
1244
1245                                 SAFE_G_FREE(temp_conf->info[i]->detail_info[j]);
1246                         }
1247
1248                         SAFE_G_FREE(temp_conf->info[i]->detail_info);
1249
1250                         SAFE_G_FREE(temp_conf->info[i]);
1251                         temp_conf->info[i] = NULL;
1252                 }
1253         }
1254
1255         SAFE_G_FREE((*configure_info)->info);
1256         SAFE_G_FREE((*configure_info));
1257
1258         _mmcam_dbg_log("Done.");
1259 }
1260
1261 int _mmcamcorder_conf_get_value_type(MMHandleType handle, int type, int category, const char* name, int* value_type)
1262 {
1263         int i = 0;
1264         int count_value = 0;
1265
1266         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
1267
1268         if (hcamcorder == NULL) {
1269                 _mmcam_dbg_err("handle is NULL");
1270                 return FALSE;
1271         }
1272
1273         /*_mmcam_dbg_log("Entered...");*/
1274
1275         mmf_return_val_if_fail(name, FALSE);
1276
1277         if (!_mmcamcorder_conf_get_category_size(handle, type, category, &count_value)) {
1278                 _mmcam_dbg_warn("No matched category... check it... categoty[%d]", category);
1279                 return FALSE;
1280         }
1281
1282         /*_mmcam_dbg_log("Number of value : [%d]", count_value);*/
1283
1284         if (type == CONFIGURE_TYPE_MAIN) {
1285                 for (i = 0 ; i < count_value ; i++) {
1286                         if (!strcmp(hcamcorder->conf_main_info_table[category][i].name, name)) {
1287                                 *value_type = hcamcorder->conf_main_info_table[category][i].value_type;
1288                                 /*_mmcam_dbg_log("Category[%d],Name[%s],Type[%d]", category, name, *value_type);*/
1289                                 return TRUE;
1290                         }
1291                 }
1292         } else {
1293                 for (i = 0 ; i < count_value ; i++) {
1294                         if (!strcmp(hcamcorder->conf_ctrl_info_table[category][i].name, name)) {
1295                                 *value_type = hcamcorder->conf_ctrl_info_table[category][i].value_type;
1296                                 /*_mmcam_dbg_log("Category[%d],Name[%s],Type[%d]", category, name, *value_type);*/
1297                                 return TRUE;
1298                         }
1299                 }
1300         }
1301
1302         return FALSE;
1303 }
1304
1305
1306 int _mmcamcorder_conf_add_info(MMHandleType handle, int type, conf_detail **info, char **buffer_details, int category, int count_details)
1307 {
1308         const int BUFFER_NUM_TOKEN = 256;
1309
1310         int i = 0;
1311         int j = 0;
1312         int count_token;
1313         int value_type;
1314         char *token = NULL;
1315         char *buffer_token[BUFFER_NUM_TOKEN];
1316         char *user_ptr = NULL;
1317
1318         const char *delimiters     = " |=,\t\n";
1319         const char *delimiters_sub = " |\t\n";
1320         const char *delimiters_3rd = "|\n";
1321
1322         mmf_return_val_if_fail(info && buffer_details, FALSE);
1323
1324         (*info) = (conf_detail*)g_malloc0(sizeof(conf_detail));
1325         if (*info == NULL) {
1326                 _mmcam_dbg_err("info allo failed");
1327                 return FALSE;
1328         }
1329         (*info)->detail_info = (void**)g_malloc0(sizeof(void*) * count_details);
1330         (*info)->count = count_details;
1331
1332         if ((*info)->detail_info == NULL) {
1333                 _mmcam_dbg_err("detail_info alloc failed");
1334                 g_free(*info);
1335                 *info = NULL;
1336                 return FALSE;
1337         }
1338
1339         for (i = 0 ; i < count_details ; i++) {
1340                 /*_mmcam_dbg_log("Read line\"%s\"", buffer_details[i]);*/
1341                 count_token = 0;
1342                 token = strtok_r(buffer_details[i], delimiters, &user_ptr);
1343
1344                 if (token) {
1345                         buffer_token[count_token] = token;
1346                         count_token++;
1347                 } else {
1348                         (*info)->detail_info[i] = NULL;
1349                         _mmcam_dbg_warn("No token... check it.[%s]", buffer_details[i]);
1350                         continue;
1351                 }
1352
1353                 if (!_mmcamcorder_conf_get_value_type(handle, type, category, buffer_token[0], &value_type)) {
1354                         (*info)->detail_info[i] = NULL;
1355                         _mmcam_dbg_warn("Failed to get value type... check it. Category[%d],Name[%s]", category, buffer_token[0]);
1356                         continue;
1357                 }
1358
1359                 if (value_type != CONFIGURE_VALUE_STRING && value_type != CONFIGURE_VALUE_STRING_ARRAY) {
1360                         token = strtok_r(NULL, delimiters, &user_ptr);
1361                         while (token) {
1362                                 buffer_token[count_token] = token;
1363                                 /*_mmcam_dbg_log("token : [%s]", buffer_token[count_token]);*/
1364                                 count_token++;
1365                                 token = strtok_r(NULL, delimiters, &user_ptr);
1366                         }
1367
1368                         if (count_token < 2) {
1369                                 (*info)->detail_info[i] = NULL;
1370                                 _mmcam_dbg_warn("Number of token is too small... check it.[%s]", buffer_details[i]);
1371                                 continue;
1372                         }
1373                 } else { /* CONFIGURE_VALUE_STRING or CONFIGURE_VALUE_STRING_ARRAY */
1374                         /* skip "=" */
1375                         strtok_r(NULL, delimiters_sub, &user_ptr);
1376
1377                         if (value_type == CONFIGURE_VALUE_STRING_ARRAY) {
1378                                 token = strtok_r(NULL, delimiters_sub, &user_ptr);
1379                                 while (token) {
1380                                         buffer_token[count_token] = token;
1381                                         /*_mmcam_dbg_log("token : [%s]", buffer_token[count_token]);*/
1382                                         count_token++;
1383                                         token = strtok_r(NULL, delimiters_sub, &user_ptr);
1384                                 }
1385                         } else { /* CONFIGURE_VALUE_STRING */
1386                                 token = strtok_r(NULL, delimiters_3rd, &user_ptr);
1387                                 if (token) {
1388                                         g_strchug(token);
1389                                         buffer_token[count_token] = token;
1390                                         /*_mmcam_dbg_log("token : [%s]", buffer_token[count_token]);*/
1391                                         count_token++;
1392                                 }
1393                         }
1394
1395                         if (count_token < 2) {
1396                                 (*info)->detail_info[i] = NULL;
1397                                 _mmcam_dbg_warn("No string value... check it.[%s]", buffer_details[i]);
1398                                 continue;
1399                         }
1400                 }
1401
1402                 switch (value_type) {
1403                 case CONFIGURE_VALUE_INT:
1404                 {
1405                         type_int2* new_int;
1406
1407                         new_int = (type_int2*)g_malloc0(sizeof(type_int2));
1408                         if (new_int == NULL) {
1409                                 _mmcam_dbg_err("allocation failed");
1410                                 break;
1411                         }
1412                         new_int->name  = get_new_string(buffer_token[0]);
1413                         new_int->value = atoi(buffer_token[1]);
1414                         (*info)->detail_info[i] = (void*)new_int;
1415                         /*_mmcam_dbg_log("INT - name[%s],value[%d]", new_int->name, new_int->value);*/
1416                         break;
1417                 }
1418                 case CONFIGURE_VALUE_INT_RANGE:
1419                 {
1420                         type_int_range* new_int_range;
1421
1422                         new_int_range = (type_int_range*)g_malloc0(sizeof(type_int_range));
1423                         if (new_int_range == NULL) {
1424                                 _mmcam_dbg_err("allocation failed");
1425                                 break;
1426                         }
1427                         new_int_range->name          = get_new_string(buffer_token[0]);
1428                         new_int_range->min           = atoi(buffer_token[1]);
1429                         new_int_range->max           = atoi(buffer_token[2]);
1430                         new_int_range->default_value = atoi(buffer_token[3]);
1431                         (*info)->detail_info[i]      = (void*)new_int_range;
1432                         /*
1433                         _mmcam_dbg_log("INT RANGE - name[%s],min[%d],max[%d],default[%d]",
1434                                 new_int_range->name,
1435                                 new_int_range->min,
1436                                 new_int_range->max,
1437                                 new_int_range->default_value);
1438                         */
1439                         break;
1440                 }
1441                 case CONFIGURE_VALUE_INT_ARRAY:
1442                 {
1443                         int count_value = count_token - 2;
1444                         type_int_array* new_int_array;
1445
1446                         new_int_array = (type_int_array*)g_malloc0(sizeof(type_int_array));
1447                         if (new_int_array == NULL) {
1448                                 _mmcam_dbg_err("allocation failed");
1449                                 break;
1450                         }
1451                         new_int_array->name = get_new_string(buffer_token[0]);
1452                         new_int_array->value = (int*)g_malloc0(sizeof(int)*count_value);
1453                         if (new_int_array->value == NULL) {
1454                                 SAFE_G_FREE(new_int_array->name);
1455                                 SAFE_G_FREE(new_int_array);
1456                                 _mmcam_dbg_err("allocation failed");
1457                                 break;
1458                         }
1459                         new_int_array->count = count_value;
1460
1461                         /*_mmcam_dbg_log("INT ARRAY - name[%s]", new_int_array->name);*/
1462                         for (j = 0 ; j < count_value ; j++) {
1463                                 new_int_array->value[j] = atoi(buffer_token[j+1]);
1464                                 /*_mmcam_dbg_log("   index[%d] - value[%d]", j, new_int_array->value[j]);*/
1465                         }
1466
1467                         new_int_array->default_value = atoi(buffer_token[count_token-1]);
1468                         /*_mmcam_dbg_log("   default value[%d]", new_int_array->default_value);*/
1469
1470                         (*info)->detail_info[i] = (void*)new_int_array;
1471                         break;
1472                 }
1473                 case CONFIGURE_VALUE_INT_PAIR_ARRAY:
1474                 {
1475                         int count_value = (count_token - 3) >> 1;
1476                         type_int_pair_array* new_int_pair_array;
1477
1478                         new_int_pair_array = (type_int_pair_array*)g_malloc0(sizeof(type_int_pair_array));
1479                         if (new_int_pair_array == NULL) {
1480                                 _mmcam_dbg_err("allocation failed");
1481                                 break;
1482                         }
1483                         new_int_pair_array->name = get_new_string(buffer_token[0]);
1484                         new_int_pair_array->value[0] = (int*)g_malloc0(sizeof(int)*(count_value));
1485                         if (new_int_pair_array->value[0] == NULL) {
1486                                 SAFE_G_FREE(new_int_pair_array->name);
1487                                 SAFE_G_FREE(new_int_pair_array);
1488                                 _mmcam_dbg_err("allocation failed");
1489                                 break;
1490                         }
1491                         new_int_pair_array->value[1] = (int*)g_malloc0(sizeof(int)*(count_value));
1492                         if (new_int_pair_array->value[1] == NULL) {
1493                                 SAFE_G_FREE(new_int_pair_array->value[0]);
1494                                 SAFE_G_FREE(new_int_pair_array->name);
1495                                 SAFE_G_FREE(new_int_pair_array);
1496                                 _mmcam_dbg_err("allocation failed");
1497                                 break;
1498                         }
1499                         new_int_pair_array->count    = count_value;
1500
1501                         /*_mmcam_dbg_log("INT PAIR ARRAY - name[%s],count[%d]", new_int_pair_array->name, count_value);*/
1502                         for (j = 0 ; j < count_value ; j++) {
1503                                 new_int_pair_array->value[0][j] = atoi(buffer_token[(j<<1)+1]);
1504                                 new_int_pair_array->value[1][j] = atoi(buffer_token[(j<<1)+2]);
1505                                 /*
1506                                 _mmcam_dbg_log("   index[%d] - value[%d,%d]", j,
1507                                         new_int_pair_array->value[0][j],
1508                                         new_int_pair_array->value[1][j]);
1509                                 */
1510                         }
1511
1512                         new_int_pair_array->default_value[0] = atoi(buffer_token[count_token-2]);
1513                         new_int_pair_array->default_value[1] = atoi(buffer_token[count_token-1]);
1514                         /*
1515                         _mmcam_dbg_log("   default value[%d,%d]",
1516                                 new_int_pair_array->default_value[0],
1517                                 new_int_pair_array->default_value[1]);
1518                         */
1519                         (*info)->detail_info[i] = (void*)new_int_pair_array;
1520                         break;
1521                 }
1522                 case CONFIGURE_VALUE_STRING:
1523                 {
1524                         type_string2* new_string;
1525
1526                         new_string = (type_string2*)g_malloc0(sizeof(type_string2));
1527                         if (new_string == NULL) {
1528                                 _mmcam_dbg_err("allocation failed");
1529                                 break;
1530                         }
1531                         new_string->name  = get_new_string(buffer_token[0]);
1532                         new_string->value = get_new_string(buffer_token[1]);
1533                         (*info)->detail_info[i] = (void*)new_string;
1534
1535                         /*_mmcam_dbg_log("STRING - name[%s],value[%s]", new_string->name, new_string->value);*/
1536                         break;
1537                 }
1538                 case CONFIGURE_VALUE_STRING_ARRAY:
1539                 {
1540                         int count_value = count_token - 2;
1541                         type_string_array* new_string_array;
1542
1543                         new_string_array = (type_string_array*)g_malloc0(sizeof(type_string_array));
1544                         if (new_string_array == NULL)
1545                                 break;
1546
1547                         new_string_array->name  = get_new_string(buffer_token[0]);
1548                         new_string_array->count = count_value;
1549                         new_string_array->value = (char**)g_malloc0(sizeof(char*)*count_value);
1550                         if (new_string_array->value == NULL) {
1551                                 SAFE_G_FREE(new_string_array->name);
1552                                 SAFE_G_FREE(new_string_array);
1553                                 _mmcam_dbg_err("allocation failed");
1554                                 break;
1555                         }
1556                         /*_mmcam_dbg_log("STRING ARRAY - name[%s]", new_string_array->name);*/
1557                         for (j = 0 ; j < count_value ; j++) {
1558                                 new_string_array->value[j] = get_new_string(buffer_token[j+1]);
1559                                 /*_mmcam_dbg_log("   index[%d] - value[%s]", j, new_string_array->value[j]);*/
1560                         }
1561
1562                         new_string_array->default_value = get_new_string(buffer_token[count_token-1]);
1563                         /*_mmcam_dbg_log("   default value[%s]", new_string_array->default_value);*/
1564                         (*info)->detail_info[i] = (void*)new_string_array;
1565                         break;
1566                 }
1567                 case CONFIGURE_VALUE_ELEMENT:
1568                 {
1569                         type_element2* new_element;
1570
1571                         new_element = (type_element2*)g_malloc0(sizeof(type_element2));
1572                         if (new_element == NULL) {
1573                                 _mmcam_dbg_err("allocation failed");
1574                                 break;
1575                         }
1576                         new_element->name         = get_new_string(buffer_token[0]);
1577                         new_element->element_name = get_new_string(buffer_token[1]);
1578                         new_element->count_int    = atoi(buffer_token[2]);
1579                         new_element->value_int    = NULL;
1580                         new_element->count_string = atoi(buffer_token[3]);
1581                         new_element->value_string = NULL;
1582                         /*
1583                         _mmcam_dbg_log("Element - name[%s],element_name[%s],count_int[%d],count_string[%d]",
1584                                 new_element->name, new_element->element_name, new_element->count_int, new_element->count_string);
1585                         */
1586
1587                         /* add int values */
1588                         if (new_element->count_int > 0 && new_element->count_int <= 30) {
1589                                 new_element->value_int = (type_int2**)g_malloc0(sizeof(type_int2*)*(new_element->count_int));
1590                                 if (new_element->value_int) {
1591                                         for (j = 0 ; j < new_element->count_int ; j++) {
1592                                                 new_element->value_int[j] = (type_int2*)g_malloc0(sizeof(type_int2));
1593                                                 if (new_element->value_int[j]) {
1594                                                         new_element->value_int[j]->name  = get_new_string(buffer_token[4+(j<<1)]);
1595                                                         new_element->value_int[j]->value = atoi(buffer_token[5+(j<<1)]);
1596                                                 } else {
1597                                                         _mmcam_dbg_err("allocation failed");
1598                                                 }
1599                                                 /*
1600                                                 _mmcam_dbg_log("   Element INT[%d] - name[%s],value[%d]",
1601                                                         j, new_element->value_int[j]->name, new_element->value_int[j]->value);
1602                                                 */
1603                                         }
1604                                 } else {
1605                                         _mmcam_dbg_err("allocation failed");
1606                                 }
1607                         } else {
1608                                 /*_mmcam_dbg_err("invalid count - %d", new_element->count_int);*/
1609                                 new_element->value_int = NULL;
1610                         }
1611
1612                         /* add string values */
1613                         if (new_element->count_string > 0 && new_element->count_string <= 30 &&
1614                                 new_element->count_int >= 0 && new_element->count_int <= 30) {
1615                                 new_element->value_string = (type_string2**)g_malloc0(sizeof(type_string2*)*(new_element->count_string));
1616                                 if (new_element->value_string) {
1617                                         for ( ; j < new_element->count_string + new_element->count_int ; j++) {
1618                                                 new_element->value_string[j-new_element->count_int]     = (type_string2*)g_malloc0(sizeof(type_string2));
1619                                                 if (new_element->value_string[j-new_element->count_int]) {
1620                                                         new_element->value_string[j-new_element->count_int]->name       = get_new_string(buffer_token[4+(j<<1)]);
1621                                                         new_element->value_string[j-new_element->count_int]->value      = get_new_string(buffer_token[5+(j<<1)]);
1622                                                         /*
1623                                                         _mmcam_dbg_log("   Element STRING[%d] - name[%s],value[%s]",
1624                                                                 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);
1625                                                         */
1626                                                 } else {
1627                                                         _mmcam_dbg_err("allocation failed");
1628                                                 }
1629                                         }
1630                                 } else {
1631                                         _mmcam_dbg_err("malloc failed : %zu", sizeof(type_string2*)*(new_element->count_string));
1632                                 }
1633                         } else {
1634                                 /*_mmcam_dbg_err("invalid count - %d", new_element->count_string);*/
1635                                 new_element->value_string = NULL;
1636                         }
1637
1638                         (*info)->detail_info[i] = (void*)new_element;
1639                         break;
1640                 }
1641                 default:
1642                         break;
1643                 }
1644         }
1645
1646         return TRUE;
1647 }
1648
1649
1650 int _mmcamcorder_conf_get_value_int(MMHandleType handle, camera_conf* configure_info, int category, const char* name, int* value)
1651 {
1652         int i, count;
1653         conf_detail* info;
1654
1655         /* _mmcam_dbg_log("Entered... category[%d],name[%s]", category, name); */
1656
1657         mmf_return_val_if_fail(configure_info, FALSE);
1658         mmf_return_val_if_fail(name, FALSE);
1659
1660         if (configure_info->info[category]) {
1661                 count = configure_info->info[category]->count;
1662                 info = configure_info->info[category];
1663
1664                 for (i = 0 ; i < count ; i++) {
1665                         if (info->detail_info[i] == NULL)
1666                                 continue;
1667
1668                         if (!strcmp(((type_int*)(info->detail_info[i]))->name , name)) {
1669                                 *value = ((type_int*)(info->detail_info[i]))->value;
1670                                 /* _mmcam_dbg_log("Get[%s] int[%d]", name, *value); */
1671                                 return TRUE;
1672                         }
1673                 }
1674         }
1675
1676         if (_mmcamcorder_conf_get_default_value_int(handle, configure_info->type, category, name, value)) {
1677                  /*_mmcam_dbg_log("Get[%s] int[%d]", name, *value);*/
1678                 return TRUE;
1679         }
1680
1681         _mmcam_dbg_err("Faild to get int... check it...Category[%d],Name[%s]", category, name);
1682
1683         return FALSE;
1684 }
1685
1686 int
1687 _mmcamcorder_conf_get_value_int_range(camera_conf* configure_info, int category, const char* name, type_int_range** value)
1688 {
1689         int i, count;
1690         conf_detail* info;
1691
1692         /* _mmcam_dbg_log("Entered... category[%d],name[%s]", category, name); */
1693
1694         mmf_return_val_if_fail(configure_info, FALSE);
1695         mmf_return_val_if_fail(name, FALSE);
1696
1697         if (configure_info->info[category]) {
1698                 count = configure_info->info[category]->count;
1699                 info = configure_info->info[category];
1700
1701                 for (i = 0 ; i < count ; i++) {
1702                         if (info->detail_info[i] == NULL)
1703                                 continue;
1704
1705                         if (!strcmp(((type_int_range*)(info->detail_info[i]))->name , name)) {
1706                                 *value = (type_int_range*)(info->detail_info[i]);
1707                                 /*
1708                                 _mmcam_dbg_log("Get[%s] int range - min[%d],max[%d],default[%d]",
1709                                         name, (*value)->min, (*value)->max, (*value)->default_value);
1710                                 */
1711                                 return TRUE;
1712                         }
1713                 }
1714         }
1715
1716         *value = NULL;
1717
1718         /*_mmcam_dbg_warn( "Faild to get int range... check it...Category[%d],Name[%s]", category, name );*/
1719
1720         return FALSE;
1721 }
1722
1723 int
1724 _mmcamcorder_conf_get_value_int_array(camera_conf* configure_info, int category, const char* name, type_int_array** value)
1725 {
1726         int i, count;
1727         conf_detail* info;
1728
1729         /*_mmcam_dbg_log("Entered... category[%d],name[%s]", category, name);*/
1730
1731         mmf_return_val_if_fail(configure_info, FALSE);
1732         mmf_return_val_if_fail(name, FALSE);
1733
1734         if (configure_info->info[category]) {
1735                 count   = configure_info->info[category]->count;
1736                 info    = configure_info->info[category];
1737
1738                 for (i = 0 ; i < count ; i++) {
1739                         if (info->detail_info[i] == NULL)
1740                                 continue;
1741
1742                         if (!strcmp(((type_int_array*)(info->detail_info[i]))->name , name)) {
1743                                 *value = (type_int_array*)(info->detail_info[i]);
1744                                 /*
1745                                 _mmcam_dbg_log("Get[%s] int array - [%x],count[%d],default[%d]",
1746                                         name, (*value)->value, (*value)->count, (*value)->default_value);
1747                                 */
1748                                 return TRUE;
1749                         }
1750                 }
1751         }
1752
1753         *value = NULL;
1754
1755         /*_mmcam_dbg_warn( "Faild to get int array... check it...Category[%d],Name[%s]", category, name );*/
1756
1757         return FALSE;
1758 }
1759
1760 int
1761 _mmcamcorder_conf_get_value_int_pair_array(camera_conf* configure_info, int category, const char* name, type_int_pair_array** value)
1762 {
1763         int i, count;
1764         conf_detail* info;
1765
1766         /* _mmcam_dbg_log("Entered... category[%d],name[%s]", category, name); */
1767
1768         mmf_return_val_if_fail(configure_info, FALSE);
1769         mmf_return_val_if_fail(name, FALSE);
1770
1771         if (configure_info->info[category]) {
1772                 count = configure_info->info[category]->count;
1773                 info = configure_info->info[category];
1774
1775                 for (i = 0 ; i < count ; i++) {
1776                         if (info->detail_info[i] == NULL)
1777                                 continue;
1778
1779                         if (!strcmp(((type_int_pair_array*)(info->detail_info[i]))->name , name)) {
1780                                 *value = (type_int_pair_array*)(info->detail_info[i]);
1781                                 /*
1782                                 _mmcam_dbg_log("Get[%s] int pair array - [%x][%x],count[%d],default[%d][%d]",
1783                                         name, (*value)->value[0], (*value)->value[1], (*value)->count,
1784                                         (*value)->default_value[0], (*value)->default_value[1]);
1785                                 */
1786                                 return TRUE;
1787                         }
1788                 }
1789         }
1790
1791         *value = NULL;
1792
1793         /*_mmcam_dbg_warn("Faild to get int pair array... check it...Category[%d],Name[%s]", category, name);*/
1794
1795         return FALSE;
1796 }
1797
1798 int _mmcamcorder_conf_get_value_string(MMHandleType handle, camera_conf* configure_info, int category, const char* name, const char** value)
1799 {
1800         int i, count;
1801         conf_detail* info;
1802
1803         /* _mmcam_dbg_log("Entered... category[%d],name[%s]", category, name); */
1804
1805         mmf_return_val_if_fail(configure_info, FALSE);
1806         mmf_return_val_if_fail(name, FALSE);
1807
1808         if (configure_info->info[category]) {
1809                 count = configure_info->info[category]->count;
1810                 info = configure_info->info[category];
1811
1812                 for (i = 0 ; i < count ; i++) {
1813                         if (info->detail_info[i] == NULL)
1814                                 continue;
1815
1816                         if (!strcmp(((type_string*)(info->detail_info[i]))->name , name)) {
1817                                 *value = ((type_string*)(info->detail_info[i]))->value;
1818                                  /*_mmcam_dbg_log( "Get[%s] string[%s]", name, *value ? *value : "NULL" );*/
1819                                 return TRUE;
1820                         }
1821                 }
1822         }
1823
1824         if (_mmcamcorder_conf_get_default_value_string(handle, configure_info->type, category, name, value)) {
1825                 /*_mmcam_dbg_log( "Get[%s] string[%s]", name, *value ? *value : "NULL" );*/
1826                 return TRUE;
1827         }
1828
1829         _mmcam_dbg_err("Faild to get string... check it...Category[%d],Name[%s]", category, name);
1830
1831         return FALSE;
1832 }
1833
1834 int
1835 _mmcamcorder_conf_get_value_string_array(camera_conf* configure_info, int category, const char* name, type_string_array** value)
1836 {
1837         int i, count;
1838         conf_detail* info;
1839
1840         /* _mmcam_dbg_log("Entered... category[%d],name[%s]", category, name); */
1841
1842         mmf_return_val_if_fail(configure_info, FALSE);
1843         mmf_return_val_if_fail(name, FALSE);
1844
1845         if (configure_info->info[category]) {
1846                 count = configure_info->info[category]->count;
1847                 info = configure_info->info[category];
1848
1849                 for (i = 0 ; i < count ; i++) {
1850                         if (info->detail_info[i] == NULL)
1851                                 continue;
1852
1853                         if (!strcmp(((type_string_array*)(info->detail_info[i]))->name , name)) {
1854                                 *value = (type_string_array*)(info->detail_info[i]);
1855                                 /*
1856                                 _mmcam_dbg_log("Get[%s] string array - [%x],count[%d],default[%s]",
1857                                         name, (*value)->value, (*value)->count, (*value)->default_value);
1858                                 */
1859                                 return TRUE;
1860                         }
1861                 }
1862         }
1863
1864         *value = NULL;
1865
1866         /*_mmcam_dbg_warn("Faild to get string array... check it...Category[%d],Name[%s]", category, name);*/
1867
1868         return FALSE;
1869 }
1870
1871 int _mmcamcorder_conf_get_element(MMHandleType handle, camera_conf* configure_info, int category, const char* name, type_element** element)
1872 {
1873         int i, count;
1874         conf_detail* info;
1875
1876         /* _mmcam_dbg_log("Entered... category[%d], ame[%s]", category, name); */
1877
1878         mmf_return_val_if_fail(configure_info, FALSE);
1879         mmf_return_val_if_fail(name, FALSE);
1880
1881         if (configure_info->info[category]) {
1882                 count = configure_info->info[category]->count;
1883                 info = configure_info->info[category];
1884
1885                 for (i = 0 ; i < count ; i++) {
1886                         if (info->detail_info[i] == NULL)
1887                                 continue;
1888
1889                         if (!strcmp(((type_element*)(info->detail_info[i]))->name , name)) {
1890                                 *element = (type_element*)(info->detail_info[i]);
1891                                 /* _mmcam_dbg_log("Get[%s] element[%x]", name, *element); */
1892                                 return TRUE;
1893                         }
1894                 }
1895         }
1896
1897         if (_mmcamcorder_conf_get_default_element(handle, configure_info->type, category, name, element)) {
1898                 /* _mmcam_dbg_log("Get[%s] element[%x]", name, *element); */
1899                 return TRUE;
1900         }
1901
1902         _mmcam_dbg_warn("Faild to get element name... check it...Category[%d],Name[%s]", category, name);
1903
1904         return FALSE;
1905 }
1906
1907 int
1908 _mmcamcorder_conf_get_value_element_name(type_element* element, const char** value)
1909 {
1910         /* _mmcam_dbg_log("Entered..."); */
1911
1912         mmf_return_val_if_fail(element, FALSE);
1913
1914         *value = element->element_name;
1915
1916         /* _mmcam_dbg_log("Get element name : [%s]", *value); */
1917
1918         return TRUE;
1919 }
1920
1921 int
1922 _mmcamcorder_conf_get_value_element_int(type_element* element, const char* name, int* value)
1923 {
1924         int i;
1925
1926         /* _mmcam_dbg_log( "Entered..." ); */
1927
1928         mmf_return_val_if_fail(element, FALSE);
1929         mmf_return_val_if_fail(name, FALSE);
1930
1931         for (i = 0 ; i < element->count_int ; i++) {
1932                 if (!strcmp(element->value_int[i]->name, name)) {
1933                         *value = element->value_int[i]->value;
1934                         /* _mmcam_dbg_log("Get[%s] element int[%d]", name, *value); */
1935                         return TRUE;
1936                 }
1937         }
1938
1939         _mmcam_dbg_warn("Faild to get int in element... ElementName[%p],Name[%s],Count[%d]",
1940                 element->name, name, element->count_int);
1941
1942         return FALSE;
1943 }
1944
1945 int
1946 _mmcamcorder_conf_get_value_element_string(type_element* element, const char* name, const char** value)
1947 {
1948         int i;
1949
1950         /* _mmcam_dbg_log("Entered..."); */
1951
1952         mmf_return_val_if_fail(element, FALSE);
1953         mmf_return_val_if_fail(name, FALSE);
1954
1955         for (i = 0 ; i < element->count_string ; i++) {
1956                 if (!strcmp(element->value_string[i]->name, name)) {
1957                         *value = element->value_string[i]->value;
1958                         /*_mmcam_dbg_log("Get[%s] element string[%s]", name, *value);*/
1959                         return TRUE;
1960                 }
1961         }
1962
1963         _mmcam_dbg_warn("Faild to get int in element... ElementName[%p],Name[%s],Count[%d]",
1964                 element->name, name, element->count_string);
1965
1966         return FALSE;
1967 }
1968
1969 int
1970 _mmcamcorder_conf_set_value_element_property(GstElement* gst, type_element* element)
1971 {
1972         int i;
1973
1974         /* _mmcam_dbg_log("Entered..."); */
1975
1976         mmf_return_val_if_fail(gst, FALSE);
1977         mmf_return_val_if_fail(element, FALSE);
1978
1979         if (element->count_int == 0) {
1980                 /*_mmcam_dbg_log( "There is no integer property to set in INI file[%s].", element->name );*/
1981         } else {
1982                 if (element->value_int == NULL) {
1983                         _mmcam_dbg_warn("count_int[%d] is NOT zero, but value_int is NULL", element->count_int);
1984                         return FALSE;
1985                 }
1986
1987                 for (i = 0 ; i < element->count_int ; i++) {
1988                         MMCAMCORDER_G_OBJECT_SET(gst, element->value_int[i]->name, element->value_int[i]->value);
1989
1990                         /*
1991                         _mmcam_dbg_log("Element[%s] Set[%s] -> integer[%d]",
1992                                 element->element_name,
1993                                 element->value_int[i]->name,
1994                                 element->value_int[i]->value);
1995                         */
1996                 }
1997         }
1998
1999         if (element->count_string == 0) {
2000                 _mmcam_dbg_log("There is no string property to set in INI file[%s].", element->name);
2001         } else {
2002                 if (element->value_string == NULL) {
2003                         _mmcam_dbg_warn("count_string[%d] is NOT zero, but value_string is NULL", element->count_string);
2004                         return FALSE;
2005                 }
2006
2007                 for (i = 0 ; i < element->count_string ; i++) {
2008                         MMCAMCORDER_G_OBJECT_SET_POINTER(gst, element->value_string[i]->name, element->value_string[i]->value);
2009
2010                         _mmcam_dbg_log("Element[%s] Set[%s] -> string[%s]",
2011                                 element->element_name,
2012                                 element->value_string[i]->name,
2013                                 element->value_string[i]->value);
2014                 }
2015         }
2016
2017         /* _mmcam_dbg_log( "Done." ); */
2018
2019         return TRUE;
2020 }
2021
2022 int
2023 _mmcamcorder_conf_get_default_value_int(MMHandleType handle, int type, int category, const char* name, int* value)
2024 {
2025         int i = 0;
2026         int count_value = 0;
2027
2028         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2029
2030         if (hcamcorder == NULL) {
2031                 _mmcam_dbg_err("handle is NULL");
2032                 return FALSE;
2033         }
2034
2035         /* _mmcam_dbg_log("Entered..."); */
2036
2037         mmf_return_val_if_fail(name, FALSE);
2038
2039         if (!_mmcamcorder_conf_get_category_size(handle, type, category, &count_value)) {
2040                 _mmcam_dbg_warn("No matched category... check it... categoty[%d]", category);
2041                 return FALSE;
2042         }
2043
2044         if (type == CONFIGURE_TYPE_MAIN) {
2045                 for (i = 0 ; i < count_value ; i++) {
2046                         if (!strcmp(hcamcorder->conf_main_info_table[category][i].name, name)) {
2047                                 *value = hcamcorder->conf_main_info_table[category][i].value_int;
2048                                 return TRUE;
2049                         }
2050                 }
2051         } else {
2052                 for (i = 0 ; i < count_value ; i++) {
2053                         if (!strcmp(hcamcorder->conf_ctrl_info_table[category][i].name, name)) {
2054                                 *value = hcamcorder->conf_ctrl_info_table[category][i].value_int;
2055                                 return TRUE;
2056                         }
2057                 }
2058         }
2059
2060         _mmcam_dbg_err("Failed to get default int... check it... Type[%d],Category[%d],Name[%s]", type, category, name);
2061
2062         return FALSE;
2063 }
2064
2065 int _mmcamcorder_conf_get_default_value_string(MMHandleType handle, int type, int category, const char* name, const char** value)
2066 {
2067         int i = 0;
2068         int count_value = 0;
2069
2070         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2071
2072         if (hcamcorder == NULL) {
2073                 _mmcam_dbg_err("handle is NULL");
2074                 return FALSE;
2075         }
2076
2077         /* _mmcam_dbg_log("Entered..."); */
2078
2079         mmf_return_val_if_fail(name, FALSE);
2080
2081         if (!_mmcamcorder_conf_get_category_size(handle, type, category, &count_value)) {
2082                 _mmcam_dbg_warn("No matched category... check it... categoty[%d]", category);
2083                 return FALSE;
2084         }
2085
2086         if (type == CONFIGURE_TYPE_MAIN) {
2087                 for (i = 0 ; i < count_value ; i++) {
2088                         if (!strcmp(hcamcorder->conf_main_info_table[category][i].name, name)) {
2089                                 *value = hcamcorder->conf_main_info_table[category][i].value_string;
2090                                 /*_mmcam_dbg_log("Get[%s] default string[%s]", name, *value ? *value : "NULL");*/
2091                                 return TRUE;
2092                         }
2093                 }
2094         } else {
2095                 for (i = 0 ; i < count_value ; i++) {
2096                         if (!strcmp(hcamcorder->conf_ctrl_info_table[category][i].name, name)) {
2097                                 *value = hcamcorder->conf_ctrl_info_table[category][i].value_string;
2098                                 /*_mmcam_dbg_log("Get[%s] default string[%s]", name, *value ? *value : "NULL");*/
2099                                 return TRUE;
2100                         }
2101                 }
2102         }
2103
2104         _mmcam_dbg_warn("Failed to get default string... check it... Type[%d],Category[%d],Name[%s]", type, category, name);
2105
2106         return FALSE;
2107 }
2108
2109 int _mmcamcorder_conf_get_default_element(MMHandleType handle, int type, int category, const char* name, type_element** element)
2110 {
2111         int i = 0;
2112         int count_value = 0;
2113
2114         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2115
2116         if (hcamcorder == NULL) {
2117                 _mmcam_dbg_err("handle is NULL");
2118                 return FALSE;
2119         }
2120
2121         /* _mmcam_dbg_log("Entered..."); */
2122
2123         mmf_return_val_if_fail(name, FALSE);
2124
2125         if (!_mmcamcorder_conf_get_category_size(handle, type, category, &count_value)) {
2126                 _mmcam_dbg_warn("No matched category... check it... categoty[%d]", category);
2127                 return FALSE;
2128         }
2129
2130         if (type == CONFIGURE_TYPE_MAIN) {
2131                 for (i = 0 ; i < count_value ; i++) {
2132                         if (!strcmp(hcamcorder->conf_main_info_table[category][i].name, name)) {
2133                                 *element = hcamcorder->conf_main_info_table[category][i].value_element;
2134                                 _mmcam_dbg_log("Get[%s] element[%p]", name, *element);
2135                                 return TRUE;
2136                         }
2137                 }
2138         } else {
2139                 for (i = 0 ; i < count_value ; i++) {
2140                         if (!strcmp(hcamcorder->conf_ctrl_info_table[category][i].name, name)) {
2141                                 *element = hcamcorder->conf_ctrl_info_table[category][i].value_element;
2142                                 _mmcam_dbg_log("Get[%s] element[%p]", name, *element);
2143                                 return TRUE;
2144                         }
2145                 }
2146         }
2147
2148         _mmcam_dbg_warn("Failed to get default element... check it... Type[%d],Category[%d],Name[%s]", type, category, name);
2149
2150         return FALSE;
2151 }
2152
2153 int _mmcamcorder_conf_get_category_size(MMHandleType handle, int type, int category, int* size)
2154 {
2155         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2156
2157         if (hcamcorder == NULL) {
2158                 _mmcam_dbg_err("handle is NULL");
2159                 return FALSE;
2160         }
2161
2162         /*
2163         mmf_return_val_if_fail(conf_main_category_size, FALSE);
2164         mmf_return_val_if_fail(conf_ctrl_category_size, FALSE);
2165         */
2166
2167         if (type == CONFIGURE_TYPE_MAIN) {
2168                 mmf_return_val_if_fail(category < CONFIGURE_CATEGORY_MAIN_NUM, FALSE);
2169
2170                 *size = (int)hcamcorder->conf_main_category_size[category];
2171         } else {
2172                 mmf_return_val_if_fail(category < CONFIGURE_CATEGORY_CTRL_NUM, FALSE);
2173
2174                 *size = (int)hcamcorder->conf_ctrl_category_size[category];
2175         }
2176
2177         return TRUE;
2178 }
2179
2180 void
2181 _mmcamcorder_conf_print_info(MMHandleType handle, camera_conf** configure_info)
2182 {
2183         int i, j, k, type, category_type;
2184
2185         type_int                *temp_int;
2186         type_int_range          *temp_int_range;
2187         type_int_array          *temp_int_array;
2188         type_int_pair_array     *temp_int_pair_array;
2189         type_string             *temp_string;
2190         type_element            *temp_element;
2191
2192         g_print("[ConfigureInfoPrint] : Entered.\n");
2193
2194         mmf_return_if_fail(*configure_info);
2195
2196         if ((*configure_info)->type == CONFIGURE_TYPE_MAIN)
2197                 category_type = CONFIGURE_CATEGORY_MAIN_NUM;
2198         else
2199                 category_type = CONFIGURE_CATEGORY_CTRL_NUM;
2200
2201         for (i = 0 ; i < category_type ; i++) {
2202
2203                 if ((*configure_info)->info[i]) {
2204                         g_print("[ConfigureInfo] : Category [%d]\n", i);
2205
2206                         for (j = 0 ; j < (*configure_info)->info[i]->count ; j++) {
2207
2208                                 if (_mmcamcorder_conf_get_value_type(handle, (*configure_info)->type, i, ((type_int*)((*configure_info)->info[i]->detail_info[j]))->name, &type)) {
2209                                         switch (type) {
2210                                         case CONFIGURE_VALUE_INT:
2211                                                 temp_int = (type_int*)((*configure_info)->info[i]->detail_info[j]);
2212                                                 g_print("[ConfigureInfo] : INT - Name[%s],Value [%d]\n", temp_int->name, temp_int->value);
2213                                                 break;
2214                                         case CONFIGURE_VALUE_INT_RANGE:
2215                                                 temp_int_range = (type_int_range*)((*configure_info)->info[i]->detail_info[j]);
2216                                                 g_print("[ConfigureInfo] : INT_RANGE - Name[%s],Value [%d]~[%d], default [%d]\n",
2217                                                         temp_int_range->name, temp_int_range->min, temp_int_range->max, temp_int_range->default_value);
2218                                                 break;
2219                                         case CONFIGURE_VALUE_INT_ARRAY:
2220                                                 temp_int_array = (type_int_array*)((*configure_info)->info[i]->detail_info[j]);
2221                                                 g_print("[ConfigureInfo] : INT_ARRAY - Name[%s], default [%d]\n                            - ",
2222                                                         temp_int_array->name, temp_int_array->default_value);
2223
2224                                                 for (k = 0 ; k < temp_int_array->count ; k++)
2225                                                         g_print("[%d] ", temp_int_array->value[k]);
2226
2227                                                 g_print("\n");
2228                                                 break;
2229                                         case CONFIGURE_VALUE_INT_PAIR_ARRAY:
2230                                                 temp_int_pair_array = (type_int_pair_array*)((*configure_info)->info[i]->detail_info[j]);
2231                                                 g_print("[ConfigureInfo] : INT_PAIR_ARRAY - Name[%s], default [%d][%d]\n                            - ",
2232                                                         temp_int_pair_array->name, temp_int_pair_array->default_value[0], temp_int_pair_array->default_value[0]);
2233
2234                                                 for (k = 0 ; k < temp_int_pair_array->count ; k++)
2235                                                         g_print("[%d,%d] ", temp_int_pair_array->value[0][k], temp_int_pair_array->value[1][k]);
2236
2237                                                 g_print("\n");
2238                                                 break;
2239                                         case CONFIGURE_VALUE_STRING:
2240                                                 temp_string = (type_string*)((*configure_info)->info[i]->detail_info[j]);
2241                                                 g_print("[ConfigureInfo] : STRING - Name[%s],Value[%s]\n", temp_string->name, temp_string->value);
2242                                                 break;
2243                                         case CONFIGURE_VALUE_ELEMENT:
2244                                                 temp_element = (type_element*)((*configure_info)->info[i]->detail_info[j]);
2245                                                 g_print("[ConfigureInfo] : Element - Name[%s],Element_Name[%s]\n", temp_element->name, temp_element->element_name);
2246
2247                                                 for (k = 0 ; k < temp_element->count_int ; k++)
2248                                                         g_print("                          - INT[%d] Name[%s],Value[%d]\n", k, temp_element->value_int[k]->name, temp_element->value_int[k]->value);
2249
2250                                                 for (k = 0 ; k < temp_element->count_string ; k++)
2251                                                         g_print("                          - STRING[%d] Name[%s],Value[%s]\n", k, temp_element->value_string[k]->name, temp_element->value_string[k]->value);
2252
2253                                                 break;
2254                                         default:
2255                                                 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);
2256                                                 break;
2257                                         }
2258                                 } else {
2259                                         g_print("[ConfigureInfo] : Failed to get value type.");
2260                                 }
2261                         }
2262                 }
2263         }
2264
2265         g_print("[ConfigureInfoPrint] : Done.\n");
2266 }
2267
2268
2269 static type_element *
2270 __mmcamcorder_get_audio_codec_element(MMHandleType handle)
2271 {
2272         type_element *telement = NULL;
2273         const char *codec_type_str = NULL;
2274         int codec_type = MM_AUDIO_CODEC_INVALID;
2275         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2276         _MMCamcorderSubContext *sc = NULL;
2277
2278         mmf_return_val_if_fail(hcamcorder, NULL);
2279         sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2280
2281         mmf_return_val_if_fail(sc, NULL);
2282
2283         _mmcam_dbg_log("");
2284
2285         /* Check element availability */
2286         mm_camcorder_get_attributes(handle, NULL, MMCAM_AUDIO_ENCODER, &codec_type, NULL);
2287
2288         switch (codec_type) {
2289         case MM_AUDIO_CODEC_AMR:
2290                 codec_type_str = "AMR";
2291                 break;
2292         case MM_AUDIO_CODEC_G723_1:
2293                 codec_type_str = "G723_1";
2294                 break;
2295         case MM_AUDIO_CODEC_MP3:
2296                 codec_type_str = "MP3";
2297                 break;
2298         case MM_AUDIO_CODEC_AAC:
2299                 codec_type_str = "AAC";
2300                 break;
2301         case MM_AUDIO_CODEC_MMF:
2302                 codec_type_str = "MMF";
2303                 break;
2304         case MM_AUDIO_CODEC_ADPCM:
2305                 codec_type_str = "ADPCM";
2306                 break;
2307         case MM_AUDIO_CODEC_WAVE:
2308                 codec_type_str = "WAVE";
2309                 break;
2310         case MM_AUDIO_CODEC_MIDI:
2311                 codec_type_str = "MIDI";
2312                 break;
2313         case MM_AUDIO_CODEC_IMELODY:
2314                 codec_type_str = "IMELODY";
2315                 break;
2316         case MM_AUDIO_CODEC_VORBIS:
2317                 codec_type_str = "VORBIS";
2318                 break;
2319         default:
2320                 _mmcam_dbg_err("Not supported audio codec[%d]", codec_type);
2321                 return NULL;
2322         }
2323
2324         _mmcamcorder_conf_get_element(handle, hcamcorder->conf_main,
2325                 CONFIGURE_CATEGORY_MAIN_AUDIO_ENCODER,
2326                 codec_type_str,
2327                 &telement);
2328
2329         return telement;
2330 }
2331
2332
2333 static type_element *
2334 __mmcamcorder_get_video_codec_element(MMHandleType handle)
2335 {
2336         type_element *telement = NULL;
2337         const char *codec_type_str = NULL;
2338         int codec_type = MM_VIDEO_CODEC_INVALID;
2339         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2340         _MMCamcorderSubContext *sc = NULL;
2341
2342         mmf_return_val_if_fail(hcamcorder, NULL);
2343         sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2344
2345         mmf_return_val_if_fail(sc, NULL);
2346
2347         _mmcam_dbg_log("");
2348
2349         /* Check element availability */
2350         mm_camcorder_get_attributes(handle, NULL, MMCAM_VIDEO_ENCODER, &codec_type, NULL);
2351
2352         switch (codec_type) {
2353         case MM_VIDEO_CODEC_H263:
2354                 codec_type_str = "H263";
2355                 break;
2356         case MM_VIDEO_CODEC_H264:
2357                 codec_type_str = "H264";
2358                 break;
2359         case MM_VIDEO_CODEC_H26L:
2360                 codec_type_str = "H26L";
2361                 break;
2362         case MM_VIDEO_CODEC_MPEG4:
2363                 codec_type_str = "MPEG4";
2364                 break;
2365         case MM_VIDEO_CODEC_MPEG1:
2366                 codec_type_str = "MPEG1";
2367                 break;
2368         case MM_VIDEO_CODEC_THEORA:
2369                 codec_type_str = "THEORA";
2370                 break;
2371         default:
2372                 _mmcam_dbg_err("Not supported video codec[%d]", codec_type);
2373                 return NULL;
2374         }
2375
2376         _mmcamcorder_conf_get_element(handle, hcamcorder->conf_main,
2377                 CONFIGURE_CATEGORY_MAIN_VIDEO_ENCODER,
2378                 codec_type_str,
2379                 &telement);
2380
2381         return telement;
2382 }
2383
2384
2385 static type_element *
2386 __mmcamcorder_get_image_codec_element(MMHandleType handle)
2387 {
2388         type_element *telement = NULL;
2389         const char *codec_type_str = NULL;
2390         int codec_type = MM_IMAGE_CODEC_INVALID;
2391         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2392         _MMCamcorderSubContext *sc = NULL;
2393
2394         mmf_return_val_if_fail(hcamcorder, NULL);
2395         sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2396
2397         mmf_return_val_if_fail(sc, NULL);
2398
2399         _mmcam_dbg_log("");
2400
2401         /* Check element availability */
2402         mm_camcorder_get_attributes(handle, NULL, MMCAM_IMAGE_ENCODER, &codec_type, NULL);
2403
2404         switch (codec_type) {
2405         case MM_IMAGE_CODEC_JPEG:
2406                 codec_type_str = "JPEG";
2407                 break;
2408         case MM_IMAGE_CODEC_SRW:
2409                 codec_type_str = "SRW";
2410                 break;
2411         case MM_IMAGE_CODEC_JPEG_SRW:
2412                 codec_type_str = "JPEG_SRW";
2413                 break;
2414         case MM_IMAGE_CODEC_PNG:
2415                 codec_type_str = "PNG";
2416                 break;
2417         case MM_IMAGE_CODEC_BMP:
2418                 codec_type_str = "BMP";
2419                 break;
2420         case MM_IMAGE_CODEC_WBMP:
2421                 codec_type_str = "WBMP";
2422                 break;
2423         case MM_IMAGE_CODEC_TIFF:
2424                 codec_type_str = "TIFF";
2425                 break;
2426         case MM_IMAGE_CODEC_PCX:
2427                 codec_type_str = "PCX";
2428                 break;
2429         case MM_IMAGE_CODEC_GIF:
2430                 codec_type_str = "GIF";
2431                 break;
2432         case MM_IMAGE_CODEC_ICO:
2433                 codec_type_str = "ICO";
2434                 break;
2435         case MM_IMAGE_CODEC_RAS:
2436                 codec_type_str = "RAS";
2437                 break;
2438         case MM_IMAGE_CODEC_TGA:
2439                 codec_type_str = "TGA";
2440                 break;
2441         case MM_IMAGE_CODEC_XBM:
2442                 codec_type_str = "XBM";
2443                 break;
2444         case MM_IMAGE_CODEC_XPM:
2445                 codec_type_str = "XPM";
2446                 break;
2447         default:
2448                 _mmcam_dbg_err("Not supported image codec[%d]", codec_type);
2449                 return NULL;
2450         }
2451
2452         _mmcamcorder_conf_get_element(handle, hcamcorder->conf_main,
2453                 CONFIGURE_CATEGORY_MAIN_IMAGE_ENCODER,
2454                 codec_type_str,
2455                 &telement);
2456
2457         return telement;
2458 }
2459
2460
2461 static type_element *
2462 __mmcamcorder_get_file_format_element(MMHandleType handle)
2463 {
2464         type_element *telement = NULL;
2465         const char *mux_type_str = NULL;
2466         int file_type = MM_FILE_FORMAT_INVALID;
2467         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2468         _MMCamcorderSubContext *sc = NULL;
2469
2470         mmf_return_val_if_fail(hcamcorder, NULL);
2471         sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2472
2473         mmf_return_val_if_fail(sc, NULL);
2474
2475         _mmcam_dbg_log("");
2476
2477         /* Check element availability */
2478         mm_camcorder_get_attributes(handle, NULL, MMCAM_FILE_FORMAT, &file_type, NULL);
2479
2480         switch (file_type) {
2481         case MM_FILE_FORMAT_3GP:
2482                 mux_type_str = "3GP";
2483                 break;
2484         case MM_FILE_FORMAT_AMR:
2485                 mux_type_str = "AMR";
2486                 break;
2487         case MM_FILE_FORMAT_MP4:
2488                 mux_type_str = "MP4";
2489                 break;
2490         case MM_FILE_FORMAT_AAC:
2491                 mux_type_str = "AAC";
2492                 break;
2493         case MM_FILE_FORMAT_MP3:
2494                 mux_type_str = "MP3";
2495                 break;
2496         case MM_FILE_FORMAT_OGG:
2497                 mux_type_str = "OGG";
2498                 break;
2499         case MM_FILE_FORMAT_WAV:
2500                 mux_type_str = "WAV";
2501                 break;
2502         case MM_FILE_FORMAT_AVI:
2503                 mux_type_str = "AVI";
2504                 break;
2505         case MM_FILE_FORMAT_WMA:
2506                 mux_type_str = "WMA";
2507                 break;
2508         case MM_FILE_FORMAT_WMV:
2509                 mux_type_str = "WMV";
2510                 break;
2511         case MM_FILE_FORMAT_MID:
2512                 mux_type_str = "MID";
2513                 break;
2514         case MM_FILE_FORMAT_MMF:
2515                 mux_type_str = "MMF";
2516                 break;
2517         case MM_FILE_FORMAT_MATROSKA:
2518                 mux_type_str = "MATROSKA";
2519                 break;
2520         case MM_FILE_FORMAT_M2TS:
2521                 mux_type_str = "M2TS";
2522                 break;
2523         default:
2524                 _mmcam_dbg_err("Not supported file format[%d]", file_type);
2525                 return NULL;
2526         }
2527
2528         _mmcamcorder_conf_get_element(handle, hcamcorder->conf_main,
2529                 CONFIGURE_CATEGORY_MAIN_MUX,
2530                 mux_type_str,
2531                 &telement);
2532
2533         return telement;
2534 }
2535
2536
2537 type_element *
2538 _mmcamcorder_get_type_element(MMHandleType handle, int type)
2539 {
2540         type_element *telement = NULL;
2541
2542         _mmcam_dbg_log("type:%d", type);
2543
2544         switch (type) {
2545         case MM_CAM_AUDIO_ENCODER:
2546                 telement = __mmcamcorder_get_audio_codec_element(handle);
2547                 break;
2548         case MM_CAM_VIDEO_ENCODER:
2549                 telement = __mmcamcorder_get_video_codec_element(handle);
2550                 break;
2551         case MM_CAM_IMAGE_ENCODER:
2552                 telement = __mmcamcorder_get_image_codec_element(handle);
2553                 break;
2554         case MM_CAM_FILE_FORMAT:
2555                 telement = __mmcamcorder_get_file_format_element(handle);
2556                 break;
2557         default:
2558                 _mmcam_dbg_log("Can't get element type form this profile.(%d)", type);
2559         }
2560
2561         return telement;
2562 }
2563
2564
2565 int _mmcamcorder_get_audio_codec_format(MMHandleType handle, const char *name)
2566 {
2567         int codec_index = MM_AUDIO_CODEC_INVALID;
2568
2569         if (!name) {
2570                 _mmcam_dbg_err("name is NULL");
2571                 return MM_AUDIO_CODEC_INVALID;
2572         }
2573
2574         if (!strcmp(name, "AMR"))
2575                 codec_index = MM_AUDIO_CODEC_AMR;
2576         else if (!strcmp(name, "G723_1"))
2577                 codec_index = MM_AUDIO_CODEC_G723_1;
2578         else if (!strcmp(name, "MP3"))
2579                 codec_index = MM_AUDIO_CODEC_MP3;
2580         else if (!strcmp(name, "AAC"))
2581                 codec_index = MM_AUDIO_CODEC_AAC;
2582         else if (!strcmp(name, "MMF"))
2583                 codec_index = MM_AUDIO_CODEC_MMF;
2584         else if (!strcmp(name, "ADPCM"))
2585                 codec_index = MM_AUDIO_CODEC_ADPCM;
2586         else if (!strcmp(name, "WAVE"))
2587                 codec_index = MM_AUDIO_CODEC_WAVE;
2588         else if (!strcmp(name, "MIDI"))
2589                 codec_index = MM_AUDIO_CODEC_MIDI;
2590         else if (!strcmp(name, "IMELODY"))
2591                 codec_index = MM_AUDIO_CODEC_IMELODY;
2592         else if (!strcmp(name, "VORBIS"))
2593                 codec_index = MM_AUDIO_CODEC_VORBIS;
2594
2595         /*_mmcam_dbg_log("audio codec index %d", codec_index);*/
2596
2597         return codec_index;
2598 }
2599
2600
2601
2602 int _mmcamcorder_get_video_codec_format(MMHandleType handle, const char *name)
2603 {
2604         int codec_index = MM_VIDEO_CODEC_INVALID;
2605
2606         if (!name) {
2607                 _mmcam_dbg_err("name is NULL");
2608                 return MM_VIDEO_CODEC_INVALID;
2609         }
2610
2611         if (!strcmp(name, "H263"))
2612                 codec_index = MM_VIDEO_CODEC_H263;
2613         else if (!strcmp(name, "H264"))
2614                 codec_index = MM_VIDEO_CODEC_H264;
2615         else if (!strcmp(name, "H26L"))
2616                 codec_index = MM_VIDEO_CODEC_H26L;
2617         else if (!strcmp(name, "MPEG4"))
2618                 codec_index = MM_VIDEO_CODEC_MPEG4;
2619         else if (!strcmp(name, "MPEG1"))
2620                 codec_index = MM_VIDEO_CODEC_MPEG1;
2621         else if (!strcmp(name, "THEORA"))
2622                 codec_index = MM_VIDEO_CODEC_THEORA;
2623
2624         /*_mmcam_dbg_log("video codec index %d", codec_index);*/
2625
2626         return codec_index;
2627 }
2628
2629
2630
2631 int _mmcamcorder_get_image_codec_format(MMHandleType handle, const char *name)
2632 {
2633         int codec_index = MM_IMAGE_CODEC_INVALID;
2634
2635         if (!name) {
2636                 _mmcam_dbg_err("name is NULL");
2637                 return MM_IMAGE_CODEC_INVALID;
2638         }
2639
2640         if (!strcmp(name, "JPEG"))
2641                 codec_index = MM_IMAGE_CODEC_JPEG;
2642         else if (!strcmp(name, "PNG"))
2643                 codec_index = MM_IMAGE_CODEC_PNG;
2644         else if (!strcmp(name, "BMP"))
2645                 codec_index = MM_IMAGE_CODEC_BMP;
2646         else if (!strcmp(name, "WBMP"))
2647                 codec_index = MM_IMAGE_CODEC_WBMP;
2648         else if (!strcmp(name, "TIFF"))
2649                 codec_index = MM_IMAGE_CODEC_TIFF;
2650         else if (!strcmp(name, "PCX"))
2651                 codec_index = MM_IMAGE_CODEC_PCX;
2652         else if (!strcmp(name, "GIF"))
2653                 codec_index = MM_IMAGE_CODEC_GIF;
2654         else if (!strcmp(name, "ICO"))
2655                 codec_index = MM_IMAGE_CODEC_ICO;
2656         else if (!strcmp(name, "RAS"))
2657                 codec_index = MM_IMAGE_CODEC_RAS;
2658         else if (!strcmp(name, "TGA"))
2659                 codec_index = MM_IMAGE_CODEC_TGA;
2660         else if (!strcmp(name, "XBM"))
2661                 codec_index = MM_IMAGE_CODEC_XBM;
2662         else if (!strcmp(name, "XPM"))
2663                 codec_index = MM_IMAGE_CODEC_XPM;
2664
2665         _mmcam_dbg_log("image codec index %d", codec_index);
2666
2667         return codec_index;
2668 }
2669
2670
2671 int _mmcamcorder_get_mux_format(MMHandleType handle, const char *name)
2672 {
2673         int mux_index = MM_FILE_FORMAT_INVALID;
2674
2675         if (!name) {
2676                 _mmcam_dbg_err("name is NULL");
2677                 return MM_FILE_FORMAT_INVALID;
2678         }
2679
2680         if (!strcmp(name, "3GP"))
2681                 mux_index = MM_FILE_FORMAT_3GP;
2682         else if (!strcmp(name, "AMR"))
2683                 mux_index = MM_FILE_FORMAT_AMR;
2684         else if (!strcmp(name, "MP4"))
2685                 mux_index = MM_FILE_FORMAT_MP4;
2686         else if (!strcmp(name, "AAC"))
2687                 mux_index = MM_FILE_FORMAT_AAC;
2688         else if (!strcmp(name, "MP3"))
2689                 mux_index = MM_FILE_FORMAT_MP3;
2690         else if (!strcmp(name, "OGG"))
2691                 mux_index = MM_FILE_FORMAT_OGG;
2692         else if (!strcmp(name, "WAV"))
2693                 mux_index = MM_FILE_FORMAT_WAV;
2694         else if (!strcmp(name, "AVI"))
2695                 mux_index = MM_FILE_FORMAT_AVI;
2696         else if (!strcmp(name, "WMA"))
2697                 mux_index = MM_FILE_FORMAT_WMA;
2698         else if (!strcmp(name, "WMV"))
2699                 mux_index = MM_FILE_FORMAT_WMV;
2700         else if (!strcmp(name, "MID"))
2701                 mux_index = MM_FILE_FORMAT_MID;
2702         else if (!strcmp(name, "MMF"))
2703                 mux_index = MM_FILE_FORMAT_MMF;
2704         else if (!strcmp(name, "MATROSKA"))
2705                 mux_index = MM_FILE_FORMAT_MATROSKA;
2706         else if (!strcmp(name, "M2TS"))
2707                 mux_index = MM_FILE_FORMAT_M2TS;
2708
2709         /*_mmcam_dbg_log("mux index %d", mux_index);*/
2710
2711         return mux_index;
2712 }
2713
2714
2715 int
2716 _mmcamcorder_get_format(MMHandleType handle, int conf_category, const char *name)
2717 {
2718         int fmt = -1;
2719
2720         mmf_return_val_if_fail(name, -1);
2721
2722         switch (conf_category) {
2723         case CONFIGURE_CATEGORY_MAIN_AUDIO_ENCODER:
2724                 fmt = _mmcamcorder_get_audio_codec_format(handle, name);
2725                 break;
2726         case CONFIGURE_CATEGORY_MAIN_VIDEO_ENCODER:
2727                 fmt = _mmcamcorder_get_video_codec_format(handle, name);
2728                 break;
2729         case CONFIGURE_CATEGORY_MAIN_IMAGE_ENCODER:
2730                 fmt = _mmcamcorder_get_image_codec_format(handle, name);
2731                 break;
2732         case CONFIGURE_CATEGORY_MAIN_MUX:
2733                 fmt = _mmcamcorder_get_mux_format(handle, name);
2734                 break;
2735         default:
2736                 _mmcam_dbg_log("Can't get format from this category.(%d)", conf_category);
2737         }
2738
2739         return fmt;
2740 }
2741
2742 int
2743 _mmcamcorder_get_available_format(MMHandleType handle, int conf_category, int ** format)
2744 {
2745         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2746         camera_conf* configure_info = NULL;
2747         int *arr = NULL;
2748         int total_count = 0;
2749
2750         mmf_return_val_if_fail(hcamcorder, 0);
2751
2752         /*_mmcam_dbg_log("conf_category:%d", conf_category);*/
2753
2754         configure_info = hcamcorder->conf_main;
2755
2756         if (configure_info->info[conf_category]) {
2757                 int i = 0;
2758                 int fmt = 0;
2759                 const char *name = NULL;
2760                 int count = configure_info->info[conf_category]->count;
2761                 conf_detail *info = configure_info->info[conf_category];
2762
2763                 /*_mmcam_dbg_log("count[%d], info[%p]", count, info);*/
2764
2765                 if (count <= 0 || !info)
2766                         return total_count;
2767
2768                 arr = (int*) g_malloc0(count * sizeof(int));
2769                 if (arr == NULL) {
2770                         _mmcam_dbg_err("malloc failed : %zu", count * sizeof(int));
2771                         return 0;
2772                 }
2773
2774                 for (i = 0 ; i < count ; i++) {
2775                         if (info->detail_info[i] == NULL)
2776                                 continue;
2777
2778                         name = ((type_element*)(info->detail_info[i]))->name;
2779                         fmt = _mmcamcorder_get_format(handle, conf_category, name);
2780                         if (fmt >= 0)
2781                                 arr[total_count++] = fmt;
2782
2783                         /*_mmcam_dbg_log("name:%s, fmt:%d", name, fmt);*/
2784                 }
2785         }
2786
2787         *format = arr;
2788
2789         return total_count;
2790 }