Jack2  1.9.10
JackNetDriver.h
00001 /*
00002 Copyright (C) 2008-2011 Romain Moret at Grame
00003 
00004 This program is free software; you can redistribute it and/or modify
00005 it under the terms of the GNU General Public License as published by
00006 the Free Software Foundation; either version 2 of the License, or
00007 (at your option) any later version.
00008 
00009 This program is distributed in the hope that it will be useful,
00010 but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 GNU General Public License for more details.
00013 
00014 You should have received a copy of the GNU General Public License
00015 along with this program; if not, write to the Free Software
00016 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00017 
00018 */
00019 
00020 #ifndef __JackNetDriver__
00021 #define __JackNetDriver__
00022 
00023 #include "JackTimedDriver.h"
00024 #include "JackNetInterface.h"
00025 
00026 //#define JACK_MONITOR
00027 
00028 namespace Jack
00029 {
00034     class JackNetDriver : public JackWaiterDriver, public JackNetSlaveInterface
00035     {
00036 
00037         private:
00038 
00039             //jack data
00040             jack_port_id_t* fMidiCapturePortList;
00041             jack_port_id_t* fMidiPlaybackPortList;
00042 
00043             //transport
00044             int fLastTransportState;
00045             int fLastTimebaseMaster;
00046             
00047             // The wanted value at creation time (may be different than the value actually returned by the master)
00048             int fWantedAudioCaptureChannels;   
00049             int fWantedAudioPlaybackChannels;  
00050             
00051             int fWantedMIDICaptureChannels;
00052             int fWantedMIDIPlaybackChannels;
00053             
00054             bool fAutoSave;
00055       
00056             //monitoring
00057         #ifdef JACK_MONITOR
00058             JackGnuPlotMonitor<float>* fNetTimeMon;
00059             jack_time_t fRcvSyncUst;
00060         #endif
00061 
00062             bool Initialize();
00063             void FreeAll();
00064 
00065             int AllocPorts();
00066             int FreePorts();
00067 
00068             //transport
00069             void EncodeTransportData();
00070             void DecodeTransportData();
00071 
00072             JackMidiBuffer* GetMidiInputBuffer(int port_index);
00073             JackMidiBuffer* GetMidiOutputBuffer(int port_index);
00074 
00075             void SaveConnections(int alias);
00076             
00077             void UpdateLatencies();
00078 
00079         public:
00080 
00081             JackNetDriver(const char* name, const char* alias, JackLockedEngine* engine, JackSynchro* table,
00082                         const char* ip, int port, int mtu, int midi_input_ports, int midi_output_ports,
00083                         char* net_name, uint transport_sync, int network_latency, int celt_encoding, 
00084                         int opus_encoding, bool auto_save);
00085             virtual ~JackNetDriver();
00086 
00087             int Open(jack_nframes_t buffer_size,
00088                          jack_nframes_t samplerate,
00089                          bool capturing,
00090                          bool playing,
00091                          int inchannels,
00092                          int outchannels,
00093                          bool monitor,
00094                          const char* capture_driver_name,
00095                          const char* playback_driver_name,
00096                          jack_nframes_t capture_latency,
00097                          jack_nframes_t playback_latency);
00098             int Close();
00099 
00100             int Attach();
00101             int Detach();
00102 
00103             int Read();
00104             int Write();
00105 
00106             // BufferSize can't be changed
00107             bool IsFixedBufferSize()
00108             {
00109                 return true;
00110             }
00111 
00112             int SetBufferSize(jack_nframes_t buffer_size)
00113             {
00114                 return -1;
00115             }
00116 
00117             int SetSampleRate(jack_nframes_t sample_rate)
00118             {
00119                 return -1;
00120             }
00121 
00122     };
00123 }
00124 
00125 #endif