blob: 0bd24705fd30d49fbb37ef559c5dc0f7b8ef541e [file] [log] [blame]
henrik.lundin@webrtc.org0e6e4d22014-09-23 12:05:341/*
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
Mirko Bonadei92ea95e2017-09-15 04:47:3111#ifndef MODULES_AUDIO_CODING_ACM2_ACM_SEND_TEST_H_
12#define MODULES_AUDIO_CODING_ACM2_ACM_SEND_TEST_H_
henrik.lundin@webrtc.org0e6e4d22014-09-23 12:05:3413
kwiberg16c5a962016-02-15 10:27:2214#include <memory>
henrik.lundin@webrtc.org0e6e4d22014-09-23 12:05:3415#include <vector>
16
Ali Tofigh714e3cb2022-07-20 10:53:0717#include "absl/strings/string_view.h"
Fredrik Solenbergbbf21a32018-04-12 20:44:0918#include "api/audio/audio_frame.h"
Mirko Bonadei92ea95e2017-09-15 04:47:3119#include "modules/audio_coding/include/audio_coding_module.h"
20#include "modules/audio_coding/neteq/tools/packet_source.h"
Mirko Bonadei92ea95e2017-09-15 04:47:3121#include "system_wrappers/include/clock.h"
henrik.lundin@webrtc.org0e6e4d22014-09-23 12:05:3422
23namespace webrtc {
kwiberg12cfc9b2015-09-08 12:57:5324class AudioEncoder;
henrik.lundin@webrtc.org0e6e4d22014-09-23 12:05:3425
26namespace test {
27class InputAudioFile;
28class Packet;
29
30class AcmSendTestOldApi : public AudioPacketizationCallback,
31 public PacketSource {
32 public:
33 AcmSendTestOldApi(InputAudioFile* audio_source,
34 int source_rate_hz,
35 int test_duration_ms);
kwiberg65fc8b92016-08-29 17:05:2436 ~AcmSendTestOldApi() override;
henrik.lundin@webrtc.org0e6e4d22014-09-23 12:05:3437
Byoungchan Lee604fd2f2022-01-21 00:49:3938 AcmSendTestOldApi(const AcmSendTestOldApi&) = delete;
39 AcmSendTestOldApi& operator=(const AcmSendTestOldApi&) = delete;
40
henrik.lundin@webrtc.org0e6e4d22014-09-23 12:05:3441 // Registers the send codec. Returns true on success, false otherwise.
Ali Tofigh714e3cb2022-07-20 10:53:0742 bool RegisterCodec(absl::string_view payload_name,
henrik.lundin@webrtc.org0e6e4d22014-09-23 12:05:3443 int sampling_freq_hz,
44 int channels,
45 int payload_type,
46 int frame_size_samples);
47
Karl Wiberg801500c2018-08-16 13:01:1248 // Registers an external send codec.
49 void RegisterExternalCodec(
50 std::unique_ptr<AudioEncoder> external_speech_encoder);
Karl Wiberg7e0c7d42015-05-18 12:52:2951
henrik.lundin@webrtc.org0e6e4d22014-09-23 12:05:3452 // Inherited from PacketSource.
henrik.lundin46ba49c2016-05-25 05:50:4753 std::unique_ptr<Packet> NextPacket() override;
henrik.lundin@webrtc.org0e6e4d22014-09-23 12:05:3454
55 // Inherited from AudioPacketizationCallback.
Niels Möller87e2d782019-03-07 09:18:2356 int32_t SendData(AudioFrameType frame_type,
kjellander@webrtc.org14665ff2015-03-04 12:58:3557 uint8_t payload_type,
58 uint32_t timestamp,
59 const uint8_t* payload_data,
Minyue Liff0e4db2020-01-23 12:45:5060 size_t payload_len_bytes,
61 int64_t absolute_capture_timestamp_ms) override;
henrik.lundin@webrtc.org0e6e4d22014-09-23 12:05:3462
minyue@webrtc.org7dba7862015-01-20 16:01:5063 AudioCodingModule* acm() { return acm_.get(); }
64
henrik.lundin@webrtc.org0e6e4d22014-09-23 12:05:3465 private:
66 static const int kBlockSizeMs = 10;
67
68 // Creates a Packet object from the last packet produced by ACM (and received
henrik.lundin46ba49c2016-05-25 05:50:4769 // through the SendData method as a callback).
70 std::unique_ptr<Packet> CreatePacket();
henrik.lundin@webrtc.org0e6e4d22014-09-23 12:05:3471
72 SimulatedClock clock_;
kwiberg16c5a962016-02-15 10:27:2273 std::unique_ptr<AudioCodingModule> acm_;
henrik.lundin@webrtc.org0e6e4d22014-09-23 12:05:3474 InputAudioFile* audio_source_;
75 int source_rate_hz_;
Peter Kastingdce40cf2015-08-24 21:52:2376 const size_t input_block_size_samples_;
henrik.lundin@webrtc.org0e6e4d22014-09-23 12:05:3477 AudioFrame input_frame_;
henrik.lundin@webrtc.org0e6e4d22014-09-23 12:05:3478 bool codec_registered_;
79 int test_duration_ms_;
80 // The following member variables are set whenever SendData() is called.
Niels Möller87e2d782019-03-07 09:18:2381 AudioFrameType frame_type_;
henrik.lundin@webrtc.org0e6e4d22014-09-23 12:05:3482 int payload_type_;
83 uint32_t timestamp_;
84 uint16_t sequence_number_;
85 std::vector<uint8_t> last_payload_vec_;
henrik.lundin@webrtc.orgf56c1622015-03-02 12:29:3086 bool data_to_send_;
henrik.lundin@webrtc.org0e6e4d22014-09-23 12:05:3487};
88
89} // namespace test
90} // namespace webrtc
Mirko Bonadei92ea95e2017-09-15 04:47:3191#endif // MODULES_AUDIO_CODING_ACM2_ACM_SEND_TEST_H_