JackNetTool.h 22.3 KB
Newer Older
1
/*
sletz's avatar
sletz committed
2
Copyright (C) 2008 Romain Moret at Grame
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

*/
sletz's avatar
sletz committed
19
20

#include "JackMidiPort.h"
21
#include "JackTools.h"
22
#include "JackPlatformPlug.h"
23
#include "types.h"
24
#include "transport.h"
sletz's avatar
sletz committed
25
#ifndef WIN32
26
#include <netinet/in.h>
sletz's avatar
sletz committed
27
#endif
sletz's avatar
sletz committed
28
29
#include <cmath>

moret's avatar
moret committed
30
31
using namespace std;

sletz's avatar
sletz committed
32
33
34
35
36
37
38
39
40
41
#ifndef htonll
#ifdef __BIG_ENDIAN__
#define htonll(x)   (x)
#define ntohll(x)   (x)
#else
#define htonll(x)   ((((uint64_t)htonl(x)) << 32) + htonl(x >> 32))
#define ntohll(x)   ((((uint64_t)ntohl(x)) << 32) + ntohl(x >> 32))
#endif
#endif

sletz's avatar
sletz committed
42
43
namespace Jack
{
44
45
    typedef struct _session_params session_params_t;
    typedef struct _packet_header packet_header_t;
46
    typedef struct _net_transport_data net_transport_data_t;
47
48
49
    typedef struct sockaddr socket_address_t;
    typedef struct in_addr address_t;
    typedef jack_default_audio_sample_t sample_t;
sletz's avatar
sletz committed
50
51
52

//session params ******************************************************************************

moret's avatar
moret committed
53
54
55
56
57
58
59
60
61
62
63
64
    /**
    \brief This structure containes master/slave connection parameters, it's used to setup the whole system

    We have :
        - some info like version, type and packet id
        - names
        - network parameters (hostnames and mtu)
        - nunber of audio and midi channels
        - sample rate and buffersize
        - number of audio frames in one network packet (depends on the channel number)
        - is the NetDriver in Sync or ASync mode ?
        - is the NetDriver linked with the master's transport
sletz's avatar
sletz committed
65

66
    Data encoding : headers (session_params and packet_header) are encoded using HTN kind of functions but float data
sletz's avatar
sletz committed
67
    are kept in LITTLE_ENDIAN format (to avoid 2 conversions in the more common LITTLE_ENDIAN <==> LITTLE_ENDIAN connection case).
moret's avatar
moret committed
68
    */
sletz's avatar
sletz committed
69

sletz's avatar
sletz committed
70
71
    #define MASTER_PROTOCOL 2
    #define SLAVE_PROTOCOL 2
72

73
74
    struct _session_params
    {
moret's avatar
moret committed
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
        char fPacketType[7];                //packet type ('param')
        char fProtocolVersion;              //version
        uint32_t fPacketID;                 //indicates the packet type
        char fName[JACK_CLIENT_NAME_SIZE];  //slave's name
        char fMasterNetName[256];           //master hostname (network)
        char fSlaveNetName[256];            //slave hostname (network)
        uint32_t fMtu;                      //connection mtu
        uint32_t fID;                       //slave's ID
        uint32_t fTransportSync;            //is the transport synced ?
        uint32_t fSendAudioChannels;        //number of master->slave channels
        uint32_t fReturnAudioChannels;      //number of slave->master channels
        uint32_t fSendMidiChannels;         //number of master->slave midi channels
        uint32_t fReturnMidiChannels;       //number of slave->master midi channels
        uint32_t fSampleRate;               //session sample rate
        uint32_t fPeriodSize;               //period size
        uint32_t fBitdepth;                 //samples bitdepth (unused)
moret's avatar
moret committed
91
        uint32_t fSlaveSyncMode;            //is the slave in sync mode ?
92
        char fNetworkMode;                  //fast, normal or slow mode
93
    };
sletz's avatar
sletz committed
94
95
96

//net status **********************************************************************************

moret's avatar
moret committed
97
98
99
    /**
    \Brief This enum groups network error by type
    */
100

101
102
103
104
105
106
107
108
109
110
    enum  _net_status
    {
        NET_SOCKET_ERROR = 0,
        NET_CONNECT_ERROR,
        NET_ERROR,
        NET_SEND_ERROR,
        NET_RECV_ERROR,
        NET_CONNECTED,
        NET_ROLLING
    };
sletz's avatar
sletz committed
111

112
    typedef enum _net_status net_status_t;
sletz's avatar
sletz committed
113
114
115

//sync packet type ****************************************************************************

moret's avatar
moret committed
116
117
118
    /**
    \Brief This enum indicates the type of a sync packet (used in the initialization phase)
    */
119

120
121
    enum _sync_packet_type
    {
122
123
124
125
126
127
        INVALID = 0,        //...
        SLAVE_AVAILABLE,    //a slave is available
        SLAVE_SETUP,        //slave configuration
        START_MASTER,       //slave is ready, start master
        START_SLAVE,        //master is ready, activate slave
        KILL_MASTER         //master must stop
128
    };
sletz's avatar
sletz committed
129

130
    typedef enum _sync_packet_type sync_packet_type_t;
sletz's avatar
sletz committed
131
132
133
134


//packet header *******************************************************************************

moret's avatar
moret committed
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
    /**
    \Brief This structure is a complete header

    A header indicates :
        - it is a header
        - the type of data the packet contains (sync, midi or audio)
        - the path of the packet (send -master->slave- or return -slave->master-)
        - the unique ID of the slave
        - the sample's bitdepth (unused for now)
        - the size of the midi data contains in the packet (indicates how much midi data will be sent)
        - the number of midi packet(s) : more than one is very unusual, it depends on the midi load
        - the ID of the current cycle (used to check missing packets)
        - the ID of the packet subcycle (for audio data)
        - a flag indicating this packet is the last of the cycle (for sync robustness, it's better to process this way)
        - a flag indicating if, in async mode, the previous graph was not finished or not
        - padding to fill 64 bytes

    */
153

154
155
    struct _packet_header
    {
156
        char fPacketType[7];        //packet type ( 'headr' )
157
        char fDataType;             //a for audio, m for midi and s for sync
158
        char fDataStream;           //s for send, r for return
159
        uint32_t fID;               //unique ID of the slave
160
        uint32_t fBitdepth;         //bitdepth of the data samples
sletz's avatar
sletz committed
161
        uint32_t fNumPacket;        //number of data packets of the cycle
moret's avatar
moret committed
162
        uint32_t fPacketSize;       //packet size in bytes
163
164
        uint32_t fCycle;            //process cycle counter
        uint32_t fSubCycle;         //midi/audio subcycle counter
moret's avatar
moret committed
165
        uint32_t fIsLastPckt;       //is it the last packet of a given cycle ('y' or 'n')
166
    };
sletz's avatar
sletz committed
167

168
169
170
171
172
173
174
175
//net timebase master

    /**
    \Brief This enum describes timebase master's type
    */

    enum _net_timebase_master
    {
176
177
178
179
        NO_CHANGE = 0,
        RELEASE_TIMEBASEMASTER = 1,
        TIMEBASEMASTER = 2,
        CONDITIONAL_TIMEBASEMASTER = 3
180
181
182
183
184
    };

    typedef enum _net_timebase_master net_timebase_master_t;


185
186
//transport data ******************************************************************************

moret's avatar
moret committed
187
    /**
188
    \Brief This structure contains transport data to be sent over the network
moret's avatar
moret committed
189
    */
190

moret's avatar
moret committed
191
192
    struct _net_transport_data
    {
193
194
        uint32_t fNewState;             //is it a state change
        uint32_t fTimebaseMaster;       //is there a new timebase master
moret's avatar
moret committed
195
        int32_t fState;                 //current cycle state
196
        jack_position_t fPosition;      //current cycle position
moret's avatar
moret committed
197
    };
sletz's avatar
sletz committed
198
199
    
 //midi data ***********************************************************************************
sletz's avatar
sletz committed
200

moret's avatar
moret committed
201
202
    /**
    \Brief Midi buffer and operations class
203

moret's avatar
moret committed
204
205
206
207
208
209
210
211
212
    This class is a toolset to manipulate Midi buffers.
    A JackMidiBuffer has a fixed size, which is the same than an audio buffer size.
    An intermediate fixed size buffer allows to uninterleave midi data (from jack ports).
    But for a big majority of the process cycles, this buffer is filled less than 1%,
    Sending over a network 99% of useless data seems completely unappropriate.
    The idea is to count effective midi data, and then send the smallest packet we can.
    To do it, we use an intermediate buffer.
    We have two methods to convert data from jack ports to intermediate buffer,
    And two others to convert this intermediate buffer to a network buffer (header + payload data)
213

moret's avatar
moret committed
214
    */
215

216
    class SERVER_EXPORT NetMidiBuffer
217
    {
218
219
220
221
222
223
224
        private:
            int fNPorts;
            size_t fMaxBufsize;
            int fMaxPcktSize;
            char* fBuffer;
            char* fNetBuffer;
            JackMidiBuffer** fPortBuffer;
sletz's avatar
sletz committed
225
226
            
            size_t fCycleSize;  // needed size in bytes ofr an entire cycle
227
228
229
230
231
232
233

        public:
            NetMidiBuffer ( session_params_t* params, uint32_t nports, char* net_buffer );
            ~NetMidiBuffer();

            void Reset();
            size_t GetSize();
sletz's avatar
sletz committed
234
            
sletz's avatar
sletz committed
235
236
237
238
239
            // needed size in bytes for an entire cycle
            size_t GetCycleSize();
            
            int GetNumPackets();
            
240
241
            //utility
            void DisplayEvents();
sletz's avatar
sletz committed
242
            
243
244
245
            //jack<->buffer
            int RenderFromJackPorts();
            int RenderToJackPorts();
sletz's avatar
sletz committed
246
            
247
248
249
250
251
252
            //network<->buffer
            int RenderFromNetwork ( int subcycle, size_t copy_size );
            int RenderToNetwork ( int subcycle, size_t total_size );

            void SetBuffer ( int index, JackMidiBuffer* buffer );
            JackMidiBuffer* GetBuffer ( int index );
253
    };
sletz's avatar
sletz committed
254
255
256

// audio data *********************************************************************************

257
258
259
260
261
262
263
264
265
266
    class SERVER_EXPORT NetAudioBuffer 
    {
    
        public:
            NetAudioBuffer ()
            {}
            ~NetAudioBuffer()
            {}
            
            virtual size_t GetSize() = 0;
sletz's avatar
sletz committed
267
            
sletz's avatar
sletz committed
268
269
270
271
272
273
274
275
            // needed syze in bytes ofr an entire cycle
            virtual size_t GetCycleSize() = 0;
            
            // cycle duration in sec
            virtual float GetCycleDuration() = 0;
            
            virtual int GetNumPackets() = 0;
            
276
            //jack<->buffer
sletz's avatar
sletz committed
277
278
            virtual int RenderFromJackPorts () = 0;
            virtual int RenderToJackPorts () = 0;
sletz's avatar
sletz committed
279
280
            
            //network<->buffer
sletz's avatar
sletz committed
281
282
            virtual int RenderFromNetwork ( int cycle,  int subcycle, size_t copy_size ) = 0;
            virtual int RenderToNetwork (int subcycle, size_t total_size ) = 0;
283
284
285
286
287

            virtual void SetBuffer ( int index, sample_t* buffer ) = 0;
            virtual sample_t* GetBuffer ( int index ) = 0;
   };

moret's avatar
moret committed
288
289
    /**
    \Brief Audio buffer and operations class
290

moret's avatar
moret committed
291
292
293
294
    This class is a toolset to manipulate audio buffers.
    The manipulation of audio buffers is similar to midi buffer, except those buffers have fixed size.
    The interleaving/uninterleaving operations are simplier here because audio buffers have fixed size,
    So there is no need of an intermediate buffer as in NetMidiBuffer.
295

moret's avatar
moret committed
296
    */
297
298
299
300
301
302
303
304
    
    struct JackPortList {
    
        jack_nframes_t fPeriodSize;
        jack_nframes_t fSubPeriodSize;
        size_t fSubPeriodBytesSize;
        sample_t** fPortBuffer;
        int fNPorts;
sletz's avatar
sletz committed
305
306
307
308
        size_t fCycleSize; // needed size in bytes for an entire cycle
        float fCycleDuration; // in dec 
        
        int fLastSubCycle;
309
310
311
312
313
        
        JackPortList(session_params_t* params, uint32_t nports)
        {
            fNPorts = nports;
            fPeriodSize = params->fPeriodSize;
sletz's avatar
sletz committed
314
315
316
317
318
319
320
321
322
            
             if (params->fSendAudioChannels == 0 && params->fReturnAudioChannels == 0) {
                fSubPeriodSize = params->fPeriodSize;
            } else {
                jack_nframes_t period = ( int ) powf ( 2.f, ( int ) ( log (float ((params->fMtu - sizeof(packet_header_t)))
                                                   / ( max ( params->fReturnAudioChannels, params->fSendAudioChannels ) * sizeof ( sample_t ) ) ) / log ( 2. ) ) );
                fSubPeriodSize = ( period > params->fPeriodSize ) ? params->fPeriodSize : period;
            }
     
323
            fSubPeriodBytesSize = fSubPeriodSize * sizeof ( sample_t );
sletz's avatar
sletz committed
324
            
325
326
327
            fPortBuffer = new sample_t* [fNPorts];
            for ( int port_index = 0; port_index < fNPorts; port_index++ )
                fPortBuffer[port_index] = NULL;
sletz's avatar
sletz committed
328
329
330
331
332
333
334
335
336
337
                
            fCycleDuration = float(fSubPeriodSize) / float(params->fSampleRate);
            fCycleSize = params->fMtu * ( fPeriodSize / fSubPeriodBytesSize );
            
            fLastSubCycle = -1;
        }
        
        int GetNumPackets()
        {
            return fPeriodSize / fSubPeriodSize;
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
        }
        
        JackPortList()
        {
            fNPorts = 0;
            fPeriodSize = 0;
            fSubPeriodSize = 0;
            fSubPeriodBytesSize = 0;
            fPortBuffer = 0;
        }
     
        ~JackPortList()
        {
            delete [] fPortBuffer;
        }
        
        void SetBuffer( int index, sample_t* buffer )
        {
            fPortBuffer[index] = buffer;
        }
        
        sample_t* GetBuffer ( int index ) 
        {
            return fPortBuffer[index];
        }
        
        void Copy(sample_t** buffers)
        {
            for ( int port_index = 0; port_index < fNPorts; port_index++ )
                memcpy(buffers[port_index], fPortBuffer[port_index], fPeriodSize * sizeof(float));
        }
        
        size_t GetSize()
        {
             return fNPorts * fSubPeriodBytesSize;
        }
sletz's avatar
sletz committed
374
375
376
377
378
379
380
381
382
383
384
385
386
        
        // needed syze in bytes ofr an entire cycle
        size_t GetCycleSize()
        {
            return fCycleSize;
        }
        
        // cycle duration in sec
        float GetCycleDuration()
        {
            return fCycleDuration;
        }
        
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
    #ifdef __BIG_ENDIAN__

        static inline float SwapFloat(float f)
        {
              union
              {
                float f;
                unsigned char b[4];
              } dat1, dat2;

              dat1.f = f;
              dat2.b[0] = dat1.b[3];
              dat2.b[1] = dat1.b[2];
              dat2.b[2] = dat1.b[1];
              dat2.b[3] = dat1.b[0];
              return dat2.f;
        }

sletz's avatar
sletz committed
405
        int RenderFromJackPorts ()
406
        {
sletz's avatar
sletz committed
407
            return fNPorts * fSubPeriodBytesSize;  // in bytes
408
409
        }

sletz's avatar
sletz committed
410
        int RenderToJackPorts ()
411
        {
sletz's avatar
sletz committed
412
413
414
415
416
417
418
            return fPeriodSize * sizeof(sample_t);  // in bytes TODO
        }
        
        //network<->buffer
        int RenderFromNetwork (char* net_buffer, int cycle,  int subcycle, size_t copy_size )
        {
             for ( int port_index = 0; port_index < fNPorts; port_index++ ) {
419
420
421
422
423
                float* src = (float*)(net_buffer + port_index * fSubPeriodBytesSize);
                float* dst = (float*)(fPortBuffer[port_index] + subcycle * fSubPeriodSize);
                for (unsigned int sample = 0; sample < fSubPeriodBytesSize / sizeof(float); sample++) {
                    dst[sample] = SwapFloat(src[sample]);
                }
sletz's avatar
sletz committed
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
            }  
     
            return copy_size;
        }
        
        int RenderToNetwork (char* net_buffer, int subcycle, size_t total_size )
        {
                       
             for ( int port_index = 0; port_index < fNPorts; port_index++ ) {
                float* src = (float*)(fPortBuffer[port_index] + subcycle * fSubPeriodSize);
                float* dst = (float*)(net_buffer + port_index * fSubPeriodBytesSize);
                for (unsigned int sample = 0; sample < fSubPeriodBytesSize / sizeof(float); sample++) {
                    dst[sample] = SwapFloat(src[sample]);
                }
            }
            
            return fNPorts * fSubPeriodBytesSize; 
441
442
443
444
        }
        
    #else

sletz's avatar
sletz committed
445
        int RenderFromJackPorts ()
446
        {
sletz's avatar
sletz committed
447
            return fNPorts * fSubPeriodBytesSize;  // in bytes
448
449
        }

sletz's avatar
sletz committed
450
451
452
453
454
455
456
457
        int RenderToJackPorts ()
        {
            fLastSubCycle = -1;
            return fPeriodSize * sizeof(sample_t);  // in bytes; TODO
        }
        
         //network<->buffer
        int RenderFromNetwork (char* net_buffer, int cycle,  int subcycle, size_t copy_size )
458
459
460
        {
            for ( int port_index = 0; port_index < fNPorts; port_index++ )
                memcpy ( fPortBuffer[port_index] + subcycle * fSubPeriodSize, net_buffer + port_index * fSubPeriodBytesSize, fSubPeriodBytesSize );
sletz's avatar
sletz committed
461
462
463
464
465
466
467
468
469
470
471
472
473
            if (subcycle != fLastSubCycle + 1) {
                jack_error("Packet(s) missing from... %d %d", fLastSubCycle, subcycle);
            }
            fLastSubCycle = subcycle;
            return copy_size;
        }
        
        int RenderToNetwork (char* net_buffer,int subcycle, size_t total_size )
        {
            for ( int port_index = 0; port_index < fNPorts; port_index++ )
                memcpy ( net_buffer + port_index * fSubPeriodBytesSize, fPortBuffer[port_index] + subcycle * fSubPeriodSize, fSubPeriodBytesSize );
            
            return fNPorts * fSubPeriodBytesSize; 
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
        }

    #endif
    
    };
    
    struct JackPortListAllocate : public JackPortList {
     
        JackPortListAllocate()
        {
            fNPorts = 0;
            fPeriodSize = 0;
            fSubPeriodSize = 0;
            fSubPeriodBytesSize = 0;
            fPortBuffer = 0;
        }
        
        ~JackPortListAllocate()
        {
            for ( int port_index = 0; port_index < fNPorts; port_index++ )
                delete [] fPortBuffer[port_index];
            delete [] fPortBuffer;
        }
        
        void Init(session_params_t* params, uint32_t nports)
        {
            fNPorts = nports;
            fPeriodSize = params->fPeriodSize;
sletz's avatar
sletz committed
502
503
504
505
506
507
508
509
510
            
            if (params->fSendAudioChannels == 0 && params->fReturnAudioChannels == 0) {
                fSubPeriodSize = params->fPeriodSize;
            } else {
                jack_nframes_t period = ( int ) powf ( 2.f, ( int ) ( log (float ((params->fMtu - sizeof(packet_header_t)))
                                                   / ( max ( params->fReturnAudioChannels, params->fSendAudioChannels ) * sizeof ( sample_t ) ) ) / log ( 2. ) ) );
                fSubPeriodSize = ( period > params->fPeriodSize ) ? params->fPeriodSize : period;
            }
            
511
512
513
514
515
516
517
            fSubPeriodBytesSize = fSubPeriodSize * sizeof ( sample_t );
            fPortBuffer = new sample_t* [fNPorts];
            for ( int port_index = 0; port_index < fNPorts; port_index++ )
                fPortBuffer[port_index] = new sample_t[fPeriodSize];
        }
        
    };
518

519
    class SERVER_EXPORT NetSingleAudioBuffer : public NetAudioBuffer
520
    {
521
        private:
522
523
524
525
526
527
528
529
            JackPortList fPortBuffer;
            char* fNetBuffer;
            
        public:
            NetSingleAudioBuffer ( session_params_t* params, uint32_t nports, char* net_buffer );
            ~NetSingleAudioBuffer();

            size_t GetSize();
sletz's avatar
sletz committed
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
            
            // needed size in bytes for an entire cycle
            size_t GetCycleSize();
            
             // cycle duration in sec
            float GetCycleDuration()
            {
                return fPortBuffer.GetCycleDuration();
            }
            
            int GetNumPackets()
            {
                return fPortBuffer.GetNumPackets();
            }
            
545
            //jack<->buffer
sletz's avatar
sletz committed
546
547
            int RenderFromJackPorts ();
            int RenderToJackPorts ();
548
549
550

            void SetBuffer ( int index, sample_t* buffer );
            sample_t* GetBuffer ( int index );
sletz's avatar
sletz committed
551
552
553
554
 
            //network<->buffer
            int RenderFromNetwork ( int cycle, int subcycle, size_t copy_size );
            int RenderToNetwork (int subcycle, size_t total_size );
555
556
557
558
    };
    
    #define AUDIO_BUFFER_SIZE 8
    
sletz's avatar
sletz committed
559
    /*
560
561
562
563
    class SERVER_EXPORT NetBufferedAudioBuffer : public NetAudioBuffer
    {
    
        private:
564
            char* fNetBuffer;
565
566
567
568
            JackPortListAllocate fPortBuffer[AUDIO_BUFFER_SIZE];
            sample_t** fJackPortBuffer;
            int fMaxCycle;
            
569
        public:
570
571
            NetBufferedAudioBuffer ( session_params_t* params, uint32_t nports, char* net_buffer );
            ~NetBufferedAudioBuffer();
572
573

            size_t GetSize();
sletz's avatar
sletz committed
574
575
576
577
578
579
580
581
582
            // needed syze in bytes ofr an entire cycle
            size_t GetCycleSize();
            
             // cycle duration in sec
            float GetCycleDuration()
            {
                return fPortBuffer[0].GetCycleDuration();
            }
            
583
            //jack<->buffer
sletz's avatar
sletz committed
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
            int RenderFromJackPorts (int subcycle );
            int RenderToJackPorts ( int cycle, int subcycle);
            //void FinishRenderToJackPorts (int cycle);
            
            //network<->buffer
            int RenderFromNetwork ( int subcycle, size_t copy_size )
            { 
                // TODO
                return 0;
            }
            int RenderToNetwork ( int subcycle, size_t total_size )
            { 
                // TODO
                return 0;
            }
599
600
601

            void SetBuffer ( int index, sample_t* buffer );
            sample_t* GetBuffer ( int index );
602
    };
sletz's avatar
sletz committed
603
    */
sletz's avatar
sletz committed
604
605

//utility *************************************************************************************
606
607

    //socket API management
608
609
    SERVER_EXPORT int SocketAPIInit();
    SERVER_EXPORT int SocketAPIEnd();
610
    //n<-->h functions
611
612
613
614
    SERVER_EXPORT void SessionParamsHToN ( session_params_t* src_params, session_params_t* dst_params );
    SERVER_EXPORT void SessionParamsNToH ( session_params_t* src_params, session_params_t* dst_params );
    SERVER_EXPORT void PacketHeaderHToN ( packet_header_t* src_header, packet_header_t* dst_header );
    SERVER_EXPORT void PacketHeaderNToH ( packet_header_t* src_header, packet_header_t* dst_header );
615
616
    SERVER_EXPORT void MidiBufferHToN ( JackMidiBuffer* src_buffer, JackMidiBuffer* dst_buffer );
    SERVER_EXPORT void MidiBufferNToH ( JackMidiBuffer* src_buffer, JackMidiBuffer* dst_buffer );
sletz's avatar
sletz committed
617
618
    SERVER_EXPORT void TransportDataHToN ( net_transport_data_t* src_params, net_transport_data_t* dst_params );
    SERVER_EXPORT void TransportDataNToH ( net_transport_data_t* src_params, net_transport_data_t* dst_params );
619
    //display session parameters
620
    SERVER_EXPORT void SessionParamsDisplay ( session_params_t* params );
621
    //display packet header
622
    SERVER_EXPORT void PacketHeaderDisplay ( packet_header_t* header );
623
    //get the packet type from a sesion parameters
624
    SERVER_EXPORT sync_packet_type_t GetPacketType ( session_params_t* params );
625
    //set the packet type in a session parameters
626
    SERVER_EXPORT int SetPacketType ( session_params_t* params, sync_packet_type_t packet_type );
627
    //transport utility
628
    SERVER_EXPORT const char* GetTransportState ( int transport_state );
sletz's avatar
sletz committed
629
    SERVER_EXPORT void NetTransportDataDisplay ( net_transport_data_t* data );
sletz's avatar
sletz committed
630
}