4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Jonghyuk Choi <jhchoi.choi@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.
24 #ifndef __MM_ATTRS_H__
25 #define __MM_ATTRS_H__
41 * @brief This file declares data structures and functions of attribute library.
44 This part describes the APIs with respect to Multimedia Attribute Library.
45 The Attribute Library is a set of attribute. An attribute contains a value,
46 access flags and it's validation information. This document explains how to
47 manipulate an attribute in the Attribute Library.
52 * Enumeration for attribute values types.
55 MM_ATTRS_TYPE_INVALID = -1, /**< Type is invalid */
56 MM_ATTRS_TYPE_INT, /**< Integer type attribute */
57 MM_ATTRS_TYPE_DOUBLE, /**< Double type attribute */
58 MM_ATTRS_TYPE_STRING, /**< UTF-8 String type attribute */
59 MM_ATTRS_TYPE_DATA, /**< Pointer type attribute */
60 MM_ATTRS_TYPE_NUM, /**< Number of attribute type */
64 * Enumeration for attribute validation type.
67 MM_ATTRS_VALID_TYPE_INVALID = -1, /**< Invalid validation type */
68 MM_ATTRS_VALID_TYPE_NONE, /**< Do not check validity */
69 MM_ATTRS_VALID_TYPE_INT_ARRAY, /**< validity checking type of integer array */
70 MM_ATTRS_VALID_TYPE_INT_RANGE, /**< validity checking type of integer range */
71 MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY, /**< validity checking type of double array */
72 MM_ATTRS_VALID_TYPE_DOUBLE_RANGE, /**< validity checking type of double range */
76 * Enumeration for attribute access flag.
79 MM_ATTRS_FLAG_NONE = 0, /**< None flag is set */
80 MM_ATTRS_FLAG_READABLE = 1 << 0, /**< Readable */
81 MM_ATTRS_FLAG_WRITABLE = 1 << 1, /**< Writable */
82 MM_ATTRS_FLAG_MODIFIED = 1 << 2, /**< Modified */
84 MM_ATTRS_FLAG_RW = MM_ATTRS_FLAG_READABLE | MM_ATTRS_FLAG_WRITABLE, /**< Readable and Writable */
94 MMAttrsValidType validity_type;
97 * a union that describes validity of the attribute.
98 * Only when type is 'MM_ATTRS_TYPE_INT' or 'MM_ATTRS_TYPE_DOUBLE',
99 * the attribute can have validity.
103 * Validity structure for integer array.
106 int *array; /**< a pointer of array */
107 int count; /**< size of array */
108 int dval; /**< default value */
112 * Validity structure for integer range.
115 int min; /**< minimum range */
116 int max; /**< maximum range */
117 int dval; /**< default value */
121 * Validity structure for double array.
124 double *array; /**< a pointer of array */
125 int count; /**< size of array */
126 double dval; /**< default value */
130 * Validity structure for double range.
133 double min; /**< minimum range */
134 double max; /**< maximum range */
135 double dval; /**< default value */
142 #define __NULL_TERMINATED __attribute__((__sentinel__))
144 #define __NULL_TERMINATED
148 * This function is to set the integer value to the attribute by name.
150 * @param attrs [in] MMAttrs handle
151 * @param attr_name [in] attribute name
152 * @param val [in] integer value to set
154 * @return This function returns MM_ERROR_NONE on success, or negative value with error code.
156 int mm_attrs_set_int_by_name(MMHandleType attrs, const char *attr_name, int val);
160 * This function is to get the number of attribute in the MMAttrs.
162 * @param attrs [in] Handle of attributes list
163 * @param size [out] Number of attributes
165 * @return This function returns the number of attributes in the attribute list.
167 int mm_attrs_get_size(MMHandleType attrs, int *size);
171 * This function is to get the name of attribute at the given index.
173 * @param attrs [in] Handle of attributes list
174 * @param index [in] Index of the attribute
175 * @param name [out] Name of attribute
177 * @return This function returns the name of attribute on success, or NULL
180 int mm_attrs_get_name(MMHandleType attrs, int index, char **name);
184 * This function is to get the index of attribute at the given name.
186 * @param attrs [in] Handle of attributes list
187 * @param attr_name [in] Name of attribute
188 * @param index [out] Index of attribute
190 * @return This function returns the index of the attribute on success,
191 * or negative value on failure.
193 int mm_attrs_get_index(MMHandleType attrs, const char *attr_name, int *index);
197 * This function is to get the integer value from the attribute by name.
199 * @param attrs [in] Handle of attributes list
200 * @param attr_name [in] Name of attribute
201 * @param val [out] Value of attribute
203 * @return This function returns attribute value
205 int mm_attrs_get_int_by_name(MMHandleType attrs, const char *attr_name, int *val);
209 * This function is to set the string to attribute by name.
211 * @param attrs [in] MMAttrs handle
212 * @param attr_name [in] attribute name
213 * @param string [in] string value to set
215 * @return This function returns MM_ERROR_NONE on success, or negative value with error code.
217 int mm_attrs_set_string_by_name(MMHandleType attrs, const char *attr_name, const char *string);
221 * This function is to get the string from the attribute by name.
223 * @param attrs [in] Handle of attributes list
224 * @param attr_name [in] Name of attribute
225 * @param val [out] Value of attribute
227 * @return This function returns the string value of attribute on success,
230 int mm_attrs_get_string_by_name(MMHandleType attrs, const char *attr_name, char **val);
234 * This function is to set the data to the attribute by name.
236 * @param attrs [in] MMAttrs handle
237 * @param attr_name [in] attribute name
238 * @param data [in] data pointer to set
239 * @param size [in] data size to set
241 * @return This function returns MM_ERROR_NONE on success, or negative value with error code.
243 int mm_attrs_set_data_by_name(MMHandleType attrs, const char *attr_name, void *data, int size);
246 * This function is to get the data from the attribute by name.
248 * @param attrs [in] Handle of attributes list
249 * @param attr_name [in] Name of attribute
250 * @param data [out] data pointer to set
252 * @return This function returns user defined value on success, or NULL
255 int mm_attrs_get_data_by_name(MMHandleType attrs, const char *attr_name, void **data);
259 * This function is to retrieve type of attribute.
261 * @param attrs [in] List of attributes
262 * @param index [in] Index of attribute
263 * @param attrtype [out] On return contains type of attribute
265 * @return This function returns MM_ERROR_NONE.
268 int mm_attrs_get_type(MMHandleType attrs, int index, MMAttrsType *attrtype);
272 * This function is to get flags of attribute with given index.
274 * @param attrs [in] List of attributes
275 * @param index [in] Index of attribute
276 * @param flags [out] On return contains flags of attribute.
278 * @return This function returns MM_ERROR_NONE on success, or negative value with error code.
281 int mm_attrs_get_flags(MMHandleType attrs, int index, int *flags);
285 * This function is to get valid value type of attribute with given index.
287 * @param attrs [in] List of attributes
288 * @param index [in] Index of attribute
289 * @param type [out] On return contains valid value type of attribute
291 * @return This function returns MM_ERROR_NONE on success, or negative value with error code.
294 int mm_attrs_get_valid_type(MMHandleType attrs, int index, int *type);
298 * This function is to get valid range of attribute with given index.
300 * @param attrs [in] List of attributes
301 * @param index [in] Index of attribute
302 * @param min [out] minimum value of the valid range
303 * @param max [out] maximum value of the valid range
305 * @return This function returns MM_ERROR_NONE on success, or negative value with error code.
307 int mm_attrs_get_valid_range(MMHandleType attrs, int index, int *min, int *max);
311 * This function is to get valid array of attribute with given index.
313 * @param attrs [in] list of attributes
314 * @param index [in] Index of attribute
315 * @param count [out] number of array
316 * @param array [out] on return contains valid array of attribute
318 * @return This function returns MM_ERROR_NONE on success, or negative value with error code.
320 int mm_attrs_get_valid_array(MMHandleType attrs, int index, int *count, int **array);
324 * This function is to set integer value to attribute with given index.
326 * @param attrs [in] List of attributes
327 * @param index [in] Index of attribute
328 * @param val [in] integer value to set
330 * @return This function returns MM_ERROR_NONE on success, or negative value with error code.
331 * @see mm_attrs_get_int
333 int mm_attrs_set_int(MMHandleType attrs, int index, int val);
337 * This function is to get integer value to attribute with given index.
339 * @param attrs [in] List of attributes
340 * @param index [in] Index of attribute
341 * @param val [out] On return contains integer value of attribute
343 * @return This function returns MM_ERROR_NONE on success, or negative value with error code.
344 * @remarks If type of attributes is not an integer type, the value which is returned by this function is meaningless.
345 * @see mm_attrs_get_int
347 int mm_attrs_get_int(MMHandleType attrs, int index, int *val);
351 * This function is to set double value to attribute with given index.
353 * @param attrs [in] List of attributes
354 * @param index [in] Index of attribute
355 * @param val [in] Integer value to set
357 * @return This function returns MM_ERROR_NONE on success, or negative value with error code.
358 * @see mm_attrs_get_double
360 int mm_attrs_set_double(MMHandleType attrs, int index, double val);
364 * This function is to set the double value to the attribute by name.
366 * @param attrs [in] Handle of attributes list
367 * @param attr_name [in] Name of attribute
368 * @param val [in] Integer value to set
370 * @return This function returns MM_ERROR_NONE on success, or negative value with error code.
372 int mm_attrs_set_double_by_name(MMHandleType attrs, const char *attr_name, double val);
376 * This function is to get double value to attribute with given index.
378 * @param attrs [in] List of attributes
379 * @param index [in] Index of attribute
380 * @param attrval [out] On return contains double value of attribute on success, or invalid value.
382 * @return This function returns MM_ERROR_NONE on success, or negative value with error code.
383 * @see mm_attrs_set_double
385 int mm_attrs_get_double(MMHandleType attrs, int index, double *attrval);
389 * This function is to get the double value from the attribute by name.
391 * @param attrs [in] Handle of attributes list
392 * @param attr_name [in] Name of attribute
393 * @param val [out] Double value to set
395 * @return This function returns attribute value
397 int mm_attrs_get_double_by_name(MMHandleType attrs, const char *attr_name, double *val);
401 * This function is to set string to attribute with given index.
403 * @param attrs [in] List of attributes
404 * @param index [in] Index of attribute
405 * @param string [in] String to set
406 * @param size [in] length of string to set
408 * @return This function returns MM_ERROR_NONE on success, or negative value with error code.
409 * @see mm_attrs_get_string
411 int mm_attrs_set_string(MMHandleType attrs, int index, const char *string, int size);
415 * This function is to get string to attribute with given index.
417 * @param attrs [in] List of attributes
418 * @param index [in] Index of attribute
419 * @param sval [in] Placeholder to output string buffer
420 * @param size [in] The field contains number of characters filled in the buffer
422 * @return This function returns MM_ERROR_NONE on success, or negative value with error code.
423 * @remarks Application would be responsible for managing/releasing the string
424 * @see mm_attrs_set_string
426 int mm_attrs_get_string(MMHandleType attrs, int index, char **sval, int *size);
430 * This function is to set pointer to attribute with given index.
432 * @param attrs [in] List of attributes
433 * @param index [in] Index of attribute
434 * @param data [in] data to set
435 * @param size [in] Length of input data
436 * @return This function returns MM_ERROR_NONE on success, or negative value with error code.
438 * @remarks Data type is the reference to memory which is allocated by user. The allocated memory must be freed by user.
439 * @see mm_attrs_get_data
441 int mm_attrs_set_data(MMHandleType attrs, int index, void *data, int size);
444 * This function is to get pointer to attribute with given index.
446 * @param attrs [in] List of attributes
447 * @param index [in] Index of attribute
448 * @param data [out] Placeholder to output data buffer
449 * @param size [out] The field contains number of bytes filled in the buffer
451 * @return This function returns MM_ERROR_NONE on success, or negative value with error code.
452 * @remarks Application would be responsible for managing/releasing data
453 * @see mm_attrs_set_data
455 int mm_attrs_get_data(MMHandleType attrs, int index, void **data, int *size);
459 * A function to get information of the attribute
461 * @param attrs [in] List of attributes
462 * @param index [in] Index of attribute
463 * @param info [out] Information of the attribute
465 * @return This function returns MM_ERROR_NONE on success, or negative value with error code.
467 int mm_attrs_get_info(MMHandleType attrs, int index, MMAttrsInfo *info);
471 * This function is to get array of attribute with given name.
473 * @param attrs [in] List of attributes
474 * @param attr_name [in] Name of attribute
475 * @param info [out] Information of the attribute
477 * @return This function returns MM_ERROR_NONE on success, or negative value with error code.
479 int mm_attrs_get_info_by_name(MMHandleType attrs, const char *attr_name, MMAttrsInfo *info);
482 * Sets properties on an object.
484 * @param attrs [in] List of attributes
485 * @param err_attr_name [out] the name of attributes that occurs error. Free this variable after use.
486 * @param attribute_name [in] name of the first property to set
487 * @param ... [in] value for the first property, followed optionally by more
488 * name/value pairs, followed by %NULL
490 * @return This function returns MM_ERROR_NONE on success, or negative value with error code.
491 * @remarks Multiple setter of attribute
492 * @see mm_attrs_set_int, mm_attrs_set_string, ...
494 int mm_attrs_multiple_set(MMHandleType attrs, char **err_attr_name, const char *attribute_name, ...) __NULL_TERMINATED;
498 * Gets properties on an object.
500 * @param attrs [in] List of attributes
501 * @param err_attr_name [out] the name of attributes that occurs error. Free this variable after use.
502 * @param attribute_name [in] name of the first property to set
503 * @param ... [in] value for the first property, followed optionally by more
504 * name/value pairs, followed by %NULL
506 * @return This function returns MM_ERROR_NONE on success, or negative value with error code.
507 * @remarks Multiple setter of attribute
508 * @see mm_attrs_set_int, mm_attrs_set_string, ...
510 int mm_attrs_multiple_get(MMHandleType attrs, char **err_attr_name, const char *attribute_name, ...) __NULL_TERMINATED;
514 * Sets properties on an object with va_list param.
516 * @param attrs [in] List of attributes
517 * @param err_attr_name [out] the name of attributes that occurs error. Free this variable after use.
518 * @param attribute_name [in] name of the first property to set
519 * @param var_args [in] variable arguments
521 * @return This function returns MM_ERROR_NONE on success, or negative value with error code.
522 * @remarks Multiple setter of attribute
523 * @see mm_attrs_multiple_set
525 int mm_attrs_set_valist(MMHandleType attrs, char **err_attr_name, const char *attribute_name, va_list var_args);
529 * Gets properties on an object with va_list param.
531 * @param attrs [in] List of attributes
532 * @param err_attr_name [out] the name of attributes that occurs error. Free this variable after use.
533 * @param attribute_name [in] name of the first property to set
534 * @param var_args [in] variable arguments
536 * @return This function returns MM_ERROR_NONE on success, or negative value with error code.
537 * @remarks Multiple setter of attribute
538 * @see mm_attrs_multiple_get
540 int mm_attrs_get_valist(MMHandleType attrs, char **err_attr_name, const char *attribute_name, va_list var_args);
550 #endif /* __MM_ATTRS_H__ */