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