jack2 codebase
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.

323 lines
11KB

  1. /*
  2. Copyright (C) 2011-2014 David Robillard
  3. Copyright (C) 2013 Paul Davis
  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. /**
  17. * @file jack/metadata.h
  18. * @ingroup publicheader
  19. * @brief JACK Metadata API
  20. *
  21. */
  22. #ifndef __jack_metadata_h__
  23. #define __jack_metadata_h__
  24. #include <jack/types.h>
  25. #ifdef __cplusplus
  26. extern "C" {
  27. #endif
  28. /**
  29. * @defgroup Metadata Metadata API.
  30. * @{
  31. */
  32. /**
  33. * A single property (key:value pair).
  34. *
  35. * Although there is no semantics imposed on metadata keys and values, it is
  36. * much less useful to use it to associate highly structured data with a port
  37. * (or client), since this then implies the need for some (presumably
  38. * library-based) code to parse the structure and be able to use it.
  39. *
  40. * The real goal of the metadata API is to be able to tag ports (and clients)
  41. * with small amounts of data that is outside of the core JACK API but
  42. * nevertheless useful.
  43. */
  44. typedef struct {
  45. /** The key of this property (URI string). */
  46. const char* key;
  47. /** The property value (null-terminated string). */
  48. const char* data;
  49. /**
  50. * Type of data, either a MIME type or URI.
  51. *
  52. * If type is NULL or empty, the data is assumed to be a UTF-8 encoded
  53. * string (text/plain). The data is a null-terminated string regardless of
  54. * type, so values can always be copied, but clients should not try to
  55. * interpret values of an unknown type.
  56. *
  57. * Example values:
  58. * - image/png;base64 (base64 encoded PNG image)
  59. * - http://www.w3.org/2001/XMLSchema#int (integer)
  60. *
  61. * Official types are preferred, but clients may use any syntactically
  62. * valid MIME type (which start with a type and slash, like "text/...").
  63. * If a URI type is used, it must be a complete absolute URI
  64. * (which start with a scheme and colon, like "http:").
  65. */
  66. const char* type;
  67. } jack_property_t;
  68. /**
  69. * Set a property on @p subject.
  70. *
  71. * See the above documentation for rules about @p subject and @p key.
  72. * @param subject The subject to set the property on.
  73. * @param key The key of the property.
  74. * @param value The value of the property.
  75. * @param type The type of the property. See the discussion of
  76. * types in the definition of jack_property_t above.
  77. * @return 0 on success.
  78. */
  79. int
  80. jack_set_property(jack_client_t*,
  81. jack_uuid_t subject,
  82. const char* key,
  83. const char* value,
  84. const char* type);
  85. /**
  86. * Get a property on @p subject.
  87. *
  88. * @param subject The subject to get the property from.
  89. * @param key The key of the property.
  90. * @param value Set to the value of the property if found, or NULL otherwise.
  91. * The caller must free this value with jack_free().
  92. * @param type The type of the property if set, or NULL. See the discussion
  93. * of types in the definition of jack_property_t above.
  94. * If non-null, the caller must free this value with jack_free().
  95. *
  96. * @return 0 on success, -1 if the @p subject has no @p key property.
  97. */
  98. int
  99. jack_get_property(jack_uuid_t subject,
  100. const char* key,
  101. char** value,
  102. char** type);
  103. /**
  104. * A description of a subject (a set of properties).
  105. */
  106. typedef struct {
  107. jack_uuid_t subject; /**< Subject being described. */
  108. uint32_t property_cnt; /**< Number of elements in "properties". */
  109. jack_property_t* properties; /**< Array of properties. */
  110. uint32_t property_size; /**< Private, do not use. */
  111. } jack_description_t;
  112. /**
  113. * Free a description.
  114. *
  115. * @param desc a jack_description_t whose associated memory will all be released
  116. * @param free_description_itself if non-zero, then @param desc will also be passed to free()
  117. */
  118. void
  119. jack_free_description (jack_description_t* desc, int free_description_itself);
  120. /**
  121. * Get a description of @p subject.
  122. * @param subject The subject to get all properties of.
  123. * @param desc Set to the description of subject if found, or NULL otherwise.
  124. * The caller must free this value with jack_free_description().
  125. * @return the number of properties, -1 if no @p subject with any properties exists.
  126. */
  127. int
  128. jack_get_properties (jack_uuid_t subject,
  129. jack_description_t* desc);
  130. /**
  131. * Get descriptions for all subjects with metadata.
  132. * @param descs Set to an array of descriptions.
  133. * The caller must free each of these with jack_free_description(),
  134. * and the array itself with jack_free().
  135. * @return the number of descriptions, or -1 on error.
  136. */
  137. int
  138. jack_get_all_properties (jack_description_t** descs);
  139. /**
  140. * Remove a single property on a subject.
  141. *
  142. * @param client The JACK client making the request to remove the property.
  143. * @param subject The subject to remove the property from.
  144. * @param key The key of the property to be removed.
  145. *
  146. * @return 0 on success, -1 otherwise
  147. */
  148. int jack_remove_property (jack_client_t* client, jack_uuid_t subject, const char* key);
  149. /**
  150. * Remove all properties on a subject.
  151. *
  152. * @param client The JACK client making the request to remove some properties.
  153. * @param subject The subject to remove all properties from.
  154. *
  155. * @return a count of the number of properties removed, or -1 on error.
  156. */
  157. int jack_remove_properties (jack_client_t* client, jack_uuid_t subject);
  158. /**
  159. * Remove all properties.
  160. *
  161. * WARNING!! This deletes all metadata managed by a running JACK server.
  162. * Data lost cannot be recovered (though it can be recreated by new calls
  163. * to jack_set_property()).
  164. *
  165. * @param client The JACK client making the request to remove all properties
  166. *
  167. * @return 0 on success, -1 otherwise
  168. */
  169. int jack_remove_all_properties (jack_client_t* client);
  170. typedef enum {
  171. PropertyCreated,
  172. PropertyChanged,
  173. PropertyDeleted
  174. } jack_property_change_t;
  175. /**
  176. * Prototype for the client supplied function that is called by the
  177. * engine anytime a property or properties have been modified.
  178. *
  179. * Note that when the key is empty, it means all properties have been
  180. * modified. This is often used to indicate that the removal of all keys.
  181. *
  182. * @param subject The subject the change relates to, this can be either a client or port
  183. * @param key The key of the modified property (URI string)
  184. * @param change Wherever the key has been created, changed or deleted
  185. * @param arg pointer to a client supplied structure
  186. */
  187. typedef void (*JackPropertyChangeCallback)(jack_uuid_t subject,
  188. const char* key,
  189. jack_property_change_t change,
  190. void* arg);
  191. /**
  192. * Arrange for @p client to call @p callback whenever a property is created,
  193. * changed or deleted.
  194. *
  195. * @param client the JACK client making the request
  196. * @param callback the function to be invoked when a property change occurs
  197. * @param arg the argument to be passed to @param callback when it is invoked
  198. *
  199. * @return 0 success, -1 otherwise.
  200. */
  201. int jack_set_property_change_callback (jack_client_t* client,
  202. JackPropertyChangeCallback callback,
  203. void* arg);
  204. /**
  205. * A value that identifies what the hardware port is connected to (an external
  206. * device of some kind). Possible values might be "E-Piano" or "Master 2 Track".
  207. */
  208. extern const char* JACK_METADATA_CONNECTED;
  209. /**
  210. * The supported event types of an event port.
  211. *
  212. * This is a kludge around Jack only supporting MIDI, particularly for OSC.
  213. * This property is a comma-separated list of event types, currently "MIDI" or
  214. * "OSC". If this contains "OSC", the port may carry OSC bundles (first byte
  215. * '#') or OSC messages (first byte '/'). Note that the "status byte" of both
  216. * OSC events is not a valid MIDI status byte, so MIDI clients that check the
  217. * status byte will gracefully ignore OSC messages if the user makes an
  218. * inappropriate connection.
  219. */
  220. extern const char* JACK_METADATA_EVENT_TYPES;
  221. /**
  222. * A value that should be shown when attempting to identify the
  223. * specific hardware outputs of a client. Typical values might be
  224. * "ADAT1", "S/PDIF L" or "MADI 43".
  225. */
  226. extern const char* JACK_METADATA_HARDWARE;
  227. /**
  228. * A value with a MIME type of "image/png;base64" that is an encoding of an
  229. * NxN (with 32 < N <= 128) image to be used when displaying a visual
  230. * representation of that client or port.
  231. */
  232. extern const char* JACK_METADATA_ICON_LARGE;
  233. /**
  234. * The name of the icon for the subject (typically client).
  235. *
  236. * This is used for looking up icons on the system, possibly with many sizes or
  237. * themes. Icons should be searched for according to the freedesktop Icon
  238. *
  239. * Theme Specification:
  240. * https://specifications.freedesktop.org/icon-theme-spec/icon-theme-spec-latest.html
  241. */
  242. extern const char* JACK_METADATA_ICON_NAME;
  243. /**
  244. * A value with a MIME type of "image/png;base64" that is an encoding of an
  245. * NxN (with N <=32) image to be used when displaying a visual representation
  246. * of that client or port.
  247. */
  248. extern const char* JACK_METADATA_ICON_SMALL;
  249. /**
  250. * Order for a port.
  251. *
  252. * This is used to specify the best order to show ports in user interfaces.
  253. * The value MUST be an integer. There are no other requirements, so there may
  254. * be gaps in the orders for several ports. Applications should compare the
  255. * orders of ports to determine their relative order, but must not assign any
  256. * other relevance to order values.
  257. *
  258. * It is encouraged to use http://www.w3.org/2001/XMLSchema#int as the type.
  259. */
  260. extern const char* JACK_METADATA_ORDER;
  261. /**
  262. * A value that should be shown to the user when displaying a port to the user,
  263. * unless the user has explicitly overridden that a request to show the port
  264. * name, or some other key value.
  265. */
  266. extern const char* JACK_METADATA_PRETTY_NAME;
  267. /**
  268. */
  269. extern const char* JACK_METADATA_PORT_GROUP;
  270. /**
  271. * The type of an audio signal.
  272. *
  273. * This property allows audio ports to be tagged with a "meaning". The value
  274. * is a simple string. Currently, the only type is "CV", for "control voltage"
  275. * ports. Hosts SHOULD be take care to not treat CV ports as audibile and send
  276. * their output directly to speakers. In particular, CV ports are not
  277. * necessarily periodic at all and may have very high DC.
  278. */
  279. extern const char* JACK_METADATA_SIGNAL_TYPE;
  280. /**
  281. * @}
  282. */
  283. #ifdef __cplusplus
  284. } /* namespace */
  285. #endif
  286. #endif /* __jack_metadata_h__ */