20 #include "JackMidiPort.h" 21 #include "JackTools.h" 23 #include "transport.h" 25 #include <netinet/in.h> 36 #define htonll(x) ((((uint64_t)htonl(x)) << 32) + htonl(x >> 32)) 37 #define ntohll(x) ((((uint64_t)ntohl(x)) << 32) + ntohl(x >> 32)) 41 #define NETWORK_PROTOCOL 8 43 #define NET_SYNCHING 0 44 #define SYNC_PACKET_ERROR -2 45 #define DATA_PACKET_ERROR -3 47 #define OPTIMIZED_PROTOCOL 1 49 #define HEADER_SIZE (sizeof(packet_header_t)) 50 #define PACKET_AVAILABLE_SIZE(params) ((params)->fMtu - sizeof(packet_header_t)) 54 typedef struct _session_params session_params_t;
55 typedef struct _packet_header packet_header_t;
56 typedef struct _net_transport_data net_transport_data_t;
57 typedef struct sockaddr socket_address_t;
58 typedef struct in_addr address_t;
59 typedef jack_default_audio_sample_t sample_t;
92 uint32_t fProtocolVersion;
94 char fName[JACK_CLIENT_NAME_SIZE];
95 char fMasterNetName[JACK_SERVER_NAME_SIZE];
96 char fSlaveNetName[JACK_SERVER_NAME_SIZE];
99 uint32_t fTransportSync;
100 int32_t fSendAudioChannels;
101 int32_t fReturnAudioChannels;
102 int32_t fSendMidiChannels;
103 int32_t fReturnMidiChannels;
104 uint32_t fSampleRate;
105 uint32_t fPeriodSize;
106 uint32_t fSampleEncoder;
108 uint32_t fSlaveSyncMode;
109 uint32_t fNetworkLatency;
110 } POST_PACKED_STRUCTURE;
120 NET_SOCKET_ERROR = 0,
129 typedef enum _net_status net_status_t;
137 enum _sync_packet_type
147 typedef enum _sync_packet_type sync_packet_type_t;
176 uint32_t fDataStream;
179 uint32_t fPacketSize;
180 uint32_t fActivePorts;
184 uint32_t fIsLastPckt;
185 } POST_PACKED_STRUCTURE;
193 enum _net_timebase_master
196 RELEASE_TIMEBASEMASTER = 1,
198 CONDITIONAL_TIMEBASEMASTER = 3
201 typedef enum _net_timebase_master net_timebase_master_t;
214 uint32_t fTimebaseMaster;
217 } POST_PACKED_STRUCTURE;
248 size_t fCycleBytesSize;
258 size_t GetCycleSize();
259 int GetNumPackets(
int data_sizen,
int max_size);
265 void DisplayEvents();
268 int RenderFromJackPorts();
269 void RenderToJackPorts();
272 void RenderFromNetwork(
int sub_cycle,
size_t copy_size);
273 int RenderToNetwork(
int sub_cycle,
size_t total_size);
289 sample_t** fPortBuffer;
290 bool* fConnectedPorts;
292 jack_nframes_t fPeriodSize;
293 jack_nframes_t fSubPeriodSize;
294 size_t fSubPeriodBytesSize;
296 float fCycleDuration;
297 size_t fCycleBytesSize;
299 int CheckPacket(
int cycle,
int sub_cycle);
308 bool GetConnected(
int port_index) {
return fConnectedPorts[port_index]; }
309 void SetConnected(
int port_index,
bool state) { fConnectedPorts[port_index] = state; }
312 virtual size_t GetCycleSize() = 0;
315 virtual float GetCycleDuration() = 0;
317 virtual int GetNumPackets(
int active_ports) = 0;
319 virtual void SetBuffer(
int index, sample_t* buffer);
320 virtual sample_t* GetBuffer(
int index);
323 virtual int RenderFromJackPorts(
int nframes);
324 virtual void RenderToJackPorts(
int nframes);
327 virtual int RenderFromNetwork(
int cycle,
int sub_cycle, uint32_t port_num) = 0;
328 virtual int RenderToNetwork(
int sub_cycle, uint32_t port_num) = 0;
330 virtual int ActivePortsToNetwork(
char* net_buffer);
331 virtual void ActivePortsFromNetwork(
char* net_buffer, uint32_t port_num);
342 void UpdateParams(
int active_ports);
345 void RenderFromNetwork(
char* net_buffer,
int active_port,
int sub_cycle);
346 void RenderToNetwork(
char* net_buffer,
int active_port,
int sub_cycle);
354 size_t GetCycleSize();
357 float GetCycleDuration();
358 int GetNumPackets(
int active_ports);
361 int RenderFromNetwork(
int cycle,
int sub_cycle, uint32_t port_num);
362 int RenderToNetwork(
int sub_cycle, uint32_t port_num);
368 #include <celt/celt.h> 374 CELTMode** fCeltMode;
375 CELTEncoder** fCeltEncoder;
376 CELTDecoder** fCeltDecoder;
378 int fCompressedSizeByte;
379 unsigned char** fCompressedBuffer;
381 size_t fLastSubPeriodBytesSize;
387 NetCeltAudioBuffer(
session_params_t* params, uint32_t nports,
char* net_buffer,
int kbps);
388 virtual ~NetCeltAudioBuffer();
391 size_t GetCycleSize();
394 float GetCycleDuration();
395 int GetNumPackets(
int active_ports);
398 int RenderFromJackPorts(
int nframes);
399 void RenderToJackPorts(
int nframes);
402 int RenderFromNetwork(
int cycle,
int sub_cycle, uint32_t port_num);
403 int RenderToNetwork(
int sub_cycle, uint32_t port_num);
410 #include <opus/opus.h> 411 #include <opus/opus_custom.h> 417 OpusCustomMode** fOpusMode;
418 OpusCustomEncoder** fOpusEncoder;
419 OpusCustomDecoder** fOpusDecoder;
421 int fCompressedMaxSizeByte;
422 unsigned short* fCompressedSizesByte;
424 size_t fLastSubPeriodBytesSize;
426 unsigned char** fCompressedBuffer;
431 NetOpusAudioBuffer(
session_params_t* params, uint32_t nports,
char* net_buffer,
int kbps);
432 virtual ~NetOpusAudioBuffer();
435 size_t GetCycleSize();
438 float GetCycleDuration();
439 int GetNumPackets(
int active_ports);
442 int RenderFromJackPorts(
int nframes);
443 void RenderToJackPorts(
int nframes);
446 int RenderFromNetwork(
int cycle,
int sub_cycle, uint32_t port_num);
447 int RenderToNetwork(
int sub_cycle, uint32_t port_num);
456 int fCompressedSizeByte;
458 size_t fLastSubPeriodBytesSize;
468 size_t GetCycleSize();
471 float GetCycleDuration();
472 int GetNumPackets(
int active_ports);
475 int RenderFromJackPorts(
int nframes);
476 void RenderToJackPorts(
int nframes);
479 int RenderFromNetwork(
int cycle,
int sub_cycle, uint32_t port_num);
480 int RenderToNetwork(
int sub_cycle, uint32_t port_num);
486 SERVER_EXPORT
int SocketAPIInit();
487 SERVER_EXPORT
int SocketAPIEnd();
504 SERVER_EXPORT
int SetPacketType(
session_params_t* params, sync_packet_type_t packet_type);
506 SERVER_EXPORT
const char* GetTransportState(
int transport_state);
This structure containes master/slave connection parameters, it's used to setup the whole system...