Mercurial > hg > beaglert
annotate 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 |
rev | line source |
---|---|
l@270 | 1 /***** OSCServer.h *****/ |
l@270 | 2 #ifndef __OSCServer_H_INCLUDED__ |
l@270 | 3 #define __OSCServer_H_INCLUDED__ |
l@270 | 4 |
l@270 | 5 #include <UdpServer.h> |
l@270 | 6 #include <oscpkt.hh> |
l@270 | 7 #include <BeagleRT.h> |
l@270 | 8 #include <queue> |
l@270 | 9 |
l@270 | 10 #define UDP_RECIEVE_TIMEOUT_MS 20 |
l@270 | 11 #define UDP_RECIEVE_MAX_LENGTH 16384 |
l@270 | 12 |
l@270 | 13 class OSCServer{ |
l@270 | 14 public: |
l@270 | 15 OSCServer(); |
l@270 | 16 |
l@270 | 17 // must be called once during setup |
l@270 | 18 void setup(int port); |
l@270 | 19 |
l@270 | 20 // returns true if messages are queued |
l@270 | 21 // audio-thread safe |
l@270 | 22 bool messageWaiting(); |
l@270 | 23 |
l@270 | 24 // removes and returns the oldest message from the queue |
l@270 | 25 // audio-thread safe, but don't call unless messageWaiting() returns true |
l@270 | 26 oscpkt::Message popMessage(); |
l@270 | 27 |
l@270 | 28 // if there are OSC messages waiting, decode and queue them |
l@270 | 29 // not audio-thread safe! |
l@270 | 30 void recieveMessageNow(int timeout); |
l@270 | 31 |
l@270 | 32 private: |
l@270 | 33 int port; |
l@270 | 34 UdpServer socket; |
l@270 | 35 |
l@270 | 36 AuxiliaryTask OSCRecieveTask; |
l@270 | 37 |
l@270 | 38 void createAuxTasks(); |
l@270 | 39 void messageCheck(); |
l@270 | 40 |
l@270 | 41 static void checkMessages(void*); |
l@270 | 42 |
l@270 | 43 int inBuffer[UDP_RECIEVE_MAX_LENGTH]; |
l@270 | 44 std::queue<oscpkt::Message> inQueue; |
l@270 | 45 oscpkt::Message poppedMessage; |
l@270 | 46 oscpkt::PacketReader pr; |
l@270 | 47 }; |
l@270 | 48 |
l@270 | 49 |
l@270 | 50 #endif |