1/* 2 * Copyright (c) 2013 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#include <assert.h> 12 13#include "webrtc/modules/audio_coding/neteq/tools/rtp_generator.h" 14 15namespace webrtc { 16namespace test { 17 18uint32_t RtpGenerator::GetRtpHeader(uint8_t payload_type, 19 size_t payload_length_samples, 20 WebRtcRTPHeader* rtp_header) { 21 assert(rtp_header); 22 if (!rtp_header) { 23 return 0; 24 } 25 rtp_header->header.sequenceNumber = seq_number_++; 26 rtp_header->header.timestamp = timestamp_; 27 timestamp_ += static_cast<uint32_t>(payload_length_samples); 28 rtp_header->header.payloadType = payload_type; 29 rtp_header->header.markerBit = false; 30 rtp_header->header.ssrc = ssrc_; 31 rtp_header->header.numCSRCs = 0; 32 rtp_header->frameType = kAudioFrameSpeech; 33 34 uint32_t this_send_time = next_send_time_ms_; 35 assert(samples_per_ms_ > 0); 36 next_send_time_ms_ += ((1.0 + drift_factor_) * payload_length_samples) / 37 samples_per_ms_; 38 return this_send_time; 39} 40 41void RtpGenerator::set_drift_factor(double factor) { 42 if (factor > -1.0) { 43 drift_factor_ = factor; 44 } 45} 46 47} // namespace test 48} // namespace webrtc 49