00001 // 00002 // RemoteIO.h -- CSL I/O Port for sending sample buffers out over UDP or TCP-IP sockets 00003 // (in response to request packets sent from a RemoteStream client) 00004 // See the copyright notice and acknowledgment of authors in the file COPYRIGHT 00005 // 00006 // This is an output driver that receives call-backs from a remote client over a network socket 00007 // and calls on its DSP graph to generate a buffer of samples. 00008 // See the comment in RemoteStream.h for a description of the packet format 00009 // 00010 00011 #ifndef INCLUDE_REMOTEIO_H 00012 #define INCLUDE_REMOTEIO_H 00013 00014 #include "CSL_Includes.h" 00015 #include "ThreadUtilities.h" 00016 #include "RemoteStream.h" 00017 00018 namespace csl { 00019 00020 // Driver thread function 00021 00022 extern "C" void * RemoteIO_read_loop(void * inst); 00023 00027 00028 class RemoteIO : public IO { 00029 00030 protected: 00031 unsigned _inputs, _outputs; // The default # of I/O channels 00032 Buffer _outputBuffer; // My output buffer (proxy for the remote frame stream client) 00033 Buffer _inputBuffer; // empty input buffer (since we don't pass input across the network [yet]) 00034 00035 struct sockaddr_in _clientAddr, _myAddr; // Socket addresses for the remote client and me 00036 int _inSock; // The RFS socket I listen to 00037 int _outSock; // The RFS socket I read/write from/to 00038 00039 sample * _buffer; // My local packet buffer (used for io and for the DSP graph) 00040 #ifdef DO_TIMING // This is for the performance timing code 00041 struct timeval then, now; // Used for getting the real time 00042 long timeVals, thisSec; // Used for CPU usage statistics 00043 long timeSum; 00044 #endif 00045 void init_io(unsigned in, unsigned out); 00046 00047 public: // These data members are public so that they can be used from the thread call 00048 RemoteIO(); 00049 RemoteIO(unsigned chans); 00050 ~RemoteIO(); 00051 00052 status open(); 00053 status open(unsigned port); 00054 virtual status start(); 00055 status stop(); 00056 status close(); 00057 00058 void process_request_packet(); 00059 int get_out_sock() { return(_outSock); }; 00060 sample * get_buffer() { return(_buffer); }; 00061 struct sockaddr_in * get_client_addr() { return(&_clientAddr); }; 00062 }; 00063 00064 } 00065 00066 #endif 00067
1.5.8