4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Jeongmo Yang <jm80.yang@samsung.com>
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
12 * http://www.apache.org/licenses/LICENSE-2.0
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.
22 /*=======================================================================================
24 =======================================================================================*/
30 #include "mm_camcorder_internal.h"
31 #include "mm_camcorder_configure.h"
33 /*-----------------------------------------------------------------------
34 | MACRO DEFINITIONS: |
35 -----------------------------------------------------------------------*/
37 /*-----------------------------------------------------------------------
38 | GLOBAL VARIABLE DEFINITIONS |
39 -----------------------------------------------------------------------*/
41 /*-----------------------------------------------------------------------
42 | LOCAL VARIABLE DEFINITIONS |
43 -----------------------------------------------------------------------*/
44 #define DEFAULT_AUDIO_BUFFER_INTERVAL 50
45 #define DEFAULT_ENCODED_PREVIEW_BITRATE (1024*1024*4)
47 #define MMCAMCORDER_CONF_FILEPATH_LENGTH 128
48 #define MMCAMCORDER_BUFFER_LINE_MAX 256
50 char *get_new_string(char* src_string)
52 return g_strdup(src_string);
55 int _mmcamcorder_conf_init(MMHandleType handle, int type, camera_conf *configure_info)
58 int info_table_size = sizeof(conf_info_table);
60 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
62 mmf_return_val_if_fail(hcamcorder && configure_info, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
64 /* Videosrc element default value */
65 static type_element _videosrc_element_default = {
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,
85 static type_string ___audiosrc_default_device = {"Device", "default"};
86 static type_string* __audiosrc_default_string_array[] = {
87 &___audiosrc_default_device,
89 static type_element _audiosrc_element_default = {
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*),
98 static type_element _audiomodemsrc_element_default = {
99 "AudiomodemsrcElement",
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*),
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,
123 static type_string* __videosink_default_string_array[] = {NULL};
124 static type_element _videosink_element_overlay_default = {
125 "VideosinkElementOverlay",
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*),
132 static type_element _videosink_element_evas_default = {
133 "VideosinkElementEvas",
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*),
140 static type_element _videosink_element_gl_default = {
141 "VideosinkElementGL",
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*),
148 static type_element _videosink_element_remote_default = {
149 "VideosinkElementRemote",
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*),
156 static type_element _videosink_element_null_default = {
157 "VideosinkElementNull",
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*),
165 /* Videoscale element default value */
166 static type_element _videoscale_element_default = {
175 /* Videoconvert element default value */
176 static type_element _videoconvert_element_default = {
177 "VideoconvertElement",
185 /* H.264 decoder element default value */
186 static type_element _videodecoder_element_h264_default = {
187 "VideodecoderElementH264",
195 /* MJPEG decoder element default value */
196 static type_element _videodecoder_element_mjpeg_default = {
197 "VideodecoderElementMJPEG",
205 /* VP8 decoder element default value */
206 static type_element _videodecoder_element_vp8_default = {
207 "VideodecoderElementVP8",
215 /* VP9 decoder element default value */
216 static type_element _videodecoder_element_vp9_default = {
217 "VideodecoderElementVP9",
225 /* Record sink element default value */
226 static type_element _recordsink_element_default = {
235 /* H263 element default value */
236 static type_element _h263_element_default = {
245 /* H264 element default value */
246 static type_element _h264_element_default = {
255 /* H26L element default value */
256 static type_element _h26l_element_default = {
265 /* MPEG4 element default value */
266 static type_element _mpeg4_element_default = {
275 /* MPEG1 element default value */
276 static type_element _mpeg1_element_default = {
285 /* THEORA element default value */
286 static type_element _theora_element_default = {
295 /* AMR element default value */
296 static type_element _amr_element_default = {
305 /* G723_1 element default value */
306 static type_element _g723_1_element_default = {
315 /* MP3 element default value */
316 static type_element _mp3_element_default = {
325 /* AAC element default value */
326 static type_element _aac_element_default = {
335 /* MMF element default value */
336 static type_element _mmf_element_default = {
345 /* ADPCM element default value */
346 static type_element _adpcm_element_default = {
348 "avenc_adpcm_ima_qt",
355 /* WAVE element default value */
356 static type_element _wave_element_default = {
365 /* VORBIS element default value */
366 static type_element _vorbis_element_default = {
375 /* MIDI element default value */
376 static type_element _midi_element_default = {
385 /* IMELODY element default value */
386 static type_element _imelody_element_default = {
395 /* JPEG element default value */
396 static type_element _jpeg_element_default = {
405 /* PNG element default value */
406 static type_element _png_element_default = {
415 /* BMP element default value */
416 static type_element _bmp_element_default = {
425 /* WBMP element default value */
426 static type_element _wbmp_element_default = {
435 /* TIFF element default value */
436 static type_element _tiff_element_default = {
445 /* PCX element default value */
446 static type_element _pcx_element_default = {
455 /* GIF element default value */
456 static type_element _gif_element_default = {
465 /* ICO element default value */
466 static type_element _ico_element_default = {
475 /* RAS element default value */
476 static type_element _ras_element_default = {
485 /* TGA element default value */
486 static type_element _tga_element_default = {
495 /* XBM element default value */
496 static type_element _xbm_element_default = {
505 /* XPM element default value */
506 static type_element _xpm_element_default = {
515 /* 3GP element default value */
516 static type_element _3gp_element_default = {
525 /* AMR mux element default value */
526 static type_element _amrmux_element_default = {
535 /* MP4 element default value */
536 static type_element _mp4_element_default = {
545 /* AAC mux element default value */
546 static type_element _aacmux_element_default = {
555 /* MP3 mux element default value */
556 static type_element _mp3mux_element_default = {
565 /* OGG element default value */
566 static type_element _ogg_element_default = {
575 /* WAV element default value */
576 static type_element _wav_element_default = {
585 /* AVI element default value */
586 static type_element _avi_element_default = {
595 /* WMA element default value */
596 static type_element _wma_element_default = {
605 /* WMV element default value */
606 static type_element _wmv_element_default = {
615 /* MID element default value */
616 static type_element _mid_element_default = {
625 /* MMF mux element default value */
626 static type_element _mmfmux_element_default = {
635 /* MATROSKA element default value */
636 static type_element _matroska_element_default = {
645 /* M2TS element default value */
646 static type_element _m2ts_element_default = {
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} },
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} },
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} },
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} }
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} },
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} }
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} },
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} },
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} },
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} },
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} }
829 /* [Strobe] matching table */
830 static conf_info_table conf_ctrl_strobe_table[] = {
831 { "StrobeControl", CONFIGURE_VALUE_INT_ARRAY, {NULL} },
832 { "StrobeMode", CONFIGURE_VALUE_INT_ARRAY, {NULL} },
833 { "StrobeEV", CONFIGURE_VALUE_INT_RANGE, {NULL} },
834 { "StrobeBrightness", CONFIGURE_VALUE_INT_RANGE, {NULL} },
837 /* [Effect] matching table */
838 static conf_info_table conf_ctrl_effect_table[] = {
839 { "Brightness", CONFIGURE_VALUE_INT_RANGE, {NULL} },
840 { "BrightnessStepDenominator", CONFIGURE_VALUE_INT, {.value_int = 2} },
841 { "Contrast", CONFIGURE_VALUE_INT_RANGE, {NULL} },
842 { "Saturation", CONFIGURE_VALUE_INT_RANGE, {NULL} },
843 { "Sharpness", CONFIGURE_VALUE_INT_RANGE, {NULL} },
844 { "Hue", CONFIGURE_VALUE_INT_RANGE, {NULL} },
845 { "WhiteBalance", CONFIGURE_VALUE_INT_ARRAY, {NULL} },
846 { "ColorTone", CONFIGURE_VALUE_INT_ARRAY, {NULL} },
847 { "Flip", CONFIGURE_VALUE_INT_ARRAY, {NULL} },
848 { "Rotation", CONFIGURE_VALUE_INT_ARRAY, {NULL} },
849 { "WDR", CONFIGURE_VALUE_INT_ARRAY, {NULL} },
850 { "PartColorMode", CONFIGURE_VALUE_INT_ARRAY, {NULL} },
851 { "PartColor", CONFIGURE_VALUE_INT_ARRAY, {NULL} },
854 /* [Photograph] matching table */
855 static conf_info_table conf_ctrl_photograph_table[] = {
856 { "LensInit", CONFIGURE_VALUE_INT_ARRAY, {NULL} },
857 { "DigitalZoom", CONFIGURE_VALUE_INT_RANGE, {NULL} },
858 { "OpticalZoom", CONFIGURE_VALUE_INT_RANGE, {NULL} },
859 { "FocusMode", CONFIGURE_VALUE_INT_ARRAY, {NULL} },
860 { "FocusLevel", CONFIGURE_VALUE_INT_RANGE, {NULL} },
861 { "AFType", CONFIGURE_VALUE_INT_ARRAY, {NULL} },
862 { "AEType", CONFIGURE_VALUE_INT_ARRAY, {NULL} },
863 { "ExposureValue", CONFIGURE_VALUE_INT_RANGE, {NULL} },
864 { "FNumber", CONFIGURE_VALUE_INT_ARRAY, {NULL} },
865 { "ShutterSpeed", CONFIGURE_VALUE_INT_ARRAY, {NULL} },
866 { "ISO", CONFIGURE_VALUE_INT_ARRAY, {NULL} },
867 { "ProgramMode", CONFIGURE_VALUE_INT_ARRAY, {NULL} },
868 { "AntiHandshake", CONFIGURE_VALUE_INT_ARRAY, {NULL} },
869 { "VideoStabilization", CONFIGURE_VALUE_INT_ARRAY, {NULL} },
870 { "FaceZoomMode", CONFIGURE_VALUE_INT_ARRAY, {NULL} },
871 { "FaceZoomLevel", CONFIGURE_VALUE_INT_RANGE, {NULL} },
872 { "PtzType", CONFIGURE_VALUE_INT_ARRAY, {NULL} },
873 { "PanMecha", CONFIGURE_VALUE_INT_RANGE, {NULL} },
874 { "PanElec", CONFIGURE_VALUE_INT_RANGE, {NULL} },
875 { "TiltMecha", CONFIGURE_VALUE_INT_RANGE, {NULL} },
876 { "TiltElec", CONFIGURE_VALUE_INT_RANGE, {NULL} },
879 /* [Capture] matching table */
880 static conf_info_table conf_ctrl_capture_table[] = {
881 { "OutputMode", CONFIGURE_VALUE_INT_ARRAY, {NULL} },
882 { "JpegQuality", CONFIGURE_VALUE_INT_RANGE, {NULL} },
883 { "MultishotNumber", CONFIGURE_VALUE_INT_RANGE, {NULL} },
884 { "SensorEncodedCapture", CONFIGURE_VALUE_INT, {.value_int = 1} },
885 { "SupportHDR", CONFIGURE_VALUE_INT_ARRAY, {NULL} },
886 { "SupportZSL", CONFIGURE_VALUE_INT, {.value_int = FALSE} },
887 { "FrameStabilityCount", CONFIGURE_VALUE_INT, {.value_int = 0} },
890 /* [Detect] matching table */
891 static conf_info_table conf_ctrl_detect_table[] = {
892 { "DetectMode", CONFIGURE_VALUE_INT_ARRAY, {NULL} },
893 { "DetectNumber", CONFIGURE_VALUE_INT_RANGE, {NULL} },
894 { "DetectSelect", CONFIGURE_VALUE_INT_RANGE, {NULL} },
895 { "DetectSelectNumber", CONFIGURE_VALUE_INT_RANGE, {NULL} },
898 MMCAM_LOG_INFO("Entered...");
900 if (type == CONFIGURE_TYPE_MAIN) {
901 hcamcorder->conf_main_info_table[CONFIGURE_CATEGORY_MAIN_GENERAL] = conf_main_general_table;
902 hcamcorder->conf_main_info_table[CONFIGURE_CATEGORY_MAIN_VIDEO_INPUT] = conf_main_video_input_table;
903 hcamcorder->conf_main_info_table[CONFIGURE_CATEGORY_MAIN_AUDIO_INPUT] = conf_main_audio_input_table;
904 hcamcorder->conf_main_info_table[CONFIGURE_CATEGORY_MAIN_VIDEO_OUTPUT] = conf_main_video_output_table;
905 hcamcorder->conf_main_info_table[CONFIGURE_CATEGORY_MAIN_CAPTURE] = conf_main_capture_table;
906 hcamcorder->conf_main_info_table[CONFIGURE_CATEGORY_MAIN_RECORD] = conf_main_record_table;
907 hcamcorder->conf_main_info_table[CONFIGURE_CATEGORY_MAIN_VIDEO_ENCODER] = conf_main_video_encoder_table;
908 hcamcorder->conf_main_info_table[CONFIGURE_CATEGORY_MAIN_AUDIO_ENCODER] = conf_main_audio_encoder_table;
909 hcamcorder->conf_main_info_table[CONFIGURE_CATEGORY_MAIN_IMAGE_ENCODER] = conf_main_image_encoder_table;
910 hcamcorder->conf_main_info_table[CONFIGURE_CATEGORY_MAIN_MUX] = conf_main_mux_table;
912 hcamcorder->conf_main_category_size[CONFIGURE_CATEGORY_MAIN_GENERAL] = sizeof(conf_main_general_table) / info_table_size;
913 hcamcorder->conf_main_category_size[CONFIGURE_CATEGORY_MAIN_VIDEO_INPUT] = sizeof(conf_main_video_input_table) / info_table_size;
914 hcamcorder->conf_main_category_size[CONFIGURE_CATEGORY_MAIN_AUDIO_INPUT] = sizeof(conf_main_audio_input_table) / info_table_size;
915 hcamcorder->conf_main_category_size[CONFIGURE_CATEGORY_MAIN_VIDEO_OUTPUT] = sizeof(conf_main_video_output_table) / info_table_size;
916 hcamcorder->conf_main_category_size[CONFIGURE_CATEGORY_MAIN_CAPTURE] = sizeof(conf_main_capture_table) / info_table_size;
917 hcamcorder->conf_main_category_size[CONFIGURE_CATEGORY_MAIN_RECORD] = sizeof(conf_main_record_table) / info_table_size;
918 hcamcorder->conf_main_category_size[CONFIGURE_CATEGORY_MAIN_VIDEO_ENCODER] = sizeof(conf_main_video_encoder_table) / info_table_size;
919 hcamcorder->conf_main_category_size[CONFIGURE_CATEGORY_MAIN_AUDIO_ENCODER] = sizeof(conf_main_audio_encoder_table) / info_table_size;
920 hcamcorder->conf_main_category_size[CONFIGURE_CATEGORY_MAIN_IMAGE_ENCODER] = sizeof(conf_main_image_encoder_table) / info_table_size;
921 hcamcorder->conf_main_category_size[CONFIGURE_CATEGORY_MAIN_MUX] = sizeof(conf_main_mux_table) / info_table_size;
923 category_num = CONFIGURE_CATEGORY_MAIN_NUM;
925 hcamcorder->conf_ctrl_info_table[CONFIGURE_CATEGORY_CTRL_CAMERA] = conf_ctrl_camera_table;
926 hcamcorder->conf_ctrl_info_table[CONFIGURE_CATEGORY_CTRL_STROBE] = conf_ctrl_strobe_table;
927 hcamcorder->conf_ctrl_info_table[CONFIGURE_CATEGORY_CTRL_EFFECT] = conf_ctrl_effect_table;
928 hcamcorder->conf_ctrl_info_table[CONFIGURE_CATEGORY_CTRL_PHOTOGRAPH] = conf_ctrl_photograph_table;
929 hcamcorder->conf_ctrl_info_table[CONFIGURE_CATEGORY_CTRL_CAPTURE] = conf_ctrl_capture_table;
930 hcamcorder->conf_ctrl_info_table[CONFIGURE_CATEGORY_CTRL_DETECT] = conf_ctrl_detect_table;
932 hcamcorder->conf_ctrl_category_size[CONFIGURE_CATEGORY_CTRL_CAMERA] = sizeof(conf_ctrl_camera_table) / info_table_size;
933 hcamcorder->conf_ctrl_category_size[CONFIGURE_CATEGORY_CTRL_STROBE] = sizeof(conf_ctrl_strobe_table) / info_table_size;
934 hcamcorder->conf_ctrl_category_size[CONFIGURE_CATEGORY_CTRL_EFFECT] = sizeof(conf_ctrl_effect_table) / info_table_size;
935 hcamcorder->conf_ctrl_category_size[CONFIGURE_CATEGORY_CTRL_PHOTOGRAPH] = sizeof(conf_ctrl_photograph_table) / info_table_size;
936 hcamcorder->conf_ctrl_category_size[CONFIGURE_CATEGORY_CTRL_CAPTURE] = sizeof(conf_ctrl_capture_table) / info_table_size;
937 hcamcorder->conf_ctrl_category_size[CONFIGURE_CATEGORY_CTRL_DETECT] = sizeof(conf_ctrl_detect_table) / info_table_size;
939 category_num = CONFIGURE_CATEGORY_CTRL_NUM;
942 configure_info->info = (conf_detail **)g_malloc0(sizeof(conf_detail *) * category_num);
944 MMCAM_LOG_INFO("Done.");
946 return MM_ERROR_NONE;
950 int _mmcamcorder_conf_get_info(MMHandleType handle, int type, const char *ConfFile, camera_conf **configure_info)
952 int ret = MM_ERROR_NONE;
954 char conf_path[MMCAMCORDER_CONF_FILEPATH_LENGTH] = {'\0',};
956 MMCAM_LOG_INFO("Opening...[%s]", ConfFile);
958 mmf_return_val_if_fail(ConfFile, FALSE);
960 snprintf(conf_path, sizeof(conf_path), "%s/multimedia/%s", SYSCONFDIR, ConfFile);
961 MMCAM_LOG_INFO("Try open Configure File[%s]", conf_path);
963 fp = fopen(conf_path, "r");
965 MMCAM_LOG_WARNING("File open failed.[%s] retry...", conf_path);
967 snprintf(conf_path, sizeof(conf_path), "%s/multimedia/%s", TZ_SYS_ETC, ConfFile);
968 MMCAM_LOG_INFO("Try open Configure File[%s]", conf_path);
969 fp = fopen(conf_path, "r");
971 MMCAM_LOG_WARNING("open failed.[%s] errno [%d]", conf_path, errno);
972 return MM_ERROR_CAMCORDER_NOT_SUPPORTED;
976 ret = _mmcamcorder_conf_parse_info(handle, type, fp, configure_info);
980 MMCAM_LOG_INFO("Leave [0x%x]", ret);
986 int _mmcamcorder_conf_parse_info(MMHandleType handle, int type, FILE *fp, camera_conf **configure_info)
988 const unsigned int BUFFER_NUM_DETAILS = 256;
989 const unsigned int BUFFER_NUM_TOKEN = 20;
990 size_t buffer_line_size = MMCAMCORDER_BUFFER_LINE_MAX;
991 const char* delimiters = " |=,\t\r\n";
994 int ret = MM_ERROR_NONE;
996 int count_main_category = 0;
997 int count_details = 0;
1002 char *buffer_string = NULL;
1003 char *buffer_details[BUFFER_NUM_DETAILS];
1004 char *buffer_token[BUFFER_NUM_TOKEN];
1006 char *category_name = NULL;
1007 char *detail_string = NULL;
1008 char *user_ptr = NULL;
1010 camera_conf *new_conf = NULL;
1014 mmf_return_val_if_fail(handle && fp && configure_info, MM_ERROR_INVALID_ARGUMENT);
1016 *configure_info = NULL;
1018 new_conf = (camera_conf *)g_malloc0(sizeof(camera_conf));
1019 buffer_string = (char *)g_malloc0(sizeof(char) * buffer_line_size);
1021 new_conf->type = type;
1023 ret = _mmcamcorder_conf_init(handle, type, new_conf);
1024 if (ret != MM_ERROR_NONE) {
1025 MMCAM_LOG_ERROR("conf init failed 0x%x", ret);
1027 g_free(buffer_string);
1031 *configure_info = new_conf;
1034 count_main_category = 0;
1037 if (read_main == 0) {
1038 buffer_line_size = MMCAMCORDER_BUFFER_LINE_MAX;
1039 length_read = getline(&buffer_string, &buffer_line_size, fp);
1040 if (length_read < 1) {
1041 MMCAM_LOG_DEBUG("skip this case - length read[%d]", length_read);
1045 buffer_string[--length_read] = '\0'; /* remove new line character */
1047 MMCAM_LOG_DEBUG("Read Line : \"%s\"", buffer_string);
1050 token = strtok_r(buffer_string, delimiters, &user_ptr);
1052 if ((token) && (token[0] == ';') && (length_read > -1)) {
1053 MMCAM_LOG_VERBOSE( "Comment - Nothing to do" );
1058 MMCAM_LOG_VERBOSE("token : \"%s\"", token);
1059 buffer_token[count_token] = token;
1061 token = strtok_r(NULL, delimiters, &user_ptr);
1064 if (count_token == 0)
1070 if (*buffer_token[0] == ';') {
1072 MMCAM_LOG_VERBOSE( "Comment - Nothing to do" );
1073 } else if (*buffer_token[0] == '[') {
1075 category_name = get_new_string(buffer_token[0]);
1076 if (category_name == NULL) {
1077 MMCAM_LOG_ERROR("strdup failed for \"%s\"", buffer_token[0]);
1081 count_main_category++;
1085 length_read = getline(&buffer_string, &buffer_line_size, fp);
1086 if (length_read < 1) {
1087 MMCAM_LOG_DEBUG("skip this case - length read[%d]", length_read);
1091 buffer_string[--length_read] = '\0'; /* remove new line character */
1093 MMCAM_LOG_DEBUG("Read Detail Line : \"%s\", length[%d]", buffer_string, length_read);
1095 detail_string = get_new_string(buffer_string);
1097 token = strtok_r(buffer_string, delimiters, &user_ptr);
1099 if (token && token[0] != ';' && length_read > -1) {
1100 MMCAM_LOG_VERBOSE("token : [%s]", token);
1101 if (token[0] == '[') {
1103 buffer_token[0] = token;
1104 SAFE_G_FREE(detail_string);
1108 buffer_details[count_details++] = detail_string;
1110 SAFE_G_FREE(detail_string);
1114 MMCAM_LOG_DEBUG("type : %d, category_name : %s, count : [%d]", type, category_name, count_details);
1116 if (count_details == 0) {
1117 MMCAM_LOG_WARNING("category %s has no detail value... skip this category...", category_name);
1118 SAFE_G_FREE(category_name);
1125 if (type == CONFIGURE_TYPE_MAIN) {
1126 if (!strcmp("[General]", category_name))
1127 category = CONFIGURE_CATEGORY_MAIN_GENERAL;
1128 else if (!strcmp("[VideoInput]", category_name))
1129 category = CONFIGURE_CATEGORY_MAIN_VIDEO_INPUT;
1130 else if (!strcmp("[AudioInput]", category_name))
1131 category = CONFIGURE_CATEGORY_MAIN_AUDIO_INPUT;
1132 else if (!strcmp("[VideoOutput]", category_name))
1133 category = CONFIGURE_CATEGORY_MAIN_VIDEO_OUTPUT;
1134 else if (!strcmp("[Capture]", category_name))
1135 category = CONFIGURE_CATEGORY_MAIN_CAPTURE;
1136 else if (!strcmp("[Record]", category_name))
1137 category = CONFIGURE_CATEGORY_MAIN_RECORD;
1138 else if (!strcmp("[VideoEncoder]", category_name))
1139 category = CONFIGURE_CATEGORY_MAIN_VIDEO_ENCODER;
1140 else if (!strcmp("[AudioEncoder]", category_name))
1141 category = CONFIGURE_CATEGORY_MAIN_AUDIO_ENCODER;
1142 else if (!strcmp("[ImageEncoder]", category_name))
1143 category = CONFIGURE_CATEGORY_MAIN_IMAGE_ENCODER;
1144 else if (!strcmp("[Mux]", category_name))
1145 category = CONFIGURE_CATEGORY_MAIN_MUX;
1147 if (!strcmp("[Camera]", category_name))
1148 category = CONFIGURE_CATEGORY_CTRL_CAMERA;
1149 else if (!strcmp("[Strobe]", category_name))
1150 category = CONFIGURE_CATEGORY_CTRL_STROBE;
1151 else if (!strcmp("[Effect]", category_name))
1152 category = CONFIGURE_CATEGORY_CTRL_EFFECT;
1153 else if (!strcmp("[Photograph]", category_name))
1154 category = CONFIGURE_CATEGORY_CTRL_PHOTOGRAPH;
1155 else if (!strcmp("[Capture]", category_name))
1156 category = CONFIGURE_CATEGORY_CTRL_CAPTURE;
1157 else if (!strcmp("[Detect]", category_name))
1158 category = CONFIGURE_CATEGORY_CTRL_DETECT;
1161 if (category != -1) {
1162 _mmcamcorder_conf_add_info(handle, type, &(new_conf->info[category]),
1163 buffer_details, category, count_details);
1165 MMCAM_LOG_WARNING("No matched category[%s],type[%d]... check it.", category_name, type);
1169 for (i = 0 ; i < count_details ; i++)
1170 SAFE_G_FREE(buffer_details[i]);
1173 SAFE_G_FREE(category_name);
1176 /* (*configure_info) = new_conf; */
1178 SAFE_G_FREE(buffer_string);
1180 /*MMCAM_LOG_INFO("Done.");*/
1182 return MM_ERROR_NONE;
1186 void _mmcamcorder_conf_release_info(MMHandleType handle, camera_conf **configure_info)
1191 int type = CONFIGURE_VALUE_INT;
1193 int category_num = CONFIGURE_CATEGORY_MAIN_NUM;
1194 camera_conf *temp_conf = (*configure_info);
1196 type_int2 *temp_int = NULL;
1197 type_int_range *temp_int_range = NULL;
1198 type_int_array *temp_int_array = NULL;
1199 type_int_pair_array *temp_int_pair_array = NULL;
1200 type_string2 *temp_string = NULL;
1201 type_string_array *temp_string_array = NULL;
1202 type_element2 *temp_element = NULL;
1204 MMCAM_LOG_INFO("Entered...");
1206 mmf_return_if_fail(temp_conf);
1208 if ((*configure_info)->type == CONFIGURE_TYPE_MAIN)
1209 category_num = CONFIGURE_CATEGORY_MAIN_NUM;
1211 category_num = CONFIGURE_CATEGORY_CTRL_NUM;
1213 for (i = 0 ; i < category_num ; i++) {
1214 if (temp_conf->info[i]) {
1215 for (j = 0 ; j < temp_conf->info[i]->count ; j++) {
1216 if (temp_conf->info[i]->detail_info[j] == NULL)
1219 if (_mmcamcorder_conf_get_value_type(handle, temp_conf->type, i, ((type_element*)(temp_conf->info[i]->detail_info[j]))->name, &type)) {
1221 case CONFIGURE_VALUE_INT:
1222 temp_int = (type_int2*)(temp_conf->info[i]->detail_info[j]);
1223 SAFE_G_FREE(temp_int->name);
1225 case CONFIGURE_VALUE_INT_RANGE:
1226 temp_int_range = (type_int_range*)(temp_conf->info[i]->detail_info[j]);
1227 SAFE_G_FREE(temp_int_range->name);
1229 case CONFIGURE_VALUE_INT_ARRAY:
1230 temp_int_array = (type_int_array*)(temp_conf->info[i]->detail_info[j]);
1231 SAFE_G_FREE(temp_int_array->name);
1232 SAFE_G_FREE(temp_int_array->value);
1234 case CONFIGURE_VALUE_INT_PAIR_ARRAY:
1235 temp_int_pair_array = (type_int_pair_array*)(temp_conf->info[i]->detail_info[j]);
1236 SAFE_G_FREE(temp_int_pair_array->name);
1237 SAFE_G_FREE(temp_int_pair_array->value[0]);
1238 SAFE_G_FREE(temp_int_pair_array->value[1]);
1240 case CONFIGURE_VALUE_STRING:
1241 temp_string = (type_string2*)(temp_conf->info[i]->detail_info[j]);
1242 SAFE_G_FREE(temp_string->name);
1243 SAFE_G_FREE(temp_string->value);
1245 case CONFIGURE_VALUE_STRING_ARRAY:
1246 temp_string_array = (type_string_array*)(temp_conf->info[i]->detail_info[j]);
1247 SAFE_G_FREE(temp_string_array->name);
1248 if (temp_string_array->value) {
1249 count = temp_string_array->count;
1251 for (k = 0 ; k < count ; k++)
1252 SAFE_G_FREE(temp_string_array->value[k]);
1254 SAFE_G_FREE(temp_string_array->value);
1256 SAFE_G_FREE(temp_string_array->default_value);
1258 case CONFIGURE_VALUE_ELEMENT:
1259 temp_element = (type_element2*)(temp_conf->info[i]->detail_info[j]);
1260 SAFE_G_FREE(temp_element->name);
1261 SAFE_G_FREE(temp_element->element_name);
1263 if (temp_element->value_int) {
1264 count = temp_element->count_int;
1265 for (k = 0 ; k < count ; k++) {
1266 SAFE_G_FREE(temp_element->value_int[k]->name);
1267 SAFE_G_FREE(temp_element->value_int[k]);
1269 SAFE_G_FREE(temp_element->value_int);
1272 if (temp_element->value_string) {
1273 count = temp_element->count_string;
1274 for (k = 0 ; k < count ; k++) {
1275 SAFE_G_FREE(temp_element->value_string[k]->name);
1276 SAFE_G_FREE(temp_element->value_string[k]->value);
1277 SAFE_G_FREE(temp_element->value_string[k]);
1279 SAFE_G_FREE(temp_element->value_string);
1283 MMCAM_LOG_WARNING("unknown type %d", type);
1288 SAFE_G_FREE(temp_conf->info[i]->detail_info[j]);
1291 SAFE_G_FREE(temp_conf->info[i]->detail_info);
1293 SAFE_G_FREE(temp_conf->info[i]);
1294 temp_conf->info[i] = NULL;
1298 SAFE_G_FREE((*configure_info)->info);
1299 SAFE_G_FREE((*configure_info));
1301 MMCAM_LOG_INFO("Done.");
1304 int _mmcamcorder_conf_get_value_type(MMHandleType handle, int type, int category, const char* name, int* value_type)
1307 int count_value = 0;
1309 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
1311 if (hcamcorder == NULL) {
1312 MMCAM_LOG_ERROR("handle is NULL");
1316 /*MMCAM_LOG_INFO("Entered...");*/
1318 mmf_return_val_if_fail(name, FALSE);
1320 if (!_mmcamcorder_conf_get_category_size(handle, type, category, &count_value)) {
1321 MMCAM_LOG_WARNING("No matched category... check it... categoty[%d]", category);
1325 /*MMCAM_LOG_INFO("Number of value : [%d]", count_value);*/
1327 if (type == CONFIGURE_TYPE_MAIN) {
1328 for (i = 0 ; i < count_value ; i++) {
1329 if (!strcmp(hcamcorder->conf_main_info_table[category][i].name, name)) {
1330 *value_type = hcamcorder->conf_main_info_table[category][i].value_type;
1331 /*MMCAM_LOG_INFO("Category[%d],Name[%s],Type[%d]", category, name, *value_type);*/
1336 for (i = 0 ; i < count_value ; i++) {
1337 if (!strcmp(hcamcorder->conf_ctrl_info_table[category][i].name, name)) {
1338 *value_type = hcamcorder->conf_ctrl_info_table[category][i].value_type;
1339 /*MMCAM_LOG_INFO("Category[%d],Name[%s],Type[%d]", category, name, *value_type);*/
1349 int _mmcamcorder_conf_add_info(MMHandleType handle, int type, conf_detail **info, char **buffer_details, int category, int count_details)
1351 const int BUFFER_NUM_TOKEN = 256;
1358 char *buffer_token[BUFFER_NUM_TOKEN];
1359 char *user_ptr = NULL;
1361 const char *delimiters = " |=,\t\r\n";
1362 const char *delimiters_sub = " |\t\r\n";
1363 const char *delimiters_3rd = "|\r\n";
1365 mmf_return_val_if_fail(info && buffer_details, FALSE);
1367 (*info) = (conf_detail *)g_malloc0(sizeof(conf_detail));
1368 (*info)->detail_info = (void**)g_malloc0(sizeof(void*) * count_details);
1369 (*info)->count = count_details;
1371 for (i = 0 ; i < count_details ; i++) {
1372 MMCAM_LOG_VERBOSE("Read line \"%s\"", buffer_details[i]);
1374 token = strtok_r(buffer_details[i], delimiters, &user_ptr);
1377 buffer_token[count_token] = token;
1380 (*info)->detail_info[i] = NULL;
1381 MMCAM_LOG_WARNING("No token... check it.[%s]", buffer_details[i]);
1385 if (!_mmcamcorder_conf_get_value_type(handle, type, category, buffer_token[0], &value_type)) {
1386 (*info)->detail_info[i] = NULL;
1387 MMCAM_LOG_WARNING("Failed to get value type... check it. Category[%d],Name[%s]", category, buffer_token[0]);
1391 if (value_type != CONFIGURE_VALUE_STRING && value_type != CONFIGURE_VALUE_STRING_ARRAY) {
1392 token = strtok_r(NULL, delimiters, &user_ptr);
1394 buffer_token[count_token] = token;
1395 MMCAM_LOG_VERBOSE("token : [%s]", buffer_token[count_token]);
1397 token = strtok_r(NULL, delimiters, &user_ptr);
1400 if (count_token < 2) {
1401 (*info)->detail_info[i] = NULL;
1402 MMCAM_LOG_WARNING("Number of token is too small... check it.[%s]", buffer_details[i]);
1405 } else { /* CONFIGURE_VALUE_STRING or CONFIGURE_VALUE_STRING_ARRAY */
1407 strtok_r(NULL, delimiters_sub, &user_ptr);
1409 if (value_type == CONFIGURE_VALUE_STRING_ARRAY) {
1410 token = strtok_r(NULL, delimiters_sub, &user_ptr);
1412 buffer_token[count_token] = token;
1413 MMCAM_LOG_VERBOSE("token : [%s]", buffer_token[count_token]);
1415 token = strtok_r(NULL, delimiters_sub, &user_ptr);
1417 } else { /* CONFIGURE_VALUE_STRING */
1418 token = strtok_r(NULL, delimiters_3rd, &user_ptr);
1421 buffer_token[count_token] = token;
1422 MMCAM_LOG_VERBOSE("token : [%s]", buffer_token[count_token]);
1427 if (count_token < 2) {
1428 (*info)->detail_info[i] = NULL;
1429 MMCAM_LOG_WARNING("No string value... check it.[%s]", buffer_details[i]);
1434 switch (value_type) {
1435 case CONFIGURE_VALUE_INT:
1439 new_int = (type_int2*)g_malloc0(sizeof(type_int2));
1440 new_int->name = get_new_string(buffer_token[0]);
1441 new_int->value = atoi(buffer_token[1]);
1442 (*info)->detail_info[i] = (void*)new_int;
1443 MMCAM_LOG_VERBOSE("INT - name[%s],value[%d]", new_int->name, new_int->value);
1446 case CONFIGURE_VALUE_INT_RANGE:
1448 type_int_range* new_int_range;
1450 new_int_range = (type_int_range*)g_malloc0(sizeof(type_int_range));
1451 new_int_range->name = get_new_string(buffer_token[0]);
1452 new_int_range->min = atoi(buffer_token[1]);
1453 new_int_range->max = atoi(buffer_token[2]);
1454 new_int_range->default_value = atoi(buffer_token[3]);
1455 (*info)->detail_info[i] = (void*)new_int_range;
1457 MMCAM_LOG_VERBOSE("INT RANGE - name[%s],min[%d],max[%d],default[%d]",
1458 new_int_range->name,
1461 new_int_range->default_value);
1464 case CONFIGURE_VALUE_INT_ARRAY:
1466 int count_value = count_token - 2;
1467 type_int_array* new_int_array;
1469 new_int_array = (type_int_array*)g_malloc0(sizeof(type_int_array));
1470 new_int_array->name = get_new_string(buffer_token[0]);
1471 new_int_array->value = (int*)g_malloc0(sizeof(int)*count_value);
1472 new_int_array->count = count_value;
1474 MMCAM_LOG_VERBOSE("INT ARRAY - name[%s]", new_int_array->name);
1475 for (j = 0 ; j < count_value ; j++) {
1476 new_int_array->value[j] = atoi(buffer_token[j+1]);
1477 MMCAM_LOG_VERBOSE(" index[%d] - value[%d]", j, new_int_array->value[j]);
1480 new_int_array->default_value = atoi(buffer_token[count_token-1]);
1481 MMCAM_LOG_VERBOSE(" default value[%d]", new_int_array->default_value);
1483 (*info)->detail_info[i] = (void*)new_int_array;
1486 case CONFIGURE_VALUE_INT_PAIR_ARRAY:
1488 int count_value = (count_token - 3) >> 1;
1489 type_int_pair_array* new_int_pair_array;
1491 new_int_pair_array = (type_int_pair_array*)g_malloc0(sizeof(type_int_pair_array));
1492 new_int_pair_array->name = get_new_string(buffer_token[0]);
1493 new_int_pair_array->value[0] = (int*)g_malloc0(sizeof(int)*(count_value));
1494 new_int_pair_array->value[1] = (int*)g_malloc0(sizeof(int)*(count_value));
1495 new_int_pair_array->count = count_value;
1497 MMCAM_LOG_VERBOSE("INT PAIR ARRAY - name[%s],count[%d]", new_int_pair_array->name, count_value);
1498 for (j = 0 ; j < count_value ; j++) {
1499 new_int_pair_array->value[0][j] = atoi(buffer_token[(j<<1)+1]);
1500 new_int_pair_array->value[1][j] = atoi(buffer_token[(j<<1)+2]);
1502 MMCAM_LOG_VERBOSE(" index[%d] - value[%d,%d]", j,
1503 new_int_pair_array->value[0][j],
1504 new_int_pair_array->value[1][j]);
1507 new_int_pair_array->default_value[0] = atoi(buffer_token[count_token-2]);
1508 new_int_pair_array->default_value[1] = atoi(buffer_token[count_token-1]);
1510 MMCAM_LOG_VERBOSE(" default value[%d,%d]",
1511 new_int_pair_array->default_value[0],
1512 new_int_pair_array->default_value[1]);
1514 (*info)->detail_info[i] = (void*)new_int_pair_array;
1517 case CONFIGURE_VALUE_STRING:
1519 type_string2* new_string;
1521 new_string = (type_string2*)g_malloc0(sizeof(type_string2));
1522 new_string->name = get_new_string(buffer_token[0]);
1523 new_string->value = get_new_string(buffer_token[1]);
1524 (*info)->detail_info[i] = (void*)new_string;
1526 MMCAM_LOG_VERBOSE("STRING - name[%s],value[%s]", new_string->name, new_string->value);
1529 case CONFIGURE_VALUE_STRING_ARRAY:
1531 int count_value = count_token - 2;
1532 type_string_array* new_string_array;
1534 new_string_array = (type_string_array*)g_malloc0(sizeof(type_string_array));
1535 new_string_array->name = get_new_string(buffer_token[0]);
1536 new_string_array->count = count_value;
1537 new_string_array->value = (char**)g_malloc0(sizeof(char*)*count_value);
1539 MMCAM_LOG_VERBOSE("STRING ARRAY - name[%s]", new_string_array->name);
1541 for (j = 0 ; j < count_value ; j++) {
1542 new_string_array->value[j] = get_new_string(buffer_token[j+1]);
1543 MMCAM_LOG_VERBOSE(" index[%d] - value[%s]", j, new_string_array->value[j]);
1546 new_string_array->default_value = get_new_string(buffer_token[count_token-1]);
1548 MMCAM_LOG_VERBOSE(" default value[%s]", new_string_array->default_value);
1550 (*info)->detail_info[i] = (void*)new_string_array;
1553 case CONFIGURE_VALUE_ELEMENT:
1555 type_element2* new_element;
1557 new_element = (type_element2*)g_malloc0(sizeof(type_element2));
1558 new_element->name = get_new_string(buffer_token[0]);
1559 new_element->element_name = get_new_string(buffer_token[1]);
1560 new_element->count_int = atoi(buffer_token[2]);
1561 new_element->value_int = NULL;
1562 new_element->count_string = atoi(buffer_token[3]);
1563 new_element->value_string = NULL;
1565 MMCAM_LOG_VERBOSE("Element - name[%s],element_name[%s],count_int[%d],count_string[%d]",
1566 new_element->name, new_element->element_name, new_element->count_int, new_element->count_string);
1568 /* add int values */
1569 if (new_element->count_int > 0 && new_element->count_int <= 30) {
1570 new_element->value_int = (type_int2**)g_malloc0(sizeof(type_int2*)*(new_element->count_int));
1571 for (j = 0 ; j < new_element->count_int ; j++) {
1572 new_element->value_int[j] = (type_int2*)g_malloc0(sizeof(type_int2));
1573 new_element->value_int[j]->name = get_new_string(buffer_token[4+(j<<1)]);
1574 new_element->value_int[j]->value = atoi(buffer_token[5+(j<<1)]);
1576 MMCAM_LOG_VERBOSE(" Element INT[%d] - name[%s],value[%d]",
1577 j, new_element->value_int[j]->name, new_element->value_int[j]->value);
1581 /* add string values */
1582 if (new_element->count_string > 0 && new_element->count_string <= 30 &&
1583 new_element->count_int >= 0 && new_element->count_int <= 30) {
1584 new_element->value_string = (type_string2**)g_malloc0(sizeof(type_string2*)*(new_element->count_string));
1585 for ( ; j < new_element->count_string + new_element->count_int ; j++) {
1586 new_element->value_string[j-new_element->count_int] = (type_string2*)g_malloc0(sizeof(type_string2));
1587 new_element->value_string[j-new_element->count_int]->name = get_new_string(buffer_token[4+(j<<1)]);
1588 new_element->value_string[j-new_element->count_int]->value = get_new_string(buffer_token[5+(j<<1)]);
1590 MMCAM_LOG_VERBOSE(" Element STRING[%d] - name[%s],value[%s]",
1591 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);
1595 (*info)->detail_info[i] = (void*)new_element;
1607 int _mmcamcorder_conf_get_value_int(MMHandleType handle, camera_conf* configure_info, int category, const char* name, int* value)
1612 MMCAM_LOG_VERBOSE("category[%d], name[%s]", category, name);
1614 mmf_return_val_if_fail(configure_info, FALSE);
1615 mmf_return_val_if_fail(name, FALSE);
1617 if (configure_info->info[category]) {
1618 count = configure_info->info[category]->count;
1619 info = configure_info->info[category];
1621 for (i = 0 ; i < count ; i++) {
1622 if (info->detail_info[i] == NULL)
1625 if (!strcmp(((type_int*)(info->detail_info[i]))->name , name)) {
1626 *value = ((type_int*)(info->detail_info[i]))->value;
1627 MMCAM_LOG_DEBUG("Get[%s] int[%d]", name, *value);
1633 if (_mmcamcorder_conf_get_default_value_int(handle, configure_info->type, category, name, value)) {
1634 MMCAM_LOG_DEBUG("Get default [%s] int[%d]", name, *value);
1638 MMCAM_LOG_DEBUG("Failed to get [%s]", name);
1644 _mmcamcorder_conf_get_value_int_range(camera_conf* configure_info, int category, const char* name, type_int_range** value)
1649 MMCAM_LOG_VERBOSE("category[%d], name[%s]", category, name);
1651 mmf_return_val_if_fail(configure_info, FALSE);
1652 mmf_return_val_if_fail(name, FALSE);
1654 if (configure_info->info[category]) {
1655 count = configure_info->info[category]->count;
1656 info = configure_info->info[category];
1658 for (i = 0 ; i < count ; i++) {
1659 if (info->detail_info[i] == NULL)
1662 if (!strcmp(((type_int_range*)(info->detail_info[i]))->name , name)) {
1663 *value = (type_int_range*)(info->detail_info[i]);
1664 MMCAM_LOG_DEBUG("Get[%s] int range - min[%d],max[%d],default[%d]",
1665 name, (*value)->min, (*value)->max, (*value)->default_value);
1673 MMCAM_LOG_DEBUG("Failed to get [%s]", name);
1678 int _mmcamcorder_conf_get_value_int_array(camera_conf* configure_info, int category, const char* name, type_int_array** value)
1683 MMCAM_LOG_VERBOSE("category[%d], name[%s]", category, name);
1685 mmf_return_val_if_fail(configure_info, FALSE);
1686 mmf_return_val_if_fail(name, FALSE);
1688 if (configure_info->info[category]) {
1689 count = configure_info->info[category]->count;
1690 info = configure_info->info[category];
1692 for (i = 0 ; i < count ; i++) {
1693 if (info->detail_info[i] == NULL)
1696 if (!strcmp(((type_int_array*)(info->detail_info[i]))->name , name)) {
1697 *value = (type_int_array*)(info->detail_info[i]);
1698 MMCAM_LOG_DEBUG("Get[%s] int array - [%p],count[%d],default[%d]",
1699 name, (*value)->value, (*value)->count, (*value)->default_value);
1707 MMCAM_LOG_DEBUG("Failed to get [%s]", name);
1713 _mmcamcorder_conf_get_value_int_pair_array(camera_conf* configure_info, int category, const char* name, type_int_pair_array** value)
1718 MMCAM_LOG_VERBOSE("category[%d], name[%s]", category, name);
1720 mmf_return_val_if_fail(configure_info, FALSE);
1721 mmf_return_val_if_fail(name, FALSE);
1723 if (configure_info->info[category]) {
1724 count = configure_info->info[category]->count;
1725 info = configure_info->info[category];
1727 for (i = 0 ; i < count ; i++) {
1728 if (info->detail_info[i] == NULL)
1731 if (!strcmp(((type_int_pair_array*)(info->detail_info[i]))->name , name)) {
1732 *value = (type_int_pair_array*)(info->detail_info[i]);
1733 MMCAM_LOG_DEBUG("Get[%s] int pair array - [%p][%p],count[%d],default[%d][%d]",
1734 name, (*value)->value[0], (*value)->value[1], (*value)->count,
1735 (*value)->default_value[0], (*value)->default_value[1]);
1743 MMCAM_LOG_DEBUG("Failed to get [%s]", name);
1748 int _mmcamcorder_conf_get_value_string(MMHandleType handle, camera_conf* configure_info, int category, const char* name, const char** value)
1753 MMCAM_LOG_VERBOSE("category[%d], name[%s]", category, name);
1755 mmf_return_val_if_fail(configure_info, FALSE);
1756 mmf_return_val_if_fail(name, FALSE);
1758 if (configure_info->info[category]) {
1759 count = configure_info->info[category]->count;
1760 info = configure_info->info[category];
1762 for (i = 0 ; i < count ; i++) {
1763 if (info->detail_info[i] == NULL)
1766 if (!strcmp(((type_string*)(info->detail_info[i]))->name , name)) {
1767 *value = ((type_string*)(info->detail_info[i]))->value;
1768 MMCAM_LOG_DEBUG("Get[%s] string[%s]", name, *value ? *value : "NULL");
1774 if (_mmcamcorder_conf_get_default_value_string(handle, configure_info->type, category, name, value)) {
1775 MMCAM_LOG_DEBUG("Get default [%s] string[%s]", name, *value ? *value : "NULL");
1779 MMCAM_LOG_DEBUG("Failed to get [%s]", name);
1784 int _mmcamcorder_conf_get_value_string_array(camera_conf* configure_info, int category, const char* name, type_string_array** value)
1789 MMCAM_LOG_VERBOSE("category[%d], name[%s]", category, name);
1791 mmf_return_val_if_fail(configure_info, FALSE);
1792 mmf_return_val_if_fail(name, FALSE);
1794 if (configure_info->info[category]) {
1795 count = configure_info->info[category]->count;
1796 info = configure_info->info[category];
1798 for (i = 0 ; i < count ; i++) {
1799 if (info->detail_info[i] == NULL)
1802 if (!strcmp(((type_string_array*)(info->detail_info[i]))->name , name)) {
1803 *value = (type_string_array*)(info->detail_info[i]);
1804 MMCAM_LOG_DEBUG("Get[%s] string array - [%p],count[%d],default[%s]",
1805 name, (*value)->value, (*value)->count, (*value)->default_value);
1813 MMCAM_LOG_DEBUG("Failed to get [%s]", name);
1818 int _mmcamcorder_conf_get_element(MMHandleType handle, camera_conf* configure_info, int category, const char* name, type_element** element)
1823 MMCAM_LOG_VERBOSE("category[%d], name[%s]", category, name);
1825 mmf_return_val_if_fail(configure_info, FALSE);
1826 mmf_return_val_if_fail(name, FALSE);
1828 if (configure_info->info[category]) {
1829 count = configure_info->info[category]->count;
1830 info = configure_info->info[category];
1832 for (i = 0 ; i < count ; i++) {
1833 if (info->detail_info[i] == NULL)
1836 if (!strcmp(((type_element*)(info->detail_info[i]))->name , name)) {
1837 *element = (type_element*)(info->detail_info[i]);
1838 MMCAM_LOG_DEBUG("Get[%s] element[%p]", name, *element);
1844 if (_mmcamcorder_conf_get_default_element(handle, configure_info->type, category, name, element)) {
1845 MMCAM_LOG_DEBUG("Get default [%s] element[%p]", name, *element);
1849 MMCAM_LOG_ERROR("Failed to get [%s]", name);
1854 int _mmcamcorder_conf_get_value_element_name(type_element* element, const char** value)
1856 mmf_return_val_if_fail(element, FALSE);
1858 *value = element->element_name;
1860 MMCAM_LOG_DEBUG("Get element name : [%s]", *value);
1865 int _mmcamcorder_conf_get_value_element_int(type_element* element, const char* name, int* value)
1869 mmf_return_val_if_fail(element, FALSE);
1870 mmf_return_val_if_fail(name, FALSE);
1872 for (i = 0 ; i < element->count_int ; i++) {
1873 if (!strcmp(element->value_int[i]->name, name)) {
1874 *value = element->value_int[i]->value;
1875 MMCAM_LOG_DEBUG("Get[%s] element int[%d]", name, *value);
1880 MMCAM_LOG_ERROR("Failed to get int in element. Element[%s],Name[%s],Count[%d]",
1881 element->name, name, element->count_int);
1886 int _mmcamcorder_conf_get_value_element_string(type_element* element, const char* name, const char** value)
1890 mmf_return_val_if_fail(element, FALSE);
1891 mmf_return_val_if_fail(name, FALSE);
1893 for (i = 0 ; i < element->count_string ; i++) {
1894 if (!strcmp(element->value_string[i]->name, name)) {
1895 *value = element->value_string[i]->value;
1896 MMCAM_LOG_DEBUG("Get[%s] element string[%s]", name, *value);
1901 MMCAM_LOG_ERROR("Failed to get int in element. Element[%s],Name[%s],Count[%d]",
1902 element->name, name, element->count_string);
1907 int _mmcamcorder_conf_set_value_element_property(GstElement* gst, type_element* element)
1911 mmf_return_val_if_fail(gst, FALSE);
1912 mmf_return_val_if_fail(element, FALSE);
1914 if (element->count_int == 0) {
1915 MMCAM_LOG_DEBUG("There is no integer property to set in INI file[%s].", element->name );
1917 if (element->value_int == NULL) {
1918 MMCAM_LOG_WARNING("count_int[%d] is NOT zero, but value_int is NULL", element->count_int);
1922 for (i = 0 ; i < element->count_int ; i++) {
1923 MMCAMCORDER_G_OBJECT_SET(gst, element->value_int[i]->name, element->value_int[i]->value);
1925 MMCAM_LOG_DEBUG("Element[%s] Set[%s] -> [i:%d]",
1926 element->element_name,
1927 element->value_int[i]->name,
1928 element->value_int[i]->value);
1932 if (element->count_string == 0) {
1933 MMCAM_LOG_DEBUG("There is no string property to set in INI file[%s].", element->name);
1935 if (element->value_string == NULL) {
1936 MMCAM_LOG_WARNING("count_string[%d] is NOT zero, but value_string is NULL", element->count_string);
1940 for (i = 0 ; i < element->count_string ; i++) {
1941 MMCAMCORDER_G_OBJECT_SET_POINTER(gst, element->value_string[i]->name, element->value_string[i]->value);
1943 MMCAM_LOG_DEBUG("Element[%s] Set[%s] -> [s:%s]",
1944 element->element_name,
1945 element->value_string[i]->name,
1946 element->value_string[i]->value);
1953 int _mmcamcorder_conf_get_default_value_int(MMHandleType handle, int type, int category, const char* name, int* value)
1956 int count_value = 0;
1958 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
1960 if (hcamcorder == NULL) {
1961 MMCAM_LOG_ERROR("handle is NULL");
1965 mmf_return_val_if_fail(name, FALSE);
1967 if (!_mmcamcorder_conf_get_category_size(handle, type, category, &count_value)) {
1968 MMCAM_LOG_WARNING("No matched category. categoty[%d]", category);
1972 if (type == CONFIGURE_TYPE_MAIN) {
1973 for (i = 0 ; i < count_value ; i++) {
1974 if (!strcmp(hcamcorder->conf_main_info_table[category][i].name, name)) {
1975 *value = hcamcorder->conf_main_info_table[category][i].value_int;
1980 for (i = 0 ; i < count_value ; i++) {
1981 if (!strcmp(hcamcorder->conf_ctrl_info_table[category][i].name, name)) {
1982 *value = hcamcorder->conf_ctrl_info_table[category][i].value_int;
1988 MMCAM_LOG_ERROR("Failed to get default int. Type[%d],Category[%d],Name[%s]", type, category, name);
1993 int _mmcamcorder_conf_get_default_value_string(MMHandleType handle, int type, int category, const char* name, const char** value)
1996 int count_value = 0;
1998 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2000 if (hcamcorder == NULL) {
2001 MMCAM_LOG_ERROR("handle is NULL");
2005 mmf_return_val_if_fail(name, FALSE);
2007 if (!_mmcamcorder_conf_get_category_size(handle, type, category, &count_value)) {
2008 MMCAM_LOG_WARNING("No matched category... check it... categoty[%d]", category);
2012 if (type == CONFIGURE_TYPE_MAIN) {
2013 for (i = 0 ; i < count_value ; i++) {
2014 if (!strcmp(hcamcorder->conf_main_info_table[category][i].name, name)) {
2015 *value = hcamcorder->conf_main_info_table[category][i].value_string;
2020 for (i = 0 ; i < count_value ; i++) {
2021 if (!strcmp(hcamcorder->conf_ctrl_info_table[category][i].name, name)) {
2022 *value = hcamcorder->conf_ctrl_info_table[category][i].value_string;
2028 MMCAM_LOG_ERROR("Failed to get default string. Type[%d],Category[%d],Name[%s]", type, category, name);
2033 int _mmcamcorder_conf_get_default_element(MMHandleType handle, int type, int category, const char* name, type_element** element)
2036 int count_value = 0;
2038 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2040 if (hcamcorder == NULL) {
2041 MMCAM_LOG_ERROR("handle is NULL");
2045 mmf_return_val_if_fail(name, FALSE);
2047 if (!_mmcamcorder_conf_get_category_size(handle, type, category, &count_value)) {
2048 MMCAM_LOG_WARNING("No matched category... check it... categoty[%d]", category);
2052 if (type == CONFIGURE_TYPE_MAIN) {
2053 for (i = 0 ; i < count_value ; i++) {
2054 if (!strcmp(hcamcorder->conf_main_info_table[category][i].name, name)) {
2055 *element = hcamcorder->conf_main_info_table[category][i].value_element;
2060 for (i = 0 ; i < count_value ; i++) {
2061 if (!strcmp(hcamcorder->conf_ctrl_info_table[category][i].name, name)) {
2062 *element = hcamcorder->conf_ctrl_info_table[category][i].value_element;
2068 MMCAM_LOG_ERROR("Failed to get default element. Type[%d],Category[%d],Name[%s]", type, category, name);
2073 int _mmcamcorder_conf_get_category_size(MMHandleType handle, int type, int category, int* size)
2075 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2077 if (hcamcorder == NULL) {
2078 MMCAM_LOG_ERROR("handle is NULL");
2082 if (type == CONFIGURE_TYPE_MAIN) {
2083 mmf_return_val_if_fail(category < CONFIGURE_CATEGORY_MAIN_NUM, FALSE);
2084 *size = (int)hcamcorder->conf_main_category_size[category];
2086 mmf_return_val_if_fail(category < CONFIGURE_CATEGORY_CTRL_NUM, FALSE);
2087 *size = (int)hcamcorder->conf_ctrl_category_size[category];
2093 void _mmcamcorder_conf_get_element_and_name(MMHandleType handle, int category, const char *name, type_element **element, const char **element_name)
2095 type_element *_element = NULL;
2096 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2099 MMCAM_LOG_ERROR("NULL handle");
2103 _mmcamcorder_conf_get_element(handle, hcamcorder->conf_main,
2104 category, name, &_element);
2107 *element = _element;
2110 _mmcamcorder_conf_get_value_element_name(_element, element_name);
2111 MMCAM_LOG_INFO("[%s] -> [%s]", name, *element_name);
2115 void _mmcamcorder_conf_print_info(MMHandleType handle, camera_conf** configure_info)
2117 int i, j, k, type, category_type;
2120 type_int_range *temp_int_range;
2121 type_int_array *temp_int_array;
2122 type_int_pair_array *temp_int_pair_array;
2123 type_string *temp_string;
2124 type_element *temp_element;
2126 g_print("[ConfigureInfoPrint] : Entered.\n");
2128 mmf_return_if_fail(*configure_info);
2130 if ((*configure_info)->type == CONFIGURE_TYPE_MAIN)
2131 category_type = CONFIGURE_CATEGORY_MAIN_NUM;
2133 category_type = CONFIGURE_CATEGORY_CTRL_NUM;
2135 for (i = 0 ; i < category_type ; i++) {
2137 if ((*configure_info)->info[i]) {
2138 g_print("[ConfigureInfo] : Category [%d]\n", i);
2140 for (j = 0 ; j < (*configure_info)->info[i]->count ; j++) {
2142 if (_mmcamcorder_conf_get_value_type(handle, (*configure_info)->type, i, ((type_int*)((*configure_info)->info[i]->detail_info[j]))->name, &type)) {
2144 case CONFIGURE_VALUE_INT:
2145 temp_int = (type_int*)((*configure_info)->info[i]->detail_info[j]);
2146 g_print("[ConfigureInfo] : INT - Name[%s],Value [%d]\n", temp_int->name, temp_int->value);
2148 case CONFIGURE_VALUE_INT_RANGE:
2149 temp_int_range = (type_int_range*)((*configure_info)->info[i]->detail_info[j]);
2150 g_print("[ConfigureInfo] : INT_RANGE - Name[%s],Value [%d]~[%d], default [%d]\n",
2151 temp_int_range->name, temp_int_range->min, temp_int_range->max, temp_int_range->default_value);
2153 case CONFIGURE_VALUE_INT_ARRAY:
2154 temp_int_array = (type_int_array*)((*configure_info)->info[i]->detail_info[j]);
2155 g_print("[ConfigureInfo] : INT_ARRAY - Name[%s], default [%d]\n - ",
2156 temp_int_array->name, temp_int_array->default_value);
2158 for (k = 0 ; k < temp_int_array->count ; k++)
2159 g_print("[%d] ", temp_int_array->value[k]);
2163 case CONFIGURE_VALUE_INT_PAIR_ARRAY:
2164 temp_int_pair_array = (type_int_pair_array*)((*configure_info)->info[i]->detail_info[j]);
2165 g_print("[ConfigureInfo] : INT_PAIR_ARRAY - Name[%s], default [%d][%d]\n - ",
2166 temp_int_pair_array->name, temp_int_pair_array->default_value[0], temp_int_pair_array->default_value[0]);
2168 for (k = 0 ; k < temp_int_pair_array->count ; k++)
2169 g_print("[%d,%d] ", temp_int_pair_array->value[0][k], temp_int_pair_array->value[1][k]);
2173 case CONFIGURE_VALUE_STRING:
2174 temp_string = (type_string*)((*configure_info)->info[i]->detail_info[j]);
2175 g_print("[ConfigureInfo] : STRING - Name[%s],Value[%s]\n", temp_string->name, temp_string->value);
2177 case CONFIGURE_VALUE_ELEMENT:
2178 temp_element = (type_element*)((*configure_info)->info[i]->detail_info[j]);
2179 g_print("[ConfigureInfo] : Element - Name[%s],Element_Name[%s]\n", temp_element->name, temp_element->element_name);
2181 for (k = 0 ; k < temp_element->count_int ; k++)
2182 g_print(" - INT[%d] Name[%s],Value[%d]\n", k, temp_element->value_int[k]->name, temp_element->value_int[k]->value);
2184 for (k = 0 ; k < temp_element->count_string ; k++)
2185 g_print(" - STRING[%d] Name[%s],Value[%s]\n", k, temp_element->value_string[k]->name, temp_element->value_string[k]->value);
2189 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);
2193 g_print("[ConfigureInfo] : Failed to get value type.");
2199 g_print("[ConfigureInfoPrint] : Done.\n");
2203 static type_element *__mmcamcorder_get_audio_codec_element(MMHandleType handle)
2205 type_element *telement = NULL;
2206 const char *codec_type_str = NULL;
2207 int codec_type = MM_AUDIO_CODEC_INVALID;
2208 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2209 _MMCamcorderSubContext *sc = NULL;
2211 mmf_return_val_if_fail(hcamcorder, NULL);
2212 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2214 mmf_return_val_if_fail(sc, NULL);
2218 /* Check element availability */
2219 mm_camcorder_get_attributes(handle, NULL, MMCAM_AUDIO_ENCODER, &codec_type, NULL);
2221 switch (codec_type) {
2222 case MM_AUDIO_CODEC_AMR:
2223 codec_type_str = "AMR";
2225 case MM_AUDIO_CODEC_G723_1:
2226 codec_type_str = "G723_1";
2228 case MM_AUDIO_CODEC_MP3:
2229 codec_type_str = "MP3";
2231 case MM_AUDIO_CODEC_AAC:
2232 codec_type_str = "AAC";
2234 case MM_AUDIO_CODEC_MMF:
2235 codec_type_str = "MMF";
2237 case MM_AUDIO_CODEC_ADPCM:
2238 codec_type_str = "ADPCM";
2240 case MM_AUDIO_CODEC_WAVE:
2241 codec_type_str = "WAVE";
2243 case MM_AUDIO_CODEC_MIDI:
2244 codec_type_str = "MIDI";
2246 case MM_AUDIO_CODEC_IMELODY:
2247 codec_type_str = "IMELODY";
2249 case MM_AUDIO_CODEC_VORBIS:
2250 codec_type_str = "VORBIS";
2253 MMCAM_LOG_ERROR("Not supported audio codec[%d]", codec_type);
2257 _mmcamcorder_conf_get_element(handle, hcamcorder->conf_main,
2258 CONFIGURE_CATEGORY_MAIN_AUDIO_ENCODER,
2266 static type_element *__mmcamcorder_get_video_codec_element(MMHandleType handle)
2268 type_element *telement = NULL;
2269 const char *codec_type_str = NULL;
2270 int codec_type = MM_VIDEO_CODEC_INVALID;
2271 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2272 _MMCamcorderSubContext *sc = NULL;
2274 mmf_return_val_if_fail(hcamcorder, NULL);
2275 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2277 mmf_return_val_if_fail(sc, NULL);
2279 /* Check element availability */
2280 mm_camcorder_get_attributes(handle, NULL, MMCAM_VIDEO_ENCODER, &codec_type, NULL);
2282 switch (codec_type) {
2283 case MM_VIDEO_CODEC_H263:
2284 codec_type_str = "H263";
2286 case MM_VIDEO_CODEC_H264:
2287 codec_type_str = "H264";
2289 case MM_VIDEO_CODEC_H26L:
2290 codec_type_str = "H26L";
2292 case MM_VIDEO_CODEC_MPEG4:
2293 codec_type_str = "MPEG4";
2295 case MM_VIDEO_CODEC_MPEG1:
2296 codec_type_str = "MPEG1";
2298 case MM_VIDEO_CODEC_THEORA:
2299 codec_type_str = "THEORA";
2302 MMCAM_LOG_ERROR("Not supported video codec[%d]", codec_type);
2306 _mmcamcorder_conf_get_element(handle, hcamcorder->conf_main,
2307 CONFIGURE_CATEGORY_MAIN_VIDEO_ENCODER,
2315 static type_element *__mmcamcorder_get_image_codec_element(MMHandleType handle)
2317 type_element *telement = NULL;
2318 const char *codec_type_str = NULL;
2319 int codec_type = MM_IMAGE_CODEC_INVALID;
2320 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2321 _MMCamcorderSubContext *sc = NULL;
2323 mmf_return_val_if_fail(hcamcorder, NULL);
2324 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2326 mmf_return_val_if_fail(sc, NULL);
2328 /* Check element availability */
2329 mm_camcorder_get_attributes(handle, NULL, MMCAM_IMAGE_ENCODER, &codec_type, NULL);
2331 switch (codec_type) {
2332 case MM_IMAGE_CODEC_JPEG:
2333 codec_type_str = "JPEG";
2335 case MM_IMAGE_CODEC_SRW:
2336 codec_type_str = "SRW";
2338 case MM_IMAGE_CODEC_JPEG_SRW:
2339 codec_type_str = "JPEG_SRW";
2341 case MM_IMAGE_CODEC_PNG:
2342 codec_type_str = "PNG";
2344 case MM_IMAGE_CODEC_BMP:
2345 codec_type_str = "BMP";
2347 case MM_IMAGE_CODEC_WBMP:
2348 codec_type_str = "WBMP";
2350 case MM_IMAGE_CODEC_TIFF:
2351 codec_type_str = "TIFF";
2353 case MM_IMAGE_CODEC_PCX:
2354 codec_type_str = "PCX";
2356 case MM_IMAGE_CODEC_GIF:
2357 codec_type_str = "GIF";
2359 case MM_IMAGE_CODEC_ICO:
2360 codec_type_str = "ICO";
2362 case MM_IMAGE_CODEC_RAS:
2363 codec_type_str = "RAS";
2365 case MM_IMAGE_CODEC_TGA:
2366 codec_type_str = "TGA";
2368 case MM_IMAGE_CODEC_XBM:
2369 codec_type_str = "XBM";
2371 case MM_IMAGE_CODEC_XPM:
2372 codec_type_str = "XPM";
2375 MMCAM_LOG_ERROR("Not supported image codec[%d]", codec_type);
2379 _mmcamcorder_conf_get_element(handle, hcamcorder->conf_main,
2380 CONFIGURE_CATEGORY_MAIN_IMAGE_ENCODER,
2388 static type_element *__mmcamcorder_get_file_format_element(MMHandleType handle)
2390 type_element *telement = NULL;
2391 const char *mux_type_str = NULL;
2392 int file_type = MM_FILE_FORMAT_INVALID;
2393 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2394 _MMCamcorderSubContext *sc = NULL;
2396 mmf_return_val_if_fail(hcamcorder, NULL);
2397 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2399 mmf_return_val_if_fail(sc, NULL);
2401 /* Check element availability */
2402 mm_camcorder_get_attributes(handle, NULL, MMCAM_FILE_FORMAT, &file_type, NULL);
2404 switch (file_type) {
2405 case MM_FILE_FORMAT_3GP:
2406 mux_type_str = "3GP";
2408 case MM_FILE_FORMAT_AMR:
2409 mux_type_str = "AMR";
2411 case MM_FILE_FORMAT_MP4:
2412 mux_type_str = "MP4";
2414 case MM_FILE_FORMAT_AAC:
2415 mux_type_str = "AAC";
2417 case MM_FILE_FORMAT_MP3:
2418 mux_type_str = "MP3";
2420 case MM_FILE_FORMAT_OGG:
2421 mux_type_str = "OGG";
2423 case MM_FILE_FORMAT_WAV:
2424 mux_type_str = "WAV";
2426 case MM_FILE_FORMAT_AVI:
2427 mux_type_str = "AVI";
2429 case MM_FILE_FORMAT_WMA:
2430 mux_type_str = "WMA";
2432 case MM_FILE_FORMAT_WMV:
2433 mux_type_str = "WMV";
2435 case MM_FILE_FORMAT_MID:
2436 mux_type_str = "MID";
2438 case MM_FILE_FORMAT_MMF:
2439 mux_type_str = "MMF";
2441 case MM_FILE_FORMAT_MATROSKA:
2442 mux_type_str = "MATROSKA";
2444 case MM_FILE_FORMAT_M2TS:
2445 mux_type_str = "M2TS";
2448 MMCAM_LOG_ERROR("Not supported file format[%d]", file_type);
2452 _mmcamcorder_conf_get_element(handle, hcamcorder->conf_main,
2453 CONFIGURE_CATEGORY_MAIN_MUX,
2461 type_element *_mmcamcorder_get_type_element(MMHandleType handle, int type)
2463 type_element *telement = NULL;
2466 case MM_CAM_AUDIO_ENCODER:
2467 telement = __mmcamcorder_get_audio_codec_element(handle);
2469 case MM_CAM_VIDEO_ENCODER:
2470 telement = __mmcamcorder_get_video_codec_element(handle);
2472 case MM_CAM_IMAGE_ENCODER:
2473 telement = __mmcamcorder_get_image_codec_element(handle);
2475 case MM_CAM_FILE_FORMAT:
2476 telement = __mmcamcorder_get_file_format_element(handle);
2479 MMCAM_LOG_INFO("Can't get element type form this profile.(%d)", type);
2486 int _mmcamcorder_get_audio_codec_format(MMHandleType handle, const char *name)
2488 int codec_index = MM_AUDIO_CODEC_INVALID;
2491 MMCAM_LOG_ERROR("name is NULL");
2492 return MM_AUDIO_CODEC_INVALID;
2495 if (!strcmp(name, "AMR"))
2496 codec_index = MM_AUDIO_CODEC_AMR;
2497 else if (!strcmp(name, "G723_1"))
2498 codec_index = MM_AUDIO_CODEC_G723_1;
2499 else if (!strcmp(name, "MP3"))
2500 codec_index = MM_AUDIO_CODEC_MP3;
2501 else if (!strcmp(name, "AAC"))
2502 codec_index = MM_AUDIO_CODEC_AAC;
2503 else if (!strcmp(name, "MMF"))
2504 codec_index = MM_AUDIO_CODEC_MMF;
2505 else if (!strcmp(name, "ADPCM"))
2506 codec_index = MM_AUDIO_CODEC_ADPCM;
2507 else if (!strcmp(name, "WAVE"))
2508 codec_index = MM_AUDIO_CODEC_WAVE;
2509 else if (!strcmp(name, "MIDI"))
2510 codec_index = MM_AUDIO_CODEC_MIDI;
2511 else if (!strcmp(name, "IMELODY"))
2512 codec_index = MM_AUDIO_CODEC_IMELODY;
2513 else if (!strcmp(name, "VORBIS"))
2514 codec_index = MM_AUDIO_CODEC_VORBIS;
2516 MMCAM_LOG_DEBUG("audio codec index %d", codec_index);
2523 int _mmcamcorder_get_video_codec_format(MMHandleType handle, const char *name)
2525 int codec_index = MM_VIDEO_CODEC_INVALID;
2528 MMCAM_LOG_ERROR("name is NULL");
2529 return MM_VIDEO_CODEC_INVALID;
2532 if (!strcmp(name, "H263"))
2533 codec_index = MM_VIDEO_CODEC_H263;
2534 else if (!strcmp(name, "H264"))
2535 codec_index = MM_VIDEO_CODEC_H264;
2536 else if (!strcmp(name, "H26L"))
2537 codec_index = MM_VIDEO_CODEC_H26L;
2538 else if (!strcmp(name, "MPEG4"))
2539 codec_index = MM_VIDEO_CODEC_MPEG4;
2540 else if (!strcmp(name, "MPEG1"))
2541 codec_index = MM_VIDEO_CODEC_MPEG1;
2542 else if (!strcmp(name, "THEORA"))
2543 codec_index = MM_VIDEO_CODEC_THEORA;
2545 MMCAM_LOG_DEBUG("video codec index %d", codec_index);
2552 int _mmcamcorder_get_image_codec_format(MMHandleType handle, const char *name)
2554 int codec_index = MM_IMAGE_CODEC_INVALID;
2557 MMCAM_LOG_ERROR("name is NULL");
2558 return MM_IMAGE_CODEC_INVALID;
2561 if (!strcmp(name, "JPEG"))
2562 codec_index = MM_IMAGE_CODEC_JPEG;
2563 else if (!strcmp(name, "PNG"))
2564 codec_index = MM_IMAGE_CODEC_PNG;
2565 else if (!strcmp(name, "BMP"))
2566 codec_index = MM_IMAGE_CODEC_BMP;
2567 else if (!strcmp(name, "WBMP"))
2568 codec_index = MM_IMAGE_CODEC_WBMP;
2569 else if (!strcmp(name, "TIFF"))
2570 codec_index = MM_IMAGE_CODEC_TIFF;
2571 else if (!strcmp(name, "PCX"))
2572 codec_index = MM_IMAGE_CODEC_PCX;
2573 else if (!strcmp(name, "GIF"))
2574 codec_index = MM_IMAGE_CODEC_GIF;
2575 else if (!strcmp(name, "ICO"))
2576 codec_index = MM_IMAGE_CODEC_ICO;
2577 else if (!strcmp(name, "RAS"))
2578 codec_index = MM_IMAGE_CODEC_RAS;
2579 else if (!strcmp(name, "TGA"))
2580 codec_index = MM_IMAGE_CODEC_TGA;
2581 else if (!strcmp(name, "XBM"))
2582 codec_index = MM_IMAGE_CODEC_XBM;
2583 else if (!strcmp(name, "XPM"))
2584 codec_index = MM_IMAGE_CODEC_XPM;
2586 MMCAM_LOG_DEBUG("image codec index %d", codec_index);
2592 int _mmcamcorder_get_mux_format(MMHandleType handle, const char *name)
2594 int mux_index = MM_FILE_FORMAT_INVALID;
2597 MMCAM_LOG_ERROR("name is NULL");
2598 return MM_FILE_FORMAT_INVALID;
2601 if (!strcmp(name, "3GP"))
2602 mux_index = MM_FILE_FORMAT_3GP;
2603 else if (!strcmp(name, "AMR"))
2604 mux_index = MM_FILE_FORMAT_AMR;
2605 else if (!strcmp(name, "MP4"))
2606 mux_index = MM_FILE_FORMAT_MP4;
2607 else if (!strcmp(name, "AAC"))
2608 mux_index = MM_FILE_FORMAT_AAC;
2609 else if (!strcmp(name, "MP3"))
2610 mux_index = MM_FILE_FORMAT_MP3;
2611 else if (!strcmp(name, "OGG"))
2612 mux_index = MM_FILE_FORMAT_OGG;
2613 else if (!strcmp(name, "WAV"))
2614 mux_index = MM_FILE_FORMAT_WAV;
2615 else if (!strcmp(name, "AVI"))
2616 mux_index = MM_FILE_FORMAT_AVI;
2617 else if (!strcmp(name, "WMA"))
2618 mux_index = MM_FILE_FORMAT_WMA;
2619 else if (!strcmp(name, "WMV"))
2620 mux_index = MM_FILE_FORMAT_WMV;
2621 else if (!strcmp(name, "MID"))
2622 mux_index = MM_FILE_FORMAT_MID;
2623 else if (!strcmp(name, "MMF"))
2624 mux_index = MM_FILE_FORMAT_MMF;
2625 else if (!strcmp(name, "MATROSKA"))
2626 mux_index = MM_FILE_FORMAT_MATROSKA;
2627 else if (!strcmp(name, "M2TS"))
2628 mux_index = MM_FILE_FORMAT_M2TS;
2630 MMCAM_LOG_DEBUG("mux index %d", mux_index);
2636 int _mmcamcorder_get_format(MMHandleType handle, int conf_category, const char *name)
2640 mmf_return_val_if_fail(name, -1);
2642 switch (conf_category) {
2643 case CONFIGURE_CATEGORY_MAIN_AUDIO_ENCODER:
2644 fmt = _mmcamcorder_get_audio_codec_format(handle, name);
2646 case CONFIGURE_CATEGORY_MAIN_VIDEO_ENCODER:
2647 fmt = _mmcamcorder_get_video_codec_format(handle, name);
2649 case CONFIGURE_CATEGORY_MAIN_IMAGE_ENCODER:
2650 fmt = _mmcamcorder_get_image_codec_format(handle, name);
2652 case CONFIGURE_CATEGORY_MAIN_MUX:
2653 fmt = _mmcamcorder_get_mux_format(handle, name);
2656 MMCAM_LOG_ERROR("Can't get format from this category.(%d)", conf_category);
2662 int _mmcamcorder_get_available_format(MMHandleType handle, int conf_category, int **format)
2664 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2665 camera_conf* configure_info = NULL;
2667 int total_count = 0;
2669 mmf_return_val_if_fail(hcamcorder, 0);
2671 configure_info = hcamcorder->conf_main;
2673 if (configure_info->info[conf_category]) {
2676 const char *name = NULL;
2677 int count = configure_info->info[conf_category]->count;
2678 conf_detail *info = configure_info->info[conf_category];
2680 MMCAM_LOG_DEBUG("conf_category[%d] : count[%d], info[%p]",
2681 conf_category, count, info);
2683 if (count <= 0 || !info)
2686 arr = (int*)g_malloc0(count * sizeof(int));
2688 for (i = 0 ; i < count ; i++) {
2689 if (info->detail_info[i] == NULL)
2692 name = ((type_element*)(info->detail_info[i]))->name;
2693 fmt = _mmcamcorder_get_format(handle, conf_category, name);
2695 arr[total_count++] = fmt;
2697 MMCAM_LOG_VERBOSE(" name:%s, fmt:%d", name, fmt);