1 /* 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 3 * 4 * Use of this source code is governed by a BSD-style license 5 * that can be found in the LICENSE file in the root of the source 6 * tree. An additional intellectual property rights grant can be found 7 * in the file PATENTS. All contributing project authors may 8 * be found in the AUTHORS file in the root of the source tree. 9 */ 10 11 #ifndef MODULES_AUDIO_CODING_NETEQ_TOOLS_RTP_GENERATOR_H_ 12 #define MODULES_AUDIO_CODING_NETEQ_TOOLS_RTP_GENERATOR_H_ 13 14 #include "api/rtp_headers.h" 15 #include "rtc_base/constructor_magic.h" 16 17 namespace webrtc { 18 namespace test { 19 20 // Class for generating RTP headers. 21 class RtpGenerator { 22 public: 23 RtpGenerator(int samples_per_ms, 24 uint16_t start_seq_number = 0, 25 uint32_t start_timestamp = 0, 26 uint32_t start_send_time_ms = 0, 27 uint32_t ssrc = 0x12345678) seq_number_(start_seq_number)28 : seq_number_(start_seq_number), 29 timestamp_(start_timestamp), 30 next_send_time_ms_(start_send_time_ms), 31 ssrc_(ssrc), 32 samples_per_ms_(samples_per_ms), 33 drift_factor_(0.0) {} 34 ~RtpGenerator()35 virtual ~RtpGenerator() {} 36 37 // Writes the next RTP header to |rtp_header|, which will be of type 38 // |payload_type|. Returns the send time for this packet (in ms). The value of 39 // |payload_length_samples| determines the send time for the next packet. 40 virtual uint32_t GetRtpHeader(uint8_t payload_type, 41 size_t payload_length_samples, 42 RTPHeader* rtp_header); 43 44 void set_drift_factor(double factor); 45 46 protected: 47 uint16_t seq_number_; 48 uint32_t timestamp_; 49 uint32_t next_send_time_ms_; 50 const uint32_t ssrc_; 51 const int samples_per_ms_; 52 double drift_factor_; 53 54 private: 55 RTC_DISALLOW_COPY_AND_ASSIGN(RtpGenerator); 56 }; 57 58 class TimestampJumpRtpGenerator : public RtpGenerator { 59 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)60 TimestampJumpRtpGenerator(int samples_per_ms, 61 uint16_t start_seq_number, 62 uint32_t start_timestamp, 63 uint32_t jump_from_timestamp, 64 uint32_t jump_to_timestamp) 65 : RtpGenerator(samples_per_ms, start_seq_number, start_timestamp), 66 jump_from_timestamp_(jump_from_timestamp), 67 jump_to_timestamp_(jump_to_timestamp) {} 68 69 uint32_t GetRtpHeader(uint8_t payload_type, 70 size_t payload_length_samples, 71 RTPHeader* rtp_header) override; 72 73 private: 74 uint32_t jump_from_timestamp_; 75 uint32_t jump_to_timestamp_; 76 RTC_DISALLOW_COPY_AND_ASSIGN(TimestampJumpRtpGenerator); 77 }; 78 79 } // namespace test 80 } // namespace webrtc 81 #endif // MODULES_AUDIO_CODING_NETEQ_TOOLS_RTP_GENERATOR_H_ 82