O2 2.0
A communication protocol for interactive music and media applications.
o2osc.h
1/* osc.h -- open sound control compatibility */
2
3/* Roger B. Dannenberg
4 * April 2020
5 */
6
7#ifndef O2_NO_OSC
8
9#define ISA_OSC(node) ((node)->tag & (O2TAG_OSC_UDP_SERVER | \
10 O2TAG_OSC_TCP_SERVER | O2TAG_OSC_UDP_CLIENT | \
11 O2TAG_OSC_TCP_CLIENT | O2TAG_OSC_TCP_CONNECTION))
12
13#ifdef O2_NO_DEBUG
14#define TO_OSC_INFO(node) ((Osc_info *) (node))
15#else
16#define TO_OSC_INFO(node) (assert(ISA_OSC(((Osc_info *) (node)))),\
17 ((Osc_info *) (node)))
18#endif
19
20// See o2osc.c for details of osc_info creation, destruction, usage.
21class Osc_info : public Proxy_info {
22 public:
23 // the key is used by Osc_info as the service name
24 Net_address udp_address;
25 int port; // the port could be either TCP port or UDP port, so we
26 // keep a host-order copy here rather than use the port field
27 // of udp_address.
28
29 // zero out udp_address by allocating with CALLOC:
30 Osc_info(const char *key, int port_, Fds_info *info, int tag) :
31 Proxy_info(key, tag) {
32 memset(&udp_address, 0, sizeof udp_address);
33 port = port_; fds_info = info; }
34 virtual ~Osc_info();
35
36 // OSC services are considered synchronized with the Host because
37 // they either use Host scheduling or NTP timestamps (which
38 // are unlikely to be accurate enough except when sending to
39 // localhost).
40 bool local_is_synchronized() { return true; }
41 bool schedule_before_send();
42
43 // Implement the Net_interface:
44 O2err accepted(Fds_info *conn);
45 O2err connected();
46 O2err deliver(O2netmsg_ptr msg);
47
48#ifndef O2_NO_DEBUG
49 void show(int indent);
50#endif
51
52 O2status status(const char **process) {
53 if (process) {
54 *process = get_proc_name();
55 }
57 }
58 O2err msg_data_to_osc_data(o2_msg_data_ptr msg, O2time min_time);
59
60 O2err send(bool block);
61};
62
63
64#endif
Definition: o2network.h:147
Definition: o2network.h:105
Definition: o2osc.h:21
Definition: o2node.h:291
bool o2_clock_is_synchronized
A variable indicating that the clock is the reference or is synchronized to the reference.
Definition: clock.cpp:26
double O2time
O2 timestamps are doubles representing seconds since the approximate start time of the ensemble.
Definition: o2.h:625
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_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
data part of an O2 message
Definition: o2.h:638
Definition: o2network.h:57