Add version of so files
[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                 { "AltVideosrcElement",   CONFIGURE_VALUE_ELEMENT,        {NULL} }, /* The alternative of videosrc element, it will be used instead of "VideosrcElement" if exists. */
828                 { "AltUseZeroCopyFormat", CONFIGURE_VALUE_INT,            {.value_int = -1} }, /* The alternative of "UseZeroCopyFormat", it will be used if it's not default(-1) value. */
829                 { "VideoFilterElement",   CONFIGURE_VALUE_ELEMENT,        {NULL} }, /* The video filter element which is placed between videosrc and videosink elements. */
830                 { "VideoFilterCropX",     CONFIGURE_VALUE_INT,            {.value_int = 0} }, /* The VideoFilterElement is existed and these values are valid, they will be set to "crop" property. */
831                 { "VideoFilterCropY",     CONFIGURE_VALUE_INT,            {.value_int = 0} },
832                 { "VideoFilterCropW",     CONFIGURE_VALUE_INT,            {.value_int = 0} },
833                 { "VideoFilterCropH",     CONFIGURE_VALUE_INT,            {.value_int = 0} }
834         };
835
836         /* [Strobe] matching table */
837         static conf_info_table conf_ctrl_strobe_table[] = {
838                 { "StrobeControl",        CONFIGURE_VALUE_INT_ARRAY, {NULL} },
839                 { "StrobeMode",           CONFIGURE_VALUE_INT_ARRAY, {NULL} },
840                 { "StrobeEV",             CONFIGURE_VALUE_INT_RANGE, {NULL} },
841                 { "StrobeBrightness",     CONFIGURE_VALUE_INT_RANGE, {NULL} },
842         };
843
844         /* [Effect] matching table */
845         static conf_info_table conf_ctrl_effect_table[] = {
846                 { "Brightness",                     CONFIGURE_VALUE_INT_RANGE, {NULL} },
847                 { "BrightnessStepDenominator",      CONFIGURE_VALUE_INT, {.value_int = 2} },
848                 { "Contrast",                       CONFIGURE_VALUE_INT_RANGE, {NULL} },
849                 { "Saturation",                     CONFIGURE_VALUE_INT_RANGE, {NULL} },
850                 { "Sharpness",                      CONFIGURE_VALUE_INT_RANGE, {NULL} },
851                 { "Hue",                            CONFIGURE_VALUE_INT_RANGE, {NULL} },
852                 { "WhiteBalance",                   CONFIGURE_VALUE_INT_ARRAY, {NULL} },
853                 { "ColorTone",                      CONFIGURE_VALUE_INT_ARRAY, {NULL} },
854                 { "Flip",                           CONFIGURE_VALUE_INT_ARRAY, {NULL} },
855                 { "Rotation",                       CONFIGURE_VALUE_INT_ARRAY, {NULL} },
856                 { "WDR",                            CONFIGURE_VALUE_INT_ARRAY, {NULL} },
857                 { "PartColorMode",                  CONFIGURE_VALUE_INT_ARRAY, {NULL} },
858                 { "PartColor",                      CONFIGURE_VALUE_INT_ARRAY, {NULL} },
859                 { "WhiteBalanceTemperature",        CONFIGURE_VALUE_INT_RANGE, {NULL} },
860                 { "WhiteBalanceTemperatureStep",    CONFIGURE_VALUE_INT, {.value_int = 1} }
861         };
862
863         /* [Photograph] matching table */
864         static conf_info_table conf_ctrl_photograph_table[] = {
865                 { "LensInit",             CONFIGURE_VALUE_INT_ARRAY, {NULL} },
866                 { "DigitalZoom",          CONFIGURE_VALUE_INT_RANGE, {NULL} },
867                 { "OpticalZoom",          CONFIGURE_VALUE_INT_RANGE, {NULL} },
868                 { "FocusMode",            CONFIGURE_VALUE_INT_ARRAY, {NULL} },
869                 { "FocusLevel",           CONFIGURE_VALUE_INT_RANGE, {NULL} },
870                 { "AFType",               CONFIGURE_VALUE_INT_ARRAY, {NULL} },
871                 { "AEType",               CONFIGURE_VALUE_INT_ARRAY, {NULL} },
872                 { "ExposureValue",        CONFIGURE_VALUE_INT_RANGE, {NULL} },
873                 { "FNumber",              CONFIGURE_VALUE_INT_ARRAY, {NULL} },
874                 { "ShutterSpeed",         CONFIGURE_VALUE_INT_ARRAY, {NULL} },
875                 { "ISO",                  CONFIGURE_VALUE_INT_ARRAY, {NULL} },
876                 { "ProgramMode",          CONFIGURE_VALUE_INT_ARRAY, {NULL} },
877                 { "AntiHandshake",        CONFIGURE_VALUE_INT_ARRAY, {NULL} },
878                 { "VideoStabilization",   CONFIGURE_VALUE_INT_ARRAY, {NULL} },
879                 { "FaceZoomMode",         CONFIGURE_VALUE_INT_ARRAY, {NULL} },
880                 { "FaceZoomLevel",        CONFIGURE_VALUE_INT_RANGE, {NULL} },
881                 { "PtzType",              CONFIGURE_VALUE_INT_ARRAY, {NULL} },
882                 { "PanMecha",             CONFIGURE_VALUE_INT_RANGE, {NULL} },
883                 { "PanElec",              CONFIGURE_VALUE_INT_RANGE, {NULL} },
884                 { "TiltMecha",            CONFIGURE_VALUE_INT_RANGE, {NULL} },
885                 { "TiltElec",             CONFIGURE_VALUE_INT_RANGE, {NULL} },
886                 { "Gain",                 CONFIGURE_VALUE_INT_RANGE, {NULL} },
887                 { "GainStep",             CONFIGURE_VALUE_INT, {.value_int = 1} }
888         };
889
890         /* [Capture] matching table */
891         static conf_info_table conf_ctrl_capture_table[] = {
892                 { "OutputMode",           CONFIGURE_VALUE_INT_ARRAY, {NULL} },
893                 { "JpegQuality",          CONFIGURE_VALUE_INT_RANGE, {NULL} },
894                 { "MultishotNumber",      CONFIGURE_VALUE_INT_RANGE, {NULL} },
895                 { "SensorEncodedCapture", CONFIGURE_VALUE_INT,       {.value_int = 1} },
896                 { "SupportHDR",           CONFIGURE_VALUE_INT_ARRAY, {NULL} },
897                 { "SupportZSL",           CONFIGURE_VALUE_INT,       {.value_int = FALSE} },
898                 { "FrameStabilityCount",  CONFIGURE_VALUE_INT,       {.value_int = 0} },
899         };
900
901         /* [Detect] matching table */
902         static conf_info_table conf_ctrl_detect_table[] = {
903                 { "DetectMode",           CONFIGURE_VALUE_INT_ARRAY, {NULL} },
904                 { "DetectNumber",         CONFIGURE_VALUE_INT_RANGE, {NULL} },
905                 { "DetectSelect",         CONFIGURE_VALUE_INT_RANGE, {NULL} },
906                 { "DetectSelectNumber",   CONFIGURE_VALUE_INT_RANGE, {NULL} },
907         };
908
909         MMCAM_LOG_INFO("Entered...");
910
911         if (type == CONFIGURE_TYPE_MAIN) {
912                 hcamcorder->conf_main_info_table[CONFIGURE_CATEGORY_MAIN_GENERAL]       = conf_main_general_table;
913                 hcamcorder->conf_main_info_table[CONFIGURE_CATEGORY_MAIN_VIDEO_INPUT]   = conf_main_video_input_table;
914                 hcamcorder->conf_main_info_table[CONFIGURE_CATEGORY_MAIN_AUDIO_INPUT]   = conf_main_audio_input_table;
915                 hcamcorder->conf_main_info_table[CONFIGURE_CATEGORY_MAIN_VIDEO_OUTPUT]  = conf_main_video_output_table;
916                 hcamcorder->conf_main_info_table[CONFIGURE_CATEGORY_MAIN_CAPTURE]       = conf_main_capture_table;
917                 hcamcorder->conf_main_info_table[CONFIGURE_CATEGORY_MAIN_RECORD]        = conf_main_record_table;
918                 hcamcorder->conf_main_info_table[CONFIGURE_CATEGORY_MAIN_VIDEO_ENCODER] = conf_main_video_encoder_table;
919                 hcamcorder->conf_main_info_table[CONFIGURE_CATEGORY_MAIN_AUDIO_ENCODER] = conf_main_audio_encoder_table;
920                 hcamcorder->conf_main_info_table[CONFIGURE_CATEGORY_MAIN_IMAGE_ENCODER] = conf_main_image_encoder_table;
921                 hcamcorder->conf_main_info_table[CONFIGURE_CATEGORY_MAIN_MUX]           = conf_main_mux_table;
922
923                 hcamcorder->conf_main_category_size[CONFIGURE_CATEGORY_MAIN_GENERAL]       = sizeof(conf_main_general_table) / info_table_size;
924                 hcamcorder->conf_main_category_size[CONFIGURE_CATEGORY_MAIN_VIDEO_INPUT]   = sizeof(conf_main_video_input_table) / info_table_size;
925                 hcamcorder->conf_main_category_size[CONFIGURE_CATEGORY_MAIN_AUDIO_INPUT]   = sizeof(conf_main_audio_input_table) / info_table_size;
926                 hcamcorder->conf_main_category_size[CONFIGURE_CATEGORY_MAIN_VIDEO_OUTPUT]  = sizeof(conf_main_video_output_table) / info_table_size;
927                 hcamcorder->conf_main_category_size[CONFIGURE_CATEGORY_MAIN_CAPTURE]       = sizeof(conf_main_capture_table) / info_table_size;
928                 hcamcorder->conf_main_category_size[CONFIGURE_CATEGORY_MAIN_RECORD]        = sizeof(conf_main_record_table) / info_table_size;
929                 hcamcorder->conf_main_category_size[CONFIGURE_CATEGORY_MAIN_VIDEO_ENCODER] = sizeof(conf_main_video_encoder_table) / info_table_size;
930                 hcamcorder->conf_main_category_size[CONFIGURE_CATEGORY_MAIN_AUDIO_ENCODER] = sizeof(conf_main_audio_encoder_table) / info_table_size;
931                 hcamcorder->conf_main_category_size[CONFIGURE_CATEGORY_MAIN_IMAGE_ENCODER] = sizeof(conf_main_image_encoder_table) / info_table_size;
932                 hcamcorder->conf_main_category_size[CONFIGURE_CATEGORY_MAIN_MUX]           = sizeof(conf_main_mux_table) / info_table_size;
933
934                 category_num = CONFIGURE_CATEGORY_MAIN_NUM;
935         } else {
936                 hcamcorder->conf_ctrl_info_table[CONFIGURE_CATEGORY_CTRL_CAMERA]     = conf_ctrl_camera_table;
937                 hcamcorder->conf_ctrl_info_table[CONFIGURE_CATEGORY_CTRL_STROBE]     = conf_ctrl_strobe_table;
938                 hcamcorder->conf_ctrl_info_table[CONFIGURE_CATEGORY_CTRL_EFFECT]     = conf_ctrl_effect_table;
939                 hcamcorder->conf_ctrl_info_table[CONFIGURE_CATEGORY_CTRL_PHOTOGRAPH] = conf_ctrl_photograph_table;
940                 hcamcorder->conf_ctrl_info_table[CONFIGURE_CATEGORY_CTRL_CAPTURE]    = conf_ctrl_capture_table;
941                 hcamcorder->conf_ctrl_info_table[CONFIGURE_CATEGORY_CTRL_DETECT]     = conf_ctrl_detect_table;
942
943                 hcamcorder->conf_ctrl_category_size[CONFIGURE_CATEGORY_CTRL_CAMERA]     = sizeof(conf_ctrl_camera_table) / info_table_size;
944                 hcamcorder->conf_ctrl_category_size[CONFIGURE_CATEGORY_CTRL_STROBE]     = sizeof(conf_ctrl_strobe_table) / info_table_size;
945                 hcamcorder->conf_ctrl_category_size[CONFIGURE_CATEGORY_CTRL_EFFECT]     = sizeof(conf_ctrl_effect_table) / info_table_size;
946                 hcamcorder->conf_ctrl_category_size[CONFIGURE_CATEGORY_CTRL_PHOTOGRAPH] = sizeof(conf_ctrl_photograph_table) / info_table_size;
947                 hcamcorder->conf_ctrl_category_size[CONFIGURE_CATEGORY_CTRL_CAPTURE]    = sizeof(conf_ctrl_capture_table) / info_table_size;
948                 hcamcorder->conf_ctrl_category_size[CONFIGURE_CATEGORY_CTRL_DETECT]     = sizeof(conf_ctrl_detect_table) / info_table_size;
949
950                 category_num = CONFIGURE_CATEGORY_CTRL_NUM;
951         }
952
953         configure_info->info = (conf_detail **)g_malloc0(sizeof(conf_detail *) * category_num);
954
955         MMCAM_LOG_INFO("Done.");
956
957         return MM_ERROR_NONE;
958 }
959
960
961 int _mmcamcorder_conf_get_info(MMHandleType handle, int type, const char *ConfFile, camera_conf **configure_info)
962 {
963         int ret = MM_ERROR_NONE;
964         FILE *fp = NULL;
965         char conf_path[MMCAMCORDER_CONF_FILEPATH_LENGTH] = {'\0',};
966
967         MMCAM_LOG_INFO("Opening...[%s]", ConfFile);
968
969         mmf_return_val_if_fail(ConfFile, FALSE);
970
971         snprintf(conf_path, sizeof(conf_path), "%s/multimedia/%s", SYSCONFDIR, ConfFile);
972         MMCAM_LOG_INFO("Try open Configure File[%s]", conf_path);
973
974         fp = fopen(conf_path, "r");
975         if (!fp) {
976                 MMCAM_LOG_WARNING("File open failed.[%s] retry...", conf_path);
977
978                 snprintf(conf_path, sizeof(conf_path), "%s/multimedia/%s", TZ_SYS_ETC, ConfFile);
979                 MMCAM_LOG_INFO("Try open Configure File[%s]", conf_path);
980                 fp = fopen(conf_path, "r");
981                 if (!fp) {
982                         MMCAM_LOG_WARNING("open failed.[%s] errno [%d]", conf_path, errno);
983                         return MM_ERROR_CAMCORDER_NOT_SUPPORTED;
984                 }
985         }
986
987         ret = _mmcamcorder_conf_parse_info(handle, type, fp, configure_info);
988
989         fclose(fp);
990
991         MMCAM_LOG_INFO("Leave [0x%x]", ret);
992
993         return ret;
994 }
995
996
997 int _mmcamcorder_conf_parse_info(MMHandleType handle, int type, FILE *fp, camera_conf **configure_info)
998 {
999         const unsigned int BUFFER_NUM_DETAILS = 256;
1000         const unsigned int BUFFER_NUM_TOKEN = 20;
1001         size_t buffer_line_size = MMCAMCORDER_BUFFER_LINE_MAX;
1002         const char* delimiters = " |=,\t\r\n";
1003
1004         int i = 0;
1005         int ret = MM_ERROR_NONE;
1006         int category = 0;
1007         int count_main_category = 0;
1008         int count_details = 0;
1009         int length_read = 0;
1010         int count_token = 0;
1011         int read_main = 0;
1012
1013         char *buffer_string = NULL;
1014         char *buffer_details[BUFFER_NUM_DETAILS];
1015         char *buffer_token[BUFFER_NUM_TOKEN];
1016         char *token = NULL;
1017         char *category_name = NULL;
1018         char *detail_string = NULL;
1019         char *user_ptr = NULL;
1020
1021         camera_conf *new_conf = NULL;
1022
1023         MMCAM_LOG_INFO("");
1024
1025         mmf_return_val_if_fail(handle && fp && configure_info, MM_ERROR_INVALID_ARGUMENT);
1026
1027         *configure_info = NULL;
1028
1029         new_conf = (camera_conf *)g_malloc0(sizeof(camera_conf));
1030         buffer_string = (char *)g_malloc0(sizeof(char) * buffer_line_size);
1031
1032         new_conf->type  = type;
1033
1034         ret = _mmcamcorder_conf_init(handle, type, new_conf);
1035         if (ret != MM_ERROR_NONE) {
1036                 MMCAM_LOG_ERROR("conf init failed 0x%x", ret);
1037                 g_free(new_conf);
1038                 g_free(buffer_string);
1039                 return ret;
1040         }
1041
1042         *configure_info = new_conf;
1043
1044         read_main = 0;
1045         count_main_category = 0;
1046
1047         while (!feof(fp)) {
1048                 if (read_main == 0) {
1049                         buffer_line_size = MMCAMCORDER_BUFFER_LINE_MAX;
1050                         length_read = getline(&buffer_string, &buffer_line_size, fp);
1051                         if (length_read < 1) {
1052                                 MMCAM_LOG_DEBUG("skip this case - length read[%d]", length_read);
1053                                 continue;
1054                         }
1055
1056                         buffer_string[--length_read] = '\0'; /* remove new line character */
1057
1058                         MMCAM_LOG_DEBUG("Read Line : \"%s\"", buffer_string);
1059
1060                         count_token = 0;
1061                         token = strtok_r(buffer_string, delimiters, &user_ptr);
1062
1063                         if ((token) && (token[0] == ';') && (length_read > -1)) {
1064                                 MMCAM_LOG_VERBOSE( "Comment - Nothing to do" );
1065                                 continue;
1066                         }
1067
1068                         while (token) {
1069                                 MMCAM_LOG_VERBOSE("token : \"%s\"", token);
1070                                 buffer_token[count_token] = token;
1071                                 count_token++;
1072                                 token = strtok_r(NULL, delimiters, &user_ptr);
1073                         }
1074
1075                         if (count_token == 0)
1076                                 continue;
1077                 }
1078
1079                 read_main = 0;
1080
1081                 if (*buffer_token[0] == ';') {
1082                         /* Comment */
1083                         MMCAM_LOG_VERBOSE( "Comment - Nothing to do" );
1084                 } else if (*buffer_token[0] == '[') {
1085                         /* Main Category */
1086                         category_name = get_new_string(buffer_token[0]);
1087                         if (category_name == NULL) {
1088                                 MMCAM_LOG_ERROR("strdup failed for \"%s\"", buffer_token[0]);
1089                                 continue;
1090                         }
1091
1092                         count_main_category++;
1093                         count_details = 0;
1094
1095                         while (!feof(fp)) {
1096                                 length_read = getline(&buffer_string, &buffer_line_size, fp);
1097                                 if (length_read < 1) {
1098                                         MMCAM_LOG_DEBUG("skip this case - length read[%d]", length_read);
1099                                         continue;
1100                                 }
1101
1102                                 buffer_string[--length_read] = '\0'; /* remove new line character */
1103
1104                                 MMCAM_LOG_DEBUG("Read Detail Line : \"%s\", length[%d]", buffer_string, length_read);
1105
1106                                 detail_string = get_new_string(buffer_string);
1107
1108                                 token = strtok_r(buffer_string, delimiters, &user_ptr);
1109
1110                                 if (token && token[0] != ';' && length_read > -1) {
1111                                         MMCAM_LOG_VERBOSE("token : [%s]", token);
1112                                         if (token[0] == '[') {
1113                                                 read_main = 1;
1114                                                 buffer_token[0] = token;
1115                                                 SAFE_G_FREE(detail_string);
1116                                                 break;
1117                                         }
1118
1119                                         buffer_details[count_details++] = detail_string;
1120                                 } else {
1121                                         SAFE_G_FREE(detail_string);
1122                                 }
1123                         }
1124
1125                         MMCAM_LOG_DEBUG("type : %d, category_name : %s, count : [%d]", type, category_name, count_details);
1126
1127                         if (count_details == 0) {
1128                                 MMCAM_LOG_WARNING("category %s has no detail value... skip this category...", category_name);
1129                                 SAFE_G_FREE(category_name);
1130                                 continue;
1131                         }
1132
1133                         category = -1;
1134
1135                         /* Details */
1136                         if (type == CONFIGURE_TYPE_MAIN) {
1137                                 if (!strcmp("[General]", category_name))
1138                                         category = CONFIGURE_CATEGORY_MAIN_GENERAL;
1139                                 else if (!strcmp("[VideoInput]", category_name))
1140                                         category = CONFIGURE_CATEGORY_MAIN_VIDEO_INPUT;
1141                                 else if (!strcmp("[AudioInput]", category_name))
1142                                         category = CONFIGURE_CATEGORY_MAIN_AUDIO_INPUT;
1143                                 else if (!strcmp("[VideoOutput]", category_name))
1144                                         category = CONFIGURE_CATEGORY_MAIN_VIDEO_OUTPUT;
1145                                 else if (!strcmp("[Capture]", category_name))
1146                                         category = CONFIGURE_CATEGORY_MAIN_CAPTURE;
1147                                 else if (!strcmp("[Record]", category_name))
1148                                         category = CONFIGURE_CATEGORY_MAIN_RECORD;
1149                                 else if (!strcmp("[VideoEncoder]", category_name))
1150                                         category = CONFIGURE_CATEGORY_MAIN_VIDEO_ENCODER;
1151                                 else if (!strcmp("[AudioEncoder]", category_name))
1152                                         category = CONFIGURE_CATEGORY_MAIN_AUDIO_ENCODER;
1153                                 else if (!strcmp("[ImageEncoder]", category_name))
1154                                         category = CONFIGURE_CATEGORY_MAIN_IMAGE_ENCODER;
1155                                 else if (!strcmp("[Mux]", category_name))
1156                                         category = CONFIGURE_CATEGORY_MAIN_MUX;
1157                         } else {
1158                                 if (!strcmp("[Camera]", category_name))
1159                                         category = CONFIGURE_CATEGORY_CTRL_CAMERA;
1160                                 else if (!strcmp("[Strobe]", category_name))
1161                                         category = CONFIGURE_CATEGORY_CTRL_STROBE;
1162                                 else if (!strcmp("[Effect]", category_name))
1163                                         category = CONFIGURE_CATEGORY_CTRL_EFFECT;
1164                                 else if (!strcmp("[Photograph]", category_name))
1165                                         category = CONFIGURE_CATEGORY_CTRL_PHOTOGRAPH;
1166                                 else if (!strcmp("[Capture]", category_name))
1167                                         category = CONFIGURE_CATEGORY_CTRL_CAPTURE;
1168                                 else if (!strcmp("[Detect]", category_name))
1169                                         category = CONFIGURE_CATEGORY_CTRL_DETECT;
1170                         }
1171
1172                         if (category != -1) {
1173                                 _mmcamcorder_conf_add_info(handle, type, &(new_conf->info[category]),
1174                                         buffer_details, category, count_details);
1175                         } else {
1176                                 MMCAM_LOG_WARNING("No matched category[%s],type[%d]... check it.", category_name, type);
1177                         }
1178
1179                         /* Free memory */
1180                         for (i = 0 ; i < count_details ; i++)
1181                                 SAFE_G_FREE(buffer_details[i]);
1182                 }
1183
1184                 SAFE_G_FREE(category_name);
1185         }
1186
1187         /* (*configure_info) = new_conf; */
1188
1189         SAFE_G_FREE(buffer_string);
1190
1191         /*MMCAM_LOG_INFO("Done.");*/
1192
1193         return MM_ERROR_NONE;
1194 }
1195
1196
1197 void _mmcamcorder_conf_release_info(MMHandleType handle, camera_conf **configure_info)
1198 {
1199         int i = 0;
1200         int j = 0;
1201         int k = 0;
1202         int type = CONFIGURE_VALUE_INT;
1203         int count = 0;
1204         int category_num = CONFIGURE_CATEGORY_MAIN_NUM;
1205         camera_conf *temp_conf = (*configure_info);
1206
1207         type_int2 *temp_int = NULL;
1208         type_int_range *temp_int_range = NULL;
1209         type_int_array *temp_int_array = NULL;
1210         type_int_pair_array *temp_int_pair_array = NULL;
1211         type_string2 *temp_string = NULL;
1212         type_string_array *temp_string_array = NULL;
1213         type_element2 *temp_element = NULL;
1214
1215         MMCAM_LOG_INFO("Entered...");
1216
1217         mmf_return_if_fail(temp_conf);
1218
1219         if ((*configure_info)->type == CONFIGURE_TYPE_MAIN)
1220                 category_num = CONFIGURE_CATEGORY_MAIN_NUM;
1221         else
1222                 category_num = CONFIGURE_CATEGORY_CTRL_NUM;
1223
1224         for (i = 0 ; i < category_num ; i++) {
1225                 if (temp_conf->info[i]) {
1226                         for (j = 0 ; j < temp_conf->info[i]->count ; j++) {
1227                                 if (temp_conf->info[i]->detail_info[j] == NULL)
1228                                         continue;
1229
1230                                 if (_mmcamcorder_conf_get_value_type(handle, temp_conf->type, i, ((type_element*)(temp_conf->info[i]->detail_info[j]))->name, &type)) {
1231                                         switch (type) {
1232                                         case CONFIGURE_VALUE_INT:
1233                                                 temp_int = (type_int2*)(temp_conf->info[i]->detail_info[j]);
1234                                                 SAFE_G_FREE(temp_int->name);
1235                                                 break;
1236                                         case CONFIGURE_VALUE_INT_RANGE:
1237                                                 temp_int_range = (type_int_range*)(temp_conf->info[i]->detail_info[j]);
1238                                                 SAFE_G_FREE(temp_int_range->name);
1239                                                 break;
1240                                         case CONFIGURE_VALUE_INT_ARRAY:
1241                                                 temp_int_array = (type_int_array*)(temp_conf->info[i]->detail_info[j]);
1242                                                 SAFE_G_FREE(temp_int_array->name);
1243                                                 SAFE_G_FREE(temp_int_array->value);
1244                                                 break;
1245                                         case CONFIGURE_VALUE_INT_PAIR_ARRAY:
1246                                                 temp_int_pair_array = (type_int_pair_array*)(temp_conf->info[i]->detail_info[j]);
1247                                                 SAFE_G_FREE(temp_int_pair_array->name);
1248                                                 SAFE_G_FREE(temp_int_pair_array->value[0]);
1249                                                 SAFE_G_FREE(temp_int_pair_array->value[1]);
1250                                                 break;
1251                                         case CONFIGURE_VALUE_STRING:
1252                                                 temp_string = (type_string2*)(temp_conf->info[i]->detail_info[j]);
1253                                                 SAFE_G_FREE(temp_string->name);
1254                                                 SAFE_G_FREE(temp_string->value);
1255                                                 break;
1256                                         case CONFIGURE_VALUE_STRING_ARRAY:
1257                                                 temp_string_array = (type_string_array*)(temp_conf->info[i]->detail_info[j]);
1258                                                 SAFE_G_FREE(temp_string_array->name);
1259                                                 if (temp_string_array->value) {
1260                                                         count = temp_string_array->count;
1261
1262                                                         for (k = 0 ; k < count ; k++)
1263                                                                 SAFE_G_FREE(temp_string_array->value[k]);
1264
1265                                                         SAFE_G_FREE(temp_string_array->value);
1266                                                 }
1267                                                 SAFE_G_FREE(temp_string_array->default_value);
1268                                                 break;
1269                                         case CONFIGURE_VALUE_ELEMENT:
1270                                                 temp_element = (type_element2*)(temp_conf->info[i]->detail_info[j]);
1271                                                 SAFE_G_FREE(temp_element->name);
1272                                                 SAFE_G_FREE(temp_element->element_name);
1273
1274                                                 if (temp_element->value_int) {
1275                                                         count = temp_element->count_int;
1276                                                         for (k = 0 ; k < count ; k++) {
1277                                                                 SAFE_G_FREE(temp_element->value_int[k]->name);
1278                                                                 SAFE_G_FREE(temp_element->value_int[k]);
1279                                                         }
1280                                                         SAFE_G_FREE(temp_element->value_int);
1281                                                 }
1282
1283                                                 if (temp_element->value_string) {
1284                                                         count = temp_element->count_string;
1285                                                         for (k = 0 ; k < count ; k++) {
1286                                                                 SAFE_G_FREE(temp_element->value_string[k]->name);
1287                                                                 SAFE_G_FREE(temp_element->value_string[k]->value);
1288                                                                 SAFE_G_FREE(temp_element->value_string[k]);
1289                                                         }
1290                                                         SAFE_G_FREE(temp_element->value_string);
1291                                                 }
1292                                                 break;
1293                                         default:
1294                                                 MMCAM_LOG_WARNING("unknown type %d", type);
1295                                                 break;
1296                                         }
1297                                 }
1298
1299                                 SAFE_G_FREE(temp_conf->info[i]->detail_info[j]);
1300                         }
1301
1302                         SAFE_G_FREE(temp_conf->info[i]->detail_info);
1303
1304                         SAFE_G_FREE(temp_conf->info[i]);
1305                         temp_conf->info[i] = NULL;
1306                 }
1307         }
1308
1309         SAFE_G_FREE((*configure_info)->info);
1310         SAFE_G_FREE((*configure_info));
1311
1312         MMCAM_LOG_INFO("Done.");
1313 }
1314
1315 int _mmcamcorder_conf_get_value_type(MMHandleType handle, int type, int category, const char* name, int* value_type)
1316 {
1317         int i = 0;
1318         int count_value = 0;
1319
1320         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
1321
1322         if (hcamcorder == NULL) {
1323                 MMCAM_LOG_ERROR("handle is NULL");
1324                 return FALSE;
1325         }
1326
1327         /*MMCAM_LOG_INFO("Entered...");*/
1328
1329         mmf_return_val_if_fail(name, FALSE);
1330
1331         if (!_mmcamcorder_conf_get_category_size(handle, type, category, &count_value)) {
1332                 MMCAM_LOG_WARNING("No matched category... check it... categoty[%d]", category);
1333                 return FALSE;
1334         }
1335
1336         /*MMCAM_LOG_INFO("Number of value : [%d]", count_value);*/
1337
1338         if (type == CONFIGURE_TYPE_MAIN) {
1339                 for (i = 0 ; i < count_value ; i++) {
1340                         if (!strcmp(hcamcorder->conf_main_info_table[category][i].name, name)) {
1341                                 *value_type = hcamcorder->conf_main_info_table[category][i].value_type;
1342                                 /*MMCAM_LOG_INFO("Category[%d],Name[%s],Type[%d]", category, name, *value_type);*/
1343                                 return TRUE;
1344                         }
1345                 }
1346         } else {
1347                 for (i = 0 ; i < count_value ; i++) {
1348                         if (!strcmp(hcamcorder->conf_ctrl_info_table[category][i].name, name)) {
1349                                 *value_type = hcamcorder->conf_ctrl_info_table[category][i].value_type;
1350                                 /*MMCAM_LOG_INFO("Category[%d],Name[%s],Type[%d]", category, name, *value_type);*/
1351                                 return TRUE;
1352                         }
1353                 }
1354         }
1355
1356         return FALSE;
1357 }
1358
1359
1360 int _mmcamcorder_conf_add_info(MMHandleType handle, int type, conf_detail **info, char **buffer_details, int category, int count_details)
1361 {
1362         const int BUFFER_NUM_TOKEN = 256;
1363
1364         int i = 0;
1365         int j = 0;
1366         int count_token;
1367         int value_type;
1368         char *token = NULL;
1369         char *buffer_token[BUFFER_NUM_TOKEN];
1370         char *user_ptr = NULL;
1371
1372         const char *delimiters     = " |=,\t\r\n";
1373         const char *delimiters_sub = " |\t\r\n";
1374         const char *delimiters_3rd = "|\r\n";
1375
1376         mmf_return_val_if_fail(info && buffer_details, FALSE);
1377
1378         (*info) = (conf_detail *)g_malloc0(sizeof(conf_detail));
1379         (*info)->detail_info = (void**)g_malloc0(sizeof(void*) * count_details);
1380         (*info)->count = count_details;
1381
1382         for (i = 0 ; i < count_details ; i++) {
1383                 MMCAM_LOG_VERBOSE("Read line \"%s\"", buffer_details[i]);
1384                 count_token = 0;
1385                 token = strtok_r(buffer_details[i], delimiters, &user_ptr);
1386
1387                 if (token) {
1388                         buffer_token[count_token] = token;
1389                         count_token++;
1390                 } else {
1391                         (*info)->detail_info[i] = NULL;
1392                         MMCAM_LOG_WARNING("No token... check it.[%s]", buffer_details[i]);
1393                         continue;
1394                 }
1395
1396                 if (!_mmcamcorder_conf_get_value_type(handle, type, category, buffer_token[0], &value_type)) {
1397                         (*info)->detail_info[i] = NULL;
1398                         MMCAM_LOG_WARNING("Failed to get value type... check it. Category[%d],Name[%s]", category, buffer_token[0]);
1399                         continue;
1400                 }
1401
1402                 if (value_type != CONFIGURE_VALUE_STRING && value_type != CONFIGURE_VALUE_STRING_ARRAY) {
1403                         token = strtok_r(NULL, delimiters, &user_ptr);
1404                         while (token) {
1405                                 buffer_token[count_token] = token;
1406                                 MMCAM_LOG_VERBOSE("token : [%s]", buffer_token[count_token]);
1407                                 count_token++;
1408                                 token = strtok_r(NULL, delimiters, &user_ptr);
1409                         }
1410
1411                         if (count_token < 2) {
1412                                 (*info)->detail_info[i] = NULL;
1413                                 MMCAM_LOG_WARNING("Number of token is too small... check it.[%s]", buffer_details[i]);
1414                                 continue;
1415                         }
1416                 } else { /* CONFIGURE_VALUE_STRING or CONFIGURE_VALUE_STRING_ARRAY */
1417                         /* skip "=" */
1418                         strtok_r(NULL, delimiters_sub, &user_ptr);
1419
1420                         if (value_type == CONFIGURE_VALUE_STRING_ARRAY) {
1421                                 token = strtok_r(NULL, delimiters_sub, &user_ptr);
1422                                 while (token) {
1423                                         buffer_token[count_token] = token;
1424                                         MMCAM_LOG_VERBOSE("token : [%s]", buffer_token[count_token]);
1425                                         count_token++;
1426                                         token = strtok_r(NULL, delimiters_sub, &user_ptr);
1427                                 }
1428                         } else { /* CONFIGURE_VALUE_STRING */
1429                                 token = strtok_r(NULL, delimiters_3rd, &user_ptr);
1430                                 if (token) {
1431                                         g_strchug(token);
1432                                         buffer_token[count_token] = token;
1433                                         MMCAM_LOG_VERBOSE("token : [%s]", buffer_token[count_token]);
1434                                         count_token++;
1435                                 }
1436                         }
1437
1438                         if (count_token < 2) {
1439                                 (*info)->detail_info[i] = NULL;
1440                                 MMCAM_LOG_WARNING("No string value... check it.[%s]", buffer_details[i]);
1441                                 continue;
1442                         }
1443                 }
1444
1445                 switch (value_type) {
1446                 case CONFIGURE_VALUE_INT:
1447                 {
1448                         type_int2* new_int;
1449
1450                         new_int = (type_int2*)g_malloc0(sizeof(type_int2));
1451                         new_int->name  = get_new_string(buffer_token[0]);
1452                         new_int->value = atoi(buffer_token[1]);
1453                         (*info)->detail_info[i] = (void*)new_int;
1454                         MMCAM_LOG_VERBOSE("INT - name[%s],value[%d]", new_int->name, new_int->value);
1455                         break;
1456                 }
1457                 case CONFIGURE_VALUE_INT_RANGE:
1458                 {
1459                         type_int_range* new_int_range;
1460
1461                         new_int_range = (type_int_range*)g_malloc0(sizeof(type_int_range));
1462                         new_int_range->name          = get_new_string(buffer_token[0]);
1463                         new_int_range->min           = atoi(buffer_token[1]);
1464                         new_int_range->max           = atoi(buffer_token[2]);
1465                         new_int_range->default_value = atoi(buffer_token[3]);
1466                         (*info)->detail_info[i]      = (void*)new_int_range;
1467
1468                         MMCAM_LOG_VERBOSE("INT RANGE - name[%s],min[%d],max[%d],default[%d]",
1469                                 new_int_range->name,
1470                                 new_int_range->min,
1471                                 new_int_range->max,
1472                                 new_int_range->default_value);
1473                         break;
1474                 }
1475                 case CONFIGURE_VALUE_INT_ARRAY:
1476                 {
1477                         int count_value = count_token - 2;
1478                         type_int_array* new_int_array;
1479
1480                         new_int_array = (type_int_array*)g_malloc0(sizeof(type_int_array));
1481                         new_int_array->name = get_new_string(buffer_token[0]);
1482                         new_int_array->value = (int*)g_malloc0(sizeof(int)*count_value);
1483                         new_int_array->count = count_value;
1484
1485                         MMCAM_LOG_VERBOSE("INT ARRAY - name[%s]", new_int_array->name);
1486                         for (j = 0 ; j < count_value ; j++) {
1487                                 new_int_array->value[j] = atoi(buffer_token[j+1]);
1488                                 MMCAM_LOG_VERBOSE("   index[%d] - value[%d]", j, new_int_array->value[j]);
1489                         }
1490
1491                         new_int_array->default_value = atoi(buffer_token[count_token-1]);
1492                         MMCAM_LOG_VERBOSE("   default value[%d]", new_int_array->default_value);
1493
1494                         (*info)->detail_info[i] = (void*)new_int_array;
1495                         break;
1496                 }
1497                 case CONFIGURE_VALUE_INT_PAIR_ARRAY:
1498                 {
1499                         int count_value = (count_token - 3) >> 1;
1500                         type_int_pair_array* new_int_pair_array;
1501
1502                         new_int_pair_array = (type_int_pair_array*)g_malloc0(sizeof(type_int_pair_array));
1503                         new_int_pair_array->name = get_new_string(buffer_token[0]);
1504                         new_int_pair_array->value[0] = (int*)g_malloc0(sizeof(int)*(count_value));
1505                         new_int_pair_array->value[1] = (int*)g_malloc0(sizeof(int)*(count_value));
1506                         new_int_pair_array->count    = count_value;
1507
1508                         MMCAM_LOG_VERBOSE("INT PAIR ARRAY - name[%s],count[%d]", new_int_pair_array->name, count_value);
1509                         for (j = 0 ; j < count_value ; j++) {
1510                                 new_int_pair_array->value[0][j] = atoi(buffer_token[(j<<1)+1]);
1511                                 new_int_pair_array->value[1][j] = atoi(buffer_token[(j<<1)+2]);
1512
1513                                 MMCAM_LOG_VERBOSE("   index[%d] - value[%d,%d]", j,
1514                                         new_int_pair_array->value[0][j],
1515                                         new_int_pair_array->value[1][j]);
1516                         }
1517
1518                         new_int_pair_array->default_value[0] = atoi(buffer_token[count_token-2]);
1519                         new_int_pair_array->default_value[1] = atoi(buffer_token[count_token-1]);
1520
1521                         MMCAM_LOG_VERBOSE("   default value[%d,%d]",
1522                                 new_int_pair_array->default_value[0],
1523                                 new_int_pair_array->default_value[1]);
1524
1525                         (*info)->detail_info[i] = (void*)new_int_pair_array;
1526                         break;
1527                 }
1528                 case CONFIGURE_VALUE_STRING:
1529                 {
1530                         type_string2* new_string;
1531
1532                         new_string = (type_string2*)g_malloc0(sizeof(type_string2));
1533                         new_string->name  = get_new_string(buffer_token[0]);
1534                         new_string->value = get_new_string(buffer_token[1]);
1535                         (*info)->detail_info[i] = (void*)new_string;
1536
1537                         MMCAM_LOG_VERBOSE("STRING - name[%s],value[%s]", new_string->name, new_string->value);
1538                         break;
1539                 }
1540                 case CONFIGURE_VALUE_STRING_ARRAY:
1541                 {
1542                         int count_value = count_token - 2;
1543                         type_string_array* new_string_array;
1544
1545                         new_string_array = (type_string_array*)g_malloc0(sizeof(type_string_array));
1546                         new_string_array->name  = get_new_string(buffer_token[0]);
1547                         new_string_array->count = count_value;
1548                         new_string_array->value = (char**)g_malloc0(sizeof(char*)*count_value);
1549
1550                         MMCAM_LOG_VERBOSE("STRING ARRAY - name[%s]", new_string_array->name);
1551
1552                         for (j = 0 ; j < count_value ; j++) {
1553                                 new_string_array->value[j] = get_new_string(buffer_token[j+1]);
1554                                 MMCAM_LOG_VERBOSE("   index[%d] - value[%s]", j, new_string_array->value[j]);
1555                         }
1556
1557                         new_string_array->default_value = get_new_string(buffer_token[count_token-1]);
1558
1559                         MMCAM_LOG_VERBOSE("   default value[%s]", new_string_array->default_value);
1560
1561                         (*info)->detail_info[i] = (void*)new_string_array;
1562                         break;
1563                 }
1564                 case CONFIGURE_VALUE_ELEMENT:
1565                 {
1566                         type_element2* new_element;
1567
1568                         j = 0;
1569                         new_element = (type_element2*)g_malloc0(sizeof(type_element2));
1570                         new_element->name         = get_new_string(buffer_token[0]);
1571                         new_element->element_name = get_new_string(buffer_token[1]);
1572                         new_element->count_int    = atoi(buffer_token[2]);
1573                         new_element->value_int    = NULL;
1574                         new_element->count_string = atoi(buffer_token[3]);
1575                         new_element->value_string = NULL;
1576
1577                         MMCAM_LOG_VERBOSE("Element - name[%s],element_name[%s],count_int[%d],count_string[%d]",
1578                                 new_element->name, new_element->element_name, new_element->count_int, new_element->count_string);
1579
1580                         /* add int values */
1581                         if (new_element->count_int > 0 && new_element->count_int <= 30) {
1582                                 new_element->value_int = (type_int2**)g_malloc0(sizeof(type_int2*)*(new_element->count_int));
1583                                 for ( ; j < new_element->count_int ; j++) {
1584                                         new_element->value_int[j] = (type_int2*)g_malloc0(sizeof(type_int2));
1585                                         new_element->value_int[j]->name  = get_new_string(buffer_token[4+(j<<1)]);
1586                                         new_element->value_int[j]->value = atoi(buffer_token[5+(j<<1)]);
1587
1588                                         MMCAM_LOG_VERBOSE("   Element INT[%d] - name[%s],value[%d]",
1589                                                 j, new_element->value_int[j]->name, new_element->value_int[j]->value);
1590                                 }
1591                         }
1592
1593                         /* add string values */
1594                         if (new_element->count_string > 0 && new_element->count_string <= 30 &&
1595                                 new_element->count_int >= 0 && new_element->count_int <= 30) {
1596                                 new_element->value_string = (type_string2**)g_malloc0(sizeof(type_string2*)*(new_element->count_string));
1597                                 for ( ; j < new_element->count_string + new_element->count_int ; j++) {
1598                                         new_element->value_string[j-new_element->count_int]     = (type_string2*)g_malloc0(sizeof(type_string2));
1599                                         new_element->value_string[j-new_element->count_int]->name       = get_new_string(buffer_token[4+(j<<1)]);
1600                                         new_element->value_string[j-new_element->count_int]->value      = get_new_string(buffer_token[5+(j<<1)]);
1601
1602                                         MMCAM_LOG_VERBOSE("   Element STRING[%d] - name[%s],value[%s]",
1603                                                 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);
1604                                 }
1605                         }
1606
1607                         (*info)->detail_info[i] = (void*)new_element;
1608                         break;
1609                 }
1610                 default:
1611                         break;
1612                 }
1613         }
1614
1615         return TRUE;
1616 }
1617
1618
1619 int _mmcamcorder_conf_get_value_int(MMHandleType handle, camera_conf* configure_info, int category, const char* name, int* value)
1620 {
1621         int i, count;
1622         conf_detail* info;
1623
1624         MMCAM_LOG_VERBOSE("category[%d], name[%s]", category, name);
1625
1626         mmf_return_val_if_fail(configure_info, FALSE);
1627         mmf_return_val_if_fail(name, FALSE);
1628
1629         if (configure_info->info[category]) {
1630                 count = configure_info->info[category]->count;
1631                 info = configure_info->info[category];
1632
1633                 for (i = 0 ; i < count ; i++) {
1634                         if (info->detail_info[i] == NULL)
1635                                 continue;
1636
1637                         if (!strcmp(((type_int*)(info->detail_info[i]))->name , name)) {
1638                                 *value = ((type_int*)(info->detail_info[i]))->value;
1639                                 MMCAM_LOG_DEBUG("Get[%s] int[%d]", name, *value);
1640                                 return TRUE;
1641                         }
1642                 }
1643         }
1644
1645         if (_mmcamcorder_conf_get_default_value_int(handle, configure_info->type, category, name, value)) {
1646                  MMCAM_LOG_DEBUG("Get default [%s] int[%d]", name, *value);
1647                 return TRUE;
1648         }
1649
1650         MMCAM_LOG_DEBUG("Failed to get [%s]", name);
1651
1652         return FALSE;
1653 }
1654
1655 int
1656 _mmcamcorder_conf_get_value_int_range(camera_conf* configure_info, int category, const char* name, type_int_range** value)
1657 {
1658         int i, count;
1659         conf_detail* info;
1660
1661         MMCAM_LOG_VERBOSE("category[%d], name[%s]", category, name);
1662
1663         mmf_return_val_if_fail(configure_info, FALSE);
1664         mmf_return_val_if_fail(name, FALSE);
1665
1666         if (configure_info->info[category]) {
1667                 count = configure_info->info[category]->count;
1668                 info = configure_info->info[category];
1669
1670                 for (i = 0 ; i < count ; i++) {
1671                         if (info->detail_info[i] == NULL)
1672                                 continue;
1673
1674                         if (!strcmp(((type_int_range*)(info->detail_info[i]))->name , name)) {
1675                                 *value = (type_int_range*)(info->detail_info[i]);
1676                                 MMCAM_LOG_DEBUG("Get[%s] int range - min[%d],max[%d],default[%d]",
1677                                         name, (*value)->min, (*value)->max, (*value)->default_value);
1678                                 return TRUE;
1679                         }
1680                 }
1681         }
1682
1683         *value = NULL;
1684
1685         MMCAM_LOG_DEBUG("Failed to get [%s]", name);
1686
1687         return FALSE;
1688 }
1689
1690 int _mmcamcorder_conf_get_value_int_array(camera_conf* configure_info, int category, const char* name, type_int_array** value)
1691 {
1692         int i, count;
1693         conf_detail* info;
1694
1695         MMCAM_LOG_VERBOSE("category[%d], name[%s]", category, name);
1696
1697         mmf_return_val_if_fail(configure_info, FALSE);
1698         mmf_return_val_if_fail(name, FALSE);
1699
1700         if (configure_info->info[category]) {
1701                 count   = configure_info->info[category]->count;
1702                 info    = configure_info->info[category];
1703
1704                 for (i = 0 ; i < count ; i++) {
1705                         if (info->detail_info[i] == NULL)
1706                                 continue;
1707
1708                         if (!strcmp(((type_int_array*)(info->detail_info[i]))->name , name)) {
1709                                 *value = (type_int_array*)(info->detail_info[i]);
1710                                 MMCAM_LOG_DEBUG("Get[%s] int array - [%p],count[%d],default[%d]",
1711                                         name, (*value)->value, (*value)->count, (*value)->default_value);
1712                                 return TRUE;
1713                         }
1714                 }
1715         }
1716
1717         *value = NULL;
1718
1719         MMCAM_LOG_DEBUG("Failed to get [%s]", name);
1720
1721         return FALSE;
1722 }
1723
1724 int
1725 _mmcamcorder_conf_get_value_int_pair_array(camera_conf* configure_info, int category, const char* name, type_int_pair_array** value)
1726 {
1727         int i, count;
1728         conf_detail* info;
1729
1730         MMCAM_LOG_VERBOSE("category[%d], name[%s]", category, name);
1731
1732         mmf_return_val_if_fail(configure_info, FALSE);
1733         mmf_return_val_if_fail(name, FALSE);
1734
1735         if (configure_info->info[category]) {
1736                 count = configure_info->info[category]->count;
1737                 info = configure_info->info[category];
1738
1739                 for (i = 0 ; i < count ; i++) {
1740                         if (info->detail_info[i] == NULL)
1741                                 continue;
1742
1743                         if (!strcmp(((type_int_pair_array*)(info->detail_info[i]))->name , name)) {
1744                                 *value = (type_int_pair_array*)(info->detail_info[i]);
1745                                 MMCAM_LOG_DEBUG("Get[%s] int pair array - [%p][%p],count[%d],default[%d][%d]",
1746                                         name, (*value)->value[0], (*value)->value[1], (*value)->count,
1747                                         (*value)->default_value[0], (*value)->default_value[1]);
1748                                 return TRUE;
1749                         }
1750                 }
1751         }
1752
1753         *value = NULL;
1754
1755         MMCAM_LOG_DEBUG("Failed to get [%s]", name);
1756
1757         return FALSE;
1758 }
1759
1760 int _mmcamcorder_conf_get_value_string(MMHandleType handle, camera_conf* configure_info, int category, const char* name, const char** value)
1761 {
1762         int i, count;
1763         conf_detail* info;
1764
1765         MMCAM_LOG_VERBOSE("category[%d], name[%s]", category, name);
1766
1767         mmf_return_val_if_fail(configure_info, FALSE);
1768         mmf_return_val_if_fail(name, FALSE);
1769
1770         if (configure_info->info[category]) {
1771                 count = configure_info->info[category]->count;
1772                 info = configure_info->info[category];
1773
1774                 for (i = 0 ; i < count ; i++) {
1775                         if (info->detail_info[i] == NULL)
1776                                 continue;
1777
1778                         if (!strcmp(((type_string*)(info->detail_info[i]))->name , name)) {
1779                                 *value = ((type_string*)(info->detail_info[i]))->value;
1780                                  MMCAM_LOG_DEBUG("Get[%s] string[%s]", name, *value ? *value : "NULL");
1781                                 return TRUE;
1782                         }
1783                 }
1784         }
1785
1786         if (_mmcamcorder_conf_get_default_value_string(handle, configure_info->type, category, name, value)) {
1787                 MMCAM_LOG_DEBUG("Get default [%s] string[%s]", name, *value ? *value : "NULL");
1788                 return TRUE;
1789         }
1790
1791         MMCAM_LOG_DEBUG("Failed to get [%s]", name);
1792
1793         return FALSE;
1794 }
1795
1796 int _mmcamcorder_conf_get_value_string_array(camera_conf* configure_info, int category, const char* name, type_string_array** value)
1797 {
1798         int i, count;
1799         conf_detail* info;
1800
1801         MMCAM_LOG_VERBOSE("category[%d], name[%s]", category, name);
1802
1803         mmf_return_val_if_fail(configure_info, FALSE);
1804         mmf_return_val_if_fail(name, FALSE);
1805
1806         if (configure_info->info[category]) {
1807                 count = configure_info->info[category]->count;
1808                 info = configure_info->info[category];
1809
1810                 for (i = 0 ; i < count ; i++) {
1811                         if (info->detail_info[i] == NULL)
1812                                 continue;
1813
1814                         if (!strcmp(((type_string_array*)(info->detail_info[i]))->name , name)) {
1815                                 *value = (type_string_array*)(info->detail_info[i]);
1816                                 MMCAM_LOG_DEBUG("Get[%s] string array - [%p],count[%d],default[%s]",
1817                                         name, (*value)->value, (*value)->count, (*value)->default_value);
1818                                 return TRUE;
1819                         }
1820                 }
1821         }
1822
1823         *value = NULL;
1824
1825         MMCAM_LOG_DEBUG("Failed to get [%s]", name);
1826
1827         return FALSE;
1828 }
1829
1830 int _mmcamcorder_conf_get_element(MMHandleType handle, camera_conf* configure_info, int category, const char* name, type_element** element)
1831 {
1832         int i, count;
1833         conf_detail* info;
1834
1835         MMCAM_LOG_VERBOSE("category[%d], name[%s]", category, name);
1836
1837         mmf_return_val_if_fail(configure_info, FALSE);
1838         mmf_return_val_if_fail(name, FALSE);
1839
1840         if (configure_info->info[category]) {
1841                 count = configure_info->info[category]->count;
1842                 info = configure_info->info[category];
1843
1844                 for (i = 0 ; i < count ; i++) {
1845                         if (info->detail_info[i] == NULL)
1846                                 continue;
1847
1848                         if (!strcmp(((type_element*)(info->detail_info[i]))->name , name)) {
1849                                 *element = (type_element*)(info->detail_info[i]);
1850                                 MMCAM_LOG_DEBUG("Get[%s] element[%p]", name, *element);
1851                                 return TRUE;
1852                         }
1853                 }
1854         }
1855
1856         if (_mmcamcorder_conf_get_default_element(handle, configure_info->type, category, name, element)) {
1857                 MMCAM_LOG_DEBUG("Get default [%s] element[%p]", name, *element);
1858                 return TRUE;
1859         }
1860
1861         MMCAM_LOG_ERROR("Failed to get [%s]", name);
1862
1863         return FALSE;
1864 }
1865
1866 int _mmcamcorder_conf_get_value_element_name(type_element* element, const char** value)
1867 {
1868         mmf_return_val_if_fail(element, FALSE);
1869
1870         *value = element->element_name;
1871
1872         MMCAM_LOG_DEBUG("Get element name : [%s]", *value);
1873
1874         return TRUE;
1875 }
1876
1877 int _mmcamcorder_conf_get_value_element_int(type_element* element, const char* name, int* value)
1878 {
1879         int i;
1880
1881         mmf_return_val_if_fail(element, FALSE);
1882         mmf_return_val_if_fail(name, FALSE);
1883
1884         for (i = 0 ; i < element->count_int ; i++) {
1885                 if (!strcmp(element->value_int[i]->name, name)) {
1886                         *value = element->value_int[i]->value;
1887                         MMCAM_LOG_DEBUG("Get[%s] element int[%d]", name, *value);
1888                         return TRUE;
1889                 }
1890         }
1891
1892         MMCAM_LOG_ERROR("Failed to get int in element. Element[%s],Name[%s],Count[%d]",
1893                 element->name, name, element->count_int);
1894
1895         return FALSE;
1896 }
1897
1898 int _mmcamcorder_conf_get_value_element_string(type_element* element, const char* name, const char** value)
1899 {
1900         int i;
1901
1902         mmf_return_val_if_fail(element, FALSE);
1903         mmf_return_val_if_fail(name, FALSE);
1904
1905         for (i = 0 ; i < element->count_string ; i++) {
1906                 if (!strcmp(element->value_string[i]->name, name)) {
1907                         *value = element->value_string[i]->value;
1908                         MMCAM_LOG_DEBUG("Get[%s] element string[%s]", name, *value);
1909                         return TRUE;
1910                 }
1911         }
1912
1913         MMCAM_LOG_ERROR("Failed to get int in element. Element[%s],Name[%s],Count[%d]",
1914                 element->name, name, element->count_string);
1915
1916         return FALSE;
1917 }
1918
1919 int _mmcamcorder_conf_set_value_element_property(GstElement* gst, type_element* element)
1920 {
1921         int i;
1922
1923         mmf_return_val_if_fail(gst, FALSE);
1924         mmf_return_val_if_fail(element, FALSE);
1925
1926         if (element->count_int == 0) {
1927                 MMCAM_LOG_DEBUG("There is no integer property to set in INI file[%s].", element->name );
1928         } else {
1929                 if (element->value_int == NULL) {
1930                         MMCAM_LOG_WARNING("count_int[%d] is NOT zero, but value_int is NULL", element->count_int);
1931                         return FALSE;
1932                 }
1933
1934                 for (i = 0 ; i < element->count_int ; i++) {
1935                         MMCAMCORDER_G_OBJECT_SET(gst, element->value_int[i]->name, element->value_int[i]->value);
1936
1937                         MMCAM_LOG_DEBUG("Element[%s] Set[%s] -> [i:%d]",
1938                                 element->element_name,
1939                                 element->value_int[i]->name,
1940                                 element->value_int[i]->value);
1941                 }
1942         }
1943
1944         if (element->count_string == 0) {
1945                 MMCAM_LOG_DEBUG("There is no string property to set in INI file[%s].", element->name);
1946         } else {
1947                 if (element->value_string == NULL) {
1948                         MMCAM_LOG_WARNING("count_string[%d] is NOT zero, but value_string is NULL", element->count_string);
1949                         return FALSE;
1950                 }
1951
1952                 for (i = 0 ; i < element->count_string ; i++) {
1953                         MMCAMCORDER_G_OBJECT_SET_POINTER(gst, element->value_string[i]->name, element->value_string[i]->value);
1954
1955                         MMCAM_LOG_DEBUG("Element[%s] Set[%s] -> [s:%s]",
1956                                 element->element_name,
1957                                 element->value_string[i]->name,
1958                                 element->value_string[i]->value);
1959                 }
1960         }
1961
1962         return TRUE;
1963 }
1964
1965 int _mmcamcorder_conf_get_default_value_int(MMHandleType handle, int type, int category, const char* name, int* value)
1966 {
1967         int i = 0;
1968         int count_value = 0;
1969
1970         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
1971
1972         if (hcamcorder == NULL) {
1973                 MMCAM_LOG_ERROR("handle is NULL");
1974                 return FALSE;
1975         }
1976
1977         mmf_return_val_if_fail(name, FALSE);
1978
1979         if (!_mmcamcorder_conf_get_category_size(handle, type, category, &count_value)) {
1980                 MMCAM_LOG_WARNING("No matched category. categoty[%d]", category);
1981                 return FALSE;
1982         }
1983
1984         if (type == CONFIGURE_TYPE_MAIN) {
1985                 for (i = 0 ; i < count_value ; i++) {
1986                         if (!strcmp(hcamcorder->conf_main_info_table[category][i].name, name)) {
1987                                 *value = hcamcorder->conf_main_info_table[category][i].value_int;
1988                                 return TRUE;
1989                         }
1990                 }
1991         } else {
1992                 for (i = 0 ; i < count_value ; i++) {
1993                         if (!strcmp(hcamcorder->conf_ctrl_info_table[category][i].name, name)) {
1994                                 *value = hcamcorder->conf_ctrl_info_table[category][i].value_int;
1995                                 return TRUE;
1996                         }
1997                 }
1998         }
1999
2000         MMCAM_LOG_ERROR("Failed to get default int. Type[%d],Category[%d],Name[%s]", type, category, name);
2001
2002         return FALSE;
2003 }
2004
2005 int _mmcamcorder_conf_get_default_value_string(MMHandleType handle, int type, int category, const char* name, const char** value)
2006 {
2007         int i = 0;
2008         int count_value = 0;
2009
2010         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2011
2012         if (hcamcorder == NULL) {
2013                 MMCAM_LOG_ERROR("handle is NULL");
2014                 return FALSE;
2015         }
2016
2017         mmf_return_val_if_fail(name, FALSE);
2018
2019         if (!_mmcamcorder_conf_get_category_size(handle, type, category, &count_value)) {
2020                 MMCAM_LOG_WARNING("No matched category... check it... categoty[%d]", category);
2021                 return FALSE;
2022         }
2023
2024         if (type == CONFIGURE_TYPE_MAIN) {
2025                 for (i = 0 ; i < count_value ; i++) {
2026                         if (!strcmp(hcamcorder->conf_main_info_table[category][i].name, name)) {
2027                                 *value = hcamcorder->conf_main_info_table[category][i].value_string;
2028                                 return TRUE;
2029                         }
2030                 }
2031         } else {
2032                 for (i = 0 ; i < count_value ; i++) {
2033                         if (!strcmp(hcamcorder->conf_ctrl_info_table[category][i].name, name)) {
2034                                 *value = hcamcorder->conf_ctrl_info_table[category][i].value_string;
2035                                 return TRUE;
2036                         }
2037                 }
2038         }
2039
2040         MMCAM_LOG_ERROR("Failed to get default string. Type[%d],Category[%d],Name[%s]", type, category, name);
2041
2042         return FALSE;
2043 }
2044
2045 int _mmcamcorder_conf_get_default_element(MMHandleType handle, int type, int category, const char* name, type_element** element)
2046 {
2047         int i = 0;
2048         int count_value = 0;
2049
2050         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2051
2052         if (hcamcorder == NULL) {
2053                 MMCAM_LOG_ERROR("handle is NULL");
2054                 return FALSE;
2055         }
2056
2057         mmf_return_val_if_fail(name, FALSE);
2058
2059         if (!_mmcamcorder_conf_get_category_size(handle, type, category, &count_value)) {
2060                 MMCAM_LOG_WARNING("No matched category... check it... categoty[%d]", category);
2061                 return FALSE;
2062         }
2063
2064         if (type == CONFIGURE_TYPE_MAIN) {
2065                 for (i = 0 ; i < count_value ; i++) {
2066                         if (!strcmp(hcamcorder->conf_main_info_table[category][i].name, name)) {
2067                                 *element = hcamcorder->conf_main_info_table[category][i].value_element;
2068                                 return TRUE;
2069                         }
2070                 }
2071         } else {
2072                 for (i = 0 ; i < count_value ; i++) {
2073                         if (!strcmp(hcamcorder->conf_ctrl_info_table[category][i].name, name)) {
2074                                 *element = hcamcorder->conf_ctrl_info_table[category][i].value_element;
2075                                 return TRUE;
2076                         }
2077                 }
2078         }
2079
2080         MMCAM_LOG_ERROR("Failed to get default element. Type[%d],Category[%d],Name[%s]", type, category, name);
2081
2082         return FALSE;
2083 }
2084
2085 int _mmcamcorder_conf_get_category_size(MMHandleType handle, int type, int category, int* size)
2086 {
2087         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2088
2089         if (hcamcorder == NULL) {
2090                 MMCAM_LOG_ERROR("handle is NULL");
2091                 return FALSE;
2092         }
2093
2094         if (type == CONFIGURE_TYPE_MAIN) {
2095                 mmf_return_val_if_fail(category < CONFIGURE_CATEGORY_MAIN_NUM, FALSE);
2096                 *size = (int)hcamcorder->conf_main_category_size[category];
2097         } else {
2098                 mmf_return_val_if_fail(category < CONFIGURE_CATEGORY_CTRL_NUM, FALSE);
2099                 *size = (int)hcamcorder->conf_ctrl_category_size[category];
2100         }
2101
2102         return TRUE;
2103 }
2104
2105 void _mmcamcorder_conf_get_element_and_name(MMHandleType handle, camera_conf *conf, int category,
2106         const char *name, type_element **element, const char **element_name)
2107 {
2108         type_element *_element = NULL;
2109         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2110
2111         if (!hcamcorder) {
2112                 MMCAM_LOG_ERROR("NULL handle");
2113                 return;
2114         }
2115
2116         if (!_mmcamcorder_conf_get_element(handle, conf,
2117                 category, name, &_element)) {
2118                 MMCAM_LOG_WARNING("get [%s] failed", name);
2119                 return;
2120         }
2121
2122         if (element)
2123                 *element = _element;
2124
2125         if (element_name) {
2126                 _mmcamcorder_conf_get_value_element_name(_element, element_name);
2127                 MMCAM_LOG_INFO("[%s] -> [%s]", name, *element_name);
2128         }
2129 }
2130
2131 void _mmcamcorder_conf_print_info(MMHandleType handle, camera_conf** configure_info)
2132 {
2133         int i, j, k, type, category_type;
2134
2135         type_int                *temp_int;
2136         type_int_range          *temp_int_range;
2137         type_int_array          *temp_int_array;
2138         type_int_pair_array     *temp_int_pair_array;
2139         type_string             *temp_string;
2140         type_element            *temp_element;
2141
2142         g_print("[ConfigureInfoPrint] : Entered.\n");
2143
2144         mmf_return_if_fail(*configure_info);
2145
2146         if ((*configure_info)->type == CONFIGURE_TYPE_MAIN)
2147                 category_type = CONFIGURE_CATEGORY_MAIN_NUM;
2148         else
2149                 category_type = CONFIGURE_CATEGORY_CTRL_NUM;
2150
2151         for (i = 0 ; i < category_type ; i++) {
2152
2153                 if ((*configure_info)->info[i]) {
2154                         g_print("[ConfigureInfo] : Category [%d]\n", i);
2155
2156                         for (j = 0 ; j < (*configure_info)->info[i]->count ; j++) {
2157
2158                                 if (_mmcamcorder_conf_get_value_type(handle, (*configure_info)->type, i, ((type_int*)((*configure_info)->info[i]->detail_info[j]))->name, &type)) {
2159                                         switch (type) {
2160                                         case CONFIGURE_VALUE_INT:
2161                                                 temp_int = (type_int*)((*configure_info)->info[i]->detail_info[j]);
2162                                                 g_print("[ConfigureInfo] : INT - Name[%s],Value [%d]\n", temp_int->name, temp_int->value);
2163                                                 break;
2164                                         case CONFIGURE_VALUE_INT_RANGE:
2165                                                 temp_int_range = (type_int_range*)((*configure_info)->info[i]->detail_info[j]);
2166                                                 g_print("[ConfigureInfo] : INT_RANGE - Name[%s],Value [%d]~[%d], default [%d]\n",
2167                                                         temp_int_range->name, temp_int_range->min, temp_int_range->max, temp_int_range->default_value);
2168                                                 break;
2169                                         case CONFIGURE_VALUE_INT_ARRAY:
2170                                                 temp_int_array = (type_int_array*)((*configure_info)->info[i]->detail_info[j]);
2171                                                 g_print("[ConfigureInfo] : INT_ARRAY - Name[%s], default [%d]\n                            - ",
2172                                                         temp_int_array->name, temp_int_array->default_value);
2173
2174                                                 for (k = 0 ; k < temp_int_array->count ; k++)
2175                                                         g_print("[%d] ", temp_int_array->value[k]);
2176
2177                                                 g_print("\n");
2178                                                 break;
2179                                         case CONFIGURE_VALUE_INT_PAIR_ARRAY:
2180                                                 temp_int_pair_array = (type_int_pair_array*)((*configure_info)->info[i]->detail_info[j]);
2181                                                 g_print("[ConfigureInfo] : INT_PAIR_ARRAY - Name[%s], default [%d][%d]\n                            - ",
2182                                                         temp_int_pair_array->name, temp_int_pair_array->default_value[0], temp_int_pair_array->default_value[0]);
2183
2184                                                 for (k = 0 ; k < temp_int_pair_array->count ; k++)
2185                                                         g_print("[%d,%d] ", temp_int_pair_array->value[0][k], temp_int_pair_array->value[1][k]);
2186
2187                                                 g_print("\n");
2188                                                 break;
2189                                         case CONFIGURE_VALUE_STRING:
2190                                                 temp_string = (type_string*)((*configure_info)->info[i]->detail_info[j]);
2191                                                 g_print("[ConfigureInfo] : STRING - Name[%s],Value[%s]\n", temp_string->name, temp_string->value);
2192                                                 break;
2193                                         case CONFIGURE_VALUE_ELEMENT:
2194                                                 temp_element = (type_element*)((*configure_info)->info[i]->detail_info[j]);
2195                                                 g_print("[ConfigureInfo] : Element - Name[%s],Element_Name[%s]\n", temp_element->name, temp_element->element_name);
2196
2197                                                 for (k = 0 ; k < temp_element->count_int ; k++)
2198                                                         g_print("                          - INT[%d] Name[%s],Value[%d]\n", k, temp_element->value_int[k]->name, temp_element->value_int[k]->value);
2199
2200                                                 for (k = 0 ; k < temp_element->count_string ; k++)
2201                                                         g_print("                          - STRING[%d] Name[%s],Value[%s]\n", k, temp_element->value_string[k]->name, temp_element->value_string[k]->value);
2202
2203                                                 break;
2204                                         default:
2205                                                 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);
2206                                                 break;
2207                                         }
2208                                 } else {
2209                                         g_print("[ConfigureInfo] : Failed to get value type.");
2210                                 }
2211                         }
2212                 }
2213         }
2214
2215         g_print("[ConfigureInfoPrint] : Done.\n");
2216 }
2217
2218
2219 static type_element *__mmcamcorder_get_audio_codec_element(MMHandleType handle)
2220 {
2221         type_element *telement = NULL;
2222         const char *codec_type_str = NULL;
2223         int codec_type = MM_AUDIO_CODEC_INVALID;
2224         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2225         _MMCamcorderSubContext *sc = NULL;
2226
2227         mmf_return_val_if_fail(hcamcorder, NULL);
2228         sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2229
2230         mmf_return_val_if_fail(sc, NULL);
2231
2232         MMCAM_LOG_INFO("");
2233
2234         /* Check element availability */
2235         mm_camcorder_get_attributes(handle, NULL, MMCAM_AUDIO_ENCODER, &codec_type, NULL);
2236
2237         switch (codec_type) {
2238         case MM_AUDIO_CODEC_AMR:
2239                 codec_type_str = "AMR";
2240                 break;
2241         case MM_AUDIO_CODEC_G723_1:
2242                 codec_type_str = "G723_1";
2243                 break;
2244         case MM_AUDIO_CODEC_MP3:
2245                 codec_type_str = "MP3";
2246                 break;
2247         case MM_AUDIO_CODEC_AAC:
2248                 codec_type_str = "AAC";
2249                 break;
2250         case MM_AUDIO_CODEC_MMF:
2251                 codec_type_str = "MMF";
2252                 break;
2253         case MM_AUDIO_CODEC_ADPCM:
2254                 codec_type_str = "ADPCM";
2255                 break;
2256         case MM_AUDIO_CODEC_WAVE:
2257                 codec_type_str = "WAVE";
2258                 break;
2259         case MM_AUDIO_CODEC_MIDI:
2260                 codec_type_str = "MIDI";
2261                 break;
2262         case MM_AUDIO_CODEC_IMELODY:
2263                 codec_type_str = "IMELODY";
2264                 break;
2265         case MM_AUDIO_CODEC_VORBIS:
2266                 codec_type_str = "VORBIS";
2267                 break;
2268         default:
2269                 MMCAM_LOG_ERROR("Not supported audio codec[%d]", codec_type);
2270                 return NULL;
2271         }
2272
2273         _mmcamcorder_conf_get_element(handle, hcamcorder->conf_main,
2274                 CONFIGURE_CATEGORY_MAIN_AUDIO_ENCODER,
2275                 codec_type_str,
2276                 &telement);
2277
2278         return telement;
2279 }
2280
2281
2282 static type_element *__mmcamcorder_get_video_codec_element(MMHandleType handle)
2283 {
2284         type_element *telement = NULL;
2285         const char *codec_type_str = NULL;
2286         int codec_type = MM_VIDEO_CODEC_INVALID;
2287         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2288         _MMCamcorderSubContext *sc = NULL;
2289
2290         mmf_return_val_if_fail(hcamcorder, NULL);
2291         sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2292
2293         mmf_return_val_if_fail(sc, NULL);
2294
2295         /* Check element availability */
2296         mm_camcorder_get_attributes(handle, NULL, MMCAM_VIDEO_ENCODER, &codec_type, NULL);
2297
2298         switch (codec_type) {
2299         case MM_VIDEO_CODEC_H263:
2300                 codec_type_str = "H263";
2301                 break;
2302         case MM_VIDEO_CODEC_H264:
2303                 codec_type_str = "H264";
2304                 break;
2305         case MM_VIDEO_CODEC_H26L:
2306                 codec_type_str = "H26L";
2307                 break;
2308         case MM_VIDEO_CODEC_MPEG4:
2309                 codec_type_str = "MPEG4";
2310                 break;
2311         case MM_VIDEO_CODEC_MPEG1:
2312                 codec_type_str = "MPEG1";
2313                 break;
2314         case MM_VIDEO_CODEC_THEORA:
2315                 codec_type_str = "THEORA";
2316                 break;
2317         default:
2318                 MMCAM_LOG_ERROR("Not supported video codec[%d]", codec_type);
2319                 return NULL;
2320         }
2321
2322         _mmcamcorder_conf_get_element(handle, hcamcorder->conf_main,
2323                 CONFIGURE_CATEGORY_MAIN_VIDEO_ENCODER,
2324                 codec_type_str,
2325                 &telement);
2326
2327         return telement;
2328 }
2329
2330
2331 static type_element *__mmcamcorder_get_image_codec_element(MMHandleType handle)
2332 {
2333         type_element *telement = NULL;
2334         const char *codec_type_str = NULL;
2335         int codec_type = MM_IMAGE_CODEC_INVALID;
2336         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2337         _MMCamcorderSubContext *sc = NULL;
2338
2339         mmf_return_val_if_fail(hcamcorder, NULL);
2340         sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2341
2342         mmf_return_val_if_fail(sc, NULL);
2343
2344         /* Check element availability */
2345         mm_camcorder_get_attributes(handle, NULL, MMCAM_IMAGE_ENCODER, &codec_type, NULL);
2346
2347         switch (codec_type) {
2348         case MM_IMAGE_CODEC_JPEG:
2349                 codec_type_str = "JPEG";
2350                 break;
2351         case MM_IMAGE_CODEC_SRW:
2352                 codec_type_str = "SRW";
2353                 break;
2354         case MM_IMAGE_CODEC_JPEG_SRW:
2355                 codec_type_str = "JPEG_SRW";
2356                 break;
2357         case MM_IMAGE_CODEC_PNG:
2358                 codec_type_str = "PNG";
2359                 break;
2360         case MM_IMAGE_CODEC_BMP:
2361                 codec_type_str = "BMP";
2362                 break;
2363         case MM_IMAGE_CODEC_WBMP:
2364                 codec_type_str = "WBMP";
2365                 break;
2366         case MM_IMAGE_CODEC_TIFF:
2367                 codec_type_str = "TIFF";
2368                 break;
2369         case MM_IMAGE_CODEC_PCX:
2370                 codec_type_str = "PCX";
2371                 break;
2372         case MM_IMAGE_CODEC_GIF:
2373                 codec_type_str = "GIF";
2374                 break;
2375         case MM_IMAGE_CODEC_ICO:
2376                 codec_type_str = "ICO";
2377                 break;
2378         case MM_IMAGE_CODEC_RAS:
2379                 codec_type_str = "RAS";
2380                 break;
2381         case MM_IMAGE_CODEC_TGA:
2382                 codec_type_str = "TGA";
2383                 break;
2384         case MM_IMAGE_CODEC_XBM:
2385                 codec_type_str = "XBM";
2386                 break;
2387         case MM_IMAGE_CODEC_XPM:
2388                 codec_type_str = "XPM";
2389                 break;
2390         default:
2391                 MMCAM_LOG_ERROR("Not supported image codec[%d]", codec_type);
2392                 return NULL;
2393         }
2394
2395         _mmcamcorder_conf_get_element(handle, hcamcorder->conf_main,
2396                 CONFIGURE_CATEGORY_MAIN_IMAGE_ENCODER,
2397                 codec_type_str,
2398                 &telement);
2399
2400         return telement;
2401 }
2402
2403
2404 static type_element *__mmcamcorder_get_file_format_element(MMHandleType handle)
2405 {
2406         type_element *telement = NULL;
2407         const char *mux_type_str = NULL;
2408         int file_type = MM_FILE_FORMAT_INVALID;
2409         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2410         _MMCamcorderSubContext *sc = NULL;
2411
2412         mmf_return_val_if_fail(hcamcorder, NULL);
2413         sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2414
2415         mmf_return_val_if_fail(sc, NULL);
2416
2417         /* Check element availability */
2418         mm_camcorder_get_attributes(handle, NULL, MMCAM_FILE_FORMAT, &file_type, NULL);
2419
2420         switch (file_type) {
2421         case MM_FILE_FORMAT_3GP:
2422                 mux_type_str = "3GP";
2423                 break;
2424         case MM_FILE_FORMAT_AMR:
2425                 mux_type_str = "AMR";
2426                 break;
2427         case MM_FILE_FORMAT_MP4:
2428                 mux_type_str = "MP4";
2429                 break;
2430         case MM_FILE_FORMAT_AAC:
2431                 mux_type_str = "AAC";
2432                 break;
2433         case MM_FILE_FORMAT_MP3:
2434                 mux_type_str = "MP3";
2435                 break;
2436         case MM_FILE_FORMAT_OGG:
2437                 mux_type_str = "OGG";
2438                 break;
2439         case MM_FILE_FORMAT_WAV:
2440                 mux_type_str = "WAV";
2441                 break;
2442         case MM_FILE_FORMAT_AVI:
2443                 mux_type_str = "AVI";
2444                 break;
2445         case MM_FILE_FORMAT_WMA:
2446                 mux_type_str = "WMA";
2447                 break;
2448         case MM_FILE_FORMAT_WMV:
2449                 mux_type_str = "WMV";
2450                 break;
2451         case MM_FILE_FORMAT_MID:
2452                 mux_type_str = "MID";
2453                 break;
2454         case MM_FILE_FORMAT_MMF:
2455                 mux_type_str = "MMF";
2456                 break;
2457         case MM_FILE_FORMAT_MATROSKA:
2458                 mux_type_str = "MATROSKA";
2459                 break;
2460         case MM_FILE_FORMAT_M2TS:
2461                 mux_type_str = "M2TS";
2462                 break;
2463         default:
2464                 MMCAM_LOG_ERROR("Not supported file format[%d]", file_type);
2465                 return NULL;
2466         }
2467
2468         _mmcamcorder_conf_get_element(handle, hcamcorder->conf_main,
2469                 CONFIGURE_CATEGORY_MAIN_MUX,
2470                 mux_type_str,
2471                 &telement);
2472
2473         return telement;
2474 }
2475
2476
2477 type_element *_mmcamcorder_get_type_element(MMHandleType handle, int type)
2478 {
2479         type_element *telement = NULL;
2480
2481         switch (type) {
2482         case MM_CAM_AUDIO_ENCODER:
2483                 telement = __mmcamcorder_get_audio_codec_element(handle);
2484                 break;
2485         case MM_CAM_VIDEO_ENCODER:
2486                 telement = __mmcamcorder_get_video_codec_element(handle);
2487                 break;
2488         case MM_CAM_IMAGE_ENCODER:
2489                 telement = __mmcamcorder_get_image_codec_element(handle);
2490                 break;
2491         case MM_CAM_FILE_FORMAT:
2492                 telement = __mmcamcorder_get_file_format_element(handle);
2493                 break;
2494         default:
2495                 MMCAM_LOG_INFO("Can't get element type form this profile.(%d)", type);
2496         }
2497
2498         return telement;
2499 }
2500
2501
2502 int _mmcamcorder_get_audio_codec_format(MMHandleType handle, const char *name)
2503 {
2504         int codec_index = MM_AUDIO_CODEC_INVALID;
2505
2506         if (!name) {
2507                 MMCAM_LOG_ERROR("name is NULL");
2508                 return MM_AUDIO_CODEC_INVALID;
2509         }
2510
2511         if (!strcmp(name, "AMR"))
2512                 codec_index = MM_AUDIO_CODEC_AMR;
2513         else if (!strcmp(name, "G723_1"))
2514                 codec_index = MM_AUDIO_CODEC_G723_1;
2515         else if (!strcmp(name, "MP3"))
2516                 codec_index = MM_AUDIO_CODEC_MP3;
2517         else if (!strcmp(name, "AAC"))
2518                 codec_index = MM_AUDIO_CODEC_AAC;
2519         else if (!strcmp(name, "MMF"))
2520                 codec_index = MM_AUDIO_CODEC_MMF;
2521         else if (!strcmp(name, "ADPCM"))
2522                 codec_index = MM_AUDIO_CODEC_ADPCM;
2523         else if (!strcmp(name, "WAVE"))
2524                 codec_index = MM_AUDIO_CODEC_WAVE;
2525         else if (!strcmp(name, "MIDI"))
2526                 codec_index = MM_AUDIO_CODEC_MIDI;
2527         else if (!strcmp(name, "IMELODY"))
2528                 codec_index = MM_AUDIO_CODEC_IMELODY;
2529         else if (!strcmp(name, "VORBIS"))
2530                 codec_index = MM_AUDIO_CODEC_VORBIS;
2531
2532         MMCAM_LOG_DEBUG("audio codec index %d", codec_index);
2533
2534         return codec_index;
2535 }
2536
2537
2538
2539 int _mmcamcorder_get_video_codec_format(MMHandleType handle, const char *name)
2540 {
2541         int codec_index = MM_VIDEO_CODEC_INVALID;
2542
2543         if (!name) {
2544                 MMCAM_LOG_ERROR("name is NULL");
2545                 return MM_VIDEO_CODEC_INVALID;
2546         }
2547
2548         if (!strcmp(name, "H263"))
2549                 codec_index = MM_VIDEO_CODEC_H263;
2550         else if (!strcmp(name, "H264"))
2551                 codec_index = MM_VIDEO_CODEC_H264;
2552         else if (!strcmp(name, "H26L"))
2553                 codec_index = MM_VIDEO_CODEC_H26L;
2554         else if (!strcmp(name, "MPEG4"))
2555                 codec_index = MM_VIDEO_CODEC_MPEG4;
2556         else if (!strcmp(name, "MPEG1"))
2557                 codec_index = MM_VIDEO_CODEC_MPEG1;
2558         else if (!strcmp(name, "THEORA"))
2559                 codec_index = MM_VIDEO_CODEC_THEORA;
2560
2561         MMCAM_LOG_DEBUG("video codec index %d", codec_index);
2562
2563         return codec_index;
2564 }
2565
2566
2567
2568 int _mmcamcorder_get_image_codec_format(MMHandleType handle, const char *name)
2569 {
2570         int codec_index = MM_IMAGE_CODEC_INVALID;
2571
2572         if (!name) {
2573                 MMCAM_LOG_ERROR("name is NULL");
2574                 return MM_IMAGE_CODEC_INVALID;
2575         }
2576
2577         if (!strcmp(name, "JPEG"))
2578                 codec_index = MM_IMAGE_CODEC_JPEG;
2579         else if (!strcmp(name, "PNG"))
2580                 codec_index = MM_IMAGE_CODEC_PNG;
2581         else if (!strcmp(name, "BMP"))
2582                 codec_index = MM_IMAGE_CODEC_BMP;
2583         else if (!strcmp(name, "WBMP"))
2584                 codec_index = MM_IMAGE_CODEC_WBMP;
2585         else if (!strcmp(name, "TIFF"))
2586                 codec_index = MM_IMAGE_CODEC_TIFF;
2587         else if (!strcmp(name, "PCX"))
2588                 codec_index = MM_IMAGE_CODEC_PCX;
2589         else if (!strcmp(name, "GIF"))
2590                 codec_index = MM_IMAGE_CODEC_GIF;
2591         else if (!strcmp(name, "ICO"))
2592                 codec_index = MM_IMAGE_CODEC_ICO;
2593         else if (!strcmp(name, "RAS"))
2594                 codec_index = MM_IMAGE_CODEC_RAS;
2595         else if (!strcmp(name, "TGA"))
2596                 codec_index = MM_IMAGE_CODEC_TGA;
2597         else if (!strcmp(name, "XBM"))
2598                 codec_index = MM_IMAGE_CODEC_XBM;
2599         else if (!strcmp(name, "XPM"))
2600                 codec_index = MM_IMAGE_CODEC_XPM;
2601
2602         MMCAM_LOG_DEBUG("image codec index %d", codec_index);
2603
2604         return codec_index;
2605 }
2606
2607
2608 int _mmcamcorder_get_mux_format(MMHandleType handle, const char *name)
2609 {
2610         int mux_index = MM_FILE_FORMAT_INVALID;
2611
2612         if (!name) {
2613                 MMCAM_LOG_ERROR("name is NULL");
2614                 return MM_FILE_FORMAT_INVALID;
2615         }
2616
2617         if (!strcmp(name, "3GP"))
2618                 mux_index = MM_FILE_FORMAT_3GP;
2619         else if (!strcmp(name, "AMR"))
2620                 mux_index = MM_FILE_FORMAT_AMR;
2621         else if (!strcmp(name, "MP4"))
2622                 mux_index = MM_FILE_FORMAT_MP4;
2623         else if (!strcmp(name, "AAC"))
2624                 mux_index = MM_FILE_FORMAT_AAC;
2625         else if (!strcmp(name, "MP3"))
2626                 mux_index = MM_FILE_FORMAT_MP3;
2627         else if (!strcmp(name, "OGG"))
2628                 mux_index = MM_FILE_FORMAT_OGG;
2629         else if (!strcmp(name, "WAV"))
2630                 mux_index = MM_FILE_FORMAT_WAV;
2631         else if (!strcmp(name, "AVI"))
2632                 mux_index = MM_FILE_FORMAT_AVI;
2633         else if (!strcmp(name, "WMA"))
2634                 mux_index = MM_FILE_FORMAT_WMA;
2635         else if (!strcmp(name, "WMV"))
2636                 mux_index = MM_FILE_FORMAT_WMV;
2637         else if (!strcmp(name, "MID"))
2638                 mux_index = MM_FILE_FORMAT_MID;
2639         else if (!strcmp(name, "MMF"))
2640                 mux_index = MM_FILE_FORMAT_MMF;
2641         else if (!strcmp(name, "MATROSKA"))
2642                 mux_index = MM_FILE_FORMAT_MATROSKA;
2643         else if (!strcmp(name, "M2TS"))
2644                 mux_index = MM_FILE_FORMAT_M2TS;
2645
2646         MMCAM_LOG_DEBUG("mux index %d", mux_index);
2647
2648         return mux_index;
2649 }
2650
2651
2652 int _mmcamcorder_get_format(MMHandleType handle, int conf_category, const char *name)
2653 {
2654         int fmt = -1;
2655
2656         mmf_return_val_if_fail(name, -1);
2657
2658         switch (conf_category) {
2659         case CONFIGURE_CATEGORY_MAIN_AUDIO_ENCODER:
2660                 fmt = _mmcamcorder_get_audio_codec_format(handle, name);
2661                 break;
2662         case CONFIGURE_CATEGORY_MAIN_VIDEO_ENCODER:
2663                 fmt = _mmcamcorder_get_video_codec_format(handle, name);
2664                 break;
2665         case CONFIGURE_CATEGORY_MAIN_IMAGE_ENCODER:
2666                 fmt = _mmcamcorder_get_image_codec_format(handle, name);
2667                 break;
2668         case CONFIGURE_CATEGORY_MAIN_MUX:
2669                 fmt = _mmcamcorder_get_mux_format(handle, name);
2670                 break;
2671         default:
2672                 MMCAM_LOG_ERROR("Can't get format from this category.(%d)", conf_category);
2673         }
2674
2675         return fmt;
2676 }
2677
2678 int _mmcamcorder_get_available_format(MMHandleType handle, int conf_category, int **format)
2679 {
2680         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2681         camera_conf* configure_info = NULL;
2682         int *arr = NULL;
2683         int total_count = 0;
2684
2685         mmf_return_val_if_fail(hcamcorder, 0);
2686
2687         configure_info = hcamcorder->conf_main;
2688
2689         if (configure_info->info[conf_category]) {
2690                 int i = 0;
2691                 int fmt = 0;
2692                 const char *name = NULL;
2693                 int count = configure_info->info[conf_category]->count;
2694                 conf_detail *info = configure_info->info[conf_category];
2695
2696                 MMCAM_LOG_DEBUG("conf_category[%d] : count[%d], info[%p]",
2697                         conf_category, count, info);
2698
2699                 if (count <= 0 || !info)
2700                         return total_count;
2701
2702                 arr = (int*)g_malloc0(count * sizeof(int));
2703
2704                 for (i = 0 ; i < count ; i++) {
2705                         if (info->detail_info[i] == NULL)
2706                                 continue;
2707
2708                         name = ((type_element*)(info->detail_info[i]))->name;
2709                         fmt = _mmcamcorder_get_format(handle, conf_category, name);
2710                         if (fmt >= 0)
2711                                 arr[total_count++] = fmt;
2712
2713                         MMCAM_LOG_VERBOSE("    name:%s, fmt:%d", name, fmt);
2714                 }
2715         }
2716
2717         *format = arr;
2718
2719         return total_count;
2720 }