Jack2 1.9.21

net.h
1/*
2 Copyright (C) 2009-2010 Grame
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as published by
6 the Free Software Foundation; either version 2.1 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17
18*/
19
20#ifndef __net_h__
21#define __net_h__
22
23#ifdef __cplusplus
24 extern "C"
25{
26#endif
27
28#include <jack/systemdeps.h>
29#include <jack/types.h>
30#include <jack/weakmacros.h>
31
32#define DEFAULT_MULTICAST_IP "225.3.19.154"
33#define DEFAULT_PORT 19000
34#define DEFAULT_MTU 1500
35#define MASTER_NAME_SIZE 256
36
37// Possible error codes
38
39#define NO_ERROR 0
40#define SOCKET_ERROR -1
41#define SYNC_PACKET_ERROR -2
42#define DATA_PACKET_ERROR -3
43
44#define RESTART_CB_API 1
45
46 enum JackNetEncoder {
47
48 JackFloatEncoder = 0, // samples are transmitted as float
49 JackIntEncoder = 1, // samples are transmitted as 16 bits integer
50 JackCeltEncoder = 2, // samples are transmitted using CELT codec (http://www.celt-codec.org/)
51 JackOpusEncoder = 3, // samples are transmitted using OPUS codec (http://www.opus-codec.org/)
52};
53
54 typedef struct {
55
56 int audio_input; // from master or to slave (-1 to take master audio physical inputs)
57 int audio_output; // to master or from slave (-1 to take master audio physical outputs)
58 int midi_input; // from master or to slave (-1 to take master MIDI physical inputs)
59 int midi_output; // to master or from slave (-1 to take master MIDI physical outputs)
60 int mtu; // network Maximum Transmission Unit
61 int time_out; // in second, -1 means infinite
62 int encoder; // encoder type (one of JackNetEncoder)
63 int kbps; // KB per second for CELT or OPUS codec
64 int latency; // network latency in number of buffers
65
66} jack_slave_t;
67
68 typedef struct {
69
70 int audio_input; // master audio physical outputs (-1 to take slave wanted audio inputs)
71 int audio_output; // master audio physical inputs (-1 to take slave wanted audio outputs)
72 int midi_input; // master MIDI physical outputs (-1 to take slave wanted MIDI inputs)
73 int midi_output; // master MIDI physical inputs (-1 to take slave wanted MIDI outputs)
74 jack_nframes_t buffer_size; // master buffer size
75 jack_nframes_t sample_rate; // master sample rate
76 char master_name[MASTER_NAME_SIZE]; // master machine name
77 int time_out; // in second, -1 means infinite
78 int partial_cycle; // if 'true', partial buffers will be used
79
80} jack_master_t;
81
86 typedef struct _jack_net_slave jack_net_slave_t;
87
99jack_net_slave_t* jack_net_slave_open(const char* ip, int port, const char* name, jack_slave_t* request, jack_master_t* result);
100
108 int jack_net_slave_close(jack_net_slave_t* net);
109
126 typedef int (* JackNetSlaveProcessCallback) (jack_nframes_t buffer_size,
127 int audio_input,
128 float** audio_input_buffer,
129 int midi_input,
130 void** midi_input_buffer,
131 int audio_output,
132 float** audio_output_buffer,
133 int midi_output,
134 void** midi_output_buffer,
135 void* data);
136
146 int jack_set_net_slave_process_callback(jack_net_slave_t * net, JackNetSlaveProcessCallback net_callback, void *arg);
147
155 int jack_net_slave_activate(jack_net_slave_t* net);
156
164 int jack_net_slave_deactivate(jack_net_slave_t* net);
165
173 int jack_net_slave_is_active(jack_net_slave_t* net);
174
183 typedef int (*JackNetSlaveBufferSizeCallback)(jack_nframes_t nframes, void *arg);
184
194 int jack_set_net_slave_buffer_size_callback(jack_net_slave_t *net, JackNetSlaveBufferSizeCallback bufsize_callback, void *arg);
195
204 typedef int (*JackNetSlaveSampleRateCallback)(jack_nframes_t nframes, void *arg);
205
215 int jack_set_net_slave_sample_rate_callback(jack_net_slave_t *net, JackNetSlaveSampleRateCallback samplerate_callback, void *arg);
216
222 typedef void (*JackNetSlaveShutdownCallback)(void* arg);
223
233 int jack_set_net_slave_shutdown_callback(jack_net_slave_t *net, JackNetSlaveShutdownCallback shutdown_callback, void *arg) JACK_OPTIONAL_WEAK_DEPRECATED_EXPORT;
234
246 typedef int (*JackNetSlaveRestartCallback)(void* arg);
247
257 int jack_set_net_slave_restart_callback(jack_net_slave_t *net, JackNetSlaveRestartCallback restart_callback, void *arg) JACK_OPTIONAL_WEAK_EXPORT;
258
265 typedef void (*JackNetSlaveErrorCallback) (int error_code, void* arg);
266
276 int jack_set_net_slave_error_callback(jack_net_slave_t *net, JackNetSlaveErrorCallback error_callback, void *arg) JACK_OPTIONAL_WEAK_EXPORT;
277
281 typedef struct _jack_net_master jack_net_master_t;
282
293jack_net_master_t* jack_net_master_open(const char* ip, int port, jack_master_t* request, jack_slave_t* result);
294
302 int jack_net_master_close(jack_net_master_t* net);
303
315 int jack_net_master_recv(jack_net_master_t* net, int audio_input, float** audio_input_buffer, int midi_input, void** midi_input_buffer);
316
329 int jack_net_master_recv_slice(jack_net_master_t* net, int audio_input, float** audio_input_buffer, int midi_input, void** midi_input_buffer, int frames);
330
342 int jack_net_master_send(jack_net_master_t* net, int audio_output, float** audio_output_buffer, int midi_output, void** midi_output_buffer);
343
356 int jack_net_master_send_slice(jack_net_master_t* net, int audio_output, float** audio_output_buffer, int midi_output, void** midi_output_buffer, int frames);
357
358// Experimental Adapter API
359
363 typedef struct _jack_adapter jack_adapter_t;
364
377jack_adapter_t* jack_create_adapter(int input, int output,
378 jack_nframes_t host_buffer_size,
379 jack_nframes_t host_sample_rate,
380 jack_nframes_t adapted_buffer_size,
381 jack_nframes_t adapted_sample_rate);
382
390 int jack_destroy_adapter(jack_adapter_t* adapter);
391
399 void jack_flush_adapter(jack_adapter_t* adapter);
400
411 int jack_adapter_push_and_pull(jack_adapter_t* adapter, float** input, float** output, unsigned int frames);
412
423 int jack_adapter_pull_and_push(jack_adapter_t* adapter, float** input, float** output, unsigned int frames);
424
425#ifdef __cplusplus
426}
427#endif
428
429#endif /* __net_h__ */
jack_master_t
Definition: net.h:68
jack_slave_t
Definition: net.h:54