Jack2  1.9.8
netjack.h
1 
2 /*
3  Copyright (C) 2003 Robert Ham <rah@bash.sh>
4  Copyright (C) 2005 Torben Hohn <torbenh@gmx.de>
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with this program; if not, write to the Free Software
18  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */
20 
21 #ifndef __NETJACK_H__
22 #define __NETJACK_H__
23 
24 #include <unistd.h>
25 
26 #include <jack/types.h>
27 #include <jack/jack.h>
28 #include <jack/transport.h>
29 #include "jack/jslist.h"
30 
31 #if HAVE_CELT
32 #include <celt/celt.h>
33 #endif
34 
35 #ifdef __cplusplus
36 extern "C"
37 {
38 #endif
39 
40  struct _packet_cache;
41 
43 
45  jack_nframes_t net_period_up;
46  jack_nframes_t net_period_down;
47 
48  jack_nframes_t sample_rate;
49  jack_nframes_t bitdepth;
50  jack_nframes_t period_size;
51  jack_time_t period_usecs;
52  int dont_htonl_floats;
53  int always_deadline;
54 
55  jack_nframes_t codec_latency;
56 
57  unsigned int listen_port;
58 
59  unsigned int capture_channels;
60  unsigned int playback_channels;
61  unsigned int capture_channels_audio;
62  unsigned int playback_channels_audio;
63  unsigned int capture_channels_midi;
64  unsigned int playback_channels_midi;
65 
66  JSList *capture_ports;
67  JSList *playback_ports;
68  JSList *playback_srcs;
69  JSList *capture_srcs;
70 
71  jack_client_t *client;
72 
73 #ifdef WIN32
74  SOCKET sockfd;
75  SOCKET outsockfd;
76 #else
77  int sockfd;
78  int outsockfd;
79 #endif
80 
81  struct sockaddr_in syncsource_address;
82 
83  int reply_port;
84  int srcaddress_valid;
85 
86  int sync_state;
87  unsigned int handle_transport_sync;
88 
89  unsigned int *rx_buf;
90  unsigned int rx_bufsize;
91  //unsigned int tx_bufsize;
92  unsigned int mtu;
93  unsigned int latency;
94  unsigned int redundancy;
95 
96  jack_nframes_t expected_framecnt;
97  int expected_framecnt_valid;
98  unsigned int num_lost_packets;
99  jack_time_t next_deadline;
100  jack_time_t deadline_offset;
101  int next_deadline_valid;
102  int packet_data_valid;
103  int resync_threshold;
104  int running_free;
105  int deadline_goodness;
106  jack_time_t time_to_deadline;
107  unsigned int use_autoconfig;
108  unsigned int resample_factor;
109  unsigned int resample_factor_up;
110  int jitter_val;
111  struct _packet_cache * packcache;
112 #if HAVE_CELT
113  CELTMode *celt_mode;
114 #endif
115  };
116 
117  int netjack_wait( netjack_driver_state_t *netj );
118  void netjack_send_silence( netjack_driver_state_t *netj, int syncstate );
119  void netjack_read( netjack_driver_state_t *netj, jack_nframes_t nframes ) ;
120  void netjack_write( netjack_driver_state_t *netj, jack_nframes_t nframes, int syncstate );
121  void netjack_attach( netjack_driver_state_t *netj );
122  void netjack_detach( netjack_driver_state_t *netj );
123 
124  netjack_driver_state_t *netjack_init (netjack_driver_state_t *netj,
125  jack_client_t * client,
126  const char *name,
127  unsigned int capture_ports,
128  unsigned int playback_ports,
129  unsigned int capture_ports_midi,
130  unsigned int playback_ports_midi,
131  jack_nframes_t sample_rate,
132  jack_nframes_t period_size,
133  unsigned int listen_port,
134  unsigned int transport_sync,
135  unsigned int resample_factor,
136  unsigned int resample_factor_up,
137  unsigned int bitdepth,
138  unsigned int use_autoconfig,
139  unsigned int latency,
140  unsigned int redundancy,
141  int dont_htonl_floats,
142  int always_deadline,
143  int jitter_val );
144 
145  void netjack_release( netjack_driver_state_t *netj );
146  int netjack_startup( netjack_driver_state_t *netj );
147 
148 #ifdef __cplusplus
149 }
150 #endif
151 
152 #endif