SPAOP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
VSReceiver.h
Go to the documentation of this file.
1 /*
2  * Copyright 2014 Martin Hansen
3  *
4  * This file is part of SPAOP (Spatial Audio Object Positioner).
5  *
6  * SPAOP is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * SPAOP is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with SPAOP. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef VSRECEIVER_H_INCLUDED
21 #define VSRECEIVER_H_INCLUDED
22 
23 #include <iostream>
24 #include <list>
25 #include <memory>
26 
27 #include "VisualStreamReceiver.h"
28 #include "WonderOscServerSender.h"
30 #include "ServerThread.h"
32 
37 namespace wonderlo {
38 
45 {
46 
47 public:
48 
53 
61  VSReceiver(lo_err_handler err_h);
62 
70  VSReceiver(const std::string &port, lo_err_handler err_h);
71 
84  VSReceiver(const std::string& group, const std::string &port,
85  const std::string& ifaceIp, lo_err_handler err_h);
86 
88  virtual ~VSReceiver();
89 
102  wonder::OscSender* createSender(const std::string &host, const std::string &port);
103 
104  wonder::OscSenderThread* createSenderThread(const std::string &host,
105  const std::string &port);
106 
111  void setListener(VisualStreamReceiver::Listener* listener);
112 
117  void setPingHandler(PingHandler* pingHandler);
118 
119  void start();
120 
121  void stop();
122 
123  void join();
124 
125  int port();
126 
127 private:
128  VSReceiver(const VSReceiver& other); // copying not allowed
129  VSReceiver &operator= (const VSReceiver other); // assignment not allowed
130 
131 
132  VisualStreamReceiver::Listener* listener_;
133  VisualStreamReceiver::PingHandler* pingHandler_;
134  std::list<std::unique_ptr<lowrappers::ServerThread::Listener>> functorList_; // avoids memory leaks
135 
137  class Factory : public wonder::VisualStreamReceiver::Factory
138  {
139  wonder::VisualStreamReceiver* createVisualStreamReceiver();
140 
141  wonder::VisualStreamReceiver* createVisualStreamReceiver(const std::string& port);
142 
143  wonder::VisualStreamReceiver* createVisualStreamMulticastReceiver(const std::string& group,
144  const std::string& port,
145  const std::string& iface);
146  };
147 
149  void addMethods();
150 
154  void addListenerAndStoreFunctor(const char* path, const char* types,
156 
157  //==============================================================================
158  // Wrapper-Methods for wonder::VisualStreamReceiver::Listener:
159 
160  int onSourceActivateI(const char *path, const char *types,lo_arg **argv,
161  int argc, lo_message msg);
162 
163  int onSourceDeactivateI(const char *path, const char *types,lo_arg **argv,
164  int argc, lo_message msg);
165 
166  int onSourcePositionIff(const char *path, const char *types,lo_arg **argv,
167  int argc, lo_message msg);
168 
169  int onSourceAngleIf(const char *path, const char *types,lo_arg **argv,
170  int argc, lo_message msg);
171 
172  int onSourceTypeIi(const char *path, const char *types,lo_arg **argv,
173  int argc, lo_message msg);
174 
175  int onSourceNameIs(const char *path, const char *types,lo_arg **argv,
176  int argc, lo_message msg);
177 
178  int onSourceColorIiii(const char *path, const char *types,lo_arg **argv,
179  int argc, lo_message msg);
180 
181  int onSourceGroupIdIi(const char *path, const char *types,lo_arg **argv,
182  int argc, lo_message msg);
183 
184  int onSourceRotatingDirectionIi(const char *path, const char *types,lo_arg **argv,
185  int argc, lo_message msg);
186 
187  int onSourceScalingDirectionIi(const char *path, const char *types,lo_arg **argv,
188  int argc, lo_message msg);
189 
190  int onSourceDopplerEffectIi(const char *path, const char *types,lo_arg **argv,
191  int argc, lo_message msg);
192 
193  int onListenerPositionIff(const char *path, const char *types,lo_arg **argv,
194  int argc, lo_message msg);
195 
196  int onGlobalMaxNoSourcesI(const char *path, const char *types,lo_arg **argv,
197  int argc, lo_message msg);
198 
199  int onGlobalRenderpolygonSiVarFs(const char *path, const char *types,lo_arg **argv,
200  int argc, lo_message msg);
201 
202  int onProjectXmlDumpIs(const char *path, const char *types,lo_arg **argv,
203  int argc, lo_message msg);
204 
205  int onStreamVisualPongI(const char *path, const char *types,lo_arg **argv,
206  int argc, lo_message msg);
207 
208  int onStreamVisualConnect(const char *path, const char *types,lo_arg **argv,
209  int argc, lo_message msg);
210 
211  int onStreamVisualDisconnect(const char *path, const char *types,lo_arg **argv,
212  int argc, lo_message msg);
213 
214  int onReplySis(const char *path, const char *types,lo_arg **argv,
215  int argc, lo_message msg);
216 
217  int onPluginStandaloneI(const char *path, const char *types,lo_arg **argv,
218  int argc, lo_message msg);
219 
220  //==============================================================================
221  // Wrapper-Methods for wonder::VisualStreamReceiver::PingHandler:
222 
223  int onStreamVisualPingI(const char *path, const char *types,lo_arg **argv,
224  int argc, lo_message msg);
225 };
226 
227 }
228 
229 
230 #endif // VSRECEIVER_H_INCLUDED
int port()
Returns the port this server-thread is listening on.
Definition: VSReceiver.cpp:96
An abstract class describing the interface for a class that sends out the WONDER-specific OSC-message...
Definition: OscSender.h:43
static wonder::VisualStreamReceiver::Factory * getFactory()
A singleton-getter for a wonder::VisualStreamReceiver::Factory that creates instances of VSReceiver...
Definition: VSReceiver.cpp:24
Another listener interface especially for incoming ping messages.
Definition: VisualStreamReceiver.h:258
An interface defining an OSC server thread that receives and handles the messages sent via WONDER's "...
Definition: VisualStreamReceiver.h:36
A factory class that creates VisualStreamReceiver instances.
Definition: VisualStreamReceiver.h:318
VSReceiver(lo_err_handler err_h)
Constructor.
Definition: VSReceiver.cpp:30
An OscServer-Thread that calls the message-handling methods of a VisualStreamCallInterface object...
Definition: VSReceiver.h:43
void join()
Joins this server thread.
Definition: VSReceiver.cpp:91
void setPingHandler(PingHandler *pingHandler)
Sets the PingHandler.
Definition: VSReceiver.cpp:76
void start()
Starts this server thread.
Definition: VSReceiver.cpp:81
An interface for a thread implementing the OscSender interface.
Definition: OscSenderThread.h:38
A listener interface for listeners to be called by the ServerThread when incoming OSC messages are re...
Definition: ServerThread.h:64
wonder::OscSender * createSender(const std::string &host, const std::string &port)
Returns an OscSender that sends from the port of this server thread to the specified destination...
Definition: VSReceiver.cpp:59
A server thread with Liblo-style callback capabilities.
Definition: ServerThread.h:52
void setListener(VisualStreamReceiver::Listener *listener)
Sets the Listener.
Definition: VSReceiver.cpp:71
virtual ~VSReceiver()
Destructor.
Definition: VSReceiver.cpp:55
wonder::OscSenderThread * createSenderThread(const std::string &host, const std::string &port)
Definition: VSReceiver.cpp:65
void stop()
Stops this server thread.
Definition: VSReceiver.cpp:86