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