Change return value for some display settings
[platform/core/multimedia/libmm-camcorder.git] / src / include / mm_camcorder_configure.h
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 #ifndef __MM_CAMCORDER_CONFIGURE_H__
23 #define __MM_CAMCORDER_CONFIGURE_H__
24
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28
29 /*=======================================================================================
30 | MACRO DEFINITIONS                                                                     |
31 ========================================================================================*/
32 #define SAFE_FREE(x) \
33         if (x) {\
34                 free(x); \
35                 x = NULL; \
36         }
37
38 #define SAFE_G_FREE(x) \
39         if (x) {\
40                 g_free(x); \
41                 x = NULL; \
42         }
43
44 #define CONFIGURE_MAIN_FILE             "mmfw_camcorder.ini"
45
46 /*=======================================================================================
47 | ENUM DEFINITIONS                                                                      |
48 ========================================================================================*/
49 enum ConfigureType {
50         CONFIGURE_TYPE_MAIN,
51         CONFIGURE_TYPE_CTRL,
52 };
53
54 enum ConfigureValueType {
55         CONFIGURE_VALUE_INT,
56         CONFIGURE_VALUE_INT_RANGE,
57         CONFIGURE_VALUE_INT_ARRAY,
58         CONFIGURE_VALUE_INT_PAIR_ARRAY,
59         CONFIGURE_VALUE_STRING,
60         CONFIGURE_VALUE_STRING_ARRAY,
61         CONFIGURE_VALUE_ELEMENT,
62         CONFIGURE_VALUE_NUM,
63 };
64
65 enum ConfigureCategoryMain {
66         CONFIGURE_CATEGORY_MAIN_GENERAL,
67         CONFIGURE_CATEGORY_MAIN_VIDEO_INPUT,
68         CONFIGURE_CATEGORY_MAIN_AUDIO_INPUT,
69         CONFIGURE_CATEGORY_MAIN_VIDEO_OUTPUT,
70         CONFIGURE_CATEGORY_MAIN_CAPTURE,
71         CONFIGURE_CATEGORY_MAIN_RECORD,
72         CONFIGURE_CATEGORY_MAIN_VIDEO_ENCODER,
73         CONFIGURE_CATEGORY_MAIN_AUDIO_ENCODER,
74         CONFIGURE_CATEGORY_MAIN_IMAGE_ENCODER,
75         CONFIGURE_CATEGORY_MAIN_MUX,
76         CONFIGURE_CATEGORY_MAIN_NUM,
77 };
78
79 enum ConfigureCategoryCtrl {
80         CONFIGURE_CATEGORY_CTRL_CAMERA,
81         CONFIGURE_CATEGORY_CTRL_STROBE,
82         CONFIGURE_CATEGORY_CTRL_EFFECT,
83         CONFIGURE_CATEGORY_CTRL_PHOTOGRAPH,
84         CONFIGURE_CATEGORY_CTRL_CAPTURE,
85         CONFIGURE_CATEGORY_CTRL_DETECT,
86         CONFIGURE_CATEGORY_CTRL_NUM,
87 };
88
89 /*=======================================================================================
90 | STRUCTURE DEFINITIONS                                                                 |
91 ========================================================================================*/
92 typedef struct _type_int type_int;
93 struct _type_int {
94         const char *name;
95         int value;
96 };
97
98 typedef struct _type_int2 type_int2;
99 struct _type_int2 {
100         char *name;
101         int value;
102 };
103
104 typedef struct _type_int_range type_int_range;
105 struct _type_int_range {
106         char *name;
107         int min;
108         int max;
109         int default_value;
110 };
111
112 typedef struct _type_int_array type_int_array;
113 struct _type_int_array {
114         char *name;
115         int *value;
116         int count;
117         int default_value;
118 };
119
120 typedef struct _type_int_pair_array type_int_pair_array;
121 struct _type_int_pair_array {
122         char *name;
123         int *value[2];
124         int count;
125         int default_value[2];
126 };
127
128 typedef struct _type_string type_string;
129 struct _type_string {
130         const char *name;
131         const char *value;
132 };
133
134 typedef struct _type_string2 type_string2;
135 struct _type_string2 {
136         char *name;
137         char *value;
138 };
139
140 typedef struct _type_string_array type_string_array;
141 struct _type_string_array {
142         char *name;
143         char **value;
144         int count;
145         char *default_value;
146 };
147
148 typedef struct _type_element type_element;
149 struct _type_element {
150         const char *name;
151         const char *element_name;
152         type_int **value_int;
153         int count_int;
154         type_string **value_string;
155         int count_string;
156 };
157
158 typedef struct _type_element2 type_element2;
159 struct _type_element2 {
160         char *name;
161         char *element_name;
162         type_int2 **value_int;
163         int count_int;
164         type_string2 **value_string;
165         int count_string;
166 };
167
168 typedef struct _conf_detail conf_detail;
169 struct _conf_detail {
170         int count;
171         void **detail_info;
172 };
173
174 typedef struct _conf_info_table conf_info_table;
175 struct _conf_info_table {
176         const char *name;
177         int value_type;
178         union {
179                 type_element *value_element;
180                 int value_int;
181                 char *value_string;
182         };
183 };
184
185 typedef struct _camera_conf camera_conf;
186 struct _camera_conf {
187         int type;
188         conf_detail **info;
189 };
190
191 /*=======================================================================================
192 | MODULE FUNCTION PROTOTYPES                                                            |
193 ========================================================================================*/
194 /* User function */
195 /**
196  * This function creates configure info structure from ini file.
197  *
198  * @param[in]   handle          Handle of camcorder.
199  * @param[in]   type            configure type(MAIN or CTRL).
200  * @param[in]   ConfFile        ini file path.
201  * @param[out]  configure_info  configure structure to be got.
202  * @return      This function returns MM_ERROR_NONE on success, or others on failure.
203  * @remarks
204  * @see         _mmcamcorder_conf_release_info()
205  *
206  */
207 int _mmcamcorder_conf_get_info(MMHandleType handle, int type, const char *ConfFile, camera_conf **configure_info);
208
209 /**
210  * This function releases configure info.
211  *
212  * @param[in]   handle          Handle of camcorder.
213  * @param[in]   configure_info  configure structure to be released.
214  * @return      void
215  * @remarks
216  * @see         _mmcamcorder_conf_get_info()
217  *
218  */
219 void _mmcamcorder_conf_release_info(MMHandleType handle, camera_conf **configure_info);
220
221 /**
222  * This function gets integer type value from configure info.
223  *
224  * @param[in]   handle          Handle of camcorder.
225  * @param[in]   configure_info  configure structure created by _mmcamcorder_conf_get_info.
226  * @param[in]   category        configure category.
227  * @param[in]   name            detail name in category.
228  * @param[out]  value           value to be got.
229  * @return      This function returns TRUE on success, or FALSE on failure.
230  * @remarks
231  * @see
232  *
233  */
234 int _mmcamcorder_conf_get_value_int(MMHandleType handle, camera_conf *configure_info, int category, const char *name, int *value);
235
236 /**
237  * This function gets integer-range type value from configure info.
238  *
239  * @param[in]   configure_info  configure structure created by _mmcamcorder_conf_get_info.
240  * @param[in]   category        configure category.
241  * @param[in]   name            detail name in category.
242  * @param[out]  value           value to be got.
243  * @return      This function returns TRUE on success, or FALSE on failure.
244  * @remarks
245  * @see
246  *
247  */
248 int _mmcamcorder_conf_get_value_int_range(camera_conf *configure_info, int category, const char *name, type_int_range **value);
249
250 /**
251  * This function gets integer-array type value from configure info.
252  *
253  * @param[in]   configure_info  configure structure created by _mmcamcorder_conf_get_info.
254  * @param[in]   category        configure category.
255  * @param[in]   name            detail name in category.
256  * @param[out]  value           value to be got.
257  * @return      This function returns TRUE on success, or FALSE on failure.
258  * @remarks
259  * @see
260  *
261  */
262 int _mmcamcorder_conf_get_value_int_array(camera_conf *configure_info, int category, const char *name, type_int_array **value);
263
264 /**
265  * This function gets integer-pair-array type value from configure info.
266  *
267  * @param[in]   configure_info  configure structure created by _mmcamcorder_conf_get_info.
268  * @param[in]   category        configure category.
269  * @param[in]   name            detail name in category.
270  * @param[out]  value           value to be got.
271  * @return      This function returns TRUE on success, or FALSE on failure.
272  * @remarks
273  * @see
274  *
275  */
276 int _mmcamcorder_conf_get_value_int_pair_array(camera_conf *configure_info, int category, const char *name, type_int_pair_array **value);
277
278 /**
279  * This function gets string type value from configure info.
280  *
281  * @param[in]   handle          Handle of camcorder.
282  * @param[in]   configure_info  configure structure created by _mmcamcorder_conf_get_info.
283  * @param[in]   category        configure category.
284  * @param[in]   name            detail name in category.
285  * @param[out]  value           value to be got.
286  * @return      This function returns TRUE on success, or FALSE on failure.
287  * @remarks
288  * @see
289  *
290  */
291 int _mmcamcorder_conf_get_value_string(MMHandleType handle, camera_conf *configure_info, int category, const char *name, const char **value);
292
293 /**
294  * This function gets string-array type value from configure info.
295  *
296  * @param[in]   configure_info  configure structure created by _mmcamcorder_conf_get_info.
297  * @param[in]   category        configure category.
298  * @param[in]   name            detail name in category.
299  * @param[out]  value           value to be got.
300  * @return      This function returns TRUE on success, or FALSE on failure.
301  * @remarks
302  * @see
303  *
304  */
305 int _mmcamcorder_conf_get_value_string_array(camera_conf *configure_info, int category, const char *name, type_string_array **value);
306
307 /**
308  * This function gets element info from configure info.
309  *
310  * @param[in]   handle          Handle of camcorder.
311  * @param[in]   configure_info  configure structure created by _mmcamcorder_conf_get_info.
312  * @param[in]   category        configure category.
313  * @param[in]   name            detail name in category.
314  * @param[out]  element         element info to be got.
315  * @return      This function returns TRUE on success, or FALSE on failure.
316  * @remarks
317  * @see
318  *
319  */
320 int _mmcamcorder_conf_get_element(MMHandleType handle, camera_conf *configure_info, int category, const char *name, type_element **element);
321
322 /**
323  * This function gets element name from element info.
324  *
325  * @param[in]   element         element info.
326  * @param[out]  name            element name to be got.
327  * @return      This function returns TRUE on success, or FALSE on failure.
328  * @remarks
329  * @see
330  *
331  */
332 int _mmcamcorder_conf_get_value_element_name(type_element *element, const char **value);
333
334 /**
335  * This function gets integer value of element's named property from element info.
336  *
337  * @param[in]   element         element info.
338  * @param[in]   name            property name.
339  * @param[out]  value           value to be got.
340  * @return      This function returns TRUE on success, or FALSE on failure.
341  * @remarks
342  * @see
343  *
344  */
345 int _mmcamcorder_conf_get_value_element_int(type_element *element, const char *name, int *value);
346
347 /**
348  * This function gets string value of element's named property from element info.
349  *
350  * @param[in]   element         element info.
351  * @param[in]   name            property name.
352  * @param[out]  value           value to be got.
353  * @return      This function returns TRUE on success, or FALSE on failure.
354  * @remarks
355  * @see
356  *
357  */
358 int _mmcamcorder_conf_get_value_element_string(type_element *element, const char *name, const char **value);
359
360 /**
361  * This function sets all property of element info.
362  *
363  * @param[in]   gst             gstreamer element.
364  * @param[in]   element         element info.
365  * @return      This function returns TRUE on success, or FALSE on failure.
366  * @remarks
367  * @see
368  *
369  */
370 int _mmcamcorder_conf_set_value_element_property(GstElement *gst, type_element *element);
371
372 /**
373  * This function prints all values of configure info.
374  *
375  * @param[in]   configure_info  configure structure created by _mmcamcorder_conf_get_info.
376  * @return      This function returns TRUE on success, or FALSE on failure.
377  * @remarks
378  * @see
379  *
380  */
381 void _mmcamcorder_conf_print_info(MMHandleType handle, camera_conf **configure_info);
382
383 type_element *_mmcamcorder_get_type_element(MMHandleType handle, int type);
384 int _mmcamcorder_get_available_format(MMHandleType handle, int conf_category, int **format);
385
386 /* Internal function */
387 void _mmcamcorder_conf_init(MMHandleType handle, int type, camera_conf **configure_info);
388 int _mmcamcorder_conf_parse_info(MMHandleType handle, int type, FILE *fd, camera_conf **configure_info);
389 int _mmcamcorder_conf_get_value_type(MMHandleType handle, int type, int category, const char *name, int *value_type);
390 int _mmcamcorder_conf_add_info(MMHandleType handle, int type, conf_detail **info, char **buffer_details, int category, int count_details);
391 int _mmcamcorder_conf_get_default_value_int(MMHandleType handle, int type, int category, const char *name, int *value);
392 int _mmcamcorder_conf_get_default_value_string(MMHandleType handle, int type, int category, const char *name, const char **value);
393 int _mmcamcorder_conf_get_default_element(MMHandleType handle, int type, int category, const char *name, type_element **element);
394 int _mmcamcorder_conf_get_category_size(MMHandleType handle, int type, int category, int *size);
395
396 #ifdef __cplusplus
397 }
398 #endif
399 #endif /* __MM_CAMCORDER_CONFIGURE_H__ */