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