37 #ifndef RTPUDPV4TRANSMITTER_H
39 #define RTPUDPV4TRANSMITTER_H
41 #include "rtpconfig.h"
49 #ifdef RTP_SUPPORT_THREAD
50 #include <jthread/jmutex.h>
51 #endif // RTP_SUPPORT_THREAD
53 #define RTPUDPV4TRANS_HASHSIZE 8317
54 #define RTPUDPV4TRANS_DEFAULTPORTBASE 5000
56 #define RTPUDPV4TRANS_RTPRECEIVEBUFFER 32768
57 #define RTPUDPV4TRANS_RTCPRECEIVEBUFFER 32768
58 #define RTPUDPV4TRANS_RTPTRANSMITBUFFER 32768
59 #define RTPUDPV4TRANS_RTCPTRANSMITBUFFER 32768
133 void SetUseExistingSockets(SocketType rtpsocket, SocketType rtcpsocket) { rtpsock = rtpsocket; rtcpsock = rtcpsocket; useexistingsockets =
true; }
158 bool GetUseExistingSockets(SocketType &rtpsocket, SocketType &rtcpsocket)
const {
if (!useexistingsockets)
return false; rtpsocket = rtpsock; rtcpsocket = rtcpsock;
return true; }
161 uint32_t bindIP, mcastifaceIP;
162 std::list<uint32_t> localIPs;
163 uint8_t multicastTTL;
164 int rtpsendbuf, rtprecvbuf;
165 int rtcpsendbuf, rtcprecvbuf;
167 bool allowoddportbase;
168 uint16_t forcedrtcpport;
170 SocketType rtpsock, rtcpsock;
171 bool useexistingsockets;
174 inline RTPUDPv4TransmissionParams::RTPUDPv4TransmissionParams() : RTPTransmissionParams(RTPTransmitter::IPv4UDPProto)
176 portbase = RTPUDPV4TRANS_DEFAULTPORTBASE;
180 rtpsendbuf = RTPUDPV4TRANS_RTPTRANSMITBUFFER;
181 rtprecvbuf = RTPUDPV4TRANS_RTPRECEIVEBUFFER;
182 rtcpsendbuf = RTPUDPV4TRANS_RTCPTRANSMITBUFFER;
183 rtcprecvbuf = RTPUDPV4TRANS_RTCPRECEIVEBUFFER;
185 allowoddportbase =
false;
187 useexistingsockets =
false;
198 { localIPlist = iplist; rtpsocket = rtpsock; rtcpsocket = rtcpsock; m_rtpPort = rtpport; m_rtcpPort = rtcpport; }
217 std::list<uint32_t> localIPlist;
218 SocketType rtpsocket,rtcpsocket;
219 uint16_t m_rtpPort, m_rtcpPort;
222 class JRTPLIB_IMPORTEXPORT RTPUDPv4Trans_GetHashIndex_IPv4Dest
225 static int GetIndex(
const RTPIPv4Destination &d) {
return d.GetIP()%RTPUDPV4TRANS_HASHSIZE; }
228 class JRTPLIB_IMPORTEXPORT RTPUDPv4Trans_GetHashIndex_uint32_t
231 static int GetIndex(
const uint32_t &k) {
return k%RTPUDPV4TRANS_HASHSIZE; }
234 #define RTPUDPV4TRANS_HEADERSIZE (20+8)
249 int Init(
bool treadsafe);
255 int GetLocalHostName(uint8_t *buffer,
size_t *bufferlength);
256 bool ComesFromThisTransmitter(
const RTPAddress *addr);
257 size_t GetHeaderOverhead() {
return RTPUDPV4TRANS_HEADERSIZE; }
260 int WaitForIncomingData(
const RTPTime &delay,
bool *dataavailable = 0);
263 int SendRTPData(
const void *data,
size_t len);
264 int SendRTCPData(
const void *data,
size_t len);
267 int DeleteDestination(
const RTPAddress &addr);
268 void ClearDestinations();
270 bool SupportsMulticasting();
271 int JoinMulticastGroup(
const RTPAddress &addr);
272 int LeaveMulticastGroup(
const RTPAddress &addr);
273 void LeaveAllMulticastGroups();
277 int DeleteFromIgnoreList(
const RTPAddress &addr);
278 void ClearIgnoreList();
280 int DeleteFromAcceptList(
const RTPAddress &addr);
281 void ClearAcceptList();
282 int SetMaximumPacketSize(
size_t s);
284 bool NewDataAvailable();
290 int CreateLocalIPList();
291 bool GetLocalIPList_Interfaces();
292 void GetLocalIPList_DNS();
293 void AddLoopbackAddress();
295 int PollSocket(
bool rtp);
296 int ProcessAddAcceptIgnoreEntry(uint32_t ip,uint16_t port);
297 int ProcessDeleteAcceptIgnoreEntry(uint32_t ip,uint16_t port);
298 #ifdef RTP_SUPPORT_IPV4MULTICAST
299 bool SetMulticastTTL(uint8_t ttl);
300 #endif // RTP_SUPPORT_IPV4MULTICAST
301 bool ShouldAcceptData(uint32_t srcip,uint16_t srcport);
302 void ClearAcceptIgnoreInfo();
307 SocketType rtpsock,rtcpsock;
308 uint32_t mcastifaceIP;
309 std::list<uint32_t> localIPs;
310 uint16_t m_rtpPort, m_rtcpPort;
311 uint8_t multicastTTL;
314 uint8_t *localhostname;
315 size_t localhostnamelength;
317 RTPHashTable<const RTPIPv4Destination,RTPUDPv4Trans_GetHashIndex_IPv4Dest,RTPUDPV4TRANS_HASHSIZE> destinations;
318 #ifdef RTP_SUPPORT_IPV4MULTICAST
319 RTPHashTable<const uint32_t,RTPUDPv4Trans_GetHashIndex_uint32_t,RTPUDPV4TRANS_HASHSIZE> multicastgroups;
320 #endif // RTP_SUPPORT_IPV4MULTICAST
321 std::list<RTPRawPacket*> rawpacketlist;
323 bool supportsmulticasting;
329 PortInfo() { all =
false; }
332 std::list<uint16_t> portlist;
335 RTPKeyHashTable<const uint32_t,PortInfo*,RTPUDPv4Trans_GetHashIndex_uint32_t,RTPUDPV4TRANS_HASHSIZE> acceptignoreinfo;
338 SocketType abortdesc[2];
339 bool closesocketswhendone;
341 int CreateAbortDescriptors();
342 void DestroyAbortDescriptors();
343 void AbortWaitInternal();
344 #ifdef RTP_SUPPORT_THREAD
345 jthread::JMutex mainmutex,waitmutex;
347 #endif // RTP_SUPPORT_THREAD
352 #endif // RTPUDPV4TRANSMITTER_H
bool GetUseExistingSockets(SocketType &rtpsocket, SocketType &rtcpsocket) const
Returns true and fills in sockets if existing sockets were set using RTPUDPv4TransmissionParams::SetU...
Definition: rtpudpv4transmitter.h:158
void SetLocalIPList(std::list< uint32_t > &iplist)
Passes a list of IP addresses which will be used as the local IP addresses.
Definition: rtpudpv4transmitter.h:85
int GetRTPSendBuffer() const
Returns the RTP socket's send buffer size.
Definition: rtpudpv4transmitter.h:136
uint16_t GetRTCPPort() const
Returns the port number that the RTCP socket receives packets on.
Definition: rtpudpv4transmitter.h:215
This class is used by the transmission component to store the incoming RTP and RTCP data in...
Definition: rtprawpacket.h:51
Specifies the internal UDP over IPv4 transmitter.
Definition: rtptransmitter.h:72
Base class for transmission parameters.
Definition: rtptransmitter.h:228
SocketType GetRTCPSocket() const
Returns the socket descriptor used for receiving and transmitting RTCP packets.
Definition: rtpudpv4transmitter.h:209
int GetRTPReceiveBuffer() const
Returns the RTP socket's receive buffer size.
Definition: rtpudpv4transmitter.h:139
Additional information about the UDP over IPv4 transmitter.
Definition: rtpudpv4transmitter.h:193
void SetForcedRTCPPort(uint16_t rtcpport)
Force the RTCP socket to use a specific port, not necessarily one more than the RTP port (set this to...
Definition: rtpudpv4transmitter.h:128
std::list< uint32_t > GetLocalIPList() const
Returns the list of IPv4 addresses the transmitter considers to be the local IP addresses.
Definition: rtpudpv4transmitter.h:203
int GetRTCPSendBuffer() const
Returns the RTCP socket's send buffer size.
Definition: rtpudpv4transmitter.h:142
void ClearLocalIPList()
Clears the list of local IP addresses.
Definition: rtpudpv4transmitter.h:91
Parameters for the UDP over IPv4 transmitter.
Definition: rtpudpv4transmitter.h:65
uint8_t GetMulticastTTL() const
Returns the multicast TTL which will be used (default is 1).
Definition: rtpudpv4transmitter.h:103
void SetRTPSendBuffer(int s)
Sets the RTP socket's send buffer size.
Definition: rtpudpv4transmitter.h:109
This class is an abstract class which is used to specify destinations, multicast groups etc...
Definition: rtpaddress.h:50
void SetMulticastInterfaceIP(uint32_t ip)
Sets the multicast interface IP address.
Definition: rtpudpv4transmitter.h:74
uint32_t GetBindIP() const
Returns the IP address which will be used to bind the sockets.
Definition: rtpudpv4transmitter.h:94
SocketType GetRTPSocket() const
Returns the socket descriptor used for receiving and transmitting RTP packets.
Definition: rtpudpv4transmitter.h:206
uint16_t GetRTPPort() const
Returns the port number that the RTP socket receives packets on.
Definition: rtpudpv4transmitter.h:212
uint32_t GetMulticastInterfaceIP() const
Returns the multicast interface IP address.
Definition: rtpudpv4transmitter.h:97
uint16_t GetForcedRTCPPort() const
If non-zero, the specified port will be used to receive RTCP traffic.
Definition: rtpudpv4transmitter.h:154
An UDP over IPv4 transmission component.
Definition: rtpudpv4transmitter.h:243
Abstract class from which actual transmission components should be derived.
Definition: rtptransmitter.h:62
ReceiveMode
Three kind of receive modes can be specified.
Definition: rtptransmitter.h:79
void SetAllowOddPortbase(bool f)
Can be used to allow the RTP port base to be any number, not just even numbers.
Definition: rtpudpv4transmitter.h:124
void SetRTCPReceiveBuffer(int s)
Sets the RTCP socket's receive buffer size.
Definition: rtpudpv4transmitter.h:118
This class is used to specify wallclock time, delay intervals etc.
Definition: rtptimeutilities.h:84
void SetUseExistingSockets(SocketType rtpsocket, SocketType rtcpsocket)
Use sockets that have already been created, no checks on port numbers will be done, and no buffer sizes will be set; you'll need to close the sockets yourself when done, it will not be done automatically.
Definition: rtpudpv4transmitter.h:133
void SetRTCPMultiplexing(bool f)
Enables or disables multiplexing RTCP traffic over the RTP channel, so that only a single port is use...
Definition: rtpudpv4transmitter.h:121
A memory manager.
Definition: rtpmemorymanager.h:150
void SetRTCPSendBuffer(int s)
Sets the RTCP socket's send buffer size.
Definition: rtpudpv4transmitter.h:115
void SetMulticastTTL(uint8_t mcastTTL)
Sets the multicast TTL to be used to mcastTTL.
Definition: rtpudpv4transmitter.h:82
void SetPortbase(uint16_t pbase)
Sets the RTP portbase to pbase, which has to be an even number unless RTPUDPv4TransmissionParams::Set...
Definition: rtpudpv4transmitter.h:79
int GetRTCPReceiveBuffer() const
Returns the RTCP socket's receive buffer size.
Definition: rtpudpv4transmitter.h:145
const std::list< uint32_t > & GetLocalIPList() const
Returns the list of local IP addresses.
Definition: rtpudpv4transmitter.h:106
bool GetAllowOddPortbase() const
If true, any RTP portbase will be allowed, not just even numbers.
Definition: rtpudpv4transmitter.h:151
Base class for additional information about the transmitter.
Definition: rtptransmitter.h:247
void SetBindIP(uint32_t ip)
Sets the IP address which is used to bind the sockets to ip.
Definition: rtpudpv4transmitter.h:71
bool GetRTCPMultiplexing() const
Returns a flag indicating if RTCP traffic will be multiplexed over the RTP channel.
Definition: rtpudpv4transmitter.h:148
uint16_t GetPortbase() const
Returns the RTP portbase which will be used (default is 5000).
Definition: rtpudpv4transmitter.h:100
void SetRTPReceiveBuffer(int s)
Sets the RTP socket's receive buffer size.
Definition: rtpudpv4transmitter.h:112