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