1 /* 2 * Copyright (c) 2014 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 WEBRTC_MODULES_AUDIO_CODING_NETEQ_TOOLS_CONSTANT_PCM_PACKET_SOURCE_H_ 12 #define WEBRTC_MODULES_AUDIO_CODING_NETEQ_TOOLS_CONSTANT_PCM_PACKET_SOURCE_H_ 13 14 #include <stdio.h> 15 #include <string> 16 17 #include "webrtc/base/constructormagic.h" 18 #include "webrtc/common_types.h" 19 #include "webrtc/modules/audio_coding/neteq/tools/packet_source.h" 20 21 namespace webrtc { 22 namespace test { 23 24 // This class implements a packet source that delivers PCM16b encoded packets 25 // with a constant sample value. The payload length, constant sample value, 26 // sample rate, and payload type are all set in the constructor. 27 class ConstantPcmPacketSource : public PacketSource { 28 public: 29 ConstantPcmPacketSource(size_t payload_len_samples, 30 int16_t sample_value, 31 int sample_rate_hz, 32 int payload_type); 33 34 // Returns a pointer to the next packet. Will never return NULL. That is, 35 // the source is infinite. 36 Packet* NextPacket() override; 37 38 private: 39 void WriteHeader(uint8_t* packet_memory); 40 41 const size_t kHeaderLenBytes = 12; 42 const size_t payload_len_samples_; 43 const size_t packet_len_bytes_; 44 uint8_t encoded_sample_[2]; 45 const int samples_per_ms_; 46 double next_arrival_time_ms_; 47 const int payload_type_; 48 uint16_t seq_number_; 49 uint32_t timestamp_; 50 const uint32_t payload_ssrc_; 51 52 RTC_DISALLOW_COPY_AND_ASSIGN(ConstantPcmPacketSource); 53 }; 54 55 } // namespace test 56 } // namespace webrtc 57 #endif // WEBRTC_MODULES_AUDIO_CODING_NETEQ_TOOLS_CONSTANT_PCM_PACKET_SOURCE_H_ 58