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