00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
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 #if HAVE_OPUS
00036 #include <opus/opus.h>
00037 #include <opus/opus_custom.h>
00038 #endif
00039
00040 #ifdef __cplusplus
00041 extern "C"
00042 {
00043 #endif
00044
00045 struct _packet_cache;
00046
00047 typedef struct _netjack_driver_state netjack_driver_state_t;
00048
00049 struct _netjack_driver_state {
00050 jack_nframes_t net_period_up;
00051 jack_nframes_t net_period_down;
00052
00053 jack_nframes_t sample_rate;
00054 jack_nframes_t bitdepth;
00055 jack_nframes_t period_size;
00056 jack_time_t period_usecs;
00057 int dont_htonl_floats;
00058 int always_deadline;
00059
00060 jack_nframes_t codec_latency;
00061
00062 unsigned int listen_port;
00063
00064 unsigned int capture_channels;
00065 unsigned int playback_channels;
00066 unsigned int capture_channels_audio;
00067 unsigned int playback_channels_audio;
00068 unsigned int capture_channels_midi;
00069 unsigned int playback_channels_midi;
00070
00071 JSList *capture_ports;
00072 JSList *playback_ports;
00073 JSList *playback_srcs;
00074 JSList *capture_srcs;
00075
00076 jack_client_t *client;
00077
00078 #ifdef WIN32
00079 SOCKET sockfd;
00080 SOCKET outsockfd;
00081 #else
00082 int sockfd;
00083 int outsockfd;
00084 #endif
00085
00086 struct sockaddr_in syncsource_address;
00087
00088 int reply_port;
00089 int srcaddress_valid;
00090
00091 int sync_state;
00092 unsigned int handle_transport_sync;
00093
00094 unsigned int *rx_buf;
00095 unsigned int rx_bufsize;
00096
00097 unsigned int mtu;
00098 unsigned int latency;
00099 unsigned int redundancy;
00100
00101 jack_nframes_t expected_framecnt;
00102 int expected_framecnt_valid;
00103 unsigned int num_lost_packets;
00104 jack_time_t next_deadline;
00105 jack_time_t deadline_offset;
00106 int next_deadline_valid;
00107 int packet_data_valid;
00108 int resync_threshold;
00109 int running_free;
00110 int deadline_goodness;
00111 jack_time_t time_to_deadline;
00112 unsigned int use_autoconfig;
00113 unsigned int resample_factor;
00114 unsigned int resample_factor_up;
00115 int jitter_val;
00116 struct _packet_cache * packcache;
00117 #if HAVE_CELT
00118 CELTMode *celt_mode;
00119 #endif
00120 #if HAVE_OPUS
00121 OpusCustomMode* opus_mode;
00122 #endif
00123 };
00124
00125 int netjack_wait( netjack_driver_state_t *netj );
00126 void netjack_send_silence( netjack_driver_state_t *netj, int syncstate );
00127 void netjack_read( netjack_driver_state_t *netj, jack_nframes_t nframes ) ;
00128 void netjack_write( netjack_driver_state_t *netj, jack_nframes_t nframes, int syncstate );
00129 void netjack_attach( netjack_driver_state_t *netj );
00130 void netjack_detach( netjack_driver_state_t *netj );
00131
00132 netjack_driver_state_t *netjack_init (netjack_driver_state_t *netj,
00133 jack_client_t * client,
00134 const char *name,
00135 unsigned int capture_ports,
00136 unsigned int playback_ports,
00137 unsigned int capture_ports_midi,
00138 unsigned int playback_ports_midi,
00139 jack_nframes_t sample_rate,
00140 jack_nframes_t period_size,
00141 unsigned int listen_port,
00142 unsigned int transport_sync,
00143 unsigned int resample_factor,
00144 unsigned int resample_factor_up,
00145 unsigned int bitdepth,
00146 unsigned int use_autoconfig,
00147 unsigned int latency,
00148 unsigned int redundancy,
00149 int dont_htonl_floats,
00150 int always_deadline,
00151 int jitter_val );
00152
00153 void netjack_release( netjack_driver_state_t *netj );
00154 int netjack_startup( netjack_driver_state_t *netj );
00155
00156 #ifdef __cplusplus
00157 }
00158 #endif
00159
00160 #endif