O2 2.0
A communication protocol for interactive music and media applications.
o2.h
Go to the documentation of this file.
1// o2.h -- public header file for o2 system
2// Roger B. Dannenberg and Zhang Chi
3// see license.txt for license
4// June 2016
5
6#ifndef O2_H
7#define O2_H
8
9// Version is 2.0.0:
10#define O2_VERSION 0x020000
11
12#ifdef O2_NO_O2DISCOVERY
13#define O2_NO_HUB 1
14#endif
15#if defined(O2_NO_O2DISCOVERY) && defined(O2_NO_ZEROCONF)
16#error O2_NO_O2DISCOVERY and O2_NO_ZEROCONF are defined, therefore no discovery
17#endif
18#if !defined(O2_NO_O2DISCOVERY) && !defined(O2_NO_ZEROCONF)
19#warning O2DISCOVERY and ZEROCONF are *both* enabled
20#endif
21
22
23#include "o2base.h"
24#include "hostip.h"
25
26#ifdef __cplusplus
27extern "C" {
28#endif
29
311void o2_debug_flags(const char *flags);
312
320const char *o2_error_to_string(O2err i);
321
329typedef enum {
331 //
333
335 //
340
342 //
346
348 //
350
352 //
354
356 //
358
360 //
367
369 //
371
373 //
376
378 //
380
382 //
384
386 //
388
390 //
395
397 //
399
401 //
403
405 //
407
409 //
411
413 //
415
417 //
420
422 //
424
426 //
429 O2_NO_NETWORK = -20
430
432
433
435typedef enum {
437 //
439
441 //
446
448 //
454
457 //
469
472 //
488
490 //
497
499 //
503
505 //
513
515 //
529
531 //
532 O2_TAP = 8
534
538// Macros for o2 protocol
539/* an internal value, ignored in transmission but check against O2_MARKER in the
540 * argument list. Used to do primitive bounds checking */
541#define O2_MARKER_A (void *) 0xdeadbeefdeadbeefL
542#define O2_MARKER_B (void *) 0xf00baa23f00baa23L
543//#endif
544
581O2err o2_internet_enable(bool enable);
582
620O2err o2_network_enable(bool enable);
621
625typedef double O2time;
626
638typedef struct O2msg_data {
639 int32_t length; // msg length, not including this length field
640 // we could put a nice structure here, but alignment and network vs host
641 // byte ordering is confusing, so we use and int: flags are low-order bits,
642 // and ttl is (misc >> 8). Note: ttl starts at zero and is incremented
643 // each time the message is copied and forwarded to a tap. The message
644 // is not forwarded if the count exceeds 3 (O2_MAX_TAP_FORWARDING).
645 int32_t misc; // flags and ttl
655 char address[4];
657
658
663#define O2MEM_ALIGN 8
664#define O2MEM_ALIGNUP(s) ( ((s)+(O2MEM_ALIGN-1)) & ~(O2MEM_ALIGN-1) )
665#define O2MEM_BIT32_ALIGN_PTR(p) ((char *) (((size_t) (p)) & ~3))
666// returns the address of the byte AFTER the message
667#define O2_MSG_DATA_END(data) (PTR(&(data)->misc) + (data)->length)
668
669// find the next word-aligned string after str in a message:
670const char *o2_next_o2string(const char *str);
671// find the type string from o2_msg_data_ptr, skips initial ',':
672#define o2_msg_data_types(data) (o2_next_o2string((data)->address) + 1)
673#define o2_msg_types(msg) o2_msg_data_types(&msg->data)
674// find the first parameter of the message, given the type string address
675#define o2_msg_data_params(types) \
676 o2_next_o2string((const char *) ((intptr_t) (types) & ~3))
677
690typedef struct O2message {
691 union {
692 struct O2message *next;
694 };
695 O2msg_data data;
697
699#define O2_MSG_PAYLOAD(msg) PTR(&(msg)->data.misc)
700
701
708typedef struct O2blob {
709 uint32_t size;
710 char data[4];
712
713
717typedef enum {
718 // basic O2 types
719 O2_INT32 = 'i',
720 O2_FLOAT = 'f',
721 O2_STRING = 's',
722 O2_BLOB = 'b',
725
726 // extended O2 types
727 O2_INT64 = 'h',
728 O2_TIME = 't',
729 O2_DOUBLE = 'd',
730 O2_SYMBOL = 'S',
731 O2_CHAR = 'c',
732 O2_MIDI = 'm',
733 O2_TRUE = 'T',
734 O2_FALSE = 'F',
735 O2_NIL = 'N',
737
738 // O2 types
739 O2_BOOL = 'B',
740 O2_VECTOR = 'v',
741} O2type, *O2type_ptr;
742
743
764typedef union {
765 int32_t i32;
766 int32_t i;
767 int64_t i64;
768 int64_t h;
769 float f;
770 float f32;
771 double d;
772 double f64;
773 char s[4];
776 char S[4];
777 int c;
778 uint32_t m;
782 int32_t B;
783 struct {
784 int32_t len;
786 int32_t typ;
787 union {
788 int32_t *vi;
789 int64_t *vh;
790 double *vd;
791 float *vf;
792 // note that a blob is basically a vector of bytes;
793 // there is no type conversion from blob to vector though,
794 // and no vector of shorts or bytes because if you converted
795 // to a vector of int64_t, it would take 8x the message
796 // space, forcing us to allocate very big buffers to
797 // unpack messages.
798 };
799 } v;
800} O2arg, *O2arg_ptr;
801
802
803extern O2arg_ptr o2_got_start_array;
804extern O2arg_ptr o2_got_end_array;
805
806
813extern bool o2_stop_flag;
814
815/*
816 * A collection of cooperating O2 processes forms an
817 * *ensemble*. Ensembles must have unique names. This allows
818 * more than one ensemble to exist within a single network without
819 * conflict. For example, there could be two ensembles, "joe" and
820 * "sue", each with services named "synth." Since the ensemble
821 * names are different, joe's messages to the synth service go to
822 * joe's synth and not to sue's synth.
823 *
824 * Do not set, modify or free this variable! Consider it to be
825 * read-only. It is managed by O2 using #o2_initialize and #o2_finish.
826 */
827extern const char *o2_ensemble_name; // also used to detect initialization
828
829
838
839
848
849
880typedef void (*O2method_handler)(const o2_msg_data_ptr msg, const char *types,
881 O2arg_ptr *argv, int argc,
882 const void *user_data);
883
899O2err o2_initialize(const char *ensemble_name);
900
901
912int o2_version(char *version);
913
914
961int o2_memory(void *((*malloc)(size_t size)), void ((*free)(void *)),
962 char *first_chunk, int64_t size, bool mallocp);
963
964
990
991#ifndef O2_NO_HUB
1036O2err o2_hub(int version, const char *public_ip, const char *internal_ip,
1037 int tcp_port, int udp_port);
1038#endif
1039
1040
1080O2err o2_get_addresses(const char **public_ip, const char **internal_ip,
1081 int *port);
1082
1099const char *o2_get_proc_name(void);
1100
1114int o2_parse_name(const char *name, char *public_ip,
1115 char *internal_ip, int *port);
1116
1147O2err o2_service_new(const char *service_name);
1148
1149
1168
1169
1179
1180
1194const char *o2_service_name(int i);
1195
1196
1211int o2_service_type(int i);
1212
1213
1229const char *o2_service_process(int i);
1230
1231
1244const char *o2_service_tapper(int i);
1245
1246
1266const char *o2_service_properties(int i);
1267
1268
1281const char *o2_service_getprop(int i, const char *attr);
1282
1305int o2_service_search(int i, const char *attr, const char *value);
1306
1307
1335O2err o2_service_set_property(const char *service, const char *attr,
1336 const char *value);
1337
1338
1352O2err o2_service_property_free(const char *service, const char *attr);
1353
1354typedef enum {TAP_KEEP, TAP_RELIABLE, TAP_BEST_EFFORT} O2tap_send_mode;
1355
1421O2err o2_tap(const char *tappee, const char *tapper, O2tap_send_mode send_mode);
1422
1423
1435O2err o2_untap(const char *tappee, const char *tapper);
1436
1437
1450O2err o2_service_free(const char *service_name);
1451
1452
1483O2err o2_method_new(const char *path, const char *typespec,
1484 O2method_handler h, const void *user_data,
1485 bool coerce, bool parse);
1486
1487
1500O2err o2_method_free(const char *path);
1501
1502
1516void o2_message_drop_warning(const char *warn, o2_msg_data_ptr msg);
1517
1531void o2_drop_message(const char *warn, bool free_the_msg);
1532
1563 void (*warning)(const char *warn, o2_msg_data_ptr msg));
1564
1565
1585O2err o2_poll(void);
1586
1593int o2_run(int rate);
1594
1664int o2_status(const char *service);
1665
1666
1667#ifndef O2_NO_DEBUG
1683const char *o2_status_to_string(int status);
1684#endif
1685
1686
1728O2err o2_can_send(const char *service);
1729
1730
1735extern bool o2_clock_is_synchronized;
1736
1764int o2_roundtrip(double *mean, double *min);
1765
1766
1771typedef O2time (*o2_time_callback)(void *rock);
1772
1773
1801int o2_clock_set(o2_time_callback gettime, void *rock);
1802
1803 // turn off Doxygen report on #o2_send_marker
1829#define o2_send(path, time, ...) \
1830 o2_send_marker(path, time, false, \
1831 __VA_ARGS__, O2_MARKER_A, O2_MARKER_B)
1832 \
1834O2err o2_send_marker(const char *path, double time, int tcp_flag,
1835 const char *typestring, ...); // turn off Doxygen report on #o2_send_marker
1868#define o2_send_cmd(path, time, ...) \
1869 o2_send_marker(path, time, true, \
1870 __VA_ARGS__, O2_MARKER_A, O2_MARKER_B)
1871
1872
1884
1898O2time o2_time_get(void);
1899
1900
1906O2time o2_local_time(void);
1907
1930O2err o2_finish(void);
1931 // end of Basics
1933
1934
1935#ifndef O2_NO_OSC
1958O2err o2_osc_port_new(const char *service_name, int port_num,
1959 int tcp_flag);
1960
1977O2err o2_osc_port_free(int port_num);
1978
1979
2004O2err o2_osc_delegate(const char *service_name, const char *ip,
2005 int port_num, int tcp_flag);
2006
2019uint64_t o2_osc_time_offset(uint64_t offset); // end of OSC Interoperation
2021#endif
2022
2207O2blob_ptr o2_blob_new(uint32_t size);
2208
2209
2220O2err o2_send_start(void);
2221
2222
2224O2err o2_add_float(float f);
2225
2228O2err o2_add_string_or_symbol(O2type tcode, const char *s);
2229
2231#define o2_add_symbol(s) o2_add_string_or_symbol(O2_SYMBOL, s)
2232
2234#define o2_add_string(s) o2_add_string_or_symbol(O2_STRING, s)
2235
2239
2242O2err o2_add_blob_data(uint32_t size, void *data);
2243
2245O2err o2_add_int64(int64_t i);
2246
2249O2err o2_add_double_or_time(O2type tchar, double d);
2250
2252#define o2_add_double(d) o2_add_double_or_time(O2_DOUBLE, d)
2253
2255#define o2_add_time(t) o2_add_double_or_time(O2_TIME, t)
2256
2259O2err o2_add_int32_or_char(O2type tcode, int32_t i);
2260
2262#define o2_add_int32(i) o2_add_int32_or_char(O2_INT32, i)
2263
2265#define o2_add_char(c) o2_add_int32_or_char(O2_CHAR, c)
2266
2268O2err o2_add_midi(uint32_t m);
2269
2274
2276#define o2_add_true() o2_add_only_typecode(O2_TRUE);
2277
2279#define o2_add_false() o2_add_only_typecode(O2_FALSE);
2280
2284#define o2_add_tf(x) o2_add_only_typecode((x) != 0 ? O2_TRUE : O2_FALSE)
2285
2287#define o2_add_bool(x) o2_add_int32_or_char(O2_BOOL, (x) != 0)
2288
2290#define o2_add_nil() o2_add_only_typecode(O2_NIL);
2291
2293#define o2_add_infinitum() o2_add_only_typecode(O2_INFINITUM);
2294
2296#define o2_add_start_array() o2_add_only_typecode(O2_ARRAY_START);
2297
2299#define o2_add_end_array() o2_add_only_typecode(O2_ARRAY_END);
2300
2310 int length, void *data);
2311
2312#ifndef O2_NO_BUNDLES
2329#endif
2330
2345O2message_ptr o2_message_finish(O2time time, const char *address,
2346 bool tcp_flag);
2347
2364 const char *service, const char *address, bool tcp_flag);
2365
2366
2391O2err o2_send_finish(O2time time, const char *address, bool tcp_flag);
2392
2393
2420
2504O2arg_ptr o2_get_next(O2type type_code);
2505
2509/* Scheduling */
2514// Messages are stored in the table modulo their timestamp, so the
2515// table acts sort of like a hash table (this is also called the
2516// timing wheel structure). Messages are stored as linked lists sorted
2517// by increasing timestamps when there are collisions.
2518 \
2520// Size of scheduler table.
2521#define O2_SCHED_TABLE_LEN 128
2522
2523// Scheduler data structure.
2524typedef struct O2sched {
2525 int64_t last_bin;
2526 double last_time;
2527 O2message_ptr table[O2_SCHED_TABLE_LEN];
2528} O2sched, *O2sched_ptr;
2540extern O2sched o2_gtsched;
2541
2555extern O2sched o2_ltsched;
2556
2565extern O2sched_ptr o2_active_sched; // the scheduler that should be used
2566
2567
2593O2err o2_schedule_msg(O2sched_ptr scheduler, O2message_ptr msg);
2594 // end of a basics group
2596
2597#ifndef O2_NO_MQTT
2603 // end of a mqttapi group
2604#endif
2605
2606#ifndef O2_NO_BRIDGES
2613
2614 // end of a bridgeapi group
2616#endif
2617
2626
2627
2638
2639
2654
2655
2656#ifndef O2_NO_MQTT
2682 O2err o2_mqtt_enable(const char *broker, int port_num);
2683 // end of a mqttapi group
2685#endif
2686
2687// note: shared mem process support depends on bridge support
2688#ifndef O2_NO_SHAREDMEM
2689O2err o2_shmem_initialize();
2690#endif
2691
2692
2693#ifndef O2_NO_WEBSOCKETS
2694#ifdef O2_NO_BRIDGES
2695#error WEBSOCKETS feature depends on BRIDGES
2696#error You must define O2_NO_WEBSOCKETS or undefine O2_NO_BRIDGES
2697#endif
2698#endif
2699
2704#define O2_NO_HOSTNAME "\001" // a non-text marker string
2705
2734O2err http_initialize(int port, const char *root);
2735 // end of a httpapi group
2737
2738#ifdef __cplusplus
2739}
2740#endif
2741
2742#endif /* O2_H */
O2err o2_network_enable(bool enable)
Disable external nework connections.
Definition: o2.cpp:987
void o2_message_print(O2message_ptr msg)
print an O2 message to stdout
struct O2blob O2blob
The structure for binary large object.
const char * o2_ensemble_name
Definition: o2.cpp:935
struct O2message O2message
an O2 message container
O2time(* o2_time_callback)(void *rock)
signature for callback that defines the reference clock
Definition: o2.h:1771
O2err o2_service_new(const char *service_name)
Add a service to the current process.
Definition: o2.cpp:1227
O2type
An enumeration of the O2 message types.
Definition: o2.h:717
const char * o2_service_properties(int i)
get the properties string from a saved list of services
Definition: properties.cpp:130
O2err o2_get_addresses(const char **public_ip, const char **internal_ip, int *port)
Get IP address and TCP connection port number.
Definition: o2.cpp:1097
bool o2_stop_flag
set this flag to stop o2_run
Definition: o2.cpp:1342
void o2_msg_data_print(o2_msg_data_ptr msg)
print a message from msg_data_ptr to stdout
O2sched o2_gtsched
Scheduler that schedules according to global (reference) clock time.
Definition: o2sched.cpp:68
void o2_drop_message(const char *warn, bool free_the_msg)
Tell world that a message was dropped.
Definition: msgsend.cpp:209
bool o2_clock_is_synchronized
A variable indicating that the clock is the reference or is synchronized to the reference.
Definition: clock.cpp:26
const char * o2_service_getprop(int i, const char *attr)
get a property value from a saved list of services
Definition: properties.cpp:198
int o2_parse_name(const char *name, char *public_ip, char *internal_ip, int *port)
Parse Public:Local:Port string and extract fields.
Definition: discovery.cpp:83
O2time o2_time_get(void)
Get the estimated synchronized global O2 time.
Definition: clock.cpp:672
int o2_status(const char *service)
Check the status of the service.
Definition: o2.cpp:1359
void o2_message_drop_warning(const char *warn, o2_msg_data_ptr msg)
Default dropped message alert.
Definition: o2.cpp:1242
O2err o2_message_send(O2message_ptr msg)
Send an O2 message. (See also macros o2_send and o2_send_cmd).
Definition: msgsend.cpp:579
const char * o2_service_tapper(int i)
get a tapper name from a saved list of services
Definition: properties.cpp:117
O2err o2_services_list(void)
list known services and taps
Definition: properties.cpp:26
int o2_memory(void *((*malloc)(size_t size)), void((*free)(void *)), char *first_chunk, int64_t size, bool mallocp)
Tell O2 how to allocate/free memory.
Definition: o2mem.cpp:334
const char * o2_status_to_string(int status)
retrieve text version of an O2status
Definition: o2.cpp:1467
O2err o2_can_send(const char *service)
Test if send_cmd will block.
Definition: o2.cpp:1372
O2err o2_internet_enable(bool enable)
Disable Internet connections.
Definition: o2.cpp:974
const char * o2_service_process(int i)
get a process name from a saved list of services
Definition: properties.cpp:108
const char * o2_get_proc_name(void)
Get Public:Local:Port service name string.
Definition: o2.cpp:1110
int o2_version(char *version)
get O2 version number
Definition: o2.cpp:1541
O2err o2_service_free(const char *service_name)
Remove a local service.
Definition: services.cpp:568
struct O2msg_data O2msg_data
data part of an O2 message
O2err o2_service_set_property(const char *service, const char *attr, const char *value)
set an attribute and value property for a service
Definition: properties.cpp:345
O2time o2_local_time(void)
Get the real time using the local O2 clock.
Definition: clock.cpp:644
const char * o2_service_name(int i)
get a service name from a saved list of services
Definition: properties.cpp:90
O2time o2_set_discovery_period(O2time period)
Set discovery period.
Definition: discovery.cpp:73
O2err o2_finish(void)
release the memory and shut down O2.
Definition: o2.cpp:1477
int o2_run(int rate)
Run O2.
Definition: o2.cpp:1344
O2err o2_untap(const char *tappee, const char *tapper)
remove tap from service
Definition: o2.cpp:1288
int o2_service_type(int i)
get a type from a saved list of services
Definition: properties.cpp:99
void o2_message_warnings(void(*warning)(const char *warn, o2_msg_data_ptr msg))
Enable/Disable warnings for dropped messages.
Definition: o2.cpp:1254
int o2_service_search(int i, const char *attr, const char *value)
find a service matching attribute/value pair
Definition: properties.cpp:225
O2err o2_poll(void)
Process current O2 messages.
Definition: o2.cpp:1309
O2err o2_method_new(const char *path, const char *typespec, O2method_handler h, const void *user_data, bool coerce, bool parse)
Add a handler for an address.
Definition: o2.cpp:1261
O2err o2_hub(int version, const char *public_ip, const char *internal_ip, int tcp_port, int udp_port)
Connect to a hub.
Definition: discovery.cpp:789
void(* O2method_handler)(const o2_msg_data_ptr msg, const char *types, O2arg_ptr *argv, int argc, const void *user_data)
callback function to receive an O2 message
Definition: o2.h:880
O2err o2_service_property_free(const char *service, const char *attr)
remove an attribute and value property from a service
Definition: properties.cpp:357
O2err o2_services_list_free(void)
free the list of known services and taps
Definition: properties.cpp:69
O2sched_ptr o2_active_sched
Current scheduler.
Definition: o2sched.cpp:69
O2err o2_schedule_msg(O2sched_ptr scheduler, O2message_ptr msg)
Definition: o2sched.cpp:151
int o2_clock_set(o2_time_callback gettime, void *rock)
Provide a time reference to O2.
Definition: clock.cpp:606
O2err o2_initialize(const char *ensemble_name)
Start O2.
Definition: o2.cpp:1000
double O2time
O2 timestamps are doubles representing seconds since the approximate start time of the ensemble.
Definition: o2.h:625
O2err o2_tap(const char *tappee, const char *tapper, O2tap_send_mode send_mode)
install tap to copy messages from one service to another
Definition: o2.cpp:1276
O2err o2_method_free(const char *path)
remove a path – remove a path and associated handler
Definition: pathtree.cpp:452
O2sched o2_ltsched
Scheduler that schedules according to local clock time.
Definition: o2sched.cpp:68
int o2_roundtrip(double *mean, double *min)
Get network round-trip information.
Definition: clock.cpp:439
@ O2_ARRAY_END
End array or tuple.
Definition: o2.h:724
@ O2_BLOB
Binary Large OBject (BLOB) type.
Definition: o2.h:722
@ O2_FALSE
Symbol representing the value False.
Definition: o2.h:734
@ O2_TRUE
Symbol representing the value True.
Definition: o2.h:733
@ O2_INFINITUM
Symbol representing the value Infinitum.
Definition: o2.h:736
@ O2_VECTOR
Prefix to indicate a vector.
Definition: o2.h:740
@ O2_FLOAT
32 bit IEEE-754 float.
Definition: o2.h:720
@ O2_MIDI
4 byte MIDI packet.
Definition: o2.h:732
@ O2_DOUBLE
64 bit IEEE-754 double.
Definition: o2.h:729
@ O2_TIME
OSC time type.
Definition: o2.h:728
@ O2_CHAR
8bit char variable (Standard C).
Definition: o2.h:731
@ O2_INT32
32 bit signed integer.
Definition: o2.h:719
@ O2_ARRAY_START
Start array or tuple.
Definition: o2.h:723
@ O2_NIL
Symbol representing the value Nil.
Definition: o2.h:735
@ O2_INT64
64 bit signed integer.
Definition: o2.h:727
@ O2_BOOL
Boolean value returned as either 0 or 1.
Definition: o2.h:739
@ O2_SYMBOL
Used to distinguish strings and symbols.
Definition: o2.h:730
@ O2_STRING
NULL terminated string (Standard C).
Definition: o2.h:721
O2err o2lite_initialize()
enable O2lite protocol connections to this proces
Definition: bridge.cpp:538
void o2_debug_flags(const char *flags)
Enable debugging output.
Definition: debug.cpp:19
const char * o2_error_to_string(O2err i)
Return text representation of an O2 error.
Definition: o2.cpp:1445
O2err http_initialize(int port, const char *root)
Enable HTTP and Websocket access to an O2 host.
Definition: websock.cpp:208
int o2_extract_start(o2_msg_data_ptr msg)
initialize internal state to parse, extract, and coerce message arguments.
Definition: message.cpp:869
O2arg_ptr o2_get_next(O2type type_code)
get the next message parameter
Definition: message.cpp:1018
O2err o2_add_midi(uint32_t m)
add a short midi message to the message (see o2_send_start)
Definition: message.cpp:243
O2err o2_send_start(void)
Prepare to build a message.
Definition: message.cpp:135
O2message_ptr o2_service_message_finish(O2time time, const char *service, const char *address, bool tcp_flag)
finish and return a message, prepending service name
Definition: message.cpp:293
O2err o2_add_blob_data(uint32_t size, void *data)
add an O2blob to the message (see o2_send_start), where the blob is specified by a size and a data ad...
Definition: message.cpp:224
O2err o2_add_vector(O2type element_type, int length, void *data)
add a vector
O2err o2_add_int64(int64_t i)
add an int64 to the message (see o2_send_start)
Definition: message.cpp:159
O2err o2_add_only_typecode(O2type typecode)
This function supports o2_add_true, o2_add_false, o2_add_bool, o2_add_nil, o2_add_infinitum,...
Definition: message.cpp:195
O2err o2_add_float(float f)
add a float to the message (see o2_send_start)
Definition: message.cpp:147
O2message_ptr o2_message_finish(O2time time, const char *address, bool tcp_flag)
finish and return the message.
Definition: message.cpp:283
O2err o2_send_finish(O2time time, const char *address, bool tcp_flag)
send a message allocated by o2_send_start.
Definition: message.cpp:858
O2err o2_add_double_or_time(O2type tchar, double d)
This function supports o2_add_double and o2_add_time Normally, you should not call this directly.
Definition: message.cpp:183
O2err o2_add_string_or_symbol(O2type tcode, const char *s)
This function suppports o2_add_symbol and o2_add_string Normally, you should not call this directly.
Definition: message.cpp:206
O2err o2_add_int32_or_char(O2type tcode, int32_t i)
This function supports o2_add_int32 and o2_add_char Normally, you should not call this directly.
Definition: message.cpp:171
O2blob_ptr o2_blob_new(uint32_t size)
Allocate a blob.
Definition: message.cpp:512
O2err o2_add_message(O2message_ptr msg)
add a message to a bundle
Definition: message.cpp:270
O2err o2_add_blob(O2blob_ptr b)
add an O2blob to the message (see o2_send_start), where the blob is given as a pointer to an O2blob o...
O2err o2_mqtt_enable(const char *broker, int port_num)
Enable MQTT to form wide-area-network connections between O2 processes.
Definition: mqtt.cpp:48
O2err o2_osc_port_new(const char *service_name, int port_num, int tcp_flag)
Create a port to receive OSC messages.
Definition: o2osc.cpp:168
uint64_t o2_osc_time_offset(uint64_t offset)
Set the OSC time offset.
Definition: o2osc.cpp:133
O2err o2_osc_delegate(const char *service_name, const char *ip, int port_num, int tcp_flag)
Create a service that forwards O2 messages to an OSC server.
Definition: o2osc.cpp:263
O2err o2_osc_port_free(int port_num)
Remove a port receiving OSC messages.
Definition: o2osc.cpp:234
O2status
Status return codes for the o2_status function.
Definition: o2.h:435
O2err
return values used generally by O2 functions
Definition: o2.h:329
@ O2_LOCAL
local service with clock sync.
Definition: o2.h:496
@ O2_TAP
tag value for o2_services_list
Definition: o2.h:532
@ O2_REMOTE_NOTIME
remote service but no clock sync yet
Definition: o2.h:453
@ O2_BRIDGE
connected with clock sync.
Definition: o2.h:512
@ O2_UNKNOWN
status is unknown, e.g. service does not exist
Definition: o2.h:438
@ O2_BRIDGE_NOTIME
service is connected but no clock sync yet.
Definition: o2.h:468
@ O2_REMOTE
remote service with clock sync.
Definition: o2.h:502
@ O2_LOCAL_NOTIME
local service, no clock sync yet.
Definition: o2.h:445
@ O2_TO_OSC_NOTIME
service is connected but no clock sync yet.
Definition: o2.h:487
@ O2_TO_OSC
connected with clock sync.
Definition: o2.h:528
@ O2_BAD_NAME
invalid ensemble name parameter
Definition: o2.h:366
@ O2_NO_CLOCK
timed message but time is unknown
Definition: o2.h:394
@ O2_HOSTNAME_TO_NETADDR_FAIL
inet_pton() failed to convert a string to an IP address
Definition: o2.h:383
@ O2_BAD_ARGS
mismatched types and arguments
Definition: o2.h:375
@ O2_NO_PORT
unable to allocate a discovery port
Definition: o2.h:423
@ O2_SEND_FAIL
could not write to socket or send datagram
Definition: o2.h:406
@ O2_BLOCKED
TCP send would block.
Definition: o2.h:419
@ O2_NO_SERVICE
path to handler specifies non-existant service
Definition: o2.h:349
@ O2_SUCCESS
function was successful
Definition: o2.h:332
@ O2_NO_HANDLER
no handler for an address
Definition: o2.h:398
@ O2_NO_MEMORY
process is out of free memory
Definition: o2.h:353
@ O2_NO_NETWORK
networking is disabled
Definition: o2.h:429
@ O2_TCP_HUP
in o2_initialize, the socket is closed.
Definition: o2.h:379
@ O2_NOT_INITIALIZED
O2 has not been initialized.
Definition: o2.h:414
@ O2_TCP_CONNECT_FAIL
attempt to make a TCP connection failed
Definition: o2.h:387
@ O2_BAD_TYPE
in o2_add_vector, invalid element type
Definition: o2.h:370
@ O2_INVALID_MSG
an O2 message is invalid
Definition: o2.h:402
@ O2_SOCKET_ERROR
SOCKET_ERROR in select call.
Definition: o2.h:410
@ O2_SERVICE_EXISTS
not (re)creating service
Definition: o2.h:345
@ O2_ALREADY_RUNNING
o2_initialize called, but O2 is already running.
Definition: o2.h:357
@ O2_FAIL
a non-specific error occurred.
Definition: o2.h:339
void o2_complete_delivery()
Definition: msgsend.cpp:236
O2message_ptr o2_postpone_delivery()
Definition: msgsend.cpp:245
O2message_ptr o2_current_message()
Definition: msgsend.cpp:228
The structure for binary large object.
Definition: o2.h:708
uint32_t size
size of data
Definition: o2.h:709
char data[4]
the data, actually of variable length
Definition: o2.h:710
an O2 message container
Definition: o2.h:690
struct O2message * next
links used for free list and scheduler
Definition: o2.h:692
int64_t pad_if_needed
make sure allocated is 8-byte aligned
Definition: o2.h:693
data part of an O2 message
Definition: o2.h:638
O2time timestamp
the message delivery time (0 for immediate)
Definition: o2.h:646
char address[4]
the message address string
Definition: o2.h:655
union of all O2 parameter types
Definition: o2.h:764
float f32
an alias for f
Definition: o2.h:770
O2blob b
a blob (unstructured bytes)
Definition: o2.h:781
float * vf
vector of IEEE-754 floats
Definition: o2.h:791
int c
Standard C, 8 bit, char, stored as int.
Definition: o2.h:777
int64_t i64
64 bit signed integer.
Definition: o2.h:767
int32_t * vi
vector of 32-bit signed integers
Definition: o2.h:788
int64_t h
an alias for i64
Definition: o2.h:768
double f64
an alias for d
Definition: o2.h:772
O2time t
TimeTag value.
Definition: o2.h:780
int32_t len
IMPORTANT: divide by 4 or 8 to get length in elements.
Definition: o2.h:784
float f
32 bit IEEE-754 float.
Definition: o2.h:769
double * vd
vector of IEEE-754 doubles
Definition: o2.h:790
int32_t B
a boolean value, either 0 or 1
Definition: o2.h:782
int32_t i
an alias for i32
Definition: o2.h:766
int32_t typ
type of vector elements
Definition: o2.h:786
int64_t * vh
vector of 64-bit signed integers
Definition: o2.h:789
int32_t i32
32 bit signed integer.
Definition: o2.h:765
uint32_t m
Definition: o2.h:778
double d
64 bit IEEE-754 double.
Definition: o2.h:771