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_ARRAY, /**< Array type attribute */
61 MM_ATTRS_TYPE_RANGE, /**< Range type attribute */
62 MM_ATTRS_TYPE_NUM, /**< Number of attribute type */
66 * Enumeration for attribute validation type.
69 MM_ATTRS_VALID_TYPE_INVALID = -1, /**< Invalid validation type */
70 MM_ATTRS_VALID_TYPE_NONE, /**< Do not check validity */
71 MM_ATTRS_VALID_TYPE_INT_ARRAY, /**< validity checking type of integer array */
72 MM_ATTRS_VALID_TYPE_INT_RANGE, /**< validity checking type of integer range */
73 MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY, /**< validity checking type of double array */
74 MM_ATTRS_VALID_TYPE_DOUBLE_RANGE, /**< validity checking type of double range */
78 * Enumeration for attribute access flag.
81 MM_ATTRS_FLAG_NONE = 0, /**< None flag is set */
82 MM_ATTRS_FLAG_READABLE = 1 << 0, /**< Readable */
83 MM_ATTRS_FLAG_WRITABLE = 1 << 1, /**< Writable */
84 MM_ATTRS_FLAG_MODIFIED = 1 << 2, /**< Modified */
86 MM_ATTRS_FLAG_RW = MM_ATTRS_FLAG_READABLE | MM_ATTRS_FLAG_WRITABLE, /**< Readable and Writable */
96 MMAttrsValidType validity_type;
99 * a union that describes validity of the attribute.
100 * Only when type is 'MM_ATTRS_TYPE_INT' or 'MM_ATTRS_TYPE_DOUBLE',
101 * the attribute can have validity.
105 * Validity structure for integer array.
108 int * array; /**< a pointer of array */
109 int count; /**< size of array */
113 * Validity structure for integer range.
116 int min; /**< minimum range */
117 int max; /**< maximum range */
121 * Validity structure for double array.
124 double * array; /**< a pointer of array */
125 int count; /**< size of array */
129 * Validity structure for double range.
132 double min; /**< minimum range */
133 double max; /**< maximum range */
140 #define __NULL_TERMINATED __attribute__((__sentinel__))
142 #define __NULL_TERMINATED
146 * This function is to set the integer value to the attribute by name.
147 * @param attrs [in] MMAttrs handle
148 * @param attr_name [in] attribute name
149 * @param val [in] integer value to set
150 * @return This function returns MM_ERROR_NONE on success, or negative value with error code.
152 int mm_attrs_set_int_by_name(MMHandleType attrs, const char *attr_name, int val);
156 * This function is to get the number of attribute in the MMAttrs.
157 * @param attrs [in] Handle of attributes list
158 * @param size [out] Number of attributes
159 * @return This function returns the number of attributes in the attribute list.
161 int mm_attrs_get_size(MMHandleType attrs, int *size);
165 * This function is to get the name of attribute at the given index.
166 * @param attrs [in] Handle of attributes list
167 * @param index [in] Index of the attribute
168 * @param name [out] Name of attribute
169 * @return This function returns the name of attribute on success, or NULL
172 int mm_attrs_get_name(MMHandleType attrs, int index, char **name);
176 * This function is to get the index of attribute at the given name.
177 * @param attrs [in] Handle of attributes list
178 * @param attr_name [in] Name of attribute
179 * @param index [out] Index of attribute
180 * @return This function returns the index of the attribute on success,
181 * or negative value on failure.
183 int mm_attrs_get_index(MMHandleType attrs, const char *attr_name, int *index);
187 * This function is to get the integer value from the attribute by name.
188 * @param attrs [in] Handle of attributes list
189 * @param attr_name [in] Name of attribute
190 * @param val [out] Value of attribute
191 * @return This function returns attribute value
193 int mm_attrs_get_int_by_name(MMHandleType attrs, const char *attr_name, int *val);
197 * This function is to set the string to attribute by name.
198 * @param attrs [in] MMAttrs handle
199 * @param attr_name [in] attribute name
200 * @param string [in] string value to set
201 * @return This function returns MM_ERROR_NONE on success, or negative value with error code.
203 int mm_attrs_set_string_by_name(MMHandleType attrs, const char *attr_name, const char *string);
207 * This function is to get the string from the attribute by name.
208 * @param attrs [in] Handle of attributes list
209 * @param attr_name [in] Name of attribute
210 * @param val [out] Value of attribute
211 * @return This function returns the string value of attribute on success,
214 int mm_attrs_get_string_by_name(MMHandleType attrs, const char *attr_name, char **val);
218 * This function is to set the data to the attribute by name.
219 * @param attrs [in] MMAttrs handle
220 * @param attr_name [in] attribute name
221 * @param data [in] data pointer to set
222 * @param size [in] data size to set
223 * @return This function returns MM_ERROR_NONE on success, or negative value with error code.
225 int mm_attrs_set_data_by_name(MMHandleType attrs, const char *attr_name, void *data, int size);
228 * This function is to get the data from the attribute by name.
229 * @param attrs [in] Handle of attributes list
230 * @param attr_name [in] Name of attribute
231 * @param data [out] data pointer to set
232 * @return This function returns user defined value on success, or NULL
235 int mm_attrs_get_data_by_name(MMHandleType attrs, const char *attr_name, void **data);
239 * This function is to retrieve type of attribute.
240 * @param attrs [in] List of attributes
241 * @param id [in] ID of attribute
242 * @param attrtype [out] On return contains type of attribute
243 * @return This function returns MM_ERROR_NONE.
246 int mm_attrs_get_type(MMHandleType attrs, int id, MMAttrsType *attrtype);
250 * This function is to get flags of attribute with given id.
251 * @param attrs [in] List of attributes
252 * @param id [in] ID of attribute
253 * @param flags [out] On return contains flags of attribute.
254 * @return This function returns MM_ERROR_NONE on success, or negative value with error code.
257 int mm_attrs_get_flags(MMHandleType attrs, int id, int *flags);
261 * This function is to get valid value type of attribute with given id.
262 * @param attrs [in] List of attributes
263 * @param id [in] ID of attribute
264 * @param type [out] On return contains valid value type of attribute
265 * @return This function returns MM_ERROR_NONE on success, or negative value with error code.
268 int mm_attrs_get_valid_type(MMHandleType attrs, int id, int *type);
272 * This function is to get valid range of attribute with given id.
273 * @param attrs [in] List of attributes
274 * @param id [in] ID of attribute
275 * @param min [out] minimum value of the valid range.
276 * @param max [out] maximum value of the valid range.
277 * @return This function returns MM_ERROR_NONE on success, or negative value with error code.
279 int mm_attrs_get_valid_range(MMHandleType attrs, int id, int *min, int *max);
283 * This function is to get valid array of attribute with given id.
284 * @param attrs [in] list of attributes
285 * @param id [in] ID of attribute
286 * @param count [out] number of array
287 * @param array [out] on return contains valid array of attribute
288 * @return This function returns MM_ERROR_NONE on success, or negative value with error code.
290 int mm_attrs_get_valid_array(MMHandleType attrs, int id, int *count, int **array);
294 * This function is to get valid double type range of attribute with given id.
295 * @param attrs [in] List of attributes
296 * @param id [in] ID of attribute
297 * @param min [out] minimum value of the valid range.
298 * @param max [out] maximum value of the valid range.
299 * @return This function returns MM_ERROR_NONE on success, or negative value with error code.
301 int mm_attrs_get_valid_double_range(MMHandleType h, int idx, double *min, double *max);
305 * This function is to get valid double type array of attribute with given id.
306 * @param attrs [in] list of attributes
307 * @param id [in] ID of attribute
308 * @param count [out] number of array
309 * @param array [out] on return contains valid array of attribute
310 * @return This function returns MM_ERROR_NONE on success, or negative value with error code.
312 int mm_attrs_get_valid_double_array(MMHandleType h, int idx, int *count, double **array);
316 * This function is to set integer value to attribute with given id.
317 * @param attrs [in] List of attributes
318 * @param id [in] ID of attribute
319 * @param val [in] integer value to set
320 * @return This function returns MM_ERROR_NONE on success, or negative value with error code.
321 * @see mm_attrs_get_int
323 int mm_attrs_set_int(MMHandleType attrs, int id, int val);
327 * This function is to get integer value to attribute with given id.
328 * @param attrs [in] List of attributes
329 * @param id [in] ID of attribute
330 * @param val [out] On return contains integer value of attribute
331 * @return This function returns MM_ERROR_NONE on success, or negative value with error code.
332 * @remarks If type of attributes is not an integer type, the value which is returned by this function is meaningless.
333 * @see mm_attrs_get_int
335 int mm_attrs_get_int(MMHandleType attrs, int id, int *val);
339 * This function is to set double value to attribute with given id.
341 * @param attrs [in] List of attributes
342 * @param id [in] ID of attribute
343 * @param val [in] Integer value to set
345 * @return This function returns MM_ERROR_NONE on success, or negative value with error code.
346 * @see mm_attrs_get_double
348 int mm_attrs_set_double(MMHandleType attrs, int id, double val);
352 * This function is to set the double value to the attribute by name.
354 * @param attrs [in] Handle of attributes list
355 * @param attr_name [in] Name of attribute
356 * @param val [in] Integer value to set
358 * @return This function returns MM_ERROR_NONE on success, or negative value with error code.
360 int mm_attrs_set_double_by_name(MMHandleType attrs, const char *attr_name, double val);
364 * This function is to get double value to attribute with given id.
366 * @param attrs [in] List of attributes
367 * @param id [in] ID of attribute
368 * @param attrval [out] On return contains double value of attribute on success, or invalid value.
369 * @return This function returns MM_ERROR_NONE on success, or negative value with error code.
370 * @see mm_attrs_set_double
372 int mm_attrs_get_double(MMHandleType attrs, int id, double *attrval);
376 * This function is to get the double value from the attribute by name.
378 * @param attrs [in] Handle of attributes list
379 * @param attr_name [in] Name of attribute
380 * @param val [out] Double value to set
382 * @return This function returns attribute value
384 int mm_attrs_get_double_by_name(MMHandleType attrs, const char *attr_name, double *val);
388 * This function is to set string to attribute with given id.
389 * @param attrs [in] List of attributes
390 * @param id [in] ID of attribute
391 * @param string [in] String to set
392 * @param size [in] length of string to set
393 * @return This function returns MM_ERROR_NONE on success, or negative value with error code.
394 * @see mm_attrs_get_string
396 int mm_attrs_set_string(MMHandleType attrs, int id, const char *string, int size);
400 * This function is to get string to attribute with given id.
401 * @param attrs [in] List of attributes
402 * @param id [in] ID of attribute
403 * @param sval [in] Placeholder to output string buffer
404 * @param size [in] The field contains number of characters filled in the buffer
405 * @return This function returns MM_ERROR_NONE on success, or negative value with error code.
406 * @remarks Application would be responsible for managing/releasing the string
407 * @see mm_attrs_set_string
409 int mm_attrs_get_string(MMHandleType attrs, int id,char **sval, int *size);
413 * This function is to set pointer to attribute with given id.
414 * @param attrs [in] List of attributes
415 * @param id [in] ID of attribute
416 * @param data [in] data to set
417 * @param size [in] Length of input data
418 * @return This function returns MM_ERROR_NONE on success, or negative value with error code.
419 * @remarks Data type is the reference to memory which is allocated by user. The allocated memory must be freed by user.
420 * @see mm_attrs_get_data
422 int mm_attrs_set_data(MMHandleType attrs, int id, void *data, int size);
425 * This function is to get pointer to attribute with given id.
426 * @param attrs [in] List of attributes
427 * @param id [in] ID of attribute
428 * @param data [out] Placeholder to output data buffer
429 * @param size [out] The field contains number of bytes filled in the buffer
430 * @return This function returns MM_ERROR_NONE on success, or negative value with error code.
431 * @remarks Application would be responsible for managing/releasing data
432 * @see mm_attrs_set_data
434 int mm_attrs_get_data(MMHandleType attrs, int id, void **data, int *size);
437 * This function is to set range of attribute with given id.
439 * @param attrs [in] List of attributes
440 * @param id [in] ID of attribute
441 * @param min [in] Minimum value of range
442 * @param max [in] Maximum value of range
444 * @return This function returns MM_ERROR_NONE on success, or negative value with error code.
445 * @see mm_attrs_get_range
447 int mm_attrs_set_range(MMHandleType attrs, int id, int min, int max);
450 * This function is to get range of attribute with given id.
452 * @param attrs [in] List of attributes
453 * @param id [in] ID of attribute
454 * @param min [out] Minimum value of range
455 * @param max [out] Maximum value of range
457 * @return This function returns MM_ERROR_NONE on success, or negative value with error code.
458 * @see mm_attrs_set_range
460 int mm_attrs_get_range(MMHandleType attrs, int id, int *min, int *max);
463 * This function is to set array of attribute with given id.
465 * @param attrs [in] List of attributes
466 * @param id [in] ID of attribute
467 * @param array [in] Array of integer values
468 * @param count [in] Count of array
470 * @return This function returns the array of attribute on success, or NULL pointer on failure.
471 * @see mm_attrs_get_array
473 int mm_attrs_set_array(MMHandleType attrs, int id, int *array, int count);
476 * This function is to get array of attribute with given id.
478 * @param attrs [in] List of attributes
479 * @param id [in] ID of attribute
480 * @param array [out] Contains the array of attribute on success,
481 * or NULL pointer on failure.
482 * @param count [out] Count of array
484 * @return This function returns MM_ERROR_NONE on success, or negative value with error code.
485 * @remarks Application would be responsible for managing/releasing the array
486 * @see mm_attrs_set_array
488 int mm_attrs_get_array(MMHandleType attrs, int id, int **array, int *count );
492 * A function to get information of the attribute
494 * @param attrs [in] List of attributes
495 * @param id [in] ID of attribute
496 * @param array [out] Contains the array of attribute on success,
497 * or NULL pointer on failure.
498 * @param count [out] Count of array
500 * @return This function returns MM_ERROR_NONE on success, or negative value with error code.
501 * @remarks Application would be responsible for managing/releasing the array
502 * @see mm_attrs_set_info
504 int mm_attrs_get_info(MMHandleType h, int idx, MMAttrsInfo *info);
508 * This function is to get array of attribute with given id.
510 * @param attrs [in] List of attributes
511 * @param id [in] ID of attribute
512 * @param array [out] Contains the array of attribute on success,
513 * or NULL pointer on failure.
514 * @param count [out] Count of array
516 * @return This function returns MM_ERROR_NONE on success, or negative value with error code.
517 * @remarks Application would be responsible for managing/releasing the array
518 * @see mm_attrs_set_array
520 int mm_attrs_get_info_by_name(MMHandleType h, const char *attr_name, MMAttrsInfo *info);
523 * Sets properties on an object.
525 * @param attrs [in] List of attributes
526 * @param err_attr_name [out] the name of attributes that occurs error. Free this variable after use.
527 * @param attribute_name [in] name of the first property to set
528 * @param ... [in] value for the first property, followed optionally by more
529 * name/value pairs, followed by %NULL
531 * @return This function returns MM_ERROR_NONE on success, or negative value with error code.
532 * @remarks Multiple setter of attribute
533 * @see mm_attrs_set_int, mm_attrs_set_string, ...
535 int mm_attrs_multiple_set(MMHandleType handle, char **err_attr_name, const char *attribute_name, ...) __NULL_TERMINATED;
539 * Gets properties on an object.
541 * @param attrs [in] List of attributes
542 * @param err_attr_name [out] the name of attributes that occurs error. Free this variable after use.
543 * @param attribute_name [in] name of the first property to set
544 * @param ... [in] value for the first property, followed optionally by more
545 * name/value pairs, followed by %NULL
547 * @return This function returns MM_ERROR_NONE on success, or negative value with error code.
548 * @remarks Multiple setter of attribute
549 * @see mm_attrs_set_int, mm_attrs_set_string, ...
551 int mm_attrs_multiple_get(MMHandleType handle, char **err_attr_name, const char *attribute_name, ...) __NULL_TERMINATED;
555 * Sets properties on an object with va_list param.
557 * @param attrs [in] List of attributes
558 * @param err_attr_name [out] the name of attributes that occurs error. Free this variable after use.
559 * @param attribute_name [in] name of the first property to set
560 * @param var_args [in] variable arguments
562 * @return This function returns MM_ERROR_NONE on success, or negative value with error code.
563 * @remarks Multiple setter of attribute
564 * @see mm_attrs_multiple_set
566 int mm_attrs_set_valist (MMHandleType attrs, char **err_attr_name, const char *attribute_name, va_list var_args);
570 * Gets properties on an object with va_list param.
572 * @param attrs [in] List of attributes
573 * @param err_attr_name [out] the name of attributes that occurs error. Free this variable after use.
574 * @param attribute_name [in] name of the first property to set
575 * @param var_args [in] variable arguments
577 * @return This function returns MM_ERROR_NONE on success, or negative value with error code.
578 * @remarks Multiple setter of attribute
579 * @see mm_attrs_multiple_get
581 int mm_attrs_get_valist (MMHandleType attrs, char **err_attr_name, const char *attribute_name, va_list var_args);
591 #endif /* __MM_ATTRS_H__ */