21 #ifndef PLUGINS_OSC_OSCNODE_H_
22 #define PLUGINS_OSC_OSCNODE_H_
27 #include <ola/io/Descriptor.h>
28 #include <ola/io/SelectServerInterface.h>
35 #include "plugins/osc/OSCTarget.h"
75 FORMAT_INT_INDIVIDUAL,
77 FORMAT_FLOAT_INDIVIDUAL,
101 bool SendData(
unsigned int group, DataFormat data_format,
108 void SetUniverse(
const std::string &osc_address,
const uint8_t *data,
110 void SetSlot(
const std::string &osc_address, uint16_t slot, uint8_t value);
116 class NodeOSCTarget {
118 explicit NodeOSCTarget(
const OSCTarget &target);
121 bool operator==(
const NodeOSCTarget &other)
const {
122 return (socket_address == other.socket_address &&
123 osc_address == other.osc_address);
126 bool operator==(
const OSCTarget &other)
const {
127 return (socket_address == other.socket_address &&
128 osc_address == other.osc_address);
132 std::string osc_address;
133 lo_address liblo_address;
136 NodeOSCTarget(
const NodeOSCTarget&);
137 NodeOSCTarget& operator=(
const NodeOSCTarget&);
140 typedef std::vector<NodeOSCTarget*> OSCTargetVector;
142 struct OSCOutputGroup {
143 OSCTargetVector targets;
147 struct OSCInputGroup {
148 explicit OSCInputGroup(DMXCallback *callback) : callback(callback) {}
151 std::auto_ptr<DMXCallback> callback;
154 typedef std::map<unsigned int, OSCOutputGroup*> OutputGroupMap;
155 typedef std::map<std::string, OSCInputGroup*> InputUniverseMap;
163 const uint16_t m_listen_port;
164 std::auto_ptr<ola::io::UnmanagedFileDescriptor> m_descriptor;
165 lo_server m_osc_server;
166 OutputGroupMap m_output_map;
167 InputUniverseMap m_input_map;
169 void DescriptorReady();
170 bool SendBlob(
const DmxBuffer &data,
const OSCTargetVector &targets);
171 bool SendIndividualFloats(
const DmxBuffer &data,
172 OSCOutputGroup *group);
173 bool SendIndividualInts(
const DmxBuffer &data,
174 OSCOutputGroup *group);
175 bool SendIntArray(
const DmxBuffer &data,
176 const OSCTargetVector &targets);
177 bool SendFloatArray(
const DmxBuffer &data,
178 const OSCTargetVector &targets);
179 bool SendMessageToTargets(lo_message message,
180 const OSCTargetVector &targets);
181 bool SendIndividualMessages(
const DmxBuffer &data,
182 OSCOutputGroup *group,
183 const std::string &osc_type);
185 static const uint16_t DEFAULT_OSC_PORT = 7770;
186 static const char OSC_PORT_VARIABLE[];
191 #endif // PLUGINS_OSC_OSCNODE_H_