merge new MTDM code from Fons' latest release.
[jack2.git] / common / netjack.h
blobb21f5bde012d66091cbdd4282d47ed769af5de96
2 /*
3 Copyright (C) 2003 Robert Ham <rah@bash.sh>
4 Copyright (C) 2005 Torben Hohn <torbenh@gmx.de>
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.
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.
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.
21 #ifndef __NETJACK_H__
22 #define __NETJACK_H__
24 #include <unistd.h>
26 #include <jack/types.h>
27 #include <jack/jack.h>
28 #include <jack/transport.h>
29 #include "jack/jslist.h"
31 #if HAVE_CELT
32 #include <celt/celt.h>
33 #endif
35 #if HAVE_OPUS
36 #include <opus/opus.h>
37 #include <opus/opus_custom.h>
38 #endif
40 #ifdef __cplusplus
41 extern "C"
43 #endif
45 struct _packet_cache;
47 typedef struct _netjack_driver_state netjack_driver_state_t;
49 struct _netjack_driver_state {
50 jack_nframes_t net_period_up;
51 jack_nframes_t net_period_down;
53 jack_nframes_t sample_rate;
54 jack_nframes_t bitdepth;
55 jack_nframes_t period_size;
56 jack_time_t period_usecs;
57 int dont_htonl_floats;
58 int always_deadline;
60 jack_nframes_t codec_latency;
62 unsigned int listen_port;
64 unsigned int capture_channels;
65 unsigned int playback_channels;
66 unsigned int capture_channels_audio;
67 unsigned int playback_channels_audio;
68 unsigned int capture_channels_midi;
69 unsigned int playback_channels_midi;
71 JSList *capture_ports;
72 JSList *playback_ports;
73 JSList *playback_srcs;
74 JSList *capture_srcs;
76 jack_client_t *client;
78 #ifdef WIN32
79 SOCKET sockfd;
80 SOCKET outsockfd;
81 #else
82 int sockfd;
83 int outsockfd;
84 #endif
86 struct sockaddr_in syncsource_address;
88 int reply_port;
89 int srcaddress_valid;
91 int sync_state;
92 unsigned int handle_transport_sync;
94 unsigned int *rx_buf;
95 unsigned int rx_bufsize;
96 //unsigned int tx_bufsize;
97 unsigned int mtu;
98 unsigned int latency;
99 unsigned int redundancy;
101 jack_nframes_t expected_framecnt;
102 int expected_framecnt_valid;
103 unsigned int num_lost_packets;
104 jack_time_t next_deadline;
105 jack_time_t deadline_offset;
106 int next_deadline_valid;
107 int packet_data_valid;
108 int resync_threshold;
109 int running_free;
110 int deadline_goodness;
111 jack_time_t time_to_deadline;
112 unsigned int use_autoconfig;
113 unsigned int resample_factor;
114 unsigned int resample_factor_up;
115 int jitter_val;
116 struct _packet_cache * packcache;
117 #if HAVE_CELT
118 CELTMode *celt_mode;
119 #endif
120 #if HAVE_OPUS
121 OpusCustomMode* opus_mode;
122 #endif
125 int netjack_wait( netjack_driver_state_t *netj );
126 void netjack_send_silence( netjack_driver_state_t *netj, int syncstate );
127 void netjack_read( netjack_driver_state_t *netj, jack_nframes_t nframes ) ;
128 void netjack_write( netjack_driver_state_t *netj, jack_nframes_t nframes, int syncstate );
129 void netjack_attach( netjack_driver_state_t *netj );
130 void netjack_detach( netjack_driver_state_t *netj );
132 netjack_driver_state_t *netjack_init (netjack_driver_state_t *netj,
133 jack_client_t * client,
134 const char *name,
135 unsigned int capture_ports,
136 unsigned int playback_ports,
137 unsigned int capture_ports_midi,
138 unsigned int playback_ports_midi,
139 jack_nframes_t sample_rate,
140 jack_nframes_t period_size,
141 unsigned int listen_port,
142 unsigned int transport_sync,
143 unsigned int resample_factor,
144 unsigned int resample_factor_up,
145 unsigned int bitdepth,
146 unsigned int use_autoconfig,
147 unsigned int latency,
148 unsigned int redundancy,
149 int dont_htonl_floats,
150 int always_deadline,
151 int jitter_val );
153 void netjack_release( netjack_driver_state_t *netj );
154 int netjack_startup( netjack_driver_state_t *netj );
156 #ifdef __cplusplus
158 #endif
160 #endif