CSL 5.2

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

RemoteIO.h
Go to the documentation of this file.
1 //
2 // RemoteIO.h -- CSL I/O Port for sending sample buffers out over UDP or TCP-IP sockets
3 // (in response to request packets sent from a RemoteStream client)
4 // See the copyright notice and acknowledgment of authors in the file COPYRIGHT
5 //
6 // This is an output driver that receives call-backs from a remote client over a network socket
7 // and calls on its DSP graph to generate a buffer of samples.
8 // See the comment in RemoteStream.h for a description of the packet format
9 //
10
11 #ifndef INCLUDE_REMOTEIO_H
12 #define INCLUDE_REMOTEIO_H
13
14 #include "CSL_Includes.h"
15 #include "ThreadUtilities.h"
16 #include "RemoteStream.h"
17
18 namespace csl {
19
20 // Driver thread function
21
22 extern "C" void * RemoteIO_read_loop(void * inst);
23
24 ///
25 /// the RemoteIO class
26 ///
27
28 class RemoteIO : public IO {
29
30 protected:
31 unsigned _inputs, _outputs; // The default # of I/O channels
32 Buffer _outputBuffer; // My output buffer (proxy for the remote frame stream client)
33 Buffer _inputBuffer; // empty input buffer (since we don't pass input across the network [yet])
34
35 struct sockaddr_in _clientAddr, _myAddr; // Socket addresses for the remote client and me
36 int _inSock; // The RFS socket I listen to
37 int _outSock; // The RFS socket I read/write from/to
38
39 sample * _buffer; // My local packet buffer (used for io and for the DSP graph)
40 #ifdef DO_TIMING // This is for the performance timing code
41 struct timeval then, now; // Used for getting the real time
42 long timeVals, thisSec; // Used for CPU usage statistics
43 long timeSum;
44 #endif
45 void init_io(unsigned in, unsigned out);
46
47 public: // These data members are public so that they can be used from the thread call
48 RemoteIO();
49 RemoteIO(unsigned chans);
50 ~RemoteIO();
51
52 status open();
53 status open(unsigned port);
54 virtual status start();
55 status stop();
56 status close();
57
58 void process_request_packet();
59 int get_out_sock() { return(_outSock); };
60 sample * get_buffer() { return(_buffer); };
61 struct sockaddr_in * get_client_addr() { return(&_clientAddr); };
62 };
63
64 }
65
66 #endif
67