Logo Search packages:      
Sourcecode: jacktrip version File versions  Download package

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

UdpDataProtocol Class Reference

UDP implementation of DataProtocol class. More...

#include <UdpDataProtocol.h>

Inheritance diagram for UdpDataProtocol:
Inheritance graph
Collaboration diagram for UdpDataProtocol:
Collaboration graph

List of all members.

Public Types

enum  packetHeaderTypeT { DEFAULT, JAMLINK, EMPTY }

Enum to define packet header types.

enum  runModeT { SENDER, RECEIVER }

Enum to define class modes, SENDER or RECEIVER.



void signalWatingTooLong (int wait_msec)
 Signals when waiting every 10 milliseconds, with the total wait on wait_msec.

Public Member Functions

size_t getAudioPacketSizeInBites ()
 Get the size of the audio part of the packets.
virtual void getPeerAddressFromFirstPacket (QUdpSocket &UdpSocket, QHostAddress &peerHostAddress, uint16_t &port)
 Obtains the peer address from the first UDP packet received. This address is used by the SERVER mode to connect back to the client.
virtual int receivePacket (QUdpSocket &UdpSocket, char *buf, const size_t n)
 Receives a packet. It blocks until a packet is received.
virtual void run ()
 Implements the Thread Loop. To start the thread, call start() ( DO NOT CALL run() )
virtual int sendPacket (QUdpSocket &UdpSocket, const QHostAddress &PeerAddress, const char *buf, const size_t n)
 Sends a packet.
void setAudioPacketSize (const size_t size_bytes)
 Sets the size of the audio part of the packets.
void setBindPort (int port)
 Sets the bind port number.
void setPeerAddress (const char *peerHostOrIP)
 Set the Peer address to connect to.
void setPeerPort (int port)
 Sets the peer port number.
virtual void stop ()
 Stops the execution of the Thread.
 UdpDataProtocol (JackTrip *jacktrip, const runModeT runmode, int bind_port, int peer_port, unsigned int udp_redundancy_factor=1)
 The class constructor.
virtual ~UdpDataProtocol ()
 The class destructor.

Protected Member Functions

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

Protected Attributes

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

Private Slots

void printUdpWaitedTooLong (int wait_msec)

Private Member Functions

void bindSocket (QUdpSocket &UdpSocket)
 Binds the UDP socket to the available address and specified port.
void receivePacketRedundancy (QUdpSocket &UdpSocket, int8_t *full_redundant_packet, int full_redundant_packet_size, int full_packet_size, uint16_t &current_seq_num, uint16_t &last_seq_num, uint16_t &newer_seq_num)
 Redundancy algorythm at the receiving end.
void sendPacketRedundancy (QUdpSocket &UdpSocket, QHostAddress &PeerAddress, int8_t *full_redundant_packet, int full_redundant_packet_size, int full_packet_size)
 Redundancy algorythm at the sender end.
bool waitForReady (QUdpSocket &UdpSocket, int timeout_msec)
 This function blocks until data is available for reading in the QUdpSocket. The function will timeout after timeout_msec microseconds.

Private Attributes

int8_t * mAudioPacket
 Buffer to store Audio Packets.
int mBindPort
 Local Port number to Bind.
int8_t * mFullPacket
 Buffer to store Full Packet (audio+header)
QHostAddress mPeerAddress
 The Peer Address.
int mPeerPort
 Peer Port number.
const runModeT mRunMode
 Run mode, either SENDER or RECEIVER.
unsigned int mUdpRedundancyFactor
 Factor of redundancy.

Static Private Attributes

static QMutex sUdpMutex
 Mutex to make thread safe the binding process.

Detailed Description

UDP implementation of DataProtocol class.

The class has a bind port and a peer port. The meaning of these depends on the runModeT. If it's a SENDER, bind port is the source port and peer port is the destination port for each UDP packet. If it's a RECEIVER, the bind port destination port (for incoming packets) and the peer port is the source port.

The SENDER and RECEIVER socket can share the same port/address pair (for compatibility with the JamLink boxes). This is achieved setting the resusable property in the socket for address and port. You have to externaly check if the port is already binded if you want to avoid re-binding to the same port.

Definition at line 63 of file UdpDataProtocol.h.

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

Generated by  Doxygen 1.6.0   Back to index