RemoteIO.h

Go to the documentation of this file.
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 
00024 // the RemoteIO class
00025 
00026 class RemoteIO : public IO {
00027 
00028 protected:
00029     unsigned _inputs, _outputs;     // The default # of I/O channels
00030     Buffer _outputBuffer;           // My output buffer (proxy for the remote frame stream client)
00031     Buffer _inputBuffer;            // empty input buffer (since we don't pass input across the network [yet])
00032     
00033     struct sockaddr_in _clientAddr, _myAddr;    // Socket addresses for the remote client and me
00034     int _inSock;                    // The RFS socket I listen to
00035     int _outSock;                   // The RFS socket I read/write from/to
00036     
00037     sample * _buffer;               // My local packet buffer (used for io and for the DSP graph)
00038 #ifdef DO_TIMING                    // This is for the performance timing code
00039     struct timeval then, now;       // Used for getting the real time
00040     long timeVals, thisSec;         // Used for CPU usage statistics
00041     long timeSum;
00042 #endif
00043     void init_io(unsigned in, unsigned out);
00044 
00045 public:                     // These data members are public so that they can be used from the thread call
00046     RemoteIO();
00047     RemoteIO(unsigned chans);
00048     ~RemoteIO();
00049     
00050     status open();
00051     status open(unsigned port);
00052     virtual status start();
00053     status stop();
00054     status close();
00055     
00056     void process_request_packet();
00057     int get_out_sock() { return(_outSock); };
00058     sample * get_buffer() { return(_buffer); };
00059     struct sockaddr_in * get_client_addr() { return(&_clientAddr); };
00060 };
00061 
00062 }
00063 
00064 #endif
00065 

Generated on Fri Apr 6 20:18:12 2007 for CSL by  doxygen 1.4.5-20051010