aboutsummaryrefslogtreecommitdiff
path: root/webrtc/modules/audio_coding/neteq
diff options
context:
space:
mode:
authorhenrik.lundin@webrtc.org <henrik.lundin@webrtc.org>2014-09-19 07:14:31 +0000
committerhenrik.lundin@webrtc.org <henrik.lundin@webrtc.org>2014-09-19 07:14:31 +0000
commit5ca6008236e3000e8d0e911357e4796dec675758 (patch)
tree68e13dc34938a056fc145bc0520111476793ee9e /webrtc/modules/audio_coding/neteq
parent6e5c78422d3b594f9c8bb4cce3e31da454d69711 (diff)
downloadwebrtc-5ca6008236e3000e8d0e911357e4796dec675758.tar.gz
Creating a test helper class TimestampJumpRtpGenerator
This class provides a way to test with an RTP sequence that make an arbitrary jump in the timestamp series. R=tina.legrand@webrtc.org Review URL: https://webrtc-codereview.appspot.com/23679004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@7236 4adac7df-926f-26a2-2b94-8c16560cd09d
Diffstat (limited to 'webrtc/modules/audio_coding/neteq')
-rw-r--r--webrtc/modules/audio_coding/neteq/tools/rtp_generator.cc14
-rw-r--r--webrtc/modules/audio_coding/neteq/tools/rtp_generator.h32
2 files changed, 43 insertions, 3 deletions
diff --git a/webrtc/modules/audio_coding/neteq/tools/rtp_generator.cc b/webrtc/modules/audio_coding/neteq/tools/rtp_generator.cc
index 17ac209f1d..db9988d904 100644
--- a/webrtc/modules/audio_coding/neteq/tools/rtp_generator.cc
+++ b/webrtc/modules/audio_coding/neteq/tools/rtp_generator.cc
@@ -44,5 +44,19 @@ void RtpGenerator::set_drift_factor(double factor) {
}
}
+uint32_t TimestampJumpRtpGenerator::GetRtpHeader(uint8_t payload_type,
+ size_t payload_length_samples,
+ WebRtcRTPHeader* rtp_header) {
+ uint32_t ret = RtpGenerator::GetRtpHeader(
+ payload_type, payload_length_samples, rtp_header);
+ if (timestamp_ - static_cast<uint32_t>(payload_length_samples) <=
+ jump_from_timestamp_ &&
+ timestamp_ > jump_from_timestamp_) {
+ // We just moved across the |jump_from_timestamp_| timestamp. Do the jump.
+ timestamp_ = jump_to_timestamp_;
+ }
+ return ret;
+}
+
} // namespace test
} // namespace webrtc
diff --git a/webrtc/modules/audio_coding/neteq/tools/rtp_generator.h b/webrtc/modules/audio_coding/neteq/tools/rtp_generator.h
index d3824c8d22..2280436147 100644
--- a/webrtc/modules/audio_coding/neteq/tools/rtp_generator.h
+++ b/webrtc/modules/audio_coding/neteq/tools/rtp_generator.h
@@ -34,24 +34,50 @@ class RtpGenerator {
drift_factor_(0.0) {
}
+ virtual ~RtpGenerator() {}
+
// Writes the next RTP header to |rtp_header|, which will be of type
// |payload_type|. Returns the send time for this packet (in ms). The value of
// |payload_length_samples| determines the send time for the next packet.
- uint32_t GetRtpHeader(uint8_t payload_type, size_t payload_length_samples,
- WebRtcRTPHeader* rtp_header);
+ virtual uint32_t GetRtpHeader(uint8_t payload_type,
+ size_t payload_length_samples,
+ WebRtcRTPHeader* rtp_header);
void set_drift_factor(double factor);
- private:
+ protected:
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_;
+
+ private:
DISALLOW_COPY_AND_ASSIGN(RtpGenerator);
};
+class TimestampJumpRtpGenerator : public RtpGenerator {
+ public:
+ TimestampJumpRtpGenerator(int samples_per_ms,
+ uint16_t start_seq_number,
+ uint32_t start_timestamp,
+ uint32_t jump_from_timestamp,
+ uint32_t jump_to_timestamp)
+ : RtpGenerator(samples_per_ms, start_seq_number, start_timestamp),
+ jump_from_timestamp_(jump_from_timestamp),
+ jump_to_timestamp_(jump_to_timestamp) {}
+
+ uint32_t GetRtpHeader(uint8_t payload_type,
+ size_t payload_length_samples,
+ WebRtcRTPHeader* rtp_header) OVERRIDE;
+
+ private:
+ uint32_t jump_from_timestamp_;
+ uint32_t jump_to_timestamp_;
+ DISALLOW_COPY_AND_ASSIGN(TimestampJumpRtpGenerator);
+};
+
} // namespace test
} // namespace webrtc
#endif // WEBRTC_MODULES_AUDIO_CODING_NETEQ_TOOLS_RTP_GENERATOR_H_