OSSIA
Open Scenario System for Interactive Application
Loading...
Searching...
No Matches
osc.hpp
1#pragma once
2#include <ossia/detail/mutex.hpp>
3#include <ossia/network/base/listening.hpp>
4#include <ossia/network/base/protocol.hpp>
5#include <ossia/network/zeroconf/zeroconf.hpp>
6
7#include <ossia/detail/hash_map.hpp>
8
9#include <atomic>
10#include <string>
11
12namespace oscpack
13{
14class ReceivedMessage;
15class IpEndpointName;
16}
17namespace osc
18{
19template <typename T>
20class sender;
21class receiver;
22}
23namespace ossia::net
24{
25struct osc_1_0_outbound_stream_visitor;
26
27class OSSIA_EXPORT OSSIA_DEPRECATED("Use make_osc_protocol") osc_protocol final
29{
30public:
31 osc_protocol(
32 std::string ip, uint16_t remote_port, uint16_t local_port = 0,
33 std::optional<std::string> expose_name = std::nullopt);
34
35 osc_protocol(const osc_protocol&) = delete;
36 osc_protocol(osc_protocol&&) = delete;
37 osc_protocol& operator=(const osc_protocol&) = delete;
38 osc_protocol& operator=(osc_protocol&&) = delete;
39
40 ~osc_protocol() override;
41
42 const std::string& get_ip() const;
43 osc_protocol& set_ip(std::string);
44
45 uint16_t get_remote_port() const;
46 osc_protocol& set_remote_port(uint16_t);
47
48 uint16_t get_local_port() const;
49 osc_protocol& set_local_port(uint16_t);
50
51 bool learning() const;
52 osc_protocol& set_learning(bool);
53
54 bool update(ossia::net::node_base& node_base) override;
55
56 bool pull(ossia::net::parameter_base& parameter_base) override;
57
58 bool
59 push(const ossia::net::parameter_base& parameter_base, const ossia::value& v) override;
60 bool push_raw(const ossia::net::full_parameter_data& parameter_base) override;
61 bool push_bundle(const std::vector<const ossia::net::parameter_base*>&) override;
62 bool push_raw_bundle(const std::vector<full_parameter_data>&) override;
63
64 bool observe(ossia::net::parameter_base& parameter_base, bool enable) override;
65 bool echo_incoming_message(
66 const ossia::net::message_origin_identifier&, const ossia::net::parameter_base&,
67 const ossia::value& v) override;
68
69 void enable_buffering(bool b) { m_buffering = b; }
70 void send_buffer();
71
72private:
73 void on_received_message(
74 const oscpack::ReceivedMessage& m, const oscpack::IpEndpointName& ip);
75 void on_learn(const oscpack::ReceivedMessage& m);
76 void set_device(ossia::net::device_base& dev) override;
77
78 void update_sender();
79 void update_receiver();
80 void update_zeroconf();
81
82 listened_parameters m_listening;
83
84 std::unique_ptr<osc::sender<osc_1_0_outbound_stream_visitor>> m_sender;
85 std::unique_ptr<osc::receiver> m_receiver;
86
87 net::zeroconf_server m_zeroconfServer;
88
89 ossia::net::device_base* m_device{};
90 std::string m_ip;
91
92 uint16_t m_remote_port{};
93 uint16_t m_local_port{};
95 std::atomic_bool m_learning{};
97 std::optional<std::string> m_expose{};
98
99 message_origin_identifier m_id;
100
101 bool m_buffering{};
102 std::vector<ossia::net::full_parameter_data> m_buffer;
103 std::mutex m_buffer_mutex;
104};
105}
Root of a device tree.
Definition ossia/network/base/device.hpp:58
The node_base class.
Definition node.hpp:48
The parameter_base class.
Definition ossia/network/base/parameter.hpp:48
The protocol_base class.
Definition protocol.hpp:40
The value class.
Definition value.hpp:173
Full information about a parameter.
Definition parameter_data.hpp:61