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
This commit is contained in:
henrik.lundin@webrtc.org 2014-09-19 07:14:31 +00:00
parent 6e5c78422d
commit 5ca6008236
2 changed files with 43 additions and 3 deletions

View File

@ -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

View File

@ -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_