Jack2 1.9.8

netjack.h

00001 
00002 /*
00003     Copyright (C) 2003 Robert Ham <rah@bash.sh>
00004     Copyright (C) 2005 Torben Hohn <torbenh@gmx.de>
00005 
00006     This program is free software; you can redistribute it and/or modify
00007     it under the terms of the GNU General Public License as published by
00008     the Free Software Foundation; either version 2 of the License, or
00009     (at your option) any later version.
00010 
00011     This program is distributed in the hope that it will be useful,
00012     but WITHOUT ANY WARRANTY; without even the implied warranty of
00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014     GNU General Public License for more details.
00015 
00016     You should have received a copy of the GNU General Public License
00017     along with this program; if not, write to the Free Software
00018     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00019 */
00020 
00021 #ifndef __NETJACK_H__
00022 #define __NETJACK_H__
00023 
00024 #include <unistd.h>
00025 
00026 #include <jack/types.h>
00027 #include <jack/jack.h>
00028 #include <jack/transport.h>
00029 #include "jack/jslist.h"
00030 
00031 #if HAVE_CELT
00032 #include <celt/celt.h>
00033 #endif
00034 
00035 #ifdef __cplusplus
00036 extern "C"
00037 {
00038 #endif
00039 
00040     struct _packet_cache;
00041 
00042     typedef struct _netjack_driver_state netjack_driver_state_t;
00043 
00044     struct _netjack_driver_state {
00045         jack_nframes_t  net_period_up;
00046         jack_nframes_t  net_period_down;
00047 
00048         jack_nframes_t  sample_rate;
00049         jack_nframes_t  bitdepth;
00050         jack_nframes_t  period_size;
00051         jack_time_t         period_usecs;
00052         int                 dont_htonl_floats;
00053         int                 always_deadline;
00054 
00055         jack_nframes_t  codec_latency;
00056 
00057         unsigned int    listen_port;
00058 
00059         unsigned int    capture_channels;
00060         unsigned int    playback_channels;
00061         unsigned int    capture_channels_audio;
00062         unsigned int    playback_channels_audio;
00063         unsigned int    capture_channels_midi;
00064         unsigned int    playback_channels_midi;
00065 
00066         JSList      *capture_ports;
00067         JSList      *playback_ports;
00068         JSList      *playback_srcs;
00069         JSList      *capture_srcs;
00070 
00071         jack_client_t   *client;
00072 
00073 #ifdef WIN32
00074         SOCKET      sockfd;
00075         SOCKET      outsockfd;
00076 #else
00077         int                 sockfd;
00078         int                 outsockfd;
00079 #endif
00080 
00081         struct sockaddr_in syncsource_address;
00082 
00083         int                 reply_port;
00084         int                 srcaddress_valid;
00085 
00086         int sync_state;
00087         unsigned int handle_transport_sync;
00088 
00089         unsigned int *rx_buf;
00090         unsigned int rx_bufsize;
00091         //unsigned int tx_bufsize;
00092         unsigned int mtu;
00093         unsigned int latency;
00094         unsigned int redundancy;
00095 
00096         jack_nframes_t expected_framecnt;
00097         int                expected_framecnt_valid;
00098         unsigned int   num_lost_packets;
00099         jack_time_t        next_deadline;
00100         jack_time_t        deadline_offset;
00101         int                next_deadline_valid;
00102         int                packet_data_valid;
00103         int                resync_threshold;
00104         int                running_free;
00105         int                deadline_goodness;
00106         jack_time_t        time_to_deadline;
00107         unsigned int   use_autoconfig;
00108         unsigned int   resample_factor;
00109         unsigned int   resample_factor_up;
00110         int                jitter_val;
00111         struct _packet_cache * packcache;
00112 #if HAVE_CELT
00113         CELTMode           *celt_mode;
00114 #endif
00115     };
00116 
00117     int netjack_wait( netjack_driver_state_t *netj );
00118     void netjack_send_silence( netjack_driver_state_t *netj, int syncstate );
00119     void netjack_read( netjack_driver_state_t *netj, jack_nframes_t nframes ) ;
00120     void netjack_write( netjack_driver_state_t *netj, jack_nframes_t nframes, int syncstate );
00121     void netjack_attach( netjack_driver_state_t *netj );
00122     void netjack_detach( netjack_driver_state_t *netj );
00123 
00124     netjack_driver_state_t *netjack_init (netjack_driver_state_t *netj,
00125                                           jack_client_t * client,
00126                                           const char *name,
00127                                           unsigned int capture_ports,
00128                                           unsigned int playback_ports,
00129                                           unsigned int capture_ports_midi,
00130                                           unsigned int playback_ports_midi,
00131                                           jack_nframes_t sample_rate,
00132                                           jack_nframes_t period_size,
00133                                           unsigned int listen_port,
00134                                           unsigned int transport_sync,
00135                                           unsigned int resample_factor,
00136                                           unsigned int resample_factor_up,
00137                                           unsigned int bitdepth,
00138                                           unsigned int use_autoconfig,
00139                                           unsigned int latency,
00140                                           unsigned int redundancy,
00141                                           int dont_htonl_floats,
00142                                           int always_deadline,
00143                                           int jitter_val );
00144 
00145     void netjack_release( netjack_driver_state_t *netj );
00146     int netjack_startup( netjack_driver_state_t *netj );
00147 
00148 #ifdef __cplusplus
00149 }
00150 #endif
00151 
00152 #endif