- comment jitter calculation
This commit is contained in:
parent
0607bd1c47
commit
bb48e1a777
|
|
@ -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) { }
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -340,6 +340,10 @@ protected:
|
||||||
|
|
||||||
/** 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);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue