63 queueApplication(app), srtcpIndex(0)
114 queueApplication(app), srtcpIndex(0)
177 bool is_new, InetAddress& network_address, tpport_t transport_port)
230 dispatchBYE(
"SSRC collision detected when receiving RTCP packet");
248 SysTime::gettimeofday(&(
reconsInfo.rtcpTc),NULL);
270 SysTime::gettimeofday(&(
reconsInfo.rtcpTc),NULL);
301 SysTime::gettimeofday(&(
reconsInfo.rtcpTc),NULL);
317 InetHostAddress network_address;
318 tpport_t transport_port;
322 struct timeval recvtime;
323 SysTime::gettimeofday(&recvtime,NULL);
363 if ( source_created ) {
372 }
else if ( s->getControlTransportPort() == 0 ) {
408 network_address,transport_port) )
417 bool cname_found =
false;
418 while ( (pointer < len ) &&
429 cname_found = cname_found? cname_found : cname;
445 while ( pointer < len ) {
462 if ( pointer != len ) {
490 timeradd(&tNTP,&timevalInc,&packetTime);
492 SysTime::gettimeofday(&now,NULL);
493 timersub(&now,&packetTime,&diff);
511 for ( uint8 i = 0; i < blocks; i++) {
517 (reinterpret_cast<unsigned char*>(&(RR.
blocks[i].
rinfo)));
541 reason =
new char[len + 1];
545 reason =
new char[1];
580 inc.tv_usec = t % 1000000;
581 inc.tv_sec = t / 1000000;
590 inc.tv_usec = t % 1000000;
591 inc.tv_sec = t / 1000000;
601 bool cname_found =
false;
603 std::ptrdiff_t pointer =
reinterpret_cast<unsigned char*
>(&pkt) -
rtcpRecvBuffer;
610 bool source_created =
false;
631 bool cname_found =
false;
637 size_t pointer =
sizeof(chunk.
ssrc);
640 while ( (pointer < len) && !
end ) {
642 reinterpret_cast<SDESItem*
>(size_t(&(chunk)) + pointer);
644 pointer +=
sizeof(item->
type) +
sizeof(item->
len) +
648 std::string cname = std::string(item->
data,item->
len);
675 pointer += (pointer & 0x03);
677 std::ptrdiff_t prevpointer = pointer;
678 uint8 plength = *( &(item->
len) + 1 );
679 pointer +=
sizeof(item->
type) +
sizeof(item->
len) + 1;
683 reinterpret_cast<char*>(item + pointer),plength);
686 reinterpret_cast<char*>(item + pointer),
687 (item->
len - 1 - plength));
688 pointer = prevpointer + item->
len;
723 if ( bwfract != 0 ) {
725 ((participants *
rtcpAvgSize / bwfract) * 1000000);
731 interval = 100000000;
735 (rand() / (RAND_MAX + 1.0))));
738 result.tv_sec = interval / 1000000;
739 result.tv_usec = interval % 1000000;
743 #define BYE_BUFFER_LENGTH 500
756 SysTime::gettimeofday(&(
reconsInfo.rtcpTc),NULL);
763 strlen(reason.c_str()) +
764 (4 - (strlen(reason.c_str()) & 0x03)));
765 SysTime::gettimeofday(&(
reconsInfo.rtcpTc),NULL);
772 SysTime::gettimeofday(&(
reconsInfo.rtcpTc),NULL);
788 pkt->
fh.
length = htons((len1 >> 2) - 1);
792 pkt =
reinterpret_cast<RTCPPacket*
>(buffer + len1);
800 if ( reason.c_str() != NULL ){
804 padlen = 4 - ((len - len1) & 0x03);
806 memset(buffer + len,0,padlen);
811 pkt->
fh.
length = htons(((len - len1) >> 2) - 1);
827 InetHostAddress network_address;
828 tpport_t transport_port;
830 network_address,transport_port)) ) {
840 while ( pointer < len) {
888 SysTime::gettimeofday(&now,NULL);
891 pkt->
info.
SR.
sinfo.
NTPLSW = htonl((uint32)(((
double)(now.tv_usec)*(uint32)(~0))/1000000.0));
922 bool another =
false;
933 pkt->
fh.
length = htons( ((len - prevlen) >> 2) - 1);
935 if ( 31 == blocks ) {
938 if ( len < (available -
959 }
while ( (len < available) && another );
979 uint16 prevlen = len;
1000 len += (uint16)cnameLen;
1007 item->
type = nexttype;
1008 const char *content =
1010 item->
len = (uint8)strlen(content);
1021 uint8 padding = len & 0x03;
1023 padding = 4 - padding;
1027 pkt->
fh.
length = htons((len - prevlen - 1) >>2);
1052 htonl(static_cast<uint32>(srcLink.
getJitter()));
1060 htonl( ((ntohl(si->
NTPMSW) & 0x0FFFF) << 16 )+
1061 ((ntohl(si->
NTPLSW) & 0xFFFF0000) >> 16)
1064 SysTime::gettimeofday(&now,NULL);
1066 timersub(&now,&last,&diff);
1077 const char*
const value,
size_t len)
1079 char* buf =
new char[len + 1];
1080 memcpy(buf,value,len);
1088 char *buf =
new char[len + 1];
1089 memcpy(buf,value,len);
1118 t =
static_cast<SDESItemType>(
static_cast<int>(t) + 1 );
1147 len =
protect(buffer, len, pcc);
1154 for (std::list<TransportAddress*>::iterator i =
1171 uint32 ssrc = *(
reinterpret_cast<uint32*
>(pkt + 4));
1178 uint32* ip =
reinterpret_cast<uint32*
>(pkt+len);
1179 *ip = htonl(encIndex);
1203 const uint32* index =
reinterpret_cast<uint32*
>(pkt + payloadLen);
1204 uint32 ssrc = *(
reinterpret_cast<uint32*
>(pkt + 4));
1207 uint32 encIndex = ntohl(*index);
1208 uint32 remoteIndex = encIndex & ~0x80000000;
1226 if (encIndex & 0x80000000)
1227 pcc->
srtcpEncrypt(pkt + 8, payloadLen - 8, remoteIndex, ssrc);
1230 pcc->
update(remoteIndex);
1239 std::list<CryptoContextCtrl *>::iterator i;
1245 if( (*i)->getSsrc() == cc->
getSsrc() ) {
1258 std::list<CryptoContextCtrl *>::iterator i;
1270 if( (*i)->getSsrc() == cc->
getSsrc() ) {
1283 std::list<CryptoContextCtrl *>::iterator i;
1287 if( (*i)->getSsrc() == ssrc) {
1297 std::list<CryptoContextCtrl *>::iterator i;
1303 if( (*i)->getSsrc() == cc->
getSsrc() ) {
1316 std::list<CryptoContextCtrl *>::iterator i;
1328 if( (*i)->getSsrc() == cc->
getSsrc() ) {
1341 std::list<CryptoContextCtrl *>::iterator i;
1345 if( (*i)->getSsrc() == ssrc) {
uint32 getSendPacketCount() const
Get the total number of packets sent so far.
Struct for a receiver info block in a SR (sender report) or an RR (receiver report) RTCP packet...
uint32 lsr
last sender report timestamp.
uint32 getNTPTimestampFrac() const
Get fractional part of the NTP timestamp of this packet.
unsigned char block_count
< For little endian boxes
uint32 getSendOctetCount() const
Get the total number of octets (payload only) sent so far.
void deriveSrtcpKeys()
Perform key derivation according to SRTP specification.
void addParticipant(RTPApplication &app, Participant &part)
uint32 getNTPTimestampInt() const
Get integer part of the NTP timestamp of this packet.
microtimeout_t getDefaultEnd2EndDelay() const
int32 protect(uint8 *pkt, size_t len, CryptoContextCtrl *cc)
The implementation for a SRTCP cryptographic context.
int32 getTagLength() const
Get the length of the SRTP authentication tag in bytes.
SDESItemType nextSDESType(SDESItemType t)
microtimeout_t getEnd2EndDelay() const
tpport_t getDataTransportPort() const
virtual bool isPendingControl(microtimeout_t timeout)=0
unsigned char * rtcpSendBuffer
low level structs and RTCP packet parsing and building methods.
std::list< CryptoContextCtrl * > outCryptoContexts
An RTP application, holding identifying RTCP SDES item values.
NAMESPACE_COMMONCPP const uint32 NTP_EPOCH_OFFSET
ReceiverInfo rinfo
info about the source.
Synchronization source in an RTP session.
static const SDESItemType firstSchedulable
bool getBYE(RTCPPacket &pkt, size_t &pointer, size_t len)
Process a BYE packet just received and identified.
uint32 highestSeqNum
highest sequence number.
void setPRIVPrefix(Participant *part, const std::string val)
unsigned char * getSenderInfo()
IncomingRTPPkt * getPacket() const
volatile bool controlServiceActive
uint32 ssrc
ssrc identifier of source leaving.
ConflictingTransportAddress * getPrevConflict() const
const uint8 CCRTP_VERSION
RTP protocol version supported.
uint32 jitter
arrival jitter.
virtual size_t sendControl(const unsigned char *const buffer, size_t len)=0
void setPrevConflict(InetAddress &addr, tpport_t dataPort, tpport_t controlPort)
Get conflicting address.
virtual bool onGotSDESChunk(SyncSource &source, SDESChunk &chunk, size_t len)
Plug-in for handling of SDES chunks.
void setProbation(uint8 p)
void updateAvgRTCPSize(size_t len)
This must be called in order to update the average RTCP compound packet size estimation when: ...
uint32 octetCount
cumulative octet counter.
bool checkCompoundRTCPHeader(size_t len)
Perform RTCP compound packet header validity check as specified in draft-ietv-avt-rtp-new.
uint32 microtimeout_t
Time interval expressed in microseconds.
virtual ~QueueRTCPManager()
Sender block information of SR RTCP reports.
Canonical end-point identifier.
int32 unprotect(uint8 *pkt, size_t len, CryptoContextCtrl *cc)
uint32 getSessionBandwidth() const
void srtcpEncrypt(uint8 *rtp, size_t len, uint64 index, uint32 ssrc)
Perform SRTP encryption.
virtual SDESItemType scheduleSDESItem()
Choose which should be the type of the next SDES item sent.
void setState(SyncSource &source, SyncSource::State ns)
bool checkSSRCInRTCPPkt(SyncSourceLink &sourceLink, bool is_new, InetAddress &na, tpport_t tp)
Appy collision and loop detection and correction algorithm when receiving RTCP packets.
microtimeout_t end2EndDelay
unsigned char padding
Padding bit.
bool timerReconsideration()
SyncSourceLink * getNext()
Get the link object for the next RTP source.
void endQueueRTCPManager()
void reverseReconsideration()
Apply reverse reconsideration adjustment to timing parameters when receiving BYE packets and not wait...
uint32 getLength() const
Get the packet length specified in its header, in octets and in host order.
microtimeout_t timeval2microtimeout(const timeval &t)
Convert a time interval, expressed as a timeval value into a microseconds counter.
uint32 getExtendedMaxSeqNum() const
std::list< TransportAddress * > destList
timeval rtcpCheckInterval
CryptoContextCtrl * getInQueueCryptoContextCtrl(uint32 ssrc)
Get an input queue CryptoContext identified by SSRC.
bool getGoodbye()
Mark this source as having sent a BYE control packet.
virtual void onNewSyncSource(const SyncSource &)
Virtual called when a new synchronization source has joined the session.
void setSenderInfo(unsigned char *si)
uint8 getMinValidPacketSequence() const
Get the minimun number of consecutive packets that must be received from a source before accepting it...
static const microtimeout_t defaultEnd2EndDelay
maximum end to end delay: unlimited
uint32 dlsr
delay since last sender report.
Fixed RTCP packet header.
virtual void onGotSR(SyncSource &source, SendReport &SR, uint8 blocks)
Plug-in for processing (acquire information carried in) an incoming RTCP Sender Report.
void removeInQueueCryptoContextCtrl(CryptoContextCtrl *cc)
Remove input queue CryptoContext.
tpport_t controlTransportPort
timeval getInitialTime() const
void lockDestinationList() const
Declaration of ccRTP internal stuff.
virtual void onGotAPP(SyncSource &, RTCPCompoundHandler::APPPacket &, size_t)
Plug-in for handling of APP (application specific) RTCP packets.
virtual void onGotRR(SyncSource &source, RecvReport &RR, uint8 blocks)
Plug-in for processing (acquire information carried in) an incoming RTCP Receiver Report...
uint8 packReportBlocks(RRBlock *blocks, uint16 &len, uint16 &available)
uint16 lostLSW
cumulative lost two LSB.
void setInQueueCryptoContextCtrl(CryptoContextCtrl *cc)
Set input queue CryptoContext.
virtual void onGotGoodbye(const SyncSource &, const std::string &)
A plugin point for goodbye message.
Synchronization Source internal handler within the incoming packets queue.
size_t sendControlToDestinations(unsigned char *buffer, size_t len)
void getOnlyBye()
To be executed when whe are leaving the session.
uint32 getSendRTCPPacketCount() const
Get the total number of RTCP packets sent until now.
SyncSource * getSource()
Get the synchronization source object this link objet holds information for.
static const double RECONSIDERATION_COMPENSATION
void setSDESItem(Participant *part, SDESItemType type, const char *const value, size_t len)
Set item value from a string without null termination (as it is transported in RTCP packets)...
Struct for BYE (leaving session) RTCP packets.
uint8 lostMSB
cumulative lost MSB of 3 octets.
uint8 len
item len in octets.
uint8 type
type of RTCP packet.
uint32 getInitialTimestamp()
uint32 ssrc
SSRC identifer from sender.
uint32 NTPMSW
NTP timestamp higher octets.
A class of objects representing remote participants (RTP applications) in a multimedia session...
uint32 getTimestamp() const
Struct for the sender info block in a SR (sender report) RTCP packet.
Struct for SR (sender report) RTCP packets.
CryptoContextCtrl * getOutQueueCryptoContextCtrl(uint32 ssrc)
Get an output queue CryptoContext identified by SSRC.
uint8 length
[optional] length of reason.
QueueRTCPManager(uint32 size=RTPDataQueue::defaultMembersHashSize, RTPApplication &app=defaultApplication())
void setNetworkAddress(SyncSource &source, InetAddress addr)
timeval lastRTCPPacketTime
virtual uint16 transportHeaderSize()
For certain control calculations in RTCP, the size of the underlying network and transport protocols ...
microtimeout_t rtcpMinInterval
RRBlock blocks[1]
receiver report blocks.
uint8 type
item identifier.
SenderInfo sinfo
actual sender info.
void computeStats()
Compute cumulative packet lost and fraction of packets lost during the last reporting interval...
void expireSSRCs()
Purge sources that do not seem active any more.
void setSDESItem(Participant *part, SDESItemType item, const std::string &val)
SDESItem item
SDES item from sender.
Struct for a chunk of items in a SDES RTCP packet.
void removeOutQueueCryptoContextCtrl(CryptoContextCtrl *cc)
Remove output queue CryptoContext.
Participant * getParticipant() const
Get the participant this synchronization source is asociated to.
void setParticipant(SyncSource &source, Participant &p)
RRBlock blocks[1]
possibly several receiver info blocks.
Struct representing general RTCP packet headers as they are sent through the network.
bool BYESource(uint32 ssrc)
Mark the source identified by ssrc as having sent a BYE packet.
Generic RTCP control queues.
void controlReceptionService()
Process incoming RTCP packets pending in the control reception socket.
SDESItemType nextScheduledSDESItem
virtual void setControlPeer(const InetAddress &host, tpport_t port)
uint32 timevalIntervalTo65536(timeval &t)
Convert a time interval, expressed as a timeval, into a 32-bit time interval expressed in units of 1/...
#define BYE_BUFFER_LENGTH
const RTPApplication & getApplication()
timeval getLastRTCPSRTime() const
uint32 getSsrc() const
Get the SSRC of this SRTP Cryptograhic context.
const InetAddress & getNetworkAddress() const
void takeInControlPacket()
For picking up incoming RTCP packets if they are waiting.
SyncSourceLink * getSourceLink() const
tpport_t getControlTransportPort() const
received, but source validity not yet guaranteed.
struct QueueRTCPManager::@0 reconsInfo
bool checkReplay(uint32 newSeqNumber)
Check for packet replay.
void srtcpAuthenticate(uint8 *rtp, size_t len, uint32 roc, uint8 *tag)
Compute the authentication tag.
char data[1]
item content.
Personal NAME of the user.
SyncSourceLink * getSourceBySSRC(uint32 ssrc, bool &created)
Get the description of a source by its ssrc identifier.
uint32 getLocalSSRCNetwork() const
static const SDESItemType lastSchedulable
uint32 RTPTimestamp
RTP timestamp.
virtual uint16 networkHeaderSize()
For certain control calculations in RTCP, the size of the underlying network and transport protocols ...
InetAddress networkAddress
tpport_t getControlTransportPort() const
raw structure of the source and every receiver report in an SR or RR RTCP packet. ...
const InetAddress & getNetworkAddress() const
unsigned char * rtcpRecvBuffer
int32 getMkiLength() const
Get the length of the MKI in bytes.
size_t dispatchControlPacket()
Posting of RTCP messages.
uint32 ssrc
source identifier.
uint32 getSSRC() const
Get the SSRC identifier specified in the packet header, in host order.
static const uint16 TIMEOUT_MULTIPLIER
void setMembersCount(uint32 n)
uint32 getLocalSSRC() const
void setPRIVPrefix(Participant *part, const char *const value, size_t len)
Set PRIV item previx value from a string without null termination (as it is transported in RTCP packe...
uint16 length
number of 32-bit words in the packet (minus one).
Struct for an item description of a SDES packet.
CryptoContextCtrl * newCryptoContextForSSRC(uint32 ssrc)
Derive a new Crypto Context for use with a new SSRC.
uint32 getRTPTimestamp() const
uint8 getFractionLost() const
virtual bool end2EndDelayed(IncomingRTPPktLink &p)
Virtual reimplemented from RTPDataQueue.
uint8 fractionLost
packet fraction lost.
timeval NTP2Timeval(uint32 msw, uint32 lsw)
Convert a NTP timestamp, expressed as two 32-bit long words, into a timeval value.
microtimeout_t leavingDelay
SyncSourceLink * getFirst()
std::list< CryptoContextCtrl * > inCryptoContexts
void controlTransmissionService()
Build and send RTCP packets following timing rules (including the "timer reconsideration" algorithm)...
uint32 getCurrentRTPClockRate() const
Get the clock rate in RTP clock units (for instance, 8000 units per second for PCMU, or 90000 units per second for MP2T).
bool onGotSDES(SyncSource &source, RTCPPacket &pkt)
virtual void onGotRRSRExtension(unsigned char *, size_t)
Plug-in for processing of SR/RR RTCP packet profile-specific extensions (third part of SR reports or ...
uint32 ssrc
source identifier.
void addConflict(const InetAddress &na, tpport_t dtp, tpport_t ctp)
void packSDES(uint16 &len)
Builds an SDES RTCP packet.
const std::string & getSDESItem(SDESItemType item) const
SyncSourceLink * getLink(const SyncSource &source) const
Incoming RTP data packets control structure within the incoming packet queue class.
union RTCPCompoundHandler::RTCPPacket::@6 info
Union for SR, RR, SDES, BYE and APP.
unsigned char version
Version, currently 2.
RTCPFixedHeader fh
Fixed RTCP header.
bool isSingleDestination() const
Get whether there is only a destination in the list.
SyncSourcesIterator end()
uint32 packetCount
cumulative packet counter.
const Participant * getParticipant(const std::string &cname) const
void updateConflict(ConflictingTransportAddress &ca)
void setOutQueueCryptoContextCtrl(CryptoContextCtrl *cc)
Set ouput queue CryptoContext.
void setPrevMembersNum(uint32 n)
virtual size_t recvControl(unsigned char *buffer, size_t len, InetHostAddress &na, tpport_t &tp)=0
uint32 NTPLSW
NTP timestamp lower octets.
virtual timeval computeRTCPInterval()
Computes the interval for sending RTCP compound packets, based on the average size of RTCP packets se...
uint32 lastSendPacketCount
__EXPORT timeval microtimeout2Timeval(microtimeout_t to)
Convert a time interval, expressed as a microtimeout_t (number of microseconds), into a timeval value...
void update(uint32 newSeqNumber)
Update the SRTP packet index.
no packet from this source has been received lately.
A packet queue handler for building different kinds of RTP protocol systems.
ConflictingTransportAddress * searchControlConflict(InetAddress na, tpport_t ctp)
SDESItemType
SDES items that may be carried in a Source DEScription RTCP packet.
bool getHello()
Mark this source as having sent some packet.
uint32 getCumulativePacketLost() const
RTPApplication & queueApplication
size_t dispatchBYE(const std::string &reason)
This method is used to send an RTCP BYE packet.
void unlockDestinationList() const
uint32 ssrc
source identifier.
void setControlTransportPort(SyncSource &source, tpport_t p)