Mercurial > hg > beaglert
diff include/OSCServer.h @ 270:de37582ce6f3 prerelease
Added OSCServer and OSCClient
author | Liam Donovan <l.b.donovan@qmul.ac.uk> |
---|---|
date | Tue, 17 May 2016 15:56:18 +0100 |
parents | |
children | e4392164b458 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/include/OSCServer.h Tue May 17 15:56:18 2016 +0100 @@ -0,0 +1,50 @@ +/***** OSCServer.h *****/ +#ifndef __OSCServer_H_INCLUDED__ +#define __OSCServer_H_INCLUDED__ + +#include <UdpServer.h> +#include <oscpkt.hh> +#include <BeagleRT.h> +#include <queue> + +#define UDP_RECIEVE_TIMEOUT_MS 20 +#define UDP_RECIEVE_MAX_LENGTH 16384 + +class OSCServer{ + public: + OSCServer(); + + // must be called once during setup + void setup(int port); + + // returns true if messages are queued + // audio-thread safe + bool messageWaiting(); + + // removes and returns the oldest message from the queue + // audio-thread safe, but don't call unless messageWaiting() returns true + oscpkt::Message popMessage(); + + // if there are OSC messages waiting, decode and queue them + // not audio-thread safe! + void recieveMessageNow(int timeout); + + private: + int port; + UdpServer socket; + + AuxiliaryTask OSCRecieveTask; + + void createAuxTasks(); + void messageCheck(); + + static void checkMessages(void*); + + int inBuffer[UDP_RECIEVE_MAX_LENGTH]; + std::queue<oscpkt::Message> inQueue; + oscpkt::Message poppedMessage; + oscpkt::PacketReader pr; +}; + + +#endif \ No newline at end of file