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