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