19a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org/* 29a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 39a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org * 49a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org * Use of this source code is governed by a BSD-style license 59a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org * that can be found in the LICENSE file in the root of the source 69a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org * tree. An additional intellectual property rights grant can be found 79a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org * in the file PATENTS. All contributing project authors may 89a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org * be found in the AUTHORS file in the root of the source tree. 99a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org */ 109a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org 11e5abc854f3dc47de16067c2a41476c39b7626722henrik.lundin@webrtc.org#ifndef WEBRTC_MODULES_AUDIO_CODING_NETEQ_TOOLS_RTP_GENERATOR_H_ 12e5abc854f3dc47de16067c2a41476c39b7626722henrik.lundin@webrtc.org#define WEBRTC_MODULES_AUDIO_CODING_NETEQ_TOOLS_RTP_GENERATOR_H_ 139a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org 14774b3d38a4a0f1a8ec08972a3c543cb5d607ce13henrike@webrtc.org#include "webrtc/base/constructormagic.h" 159a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org#include "webrtc/modules/interface/module_common_types.h" 169a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org#include "webrtc/typedefs.h" 179a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org 189a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.orgnamespace webrtc { 199a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.orgnamespace test { 209a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org 219a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org// Class for generating RTP headers. 229a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.orgclass RtpGenerator { 239a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org public: 249a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org RtpGenerator(int samples_per_ms, 259a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org uint16_t start_seq_number = 0, 269a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org uint32_t start_timestamp = 0, 279a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org uint32_t start_send_time_ms = 0, 289a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org uint32_t ssrc = 0x12345678) 299a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org : seq_number_(start_seq_number), 309a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org timestamp_(start_timestamp), 319a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org next_send_time_ms_(start_send_time_ms), 329a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org ssrc_(ssrc), 330e2cb2989ce31ddd9069045a86ef4a9a781dddd3henrik.lundin@webrtc.org samples_per_ms_(samples_per_ms), 340e2cb2989ce31ddd9069045a86ef4a9a781dddd3henrik.lundin@webrtc.org drift_factor_(0.0) { 359a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org } 369a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org 37d60fc6a759089cdb8edf09d76244d03a52bcbb59henrik.lundin@webrtc.org virtual ~RtpGenerator() {} 38d60fc6a759089cdb8edf09d76244d03a52bcbb59henrik.lundin@webrtc.org 399a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org // Writes the next RTP header to |rtp_header|, which will be of type 409a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org // |payload_type|. Returns the send time for this packet (in ms). The value of 419a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org // |payload_length_samples| determines the send time for the next packet. 42d60fc6a759089cdb8edf09d76244d03a52bcbb59henrik.lundin@webrtc.org virtual uint32_t GetRtpHeader(uint8_t payload_type, 43d60fc6a759089cdb8edf09d76244d03a52bcbb59henrik.lundin@webrtc.org size_t payload_length_samples, 44d60fc6a759089cdb8edf09d76244d03a52bcbb59henrik.lundin@webrtc.org WebRtcRTPHeader* rtp_header); 459a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org 460e2cb2989ce31ddd9069045a86ef4a9a781dddd3henrik.lundin@webrtc.org void set_drift_factor(double factor); 470e2cb2989ce31ddd9069045a86ef4a9a781dddd3henrik.lundin@webrtc.org 48d60fc6a759089cdb8edf09d76244d03a52bcbb59henrik.lundin@webrtc.org protected: 499a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org uint16_t seq_number_; 509a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org uint32_t timestamp_; 519a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org uint32_t next_send_time_ms_; 529a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org const uint32_t ssrc_; 539a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org const int samples_per_ms_; 540e2cb2989ce31ddd9069045a86ef4a9a781dddd3henrik.lundin@webrtc.org double drift_factor_; 55d60fc6a759089cdb8edf09d76244d03a52bcbb59henrik.lundin@webrtc.org 56d60fc6a759089cdb8edf09d76244d03a52bcbb59henrik.lundin@webrtc.org private: 579a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org DISALLOW_COPY_AND_ASSIGN(RtpGenerator); 589a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org}; 599a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org 60d60fc6a759089cdb8edf09d76244d03a52bcbb59henrik.lundin@webrtc.orgclass TimestampJumpRtpGenerator : public RtpGenerator { 61d60fc6a759089cdb8edf09d76244d03a52bcbb59henrik.lundin@webrtc.org public: 62d60fc6a759089cdb8edf09d76244d03a52bcbb59henrik.lundin@webrtc.org TimestampJumpRtpGenerator(int samples_per_ms, 63d60fc6a759089cdb8edf09d76244d03a52bcbb59henrik.lundin@webrtc.org uint16_t start_seq_number, 64d60fc6a759089cdb8edf09d76244d03a52bcbb59henrik.lundin@webrtc.org uint32_t start_timestamp, 65d60fc6a759089cdb8edf09d76244d03a52bcbb59henrik.lundin@webrtc.org uint32_t jump_from_timestamp, 66d60fc6a759089cdb8edf09d76244d03a52bcbb59henrik.lundin@webrtc.org uint32_t jump_to_timestamp) 67d60fc6a759089cdb8edf09d76244d03a52bcbb59henrik.lundin@webrtc.org : RtpGenerator(samples_per_ms, start_seq_number, start_timestamp), 68d60fc6a759089cdb8edf09d76244d03a52bcbb59henrik.lundin@webrtc.org jump_from_timestamp_(jump_from_timestamp), 69d60fc6a759089cdb8edf09d76244d03a52bcbb59henrik.lundin@webrtc.org jump_to_timestamp_(jump_to_timestamp) {} 70d60fc6a759089cdb8edf09d76244d03a52bcbb59henrik.lundin@webrtc.org 71d60fc6a759089cdb8edf09d76244d03a52bcbb59henrik.lundin@webrtc.org uint32_t GetRtpHeader(uint8_t payload_type, 72d60fc6a759089cdb8edf09d76244d03a52bcbb59henrik.lundin@webrtc.org size_t payload_length_samples, 73d60fc6a759089cdb8edf09d76244d03a52bcbb59henrik.lundin@webrtc.org WebRtcRTPHeader* rtp_header) OVERRIDE; 74d60fc6a759089cdb8edf09d76244d03a52bcbb59henrik.lundin@webrtc.org 75d60fc6a759089cdb8edf09d76244d03a52bcbb59henrik.lundin@webrtc.org private: 76d60fc6a759089cdb8edf09d76244d03a52bcbb59henrik.lundin@webrtc.org uint32_t jump_from_timestamp_; 77d60fc6a759089cdb8edf09d76244d03a52bcbb59henrik.lundin@webrtc.org uint32_t jump_to_timestamp_; 78d60fc6a759089cdb8edf09d76244d03a52bcbb59henrik.lundin@webrtc.org DISALLOW_COPY_AND_ASSIGN(TimestampJumpRtpGenerator); 79d60fc6a759089cdb8edf09d76244d03a52bcbb59henrik.lundin@webrtc.org}; 80d60fc6a759089cdb8edf09d76244d03a52bcbb59henrik.lundin@webrtc.org 819a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org} // namespace test 829a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org} // namespace webrtc 83e5abc854f3dc47de16067c2a41476c39b7626722henrik.lundin@webrtc.org#endif // WEBRTC_MODULES_AUDIO_CODING_NETEQ_TOOLS_RTP_GENERATOR_H_ 84