JackTrip
Public Types | Signals | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
DataProtocol Class Referenceabstract

Base class that defines the transmission protocol. More...

#include <DataProtocol.h>

Inheritance diagram for DataProtocol:
Inheritance graph
[legend]
Collaboration diagram for DataProtocol:
Collaboration graph
[legend]

Public Types

enum  packetHeaderTypeT { DEFAULT, JAMLINK, EMPTY }
 Enum to define packet header types. More...
 
enum  runModeT { SENDER, RECEIVER }
 Enum to define class modes, SENDER or RECEIVER. More...
 

Signals

void signalError (const char *error_message)
 
void signalReceivedConnectionFromPeer ()
 

Public Member Functions

 DataProtocol (JackTrip *jacktrip, const runModeT runmode, int bind_port, int peer_port)
 The class constructor. More...
 
virtual ~DataProtocol ()
 The class destructor. More...
 
virtual void run ()=0
 Implements the thread loop. More...
 
virtual void stop ()
 Stops the execution of the Thread. More...
 
void setAudioPacketSize (const size_t size_bytes)
 Sets the size of the audio part of the packets. More...
 
size_t getAudioPacketSizeInBites ()
 Get the size of the audio part of the packets. More...
 
virtual void setPeerAddress (const char *peerHostOrIP)=0
 Set the peer address. More...
 
virtual void setPeerPort (int port)=0
 Set the peer incomming (receiving) port number. More...
 

Protected Member Functions

runModeT getRunMode () const
 Get the Run Mode of the object. More...
 

Protected Attributes

volatile bool mStopped
 Boolean stop the execution of the thread. More...
 
volatile bool mHasPeerAddress
 Boolean to indicate if the RECEIVER is waiting to obtain peer address. More...
 
volatile bool mHasPacketsToReceive
 Boolean that indicates if a packet was received. More...
 
QMutex mMutex
 
JackTripmJackTrip
 JackTrip mediator class. More...
 

Detailed Description

Base class that defines the transmission protocol.

This base class defines most of the common method to setup and connect sockets using the individual protocols (UDP, TCP, SCTP, etc).

The class has to be constructed using one of two modes (runModeT):

This has to be specified as a constructor argument. When using, create two instances of the class, one to receive and one to send packets. Each instance will run on a separate thread.

Redundancy and forward error correction should be implemented on each Transport protocol, cause they depend on the protocol itself

Todo:
This Class should contain definition of jacktrip header and basic funcionality to obtain local machine IPs and maybe functions to manipulate IPs. Redundancy and forward error correction should be implemented on each Transport protocol, cause they depend on the protocol itself
Todo:
The transport protocol itself has to be implemented subclassing this class, i.e., using a TCP or UDP protocol.

Even if the underlined transmission protocol is stream oriented (as in TCP), we send packets that are the size of the audio processing buffer. Use AudioInterface::getBufferSize to obtain this value.

Each transmission (i.e., inputs and outputs) run on its own thread.

Member Enumeration Documentation

◆ packetHeaderTypeT

Enum to define packet header types.

Enumerator
DEFAULT 

Default application header.

JAMLINK 

Header to use with Jamlinks.

EMPTY 

Empty Header.

◆ runModeT

Enum to define class modes, SENDER or RECEIVER.

Enumerator
SENDER 

Set class as a Sender (send packets)

RECEIVER 

Set class as a Receiver (receives packets)

Constructor & Destructor Documentation

◆ DataProtocol()

DataProtocol::DataProtocol ( JackTrip jacktrip,
const runModeT  runmode,
int  bind_port,
int  peer_port 
)

The class constructor.

Parameters
jacktripPointer to the JackTrip class that connects all classes (mediator)
runmodeSets the run mode, use either DataProtocol::SENDER or DataProtocol::RECEIVER
headertypepacketHeaderTypeT header type to use for packets
bind_portPort number to bind for this socket (this is the receive or send port depending on the runmode)
peer_portPeer port number (this is the receive or send port depending on the runmode)

◆ ~DataProtocol()

DataProtocol::~DataProtocol ( )
virtual

The class destructor.

Member Function Documentation

◆ getAudioPacketSizeInBites()

size_t DataProtocol::getAudioPacketSizeInBites ( )
inline

Get the size of the audio part of the packets.

Returns
size_bytes Size in bytes

◆ getRunMode()

runModeT DataProtocol::getRunMode ( ) const
inlineprotected

Get the Run Mode of the object.

Returns
SENDER or RECEIVER

◆ run()

virtual void DataProtocol::run ( )
pure virtual

Implements the thread loop.

Depending on the runmode, with will run a DataProtocol::SENDER thread or DataProtocol::RECEIVER thread

Implemented in UdpDataProtocol.

◆ setAudioPacketSize()

void DataProtocol::setAudioPacketSize ( const size_t  size_bytes)
inline

Sets the size of the audio part of the packets.

Parameters
size_bytesSize in bytes

◆ setPeerAddress()

virtual void DataProtocol::setPeerAddress ( const char *  peerHostOrIP)
pure virtual

Set the peer address.

Parameters
peerHostOrIPIPv4 number or host name
Todo:
implement here instead of in the subclass UDP

Implemented in UdpDataProtocol.

◆ setPeerPort()

virtual void DataProtocol::setPeerPort ( int  port)
pure virtual

Set the peer incomming (receiving) port number.

Parameters
portPort number
Todo:
implement here instead of in the subclass UDP

Implemented in UdpDataProtocol.

◆ signalError

void DataProtocol::signalError ( const char *  error_message)
signal

◆ signalReceivedConnectionFromPeer

void DataProtocol::signalReceivedConnectionFromPeer ( )
signal

◆ stop()

virtual void DataProtocol::stop ( )
inlinevirtual

Stops the execution of the Thread.

Member Data Documentation

◆ mHasPacketsToReceive

volatile bool DataProtocol::mHasPacketsToReceive
protected

Boolean that indicates if a packet was received.

◆ mHasPeerAddress

volatile bool DataProtocol::mHasPeerAddress
protected

Boolean to indicate if the RECEIVER is waiting to obtain peer address.

◆ mJackTrip

JackTrip* DataProtocol::mJackTrip
protected

JackTrip mediator class.

Todo:
check a better way to access the header from the subclasses

◆ mMutex

QMutex DataProtocol::mMutex
protected

◆ mStopped

volatile bool DataProtocol::mStopped
protected

Boolean stop the execution of the thread.


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