- comment jitter calculation
This commit is contained in:
parent
0607bd1c47
commit
bb48e1a777
|
|
@ -49,6 +49,7 @@
|
|||
#include "rtptimeutilities.h"
|
||||
#include "rtcpcompoundpacketbuilder.h"
|
||||
#include "rtpmemoryobject.h"
|
||||
#include "rtpsourcedata.h"
|
||||
#include <list>
|
||||
|
||||
#ifdef RTP_SUPPORT_THREAD
|
||||
|
|
@ -476,11 +477,7 @@ protected:
|
|||
const uint8_t *cname,size_t cnamelength) { }
|
||||
|
||||
/** Is called when a new entry \c srcdat is added to the source table. */
|
||||
virtual void OnNewSource(RTPSourceData *srcdat)
|
||||
{
|
||||
// Sync timestamp unit
|
||||
srcdat->SetTimestampUnit(timestampunit);
|
||||
}
|
||||
virtual void OnNewSource(RTPSourceData *srcdat) { }
|
||||
|
||||
/** Is called when the entry \c srcdat is about to be deleted from the source table. */
|
||||
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). */
|
||||
virtual void OnSendRTCPCompoundPacket(RTCPCompoundPacket *pack) { }
|
||||
|
||||
virtual void OnSenderReport(RTPSourceData* srcdat) {}
|
||||
virtual void OnReceiverReport(RTPSourceData* srcdat) {}
|
||||
|
||||
#ifdef RTP_SUPPORT_THREAD
|
||||
/** Is called when error \c errcode was detected in the poll thread. */
|
||||
virtual void OnPollThreadError(int errcode) { }
|
||||
|
|
|
|||
|
|
@ -110,5 +110,15 @@ void RTPSessionSources::OnNoteTimeout(RTPSourceData *srcdat)
|
|||
rtpsession.OnNoteTimeout(srcdat);
|
||||
}
|
||||
|
||||
void RTPSessionSources::OnSenderReport(RTPSourceData *srcdat)
|
||||
{
|
||||
rtpsession.OnSenderReport(srcdat);
|
||||
}
|
||||
|
||||
void RTPSessionSources::OnReceiverReport(RTPSourceData *srcdat)
|
||||
{
|
||||
rtpsession.OnReceiverReport(srcdat);
|
||||
}
|
||||
|
||||
} // end namespace
|
||||
|
||||
|
|
|
|||
|
|
@ -74,6 +74,8 @@ private:
|
|||
void OnUnknownPacketFormat(RTCPPacket *rtcppack,const RTPTime &receivetime,
|
||||
const RTPAddress *senderaddress);
|
||||
void OnNoteTimeout(RTPSourceData *srcdat);
|
||||
void OnSenderReport(RTPSourceData* srcdat);
|
||||
void OnReceiverReport(RTPSourceData* srcdat);
|
||||
|
||||
RTPSession &rtpsession;
|
||||
bool owncollision;
|
||||
|
|
|
|||
|
|
@ -43,6 +43,9 @@
|
|||
#include <string>
|
||||
#endif // RTPDEBUG
|
||||
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
|
||||
#include "rtpdebug.h"
|
||||
|
||||
#define ACCEPTPACKETCODE \
|
||||
|
|
@ -197,16 +200,19 @@ void RTPSourceStats::ProcessPacket(RTPPacket *pack,const RTPTime &receivetime,do
|
|||
djitter += diff;
|
||||
jitter = (uint32_t)djitter;
|
||||
#else
|
||||
// Current packet receive time
|
||||
RTPTime curtime = receivetime;
|
||||
double diffts1,diffts2,diff;
|
||||
|
||||
// Packet timestamp in units
|
||||
uint32_t curts = pack->GetTimestamp();
|
||||
|
||||
curtime -= prevpacktime;
|
||||
diffts1 = curtime.GetDouble() / tsunit;
|
||||
curtime -= prevpacktime; // Difference in RTPTime (seconds)
|
||||
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
|
||||
diffts2 = (double)unsigneddiff;
|
||||
|
|
@ -235,13 +241,17 @@ void RTPSourceStats::ProcessPacket(RTPPacket *pack,const RTPTime &receivetime,do
|
|||
else
|
||||
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)
|
||||
diff = -diff;
|
||||
diff -= djitter;
|
||||
diff /= 16.0;
|
||||
djitter += diff;
|
||||
jitter = (uint32_t)djitter;
|
||||
diff = -diff; // Get abs() if needed
|
||||
|
||||
djitter = djitter + (diff - djitter) / 16.0;
|
||||
// std::cout << std::setprecision(3) << djitter << std::endl;
|
||||
// diff -= djitter;
|
||||
// diff /= 16.0;
|
||||
// djitter += diff;
|
||||
|
||||
jitter = (uint32_t)djitter; // This is timestamp units !
|
||||
#endif
|
||||
}
|
||||
else
|
||||
|
|
|
|||
|
|
@ -659,6 +659,7 @@ int RTPSources::ProcessRTCPSenderInfo(uint32_t ssrc,const RTPNTPTime &ntptime,ui
|
|||
// Call the callback
|
||||
if (created)
|
||||
OnNewSource(srcdat);
|
||||
OnSenderReport(srcdat);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -683,6 +684,8 @@ int RTPSources::ProcessRTCPReportBlock(uint32_t ssrc,uint8_t fractionlost,int32_
|
|||
if (created)
|
||||
OnNewSource(srcdat);
|
||||
|
||||
OnReceiverReport(srcdat);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -340,6 +340,10 @@ protected:
|
|||
|
||||
/** Is called when the SDES NOTE item for source \c srcdat has been timed out. */
|
||||
virtual void OnNoteTimeout(RTPSourceData * /*srcdat*/) { }
|
||||
|
||||
virtual void OnSenderReport(RTPSourceData* /*srcdat*/) {}
|
||||
virtual void OnReceiverReport(RTPSourceData* /*srcdat*/) {}
|
||||
|
||||
private:
|
||||
void ClearSourceList();
|
||||
int ObtainSourceDataInstance(uint32_t ssrc,RTPInternalSourceData **srcdat,bool *created);
|
||||
|
|
|
|||
Loading…
Reference in New Issue