From 164c4f71ba8edc33cbf572fea005ee1df1d6c195 Mon Sep 17 00:00:00 2001 From: "henrik.lundin@webrtc.org" Date: Thu, 5 Sep 2013 12:16:38 +0000 Subject: [PATCH] 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 --- .../modules/audio_coding/neteq4/tools/rtp_generator.cc | 9 ++++++++- webrtc/modules/audio_coding/neteq4/tools/rtp_generator.h | 6 +++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/webrtc/modules/audio_coding/neteq4/tools/rtp_generator.cc b/webrtc/modules/audio_coding/neteq4/tools/rtp_generator.cc index 0ea28fb80..0b0e1ada4 100644 --- a/webrtc/modules/audio_coding/neteq4/tools/rtp_generator.cc +++ b/webrtc/modules/audio_coding/neteq4/tools/rtp_generator.cc @@ -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 diff --git a/webrtc/modules/audio_coding/neteq4/tools/rtp_generator.h b/webrtc/modules/audio_coding/neteq4/tools/rtp_generator.h index a2f885f31..ece7ef298 100644 --- a/webrtc/modules/audio_coding/neteq4/tools/rtp_generator.h +++ b/webrtc/modules/audio_coding/neteq4/tools/rtp_generator.h @@ -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); };