Bug fix - The extra preview callback is not invoked
[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                 { "GSTInitOption",              CONFIGURE_VALUE_STRING_ARRAY,   {NULL} },
658                 { "PlatformPrivilegeCamera",    CONFIGURE_VALUE_STRING,         {NULL} },
659                 { "LogLevel",                   CONFIGURE_VALUE_INT,            {.value_int = MM_CAMCORDER_LOG_LEVEL_INFO} },
660                 { "NetworkCameraHALName",       CONFIGURE_VALUE_STRING,         {NULL} },
661         };
662
663         /* [VideoInput] matching table */
664         static conf_info_table conf_main_video_input_table[] = {
665                 { "VideosrcElement",              CONFIGURE_VALUE_ELEMENT,      {&_videosrc_element_default} },
666                 { "UseVideoscale",                CONFIGURE_VALUE_INT,          {.value_int = 0} },
667                 { "VideoscaleElement",            CONFIGURE_VALUE_ELEMENT,      {&_videoscale_element_default} },
668                 { "UseZeroCopyFormat",            CONFIGURE_VALUE_INT,          {.value_int = 0} },
669                 { "DeviceCount",                  CONFIGURE_VALUE_INT,          {.value_int = MM_VIDEO_DEVICE_NUM} },
670                 { "SupportMediaPacketPreviewCb",  CONFIGURE_VALUE_INT,          {.value_int = 0} },
671                 { "SupportUserBuffer",            CONFIGURE_VALUE_INT,          {.value_int = 0} },
672                 { "MeasurePreviewFPS",            CONFIGURE_VALUE_INT,          {.value_int = 0} },
673                 { "DefaultEncodedPreviewBitrate", CONFIGURE_VALUE_INT,          {.value_int = DEFAULT_ENCODED_PREVIEW_BITRATE} },
674         };
675
676         /* [AudioInput] matching table */
677         static conf_info_table conf_main_audio_input_table[] = {
678                 { "AudioDevice",          CONFIGURE_VALUE_INT_ARRAY, {NULL} },
679                 { "AudiosrcElement",      CONFIGURE_VALUE_ELEMENT, {&_audiosrc_element_default} },
680                 { "AudiomodemsrcElement", CONFIGURE_VALUE_ELEMENT, {&_audiomodemsrc_element_default} },
681                 { "AudioBufferInterval",  CONFIGURE_VALUE_INT,     {.value_int = DEFAULT_AUDIO_BUFFER_INTERVAL} },
682         };
683
684         /* [VideoOutput] matching table */
685         static conf_info_table conf_main_video_output_table[] = {
686                 { "DisplayDevice",           CONFIGURE_VALUE_INT_ARRAY, {NULL} },
687                 { "DisplayMode",             CONFIGURE_VALUE_INT_ARRAY, {NULL} },
688                 { "Videosink",               CONFIGURE_VALUE_INT_ARRAY, {NULL} },
689                 { "VideosinkElementOverlay", CONFIGURE_VALUE_ELEMENT,   {&_videosink_element_overlay_default} },
690                 { "VideosinkElementEvas",    CONFIGURE_VALUE_ELEMENT,   {&_videosink_element_evas_default} },
691                 { "VideosinkElementGL",      CONFIGURE_VALUE_ELEMENT,   {&_videosink_element_gl_default} },
692                 { "VideosinkElementRemote",  CONFIGURE_VALUE_ELEMENT,   {&_videosink_element_remote_default} },
693                 { "VideosinkElementNull",    CONFIGURE_VALUE_ELEMENT,   {&_videosink_element_null_default} },
694                 { "UseVideoscale",           CONFIGURE_VALUE_INT,       {.value_int = 0} },
695                 { "VideoscaleElement",       CONFIGURE_VALUE_ELEMENT,   {&_videoscale_element_default} },
696                 { "UseVideoconvert",         CONFIGURE_VALUE_INT,       {.value_int = 0} },
697                 { "VideoconvertElement",     CONFIGURE_VALUE_ELEMENT,   {&_videoconvert_element_default} },
698                 { "VideodecoderElementH264", CONFIGURE_VALUE_ELEMENT,   {&_videodecoder_element_h264_default} },
699                 { "VideodecoderElementMJPEG",CONFIGURE_VALUE_ELEMENT,   {&_videodecoder_element_mjpeg_default} },
700                 { "VideodecoderElementVP8",  CONFIGURE_VALUE_ELEMENT,   {&_videodecoder_element_vp8_default} },
701                 { "VideodecoderElementVP9",  CONFIGURE_VALUE_ELEMENT,   {&_videodecoder_element_vp9_default} },
702                 { "RecreateDecoder",         CONFIGURE_VALUE_INT,       {.value_int = 0} }
703         };
704
705         /* [Capture] matching table */
706         static conf_info_table conf_main_capture_table[] = {
707                 { "CaptureMode",            CONFIGURE_VALUE_INT,     {.value_int = MM_CAMCORDER_CAPTURE_MODE_ENCODEBIN} },
708                 { "VideoscaleElement",      CONFIGURE_VALUE_ELEMENT, {&_videoscale_element_default} },
709                 { "PlayCaptureSound",       CONFIGURE_VALUE_INT,     {.value_int = 1} },
710         };
711
712         /* [Record] matching table */
713         static conf_info_table conf_main_record_table[] = {
714                 { "UseAudioEncoderQueue",   CONFIGURE_VALUE_INT,     {.value_int = 1} },
715                 { "UseVideoEncoderQueue",   CONFIGURE_VALUE_INT,     {.value_int = 1} },
716                 { "VideoProfile",           CONFIGURE_VALUE_INT,     {.value_int = 0} },
717                 { "VideoAutoAudioConvert",  CONFIGURE_VALUE_INT,     {.value_int = 0} },
718                 { "VideoAutoAudioResample", CONFIGURE_VALUE_INT,     {.value_int = 0} },
719                 { "VideoAutoColorSpace",    CONFIGURE_VALUE_INT,     {.value_int = 0} },
720                 { "AudioProfile",           CONFIGURE_VALUE_INT,     {.value_int = 0} },
721                 { "AudioAutoAudioConvert",  CONFIGURE_VALUE_INT,     {.value_int = 0} },
722                 { "AudioAutoAudioResample", CONFIGURE_VALUE_INT,     {.value_int = 0} },
723                 { "AudioAutoColorSpace",    CONFIGURE_VALUE_INT,     {.value_int = 0} },
724                 { "ImageProfile",           CONFIGURE_VALUE_INT,     {.value_int = 0} },
725                 { "ImageAutoAudioConvert",  CONFIGURE_VALUE_INT,     {.value_int = 0} },
726                 { "ImageAutoAudioResample", CONFIGURE_VALUE_INT,     {.value_int = 0} },
727                 { "ImageAutoColorSpace",    CONFIGURE_VALUE_INT,     {.value_int = 0} },
728                 { "RecordsinkElement",      CONFIGURE_VALUE_ELEMENT, {&_recordsink_element_default} },
729                 { "UseNoiseSuppressor",     CONFIGURE_VALUE_INT,     {.value_int = 0} },
730                 { "DropVideoFrame",         CONFIGURE_VALUE_INT,     {.value_int = 0} },
731                 { "PassFirstVideoFrame",    CONFIGURE_VALUE_INT,     {.value_int = 0} },
732                 { "SupportDualStream",      CONFIGURE_VALUE_INT,     {.value_int = 0} },
733                 { "UseVideoscale",          CONFIGURE_VALUE_INT,     {.value_int = 0} },
734                 { "VideoscaleElement",      CONFIGURE_VALUE_ELEMENT, {&_videoscale_element_default} }
735         };
736
737         /* [VideoEncoder] matching table */
738         static conf_info_table conf_main_video_encoder_table[] = {
739                 { "H263",    CONFIGURE_VALUE_ELEMENT, {&_h263_element_default} },
740                 { "H264",    CONFIGURE_VALUE_ELEMENT, {&_h264_element_default} },
741                 { "H26L",    CONFIGURE_VALUE_ELEMENT, {&_h26l_element_default} },
742                 { "MPEG4",   CONFIGURE_VALUE_ELEMENT, {&_mpeg4_element_default} },
743                 { "MPEG1",   CONFIGURE_VALUE_ELEMENT, {&_mpeg1_element_default} },
744                 { "THEORA",  CONFIGURE_VALUE_ELEMENT, {&_theora_element_default} },
745         };
746
747         /* [AudioEncoder] matching table */
748         static conf_info_table conf_main_audio_encoder_table[] = {
749                 { "AMR",     CONFIGURE_VALUE_ELEMENT, {&_amr_element_default} },
750                 { "G723_1",  CONFIGURE_VALUE_ELEMENT, {&_g723_1_element_default} },
751                 { "MP3",     CONFIGURE_VALUE_ELEMENT, {&_mp3_element_default} },
752                 { "AAC",     CONFIGURE_VALUE_ELEMENT, {&_aac_element_default} },
753                 { "MMF",     CONFIGURE_VALUE_ELEMENT, {&_mmf_element_default} },
754                 { "ADPCM",   CONFIGURE_VALUE_ELEMENT, {&_adpcm_element_default} },
755                 { "WAVE",    CONFIGURE_VALUE_ELEMENT, {&_wave_element_default} },
756                 { "MIDI",    CONFIGURE_VALUE_ELEMENT, {&_midi_element_default} },
757                 { "IMELODY", CONFIGURE_VALUE_ELEMENT, {&_imelody_element_default} },
758                 { "VORBIS",  CONFIGURE_VALUE_ELEMENT, {&_vorbis_element_default} },
759         };
760
761         /* [ImageEncoder] matching table */
762         static conf_info_table conf_main_image_encoder_table[] = {
763                 { "JPEG", CONFIGURE_VALUE_ELEMENT, {&_jpeg_element_default} },
764                 { "PNG",  CONFIGURE_VALUE_ELEMENT, {&_png_element_default} },
765                 { "BMP",  CONFIGURE_VALUE_ELEMENT, {&_bmp_element_default} },
766                 { "WBMP", CONFIGURE_VALUE_ELEMENT, {&_wbmp_element_default} },
767                 { "TIFF", CONFIGURE_VALUE_ELEMENT, {&_tiff_element_default} },
768                 { "PCX",  CONFIGURE_VALUE_ELEMENT, {&_pcx_element_default} },
769                 { "GIF",  CONFIGURE_VALUE_ELEMENT, {&_gif_element_default} },
770                 { "ICO",  CONFIGURE_VALUE_ELEMENT, {&_ico_element_default} },
771                 { "RAS",  CONFIGURE_VALUE_ELEMENT, {&_ras_element_default} },
772                 { "TGA",  CONFIGURE_VALUE_ELEMENT, {&_tga_element_default} },
773                 { "XBM",  CONFIGURE_VALUE_ELEMENT, {&_xbm_element_default} },
774                 { "XPM",  CONFIGURE_VALUE_ELEMENT, {&_xpm_element_default} },
775         };
776
777         /* [Mux] matching table */
778         static conf_info_table conf_main_mux_table[] = {
779                 { "3GP",      CONFIGURE_VALUE_ELEMENT, {&_3gp_element_default} },
780                 { "AMR",      CONFIGURE_VALUE_ELEMENT, {&_amrmux_element_default} },
781                 { "MP4",      CONFIGURE_VALUE_ELEMENT, {&_mp4_element_default} },
782                 { "AAC",      CONFIGURE_VALUE_ELEMENT, {&_aacmux_element_default} },
783                 { "MP3",      CONFIGURE_VALUE_ELEMENT, {&_mp3mux_element_default} },
784                 { "OGG",      CONFIGURE_VALUE_ELEMENT, {&_ogg_element_default} },
785                 { "WAV",      CONFIGURE_VALUE_ELEMENT, {&_wav_element_default} },
786                 { "AVI",      CONFIGURE_VALUE_ELEMENT, {&_avi_element_default} },
787                 { "WMA",      CONFIGURE_VALUE_ELEMENT, {&_wma_element_default} },
788                 { "WMV",      CONFIGURE_VALUE_ELEMENT, {&_wmv_element_default} },
789                 { "MID",      CONFIGURE_VALUE_ELEMENT, {&_mid_element_default} },
790                 { "MMF",      CONFIGURE_VALUE_ELEMENT, {&_mmfmux_element_default} },
791                 { "MATROSKA", CONFIGURE_VALUE_ELEMENT, {&_matroska_element_default} },
792                 { "M2TS",     CONFIGURE_VALUE_ELEMENT, {&_m2ts_element_default} },
793         };
794
795
796         /*******************
797         *  Camera control *
798         *******************/
799
800         /* [Camera] matching table */
801         static conf_info_table conf_ctrl_camera_table[] = {
802                 { "InputIndex",           CONFIGURE_VALUE_INT_ARRAY,      {NULL} },
803                 { "DeviceName",           CONFIGURE_VALUE_STRING,         {NULL} },
804                 { "PreviewResolution",    CONFIGURE_VALUE_INT_PAIR_ARRAY, {NULL} },
805                 { "CaptureResolution",    CONFIGURE_VALUE_INT_PAIR_ARRAY, {NULL} },
806                 { "VideoResolution",      CONFIGURE_VALUE_INT_PAIR_ARRAY, {NULL} },
807                 { "FPS0",                 CONFIGURE_VALUE_INT_ARRAY,      {NULL} },
808                 { "FPS1",                 CONFIGURE_VALUE_INT_ARRAY,      {NULL} },
809                 { "FPS2",                 CONFIGURE_VALUE_INT_ARRAY,      {NULL} },
810                 { "FPS3",                 CONFIGURE_VALUE_INT_ARRAY,      {NULL} },
811                 { "FPS4",                 CONFIGURE_VALUE_INT_ARRAY,      {NULL} },
812                 { "FPS5",                 CONFIGURE_VALUE_INT_ARRAY,      {NULL} },
813                 { "FPS6",                 CONFIGURE_VALUE_INT_ARRAY,      {NULL} },
814                 { "FPS7",                 CONFIGURE_VALUE_INT_ARRAY,      {NULL} },
815                 { "FPS8",                 CONFIGURE_VALUE_INT_ARRAY,      {NULL} },
816                 { "FPS9",                 CONFIGURE_VALUE_INT_ARRAY,      {NULL} },
817                 { "PictureFormat",        CONFIGURE_VALUE_INT_ARRAY,      {NULL} },
818                 { "Overlay",              CONFIGURE_VALUE_INT_RANGE,      {NULL} },
819                 { "RecommendDisplayRotation", CONFIGURE_VALUE_INT,        {.value_int = 3} },
820                 { "RecommendPreviewFormatCapture", CONFIGURE_VALUE_INT,   {.value_int = MM_PIXEL_FORMAT_YUYV} },
821                 { "RecommendPreviewFormatRecord",  CONFIGURE_VALUE_INT,   {.value_int = MM_PIXEL_FORMAT_NV12} },
822                 { "RecommendPreviewResolution", CONFIGURE_VALUE_INT_PAIR_ARRAY, {NULL} },
823                 { "FacingDirection",      CONFIGURE_VALUE_INT,            {.value_int = MM_CAMCORDER_CAMERA_FACING_DIRECTION_REAR} },
824                 { "FrameStabilityCount",  CONFIGURE_VALUE_INT,            {.value_int = 0} },
825                 { "SupportExtraPreview",  CONFIGURE_VALUE_INT,            {.value_int = 0} },
826                 { "ExtraPreviewMode",     CONFIGURE_VALUE_INT,            {.value_int = MM_CAMCORDER_EXTRA_PREVIEW_MODE_CAMERA_CONTROL} },
827                 { "AltVideosrcElement",   CONFIGURE_VALUE_ELEMENT,        {NULL} }, /* The alternative of videosrc element, it will be used instead of "VideosrcElement" if exists. */
828                 { "AltUseZeroCopyFormat", CONFIGURE_VALUE_INT,            {.value_int = -1} }, /* The alternative of "UseZeroCopyFormat", it will be used if it's not default(-1) value. */
829                 { "VideoFilterElement",   CONFIGURE_VALUE_ELEMENT,        {NULL} } /* The video filter element which is placed between videosrc and videosink elements. */
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                         return MM_ERROR_CAMCORDER_NOT_SUPPORTED;
976                 }
977         }
978
979         ret = _mmcamcorder_conf_parse_info(handle, type, fp, configure_info);
980
981         fclose(fp);
982
983         MMCAM_LOG_INFO("Leave [0x%x]", ret);
984
985         return ret;
986 }
987
988
989 int _mmcamcorder_conf_parse_info(MMHandleType handle, int type, FILE *fp, camera_conf **configure_info)
990 {
991         const unsigned int BUFFER_NUM_DETAILS = 256;
992         const unsigned int BUFFER_NUM_TOKEN = 20;
993         size_t buffer_line_size = MMCAMCORDER_BUFFER_LINE_MAX;
994         const char* delimiters = " |=,\t\r\n";
995
996         int i = 0;
997         int ret = MM_ERROR_NONE;
998         int category = 0;
999         int count_main_category = 0;
1000         int count_details = 0;
1001         int length_read = 0;
1002         int count_token = 0;
1003         int read_main = 0;
1004
1005         char *buffer_string = NULL;
1006         char *buffer_details[BUFFER_NUM_DETAILS];
1007         char *buffer_token[BUFFER_NUM_TOKEN];
1008         char *token = NULL;
1009         char *category_name = NULL;
1010         char *detail_string = NULL;
1011         char *user_ptr = NULL;
1012
1013         camera_conf *new_conf = NULL;
1014
1015         MMCAM_LOG_INFO("");
1016
1017         mmf_return_val_if_fail(handle && fp && configure_info, MM_ERROR_INVALID_ARGUMENT);
1018
1019         *configure_info = NULL;
1020
1021         new_conf = (camera_conf *)g_malloc0(sizeof(camera_conf));
1022         buffer_string = (char *)g_malloc0(sizeof(char) * buffer_line_size);
1023
1024         new_conf->type  = type;
1025
1026         ret = _mmcamcorder_conf_init(handle, type, new_conf);
1027         if (ret != MM_ERROR_NONE) {
1028                 MMCAM_LOG_ERROR("conf init failed 0x%x", ret);
1029                 g_free(new_conf);
1030                 g_free(buffer_string);
1031                 return ret;
1032         }
1033
1034         *configure_info = new_conf;
1035
1036         read_main = 0;
1037         count_main_category = 0;
1038
1039         while (!feof(fp)) {
1040                 if (read_main == 0) {
1041                         buffer_line_size = MMCAMCORDER_BUFFER_LINE_MAX;
1042                         length_read = getline(&buffer_string, &buffer_line_size, fp);
1043                         if (length_read < 1) {
1044                                 MMCAM_LOG_DEBUG("skip this case - length read[%d]", length_read);
1045                                 continue;
1046                         }
1047
1048                         buffer_string[--length_read] = '\0'; /* remove new line character */
1049
1050                         MMCAM_LOG_DEBUG("Read Line : \"%s\"", buffer_string);
1051
1052                         count_token = 0;
1053                         token = strtok_r(buffer_string, delimiters, &user_ptr);
1054
1055                         if ((token) && (token[0] == ';') && (length_read > -1)) {
1056                                 MMCAM_LOG_VERBOSE( "Comment - Nothing to do" );
1057                                 continue;
1058                         }
1059
1060                         while (token) {
1061                                 MMCAM_LOG_VERBOSE("token : \"%s\"", token);
1062                                 buffer_token[count_token] = token;
1063                                 count_token++;
1064                                 token = strtok_r(NULL, delimiters, &user_ptr);
1065                         }
1066
1067                         if (count_token == 0)
1068                                 continue;
1069                 }
1070
1071                 read_main = 0;
1072
1073                 if (*buffer_token[0] == ';') {
1074                         /* Comment */
1075                         MMCAM_LOG_VERBOSE( "Comment - Nothing to do" );
1076                 } else if (*buffer_token[0] == '[') {
1077                         /* Main Category */
1078                         category_name = get_new_string(buffer_token[0]);
1079                         if (category_name == NULL) {
1080                                 MMCAM_LOG_ERROR("strdup failed for \"%s\"", buffer_token[0]);
1081                                 continue;
1082                         }
1083
1084                         count_main_category++;
1085                         count_details = 0;
1086
1087                         while (!feof(fp)) {
1088                                 length_read = getline(&buffer_string, &buffer_line_size, fp);
1089                                 if (length_read < 1) {
1090                                         MMCAM_LOG_DEBUG("skip this case - length read[%d]", length_read);
1091                                         continue;
1092                                 }
1093
1094                                 buffer_string[--length_read] = '\0'; /* remove new line character */
1095
1096                                 MMCAM_LOG_DEBUG("Read Detail Line : \"%s\", length[%d]", buffer_string, length_read);
1097
1098                                 detail_string = get_new_string(buffer_string);
1099
1100                                 token = strtok_r(buffer_string, delimiters, &user_ptr);
1101
1102                                 if (token && token[0] != ';' && length_read > -1) {
1103                                         MMCAM_LOG_VERBOSE("token : [%s]", token);
1104                                         if (token[0] == '[') {
1105                                                 read_main = 1;
1106                                                 buffer_token[0] = token;
1107                                                 SAFE_G_FREE(detail_string);
1108                                                 break;
1109                                         }
1110
1111                                         buffer_details[count_details++] = detail_string;
1112                                 } else {
1113                                         SAFE_G_FREE(detail_string);
1114                                 }
1115                         }
1116
1117                         MMCAM_LOG_DEBUG("type : %d, category_name : %s, count : [%d]", type, category_name, count_details);
1118
1119                         if (count_details == 0) {
1120                                 MMCAM_LOG_WARNING("category %s has no detail value... skip this category...", category_name);
1121                                 SAFE_G_FREE(category_name);
1122                                 continue;
1123                         }
1124
1125                         category = -1;
1126
1127                         /* Details */
1128                         if (type == CONFIGURE_TYPE_MAIN) {
1129                                 if (!strcmp("[General]", category_name))
1130                                         category = CONFIGURE_CATEGORY_MAIN_GENERAL;
1131                                 else if (!strcmp("[VideoInput]", category_name))
1132                                         category = CONFIGURE_CATEGORY_MAIN_VIDEO_INPUT;
1133                                 else if (!strcmp("[AudioInput]", category_name))
1134                                         category = CONFIGURE_CATEGORY_MAIN_AUDIO_INPUT;
1135                                 else if (!strcmp("[VideoOutput]", category_name))
1136                                         category = CONFIGURE_CATEGORY_MAIN_VIDEO_OUTPUT;
1137                                 else if (!strcmp("[Capture]", category_name))
1138                                         category = CONFIGURE_CATEGORY_MAIN_CAPTURE;
1139                                 else if (!strcmp("[Record]", category_name))
1140                                         category = CONFIGURE_CATEGORY_MAIN_RECORD;
1141                                 else if (!strcmp("[VideoEncoder]", category_name))
1142                                         category = CONFIGURE_CATEGORY_MAIN_VIDEO_ENCODER;
1143                                 else if (!strcmp("[AudioEncoder]", category_name))
1144                                         category = CONFIGURE_CATEGORY_MAIN_AUDIO_ENCODER;
1145                                 else if (!strcmp("[ImageEncoder]", category_name))
1146                                         category = CONFIGURE_CATEGORY_MAIN_IMAGE_ENCODER;
1147                                 else if (!strcmp("[Mux]", category_name))
1148                                         category = CONFIGURE_CATEGORY_MAIN_MUX;
1149                         } else {
1150                                 if (!strcmp("[Camera]", category_name))
1151                                         category = CONFIGURE_CATEGORY_CTRL_CAMERA;
1152                                 else if (!strcmp("[Strobe]", category_name))
1153                                         category = CONFIGURE_CATEGORY_CTRL_STROBE;
1154                                 else if (!strcmp("[Effect]", category_name))
1155                                         category = CONFIGURE_CATEGORY_CTRL_EFFECT;
1156                                 else if (!strcmp("[Photograph]", category_name))
1157                                         category = CONFIGURE_CATEGORY_CTRL_PHOTOGRAPH;
1158                                 else if (!strcmp("[Capture]", category_name))
1159                                         category = CONFIGURE_CATEGORY_CTRL_CAPTURE;
1160                                 else if (!strcmp("[Detect]", category_name))
1161                                         category = CONFIGURE_CATEGORY_CTRL_DETECT;
1162                         }
1163
1164                         if (category != -1) {
1165                                 _mmcamcorder_conf_add_info(handle, type, &(new_conf->info[category]),
1166                                         buffer_details, category, count_details);
1167                         } else {
1168                                 MMCAM_LOG_WARNING("No matched category[%s],type[%d]... check it.", category_name, type);
1169                         }
1170
1171                         /* Free memory */
1172                         for (i = 0 ; i < count_details ; i++)
1173                                 SAFE_G_FREE(buffer_details[i]);
1174                 }
1175
1176                 SAFE_G_FREE(category_name);
1177         }
1178
1179         /* (*configure_info) = new_conf; */
1180
1181         SAFE_G_FREE(buffer_string);
1182
1183         /*MMCAM_LOG_INFO("Done.");*/
1184
1185         return MM_ERROR_NONE;
1186 }
1187
1188
1189 void _mmcamcorder_conf_release_info(MMHandleType handle, camera_conf **configure_info)
1190 {
1191         int i = 0;
1192         int j = 0;
1193         int k = 0;
1194         int type = CONFIGURE_VALUE_INT;
1195         int count = 0;
1196         int category_num = CONFIGURE_CATEGORY_MAIN_NUM;
1197         camera_conf *temp_conf = (*configure_info);
1198
1199         type_int2 *temp_int = NULL;
1200         type_int_range *temp_int_range = NULL;
1201         type_int_array *temp_int_array = NULL;
1202         type_int_pair_array *temp_int_pair_array = NULL;
1203         type_string2 *temp_string = NULL;
1204         type_string_array *temp_string_array = NULL;
1205         type_element2 *temp_element = NULL;
1206
1207         MMCAM_LOG_INFO("Entered...");
1208
1209         mmf_return_if_fail(temp_conf);
1210
1211         if ((*configure_info)->type == CONFIGURE_TYPE_MAIN)
1212                 category_num = CONFIGURE_CATEGORY_MAIN_NUM;
1213         else
1214                 category_num = CONFIGURE_CATEGORY_CTRL_NUM;
1215
1216         for (i = 0 ; i < category_num ; i++) {
1217                 if (temp_conf->info[i]) {
1218                         for (j = 0 ; j < temp_conf->info[i]->count ; j++) {
1219                                 if (temp_conf->info[i]->detail_info[j] == NULL)
1220                                         continue;
1221
1222                                 if (_mmcamcorder_conf_get_value_type(handle, temp_conf->type, i, ((type_element*)(temp_conf->info[i]->detail_info[j]))->name, &type)) {
1223                                         switch (type) {
1224                                         case CONFIGURE_VALUE_INT:
1225                                                 temp_int = (type_int2*)(temp_conf->info[i]->detail_info[j]);
1226                                                 SAFE_G_FREE(temp_int->name);
1227                                                 break;
1228                                         case CONFIGURE_VALUE_INT_RANGE:
1229                                                 temp_int_range = (type_int_range*)(temp_conf->info[i]->detail_info[j]);
1230                                                 SAFE_G_FREE(temp_int_range->name);
1231                                                 break;
1232                                         case CONFIGURE_VALUE_INT_ARRAY:
1233                                                 temp_int_array = (type_int_array*)(temp_conf->info[i]->detail_info[j]);
1234                                                 SAFE_G_FREE(temp_int_array->name);
1235                                                 SAFE_G_FREE(temp_int_array->value);
1236                                                 break;
1237                                         case CONFIGURE_VALUE_INT_PAIR_ARRAY:
1238                                                 temp_int_pair_array = (type_int_pair_array*)(temp_conf->info[i]->detail_info[j]);
1239                                                 SAFE_G_FREE(temp_int_pair_array->name);
1240                                                 SAFE_G_FREE(temp_int_pair_array->value[0]);
1241                                                 SAFE_G_FREE(temp_int_pair_array->value[1]);
1242                                                 break;
1243                                         case CONFIGURE_VALUE_STRING:
1244                                                 temp_string = (type_string2*)(temp_conf->info[i]->detail_info[j]);
1245                                                 SAFE_G_FREE(temp_string->name);
1246                                                 SAFE_G_FREE(temp_string->value);
1247                                                 break;
1248                                         case CONFIGURE_VALUE_STRING_ARRAY:
1249                                                 temp_string_array = (type_string_array*)(temp_conf->info[i]->detail_info[j]);
1250                                                 SAFE_G_FREE(temp_string_array->name);
1251                                                 if (temp_string_array->value) {
1252                                                         count = temp_string_array->count;
1253
1254                                                         for (k = 0 ; k < count ; k++)
1255                                                                 SAFE_G_FREE(temp_string_array->value[k]);
1256
1257                                                         SAFE_G_FREE(temp_string_array->value);
1258                                                 }
1259                                                 SAFE_G_FREE(temp_string_array->default_value);
1260                                                 break;
1261                                         case CONFIGURE_VALUE_ELEMENT:
1262                                                 temp_element = (type_element2*)(temp_conf->info[i]->detail_info[j]);
1263                                                 SAFE_G_FREE(temp_element->name);
1264                                                 SAFE_G_FREE(temp_element->element_name);
1265
1266                                                 if (temp_element->value_int) {
1267                                                         count = temp_element->count_int;
1268                                                         for (k = 0 ; k < count ; k++) {
1269                                                                 SAFE_G_FREE(temp_element->value_int[k]->name);
1270                                                                 SAFE_G_FREE(temp_element->value_int[k]);
1271                                                         }
1272                                                         SAFE_G_FREE(temp_element->value_int);
1273                                                 }
1274
1275                                                 if (temp_element->value_string) {
1276                                                         count = temp_element->count_string;
1277                                                         for (k = 0 ; k < count ; k++) {
1278                                                                 SAFE_G_FREE(temp_element->value_string[k]->name);
1279                                                                 SAFE_G_FREE(temp_element->value_string[k]->value);
1280                                                                 SAFE_G_FREE(temp_element->value_string[k]);
1281                                                         }
1282                                                         SAFE_G_FREE(temp_element->value_string);
1283                                                 }
1284                                                 break;
1285                                         default:
1286                                                 MMCAM_LOG_WARNING("unknown type %d", type);
1287                                                 break;
1288                                         }
1289                                 }
1290
1291                                 SAFE_G_FREE(temp_conf->info[i]->detail_info[j]);
1292                         }
1293
1294                         SAFE_G_FREE(temp_conf->info[i]->detail_info);
1295
1296                         SAFE_G_FREE(temp_conf->info[i]);
1297                         temp_conf->info[i] = NULL;
1298                 }
1299         }
1300
1301         SAFE_G_FREE((*configure_info)->info);
1302         SAFE_G_FREE((*configure_info));
1303
1304         MMCAM_LOG_INFO("Done.");
1305 }
1306
1307 int _mmcamcorder_conf_get_value_type(MMHandleType handle, int type, int category, const char* name, int* value_type)
1308 {
1309         int i = 0;
1310         int count_value = 0;
1311
1312         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
1313
1314         if (hcamcorder == NULL) {
1315                 MMCAM_LOG_ERROR("handle is NULL");
1316                 return FALSE;
1317         }
1318
1319         /*MMCAM_LOG_INFO("Entered...");*/
1320
1321         mmf_return_val_if_fail(name, FALSE);
1322
1323         if (!_mmcamcorder_conf_get_category_size(handle, type, category, &count_value)) {
1324                 MMCAM_LOG_WARNING("No matched category... check it... categoty[%d]", category);
1325                 return FALSE;
1326         }
1327
1328         /*MMCAM_LOG_INFO("Number of value : [%d]", count_value);*/
1329
1330         if (type == CONFIGURE_TYPE_MAIN) {
1331                 for (i = 0 ; i < count_value ; i++) {
1332                         if (!strcmp(hcamcorder->conf_main_info_table[category][i].name, name)) {
1333                                 *value_type = hcamcorder->conf_main_info_table[category][i].value_type;
1334                                 /*MMCAM_LOG_INFO("Category[%d],Name[%s],Type[%d]", category, name, *value_type);*/
1335                                 return TRUE;
1336                         }
1337                 }
1338         } else {
1339                 for (i = 0 ; i < count_value ; i++) {
1340                         if (!strcmp(hcamcorder->conf_ctrl_info_table[category][i].name, name)) {
1341                                 *value_type = hcamcorder->conf_ctrl_info_table[category][i].value_type;
1342                                 /*MMCAM_LOG_INFO("Category[%d],Name[%s],Type[%d]", category, name, *value_type);*/
1343                                 return TRUE;
1344                         }
1345                 }
1346         }
1347
1348         return FALSE;
1349 }
1350
1351
1352 int _mmcamcorder_conf_add_info(MMHandleType handle, int type, conf_detail **info, char **buffer_details, int category, int count_details)
1353 {
1354         const int BUFFER_NUM_TOKEN = 256;
1355
1356         int i = 0;
1357         int j = 0;
1358         int count_token;
1359         int value_type;
1360         char *token = NULL;
1361         char *buffer_token[BUFFER_NUM_TOKEN];
1362         char *user_ptr = NULL;
1363
1364         const char *delimiters     = " |=,\t\r\n";
1365         const char *delimiters_sub = " |\t\r\n";
1366         const char *delimiters_3rd = "|\r\n";
1367
1368         mmf_return_val_if_fail(info && buffer_details, FALSE);
1369
1370         (*info) = (conf_detail *)g_malloc0(sizeof(conf_detail));
1371         (*info)->detail_info = (void**)g_malloc0(sizeof(void*) * count_details);
1372         (*info)->count = count_details;
1373
1374         for (i = 0 ; i < count_details ; i++) {
1375                 MMCAM_LOG_VERBOSE("Read line \"%s\"", buffer_details[i]);
1376                 count_token = 0;
1377                 token = strtok_r(buffer_details[i], delimiters, &user_ptr);
1378
1379                 if (token) {
1380                         buffer_token[count_token] = token;
1381                         count_token++;
1382                 } else {
1383                         (*info)->detail_info[i] = NULL;
1384                         MMCAM_LOG_WARNING("No token... check it.[%s]", buffer_details[i]);
1385                         continue;
1386                 }
1387
1388                 if (!_mmcamcorder_conf_get_value_type(handle, type, category, buffer_token[0], &value_type)) {
1389                         (*info)->detail_info[i] = NULL;
1390                         MMCAM_LOG_WARNING("Failed to get value type... check it. Category[%d],Name[%s]", category, buffer_token[0]);
1391                         continue;
1392                 }
1393
1394                 if (value_type != CONFIGURE_VALUE_STRING && value_type != CONFIGURE_VALUE_STRING_ARRAY) {
1395                         token = strtok_r(NULL, delimiters, &user_ptr);
1396                         while (token) {
1397                                 buffer_token[count_token] = token;
1398                                 MMCAM_LOG_VERBOSE("token : [%s]", buffer_token[count_token]);
1399                                 count_token++;
1400                                 token = strtok_r(NULL, delimiters, &user_ptr);
1401                         }
1402
1403                         if (count_token < 2) {
1404                                 (*info)->detail_info[i] = NULL;
1405                                 MMCAM_LOG_WARNING("Number of token is too small... check it.[%s]", buffer_details[i]);
1406                                 continue;
1407                         }
1408                 } else { /* CONFIGURE_VALUE_STRING or CONFIGURE_VALUE_STRING_ARRAY */
1409                         /* skip "=" */
1410                         strtok_r(NULL, delimiters_sub, &user_ptr);
1411
1412                         if (value_type == CONFIGURE_VALUE_STRING_ARRAY) {
1413                                 token = strtok_r(NULL, delimiters_sub, &user_ptr);
1414                                 while (token) {
1415                                         buffer_token[count_token] = token;
1416                                         MMCAM_LOG_VERBOSE("token : [%s]", buffer_token[count_token]);
1417                                         count_token++;
1418                                         token = strtok_r(NULL, delimiters_sub, &user_ptr);
1419                                 }
1420                         } else { /* CONFIGURE_VALUE_STRING */
1421                                 token = strtok_r(NULL, delimiters_3rd, &user_ptr);
1422                                 if (token) {
1423                                         g_strchug(token);
1424                                         buffer_token[count_token] = token;
1425                                         MMCAM_LOG_VERBOSE("token : [%s]", buffer_token[count_token]);
1426                                         count_token++;
1427                                 }
1428                         }
1429
1430                         if (count_token < 2) {
1431                                 (*info)->detail_info[i] = NULL;
1432                                 MMCAM_LOG_WARNING("No string value... check it.[%s]", buffer_details[i]);
1433                                 continue;
1434                         }
1435                 }
1436
1437                 switch (value_type) {
1438                 case CONFIGURE_VALUE_INT:
1439                 {
1440                         type_int2* new_int;
1441
1442                         new_int = (type_int2*)g_malloc0(sizeof(type_int2));
1443                         new_int->name  = get_new_string(buffer_token[0]);
1444                         new_int->value = atoi(buffer_token[1]);
1445                         (*info)->detail_info[i] = (void*)new_int;
1446                         MMCAM_LOG_VERBOSE("INT - name[%s],value[%d]", new_int->name, new_int->value);
1447                         break;
1448                 }
1449                 case CONFIGURE_VALUE_INT_RANGE:
1450                 {
1451                         type_int_range* new_int_range;
1452
1453                         new_int_range = (type_int_range*)g_malloc0(sizeof(type_int_range));
1454                         new_int_range->name          = get_new_string(buffer_token[0]);
1455                         new_int_range->min           = atoi(buffer_token[1]);
1456                         new_int_range->max           = atoi(buffer_token[2]);
1457                         new_int_range->default_value = atoi(buffer_token[3]);
1458                         (*info)->detail_info[i]      = (void*)new_int_range;
1459
1460                         MMCAM_LOG_VERBOSE("INT RANGE - name[%s],min[%d],max[%d],default[%d]",
1461                                 new_int_range->name,
1462                                 new_int_range->min,
1463                                 new_int_range->max,
1464                                 new_int_range->default_value);
1465                         break;
1466                 }
1467                 case CONFIGURE_VALUE_INT_ARRAY:
1468                 {
1469                         int count_value = count_token - 2;
1470                         type_int_array* new_int_array;
1471
1472                         new_int_array = (type_int_array*)g_malloc0(sizeof(type_int_array));
1473                         new_int_array->name = get_new_string(buffer_token[0]);
1474                         new_int_array->value = (int*)g_malloc0(sizeof(int)*count_value);
1475                         new_int_array->count = count_value;
1476
1477                         MMCAM_LOG_VERBOSE("INT ARRAY - name[%s]", new_int_array->name);
1478                         for (j = 0 ; j < count_value ; j++) {
1479                                 new_int_array->value[j] = atoi(buffer_token[j+1]);
1480                                 MMCAM_LOG_VERBOSE("   index[%d] - value[%d]", j, new_int_array->value[j]);
1481                         }
1482
1483                         new_int_array->default_value = atoi(buffer_token[count_token-1]);
1484                         MMCAM_LOG_VERBOSE("   default value[%d]", new_int_array->default_value);
1485
1486                         (*info)->detail_info[i] = (void*)new_int_array;
1487                         break;
1488                 }
1489                 case CONFIGURE_VALUE_INT_PAIR_ARRAY:
1490                 {
1491                         int count_value = (count_token - 3) >> 1;
1492                         type_int_pair_array* new_int_pair_array;
1493
1494                         new_int_pair_array = (type_int_pair_array*)g_malloc0(sizeof(type_int_pair_array));
1495                         new_int_pair_array->name = get_new_string(buffer_token[0]);
1496                         new_int_pair_array->value[0] = (int*)g_malloc0(sizeof(int)*(count_value));
1497                         new_int_pair_array->value[1] = (int*)g_malloc0(sizeof(int)*(count_value));
1498                         new_int_pair_array->count    = count_value;
1499
1500                         MMCAM_LOG_VERBOSE("INT PAIR ARRAY - name[%s],count[%d]", new_int_pair_array->name, count_value);
1501                         for (j = 0 ; j < count_value ; j++) {
1502                                 new_int_pair_array->value[0][j] = atoi(buffer_token[(j<<1)+1]);
1503                                 new_int_pair_array->value[1][j] = atoi(buffer_token[(j<<1)+2]);
1504
1505                                 MMCAM_LOG_VERBOSE("   index[%d] - value[%d,%d]", j,
1506                                         new_int_pair_array->value[0][j],
1507                                         new_int_pair_array->value[1][j]);
1508                         }
1509
1510                         new_int_pair_array->default_value[0] = atoi(buffer_token[count_token-2]);
1511                         new_int_pair_array->default_value[1] = atoi(buffer_token[count_token-1]);
1512
1513                         MMCAM_LOG_VERBOSE("   default value[%d,%d]",
1514                                 new_int_pair_array->default_value[0],
1515                                 new_int_pair_array->default_value[1]);
1516
1517                         (*info)->detail_info[i] = (void*)new_int_pair_array;
1518                         break;
1519                 }
1520                 case CONFIGURE_VALUE_STRING:
1521                 {
1522                         type_string2* new_string;
1523
1524                         new_string = (type_string2*)g_malloc0(sizeof(type_string2));
1525                         new_string->name  = get_new_string(buffer_token[0]);
1526                         new_string->value = get_new_string(buffer_token[1]);
1527                         (*info)->detail_info[i] = (void*)new_string;
1528
1529                         MMCAM_LOG_VERBOSE("STRING - name[%s],value[%s]", new_string->name, new_string->value);
1530                         break;
1531                 }
1532                 case CONFIGURE_VALUE_STRING_ARRAY:
1533                 {
1534                         int count_value = count_token - 2;
1535                         type_string_array* new_string_array;
1536
1537                         new_string_array = (type_string_array*)g_malloc0(sizeof(type_string_array));
1538                         new_string_array->name  = get_new_string(buffer_token[0]);
1539                         new_string_array->count = count_value;
1540                         new_string_array->value = (char**)g_malloc0(sizeof(char*)*count_value);
1541
1542                         MMCAM_LOG_VERBOSE("STRING ARRAY - name[%s]", new_string_array->name);
1543
1544                         for (j = 0 ; j < count_value ; j++) {
1545                                 new_string_array->value[j] = get_new_string(buffer_token[j+1]);
1546                                 MMCAM_LOG_VERBOSE("   index[%d] - value[%s]", j, new_string_array->value[j]);
1547                         }
1548
1549                         new_string_array->default_value = get_new_string(buffer_token[count_token-1]);
1550
1551                         MMCAM_LOG_VERBOSE("   default value[%s]", new_string_array->default_value);
1552
1553                         (*info)->detail_info[i] = (void*)new_string_array;
1554                         break;
1555                 }
1556                 case CONFIGURE_VALUE_ELEMENT:
1557                 {
1558                         type_element2* new_element;
1559
1560                         j = 0;
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 < 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_get_element_and_name(MMHandleType handle, camera_conf *conf, int category,
2098         const char *name, type_element **element, const char **element_name)
2099 {
2100         type_element *_element = NULL;
2101         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2102
2103         if (!hcamcorder) {
2104                 MMCAM_LOG_ERROR("NULL handle");
2105                 return;
2106         }
2107
2108         if (!_mmcamcorder_conf_get_element(handle, conf,
2109                 category, name, &_element)) {
2110                 MMCAM_LOG_WARNING("get [%s] failed", name);
2111                 return;
2112         }
2113
2114         if (element)
2115                 *element = _element;
2116
2117         if (element_name) {
2118                 _mmcamcorder_conf_get_value_element_name(_element, element_name);
2119                 MMCAM_LOG_INFO("[%s] -> [%s]", name, *element_name);
2120         }
2121 }
2122
2123 void _mmcamcorder_conf_print_info(MMHandleType handle, camera_conf** configure_info)
2124 {
2125         int i, j, k, type, category_type;
2126
2127         type_int                *temp_int;
2128         type_int_range          *temp_int_range;
2129         type_int_array          *temp_int_array;
2130         type_int_pair_array     *temp_int_pair_array;
2131         type_string             *temp_string;
2132         type_element            *temp_element;
2133
2134         g_print("[ConfigureInfoPrint] : Entered.\n");
2135
2136         mmf_return_if_fail(*configure_info);
2137
2138         if ((*configure_info)->type == CONFIGURE_TYPE_MAIN)
2139                 category_type = CONFIGURE_CATEGORY_MAIN_NUM;
2140         else
2141                 category_type = CONFIGURE_CATEGORY_CTRL_NUM;
2142
2143         for (i = 0 ; i < category_type ; i++) {
2144
2145                 if ((*configure_info)->info[i]) {
2146                         g_print("[ConfigureInfo] : Category [%d]\n", i);
2147
2148                         for (j = 0 ; j < (*configure_info)->info[i]->count ; j++) {
2149
2150                                 if (_mmcamcorder_conf_get_value_type(handle, (*configure_info)->type, i, ((type_int*)((*configure_info)->info[i]->detail_info[j]))->name, &type)) {
2151                                         switch (type) {
2152                                         case CONFIGURE_VALUE_INT:
2153                                                 temp_int = (type_int*)((*configure_info)->info[i]->detail_info[j]);
2154                                                 g_print("[ConfigureInfo] : INT - Name[%s],Value [%d]\n", temp_int->name, temp_int->value);
2155                                                 break;
2156                                         case CONFIGURE_VALUE_INT_RANGE:
2157                                                 temp_int_range = (type_int_range*)((*configure_info)->info[i]->detail_info[j]);
2158                                                 g_print("[ConfigureInfo] : INT_RANGE - Name[%s],Value [%d]~[%d], default [%d]\n",
2159                                                         temp_int_range->name, temp_int_range->min, temp_int_range->max, temp_int_range->default_value);
2160                                                 break;
2161                                         case CONFIGURE_VALUE_INT_ARRAY:
2162                                                 temp_int_array = (type_int_array*)((*configure_info)->info[i]->detail_info[j]);
2163                                                 g_print("[ConfigureInfo] : INT_ARRAY - Name[%s], default [%d]\n                            - ",
2164                                                         temp_int_array->name, temp_int_array->default_value);
2165
2166                                                 for (k = 0 ; k < temp_int_array->count ; k++)
2167                                                         g_print("[%d] ", temp_int_array->value[k]);
2168
2169                                                 g_print("\n");
2170                                                 break;
2171                                         case CONFIGURE_VALUE_INT_PAIR_ARRAY:
2172                                                 temp_int_pair_array = (type_int_pair_array*)((*configure_info)->info[i]->detail_info[j]);
2173                                                 g_print("[ConfigureInfo] : INT_PAIR_ARRAY - Name[%s], default [%d][%d]\n                            - ",
2174                                                         temp_int_pair_array->name, temp_int_pair_array->default_value[0], temp_int_pair_array->default_value[0]);
2175
2176                                                 for (k = 0 ; k < temp_int_pair_array->count ; k++)
2177                                                         g_print("[%d,%d] ", temp_int_pair_array->value[0][k], temp_int_pair_array->value[1][k]);
2178
2179                                                 g_print("\n");
2180                                                 break;
2181                                         case CONFIGURE_VALUE_STRING:
2182                                                 temp_string = (type_string*)((*configure_info)->info[i]->detail_info[j]);
2183                                                 g_print("[ConfigureInfo] : STRING - Name[%s],Value[%s]\n", temp_string->name, temp_string->value);
2184                                                 break;
2185                                         case CONFIGURE_VALUE_ELEMENT:
2186                                                 temp_element = (type_element*)((*configure_info)->info[i]->detail_info[j]);
2187                                                 g_print("[ConfigureInfo] : Element - Name[%s],Element_Name[%s]\n", temp_element->name, temp_element->element_name);
2188
2189                                                 for (k = 0 ; k < temp_element->count_int ; k++)
2190                                                         g_print("                          - INT[%d] Name[%s],Value[%d]\n", k, temp_element->value_int[k]->name, temp_element->value_int[k]->value);
2191
2192                                                 for (k = 0 ; k < temp_element->count_string ; k++)
2193                                                         g_print("                          - STRING[%d] Name[%s],Value[%s]\n", k, temp_element->value_string[k]->name, temp_element->value_string[k]->value);
2194
2195                                                 break;
2196                                         default:
2197                                                 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);
2198                                                 break;
2199                                         }
2200                                 } else {
2201                                         g_print("[ConfigureInfo] : Failed to get value type.");
2202                                 }
2203                         }
2204                 }
2205         }
2206
2207         g_print("[ConfigureInfoPrint] : Done.\n");
2208 }
2209
2210
2211 static type_element *__mmcamcorder_get_audio_codec_element(MMHandleType handle)
2212 {
2213         type_element *telement = NULL;
2214         const char *codec_type_str = NULL;
2215         int codec_type = MM_AUDIO_CODEC_INVALID;
2216         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2217         _MMCamcorderSubContext *sc = NULL;
2218
2219         mmf_return_val_if_fail(hcamcorder, NULL);
2220         sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2221
2222         mmf_return_val_if_fail(sc, NULL);
2223
2224         MMCAM_LOG_INFO("");
2225
2226         /* Check element availability */
2227         mm_camcorder_get_attributes(handle, NULL, MMCAM_AUDIO_ENCODER, &codec_type, NULL);
2228
2229         switch (codec_type) {
2230         case MM_AUDIO_CODEC_AMR:
2231                 codec_type_str = "AMR";
2232                 break;
2233         case MM_AUDIO_CODEC_G723_1:
2234                 codec_type_str = "G723_1";
2235                 break;
2236         case MM_AUDIO_CODEC_MP3:
2237                 codec_type_str = "MP3";
2238                 break;
2239         case MM_AUDIO_CODEC_AAC:
2240                 codec_type_str = "AAC";
2241                 break;
2242         case MM_AUDIO_CODEC_MMF:
2243                 codec_type_str = "MMF";
2244                 break;
2245         case MM_AUDIO_CODEC_ADPCM:
2246                 codec_type_str = "ADPCM";
2247                 break;
2248         case MM_AUDIO_CODEC_WAVE:
2249                 codec_type_str = "WAVE";
2250                 break;
2251         case MM_AUDIO_CODEC_MIDI:
2252                 codec_type_str = "MIDI";
2253                 break;
2254         case MM_AUDIO_CODEC_IMELODY:
2255                 codec_type_str = "IMELODY";
2256                 break;
2257         case MM_AUDIO_CODEC_VORBIS:
2258                 codec_type_str = "VORBIS";
2259                 break;
2260         default:
2261                 MMCAM_LOG_ERROR("Not supported audio codec[%d]", codec_type);
2262                 return NULL;
2263         }
2264
2265         _mmcamcorder_conf_get_element(handle, hcamcorder->conf_main,
2266                 CONFIGURE_CATEGORY_MAIN_AUDIO_ENCODER,
2267                 codec_type_str,
2268                 &telement);
2269
2270         return telement;
2271 }
2272
2273
2274 static type_element *__mmcamcorder_get_video_codec_element(MMHandleType handle)
2275 {
2276         type_element *telement = NULL;
2277         const char *codec_type_str = NULL;
2278         int codec_type = MM_VIDEO_CODEC_INVALID;
2279         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2280         _MMCamcorderSubContext *sc = NULL;
2281
2282         mmf_return_val_if_fail(hcamcorder, NULL);
2283         sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2284
2285         mmf_return_val_if_fail(sc, NULL);
2286
2287         /* Check element availability */
2288         mm_camcorder_get_attributes(handle, NULL, MMCAM_VIDEO_ENCODER, &codec_type, NULL);
2289
2290         switch (codec_type) {
2291         case MM_VIDEO_CODEC_H263:
2292                 codec_type_str = "H263";
2293                 break;
2294         case MM_VIDEO_CODEC_H264:
2295                 codec_type_str = "H264";
2296                 break;
2297         case MM_VIDEO_CODEC_H26L:
2298                 codec_type_str = "H26L";
2299                 break;
2300         case MM_VIDEO_CODEC_MPEG4:
2301                 codec_type_str = "MPEG4";
2302                 break;
2303         case MM_VIDEO_CODEC_MPEG1:
2304                 codec_type_str = "MPEG1";
2305                 break;
2306         case MM_VIDEO_CODEC_THEORA:
2307                 codec_type_str = "THEORA";
2308                 break;
2309         default:
2310                 MMCAM_LOG_ERROR("Not supported video codec[%d]", codec_type);
2311                 return NULL;
2312         }
2313
2314         _mmcamcorder_conf_get_element(handle, hcamcorder->conf_main,
2315                 CONFIGURE_CATEGORY_MAIN_VIDEO_ENCODER,
2316                 codec_type_str,
2317                 &telement);
2318
2319         return telement;
2320 }
2321
2322
2323 static type_element *__mmcamcorder_get_image_codec_element(MMHandleType handle)
2324 {
2325         type_element *telement = NULL;
2326         const char *codec_type_str = NULL;
2327         int codec_type = MM_IMAGE_CODEC_INVALID;
2328         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2329         _MMCamcorderSubContext *sc = NULL;
2330
2331         mmf_return_val_if_fail(hcamcorder, NULL);
2332         sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2333
2334         mmf_return_val_if_fail(sc, NULL);
2335
2336         /* Check element availability */
2337         mm_camcorder_get_attributes(handle, NULL, MMCAM_IMAGE_ENCODER, &codec_type, NULL);
2338
2339         switch (codec_type) {
2340         case MM_IMAGE_CODEC_JPEG:
2341                 codec_type_str = "JPEG";
2342                 break;
2343         case MM_IMAGE_CODEC_SRW:
2344                 codec_type_str = "SRW";
2345                 break;
2346         case MM_IMAGE_CODEC_JPEG_SRW:
2347                 codec_type_str = "JPEG_SRW";
2348                 break;
2349         case MM_IMAGE_CODEC_PNG:
2350                 codec_type_str = "PNG";
2351                 break;
2352         case MM_IMAGE_CODEC_BMP:
2353                 codec_type_str = "BMP";
2354                 break;
2355         case MM_IMAGE_CODEC_WBMP:
2356                 codec_type_str = "WBMP";
2357                 break;
2358         case MM_IMAGE_CODEC_TIFF:
2359                 codec_type_str = "TIFF";
2360                 break;
2361         case MM_IMAGE_CODEC_PCX:
2362                 codec_type_str = "PCX";
2363                 break;
2364         case MM_IMAGE_CODEC_GIF:
2365                 codec_type_str = "GIF";
2366                 break;
2367         case MM_IMAGE_CODEC_ICO:
2368                 codec_type_str = "ICO";
2369                 break;
2370         case MM_IMAGE_CODEC_RAS:
2371                 codec_type_str = "RAS";
2372                 break;
2373         case MM_IMAGE_CODEC_TGA:
2374                 codec_type_str = "TGA";
2375                 break;
2376         case MM_IMAGE_CODEC_XBM:
2377                 codec_type_str = "XBM";
2378                 break;
2379         case MM_IMAGE_CODEC_XPM:
2380                 codec_type_str = "XPM";
2381                 break;
2382         default:
2383                 MMCAM_LOG_ERROR("Not supported image codec[%d]", codec_type);
2384                 return NULL;
2385         }
2386
2387         _mmcamcorder_conf_get_element(handle, hcamcorder->conf_main,
2388                 CONFIGURE_CATEGORY_MAIN_IMAGE_ENCODER,
2389                 codec_type_str,
2390                 &telement);
2391
2392         return telement;
2393 }
2394
2395
2396 static type_element *__mmcamcorder_get_file_format_element(MMHandleType handle)
2397 {
2398         type_element *telement = NULL;
2399         const char *mux_type_str = NULL;
2400         int file_type = MM_FILE_FORMAT_INVALID;
2401         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2402         _MMCamcorderSubContext *sc = NULL;
2403
2404         mmf_return_val_if_fail(hcamcorder, NULL);
2405         sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2406
2407         mmf_return_val_if_fail(sc, NULL);
2408
2409         /* Check element availability */
2410         mm_camcorder_get_attributes(handle, NULL, MMCAM_FILE_FORMAT, &file_type, NULL);
2411
2412         switch (file_type) {
2413         case MM_FILE_FORMAT_3GP:
2414                 mux_type_str = "3GP";
2415                 break;
2416         case MM_FILE_FORMAT_AMR:
2417                 mux_type_str = "AMR";
2418                 break;
2419         case MM_FILE_FORMAT_MP4:
2420                 mux_type_str = "MP4";
2421                 break;
2422         case MM_FILE_FORMAT_AAC:
2423                 mux_type_str = "AAC";
2424                 break;
2425         case MM_FILE_FORMAT_MP3:
2426                 mux_type_str = "MP3";
2427                 break;
2428         case MM_FILE_FORMAT_OGG:
2429                 mux_type_str = "OGG";
2430                 break;
2431         case MM_FILE_FORMAT_WAV:
2432                 mux_type_str = "WAV";
2433                 break;
2434         case MM_FILE_FORMAT_AVI:
2435                 mux_type_str = "AVI";
2436                 break;
2437         case MM_FILE_FORMAT_WMA:
2438                 mux_type_str = "WMA";
2439                 break;
2440         case MM_FILE_FORMAT_WMV:
2441                 mux_type_str = "WMV";
2442                 break;
2443         case MM_FILE_FORMAT_MID:
2444                 mux_type_str = "MID";
2445                 break;
2446         case MM_FILE_FORMAT_MMF:
2447                 mux_type_str = "MMF";
2448                 break;
2449         case MM_FILE_FORMAT_MATROSKA:
2450                 mux_type_str = "MATROSKA";
2451                 break;
2452         case MM_FILE_FORMAT_M2TS:
2453                 mux_type_str = "M2TS";
2454                 break;
2455         default:
2456                 MMCAM_LOG_ERROR("Not supported file format[%d]", file_type);
2457                 return NULL;
2458         }
2459
2460         _mmcamcorder_conf_get_element(handle, hcamcorder->conf_main,
2461                 CONFIGURE_CATEGORY_MAIN_MUX,
2462                 mux_type_str,
2463                 &telement);
2464
2465         return telement;
2466 }
2467
2468
2469 type_element *_mmcamcorder_get_type_element(MMHandleType handle, int type)
2470 {
2471         type_element *telement = NULL;
2472
2473         switch (type) {
2474         case MM_CAM_AUDIO_ENCODER:
2475                 telement = __mmcamcorder_get_audio_codec_element(handle);
2476                 break;
2477         case MM_CAM_VIDEO_ENCODER:
2478                 telement = __mmcamcorder_get_video_codec_element(handle);
2479                 break;
2480         case MM_CAM_IMAGE_ENCODER:
2481                 telement = __mmcamcorder_get_image_codec_element(handle);
2482                 break;
2483         case MM_CAM_FILE_FORMAT:
2484                 telement = __mmcamcorder_get_file_format_element(handle);
2485                 break;
2486         default:
2487                 MMCAM_LOG_INFO("Can't get element type form this profile.(%d)", type);
2488         }
2489
2490         return telement;
2491 }
2492
2493
2494 int _mmcamcorder_get_audio_codec_format(MMHandleType handle, const char *name)
2495 {
2496         int codec_index = MM_AUDIO_CODEC_INVALID;
2497
2498         if (!name) {
2499                 MMCAM_LOG_ERROR("name is NULL");
2500                 return MM_AUDIO_CODEC_INVALID;
2501         }
2502
2503         if (!strcmp(name, "AMR"))
2504                 codec_index = MM_AUDIO_CODEC_AMR;
2505         else if (!strcmp(name, "G723_1"))
2506                 codec_index = MM_AUDIO_CODEC_G723_1;
2507         else if (!strcmp(name, "MP3"))
2508                 codec_index = MM_AUDIO_CODEC_MP3;
2509         else if (!strcmp(name, "AAC"))
2510                 codec_index = MM_AUDIO_CODEC_AAC;
2511         else if (!strcmp(name, "MMF"))
2512                 codec_index = MM_AUDIO_CODEC_MMF;
2513         else if (!strcmp(name, "ADPCM"))
2514                 codec_index = MM_AUDIO_CODEC_ADPCM;
2515         else if (!strcmp(name, "WAVE"))
2516                 codec_index = MM_AUDIO_CODEC_WAVE;
2517         else if (!strcmp(name, "MIDI"))
2518                 codec_index = MM_AUDIO_CODEC_MIDI;
2519         else if (!strcmp(name, "IMELODY"))
2520                 codec_index = MM_AUDIO_CODEC_IMELODY;
2521         else if (!strcmp(name, "VORBIS"))
2522                 codec_index = MM_AUDIO_CODEC_VORBIS;
2523
2524         MMCAM_LOG_DEBUG("audio codec index %d", codec_index);
2525
2526         return codec_index;
2527 }
2528
2529
2530
2531 int _mmcamcorder_get_video_codec_format(MMHandleType handle, const char *name)
2532 {
2533         int codec_index = MM_VIDEO_CODEC_INVALID;
2534
2535         if (!name) {
2536                 MMCAM_LOG_ERROR("name is NULL");
2537                 return MM_VIDEO_CODEC_INVALID;
2538         }
2539
2540         if (!strcmp(name, "H263"))
2541                 codec_index = MM_VIDEO_CODEC_H263;
2542         else if (!strcmp(name, "H264"))
2543                 codec_index = MM_VIDEO_CODEC_H264;
2544         else if (!strcmp(name, "H26L"))
2545                 codec_index = MM_VIDEO_CODEC_H26L;
2546         else if (!strcmp(name, "MPEG4"))
2547                 codec_index = MM_VIDEO_CODEC_MPEG4;
2548         else if (!strcmp(name, "MPEG1"))
2549                 codec_index = MM_VIDEO_CODEC_MPEG1;
2550         else if (!strcmp(name, "THEORA"))
2551                 codec_index = MM_VIDEO_CODEC_THEORA;
2552
2553         MMCAM_LOG_DEBUG("video codec index %d", codec_index);
2554
2555         return codec_index;
2556 }
2557
2558
2559
2560 int _mmcamcorder_get_image_codec_format(MMHandleType handle, const char *name)
2561 {
2562         int codec_index = MM_IMAGE_CODEC_INVALID;
2563
2564         if (!name) {
2565                 MMCAM_LOG_ERROR("name is NULL");
2566                 return MM_IMAGE_CODEC_INVALID;
2567         }
2568
2569         if (!strcmp(name, "JPEG"))
2570                 codec_index = MM_IMAGE_CODEC_JPEG;
2571         else if (!strcmp(name, "PNG"))
2572                 codec_index = MM_IMAGE_CODEC_PNG;
2573         else if (!strcmp(name, "BMP"))
2574                 codec_index = MM_IMAGE_CODEC_BMP;
2575         else if (!strcmp(name, "WBMP"))
2576                 codec_index = MM_IMAGE_CODEC_WBMP;
2577         else if (!strcmp(name, "TIFF"))
2578                 codec_index = MM_IMAGE_CODEC_TIFF;
2579         else if (!strcmp(name, "PCX"))
2580                 codec_index = MM_IMAGE_CODEC_PCX;
2581         else if (!strcmp(name, "GIF"))
2582                 codec_index = MM_IMAGE_CODEC_GIF;
2583         else if (!strcmp(name, "ICO"))
2584                 codec_index = MM_IMAGE_CODEC_ICO;
2585         else if (!strcmp(name, "RAS"))
2586                 codec_index = MM_IMAGE_CODEC_RAS;
2587         else if (!strcmp(name, "TGA"))
2588                 codec_index = MM_IMAGE_CODEC_TGA;
2589         else if (!strcmp(name, "XBM"))
2590                 codec_index = MM_IMAGE_CODEC_XBM;
2591         else if (!strcmp(name, "XPM"))
2592                 codec_index = MM_IMAGE_CODEC_XPM;
2593
2594         MMCAM_LOG_DEBUG("image codec index %d", codec_index);
2595
2596         return codec_index;
2597 }
2598
2599
2600 int _mmcamcorder_get_mux_format(MMHandleType handle, const char *name)
2601 {
2602         int mux_index = MM_FILE_FORMAT_INVALID;
2603
2604         if (!name) {
2605                 MMCAM_LOG_ERROR("name is NULL");
2606                 return MM_FILE_FORMAT_INVALID;
2607         }
2608
2609         if (!strcmp(name, "3GP"))
2610                 mux_index = MM_FILE_FORMAT_3GP;
2611         else if (!strcmp(name, "AMR"))
2612                 mux_index = MM_FILE_FORMAT_AMR;
2613         else if (!strcmp(name, "MP4"))
2614                 mux_index = MM_FILE_FORMAT_MP4;
2615         else if (!strcmp(name, "AAC"))
2616                 mux_index = MM_FILE_FORMAT_AAC;
2617         else if (!strcmp(name, "MP3"))
2618                 mux_index = MM_FILE_FORMAT_MP3;
2619         else if (!strcmp(name, "OGG"))
2620                 mux_index = MM_FILE_FORMAT_OGG;
2621         else if (!strcmp(name, "WAV"))
2622                 mux_index = MM_FILE_FORMAT_WAV;
2623         else if (!strcmp(name, "AVI"))
2624                 mux_index = MM_FILE_FORMAT_AVI;
2625         else if (!strcmp(name, "WMA"))
2626                 mux_index = MM_FILE_FORMAT_WMA;
2627         else if (!strcmp(name, "WMV"))
2628                 mux_index = MM_FILE_FORMAT_WMV;
2629         else if (!strcmp(name, "MID"))
2630                 mux_index = MM_FILE_FORMAT_MID;
2631         else if (!strcmp(name, "MMF"))
2632                 mux_index = MM_FILE_FORMAT_MMF;
2633         else if (!strcmp(name, "MATROSKA"))
2634                 mux_index = MM_FILE_FORMAT_MATROSKA;
2635         else if (!strcmp(name, "M2TS"))
2636                 mux_index = MM_FILE_FORMAT_M2TS;
2637
2638         MMCAM_LOG_DEBUG("mux index %d", mux_index);
2639
2640         return mux_index;
2641 }
2642
2643
2644 int _mmcamcorder_get_format(MMHandleType handle, int conf_category, const char *name)
2645 {
2646         int fmt = -1;
2647
2648         mmf_return_val_if_fail(name, -1);
2649
2650         switch (conf_category) {
2651         case CONFIGURE_CATEGORY_MAIN_AUDIO_ENCODER:
2652                 fmt = _mmcamcorder_get_audio_codec_format(handle, name);
2653                 break;
2654         case CONFIGURE_CATEGORY_MAIN_VIDEO_ENCODER:
2655                 fmt = _mmcamcorder_get_video_codec_format(handle, name);
2656                 break;
2657         case CONFIGURE_CATEGORY_MAIN_IMAGE_ENCODER:
2658                 fmt = _mmcamcorder_get_image_codec_format(handle, name);
2659                 break;
2660         case CONFIGURE_CATEGORY_MAIN_MUX:
2661                 fmt = _mmcamcorder_get_mux_format(handle, name);
2662                 break;
2663         default:
2664                 MMCAM_LOG_ERROR("Can't get format from this category.(%d)", conf_category);
2665         }
2666
2667         return fmt;
2668 }
2669
2670 int _mmcamcorder_get_available_format(MMHandleType handle, int conf_category, int **format)
2671 {
2672         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2673         camera_conf* configure_info = NULL;
2674         int *arr = NULL;
2675         int total_count = 0;
2676
2677         mmf_return_val_if_fail(hcamcorder, 0);
2678
2679         configure_info = hcamcorder->conf_main;
2680
2681         if (configure_info->info[conf_category]) {
2682                 int i = 0;
2683                 int fmt = 0;
2684                 const char *name = NULL;
2685                 int count = configure_info->info[conf_category]->count;
2686                 conf_detail *info = configure_info->info[conf_category];
2687
2688                 MMCAM_LOG_DEBUG("conf_category[%d] : count[%d], info[%p]",
2689                         conf_category, count, info);
2690
2691                 if (count <= 0 || !info)
2692                         return total_count;
2693
2694                 arr = (int*)g_malloc0(count * sizeof(int));
2695
2696                 for (i = 0 ; i < count ; i++) {
2697                         if (info->detail_info[i] == NULL)
2698                                 continue;
2699
2700                         name = ((type_element*)(info->detail_info[i]))->name;
2701                         fmt = _mmcamcorder_get_format(handle, conf_category, name);
2702                         if (fmt >= 0)
2703                                 arr[total_count++] = fmt;
2704
2705                         MMCAM_LOG_VERBOSE("    name:%s, fmt:%d", name, fmt);
2706                 }
2707         }
2708
2709         *format = arr;
2710
2711         return total_count;
2712 }