JACK API headers
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

165 lines
5.5KB

  1. /*
  2. Copyright (C) 2001 Paul Davis
  3. Copyright (C) 2011 David Robillard
  4. This program is free software; you can redistribute it and/or modify it
  5. under the terms of the GNU Lesser General Public License as published by
  6. the Free Software Foundation; either version 2.1 of the License, or (at
  7. your option) any later version.
  8. This program is distributed in the hope that it will be useful, but WITHOUT
  9. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  10. FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
  11. License for more details.
  12. You should have received a copy of the GNU Lesser General Public License
  13. along with this program; if not, write to the Free Software Foundation,
  14. Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  15. */
  16. #ifndef __jack_metadata_h__
  17. #define __jack_metadata_h__
  18. #include <jack/types.h>
  19. #ifdef __cplusplus
  20. extern "C" {
  21. #endif
  22. /**
  23. * @defgroup Metadata Metadata API.
  24. * @{
  25. */
  26. /**
  27. * A single property (key:value pair).
  28. */
  29. typedef struct {
  30. const char* key; /**< The key of this property (URI string). */
  31. const char* data; /**< The property value (null-terminated string) */
  32. const char* type; /**< MIME type of data. Likely values are:
  33. *
  34. * text/utf8 (for an null terminated string)
  35. * image/png;base64 (for a data-URI converted image)
  36. *
  37. * If type is null (or empty), the type should
  38. * be assumed to be "text/utf8" and the memory
  39. * pointed to by "data" should be interpreted
  40. * as a null-terminated string encoded using UTF-8.
  41. *
  42. * If the type is image/png;base64, the memory
  43. * pointed to by "data" should be interpreted as
  44. * a base64 encoded PNG image.
  45. *
  46. * Other types are subject to the shared understanding
  47. * of the mime type by both the setter and retriever
  48. * of the property.
  49. */
  50. } jack_property_t;
  51. /**
  52. * Set a property on @c subject.
  53. *
  54. * See the above documentation for rules about @c subject and @c key.
  55. * @param subject The subject to set the property on.
  56. * @param key The key of the property.
  57. * @param value The value of the property.
  58. * @param type The MIME type of the property. See the discussion of
  59. * types in the definition of jack_property_t above.
  60. * @return 0 on success.
  61. */
  62. int
  63. jack_set_property(jack_client_t*,
  64. jack_uuid_t subject,
  65. const char* key,
  66. const char* value,
  67. const char* type);
  68. /**
  69. * Get a property on @c subject.
  70. *
  71. * @param subject The subject to get the property from.
  72. * @param key The key of the property.
  73. * @param value Set to the value of the property if found, or NULL otherwise.
  74. * The caller must free this value with jack_free().
  75. * @param type The MIME type of the property if set, or
  76. * NULL. See the discussion of types in the definition of
  77. * jack_property_t above. If non-null, the caller must free
  78. * this value with jack_free().
  79. *
  80. * @return 0 on success, -1 if the @c subject has no @c key property.
  81. */
  82. int
  83. jack_get_property(jack_uuid_t subject,
  84. const char* key,
  85. char** value,
  86. char** type);
  87. /**
  88. * A description of a subject (a set of properties).
  89. */
  90. typedef struct {
  91. jack_uuid_t subject; /**< The subject being described. */
  92. jack_property_t* properties; /**< An array of properties. */
  93. } jack_description_t;
  94. /**
  95. * Free a description.
  96. */
  97. void
  98. jack_free_description(jack_description_t* desc);
  99. /**
  100. * Get a description of @c subject.
  101. * @param subject The subject to get all properties of.
  102. * @param desc Set to the description of subject if found, or NULL otherwise.
  103. * The caller must free this value with jack_free_desription().
  104. * @return 0 on success, -1 if no @c subject with any properties exists.
  105. */
  106. int
  107. jack_get_properties (jack_uuid_t subject,
  108. jack_description_t* desc);
  109. /**
  110. * Get descriptions for all subjects with metadata.
  111. * @param subject The subject to get all properties of.
  112. * @param descs Set to a NULL-terminated array of descriptions.
  113. * The caller must free each of these with jack_free_desription(),
  114. * and the array itself with jack_free().
  115. * @return 0 on success.
  116. */
  117. int
  118. jack_get_all_properties (jack_description_t** descs);
  119. int jack_remove_property (jack_client_t*, jack_uuid_t subject, const char* key);
  120. int jack_remove_properties (jack_client_t*, jack_uuid_t subject);
  121. int jack_remove_all_properties (jack_client_t*);
  122. typedef enum {
  123. PropertyCreated,
  124. PropertyChanged,
  125. PropertyDeleted
  126. } jack_property_change_t;
  127. typedef void (*JackPropertyChangeCallback)(jack_uuid_t subject,
  128. const char* key,
  129. jack_property_change_t change,
  130. void* arg);
  131. int jack_set_property_change_callback (jack_client_t* client,
  132. JackPropertyChangeCallback callback,
  133. void *arg);
  134. #ifdef __cplusplus
  135. } /* namespace */
  136. #endif
  137. /**
  138. * @}
  139. */
  140. #endif /* __jack_metadata_h__ */