#include <DataProtocol.h>
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... | |
Public Member Functions | |
DataProtocol (JackTrip *jacktrip, const runModeT runmode, int bind_port, int peer_port) | |
The class constructor. | |
virtual | ~DataProtocol () |
The class destructor. | |
virtual void | run ()=0 |
Implements the thread loop. | |
virtual void | stop () |
Stops the execution of the Thread. | |
void | setAudioPacketSize (const size_t size_bytes) |
Sets the size of the audio part of the packets. | |
size_t | getAudioPacketSizeInBites () |
Get the size of the audio part of the packets. | |
virtual void | setPeerAddress (const char *peerHostOrIP)=0 |
Set the peer address. | |
virtual void | setPeerPort (int port)=0 |
Set the peer incomming (receiving) port number. | |
Protected Member Functions | |
runModeT | getRunMode () const |
Get the Run Mode of the object. | |
Protected Attributes | |
volatile bool | mStopped |
Boolean stop the execution of the thread. | |
volatile bool | mHasPeerAddress |
Boolean to indicate if the RECEIVER is waiting to obtain peer address. | |
volatile bool | mHasPacketsToReceive |
Boolean that indicates if a packet was received. | |
JackTrip * | mJackTrip |
Private Attributes | |
int | mLocalPort |
Local Port number to Bind. | |
int | mPeerPort |
Peer Port number to Bind. | |
const runModeT | mRunMode |
Run mode, either SENDER or RECEIVER. | |
struct sockaddr_in | mLocalIPv4Addr |
Local IPv4 Address struct. | |
struct sockaddr_in | mPeerIPv4Addr |
Peer IPv4 Address struct. | |
size_t | mAudioPacketSize |
Packet audio part size. | |
Static Private Attributes | |
static int | sClientsRunning |
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
Each transmission (i.e., inputs and outputs) run on its own thread.
DataProtocol::DataProtocol | ( | JackTrip * | jacktrip, | |
const runModeT | runmode, | |||
int | bind_port, | |||
int | peer_port | |||
) |
The class constructor.
jacktrip | Pointer to the JackTrip class that connects all classes (mediator) | |
runmode | Sets the run mode, use either DataProtocol::SENDER or DataProtocol::RECEIVER | |
headertype | packetHeaderTypeT header type to use for packets | |
bind_port | Port number to bind for this socket (this is the receive or send port depending on the runmode) | |
peer_port | Peer port number (this is the receive or send port depending on the runmode) |
DataProtocol::~DataProtocol | ( | ) | [virtual] |
The class destructor.
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.
virtual void DataProtocol::stop | ( | ) | [inline, virtual] |
Stops the execution of the Thread.
void DataProtocol::setAudioPacketSize | ( | const size_t | size_bytes | ) | [inline] |
Sets the size of the audio part of the packets.
size_bytes | Size in bytes |
size_t DataProtocol::getAudioPacketSizeInBites | ( | ) | [inline] |
Get the size of the audio part of the packets.
virtual void DataProtocol::setPeerAddress | ( | const char * | peerHostOrIP | ) | [pure virtual] |
Set the peer address.
peerHostOrIP | IPv4 number or host name |
Implemented in UdpDataProtocol.
virtual void DataProtocol::setPeerPort | ( | int | port | ) | [pure virtual] |
Set the peer incomming (receiving) port number.
port | Port number |
Implemented in UdpDataProtocol.
runModeT DataProtocol::getRunMode | ( | ) | const [inline, protected] |
Get the Run Mode of the object.
volatile bool DataProtocol::mStopped [protected] |
Boolean stop the execution of the thread.
volatile bool DataProtocol::mHasPeerAddress [protected] |
Boolean to indicate if the RECEIVER is waiting to obtain peer address.
volatile bool DataProtocol::mHasPacketsToReceive [protected] |
Boolean that indicates if a packet was received.
int DataProtocol::mLocalPort [private] |
Local Port number to Bind.
int DataProtocol::mPeerPort [private] |
const runModeT DataProtocol::mRunMode [private] |
struct sockaddr_in DataProtocol::mLocalIPv4Addr [read, private] |
Local IPv4 Address struct.
struct sockaddr_in DataProtocol::mPeerIPv4Addr [read, private] |
Peer IPv4 Address struct.
int DataProtocol::sClientsRunning [static, private] |
Number of clients running to check for ports already used
size_t DataProtocol::mAudioPacketSize [private] |
Packet audio part size.
JackTrip* DataProtocol::mJackTrip [protected] |