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