SDRAngel  4.11.5
Developer docs for <a href="https://github.com/f4exb/sdrangel">SDRangel<\a>, an Open Source Qt5 / OpenGL 3.0+ SDR and signal analyzer frontend to various hardware.
Signals | Public Member Functions | Private Slots | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
qrtplib::RTPUDPTransmitter Class Reference

#include <rtpudptransmitter.h>

+ Inheritance diagram for qrtplib::RTPUDPTransmitter:
+ Collaboration diagram for qrtplib::RTPUDPTransmitter:

Signals

void NewDataAvailable ()
 

Public Member Functions

 RTPUDPTransmitter ()
 
virtual ~RTPUDPTransmitter ()
 
virtual int Init ()
 
virtual int Create (std::size_t maxpacksize, const RTPTransmissionParams *transparams)
 
virtual int BindSockets ()
 
void moveToThread (QThread *thread)
 
virtual void Destroy ()
 
virtual RTPTransmissionInfoGetTransmissionInfo ()
 
virtual void DeleteTransmissionInfo (RTPTransmissionInfo *inf)
 
virtual bool ComesFromThisTransmitter (const RTPAddress &addr)
 
virtual std::size_t GetHeaderOverhead ()
 
virtual int SendRTPData (const void *data, std::size_t len)
 
virtual int SendRTCPData (const void *data, std::size_t len)
 
virtual int AddDestination (const RTPAddress &addr)
 
virtual int DeleteDestination (const RTPAddress &addr)
 
virtual void ClearDestinations ()
 
virtual bool SupportsMulticasting ()
 
virtual int JoinMulticastGroup (const RTPAddress &addr)
 
virtual int LeaveMulticastGroup (const RTPAddress &addr)
 
virtual int SetReceiveMode (RTPTransmitter::ReceiveMode m)
 
virtual int AddToIgnoreList (const RTPAddress &addr)
 
virtual int DeleteFromIgnoreList (const RTPAddress &addr)
 
virtual void ClearIgnoreList ()
 
virtual int AddToAcceptList (const RTPAddress &addr)
 
virtual int DeleteFromAcceptList (const RTPAddress &addr)
 
virtual void ClearAcceptList ()
 
virtual int SetMaximumPacketSize (std::size_t s)
 
virtual RTPRawPacketGetNextPacket ()
 
- Public Member Functions inherited from qrtplib::RTPTransmitter
virtual ~RTPTransmitter ()
 

Private Slots

void readRTPPendingDatagrams ()
 
void readRTCPPendingDatagrams ()
 

Private Member Functions

bool ShouldAcceptData (const RTPAddress &address)
 

Private Attributes

bool m_init
 
bool m_created
 
bool m_waitingfordata
 
QUdpSocket * m_rtpsock
 
QUdpSocket * m_rtcpsock
 
bool m_deletesocketswhendone
 
QHostAddress m_localIP
 from parameters bind IP More...
 
QNetworkInterface m_multicastInterface
 from parameters multicast interface More...
 
uint16_t m_rtpPort
 
uint16_t m_rtcpPort
 
RTPTransmitter::ReceiveMode m_receivemode
 
std::size_t m_maxpacksize
 
char m_rtpBuffer [m_absoluteMaxPackSize]
 
char m_rtcpBuffer [m_absoluteMaxPackSize]
 
std::list< RTPAddressm_destinations
 
std::list< RTPAddressm_acceptList
 
std::list< RTPAddressm_ignoreList
 
QQueue< RTPRawPacket * > m_rawPacketQueue
 
QMutex m_rawPacketQueueLock
 

Static Private Attributes

static const std::size_t m_absoluteMaxPackSize = 65535
 

Additional Inherited Members

- Public Types inherited from qrtplib::RTPTransmitter
enum  TransmissionProtocol {
  IPv4UDPProto, IPv6UDPProto, TCPProto, ExternalProto,
  UserDefinedProto
}
 
enum  ReceiveMode { AcceptAll, AcceptSome, IgnoreSome }
 
- Protected Member Functions inherited from qrtplib::RTPTransmitter
 RTPTransmitter ()
 

Detailed Description

An UDP transmission component. This class inherits the RTPTransmitter interface and implements a transmission component which uses UDP to send and receive RTP and RTCP data. The component's parameters are described by the class RTPUDPTransmissionParams. The GetTransmissionInfo member function returns an instance of type RTPUDPTransmissionInfo.

Definition at line 301 of file rtpudptransmitter.h.

Constructor & Destructor Documentation

◆ RTPUDPTransmitter()

qrtplib::RTPUDPTransmitter::RTPUDPTransmitter ( )

Definition at line 44 of file rtpudptransmitter.cpp.

References qrtplib::RTPTransmitter::AcceptAll, m_absoluteMaxPackSize, m_created, m_deletesocketswhendone, m_init, m_maxpacksize, m_receivemode, m_rtcpBuffer, m_rtcpPort, m_rtcpsock, m_rtpBuffer, m_rtpPort, m_rtpsock, and m_waitingfordata.

44  :
45  m_rawPacketQueueLock(QMutex::Recursive)
46 {
47  m_created = false;
48  m_init = false;
49  m_rtcpsock = 0;
50  m_rtpsock = 0;
52  m_waitingfordata = false;
53  m_rtcpPort = 0;
54  m_rtpPort = 0;
56  m_maxpacksize = 0;
59 }
RTPTransmitter::ReceiveMode m_receivemode
char m_rtpBuffer[m_absoluteMaxPackSize]
char m_rtcpBuffer[m_absoluteMaxPackSize]
static const std::size_t m_absoluteMaxPackSize

◆ ~RTPUDPTransmitter()

qrtplib::RTPUDPTransmitter::~RTPUDPTransmitter ( )
virtual

Definition at line 61 of file rtpudptransmitter.cpp.

References Destroy().

62 {
63  Destroy();
64 }
+ Here is the call graph for this function:

Member Function Documentation

◆ AddDestination()

int qrtplib::RTPUDPTransmitter::AddDestination ( const RTPAddress addr)
virtual

Adds the address specified by addr to the list of destinations.

Implements qrtplib::RTPTransmitter.

Definition at line 291 of file rtpudptransmitter.cpp.

References m_destinations.

292 {
293  m_destinations.push_back(addr);
294  return 0;
295 }
std::list< RTPAddress > m_destinations

◆ AddToAcceptList()

int qrtplib::RTPUDPTransmitter::AddToAcceptList ( const RTPAddress addr)
virtual

Adds addr to the list of addresses to accept.

Implements qrtplib::RTPTransmitter.

Definition at line 410 of file rtpudptransmitter.cpp.

References m_acceptList.

411 {
412  m_acceptList.push_back(addr);
413  return 0;
414 }
std::list< RTPAddress > m_acceptList

◆ AddToIgnoreList()

int qrtplib::RTPUDPTransmitter::AddToIgnoreList ( const RTPAddress addr)
virtual

Adds addr to the list of addresses to ignore.

Implements qrtplib::RTPTransmitter.

Definition at line 393 of file rtpudptransmitter.cpp.

References m_ignoreList.

394 {
395  m_ignoreList.push_back(addr);
396  return 0;
397 }
std::list< RTPAddress > m_ignoreList

◆ BindSockets()

int qrtplib::RTPUDPTransmitter::BindSockets ( )
virtual

Bind the RTP and RTCP sockets to ports that were set at creation time

Implements qrtplib::RTPTransmitter.

Definition at line 170 of file rtpudptransmitter.cpp.

References ERR_RTP_UDPV4TRANS_CANTBINDRTCPSOCKET, ERR_RTP_UDPV4TRANS_CANTBINDRTPSOCKET, m_localIP, m_rtcpPort, m_rtcpsock, m_rtpPort, m_rtpsock, readRTCPPendingDatagrams(), and readRTPPendingDatagrams().

171 {
172  if (!m_rtpsock->bind(m_localIP, m_rtpPort)) {
174  }
175 
176  connect(m_rtpsock, SIGNAL(readyRead()), this, SLOT(readRTPPendingDatagrams()));
177 
178  if (m_rtpsock != m_rtcpsock)
179  {
180  if (!m_rtcpsock->bind(m_localIP, m_rtcpPort)) {
182  }
183 
184  connect(m_rtcpsock, SIGNAL(readyRead()), this, SLOT(readRTCPPendingDatagrams()));
185  }
186 
187  return 0;
188 }
QHostAddress m_localIP
from parameters bind IP
#define ERR_RTP_UDPV4TRANS_CANTBINDRTPSOCKET
Definition: rtperrors.h:126
#define ERR_RTP_UDPV4TRANS_CANTBINDRTCPSOCKET
Definition: rtperrors.h:125
+ Here is the call graph for this function:

◆ ClearAcceptList()

void qrtplib::RTPUDPTransmitter::ClearAcceptList ( )
virtual

Clears the list of addresses to accept.

Implements qrtplib::RTPTransmitter.

Definition at line 422 of file rtpudptransmitter.cpp.

References m_acceptList.

423 {
424  m_acceptList.clear();
425 }
std::list< RTPAddress > m_acceptList

◆ ClearDestinations()

void qrtplib::RTPUDPTransmitter::ClearDestinations ( )
virtual

Clears the list of destinations.

Implements qrtplib::RTPTransmitter.

Definition at line 303 of file rtpudptransmitter.cpp.

References m_destinations.

304 {
305  m_destinations.clear();
306 }
std::list< RTPAddress > m_destinations

◆ ClearIgnoreList()

void qrtplib::RTPUDPTransmitter::ClearIgnoreList ( )
virtual

Clears the list of addresses to ignore.

Implements qrtplib::RTPTransmitter.

Definition at line 405 of file rtpudptransmitter.cpp.

References m_ignoreList.

406 {
407  m_ignoreList.clear();
408 }
std::list< RTPAddress > m_ignoreList

◆ ComesFromThisTransmitter()

bool qrtplib::RTPUDPTransmitter::ComesFromThisTransmitter ( const RTPAddress addr)
virtual

Returns true if the address specified by addr is one of the addresses of the transmitter.

Implements qrtplib::RTPTransmitter.

Definition at line 233 of file rtpudptransmitter.cpp.

References qrtplib::RTPAddress::getAddress(), qrtplib::RTPAddress::getPort(), qrtplib::RTPAddress::getRtcpsendport(), m_localIP, m_rtcpPort, and m_rtpPort.

234 {
235  if (addr.getAddress() != m_localIP) {
236  return false;
237  }
238 
239  return (addr.getPort() == m_rtpPort) && (addr.getRtcpsendport() == m_rtcpPort);
240 }
QHostAddress m_localIP
from parameters bind IP
+ Here is the call graph for this function:

◆ Create()

int qrtplib::RTPUDPTransmitter::Create ( std::size_t  maxpacksize,
const RTPTransmissionParams transparams 
)
virtual

Prepares the component to be used. Prepares the component to be used. The parameter maxpacksize specifies the maximum size a packet can have: if the packet is larger it will not be transmitted. The transparams parameter specifies a pointer to an RTPTransmissionParams instance. This is also an abstract class and each actual component will define its own parameters by inheriting a class from RTPTransmissionParams. If transparams is NULL, the default transmission parameters for the component will be used.

Implements qrtplib::RTPTransmitter.

Definition at line 76 of file rtpudptransmitter.cpp.

References qrtplib::RTPTransmitter::AcceptAll, ERR_RTP_UDPV4TRANS_ALREADYCREATED, ERR_RTP_UDPV4TRANS_ILLEGALPARAMETERS, ERR_RTP_UDPV4TRANS_NOTINIT, ERR_RTP_UDPV4TRANS_PORTBASENOTEVEN, ERR_RTP_UDPV4TRANS_SPECIFIEDSIZETOOBIG, qrtplib::RTPUDPTransmissionParams::GetAllowOddPortbase(), qrtplib::RTPUDPTransmissionParams::GetBindIP(), qrtplib::RTPUDPTransmissionParams::GetForcedRTCPPort(), qrtplib::RTPUDPTransmissionParams::GetMulticastInterface(), qrtplib::RTPUDPTransmissionParams::GetPortbase(), qrtplib::RTPUDPTransmissionParams::GetRTCPMultiplexing(), qrtplib::RTPUDPTransmissionParams::GetRTCPReceiveBufferSize(), qrtplib::RTPUDPTransmissionParams::GetRTPReceiveBufferSize(), qrtplib::RTPTransmissionParams::GetTransmissionProtocol(), qrtplib::RTPUDPTransmissionParams::GetUseExistingSockets(), qrtplib::RTPTransmitter::IPv4UDPProto, m_absoluteMaxPackSize, m_created, m_deletesocketswhendone, m_init, m_localIP, m_maxpacksize, m_multicastInterface, m_receivemode, m_rtcpPort, m_rtcpsock, m_rtpPort, m_rtpsock, and m_waitingfordata.

Referenced by RTPSink::RTPSink().

77 {
78  const RTPUDPTransmissionParams *params, defaultparams;
79  qint64 size;
80 
81  if (maximumpacketsize > m_absoluteMaxPackSize) {
83  }
84 
85  if (!m_init) {
87  }
88 
89  if (m_created) {
91  }
92 
93  // Obtain transmission parameters
94 
95  if (transparams == 0) {
96  params = &defaultparams;
97  }
98  else
99  {
100  if (transparams->GetTransmissionProtocol() != RTPTransmitter::IPv4UDPProto)
101  {
103  }
104  params = (const RTPUDPTransmissionParams *) transparams;
105  }
106 
107  // Determine the port numbers
108 
109  m_localIP = params->GetBindIP();
110 
111  if (params->GetAllowOddPortbase())
112  {
113  m_rtpPort = params->GetPortbase();
114  m_rtcpPort = params->GetForcedRTCPPort();
115  }
116  else
117  {
118  if (params->GetPortbase() % 2 == 0)
119  {
120  m_rtpPort = params->GetPortbase();
121  m_rtcpPort = m_rtpPort + 1;
122  }
123  else
124  {
126  }
127  }
128 
129  if (params->GetUseExistingSockets(&m_rtpsock, &m_rtcpsock))
130  {
131  m_deletesocketswhendone = false;
132  }
133  else
134  {
136 
137  m_rtpsock = new QUdpSocket();
138 
139  // If we're multiplexing, we're just going to set the RTCP socket to equal the RTP socket
140  if (params->GetRTCPMultiplexing())
141  {
144  } else {
145  m_rtcpsock = new QUdpSocket();
146  }
147  }
148 
149  // set socket buffer sizes
150 
151  size = params->GetRTPReceiveBufferSize();
152  m_rtpsock->setReadBufferSize(size);
153 
154  if (m_rtpsock != m_rtcpsock)
155  {
156  size = params->GetRTCPReceiveBufferSize();
157  m_rtcpsock->setReadBufferSize(size);
158  }
159 
160  m_maxpacksize = maximumpacketsize;
161  m_multicastInterface = params->GetMulticastInterface();
163 
164  m_waitingfordata = false;
165  m_created = true;
166 
167  return 0;
168 }
#define ERR_RTP_UDPV4TRANS_ILLEGALPARAMETERS
Definition: rtperrors.h:135
RTPTransmitter::ReceiveMode m_receivemode
QNetworkInterface m_multicastInterface
from parameters multicast interface
#define ERR_RTP_UDPV4TRANS_NOTINIT
Definition: rtperrors.h:142
QHostAddress m_localIP
from parameters bind IP
#define ERR_RTP_UDPV4TRANS_PORTBASENOTEVEN
Definition: rtperrors.h:144
#define ERR_RTP_UDPV4TRANS_ALREADYCREATED
Definition: rtperrors.h:122
static const std::size_t m_absoluteMaxPackSize
#define ERR_RTP_UDPV4TRANS_SPECIFIEDSIZETOOBIG
Definition: rtperrors.h:145
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ DeleteDestination()

int qrtplib::RTPUDPTransmitter::DeleteDestination ( const RTPAddress addr)
virtual

Deletes the address specified by addr from the list of destinations.

Implements qrtplib::RTPTransmitter.

Definition at line 297 of file rtpudptransmitter.cpp.

References m_destinations.

298 {
299  m_destinations.remove(addr);
300  return 0;
301 }
std::list< RTPAddress > m_destinations

◆ DeleteFromAcceptList()

int qrtplib::RTPUDPTransmitter::DeleteFromAcceptList ( const RTPAddress addr)
virtual

Deletes addr from the list of addresses to accept.

Implements qrtplib::RTPTransmitter.

Definition at line 416 of file rtpudptransmitter.cpp.

References m_acceptList.

417 {
418  m_acceptList.remove(addr);
419  return 0;
420 }
std::list< RTPAddress > m_acceptList

◆ DeleteFromIgnoreList()

int qrtplib::RTPUDPTransmitter::DeleteFromIgnoreList ( const RTPAddress addr)
virtual

Deletes addr from the list of addresses to accept.

Implements qrtplib::RTPTransmitter.

Definition at line 399 of file rtpudptransmitter.cpp.

References m_ignoreList.

400 {
401  m_ignoreList.remove(addr);
402  return 0;
403 }
std::list< RTPAddress > m_ignoreList

◆ DeleteTransmissionInfo()

void qrtplib::RTPUDPTransmitter::DeleteTransmissionInfo ( RTPTransmissionInfo inf)
virtual

Deallocates the information returned by RTPTransmitter::GetTransmissionInfo . Deallocates the information returned by RTPTransmitter::GetTransmissionInfo .

Implements qrtplib::RTPTransmitter.

Definition at line 224 of file rtpudptransmitter.cpp.

References m_init.

225 {
226  if (!m_init) {
227  return;
228  }
229 
230  delete inf;
231 }

◆ Destroy()

void qrtplib::RTPUDPTransmitter::Destroy ( )
virtual

By calling this function, buffers are cleared and the component cannot be used anymore. By calling this function, buffers are cleared and the component cannot be used anymore. Only when the Create function is called again can the component be used again.

Implements qrtplib::RTPTransmitter.

Definition at line 190 of file rtpudptransmitter.cpp.

References m_created, m_deletesocketswhendone, m_init, m_rtcpsock, and m_rtpsock.

Referenced by ~RTPUDPTransmitter().

191 {
192  if (!m_init) {
193  return;
194  }
195 
196  if (!m_created)
197  {
198  return;
199  }
200 
202  {
203  if (m_rtpsock != m_rtcpsock) {
204  delete m_rtcpsock;
205  }
206 
207  delete m_rtpsock;
208  }
209 
210  m_created = false;
211 }
+ Here is the caller graph for this function:

◆ GetHeaderOverhead()

virtual std::size_t qrtplib::RTPUDPTransmitter::GetHeaderOverhead ( )
inlinevirtual

Returns the amount of bytes that will be added to the RTP packet by the underlying layers (excluding the link layer).

Implements qrtplib::RTPTransmitter.

Definition at line 317 of file rtpudptransmitter.h.

References RTPUDPTRANS_HEADERSIZE.

318  {
319  return RTPUDPTRANS_HEADERSIZE;
320  }
#define RTPUDPTRANS_HEADERSIZE

◆ GetNextPacket()

RTPRawPacket * qrtplib::RTPUDPTransmitter::GetNextPacket ( )
virtual

Returns the raw data of a received RTP packet in an RTPRawPacket instance.

Implements qrtplib::RTPTransmitter.

Definition at line 445 of file rtpudptransmitter.cpp.

References m_rawPacketQueue, and m_rawPacketQueueLock.

446 {
447  QMutexLocker locker(&m_rawPacketQueueLock);
448 
449  if (m_rawPacketQueue.isEmpty()) {
450  return 0;
451  } else {
452  return m_rawPacketQueue.takeFirst();
453  }
454 }
QQueue< RTPRawPacket * > m_rawPacketQueue

◆ GetTransmissionInfo()

RTPTransmissionInfo * qrtplib::RTPUDPTransmitter::GetTransmissionInfo ( )
virtual

Returns additional information about the transmitter. This function returns an instance of a subclass of RTPTransmissionInfo which will give some additional information about the transmitter (a list of local IP addresses for example). Currently, either an instance of RTPUDPv4TransmissionInfo or RTPUDPv6TransmissionInfo is returned, depending on the type of the transmitter. The user has to deallocate the returned instance when it is no longer needed, which can be done using RTPTransmitter::DeleteTransmissionInfo.

Implements qrtplib::RTPTransmitter.

Definition at line 213 of file rtpudptransmitter.cpp.

References m_init, m_localIP, m_rtcpPort, m_rtcpsock, m_rtpPort, and m_rtpsock.

214 {
215  if (!m_init) {
216  return 0;
217  }
218 
219  RTPTransmissionInfo *tinf = new RTPUDPTransmissionInfo(m_localIP, m_rtpsock, m_rtcpsock, m_rtpPort, m_rtcpPort);
220 
221  return tinf;
222 }
QHostAddress m_localIP
from parameters bind IP

◆ Init()

int qrtplib::RTPUDPTransmitter::Init ( )
virtual

This function must be called before the transmission component can be used.

Implements qrtplib::RTPTransmitter.

Definition at line 66 of file rtpudptransmitter.cpp.

References ERR_RTP_UDPV4TRANS_ALREADYINIT, and m_init.

Referenced by RTPSink::RTPSink().

67 {
68  if (m_init) {
70  }
71 
72  m_init = true;
73  return 0;
74 }
#define ERR_RTP_UDPV4TRANS_ALREADYINIT
Definition: rtperrors.h:123
+ Here is the caller graph for this function:

◆ JoinMulticastGroup()

int qrtplib::RTPUDPTransmitter::JoinMulticastGroup ( const RTPAddress addr)
virtual

Joins the multicast group specified by addr.

Implements qrtplib::RTPTransmitter.

Definition at line 321 of file rtpudptransmitter.cpp.

References ERR_RTP_UDPV4TRANS_COULDNTJOINMULTICASTGROUP, ERR_RTP_UDPV4TRANS_NOTCREATED, ERR_RTP_UDPV4TRANS_NOTINIT, ERR_RTP_UDPV6TRANS_NOMULTICASTSUPPORT, qrtplib::RTPAddress::getAddress(), m_created, m_init, m_multicastInterface, m_rtcpsock, m_rtpsock, and SupportsMulticasting().

322 {
323  if (!m_init) {
325  }
326 
327  if (!m_created) {
329  }
330 
331  if (!SupportsMulticasting()) {
333  }
334 
335  if (m_rtpsock->joinMulticastGroup(addr.getAddress(), m_multicastInterface))
336  {
337  if (m_rtpsock != m_rtcpsock)
338  {
339  if (!m_rtcpsock->joinMulticastGroup(addr.getAddress(), m_multicastInterface)) {
341  }
342  }
343  }
344  else
345  {
347  }
348 
349  return 0;
350 }
#define ERR_RTP_UDPV6TRANS_NOMULTICASTSUPPORT
Definition: rtperrors.h:162
#define ERR_RTP_UDPV4TRANS_COULDNTJOINMULTICASTGROUP
Definition: rtperrors.h:133
QNetworkInterface m_multicastInterface
from parameters multicast interface
#define ERR_RTP_UDPV4TRANS_NOTINIT
Definition: rtperrors.h:142
#define ERR_RTP_UDPV4TRANS_NOTCREATED
Definition: rtperrors.h:141
+ Here is the call graph for this function:

◆ LeaveMulticastGroup()

int qrtplib::RTPUDPTransmitter::LeaveMulticastGroup ( const RTPAddress addr)
virtual

Leaves the multicast group specified by addr.

Implements qrtplib::RTPTransmitter.

Definition at line 352 of file rtpudptransmitter.cpp.

References ERR_RTP_UDPV4TRANS_NOTCREATED, ERR_RTP_UDPV4TRANS_NOTINIT, ERR_RTP_UDPV6TRANS_NOMULTICASTSUPPORT, qrtplib::RTPAddress::getAddress(), m_created, m_init, m_rtcpsock, m_rtpsock, and SupportsMulticasting().

353 {
354  if (!m_init) {
356  }
357 
358  if (!m_created) {
360  }
361 
362  if (!SupportsMulticasting()) {
364  }
365 
366  m_rtpsock->leaveMulticastGroup(addr.getAddress());
367 
368  if (m_rtpsock != m_rtcpsock)
369  {
370  m_rtcpsock->leaveMulticastGroup(addr.getAddress());
371  }
372 
373  return 0;
374 }
#define ERR_RTP_UDPV6TRANS_NOMULTICASTSUPPORT
Definition: rtperrors.h:162
#define ERR_RTP_UDPV4TRANS_NOTINIT
Definition: rtperrors.h:142
#define ERR_RTP_UDPV4TRANS_NOTCREATED
Definition: rtperrors.h:141
+ Here is the call graph for this function:

◆ moveToThread()

void qrtplib::RTPUDPTransmitter::moveToThread ( QThread *  thread)

◆ NewDataAvailable

void qrtplib::RTPUDPTransmitter::NewDataAvailable ( )
signal

Referenced by readRTCPPendingDatagrams(), and readRTPPendingDatagrams().

+ Here is the caller graph for this function:

◆ readRTCPPendingDatagrams

void qrtplib::RTPUDPTransmitter::readRTCPPendingDatagrams ( )
privateslot

Definition at line 502 of file rtpudptransmitter.cpp.

References qrtplib::RTPTime::CurrentTime(), m_rawPacketQueue, m_rawPacketQueueLock, m_rtcpBuffer, m_rtcpsock, NewDataAvailable(), qrtplib::RTPAddress::setAddress(), qrtplib::RTPAddress::setPort(), and ShouldAcceptData().

Referenced by BindSockets().

503 {
504  while (m_rtcpsock->hasPendingDatagrams())
505  {
506  RTPTime curtime = RTPTime::CurrentTime();
507  QHostAddress remoteAddress;
508  quint16 remotePort;
509  qint64 pendingDataSize = m_rtcpsock->pendingDatagramSize();
510  qint64 bytesRead = m_rtcpsock->readDatagram(m_rtcpBuffer, pendingDataSize, &remoteAddress, &remotePort);
511  qDebug("RTPUDPTransmitter::readRTCPPendingDatagrams: %lld bytes read from %s:%d",
512  bytesRead,
513  qPrintable(remoteAddress.toString()),
514  remotePort);
515 
516  RTPAddress rtpAddress;
517  rtpAddress.setAddress(remoteAddress);
518  rtpAddress.setPort(remotePort);
519 
520  if (ShouldAcceptData(rtpAddress))
521  {
522  RTPRawPacket *pack = new RTPRawPacket((uint8_t *) m_rtcpBuffer, bytesRead, rtpAddress, curtime, false);
523 
524  m_rawPacketQueueLock.lock();
525  m_rawPacketQueue.append(pack);
526  m_rawPacketQueueLock.unlock();
527 
528  emit NewDataAvailable();
529  }
530  }
531 }
QQueue< RTPRawPacket * > m_rawPacketQueue
bool ShouldAcceptData(const RTPAddress &address)
unsigned char uint8_t
Definition: rtptypes_win.h:42
char m_rtcpBuffer[m_absoluteMaxPackSize]
static RTPTime CurrentTime()
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ readRTPPendingDatagrams

void qrtplib::RTPUDPTransmitter::readRTPPendingDatagrams ( )
privateslot

Definition at line 456 of file rtpudptransmitter.cpp.

References qrtplib::RTPTime::CurrentTime(), m_rawPacketQueue, m_rawPacketQueueLock, m_rtcpsock, m_rtpBuffer, m_rtpsock, NewDataAvailable(), qrtplib::RTCPCommonHeader::packettype, qrtplib::RTPAddress::setAddress(), qrtplib::RTPAddress::setPort(), and ShouldAcceptData().

Referenced by BindSockets().

457 {
458  while (m_rtpsock->hasPendingDatagrams())
459  {
460  RTPTime curtime = RTPTime::CurrentTime();
461  QHostAddress remoteAddress;
462  quint16 remotePort;
463  qint64 pendingDataSize = m_rtpsock->pendingDatagramSize();
464  qint64 bytesRead = m_rtpsock->readDatagram(m_rtpBuffer, pendingDataSize, &remoteAddress, &remotePort);
465  qDebug("RTPUDPTransmitter::readRTPPendingDatagrams: %lld bytes read from %s:%d",
466  bytesRead,
467  qPrintable(remoteAddress.toString()),
468  remotePort);
469 
470  RTPAddress rtpAddress;
471  rtpAddress.setAddress(remoteAddress);
472  rtpAddress.setPort(remotePort);
473 
474  if (ShouldAcceptData(rtpAddress))
475  {
476  bool isrtp = true;
477 
478  if (m_rtpsock == m_rtcpsock) // check payload type when multiplexing
479  {
480  if ((std::size_t) bytesRead > sizeof(RTCPCommonHeader))
481  {
482  RTCPCommonHeader *rtcpheader = (RTCPCommonHeader *) m_rtpBuffer;
483  uint8_t packettype = rtcpheader->packettype;
484 
485  if (packettype >= 200 && packettype <= 204) {
486  isrtp = false;
487  }
488  }
489  }
490 
491  RTPRawPacket *pack = new RTPRawPacket((uint8_t *) m_rtpBuffer, bytesRead, rtpAddress, curtime, isrtp);
492 
493  m_rawPacketQueueLock.lock();
494  m_rawPacketQueue.append(pack);
495  m_rawPacketQueueLock.unlock();
496 
497  emit NewDataAvailable();
498  }
499  }
500 }
QQueue< RTPRawPacket * > m_rawPacketQueue
char m_rtpBuffer[m_absoluteMaxPackSize]
bool ShouldAcceptData(const RTPAddress &address)
unsigned char uint8_t
Definition: rtptypes_win.h:42
static RTPTime CurrentTime()
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SendRTCPData()

int qrtplib::RTPUDPTransmitter::SendRTCPData ( const void *  data,
std::size_t  len 
)
virtual

Send a packet with length len containing data to all RTCP addresses of the current destination list.

Implements qrtplib::RTPTransmitter.

Definition at line 267 of file rtpudptransmitter.cpp.

References ERR_RTP_UDPV4TRANS_NOTCREATED, ERR_RTP_UDPV4TRANS_NOTINIT, ERR_RTP_UDPV4TRANS_SPECIFIEDSIZETOOBIG, m_created, m_destinations, m_init, m_maxpacksize, and m_rtcpsock.

268 {
269  if (!m_init) {
271  }
272 
273  if (!m_created) {
275  }
276 
277  if (len > m_maxpacksize) {
279  }
280 
281  std::list<RTPAddress>::const_iterator it = m_destinations.begin();
282 
283  for (; it != m_destinations.end(); ++it)
284  {
285  m_rtcpsock->writeDatagram((const char*) data, (qint64) len, it->getAddress(), it->getRtcpsendport());
286  }
287 
288  return 0;
289 }
std::list< RTPAddress > m_destinations
#define ERR_RTP_UDPV4TRANS_NOTINIT
Definition: rtperrors.h:142
#define ERR_RTP_UDPV4TRANS_NOTCREATED
Definition: rtperrors.h:141
#define ERR_RTP_UDPV4TRANS_SPECIFIEDSIZETOOBIG
Definition: rtperrors.h:145

◆ SendRTPData()

int qrtplib::RTPUDPTransmitter::SendRTPData ( const void *  data,
std::size_t  len 
)
virtual

Send a packet with length len containing data to all RTP addresses of the current destination list.

Implements qrtplib::RTPTransmitter.

Definition at line 242 of file rtpudptransmitter.cpp.

References ERR_RTP_UDPV4TRANS_NOTCREATED, ERR_RTP_UDPV4TRANS_NOTINIT, ERR_RTP_UDPV4TRANS_SPECIFIEDSIZETOOBIG, m_created, m_destinations, m_init, m_maxpacksize, and m_rtpsock.

243 {
244  if (!m_init) {
246  }
247 
248  if (!m_created) {
250  }
251 
252  if (len > m_maxpacksize)
253  {
255  }
256 
257  std::list<RTPAddress>::const_iterator it = m_destinations.begin();
258 
259  for (; it != m_destinations.end(); ++it)
260  {
261  m_rtpsock->writeDatagram((const char*) data, (qint64) len, it->getAddress(), it->getPort());
262  }
263 
264  return 0;
265 }
std::list< RTPAddress > m_destinations
#define ERR_RTP_UDPV4TRANS_NOTINIT
Definition: rtperrors.h:142
#define ERR_RTP_UDPV4TRANS_NOTCREATED
Definition: rtperrors.h:141
#define ERR_RTP_UDPV4TRANS_SPECIFIEDSIZETOOBIG
Definition: rtperrors.h:145

◆ SetMaximumPacketSize()

int qrtplib::RTPUDPTransmitter::SetMaximumPacketSize ( std::size_t  s)
virtual

Sets the maximum packet size which the transmitter should allow to s.

Implements qrtplib::RTPTransmitter.

Definition at line 427 of file rtpudptransmitter.cpp.

References ERR_RTP_UDPV4TRANS_NOTCREATED, ERR_RTP_UDPV4TRANS_NOTINIT, ERR_RTP_UDPV4TRANS_SPECIFIEDSIZETOOBIG, m_absoluteMaxPackSize, m_created, m_init, and m_maxpacksize.

428 {
429  if (!m_init) {
431  }
432 
433  if (!m_created) {
435  }
436 
437  if (s > m_absoluteMaxPackSize) {
439  }
440 
441  m_maxpacksize = s;
442  return 0;
443 }
#define ERR_RTP_UDPV4TRANS_NOTINIT
Definition: rtperrors.h:142
static const std::size_t m_absoluteMaxPackSize
#define ERR_RTP_UDPV4TRANS_NOTCREATED
Definition: rtperrors.h:141
#define ERR_RTP_UDPV4TRANS_SPECIFIEDSIZETOOBIG
Definition: rtperrors.h:145

◆ SetReceiveMode()

int qrtplib::RTPUDPTransmitter::SetReceiveMode ( RTPTransmitter::ReceiveMode  m)
virtual

Sets the receive mode. Sets the receive mode to m, which is one of the following: RTPTransmitter::AcceptAll, RTPTransmitter::AcceptSome or RTPTransmitter::IgnoreSome. Note that if the receive mode is changed, all information about the addresses to ignore to accept is lost.

Implements qrtplib::RTPTransmitter.

Definition at line 376 of file rtpudptransmitter.cpp.

References ERR_RTP_UDPV4TRANS_NOTCREATED, ERR_RTP_UDPV4TRANS_NOTINIT, m_created, m_init, and m_receivemode.

377 {
378  if (!m_init) {
380  }
381 
382  if (!m_created) {
384  }
385 
386  if (m != m_receivemode) {
387  m_receivemode = m;
388  }
389 
390  return 0;
391 }
RTPTransmitter::ReceiveMode m_receivemode
#define ERR_RTP_UDPV4TRANS_NOTINIT
Definition: rtperrors.h:142
#define ERR_RTP_UDPV4TRANS_NOTCREATED
Definition: rtperrors.h:141

◆ ShouldAcceptData()

bool qrtplib::RTPUDPTransmitter::ShouldAcceptData ( const RTPAddress address)
private

Definition at line 533 of file rtpudptransmitter.cpp.

References qrtplib::RTPTransmitter::AcceptAll, qrtplib::RTPTransmitter::AcceptSome, m_acceptList, m_ignoreList, and m_receivemode.

Referenced by readRTCPPendingDatagrams(), and readRTPPendingDatagrams().

534 {
536  {
537  return true;
538  }
540  {
541  std::list<RTPAddress>::iterator findIt = std::find(m_acceptList.begin(), m_acceptList.end(), rtpAddress);
542  return findIt != m_acceptList.end();
543  }
544  else // this is RTPTransmitter::IgnoreSome
545  {
546  std::list<RTPAddress>::iterator findIt = std::find(m_ignoreList.begin(), m_ignoreList.end(), rtpAddress);
547  return findIt == m_ignoreList.end();
548  }
549 }
std::list< RTPAddress > m_ignoreList
RTPTransmitter::ReceiveMode m_receivemode
std::list< RTPAddress > m_acceptList
+ Here is the caller graph for this function:

◆ SupportsMulticasting()

bool qrtplib::RTPUDPTransmitter::SupportsMulticasting ( )
virtual

Returns true if the transmission component supports multicasting.

Implements qrtplib::RTPTransmitter.

Definition at line 308 of file rtpudptransmitter.cpp.

References m_multicastInterface, m_rtcpsock, and m_rtpsock.

Referenced by JoinMulticastGroup(), and LeaveMulticastGroup().

309 {
310  QNetworkInterface::InterfaceFlags flags = m_multicastInterface.flags();
311  QAbstractSocket::SocketState rtpSocketState = m_rtpsock->state();
312  QAbstractSocket::SocketState rtcpSocketState = m_rtcpsock->state();
313  return m_multicastInterface.isValid()
314  && (rtpSocketState & QAbstractSocket::BoundState)
315  && (rtcpSocketState & QAbstractSocket::BoundState)
316  && (flags & QNetworkInterface::CanMulticast)
317  && (flags & QNetworkInterface::IsRunning)
318  && !(flags & QNetworkInterface::IsLoopBack);
319 }
QNetworkInterface m_multicastInterface
from parameters multicast interface
+ Here is the caller graph for this function:

Member Data Documentation

◆ m_absoluteMaxPackSize

const std::size_t qrtplib::RTPUDPTransmitter::m_absoluteMaxPackSize = 65535
staticprivate

Definition at line 357 of file rtpudptransmitter.h.

Referenced by Create(), RTPUDPTransmitter(), and SetMaximumPacketSize().

◆ m_acceptList

std::list<RTPAddress> qrtplib::RTPUDPTransmitter::m_acceptList
private

◆ m_created

bool qrtplib::RTPUDPTransmitter::m_created
private

◆ m_deletesocketswhendone

bool qrtplib::RTPUDPTransmitter::m_deletesocketswhendone
private

Definition at line 350 of file rtpudptransmitter.h.

Referenced by Create(), Destroy(), and RTPUDPTransmitter().

◆ m_destinations

std::list<RTPAddress> qrtplib::RTPUDPTransmitter::m_destinations
private

◆ m_ignoreList

std::list<RTPAddress> qrtplib::RTPUDPTransmitter::m_ignoreList
private

◆ m_init

bool qrtplib::RTPUDPTransmitter::m_init
private

◆ m_localIP

QHostAddress qrtplib::RTPUDPTransmitter::m_localIP
private

from parameters bind IP

Definition at line 351 of file rtpudptransmitter.h.

Referenced by BindSockets(), ComesFromThisTransmitter(), Create(), and GetTransmissionInfo().

◆ m_maxpacksize

std::size_t qrtplib::RTPUDPTransmitter::m_maxpacksize
private

◆ m_multicastInterface

QNetworkInterface qrtplib::RTPUDPTransmitter::m_multicastInterface
private

from parameters multicast interface

Definition at line 352 of file rtpudptransmitter.h.

Referenced by Create(), JoinMulticastGroup(), and SupportsMulticasting().

◆ m_rawPacketQueue

QQueue<RTPRawPacket*> qrtplib::RTPUDPTransmitter::m_rawPacketQueue
private

◆ m_rawPacketQueueLock

QMutex qrtplib::RTPUDPTransmitter::m_rawPacketQueueLock
private

◆ m_receivemode

RTPTransmitter::ReceiveMode qrtplib::RTPUDPTransmitter::m_receivemode
private

Definition at line 354 of file rtpudptransmitter.h.

Referenced by Create(), RTPUDPTransmitter(), SetReceiveMode(), and ShouldAcceptData().

◆ m_rtcpBuffer

char qrtplib::RTPUDPTransmitter::m_rtcpBuffer[m_absoluteMaxPackSize]
private

Definition at line 359 of file rtpudptransmitter.h.

Referenced by readRTCPPendingDatagrams(), and RTPUDPTransmitter().

◆ m_rtcpPort

uint16_t qrtplib::RTPUDPTransmitter::m_rtcpPort
private

◆ m_rtcpsock

QUdpSocket * qrtplib::RTPUDPTransmitter::m_rtcpsock
private

◆ m_rtpBuffer

char qrtplib::RTPUDPTransmitter::m_rtpBuffer[m_absoluteMaxPackSize]
private

Definition at line 358 of file rtpudptransmitter.h.

Referenced by readRTPPendingDatagrams(), and RTPUDPTransmitter().

◆ m_rtpPort

uint16_t qrtplib::RTPUDPTransmitter::m_rtpPort
private

◆ m_rtpsock

QUdpSocket* qrtplib::RTPUDPTransmitter::m_rtpsock
private

◆ m_waitingfordata

bool qrtplib::RTPUDPTransmitter::m_waitingfordata
private

Definition at line 348 of file rtpudptransmitter.h.

Referenced by Create(), and RTPUDPTransmitter().


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