Add clockdrift to RtpGenerator

RtpGenerator is a help class for NetEq testing. This change
add the possibility to simulate clockdrift. If no clockdrift is
set, the default is 0 (i.e., no drift).

R=stefan@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/2175005

git-svn-id: http://webrtc.googlecode.com/svn/trunk@4680 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
henrik.lundin@webrtc.org
2013-09-05 12:16:38 +00:00
parent 7e1bf318bf
commit 164c4f71ba
2 changed files with 13 additions and 2 deletions

View File

@@ -33,9 +33,16 @@ uint32_t RtpGenerator::GetRtpHeader(uint8_t payload_type,
uint32_t this_send_time = next_send_time_ms_;
assert(samples_per_ms_ > 0);
next_send_time_ms_ += payload_length_samples / samples_per_ms_;
next_send_time_ms_ += ((1.0 + drift_factor_) * payload_length_samples) /
samples_per_ms_;
return this_send_time;
}
void RtpGenerator::set_drift_factor(double factor) {
if (factor > -1.0) {
drift_factor_ = factor;
}
}
} // namespace test
} // namespace webrtc

View File

@@ -30,7 +30,8 @@ class RtpGenerator {
timestamp_(start_timestamp),
next_send_time_ms_(start_send_time_ms),
ssrc_(ssrc),
samples_per_ms_(samples_per_ms) {
samples_per_ms_(samples_per_ms),
drift_factor_(0.0) {
}
// Writes the next RTP header to |rtp_header|, which will be of type
@@ -39,12 +40,15 @@ class RtpGenerator {
uint32_t GetRtpHeader(uint8_t payload_type, size_t payload_length_samples,
WebRtcRTPHeader* rtp_header);
void set_drift_factor(double factor);
private:
uint16_t seq_number_;
uint32_t timestamp_;
uint32_t next_send_time_ms_;
const uint32_t ssrc_;
const int samples_per_ms_;
double drift_factor_;
DISALLOW_COPY_AND_ASSIGN(RtpGenerator);
};