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