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 MODULES_AUDIO_CODING_NETEQ_TOOLS_CONSTANT_PCM_PACKET_SOURCE_H_
12 #define MODULES_AUDIO_CODING_NETEQ_TOOLS_CONSTANT_PCM_PACKET_SOURCE_H_
13 
14 #include <stdio.h>
15 
16 #include <string>
17 
18 #include "modules/audio_coding/neteq/tools/packet_source.h"
19 #include "rtc_base/constructor_magic.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   std::unique_ptr<Packet> NextPacket() override;
35 
36  private:
37   void WriteHeader(uint8_t* packet_memory);
38 
39   const size_t kHeaderLenBytes = 12;
40   const size_t payload_len_samples_;
41   const size_t packet_len_bytes_;
42   uint8_t encoded_sample_[2];
43   const int samples_per_ms_;
44   double next_arrival_time_ms_;
45   const int payload_type_;
46   uint16_t seq_number_;
47   uint32_t timestamp_;
48   const uint32_t payload_ssrc_;
49 
50   RTC_DISALLOW_COPY_AND_ASSIGN(ConstantPcmPacketSource);
51 };
52 
53 }  // namespace test
54 }  // namespace webrtc
55 #endif  // MODULES_AUDIO_CODING_NETEQ_TOOLS_CONSTANT_PCM_PACKET_SOURCE_H_
56