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