- comment jitter calculation

This commit is contained in:
Dmytro Bogovych 2023-04-12 12:19:53 +03:00
parent 0607bd1c47
commit bb48e1a777
6 changed files with 276 additions and 246 deletions

View File

@ -49,6 +49,7 @@
#include "rtptimeutilities.h" #include "rtptimeutilities.h"
#include "rtcpcompoundpacketbuilder.h" #include "rtcpcompoundpacketbuilder.h"
#include "rtpmemoryobject.h" #include "rtpmemoryobject.h"
#include "rtpsourcedata.h"
#include <list> #include <list>
#ifdef RTP_SUPPORT_THREAD #ifdef RTP_SUPPORT_THREAD
@ -476,11 +477,7 @@ protected:
const uint8_t *cname,size_t cnamelength) { } const uint8_t *cname,size_t cnamelength) { }
/** Is called when a new entry \c srcdat is added to the source table. */ /** Is called when a new entry \c srcdat is added to the source table. */
virtual void OnNewSource(RTPSourceData *srcdat) virtual void OnNewSource(RTPSourceData *srcdat) { }
{
// Sync timestamp unit
srcdat->SetTimestampUnit(timestampunit);
}
/** Is called when the entry \c srcdat is about to be deleted from the source table. */ /** Is called when the entry \c srcdat is about to be deleted from the source table. */
virtual void OnRemoveSource(RTPSourceData *srcdat) { } virtual void OnRemoveSource(RTPSourceData *srcdat) { }
@ -513,6 +510,10 @@ protected:
/** Is called when an RTCP compound packet has just been sent (useful to inspect outgoing RTCP data). */ /** Is called when an RTCP compound packet has just been sent (useful to inspect outgoing RTCP data). */
virtual void OnSendRTCPCompoundPacket(RTCPCompoundPacket *pack) { } virtual void OnSendRTCPCompoundPacket(RTCPCompoundPacket *pack) { }
virtual void OnSenderReport(RTPSourceData* srcdat) {}
virtual void OnReceiverReport(RTPSourceData* srcdat) {}
#ifdef RTP_SUPPORT_THREAD #ifdef RTP_SUPPORT_THREAD
/** Is called when error \c errcode was detected in the poll thread. */ /** Is called when error \c errcode was detected in the poll thread. */
virtual void OnPollThreadError(int errcode) { } virtual void OnPollThreadError(int errcode) { }

View File

@ -110,5 +110,15 @@ void RTPSessionSources::OnNoteTimeout(RTPSourceData *srcdat)
rtpsession.OnNoteTimeout(srcdat); rtpsession.OnNoteTimeout(srcdat);
} }
void RTPSessionSources::OnSenderReport(RTPSourceData *srcdat)
{
rtpsession.OnSenderReport(srcdat);
}
void RTPSessionSources::OnReceiverReport(RTPSourceData *srcdat)
{
rtpsession.OnReceiverReport(srcdat);
}
} // end namespace } // end namespace

View File

@ -74,6 +74,8 @@ private:
void OnUnknownPacketFormat(RTCPPacket *rtcppack,const RTPTime &receivetime, void OnUnknownPacketFormat(RTCPPacket *rtcppack,const RTPTime &receivetime,
const RTPAddress *senderaddress); const RTPAddress *senderaddress);
void OnNoteTimeout(RTPSourceData *srcdat); void OnNoteTimeout(RTPSourceData *srcdat);
void OnSenderReport(RTPSourceData* srcdat);
void OnReceiverReport(RTPSourceData* srcdat);
RTPSession &rtpsession; RTPSession &rtpsession;
bool owncollision; bool owncollision;

View File

@ -43,6 +43,9 @@
#include <string> #include <string>
#endif // RTPDEBUG #endif // RTPDEBUG
#include <iostream>
#include <iomanip>
#include "rtpdebug.h" #include "rtpdebug.h"
#define ACCEPTPACKETCODE \ #define ACCEPTPACKETCODE \
@ -197,16 +200,19 @@ void RTPSourceStats::ProcessPacket(RTPPacket *pack,const RTPTime &receivetime,do
djitter += diff; djitter += diff;
jitter = (uint32_t)djitter; jitter = (uint32_t)djitter;
#else #else
// Current packet receive time
RTPTime curtime = receivetime; RTPTime curtime = receivetime;
double diffts1,diffts2,diff; double diffts1,diffts2,diff;
// Packet timestamp in units
uint32_t curts = pack->GetTimestamp(); uint32_t curts = pack->GetTimestamp();
curtime -= prevpacktime; curtime -= prevpacktime; // Difference in RTPTime (seconds)
diffts1 = curtime.GetDouble() / tsunit; diffts1 = curtime.GetDouble() / tsunit; // Current time in units
if (curts > prevtimestamp) if (curts > prevtimestamp) // If packets are ordered ok
{ {
uint32_t unsigneddiff = curts - prevtimestamp; uint32_t unsigneddiff = curts - prevtimestamp; // Difference in units
if (unsigneddiff < 0x10000000) // okay, curts realy is larger than prevtimestamp if (unsigneddiff < 0x10000000) // okay, curts realy is larger than prevtimestamp
diffts2 = (double)unsigneddiff; diffts2 = (double)unsigneddiff;
@ -235,13 +241,17 @@ void RTPSourceStats::ProcessPacket(RTPPacket *pack,const RTPTime &receivetime,do
else else
diffts2 = 0; diffts2 = 0;
diff = diffts1 - diffts2; diff = diffts1 - diffts2; // diffts1 is delta between packets in receive time; difftw2 is delta in timestamp. Both are expressed in units.
if (diff < 0) if (diff < 0)
diff = -diff; diff = -diff; // Get abs() if needed
diff -= djitter;
diff /= 16.0; djitter = djitter + (diff - djitter) / 16.0;
djitter += diff; // std::cout << std::setprecision(3) << djitter << std::endl;
jitter = (uint32_t)djitter; // diff -= djitter;
// diff /= 16.0;
// djitter += diff;
jitter = (uint32_t)djitter; // This is timestamp units !
#endif #endif
} }
else else

View File

@ -659,6 +659,7 @@ int RTPSources::ProcessRTCPSenderInfo(uint32_t ssrc,const RTPNTPTime &ntptime,ui
// Call the callback // Call the callback
if (created) if (created)
OnNewSource(srcdat); OnNewSource(srcdat);
OnSenderReport(srcdat);
return 0; return 0;
} }
@ -683,6 +684,8 @@ int RTPSources::ProcessRTCPReportBlock(uint32_t ssrc,uint8_t fractionlost,int32_
if (created) if (created)
OnNewSource(srcdat); OnNewSource(srcdat);
OnReceiverReport(srcdat);
return 0; return 0;
} }

View File

@ -52,7 +52,7 @@ namespace jrtplib
class JRTPLIB_IMPORTEXPORT RTPSources_GetHashIndex class JRTPLIB_IMPORTEXPORT RTPSources_GetHashIndex
{ {
public: public:
static int GetIndex(const uint32_t &ssrc) { return ssrc%RTPSOURCES_HASHSIZE; } static int GetIndex(const uint32_t &ssrc) { return ssrc%RTPSOURCES_HASHSIZE; }
}; };
class RTPNTPTime; class RTPNTPTime;
@ -74,289 +74,293 @@ class RTPSourceData;
class JRTPLIB_IMPORTEXPORT RTPSources : public RTPMemoryObject class JRTPLIB_IMPORTEXPORT RTPSources : public RTPMemoryObject
{ {
public: public:
/** Type of probation to use for new sources. */ /** Type of probation to use for new sources. */
enum ProbationType enum ProbationType
{ {
NoProbation, /**< Don't use the probation algorithm; accept RTP packets immediately. */ NoProbation, /**< Don't use the probation algorithm; accept RTP packets immediately. */
ProbationDiscard, /**< Discard incoming RTP packets originating from a source that's on probation. */ ProbationDiscard, /**< Discard incoming RTP packets originating from a source that's on probation. */
ProbationStore /**< Store incoming RTP packet from a source that's on probation for later retrieval. */ ProbationStore /**< Store incoming RTP packet from a source that's on probation for later retrieval. */
}; };
/** In the constructor you can select the probation type you'd like to use and also a memory manager. */ /** In the constructor you can select the probation type you'd like to use and also a memory manager. */
RTPSources(ProbationType = ProbationStore,RTPMemoryManager *mgr = 0); RTPSources(ProbationType = ProbationStore,RTPMemoryManager *mgr = 0);
virtual ~RTPSources(); virtual ~RTPSources();
/** Clears the source table. */ /** Clears the source table. */
void Clear(); void Clear();
#ifdef RTP_SUPPORT_PROBATION #ifdef RTP_SUPPORT_PROBATION
/** Changes the current probation type. */ /** Changes the current probation type. */
void SetProbationType(ProbationType probtype) { probationtype = probtype; } void SetProbationType(ProbationType probtype) { probationtype = probtype; }
#endif // RTP_SUPPORT_PROBATION #endif // RTP_SUPPORT_PROBATION
/** Creates an entry for our own SSRC identifier. */ /** Creates an entry for our own SSRC identifier. */
int CreateOwnSSRC(uint32_t ssrc); int CreateOwnSSRC(uint32_t ssrc);
/** Deletes the entry for our own SSRC identifier. */ /** Deletes the entry for our own SSRC identifier. */
int DeleteOwnSSRC(); int DeleteOwnSSRC();
/** This function should be called if our own session has sent an RTP packet. /** This function should be called if our own session has sent an RTP packet.
* This function should be called if our own session has sent an RTP packet. * This function should be called if our own session has sent an RTP packet.
* For our own SSRC entry, the sender flag is updated based upon outgoing packets instead of incoming packets. * For our own SSRC entry, the sender flag is updated based upon outgoing packets instead of incoming packets.
*/ */
void SentRTPPacket(); void SentRTPPacket();
/** Processes a raw packet \c rawpack. /** Processes a raw packet \c rawpack.
* Processes a raw packet \c rawpack. The instance \c trans will be used to check if this * Processes a raw packet \c rawpack. The instance \c trans will be used to check if this
* packet is one of our own packets. The flag \c acceptownpackets indicates whether own packets should be * packet is one of our own packets. The flag \c acceptownpackets indicates whether own packets should be
* accepted or ignored. * accepted or ignored.
*/ */
int ProcessRawPacket(RTPRawPacket *rawpack,RTPTransmitter *trans,bool acceptownpackets); int ProcessRawPacket(RTPRawPacket *rawpack,RTPTransmitter *trans,bool acceptownpackets);
/** Processes a raw packet \c rawpack. /** Processes a raw packet \c rawpack.
* Processes a raw packet \c rawpack. Every transmitter in the array \c trans of length \c numtrans * Processes a raw packet \c rawpack. Every transmitter in the array \c trans of length \c numtrans
* is used to check if the packet is from our own session. The flag \c acceptownpackets indicates * is used to check if the packet is from our own session. The flag \c acceptownpackets indicates
* whether own packets should be accepted or ignored. * whether own packets should be accepted or ignored.
*/ */
int ProcessRawPacket(RTPRawPacket *rawpack,RTPTransmitter *trans[],int numtrans,bool acceptownpackets); int ProcessRawPacket(RTPRawPacket *rawpack,RTPTransmitter *trans[],int numtrans,bool acceptownpackets);
/** Processes an RTPPacket instance \c rtppack which was received at time \c receivetime and /** Processes an RTPPacket instance \c rtppack which was received at time \c receivetime and
* which originated from \c senderaddres. * which originated from \c senderaddres.
* Processes an RTPPacket instance \c rtppack which was received at time \c receivetime and * Processes an RTPPacket instance \c rtppack which was received at time \c receivetime and
* which originated from \c senderaddres. The \c senderaddress parameter must be NULL if * which originated from \c senderaddres. The \c senderaddress parameter must be NULL if
* the packet was sent by the local participant. The flag \c stored indicates whether the packet * the packet was sent by the local participant. The flag \c stored indicates whether the packet
* was stored in the table or not. If so, the \c rtppack instance may not be deleted. * was stored in the table or not. If so, the \c rtppack instance may not be deleted.
*/ */
int ProcessRTPPacket(RTPPacket *rtppack,const RTPTime &receivetime,const RTPAddress *senderaddress,bool *stored); int ProcessRTPPacket(RTPPacket *rtppack,const RTPTime &receivetime,const RTPAddress *senderaddress,bool *stored);
/** Processes the RTCP compound packet \c rtcpcomppack which was received at time \c receivetime from \c senderaddress. /** Processes the RTCP compound packet \c rtcpcomppack which was received at time \c receivetime from \c senderaddress.
* Processes the RTCP compound packet \c rtcpcomppack which was received at time \c receivetime from \c senderaddress. * Processes the RTCP compound packet \c rtcpcomppack which was received at time \c receivetime from \c senderaddress.
* The \c senderaddress parameter must be NULL if the packet was sent by the local participant. * The \c senderaddress parameter must be NULL if the packet was sent by the local participant.
*/ */
int ProcessRTCPCompoundPacket(RTCPCompoundPacket *rtcpcomppack,const RTPTime &receivetime, int ProcessRTCPCompoundPacket(RTCPCompoundPacket *rtcpcomppack,const RTPTime &receivetime,
const RTPAddress *senderaddress); const RTPAddress *senderaddress);
/** Process the sender information of SSRC \c ssrc into the source table. /** Process the sender information of SSRC \c ssrc into the source table.
* Process the sender information of SSRC \c ssrc into the source table. The information was received * Process the sender information of SSRC \c ssrc into the source table. The information was received
* at time \c receivetime from address \c senderaddress. The \c senderaddress} parameter must be NULL * at time \c receivetime from address \c senderaddress. The \c senderaddress} parameter must be NULL
* if the packet was sent by the local participant. * if the packet was sent by the local participant.
*/ */
int ProcessRTCPSenderInfo(uint32_t ssrc,const RTPNTPTime &ntptime,uint32_t rtptime, int ProcessRTCPSenderInfo(uint32_t ssrc,const RTPNTPTime &ntptime,uint32_t rtptime,
uint32_t packetcount,uint32_t octetcount,const RTPTime &receivetime, uint32_t packetcount,uint32_t octetcount,const RTPTime &receivetime,
const RTPAddress *senderaddress); const RTPAddress *senderaddress);
/** Processes the report block information which was sent by participant \c ssrc into the source table. /** Processes the report block information which was sent by participant \c ssrc into the source table.
* Processes the report block information which was sent by participant \c ssrc into the source table. * Processes the report block information which was sent by participant \c ssrc into the source table.
* The information was received at time \c receivetime from address \c senderaddress The \c senderaddress * The information was received at time \c receivetime from address \c senderaddress The \c senderaddress
* parameter must be NULL if the packet was sent by the local participant. * parameter must be NULL if the packet was sent by the local participant.
*/ */
int ProcessRTCPReportBlock(uint32_t ssrc,uint8_t fractionlost,int32_t lostpackets, int ProcessRTCPReportBlock(uint32_t ssrc,uint8_t fractionlost,int32_t lostpackets,
uint32_t exthighseqnr,uint32_t jitter,uint32_t lsr, uint32_t exthighseqnr,uint32_t jitter,uint32_t lsr,
uint32_t dlsr,const RTPTime &receivetime,const RTPAddress *senderaddress); uint32_t dlsr,const RTPTime &receivetime,const RTPAddress *senderaddress);
/** Processes the non-private SDES item from source \c ssrc into the source table. /** Processes the non-private SDES item from source \c ssrc into the source table.
* Processes the non-private SDES item from source \c ssrc into the source table. The information was * Processes the non-private SDES item from source \c ssrc into the source table. The information was
* received at time \c receivetime from address \c senderaddress. The \c senderaddress parameter must * received at time \c receivetime from address \c senderaddress. The \c senderaddress parameter must
* be NULL if the packet was sent by the local participant. * be NULL if the packet was sent by the local participant.
*/ */
int ProcessSDESNormalItem(uint32_t ssrc,RTCPSDESPacket::ItemType t,size_t itemlength, int ProcessSDESNormalItem(uint32_t ssrc,RTCPSDESPacket::ItemType t,size_t itemlength,
const void *itemdata,const RTPTime &receivetime,const RTPAddress *senderaddress); const void *itemdata,const RTPTime &receivetime,const RTPAddress *senderaddress);
#ifdef RTP_SUPPORT_SDESPRIV #ifdef RTP_SUPPORT_SDESPRIV
/** Processes the SDES private item from source \c ssrc into the source table. /** Processes the SDES private item from source \c ssrc into the source table.
* Processes the SDES private item from source \c ssrc into the source table. The information was * Processes the SDES private item from source \c ssrc into the source table. The information was
* received at time \c receivetime from address \c senderaddress. The \c senderaddress * received at time \c receivetime from address \c senderaddress. The \c senderaddress
* parameter must be NULL if the packet was sent by the local participant. * parameter must be NULL if the packet was sent by the local participant.
*/ */
int ProcessSDESPrivateItem(uint32_t ssrc,size_t prefixlen,const void *prefixdata, int ProcessSDESPrivateItem(uint32_t ssrc,size_t prefixlen,const void *prefixdata,
size_t valuelen,const void *valuedata,const RTPTime &receivetime, size_t valuelen,const void *valuedata,const RTPTime &receivetime,
const RTPAddress *senderaddress); const RTPAddress *senderaddress);
#endif //RTP_SUPPORT_SDESPRIV #endif //RTP_SUPPORT_SDESPRIV
/** Processes the BYE message for SSRC \c ssrc. /** Processes the BYE message for SSRC \c ssrc.
* Processes the BYE message for SSRC \c ssrc. The information was received at time \c receivetime from * Processes the BYE message for SSRC \c ssrc. The information was received at time \c receivetime from
* address \c senderaddress. The \c senderaddress parameter must be NULL if the packet was sent by the * address \c senderaddress. The \c senderaddress parameter must be NULL if the packet was sent by the
* local participant. * local participant.
*/ */
int ProcessBYE(uint32_t ssrc,size_t reasonlength,const void *reasondata,const RTPTime &receivetime, int ProcessBYE(uint32_t ssrc,size_t reasonlength,const void *reasondata,const RTPTime &receivetime,
const RTPAddress *senderaddress); const RTPAddress *senderaddress);
/** If we heard from source \c ssrc, but no actual data was added to the source table (for example, if /** If we heard from source \c ssrc, but no actual data was added to the source table (for example, if
* no report block was meant for us), this function can e used to indicate that something was received from * no report block was meant for us), this function can e used to indicate that something was received from
* this source. * this source.
* If we heard from source \c ssrc, but no actual data was added to the source table (for example, if * If we heard from source \c ssrc, but no actual data was added to the source table (for example, if
* no report block was meant for us), this function can e used to indicate that something was received from * no report block was meant for us), this function can e used to indicate that something was received from
* this source. This will prevent a premature timeout for this participant. The message was received at time * this source. This will prevent a premature timeout for this participant. The message was received at time
* \c receivetime from address \c senderaddress. The \c senderaddress parameter must be NULL if the * \c receivetime from address \c senderaddress. The \c senderaddress parameter must be NULL if the
* packet was sent by the local participant. * packet was sent by the local participant.
*/ */
int UpdateReceiveTime(uint32_t ssrc,const RTPTime &receivetime,const RTPAddress *senderaddress); int UpdateReceiveTime(uint32_t ssrc,const RTPTime &receivetime,const RTPAddress *senderaddress);
/** Starts the iteration over the participants by going to the first member in the table. /** Starts the iteration over the participants by going to the first member in the table.
* Starts the iteration over the participants by going to the first member in the table. * Starts the iteration over the participants by going to the first member in the table.
* If a member was found, the function returns \c true, otherwise it returns \c false. * If a member was found, the function returns \c true, otherwise it returns \c false.
*/ */
bool GotoFirstSource(); bool GotoFirstSource();
/** Sets the current source to be the next source in the table. /** Sets the current source to be the next source in the table.
* Sets the current source to be the next source in the table. If we're already at the last source, * Sets the current source to be the next source in the table. If we're already at the last source,
* the function returns \c false, otherwise it returns \c true. * the function returns \c false, otherwise it returns \c true.
*/ */
bool GotoNextSource(); bool GotoNextSource();
/** Sets the current source to be the previous source in the table. /** Sets the current source to be the previous source in the table.
* Sets the current source to be the previous source in the table. If we're at the first source, * Sets the current source to be the previous source in the table. If we're at the first source,
* the function returns \c false, otherwise it returns \c true. * the function returns \c false, otherwise it returns \c true.
*/ */
bool GotoPreviousSource(); bool GotoPreviousSource();
/** Sets the current source to be the first source in the table which has RTPPacket instances /** Sets the current source to be the first source in the table which has RTPPacket instances
* that we haven't extracted yet. * that we haven't extracted yet.
* Sets the current source to be the first source in the table which has RTPPacket instances * Sets the current source to be the first source in the table which has RTPPacket instances
* that we haven't extracted yet. If no such member was found, the function returns \c false, * that we haven't extracted yet. If no such member was found, the function returns \c false,
* otherwise it returns \c true. * otherwise it returns \c true.
*/ */
bool GotoFirstSourceWithData(); bool GotoFirstSourceWithData();
/** Sets the current source to be the next source in the table which has RTPPacket instances that /** Sets the current source to be the next source in the table which has RTPPacket instances that
* we haven't extracted yet. * we haven't extracted yet.
* Sets the current source to be the next source in the table which has RTPPacket instances that * Sets the current source to be the next source in the table which has RTPPacket instances that
* we haven't extracted yet. If no such member was found, the function returns \c false, * we haven't extracted yet. If no such member was found, the function returns \c false,
* otherwise it returns \c true. * otherwise it returns \c true.
*/ */
bool GotoNextSourceWithData(); bool GotoNextSourceWithData();
/** Sets the current source to be the previous source in the table which has RTPPacket instances /** Sets the current source to be the previous source in the table which has RTPPacket instances
* that we haven't extracted yet. * that we haven't extracted yet.
* Sets the current source to be the previous source in the table which has RTPPacket instances * Sets the current source to be the previous source in the table which has RTPPacket instances
* that we haven't extracted yet. If no such member was found, the function returns \c false, * that we haven't extracted yet. If no such member was found, the function returns \c false,
* otherwise it returns \c true. * otherwise it returns \c true.
*/ */
bool GotoPreviousSourceWithData(); bool GotoPreviousSourceWithData();
/** Returns the RTPSourceData instance for the currently selected participant. */ /** Returns the RTPSourceData instance for the currently selected participant. */
RTPSourceData *GetCurrentSourceInfo(); RTPSourceData *GetCurrentSourceInfo();
/** Returns the RTPSourceData instance for the participant identified by \c ssrc, or /** Returns the RTPSourceData instance for the participant identified by \c ssrc, or
* NULL if no such entry exists. * NULL if no such entry exists.
*/ */
RTPSourceData *GetSourceInfo(uint32_t ssrc); RTPSourceData *GetSourceInfo(uint32_t ssrc);
/** Extracts the next packet from the received packets queue of the current participant. */ /** Extracts the next packet from the received packets queue of the current participant. */
RTPPacket *GetNextPacket(); RTPPacket *GetNextPacket();
/** Returns \c true if an entry for participant \c ssrc exists and \c false otherwise. */ /** Returns \c true if an entry for participant \c ssrc exists and \c false otherwise. */
bool GotEntry(uint32_t ssrc); bool GotEntry(uint32_t ssrc);
/** If present, it returns the RTPSourceData instance of the entry which was created by CreateOwnSSRC. */ /** If present, it returns the RTPSourceData instance of the entry which was created by CreateOwnSSRC. */
RTPSourceData *GetOwnSourceInfo() { return (RTPSourceData *)owndata; } RTPSourceData *GetOwnSourceInfo() { return (RTPSourceData *)owndata; }
/** Assuming that the current time is \c curtime, time out the members from whom we haven't heard /** Assuming that the current time is \c curtime, time out the members from whom we haven't heard
* during the previous time interval \c timeoutdelay. * during the previous time interval \c timeoutdelay.
*/ */
void Timeout(const RTPTime &curtime,const RTPTime &timeoutdelay); void Timeout(const RTPTime &curtime,const RTPTime &timeoutdelay);
/** Assuming that the current time is \c curtime, remove the sender flag for senders from whom we haven't /** Assuming that the current time is \c curtime, remove the sender flag for senders from whom we haven't
* received any RTP packets during the previous time interval \c timeoutdelay. * received any RTP packets during the previous time interval \c timeoutdelay.
*/ */
void SenderTimeout(const RTPTime &curtime,const RTPTime &timeoutdelay); void SenderTimeout(const RTPTime &curtime,const RTPTime &timeoutdelay);
/** Assuming that the current time is \c curtime, remove the members who sent a BYE packet more than /** Assuming that the current time is \c curtime, remove the members who sent a BYE packet more than
* the time interval \c timeoutdelay ago. * the time interval \c timeoutdelay ago.
*/ */
void BYETimeout(const RTPTime &curtime,const RTPTime &timeoutdelay); void BYETimeout(const RTPTime &curtime,const RTPTime &timeoutdelay);
/** Assuming that the current time is \c curtime, clear the SDES NOTE items which haven't been updated /** Assuming that the current time is \c curtime, clear the SDES NOTE items which haven't been updated
* during the previous time interval \c timeoutdelay. * during the previous time interval \c timeoutdelay.
*/ */
void NoteTimeout(const RTPTime &curtime,const RTPTime &timeoutdelay); void NoteTimeout(const RTPTime &curtime,const RTPTime &timeoutdelay);
/** Combines the functions SenderTimeout, BYETimeout, Timeout and NoteTimeout. /** Combines the functions SenderTimeout, BYETimeout, Timeout and NoteTimeout.
* Combines the functions SenderTimeout, BYETimeout, Timeout and NoteTimeout. This is more efficient * Combines the functions SenderTimeout, BYETimeout, Timeout and NoteTimeout. This is more efficient
* than calling all four functions since only one iteration is needed in this function. * than calling all four functions since only one iteration is needed in this function.
*/ */
void MultipleTimeouts(const RTPTime &curtime,const RTPTime &sendertimeout, void MultipleTimeouts(const RTPTime &curtime,const RTPTime &sendertimeout,
const RTPTime &byetimeout,const RTPTime &generaltimeout, const RTPTime &byetimeout,const RTPTime &generaltimeout,
const RTPTime &notetimeout); const RTPTime &notetimeout);
/** Returns the number of participants which are marked as a sender. */ /** Returns the number of participants which are marked as a sender. */
int GetSenderCount() const { return sendercount; } int GetSenderCount() const { return sendercount; }
/** Returns the total number of entries in the source table. */ /** Returns the total number of entries in the source table. */
int GetTotalCount() const { return totalcount; } int GetTotalCount() const { return totalcount; }
/** Returns the number of members which have been validated and which haven't sent a BYE packet yet. */ /** Returns the number of members which have been validated and which haven't sent a BYE packet yet. */
int GetActiveMemberCount() const { return activecount; } int GetActiveMemberCount() const { return activecount; }
#ifdef RTPDEBUG #ifdef RTPDEBUG
void Dump(); void Dump();
void SafeCountTotal(); void SafeCountTotal();
void SafeCountSenders(); void SafeCountSenders();
void SafeCountActive(); void SafeCountActive();
#endif // RTPDEBUG #endif // RTPDEBUG
protected: protected:
/** Is called when an RTP packet is about to be processed. */ /** Is called when an RTP packet is about to be processed. */
virtual void OnRTPPacket(RTPPacket * /*pack*/,const RTPTime &/*receivetime*/, const RTPAddress * /*senderaddress*/) { } virtual void OnRTPPacket(RTPPacket * /*pack*/,const RTPTime &/*receivetime*/, const RTPAddress * /*senderaddress*/) { }
/** Is called when an RTCP compound packet is about to be processed. */ /** Is called when an RTCP compound packet is about to be processed. */
virtual void OnRTCPCompoundPacket(RTCPCompoundPacket * /*pack*/,const RTPTime & /*receivetime*/, virtual void OnRTCPCompoundPacket(RTCPCompoundPacket * /*pack*/,const RTPTime & /*receivetime*/,
const RTPAddress * /*senderaddress*/) { } const RTPAddress * /*senderaddress*/) { }
/** Is called when an SSRC collision was detected. /** Is called when an SSRC collision was detected.
* Is called when an SSRC collision was detected. The instance \c srcdat is the one present in * Is called when an SSRC collision was detected. The instance \c srcdat is the one present in
* the table, the address \c senderaddress is the one that collided with one of the addresses * the table, the address \c senderaddress is the one that collided with one of the addresses
* and \c isrtp indicates against which address of \c srcdat the check failed. * and \c isrtp indicates against which address of \c srcdat the check failed.
*/ */
virtual void OnSSRCCollision(RTPSourceData * /*srcdat*/,const RTPAddress * /*senderaddress*/,bool /*isrtp*/) { } virtual void OnSSRCCollision(RTPSourceData * /*srcdat*/,const RTPAddress * /*senderaddress*/,bool /*isrtp*/) { }
/** Is called when another CNAME was received than the one already present for source \c srcdat. */ /** Is called when another CNAME was received than the one already present for source \c srcdat. */
virtual void OnCNAMECollision(RTPSourceData * /*srcdat*/,const RTPAddress * /*senderaddress*/, virtual void OnCNAMECollision(RTPSourceData * /*srcdat*/,const RTPAddress * /*senderaddress*/,
const uint8_t * /*cname*/,size_t /*cnamelength*/) { } const uint8_t * /*cname*/,size_t /*cnamelength*/) { }
/** Is called when a new entry \c srcdat is added to the source table. */ /** Is called when a new entry \c srcdat is added to the source table. */
virtual void OnNewSource(RTPSourceData * /*srcdat*/) { } virtual void OnNewSource(RTPSourceData * /*srcdat*/) { }
/** Is called when the entry \c srcdat is about to be deleted from the source table. */ /** Is called when the entry \c srcdat is about to be deleted from the source table. */
virtual void OnRemoveSource(RTPSourceData * /*srcdat*/) { } virtual void OnRemoveSource(RTPSourceData * /*srcdat*/) { }
/** Is called when participant \c srcdat is timed out. */ /** Is called when participant \c srcdat is timed out. */
virtual void OnTimeout(RTPSourceData * /*srcdat*/) { } virtual void OnTimeout(RTPSourceData * /*srcdat*/) { }
/** Is called when participant \c srcdat is timed after having sent a BYE packet. */ /** Is called when participant \c srcdat is timed after having sent a BYE packet. */
virtual void OnBYETimeout(RTPSourceData * /*srcdat*/) { } virtual void OnBYETimeout(RTPSourceData * /*srcdat*/) { }
/** Is called when a BYE packet has been processed for source \c srcdat. */ /** Is called when a BYE packet has been processed for source \c srcdat. */
virtual void OnBYEPacket(RTPSourceData * /*srcdat*/) { } virtual void OnBYEPacket(RTPSourceData * /*srcdat*/) { }
/** Is called when an RTCP APP packet \c apppacket has been received at time \c receivetime /** Is called when an RTCP APP packet \c apppacket has been received at time \c receivetime
* from address \c senderaddress. * from address \c senderaddress.
*/ */
virtual void OnAPPPacket(RTCPAPPPacket * /*apppacket*/,const RTPTime &/*receivetime*/, virtual void OnAPPPacket(RTCPAPPPacket * /*apppacket*/,const RTPTime &/*receivetime*/,
const RTPAddress * /*senderaddress*/) { } const RTPAddress * /*senderaddress*/) { }
/** Is called when an unknown RTCP packet type was detected. */ /** Is called when an unknown RTCP packet type was detected. */
virtual void OnUnknownPacketType(RTCPPacket * /*rtcppack*/,const RTPTime &/*receivetime*/, virtual void OnUnknownPacketType(RTCPPacket * /*rtcppack*/,const RTPTime &/*receivetime*/,
const RTPAddress * /*senderaddress*/) { } const RTPAddress * /*senderaddress*/) { }
/** Is called when an unknown packet format for a known packet type was detected. */ /** Is called when an unknown packet format for a known packet type was detected. */
virtual void OnUnknownPacketFormat(RTCPPacket * /*rtcppack*/,const RTPTime &/*receivetime*/, virtual void OnUnknownPacketFormat(RTCPPacket * /*rtcppack*/,const RTPTime &/*receivetime*/,
const RTPAddress * /*senderaddress*/) { } const RTPAddress * /*senderaddress*/) { }
/** Is called when the SDES NOTE item for source \c srcdat has been timed out. */ /** Is called when the SDES NOTE item for source \c srcdat has been timed out. */
virtual void OnNoteTimeout(RTPSourceData * /*srcdat*/) { } virtual void OnNoteTimeout(RTPSourceData * /*srcdat*/) { }
virtual void OnSenderReport(RTPSourceData* /*srcdat*/) {}
virtual void OnReceiverReport(RTPSourceData* /*srcdat*/) {}
private: private:
void ClearSourceList(); void ClearSourceList();
int ObtainSourceDataInstance(uint32_t ssrc,RTPInternalSourceData **srcdat,bool *created); int ObtainSourceDataInstance(uint32_t ssrc,RTPInternalSourceData **srcdat,bool *created);
int GetRTCPSourceData(uint32_t ssrc,const RTPAddress *senderaddress,RTPInternalSourceData **srcdat,bool *newsource); int GetRTCPSourceData(uint32_t ssrc,const RTPAddress *senderaddress,RTPInternalSourceData **srcdat,bool *newsource);
bool CheckCollision(RTPInternalSourceData *srcdat,const RTPAddress *senderaddress,bool isrtp); bool CheckCollision(RTPInternalSourceData *srcdat,const RTPAddress *senderaddress,bool isrtp);
RTPKeyHashTable<const uint32_t,RTPInternalSourceData*,RTPSources_GetHashIndex,RTPSOURCES_HASHSIZE> sourcelist; RTPKeyHashTable<const uint32_t,RTPInternalSourceData*,RTPSources_GetHashIndex,RTPSOURCES_HASHSIZE> sourcelist;
int sendercount; int sendercount;
int totalcount; int totalcount;
int activecount; int activecount;
#ifdef RTP_SUPPORT_PROBATION #ifdef RTP_SUPPORT_PROBATION
ProbationType probationtype; ProbationType probationtype;
#endif // RTP_SUPPORT_PROBATION #endif // RTP_SUPPORT_PROBATION
RTPInternalSourceData *owndata; RTPInternalSourceData *owndata;
}; };
} // end namespace } // end namespace