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