| lo.h | | lo.h | |
|
| | | /* | |
| | | * Copyright (C) 2004 Steve Harris | |
| | | * | |
| | | * This program is free software; you can redistribute it and/or modify | |
| | | * it under the terms of the GNU General Public License as published by | |
| | | * the Free Software Foundation; either version 2 of the License, or | |
| | | * (at your option) any later version. | |
| | | * | |
| | | * This program is distributed in the hope that it will be useful, | |
| | | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| | | * GNU General Public License for more details. | |
| | | * | |
| | | * $Id: lo.h,v 1.9 2004/03/24 23:33:50 swh Exp $ | |
| | | */ | |
| | | | |
| #ifndef LO_H | | #ifndef LO_H | |
| #define LO_H | | #define LO_H | |
| | | | |
|
| | | #ifdef __cplusplus | |
| | | extern "C" { | |
| | | #endif | |
| | | | |
| | | /** | |
| | | * \file lo.h The liblo main headerfile and high-level API functions. | |
| | | */ | |
| | | | |
| | | #include "lo/lo_endian.h" | |
| #include "lo/lo_types.h" | | #include "lo/lo_types.h" | |
|
| | | #include "lo/lo_osc_types.h" | |
| #include "lo/lo_errors.h" | | #include "lo/lo_errors.h" | |
| #include "lo/lo_lowlevel.h" | | #include "lo/lo_lowlevel.h" | |
|
| | | #include "lo/lo_backcompat.h" | |
| | | | |
|
| /* | | /** | |
| * lo_target_new: declares an OSC destination IP address and port number. | | * \defgroup liblo High-level OSC API | |
| * | | * | |
|
| * passing NULL for address targets localhost. | | * Defines the high-level API functions neccesary to implement OSC support. | |
| | | * Should be adequate for most applications, but ig you require lower level | |
| | | * control you can use the functions defined in lo_lowlevel.h. | |
| | | * @{ | |
| */ | | */ | |
|
| lo_target lo_target_new(const char *adddress, const char *port); | | | |
| | | | |
|
| /* | | /** | |
| * lo_target_free: frees the memory allocated by lo_target_new | | * \brief Declare an OSC destination, given IP address and port number. | |
| | | * | |
| | | * \param host An IP address or number, or NULL for the local machine. | |
| | | * \param port a decimal port number or service name. | |
| | | * | |
| | | * The lo_address object may be used as the target of OSC messages. | |
| */ | | */ | |
|
| void lo_target_free(lo_target t); | | lo_address lo_address_new(const char *host, const char *port); | |
| | | | |
|
| /* | | /** | |
| * lo_send: sends a OSC formatted message to target targ. | | * \brief Create a lo_address object from an OSC URL. | |
| | | * | |
| | | * example: osc://localhost:4444/my/path/ | |
| | | */ | |
| | | lo_address lo_address_new_from_url(const char *url); | |
| | | | |
| | | /** | |
| | | * \brief Free the memory used by the lo_address object | |
| | | */ | |
| | | void lo_address_free(lo_address t); | |
| | | | |
| | | /** | |
| | | * \brief Send a OSC formatted message to the address specified. | |
| | | * | |
| | | * \param targ The target OSC address | |
| | | * \param path The OSC path the message will be delivered to | |
| | | * \param type The types of the data items in the message, types are define | |
| | | d in | |
| | | * lo_types_common.h | |
| | | * \param ... The data values to be transmitted. The types of the arguments | |
| | | * passed here must agree with the types specified in the type parameter. | |
| | | * | |
| | | * example:<br> | |
| | | * lo_send(t, "/foo/bar", "ff", 0.1f, 23.0f); | |
| * | | * | |
|
| * example: | | | |
| * lo_send(t, "/foo/bar", "ff", 0.1f, 23.0f); | | | |
| * returns -1 on failure. | | * returns -1 on failure. | |
| */ | | */ | |
|
| int lo_send(lo_target targ, const char *path, const char *type, ...); | | int lo_send(lo_address targ, const char *path, const char *type, ...); | |
| | | | |
|
| /* | | /** | |
| * lo_target_errno: returns the error number from the last failed lo_send o | | * \brief Return the error number from the last failed lo_send or | |
| r | | * lo_address_new call | |
| * lo_target_new call | | | |
| */ | | */ | |
|
| int lo_target_errno(lo_target t); | | int lo_address_errno(lo_address a); | |
| | | | |
|
| /* | | /** | |
| * lo_target_errstr: returns the error string from the last failed lo_send | | * \brief Return the error string from the last failed lo_send or | |
| or | | * lo_address_new call | |
| * lo_target_new call | | | |
| */ | | */ | |
|
| const char *lo_target_errstr(lo_target t); | | const char *lo_address_errstr(lo_address a); | |
| | | | |
|
| /* | | /** | |
| * lo_server_thread_new: creates a new server thread to handle incoming OSC | | * \brief Create a new server thread to handle incoming OSC | |
| * messages. | | * messages. | |
| * | | * | |
|
| * server threads take care of the message reception and dispatch by | | * Server threads take care of the message reception and dispatch by | |
| * transparently creating a systme thread to handle incoming messages. | | * transparently creating a systme thread to handle incoming messages. | |
| * Use this if you do not want to handle the threading yourself. | | * Use this if you do not want to handle the threading yourself. | |
|
| | | * | |
| | | * \param port If NULL is passed then an unused port will be chosen by the | |
| | | * sytem, its number may be retreived with lo_server_thread_get_port() | |
| | | * so it can be passed to clients. Otherwise a decimal port number or servi | |
| | | ce | |
| | | * name may be passed. | |
| | | * \param err_h A function that will be called in the event of an error bei | |
| | | ng | |
| | | * raised. The function prototype is defined in lo_types.h | |
| */ | | */ | |
| lo_server_thread lo_server_thread_new(const char *port, lo_err_handler err_
h); | | lo_server_thread lo_server_thread_new(const char *port, lo_err_handler err_
h); | |
| | | | |
|
| /* | | /** | |
| * lo_server_add_method: adds an OSC method to the specifed server thread | | * \brief Add an OSC method to the specifed server thread. | |
| | | * | |
| | | * \param st The server thread the method is to be added to. | |
| | | * \param path The OSC path to register the method to. If NULL is passed th | |
| | | e | |
| | | * method will match all paths. | |
| | | * \param typespec The typespec the method accepts. Incoming messages with | |
| | | * similar typespecs (e.g. ones with numerical types in the same position) | |
| | | will | |
| | | * be coerced to the typespec given here. | |
| | | * \param h The method handler callback function that will be called it a | |
| | | * matching message is received | |
| | | * \param user_data A value that will be passed to the callback function, h | |
| | | , | |
| | | * when its invoked matching from this method. | |
| */ | | */ | |
| lo_method lo_server_thread_add_method(lo_server_thread st, const char *path
, | | lo_method lo_server_thread_add_method(lo_server_thread st, const char *path
, | |
| const char *typespec, lo_method_handler h, | | const char *typespec, lo_method_handler h, | |
| void *user_data); | | void *user_data); | |
| | | | |
|
| /* | | /** | |
| * lo_server_thread_start: starts teh server thread | | * \brief Start the server thread | |
| | | * | |
| | | * \param st the server thread to start. | |
| */ | | */ | |
| void lo_server_thread_start(lo_server_thread st); | | void lo_server_thread_start(lo_server_thread st); | |
| | | | |
|
| /* | | /** | |
| * lo_blob_new: create a new OSC blob type. | | * \brief Return the port number that the server thread has bound to. | |
| | | */ | |
| | | int lo_server_thread_get_port(lo_server_thread st); | |
| | | | |
| | | /** | |
| | | * \brief Return a URL describing the address of the server thread. | |
| | | * | |
| | | * Return value must be free()'d to reclaim memory. | |
| | | */ | |
| | | char *lo_server_thread_get_url(lo_server_thread st); | |
| | | | |
| | | /** | |
| | | * \brief Create a new OSC blob type. | |
| | | * | |
| | | * \param size The ammount of space to allocate in the blob structure. | |
| | | * \param data The data that will be used to initialise the blob, should be | |
| | | * size bytes long. | |
| */ | | */ | |
| lo_blob lo_blob_new(int32_t size, void *data); | | lo_blob lo_blob_new(int32_t size, void *data); | |
| | | | |
|
| /* | | /** | |
| * lo_blob_datasize: returns the ammount of valid data in a lo blob object. | | * \brief Return the ammount of valid data in a lo blob object. | |
| * | | * | |
|
| * If you want to know the storage size, use lo_arg_size | | * If you want to know the storage size, use lo_arg_size(). | |
| */ | | */ | |
| uint32_t lo_blob_datasize(lo_blob b); | | uint32_t lo_blob_datasize(lo_blob b); | |
| | | | |
|
| /* | | /** | |
| * lo_blob_dataptr: return a pointer to the start of hte blob data | | * \brief Return a pointer to the start of the blob data to allow contents | |
| | | to | |
| | | * be changed. | |
| */ | | */ | |
| void *lo_blob_dataptr(lo_blob b); | | void *lo_blob_dataptr(lo_blob b); | |
| | | | |
|
| | | /** @} */ | |
| | | | |
| | | #include "lo/lo_macros.h" | |
| | | | |
| | | #ifdef __cplusplus | |
| | | } | |
| | | #endif | |
| | | | |
| #endif | | #endif | |
| | | | |
End of changes. 26 change blocks. |
| 36 lines changed or deleted | | 140 lines changed or added | |
|
| lo_lowlevel.h | | lo_lowlevel.h | |
|
| | | /* | |
| | | * Copyright (C) 2004 Steve Harris | |
| | | * | |
| | | * This program is free software; you can redistribute it and/or modify | |
| | | * it under the terms of the GNU General Public License as published by | |
| | | * the Free Software Foundation; either version 2 of the License, or | |
| | | * (at your option) any later version. | |
| | | * | |
| | | * This program is distributed in the hope that it will be useful, | |
| | | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| | | * GNU General Public License for more details. | |
| | | * | |
| | | * $Id: lo_lowlevel.h,v 1.8 2004/03/26 16:12:42 swh Exp $ | |
| | | */ | |
| | | | |
| #ifndef LO_LOWLEVEL_H | | #ifndef LO_LOWLEVEL_H | |
| #define LO_LOWLEVEL_H | | #define LO_LOWLEVEL_H | |
| | | | |
|
| | | #include "lo/lo_osc_types.h" | |
| | | | |
| | | #ifdef __cplusplus | |
| | | extern "C" { | |
| | | #endif | |
| | | | |
| #include "lo/lo_types.h" | | #include "lo/lo_types.h" | |
| #include "lo/lo_errors.h" | | #include "lo/lo_errors.h" | |
| | | | |
|
| /* | | /** | |
| * lo_send_message: sends a lo_message object to target targ | | * \defgroup liblolowlevel Low-level OSC API | |
| * | | * | |
|
| * This is slightly more efficient than lo_send if you want to send a lot o | | * Use these functions if you require more precices control over OSC messag | |
| f | | e | |
| * similar messages | | * contruction or handling that what is provided in the high-level function | |
| | | s | |
| | | * described in liblo. | |
| | | * @{ | |
| */ | | */ | |
|
| int lo_send_message(lo_target targ, const char *path, lo_message msg); | | | |
| | | | |
|
| /* | | /** | |
| * lo_target_errno: returns the error number from the last failed lo_send o | | * \brief Type used to represent numerical values in conversions between OS | |
| r | | C | |
| * lo_target_new call | | * types. | |
| */ | | */ | |
|
| int lo_target_errno(lo_target t); | | typedef long double lo_hires; | |
| | | | |
|
| /* | | /** | |
| * lo_target_errstr: returns the error string from the last failed lo_send | | * \brief send a lo_message object to target targ | |
| or | | * | |
| * lo_target_new call | | * This is slightly more efficient than lo_send if you want to send a lot o | |
| | | f | |
| | | * similar messages. The messages are constructed with the lo_message_new() | |
| | | and | |
| | | * lo_message_add*() functions. | |
| */ | | */ | |
|
| const char *lo_target_errstr(lo_target t); | | int lo_send_message(lo_address targ, const char *path, lo_message msg); | |
| | | | |
|
| /* | | /** | |
| * lo_message_new: creates a new lo_message object | | * \brief Create a new lo_message object | |
| */ | | */ | |
| lo_message lo_message_new(); | | lo_message lo_message_new(); | |
| | | | |
|
| /* | | /** | |
| * lo_message_free: frees memoery allocated by lo_message_new | | * \brief Free memory allocated by lo_message_new and any subsequent | |
| | | * lo_message_add*() calls. | |
| */ | | */ | |
| void lo_message_free(lo_message m); | | void lo_message_free(lo_message m); | |
| | | | |
|
| /* | | /** | |
| * lo_message_add_*: adds a parameter of the appropriate type to message m | | * \brief Append a data item and typechar of the specified type to a messag | |
| | | e. | |
| | | * | |
| | | * The data will be added in OSC byteorder (bigendian). | |
| | | * | |
| | | * \param m The message to be extended. | |
| | | * \param a The data item. | |
| | | */ | |
| | | void lo_message_add_int32(lo_message m, int32_t a); | |
| | | | |
| | | /** | |
| | | * \brief Append a data item and typechar of the specified type to a messa | |
| | | ge. | |
| | | * See lo_message_add_int32() for details. | |
| */ | | */ | |
|
| void lo_message_add_int32(lo_message m, int a); | | | |
| void lo_message_add_float(lo_message m, float a); | | void lo_message_add_float(lo_message m, float a); | |
|
| | | | |
| | | /** | |
| | | * \brief Append a data item and typechar of the specified type to a messa | |
| | | ge. | |
| | | * See lo_message_add_int32() for details. | |
| | | */ | |
| void lo_message_add_string(lo_message m, char *a); | | void lo_message_add_string(lo_message m, char *a); | |
|
| | | | |
| | | /** | |
| | | * \brief Append a data item and typechar of the specified type to a messa | |
| | | ge. | |
| | | * See lo_message_add_int32() for details. | |
| | | */ | |
| void lo_message_add_blob(lo_message m, lo_blob a); | | void lo_message_add_blob(lo_message m, lo_blob a); | |
| | | | |
|
| /* | | /** | |
| * lo_is_*_type: identifies the class of the OSC type a | | * \brief Append a data item and typechar of the specified type to a messa | |
| | | ge. | |
| | | * See lo_message_add_int32() for details. | |
| */ | | */ | |
|
| int lo_is_numerical_type(char a); | | void lo_message_add_int64(lo_message m, int64_t a); | |
| int lo_is_string_type(char a); | | | |
| | | | |
|
| /* | | /** | |
| * lo_coerce: attempts to convert one OSC type to another | | * \brief Append a data item and typechar of the specified type to a messa | |
| | | ge. | |
| | | * See lo_message_add_int32() for details. | |
| | | */ | |
| | | void lo_message_add_timetag(lo_message m, lo_timetag a); | |
| | | | |
| | | /** | |
| | | * \brief Append a data item and typechar of the specified type to a messa | |
| | | ge. | |
| | | * See lo_message_add_int32() for details. | |
| | | */ | |
| | | void lo_message_add_double(lo_message m, double a); | |
| | | | |
| | | /** | |
| | | * \brief Append a data item and typechar of the specified type to a messa | |
| | | ge. | |
| | | * See lo_message_add_int32() for details. | |
| | | */ | |
| | | void lo_message_add_symbol(lo_message m, char *a); | |
| | | | |
| | | /** | |
| | | * \brief Append a data item and typechar of the specified type to a messa | |
| | | ge. | |
| | | * See lo_message_add_int32() for details. | |
| | | */ | |
| | | void lo_message_add_char(lo_message m, char a); | |
| | | | |
| | | /** | |
| | | * \brief Append a data item and typechar of the specified type to a messa | |
| | | ge. | |
| | | * See lo_message_add_int32() for details. | |
| | | */ | |
| | | void lo_message_add_midi(lo_message m, uint8_t a[4]); | |
| | | | |
| | | /** | |
| | | * \brief Append a data item and typechar of the specified type to a messa | |
| | | ge. | |
| | | * See lo_message_add_int32() for details. | |
| | | */ | |
| | | void lo_message_add_true(lo_message m); | |
| | | | |
| | | /** | |
| | | * \brief Append a data item and typechar of the specified type to a messa | |
| | | ge. | |
| | | * See lo_message_add_int32() for details. | |
| | | */ | |
| | | void lo_message_add_false(lo_message m); | |
| | | | |
| | | /** | |
| | | * \brief Append a data item and typechar of the specified type to a messa | |
| | | ge. | |
| | | * See lo_message_add_int32() for details. | |
| | | */ | |
| | | void lo_message_add_nil(lo_message m); | |
| | | | |
| | | /** | |
| | | * \brief Append a data item and typechar of the specified type to a messa | |
| | | ge. | |
| | | * See lo_message_add_int32() for details. | |
| | | */ | |
| | | void lo_message_add_infinitum(lo_message m); | |
| | | | |
| | | /** | |
| | | * \brief return true if the type specified has a numerical value, such as | |
| | | * LO_INT32, LO_FLOAT etc. | |
| * | | * | |
|
| * numerical types (eg int32, float etc.) may be converted to other numeric | | * \param a The type to be tested. | |
| al | | | |
| * types and string types (string and symbol) may be converted to the other | | | |
| * type. This is done automatically if a received message matches the path, | | | |
| but | | | |
| * not the exact types, and is coercible (ie. all numerical types in numeri | | | |
| cal | | | |
| * positions) | | | |
| */ | | */ | |
|
| void lo_coerce(char type_to, lo_arg *to, char type_from, lo_arg *from); | | int lo_is_numerical_type(lo_type a); | |
| | | | |
|
| /* | | /** | |
| * lo_hires_val: returns the numerical value of the given argument with the | | * \brief return true if the type specified has a textual value, such as | |
| * maximum natrive system precision. | | * LO_STRING or LO_SYMBOL. | |
| | | * | |
| | | * \param a The type to be tested. | |
| */ | | */ | |
|
| lo_hires lo_hires_val(char type, lo_arg *p); | | int lo_is_string_type(lo_type a); | |
| | | | |
|
| /* | | /** | |
| * lo_arg_size: returns the storage size of the given argument | | * \brief attempt to convert one OSC type to another. | |
| | | * | |
| | | * Numerical types (eg LO_INT32, LO_FLOAT etc.) may be converted to other | |
| | | * numerical types and string types (LO_STRING and LO_SYMBOL) may be conver | |
| | | ted | |
| | | * to the other type. This is done automatically if a received message matc | |
| | | hes | |
| | | * the path, but not the exact types, and is coercible (ie. all numerical | |
| | | * types in numerical positions). | |
| | | * | |
| | | * On failure no translation occurs and false is returned. | |
| | | * | |
| | | * \param type_to The type of the destination variable. | |
| | | * \param to A pointer to the destination variable. | |
| | | * \param type_from The type of the source variable. | |
| | | * \param from A pointer to the source variable. | |
| */ | | */ | |
|
| int lo_arg_size(char type, void *data); | | int lo_coerce(lo_type type_to, lo_arg *to, lo_type type_from, lo_arg *from)
; | |
| | | | |
|
| /* | | /** | |
| * lo_arg_host_endian: converts the speficed argument to host endianness | | * \brief return the numerical value of the given argument with the | |
| | | * maximum native system precision. | |
| */ | | */ | |
|
| void lo_arg_host_endian(char type, void *data); | | lo_hires lo_hires_val(lo_type type, lo_arg *p); | |
| | | | |
|
| /* | | /** | |
| * lo_message_free: frees the emeory used by the message | | * \brief Return the storage size, in bytes, of the given argument. | |
| */ | | */ | |
|
| void lo_message_free(lo_message m); | | size_t lo_arg_size(lo_type type, void *data); | |
| | | | |
|
| /* | | /** | |
| * lo_server_new: creates a new server instance. lo_servers block until the | | * \brief Convert the speficed argument to host endianness where neccesary. | |
| y | | * | |
| * receive OSC messages. if you want non-blocking behaviour see the | | * \param type The OSC type of the data item (eg. LO_FLOAT). | |
| * lo_server_thread_* functions | | * \param data A pointer to the data item to be converted. It is change | |
| | | * in-place. | |
| | | */ | |
| | | void lo_arg_host_endian(lo_type type, void *data); | |
| | | | |
| | | /** | |
| | | * \brief Create a new server instance. | |
| | | * | |
| | | * lo_server's block until they receive OSC messages. if you want non-block | |
| | | ing | |
| | | * behaviour see the lo_server_thread_* functions. | |
| | | * | |
| | | * \param port An decimal string for the port number the server is to liste | |
| | | n on | |
| | | * or the name of the service port you wish the server to use. Pass NULL if | |
| | | you | |
| | | * wish the OS to choose an unused port number for you. | |
| | | * \param err_h An error callback function that will be called if there is | |
| | | an | |
| | | * error in messge reception or server creation. Pass NULL if you do not wa | |
| | | nt | |
| | | * error handling. | |
| */ | | */ | |
| lo_server lo_server_new(const char *port, lo_err_handler err_h); | | lo_server lo_server_new(const char *port, lo_err_handler err_h); | |
| | | | |
|
| /* | | /** | |
| * lo_server_recv: wait for an OSC message to be received | | * \brief Free up memory used by the lo_server object | |
| | | */ | |
| | | void lo_server_free(lo_server s); | |
| | | | |
| | | /** | |
| | | * \brief Block, waiting for an OSC message to be received | |
| | | * | |
| | | * The return value is the number of bytes in the received message. The mes | |
| | | sage | |
| | | * will be dispatched to a matching method if one is found. | |
| */ | | */ | |
| int lo_server_recv(lo_server s); | | int lo_server_recv(lo_server s); | |
| | | | |
|
| /* | | /** | |
| * lo_server_add_method: adds an OSC method to the specifed server | | * \brief Add an OSC method to the specifed server. | |
| | | * | |
| | | * \param s The server the method is to be added to. | |
| | | * \param path The OSC path to register the method to. If NULL is passed th | |
| | | e | |
| | | * method will match all paths. | |
| | | * \param typespec The typespec the method accepts. Incoming messages with | |
| | | * similar typespecs (e.g. ones with numerical types in the same position) | |
| | | will | |
| | | * be coerced to the typespec given here. | |
| | | * \param h The method handler callback function that will be called it a | |
| | | * matching message is received | |
| | | * \param user_data A value that will be passed to the callback function, h | |
| | | , | |
| | | * when its invoked matching from this method. | |
| */ | | */ | |
| lo_method lo_server_add_method(lo_server s, const char *path, | | lo_method lo_server_add_method(lo_server s, const char *path, | |
| const char *typespec, lo_method_handler h, | | const char *typespec, lo_method_handler h, | |
| void *user_data); | | void *user_data); | |
| | | | |
|
| | | /** | |
| | | * \brief Return the port number that the server has bound to. | |
| | | * | |
| | | * Useful when NULL is passed for the port number and you wish to know how | |
| | | to | |
| | | * address the server. | |
| | | */ | |
| | | int lo_server_get_port(lo_server s); | |
| | | | |
| | | /** | |
| | | * \brief Return an OSC URL that can be used to contact the server. | |
| | | * | |
| | | * The return value should bee free()'d when it is no longer needed. | |
| | | */ | |
| | | char *lo_server_get_url(lo_server s); | |
| | | | |
| | | /** | |
| | | * \brief Return the protocol portion of an OSC URL, eg. udp, tcp. | |
| | | * | |
| | | * This library uses OSC URLs of the form: osc.prot://hostname:port/path if | |
| | | the | |
| | | * prot part is missing, UDP is assumed. | |
| | | * | |
| | | * The return value should bee free()'d when it is no longer needed. | |
| | | */ | |
| | | char *lo_url_get_protocol(const char *url); | |
| | | | |
| | | /** | |
| | | * \brief Return the hostname portion of an OSC URL. | |
| | | * | |
| | | * The return value should bee free()'d when it is no longer needed. | |
| | | */ | |
| | | char *lo_url_get_hostname(const char *url); | |
| | | | |
| | | /** | |
| | | * \brief Return the port portion of an OSC URL. | |
| | | * | |
| | | * The return value should bee free()'d when it is no longer needed. | |
| | | */ | |
| | | char *lo_url_get_port(const char *url); | |
| | | | |
| | | /** | |
| | | * \brief Return the path portion of an OSC URL. | |
| | | * | |
| | | * The return value should bee free()'d when it is no longer needed. | |
| | | */ | |
| | | char *lo_url_get_path(const char *url); | |
| | | | |
| | | /* utility functions */ | |
| | | | |
| | | /** | |
| | | * \brief A function to calculate the amount of OSC message space required | |
| | | by a | |
| | | * C char *. | |
| | | * | |
| | | * Returns the storage size in bytes, will always be a multiple of four. | |
| | | */ | |
| | | int lo_strsize(const char *s); | |
| | | | |
| | | /** | |
| | | * \brief A function to calculate the amount of OSC message space required | |
| | | by a | |
| | | * lo_blob object. | |
| | | * | |
| | | * Returns the storage size in bytes, will always be a multiple of four. | |
| | | */ | |
| | | uint32_t lo_blobsize(lo_blob b); | |
| | | | |
| | | /** \brief the real send function (don't call directly) */ | |
| | | int lo_send_internal(lo_address t, const char *file, const int line, | |
| | | const char *path, const char *types, ...); | |
| | | | |
| | | /** @} */ | |
| | | | |
| /* prettyprinters */ | | /* prettyprinters */ | |
| | | | |
|
| | | /** | |
| | | * \defgroup pp Prettyprinting functions | |
| | | * | |
| | | * These functions all print an ASCII representation of thier argument to | |
| | | * stdout. Useful for debugging. | |
| | | * @{ | |
| | | */ | |
| void lo_message_pp(lo_message m); | | void lo_message_pp(lo_message m); | |
|
| void lo_arg_pp(char type, void *data); | | void lo_arg_pp(lo_type type, void *data); | |
| void lo_server_pp(lo_server s); | | void lo_server_pp(lo_server s); | |
| void lo_method_pp(lo_method m); | | void lo_method_pp(lo_method m); | |
| void lo_method_pp_prefix(lo_method m, const char *p); | | void lo_method_pp_prefix(lo_method m, const char *p); | |
| void lo_server_thread_pp(lo_server_thread st); | | void lo_server_thread_pp(lo_server_thread st); | |
|
| | | /** @} */ | |
| | | | |
|
| /* utility functions */ | | #ifdef __cplusplus | |
| | | } | |
| int lo_strsize(const char *s); | | #endif | |
| | | | |
| uint32_t lo_blobsize(lo_blob b); | | | |
| | | | |
| #endif | | #endif | |
| | | | |
End of changes. 36 change blocks. |
| 66 lines changed or deleted | | 319 lines changed or added | |
|
| lo_types.h | | lo_types.h | |
|
| | | /* | |
| | | * Copyright (C) 2004 Steve Harris | |
| | | * | |
| | | * This program is free software; you can redistribute it and/or modify | |
| | | * it under the terms of the GNU General Public License as published by | |
| | | * the Free Software Foundation; either version 2 of the License, or | |
| | | * (at your option) any later version. | |
| | | * | |
| | | * This program is distributed in the hope that it will be useful, | |
| | | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| | | * GNU General Public License for more details. | |
| | | * | |
| | | * $Id: lo_types.h,v 1.6 2004/03/24 23:33:50 swh Exp $ | |
| | | */ | |
| | | | |
| #ifndef LO_TYPES_H | | #ifndef LO_TYPES_H | |
| #define LO_TYPES_H | | #define LO_TYPES_H | |
| | | | |
|
| | | #ifdef __cplusplus | |
| | | extern "C" { | |
| | | #endif | |
| | | | |
| #include <netdb.h> | | #include <netdb.h> | |
| #include <pthread.h> | | #include <pthread.h> | |
| | | | |
|
| /* basic OSC types */ | | #include "lo/lo_osc_types.h" | |
| #define LO_INT32 'i' | | | |
| #define LO_FLOAT 'f' | | | |
| #define LO_STRING 's' | | | |
| #define LO_BLOB 'b' | | | |
| | | | |
|
| /* extended OSC types */ | | /** | |
| #define LO_INT64 'h' | | * \brief A reference to an OSC service. | |
| #define LO_TIMETAG 't' | | * | |
| #define LO_DOUBLE 'd' | | * Created by calls to lo_address_new() or lo_address_new_from_url(). | |
| #define LO_SYMBOL 'S' | | */ | |
| #define LO_CHAR 'c' | | typedef void *lo_address; | |
| #define LO_MIDI 'm' | | | |
| #define LO_TRUE 'T' | | | |
| #define LO_FALSE 'F' | | | |
| #define LO_NIL 'N' | | | |
| #define LO_INFINITUM 'I' | | | |
| | | | |
|
| #define LO_MAX_MSG_SIZE 32768 | | /** | |
| | | * \brief A object to store an opaque binary data object. | |
| | | * | |
| | | * Can be passed over OSC using the 'b' type. Created by calls to lo_blob_n | |
| | | ew(). | |
| | | */ | |
| | | typedef void *lo_blob; | |
| | | | |
|
| typedef long double lo_hires; | | /** | |
| | | * \brief A low-level object used to represent messages passed over OSC. | |
| | | * | |
| | | * Created by calls to lo_message_new(), arguments can be added with calls | |
| | | to | |
| | | * lo_message_add_*(). | |
| | | */ | |
| | | typedef void *lo_message; | |
| | | | |
|
| typedef union { | | /** | |
| int32_t i; | | * \brief An object representing an method on a server. | |
| float f; | | * | |
| char *s; | | * Returned by calls to lo_server_thread_add_method() and | |
| } lo_arg; | | * lo_server_add_method(). | |
| | | */ | |
| | | typedef void *lo_method; | |
| | | | |
|
| struct _lo_method; | | /** | |
| | | * \brief An object representing an instance of an OSC server. | |
| | | * | |
| | | * Created by calls to lo_server_new(). If you with the library to take car | |
| | | e of | |
| | | * the threading as well you can just use server threads instead. | |
| | | */ | |
| | | typedef void *lo_server; | |
| | | | |
|
| typedef void (*lo_err_handler)(int num, const char *msg, const char *path); | | /** | |
| | | * \brief An object representing a thread containing an OSC server. | |
| | | * | |
| | | * Created by calls to lo_server_thread_new(). | |
| | | */ | |
| | | typedef void *lo_server_thread; | |
| | | | |
|
| | | /** | |
| | | * \brief A callback function to receive notifcation of an error in a serve | |
| | | r or | |
| | | * server thread. | |
| | | * | |
| | | * On callback the paramters will be set to the following values: | |
| | | * | |
| | | * \param num An error number that can be used to identify this condition. | |
| | | * \param msg An error message describing the condidtion. | |
| | | * \param where A string describing the place the error occured - typically | |
| | | * either a function call or method path. | |
| | | */ | |
| | | typedef void (*lo_err_handler)(int num, const char *msg, const char *where) | |
| | | ; | |
| | | | |
| | | /** | |
| | | * \brief A callback function to receive notifcation of matching message | |
| | | * arriving in the server or server thread. | |
| | | * | |
| | | * On callback the paramters will be set to the following values: | |
| | | * | |
| | | * \param path That path that the incoming message was sent to | |
| | | * \param types If you specided types in your method creation call then thi | |
| | | s | |
| | | * will match those and the incoming types will have been coerced to match, | |
| | | * otherwise it will be the types of the arguments of the incoming message. | |
| | | * \param argv An array of lo_arg types containing the values, e.g. if the | |
| | | * first argument of the incoming message is of type 'f' then the vlaue wil | |
| | | l be | |
| | | * found in argv[0]->f. | |
| | | * \param argc The number of argumets received. | |
| | | * \param msg A structure containing the original raw message as received. | |
| | | No | |
| | | * type coercion will have occured and the data will be in OSC byte order | |
| | | * (bigendian). | |
| | | * \param user_data This contains the user_data value passed in the call to | |
| | | * lo_server_thread_add_method. | |
| | | */ | |
| typedef int (*lo_method_handler)(const char *path, const char *types, | | typedef int (*lo_method_handler)(const char *path, const char *types, | |
|
| lo_arg **argv, int argc, void *data, | | lo_arg **argv, int argc, lo_message msg, | |
| void *user_data); | | void *user_data); | |
| | | | |
|
| typedef struct _lo_target { | | #ifdef __cplusplus | |
| char *address; | | } | |
| int socket; | | #endif | |
| char *port; | | | |
| struct addrinfo *ai; | | | |
| int errnum; | | | |
| const char *errstr; | | | |
| } *lo_target; | | | |
| | | | |
| typedef struct _lo_blob { | | | |
| uint32_t size; | | | |
| char data[]; | | | |
| } *lo_blob; | | | |
| | | | |
| typedef struct _lo_message { | | | |
| char *types; | | | |
| size_t typelen; | | | |
| size_t typesize; | | | |
| void *data; | | | |
| size_t datalen; | | | |
| size_t datasize; | | | |
| } *lo_message; | | | |
| | | | |
| typedef struct _lo_method { | | | |
| const char *path; | | | |
| const char *typespec; | | | |
| lo_method_handler handler; | | | |
| char *user_data; | | | |
| struct _lo_method *next; | | | |
| } *lo_method; | | | |
| | | | |
| typedef struct _lo_server { | | | |
| int socket; | | | |
| struct addrinfo *ai; | | | |
| lo_method first; | | | |
| lo_err_handler err_h; | | | |
| } *lo_server; | | | |
| | | | |
| typedef struct _lo_server_thread { | | | |
| lo_server s; | | | |
| pthread_t thread; | | | |
| } *lo_server_thread; | | | |
| | | | |
| #endif | | #endif | |
| | | | |
End of changes. 12 change blocks. |
| 68 lines changed or deleted | | 105 lines changed or added | |
|