annotate win32-mingw/include/lo/lo.h @ 169:223a55898ab9 tip default

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