Public Types | Public Slots | Signals | Public Member Functions | Private Member Functions | Private Attributes

JackTrip Class Reference

Main class to creates a SERVER (to listen) or a CLIENT (to connect to a listening server) to send audio streams in the network. More...

#include <JackTrip.h>

Collaboration diagram for JackTrip:
Collaboration graph
[legend]

List of all members.

Public Types

enum  dataProtocolT { UDP, TCP, SCTP }
 

Enum for the data Protocol. At this time only UDP is implemented.

More...
enum  jacktripModeT { SERVER, CLIENT, CLIENTTOPINGSERVER }
 

Enum for the JackTrip mode.

More...
enum  underrunModeT { WAVETABLE, ZEROS }
 

Enum for the JackTrip Underrun Mode, when packets.

More...

Public Slots

void slotStopProcesses ()
 Slot to stop all the processes and threads.
void slotUdpWatingTooLong (int wait_msec)
 This slot emits in turn the signal signalNoUdpPacketsForSeconds when UDP is waited for more than 30 seconds.

Signals

void signalProcessesStopped ()
 Signal emitted when all the processes and threads are stopped
void signalNoUdpPacketsForSeconds ()
 Signal emitted when no UDP Packets have been received for a while

Public Member Functions

 JackTrip (jacktripModeT JacktripMode=CLIENT, dataProtocolT DataProtocolType=UDP, int NumChans=2, int BufferQueueLength=8, unsigned int redundancy=1, JackAudioInterface::audioBitResolutionT AudioBitResolution=JackAudioInterface::BIT16, DataProtocol::packetHeaderTypeT PacketHeaderType=DataProtocol::DEFAULT, underrunModeT UnderRunMode=WAVETABLE, int receiver_bind_port=gDefaultPort, int sender_bind_port=gDefaultPort, int receiver_peer_port=gDefaultPort, int sender_peer_port=gDefaultPort)
 The class Constructor with Default Parameters.
virtual ~JackTrip ()
 The class destructor.
void setPeerAddress (const char *PeerHostOrIP)
 Set the Peer Address for jacktripModeT::CLIENT mode only.
void appendProcessPlugin (ProcessPlugin *plugin)
 Append a process plugin. Processes will be appended in order.
void start ()
 Start the processing threads.
void stop ()
 Stop the processing threads.
void wait ()
 Wait for all the threads to finish. This functions is used when JackTrip is run as a thread.
void checkIfPortIsBinded (int port)
 Check if UDP port is already binded.
Methods to change parameters after construction

void setJackTripMode (jacktripModeT JacktripMode)
 Sets (override) JackTrip Mode after construction.
void setDataProtocoType (dataProtocolT DataProtocolType)
 Sets (override) DataProtocol Type after construction.
void setPacketHeaderType (DataProtocol::packetHeaderTypeT PacketHeaderType)
 Sets the Packet header type.
void setBufferQueueLength (int BufferQueueLength)
 Sets (override) Number of Channels after construction.
void setAudioBitResolution (JackAudioInterface::audioBitResolutionT AudioBitResolution)
 Sets (override) Audio Bit Resolution after construction.
void setUnderRunMode (underrunModeT UnderRunMode)
 Sets (override) Underrun Mode.
void setAllPorts (int port)
 Sets port numbers for the local and peer machine. Receive port is port
void setBindPorts (int port)
 Sets port numbers to bind in RECEIVER and SENDER sockets.
void setPeerPorts (int port)
 Sets port numbers for the peer (remote) machine.
void setClientName (char *ClientName)
 Set Client Name to something different that the default (JackTrip).
Mediator Functions

void createHeader (const DataProtocol::packetHeaderTypeT headertype)
void putHeaderInPacket (int8_t *full_packet, int8_t *audio_packet)
int getPacketSizeInBytes () const
void parseAudioPacket (int8_t *full_packet, int8_t *audio_packet)
void sendNetworkPacket (const int8_t *ptrToSlot)
void receiveNetworkPacket (int8_t *ptrToReadSlot)
void readAudioBuffer (int8_t *ptrToReadSlot)
void writeAudioBuffer (const int8_t *ptrToSlot)
uint32_t getBufferSizeInSamples () const
JackAudioInterface::samplingRateT getSampleRateType () const
uint8_t getAudioBitResolution () const
int getNumInputChannels () const
int getNumOutputChannels () const
void checkPeerSettings (int8_t *full_packet)
void increaseSequenceNumber ()
int getSequenceNumber () const
int getPeerSequenceNumber (int8_t *full_packet) const

Private Member Functions

void setupJackAudio ()
 Set the JackAudioInteface object.
void setupDataProtocol ()
 Set the DataProtocol objects.
void setupRingBuffers ()
 Set the RingBuffer objects.
void clientStart ()
 Starts for the CLIENT mode.
void serverStart ()
 Starts for the SERVER mode.
void clientPingToServerStart ()
 Stats for the Client to Ping Server.

Private Attributes

jacktripModeT mJackTripMode
 JackTrip::jacktripModeT.
dataProtocolT mDataProtocol
 Data Protocol Tipe.
DataProtocol::packetHeaderTypeT mPacketHeaderType
 Packet Header Type.
int mNumChans
 Number of Channels (inputs = outputs).
int mBufferQueueLength
 Audio Buffer from network queue length.
uint32_t mSampleRate
 Sample Rate.
uint32_t mAudioBufferSize
 Audio buffer size to process on each callback.
JackAudioInterface::audioBitResolutionT mAudioBitResolution
 Audio Bit Resolutions.
QString mPeerAddress
 Peer Address to use in jacktripModeT::CLIENT Mode.
DataProtocolmDataProtocolSender
 Pointer to Abstract Type DataProtocol that sends packets.
DataProtocolmDataProtocolReceiver
JackAudioInterfacemJackAudio
 Interface to Jack Client.
PacketHeadermPacketHeader
 Pointer to Packet Header.
underrunModeT mUnderRunMode
 underrunModeT Mode
RingBuffermSendRingBuffer
 Pointer for the Send RingBuffer.
RingBuffermReceiveRingBuffer
 Pointer for the Receive RingBuffer.
int mReceiverBindPort
 Incoming (receiving) port for local machine.
int mSenderPeerPort
 Incoming (receiving) port for peer machine.
int mSenderBindPort
 Outgoing (sending) port for local machine.
int mReceiverPeerPort
 Outgoing (sending) port for peer machine.
unsigned int mRedundancy
 Redundancy factor in network data.
const char * mJackClientName
 JackAudio Client Name.
QVector< ProcessPlugin * > mProcessPlugins
 Vector of ProcesPlugins

Detailed Description

Main class to creates a SERVER (to listen) or a CLIENT (to connect to a listening server) to send audio streams in the network.

All audio and network settings can be set in this class. This class also acts as a Mediator between all the other class. Classes that uses JackTrip methods need to register with it.


Member Enumeration Documentation

Enum for the data Protocol. At this time only UDP is implemented.

Enumerator:
UDP 

Use UDP (User Datagram Protocol).

TCP 

NOT IMPLEMENTED: Use TCP (Transmission Control Protocol)

SCTP 

NOT IMPLEMENTED: Use SCTP (Stream Control Transmission Protocol)

Enum for the JackTrip mode.

Enumerator:
SERVER 

Run in Server Mode.

CLIENT 

Run in Client Mode.

CLIENTTOPINGSERVER 

Client of the Ping Server Mode.

Enum for the JackTrip Underrun Mode, when packets.

Enumerator:
WAVETABLE 

Loops on the last received packet.

ZEROS 

Set new buffers to zero if there are no new ones.


Constructor & Destructor Documentation

JackTrip::JackTrip ( jacktripModeT  JacktripMode = CLIENT,
dataProtocolT  DataProtocolType = UDP,
int  NumChans = 2,
int  BufferQueueLength = 8,
unsigned int  redundancy = 1,
JackAudioInterface::audioBitResolutionT  AudioBitResolution = JackAudioInterface::BIT16,
DataProtocol::packetHeaderTypeT  PacketHeaderType = DataProtocol::DEFAULT,
underrunModeT  UnderRunMode = WAVETABLE,
int  receiver_bind_port = gDefaultPort,
int  sender_bind_port = gDefaultPort,
int  receiver_peer_port = gDefaultPort,
int  sender_peer_port = gDefaultPort 
)

The class Constructor with Default Parameters.

Parameters:
JacktripMode JackTrip::CLIENT or JackTrip::SERVER
DataProtocolType JackTrip::dataProtocolT
NumChans Number of Audio Channels (same for inputs and outputs)
BufferQueueLength Audio Buffer for receiving packets
AudioBitResolution Audio Sample Resolutions in bits
redundancy redundancy factor for network data
JackTrip::~JackTrip (  )  [virtual]

The class destructor.


Member Function Documentation

void JackTrip::appendProcessPlugin ( ProcessPlugin plugin  ) 

Append a process plugin. Processes will be appended in order.

Parameters:
plugin Pointer to ProcessPlugin Class
void JackTrip::checkIfPortIsBinded ( int  port  ) 

Check if UDP port is already binded.

Parameters:
port Port number
void JackTrip::checkPeerSettings ( int8_t full_packet  ) 
void JackTrip::clientPingToServerStart (  )  [private]

Stats for the Client to Ping Server.

void JackTrip::clientStart (  )  [private]

Starts for the CLIENT mode.

void JackTrip::createHeader ( const DataProtocol::packetHeaderTypeT  headertype  ) 
Todo:
Document all these functions
uint8_t JackTrip::getAudioBitResolution (  )  const [inline]
uint32_t JackTrip::getBufferSizeInSamples (  )  const [inline]
int JackTrip::getNumInputChannels (  )  const [inline]
int JackTrip::getNumOutputChannels (  )  const [inline]
int JackTrip::getPacketSizeInBytes (  )  const
int JackTrip::getPeerSequenceNumber ( int8_t full_packet  )  const [inline]
JackAudioInterface::samplingRateT JackTrip::getSampleRateType (  )  const [inline]
int JackTrip::getSequenceNumber (  )  const [inline]
void JackTrip::increaseSequenceNumber (  )  [inline]
void JackTrip::parseAudioPacket ( int8_t full_packet,
int8_t audio_packet 
)
void JackTrip::putHeaderInPacket ( int8_t full_packet,
int8_t audio_packet 
)
void JackTrip::readAudioBuffer ( int8_t ptrToReadSlot  )  [inline]
void JackTrip::receiveNetworkPacket ( int8_t ptrToReadSlot  )  [inline]
void JackTrip::sendNetworkPacket ( const int8_t ptrToSlot  )  [inline]
void JackTrip::serverStart (  )  [private]

Starts for the SERVER mode.

void JackTrip::setAllPorts ( int  port  )  [inline]

Sets port numbers for the local and peer machine. Receive port is port

void JackTrip::setAudioBitResolution ( JackAudioInterface::audioBitResolutionT  AudioBitResolution  )  [inline]

Sets (override) Audio Bit Resolution after construction.

void JackTrip::setBindPorts ( int  port  )  [inline]

Sets port numbers to bind in RECEIVER and SENDER sockets.

void JackTrip::setBufferQueueLength ( int  BufferQueueLength  )  [inline]

Sets (override) Number of Channels after construction.

Todo:
implement this, not working right now because channels cannot be changed after construction

Sets (override) Buffer Queue Length Mode after construction

void JackTrip::setClientName ( char *  ClientName  )  [inline]

Set Client Name to something different that the default (JackTrip).

void JackTrip::setDataProtocoType ( dataProtocolT  DataProtocolType  )  [inline]

Sets (override) DataProtocol Type after construction.

void JackTrip::setJackTripMode ( jacktripModeT  JacktripMode  )  [inline]

Sets (override) JackTrip Mode after construction.

void JackTrip::setPacketHeaderType ( DataProtocol::packetHeaderTypeT  PacketHeaderType  )  [inline]

Sets the Packet header type.

void JackTrip::setPeerAddress ( const char *  PeerHostOrIP  ) 

Set the Peer Address for jacktripModeT::CLIENT mode only.

void JackTrip::setPeerPorts ( int  port  )  [inline]

Sets port numbers for the peer (remote) machine.

void JackTrip::setUnderRunMode ( underrunModeT  UnderRunMode  )  [inline]

Sets (override) Underrun Mode.

void JackTrip::setupDataProtocol (  )  [private]

Set the DataProtocol objects.

void JackTrip::setupJackAudio (  )  [private]

Set the JackAudioInteface object.

void JackTrip::setupRingBuffers (  )  [private]

Set the RingBuffer objects.

Todo:
Make all this operations cleaner

void JackTrip::signalNoUdpPacketsForSeconds (  )  [signal]

Signal emitted when no UDP Packets have been received for a while

void JackTrip::signalProcessesStopped (  )  [signal]

Signal emitted when all the processes and threads are stopped

void JackTrip::slotStopProcesses (  )  [inline, slot]

Slot to stop all the processes and threads.

void JackTrip::slotUdpWatingTooLong ( int  wait_msec  )  [inline, slot]

This slot emits in turn the signal signalNoUdpPacketsForSeconds when UDP is waited for more than 30 seconds.

It is used to remove the thread from the server.

void JackTrip::start (  ) 

Start the processing threads.

void JackTrip::stop (  ) 

Stop the processing threads.

void JackTrip::wait (  ) 

Wait for all the threads to finish. This functions is used when JackTrip is run as a thread.

void JackTrip::writeAudioBuffer ( const int8_t ptrToSlot  )  [inline]

Member Data Documentation

Audio Bit Resolutions.

Audio buffer size to process on each callback.

Audio Buffer from network queue length.

Data Protocol Tipe.

Pointer to Abstract Type DataProtocol that sends packets.

Pointer to Abstract Type DataProtocol that receives packets

Interface to Jack Client.

const char* JackTrip::mJackClientName [private]

JackAudio Client Name.

int JackTrip::mNumChans [private]

Number of Channels (inputs = outputs).

Pointer to Packet Header.

Packet Header Type.

QString JackTrip::mPeerAddress [private]

Peer Address to use in jacktripModeT::CLIENT Mode.

Vector of ProcesPlugins

Incoming (receiving) port for local machine.

Pointer for the Receive RingBuffer.

Outgoing (sending) port for peer machine.

unsigned int JackTrip::mRedundancy [private]

Redundancy factor in network data.

Sample Rate.

Outgoing (sending) port for local machine.

Incoming (receiving) port for peer machine.

Pointer for the Send RingBuffer.

underrunModeT Mode


The documentation for this class was generated from the following files: