video coding tests: Adding a Normal distribution to simulate packet arrival times
Review URL: http://webrtc-codereview.appspot.com/138003 git-svn-id: http://webrtc.googlecode.com/svn/trunk@483 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
8571af7be6
commit
46171cf546
@ -15,6 +15,19 @@
|
||||
|
||||
using namespace webrtc;
|
||||
|
||||
// Normal Distribution
|
||||
#define PI 3.14159265
|
||||
double
|
||||
NormalDist(double mean, double stdDev)
|
||||
{
|
||||
// Creating a Normal distribution variable from two independent uniform
|
||||
// variables based on the Box-Muller transform
|
||||
double uniform1 = (std::rand() + 1.0) / (RAND_MAX + 1.0);
|
||||
double uniform2 = (std::rand() + 1.0) / (RAND_MAX + 1.0);
|
||||
return (mean + stdDev * sqrt(-2 * log(uniform1)) * cos(2 * PI * uniform2));
|
||||
}
|
||||
|
||||
|
||||
/******************************
|
||||
* VCMEncodeCompleteCallback
|
||||
*****************************/
|
||||
@ -199,6 +212,7 @@ RTPSendCompleteCallback::RTPSendCompleteCallback(RtpRtcp* rtp,
|
||||
_lossPct(0),
|
||||
_burstLength(0),
|
||||
_networkDelayMs(0),
|
||||
_jitterVar(0),
|
||||
_prevLossState(0),
|
||||
_totalSentLength(0),
|
||||
_rtpPackets(),
|
||||
@ -307,8 +321,13 @@ RTPSendCompleteCallback::SendPacket(int channel, const void *data, int len)
|
||||
rtpPacket* newPacket = new rtpPacket();
|
||||
memcpy(newPacket->data, data, len);
|
||||
newPacket->length = len;
|
||||
// Simulate receive time
|
||||
newPacket->receiveTime = now + _networkDelayMs;
|
||||
// Simulate receive time = network delay + packet jitter
|
||||
// simulated as a Normal distribution random variable with
|
||||
// mean = networkDelay and variance = jitterVar
|
||||
WebRtc_Word32
|
||||
simulatedDelay = (WebRtc_Word32)NormalDist(_networkDelayMs,
|
||||
sqrt(_jitterVar));
|
||||
newPacket->receiveTime = now + simulatedDelay;
|
||||
_rtpPackets.PushBack(newPacket);
|
||||
}
|
||||
|
||||
|
@ -208,6 +208,9 @@ public:
|
||||
// Set network delay in the network
|
||||
void SetNetworkDelay(WebRtc_UWord32 networkDelayMs)
|
||||
{_networkDelayMs = networkDelayMs;};
|
||||
// Set Packet jitter delay
|
||||
void SetJitterVar(WebRtc_UWord32 jitterVar)
|
||||
{_jitterVar = jitterVar;};
|
||||
// Return send count
|
||||
int SendCount() {return _sendCount; }
|
||||
// Return accumulated length in bytes of transmitted packets
|
||||
@ -221,6 +224,7 @@ private:
|
||||
double _lossPct;
|
||||
double _burstLength;
|
||||
WebRtc_UWord32 _networkDelayMs;
|
||||
double _jitterVar;
|
||||
bool _prevLossState;
|
||||
WebRtc_UWord32 _totalSentLength;
|
||||
webrtc::ListWrapper _rtpPackets;
|
||||
|
Loading…
x
Reference in New Issue
Block a user