45 #ifndef RTPFAKETRANSMITTER_H
47 #define RTPFAKETRANSMITTER_H
49 #include "rtpconfig.h"
57 #ifdef RTP_SUPPORT_THREAD
59 #endif // RTP_SUPPORT_THREAD
61 #define RTPFAKETRANS_HASHSIZE 8317
62 #define RTPFAKETRANS_DEFAULTPORTBASE 5000
66 typedef void(*packet_ready_cb)(
void*, uint8_t*, uint16_t, uint32_t, uint16_t,
int rtp);
71 RTPFakeTransmissionParams():
RTPTransmissionParams(
RTPTransmitter::UserDefinedProto) { portbase = RTPFAKETRANS_DEFAULTPORTBASE; bindIP = 0; multicastTTL = 1; currentdata = NULL;}
72 void SetBindIP(uint32_t ip) { bindIP = ip; }
73 void SetPortbase(uint16_t pbase) { portbase = pbase; }
74 void SetMulticastTTL(uint8_t mcastTTL) { multicastTTL = mcastTTL; }
75 void SetLocalIPList(std::list<uint32_t> &iplist) { localIPs = iplist; }
76 void ClearLocalIPList() { localIPs.clear(); }
77 void SetCurrentData(uint8_t *data) { currentdata = data; }
78 void SetCurrentDataLen(uint16_t len) { currentdatalen = len; }
79 void SetCurrentDataAddr(uint32_t addr) { currentdataaddr = addr; }
80 void SetCurrentDataPort(uint16_t port) { currentdataport = port; }
81 void SetCurrentDataType(
bool type) { currentdatatype = type; }
82 void SetPacketReadyCB(packet_ready_cb cb) { packetreadycb = cb; };
83 void SetPacketReadyCBData(
void *data) { packetreadycbdata = data; };
84 uint32_t GetBindIP()
const {
return bindIP; }
85 uint16_t GetPortbase()
const {
return portbase; }
86 uint8_t GetMulticastTTL()
const {
return multicastTTL; }
87 const std::list<uint32_t> &GetLocalIPList()
const {
return localIPs; }
88 uint8_t* GetCurrentData()
const {
return currentdata; }
89 uint16_t GetCurrentDataLen()
const {
return currentdatalen; }
90 uint32_t GetCurrentDataAddr()
const {
return currentdataaddr; }
91 uint16_t GetCurrentDataPort()
const {
return currentdataport; }
92 bool GetCurrentDataType()
const {
return currentdatatype; }
93 packet_ready_cb GetPacketReadyCB()
const {
return packetreadycb; }
94 void* GetPacketReadyCBData()
const {
return packetreadycbdata; }
98 std::list<uint32_t> localIPs;
100 uint8_t* currentdata;
101 uint16_t currentdatalen;
102 uint32_t currentdataaddr;
103 uint16_t currentdataport;
104 bool currentdatatype;
105 packet_ready_cb packetreadycb;
106 void *packetreadycbdata;
112 RTPFakeTransmissionInfo(std::list<uint32_t> iplist,
113 RTPFakeTransmissionParams *transparams) :
115 { localIPlist = iplist; params = transparams; }
117 ~RTPFakeTransmissionInfo() { }
118 std::list<uint32_t> GetLocalIPList()
const {
return localIPlist; }
119 RTPFakeTransmissionParams* GetTransParams() {
return params; }
121 std::list<uint32_t> localIPlist;
122 RTPFakeTransmissionParams *params;
125 class RTPFakeTrans_GetHashIndex_IPv4Dest
128 static int GetIndex(
const RTPIPv4Destination &d) {
return d.GetIP()%RTPFAKETRANS_HASHSIZE; }
131 class RTPFakeTrans_GetHashIndex_uint32_t
134 static int GetIndex(
const uint32_t &k) {
return k%RTPFAKETRANS_HASHSIZE; }
137 #define RTPFAKETRANS_HEADERSIZE (20+8)
143 ~RTPFakeTransmitter();
145 int Init(
bool treadsafe);
185 int CreateLocalIPList();
186 bool GetLocalIPList_Interfaces();
187 void GetLocalIPList_DNS();
188 void AddLoopbackAddress();
191 int ProcessAddAcceptIgnoreEntry(uint32_t ip,uint16_t port);
192 int ProcessDeleteAcceptIgnoreEntry(uint32_t ip,uint16_t port);
193 #ifdef RTP_SUPPORT_IPV4MULTICAST
194 bool SetMulticastTTL(uint8_t ttl);
195 #endif // RTP_SUPPORT_IPV4MULTICAST
196 bool ShouldAcceptData(uint32_t srcip,uint16_t srcport);
197 void ClearAcceptIgnoreInfo();
199 RTPFakeTransmissionParams *params;
203 std::list<uint32_t> localIPs;
205 uint8_t multicastTTL;
208 uint8_t *localhostname;
209 size_t localhostnamelength;
211 RTPHashTable<const RTPIPv4Destination,RTPFakeTrans_GetHashIndex_IPv4Dest,RTPFAKETRANS_HASHSIZE> destinations;
212 #ifdef RTP_SUPPORT_IPV4MULTICAST
214 #endif // RTP_SUPPORT_IPV4MULTICAST
215 std::list<RTPRawPacket*> rawpacketlist;
217 bool supportsmulticasting;
223 PortInfo() { all =
false; }
226 std::list<uint16_t> portlist;
229 RTPKeyHashTable<const uint32_t,PortInfo*,RTPFakeTrans_GetHashIndex_uint32_t,RTPFAKETRANS_HASHSIZE> acceptignoreinfo;
231 int CreateAbortDescriptors();
232 void DestroyAbortDescriptors();
233 void AbortWaitInternal();
234 #ifdef RTP_SUPPORT_THREAD
235 JMutex mainmutex,waitmutex;
237 #endif // RTP_SUPPORT_THREAD
240 #endif // RTPFakeTRANSMITTER_H
virtual int WaitForIncomingData(const RTPTime &delay, bool *dataavailable=0)=0
Waits until incoming data is detected.
virtual int DeleteDestination(const RTPAddress &addr)=0
Deletes the address specified by addr from the list of destinations.
virtual int AddToAcceptList(const RTPAddress &addr)=0
Adds addr to the list of addresses to accept.
virtual int LeaveMulticastGroup(const RTPAddress &addr)=0
Leaves the multicast group specified by addr.
virtual RTPTransmissionInfo * GetTransmissionInfo()=0
Returns additional information about the transmitter.
A memory manager.
Definition: rtpmemorymanager.h:144
virtual int SendRTPData(const void *data, size_t len)=0
Send a packet with length len containing data to all RTP addresses of the current destination list...
virtual bool SupportsMulticasting()=0
Returns true if the transmission component supports multicasting.
This class is used to specify wallclock time, delay intervals etc.
Definition: rtptimeutilities.h:77
virtual int Init(bool threadsafe)=0
This function must be called before the transmission component can be used.
virtual int GetLocalHostName(uint8_t *buffer, size_t *bufferlength)=0
Looks up the local host name.
Base class for additional information about the transmitter.
Definition: rtptransmitter.h:236
virtual void ClearAcceptList()=0
Clears the list of addresses to accept.
virtual void Destroy()=0
By calling this function, buffers are cleared and the component cannot be used anymore.
virtual int Poll()=0
Checks for incoming data and stores it.
This class is used by the transmission component to store the incoming RTP and RTCP data in...
Definition: rtprawpacket.h:48
virtual int AbortWait()=0
If the previous function has been called, this one aborts the waiting.
virtual int AddDestination(const RTPAddress &addr)=0
Adds the address specified by addr to the list of destinations.
virtual void ClearDestinations()=0
Clears the list of destinations.
ReceiveMode
Three kind of receive modes can be specified.
Definition: rtptransmitter.h:73
virtual size_t GetHeaderOverhead()=0
Returns the amount of bytes that will be added to the RTP packet by the underlying layers (excluding ...
Abstract class from which actual transmission components should be derived.
Definition: rtptransmitter.h:57
virtual RTPRawPacket * GetNextPacket()=0
Returns the raw data of a received RTP packet (received during the Poll function) in an RTPRawPacket ...
This class is an abstract class which is used to specify destinations, multicast groups etc...
Definition: rtpaddress.h:47
virtual int DeleteFromAcceptList(const RTPAddress &addr)=0
Deletes addr from the list of addresses to accept.
virtual void ClearIgnoreList()=0
Clears the list of addresses to ignore.
virtual int JoinMulticastGroup(const RTPAddress &addr)=0
Joins the multicast group specified by addr.
virtual int DeleteFromIgnoreList(const RTPAddress &addr)=0
Deletes addr from the list of addresses to accept.
virtual int Create(size_t maxpacksize, const RTPTransmissionParams *transparams)=0
Prepares the component to be used.
virtual bool NewDataAvailable()=0
Returns true if packets can be obtained using the GetNextPacket member function.
virtual int SetMaximumPacketSize(size_t s)=0
Sets the maximum packet size which the transmitter should allow to s.
virtual void LeaveAllMulticastGroups()=0
Leaves all the multicast groups that have been joined.
virtual int SendRTCPData(const void *data, size_t len)=0
Send a packet with length len containing data to all RTCP addresses of the current destination list...
virtual bool ComesFromThisTransmitter(const RTPAddress *addr)=0
Returns true if the address specified by addr is one of the addresses of the transmitter.
Base class for transmission parameters.
Definition: rtptransmitter.h:217
virtual int AddToIgnoreList(const RTPAddress &addr)=0
Adds addr to the list of addresses to ignore.
virtual int SetReceiveMode(RTPTransmitter::ReceiveMode m)=0
Sets the receive mode.