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