annotate osx/include/lo/lo.h @ 79:91c729825bca pa_catalina

Update build for AUDIO_COMPONENT_FIX
author Chris Cannam
date Wed, 30 Oct 2019 12:40:34 +0000
parents fffb975dc0b1
children
rev   line source
matthiasm@27 1 /*
matthiasm@27 2 * Copyright (C) 2004 Steve Harris
matthiasm@27 3 *
matthiasm@27 4 * This program is free software; you can redistribute it and/or
matthiasm@27 5 * modify it under the terms of the GNU Lesser General Public License
matthiasm@27 6 * as published by the Free Software Foundation; either version 2.1
matthiasm@27 7 * of the License, or (at your option) any later version.
matthiasm@27 8 *
matthiasm@27 9 * This program is distributed in the hope that it will be useful,
matthiasm@27 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
matthiasm@27 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
matthiasm@27 12 * GNU Lesser General Public License for more details.
matthiasm@27 13 *
matthiasm@27 14 * $Id$
matthiasm@27 15 */
matthiasm@27 16
matthiasm@27 17 #ifndef LO_H
matthiasm@27 18 #define LO_H
matthiasm@27 19
matthiasm@27 20 #ifdef __cplusplus
matthiasm@27 21 extern "C" {
matthiasm@27 22 #endif
matthiasm@27 23
matthiasm@27 24 /**
matthiasm@27 25 * \file lo.h The liblo main headerfile and high-level API functions.
matthiasm@27 26 */
matthiasm@27 27
matthiasm@27 28 #include "lo/lo_endian.h"
matthiasm@27 29 #include "lo/lo_types.h"
matthiasm@27 30 #include "lo/lo_osc_types.h"
matthiasm@27 31 #include "lo/lo_errors.h"
matthiasm@27 32 #include "lo/lo_lowlevel.h"
matthiasm@27 33
matthiasm@27 34 /**
matthiasm@27 35 * \defgroup liblo High-level OSC API
matthiasm@27 36 *
matthiasm@27 37 * Defines the high-level API functions necessary to implement OSC support.
matthiasm@27 38 * Should be adequate for most applications, but if you require lower level
matthiasm@27 39 * control you can use the functions defined in lo_lowlevel.h
matthiasm@27 40 * @{
matthiasm@27 41 */
matthiasm@27 42
matthiasm@27 43 /**
matthiasm@27 44 * \brief Declare an OSC destination, given IP address and port number.
matthiasm@27 45 * Same as lo_address_new_with_proto(), but using UDP.
matthiasm@27 46 *
matthiasm@27 47 * \param host An IP address or number, or NULL for the local machine.
matthiasm@27 48 * \param port a decimal port number or service name.
matthiasm@27 49 *
matthiasm@27 50 * The lo_address object may be used as the target of OSC messages.
matthiasm@27 51 *
matthiasm@27 52 * Note: if you wish to receive replies from the target of this address, you
matthiasm@27 53 * must first create a lo_server_thread or lo_server object which will receive
matthiasm@27 54 * the replies. The last lo_server(_thread) object creted will be the receiver.
matthiasm@27 55 */
matthiasm@27 56 lo_address lo_address_new(const char *host, const char *port);
matthiasm@27 57
matthiasm@27 58 /**
matthiasm@27 59 * \brief Declare an OSC destination, given IP address and port number,
matthiasm@27 60 * specifying protocol.
matthiasm@27 61 *
matthiasm@27 62 * \param proto The protocol to use, must be one of LO_UDP, LO_TCP or LO_UNIX.
matthiasm@27 63 * \param host An IP address or number, or NULL for the local machine.
matthiasm@27 64 * \param port a decimal port number or service name.
matthiasm@27 65 *
matthiasm@27 66 * The lo_address object may be used as the target of OSC messages.
matthiasm@27 67 *
matthiasm@27 68 * Note: if you wish to receive replies from the target of this address, you
matthiasm@27 69 * must first create a lo_server_thread or lo_server object which will receive
matthiasm@27 70 * the replies. The last lo_server(_thread) object creted will be the receiver.
matthiasm@27 71 */
matthiasm@27 72 lo_address lo_address_new_with_proto(int proto, const char *host, const char *port);
matthiasm@27 73
matthiasm@27 74 /**
matthiasm@27 75 * \brief Create a lo_address object from an OSC URL.
matthiasm@27 76 *
matthiasm@27 77 * example: \c "osc.udp://localhost:4444/my/path/"
matthiasm@27 78 */
matthiasm@27 79 lo_address lo_address_new_from_url(const char *url);
matthiasm@27 80
matthiasm@27 81 /**
matthiasm@27 82 * \brief Free the memory used by the lo_address object
matthiasm@27 83 */
matthiasm@27 84 void lo_address_free(lo_address t);
matthiasm@27 85
matthiasm@27 86 /**
matthiasm@27 87 * \brief Set the Time-to-Live value for a given target address.
matthiasm@27 88 *
matthiasm@27 89 * This is required for sending multicast UDP messages. A value of 1
matthiasm@27 90 * (the usual case) keeps the message within the subnet, while 255
matthiasm@27 91 * means a global, unrestricted scope.
matthiasm@27 92 *
matthiasm@27 93 * \param t An OSC address.
matthiasm@27 94 * \param ttl An integer specifying the scope of a multicast UDP message.
matthiasm@27 95 */
matthiasm@27 96 void lo_address_set_ttl(lo_address t, int ttl);
matthiasm@27 97
matthiasm@27 98 /**
matthiasm@27 99 * \brief Get the Time-to-Live value for a given target address.
matthiasm@27 100 *
matthiasm@27 101 * \param t An OSC address.
matthiasm@27 102 * \return An integer specifying the scope of a multicast UDP message.
matthiasm@27 103 */
matthiasm@27 104 int lo_address_get_ttl(lo_address t);
matthiasm@27 105
matthiasm@27 106 /**
matthiasm@27 107 * \brief Send a OSC formatted message to the address specified.
matthiasm@27 108 *
matthiasm@27 109 * \param targ The target OSC address
matthiasm@27 110 * \param path The OSC path the message will be delivered to
matthiasm@27 111 * \param type The types of the data items in the message, types are defined in
matthiasm@27 112 * lo_osc_types.h
matthiasm@27 113 * \param ... The data values to be transmitted. The types of the arguments
matthiasm@27 114 * passed here must agree with the types specified in the type parameter.
matthiasm@27 115 *
matthiasm@27 116 * example:
matthiasm@27 117 * \code
matthiasm@27 118 * lo_send(t, "/foo/bar", "ff", 0.1f, 23.0f);
matthiasm@27 119 * \endcode
matthiasm@27 120 *
matthiasm@27 121 * \return -1 on failure.
matthiasm@27 122 */
matthiasm@27 123 int lo_send(lo_address targ, const char *path, const char *type, ...);
matthiasm@27 124
matthiasm@27 125 /**
matthiasm@27 126 * \brief Send a OSC formatted message to the address specified,
matthiasm@27 127 * from the same socket as the specificied server.
matthiasm@27 128 *
matthiasm@27 129 * \param targ The target OSC address
matthiasm@27 130 * \param from The server to send message from (can be NULL to use new socket)
matthiasm@27 131 * \param ts The OSC timetag timestamp at which the message will be processed
matthiasm@27 132 * (can be LO_TT_IMMEDIATE if you don't want to attach a timetag)
matthiasm@27 133 * \param path The OSC path the message will be delivered to
matthiasm@27 134 * \param type The types of the data items in the message, types are defined in
matthiasm@27 135 * lo_osc_types.h
matthiasm@27 136 * \param ... The data values to be transmitted. The types of the arguments
matthiasm@27 137 * passed here must agree with the types specified in the type parameter.
matthiasm@27 138 *
matthiasm@27 139 * example:
matthiasm@27 140 * \code
matthiasm@27 141 * serv = lo_server_new(NULL, err);
matthiasm@27 142 * lo_server_add_method(serv, "/reply", "ss", reply_handler, NULL);
matthiasm@27 143 * lo_send_from(t, serv, LO_TT_IMMEDIATE, "/foo/bar", "ff", 0.1f, 23.0f);
matthiasm@27 144 * \endcode
matthiasm@27 145 *
matthiasm@27 146 * \return on success, the number of bytes sent, or -1 on failure.
matthiasm@27 147 */
matthiasm@27 148 int lo_send_from(lo_address targ, lo_server from, lo_timetag ts,
matthiasm@27 149 const char *path, const char *type, ...);
matthiasm@27 150
matthiasm@27 151 /**
matthiasm@27 152 * \brief Send a OSC formatted message to the address specified, scheduled to
matthiasm@27 153 * be dispatch at some time in the future.
matthiasm@27 154 *
matthiasm@27 155 * \param targ The target OSC address
matthiasm@27 156 * \param ts The OSC timetag timestamp at which the message will be processed
matthiasm@27 157 * \param path The OSC path the message will be delivered to
matthiasm@27 158 * \param type The types of the data items in the message, types are defined in
matthiasm@27 159 * lo_osc_types.h
matthiasm@27 160 * \param ... The data values to be transmitted. The types of the arguments
matthiasm@27 161 * passed here must agree with the types specified in the type parameter.
matthiasm@27 162 *
matthiasm@27 163 * example:
matthiasm@27 164 * \code
matthiasm@27 165 * lo_timetag now;<br>
matthiasm@27 166 * lo_timetag_now(&now);<br>
matthiasm@27 167 * lo_send_timestamped(t, now, "/foo/bar", "ff", 0.1f, 23.0f);
matthiasm@27 168 * \endcode
matthiasm@27 169 *
matthiasm@27 170 * \return on success, the number of bytes sent, or -1 on failure.
matthiasm@27 171 */
matthiasm@27 172 int lo_send_timestamped(lo_address targ, lo_timetag ts, const char *path,
matthiasm@27 173 const char *type, ...);
matthiasm@27 174
matthiasm@27 175 /**
matthiasm@27 176 * \brief Return the error number from the last failed lo_send() or
matthiasm@27 177 * lo_address_new() call
matthiasm@27 178 */
matthiasm@27 179 int lo_address_errno(lo_address a);
matthiasm@27 180
matthiasm@27 181 /**
matthiasm@27 182 * \brief Return the error string from the last failed lo_send() or
matthiasm@27 183 * lo_address_new() call
matthiasm@27 184 */
matthiasm@27 185 const char *lo_address_errstr(lo_address a);
matthiasm@27 186
matthiasm@27 187 /**
matthiasm@27 188 * \brief Create a new server thread to handle incoming OSC
matthiasm@27 189 * messages.
matthiasm@27 190 *
matthiasm@27 191 * Server threads take care of the message reception and dispatch by
matthiasm@27 192 * transparently creating a system thread to handle incoming messages.
matthiasm@27 193 * Use this if you do not want to handle the threading yourself.
matthiasm@27 194 *
matthiasm@27 195 * \param port If NULL is passed then an unused port will be chosen by the
matthiasm@27 196 * system, its number may be retrieved with lo_server_thread_get_port()
matthiasm@27 197 * so it can be passed to clients. Otherwise a decimal port number, service
matthiasm@27 198 * name or UNIX domain socket path may be passed.
matthiasm@27 199 * \param err_h A function that will be called in the event of an error being
matthiasm@27 200 * raised. The function prototype is defined in lo_types.h
matthiasm@27 201 */
matthiasm@27 202 lo_server_thread lo_server_thread_new(const char *port, lo_err_handler err_h);
matthiasm@27 203
matthiasm@27 204 /**
matthiasm@27 205 * \brief Create a new server thread to handle incoming OSC
matthiasm@27 206 * messages, and join a UDP multicast group.
matthiasm@27 207 *
matthiasm@27 208 * Server threads take care of the message reception and dispatch by
matthiasm@27 209 * transparently creating a system thread to handle incoming messages.
matthiasm@27 210 * Use this if you do not want to handle the threading yourself.
matthiasm@27 211 *
matthiasm@27 212 * \param group The multicast group to join. See documentation on IP
matthiasm@27 213 * multicast for the acceptable address range; e.g., http://tldp.org/HOWTO/Multicast-HOWTO-2.html
matthiasm@27 214 * \param port If NULL is passed then an unused port will be chosen by the
matthiasm@27 215 * system, its number may be retrieved with lo_server_thread_get_port()
matthiasm@27 216 * so it can be passed to clients. Otherwise a decimal port number, service
matthiasm@27 217 * name or UNIX domain socket path may be passed.
matthiasm@27 218 * \param err_h A function that will be called in the event of an error being
matthiasm@27 219 * raised. The function prototype is defined in lo_types.h
matthiasm@27 220 */
matthiasm@27 221 lo_server_thread lo_server_thread_new_multicast(const char *group, const char *port,
matthiasm@27 222 lo_err_handler err_h);
matthiasm@27 223
matthiasm@27 224 /**
matthiasm@27 225 * \brief Create a new server thread to handle incoming OSC
matthiasm@27 226 * messages, specifying protocol.
matthiasm@27 227 *
matthiasm@27 228 * Server threads take care of the message reception and dispatch by
matthiasm@27 229 * transparently creating a system thread to handle incoming messages.
matthiasm@27 230 * Use this if you do not want to handle the threading yourself.
matthiasm@27 231 *
matthiasm@27 232 * \param port If NULL is passed then an unused port will be chosen by the
matthiasm@27 233 * system, its number may be retrieved with lo_server_thread_get_port()
matthiasm@27 234 * so it can be passed to clients. Otherwise a decimal port number, service
matthiasm@27 235 * name or UNIX domain socket path may be passed.
matthiasm@27 236 * \param proto The protocol to use, should be one of LO_UDP, LO_TCP or LO_UNIX.
matthiasm@27 237 * \param err_h A function that will be called in the event of an error being
matthiasm@27 238 * raised. The function prototype is defined in lo_types.h
matthiasm@27 239 */
matthiasm@27 240 lo_server_thread lo_server_thread_new_with_proto(const char *port, int proto,
matthiasm@27 241 lo_err_handler err_h);
matthiasm@27 242
matthiasm@27 243 /**
matthiasm@27 244 * \brief Free memory taken by a server thread
matthiasm@27 245 *
matthiasm@27 246 * Frees the memory, and, if currently running will stop the associated thread.
matthiasm@27 247 */
matthiasm@27 248 void lo_server_thread_free(lo_server_thread st);
matthiasm@27 249
matthiasm@27 250 /**
matthiasm@27 251 * \brief Add an OSC method to the specifed server thread.
matthiasm@27 252 *
matthiasm@27 253 * \param st The server thread the method is to be added to.
matthiasm@27 254 * \param path The OSC path to register the method to. If NULL is passed the
matthiasm@27 255 * method will match all paths.
matthiasm@27 256 * \param typespec The typespec the method accepts. Incoming messages with
matthiasm@27 257 * similar typespecs (e.g. ones with numerical types in the same position) will
matthiasm@27 258 * be coerced to the typespec given here.
matthiasm@27 259 * \param h The method handler callback function that will be called it a
matthiasm@27 260 * matching message is received
matthiasm@27 261 * \param user_data A value that will be passed to the callback function, h,
matthiasm@27 262 * when its invoked matching from this method.
matthiasm@27 263 */
matthiasm@27 264 lo_method lo_server_thread_add_method(lo_server_thread st, const char *path,
matthiasm@27 265 const char *typespec, lo_method_handler h,
matthiasm@27 266 void *user_data);
matthiasm@27 267 /**
matthiasm@27 268 * \brief Delete an OSC method from the specifed server thread.
matthiasm@27 269 *
matthiasm@27 270 * \param st The server thread the method is to be removed from.
matthiasm@27 271 * \param path The OSC path of the method to delete. If NULL is passed the
matthiasm@27 272 * method will match the generic handler.
matthiasm@27 273 * \param typespec The typespec the method accepts.
matthiasm@27 274 */
matthiasm@27 275 void lo_server_thread_del_method(lo_server_thread st, const char *path,
matthiasm@27 276 const char *typespec);
matthiasm@27 277
matthiasm@27 278 /**
matthiasm@27 279 * \brief Start the server thread
matthiasm@27 280 *
matthiasm@27 281 * \param st the server thread to start.
matthiasm@27 282 * \return Less than 0 on failure, 0 on success.
matthiasm@27 283 */
matthiasm@27 284 int lo_server_thread_start(lo_server_thread st);
matthiasm@27 285
matthiasm@27 286 /**
matthiasm@27 287 * \brief Stop the server thread
matthiasm@27 288 *
matthiasm@27 289 * \param st the server thread to start.
matthiasm@27 290 * \return Less than 0 on failure, 0 on success.
matthiasm@27 291 */
matthiasm@27 292 int lo_server_thread_stop(lo_server_thread st);
matthiasm@27 293
matthiasm@27 294 /**
matthiasm@27 295 * \brief Return the port number that the server thread has bound to.
matthiasm@27 296 */
matthiasm@27 297 int lo_server_thread_get_port(lo_server_thread st);
matthiasm@27 298
matthiasm@27 299 /**
matthiasm@27 300 * \brief Return a URL describing the address of the server thread.
matthiasm@27 301 *
matthiasm@27 302 * Return value must be free()'d to reclaim memory.
matthiasm@27 303 */
matthiasm@27 304 char *lo_server_thread_get_url(lo_server_thread st);
matthiasm@27 305
matthiasm@27 306 /**
matthiasm@27 307 * \brief Return the lo_server for a lo_server_thread
matthiasm@27 308 *
matthiasm@27 309 * This function is useful for passing a thread's lo_server
matthiasm@27 310 * to lo_send_from().
matthiasm@27 311 */
matthiasm@27 312 lo_server lo_server_thread_get_server(lo_server_thread st);
matthiasm@27 313
matthiasm@27 314 /** \brief Return true if there are scheduled events (eg. from bundles) waiting
matthiasm@27 315 * to be dispatched by the thread */
matthiasm@27 316 int lo_server_thread_events_pending(lo_server_thread st);
matthiasm@27 317
matthiasm@27 318 /**
matthiasm@27 319 * \brief Create a new OSC blob type.
matthiasm@27 320 *
matthiasm@27 321 * \param size The amount of space to allocate in the blob structure.
matthiasm@27 322 * \param data The data that will be used to initialise the blob, should be
matthiasm@27 323 * size bytes long.
matthiasm@27 324 */
matthiasm@27 325 lo_blob lo_blob_new(int32_t size, const void *data);
matthiasm@27 326
matthiasm@27 327 /**
matthiasm@27 328 * \brief Free the memory taken by a blob
matthiasm@27 329 */
matthiasm@27 330 void lo_blob_free(lo_blob b);
matthiasm@27 331
matthiasm@27 332 /**
matthiasm@27 333 * \brief Return the amount of valid data in a lo_blob object.
matthiasm@27 334 *
matthiasm@27 335 * If you want to know the storage size, use lo_arg_size().
matthiasm@27 336 */
matthiasm@27 337 uint32_t lo_blob_datasize(lo_blob b);
matthiasm@27 338
matthiasm@27 339 /**
matthiasm@27 340 * \brief Return a pointer to the start of the blob data to allow contents to
matthiasm@27 341 * be changed.
matthiasm@27 342 */
matthiasm@27 343 void *lo_blob_dataptr(lo_blob b);
matthiasm@27 344
matthiasm@27 345 /** @} */
matthiasm@27 346
matthiasm@27 347 #include "lo/lo_macros.h"
matthiasm@27 348
matthiasm@27 349 #ifdef __cplusplus
matthiasm@27 350 }
matthiasm@27 351 #endif
matthiasm@27 352
matthiasm@27 353 #endif