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;
|
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
|
* VCMEncodeCompleteCallback
|
||||||
*****************************/
|
*****************************/
|
||||||
@ -199,6 +212,7 @@ RTPSendCompleteCallback::RTPSendCompleteCallback(RtpRtcp* rtp,
|
|||||||
_lossPct(0),
|
_lossPct(0),
|
||||||
_burstLength(0),
|
_burstLength(0),
|
||||||
_networkDelayMs(0),
|
_networkDelayMs(0),
|
||||||
|
_jitterVar(0),
|
||||||
_prevLossState(0),
|
_prevLossState(0),
|
||||||
_totalSentLength(0),
|
_totalSentLength(0),
|
||||||
_rtpPackets(),
|
_rtpPackets(),
|
||||||
@ -307,8 +321,13 @@ RTPSendCompleteCallback::SendPacket(int channel, const void *data, int len)
|
|||||||
rtpPacket* newPacket = new rtpPacket();
|
rtpPacket* newPacket = new rtpPacket();
|
||||||
memcpy(newPacket->data, data, len);
|
memcpy(newPacket->data, data, len);
|
||||||
newPacket->length = len;
|
newPacket->length = len;
|
||||||
// Simulate receive time
|
// Simulate receive time = network delay + packet jitter
|
||||||
newPacket->receiveTime = now + _networkDelayMs;
|
// 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);
|
_rtpPackets.PushBack(newPacket);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -208,6 +208,9 @@ public:
|
|||||||
// Set network delay in the network
|
// Set network delay in the network
|
||||||
void SetNetworkDelay(WebRtc_UWord32 networkDelayMs)
|
void SetNetworkDelay(WebRtc_UWord32 networkDelayMs)
|
||||||
{_networkDelayMs = networkDelayMs;};
|
{_networkDelayMs = networkDelayMs;};
|
||||||
|
// Set Packet jitter delay
|
||||||
|
void SetJitterVar(WebRtc_UWord32 jitterVar)
|
||||||
|
{_jitterVar = jitterVar;};
|
||||||
// Return send count
|
// Return send count
|
||||||
int SendCount() {return _sendCount; }
|
int SendCount() {return _sendCount; }
|
||||||
// Return accumulated length in bytes of transmitted packets
|
// Return accumulated length in bytes of transmitted packets
|
||||||
@ -221,6 +224,7 @@ private:
|
|||||||
double _lossPct;
|
double _lossPct;
|
||||||
double _burstLength;
|
double _burstLength;
|
||||||
WebRtc_UWord32 _networkDelayMs;
|
WebRtc_UWord32 _networkDelayMs;
|
||||||
|
double _jitterVar;
|
||||||
bool _prevLossState;
|
bool _prevLossState;
|
||||||
WebRtc_UWord32 _totalSentLength;
|
WebRtc_UWord32 _totalSentLength;
|
||||||
webrtc::ListWrapper _rtpPackets;
|
webrtc::ListWrapper _rtpPackets;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user