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