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