blob: a17038ad8455a0492b253bc37dc01900bf88dc94 [file] [log] [blame]
niklase@google.com470e71d2011-07-07 08:21:25 +00001/*
tina.legrand@webrtc.org50d5ca52012-06-18 13:35:52 +00002 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
niklase@google.com470e71d2011-07-07 08:21:25 +00003 *
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 06:47:31 +020011#ifndef MODULES_AUDIO_CODING_TEST_TESTALLCODECS_H_
12#define MODULES_AUDIO_CODING_TEST_TESTALLCODECS_H_
niklase@google.com470e71d2011-07-07 08:21:25 +000013
kwiberg37478382016-02-14 20:40:57 -080014#include <memory>
15
Henrik Lundin84f75692023-02-01 12:07:10 +000016#include "modules/audio_coding/acm2/acm_receiver.h"
Fredrik Solenberg657b2962018-12-05 10:30:25 +010017#include "modules/audio_coding/include/audio_coding_module.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020018#include "modules/audio_coding/test/PCMFile.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000019
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +000020namespace webrtc {
21
tina.legrand@webrtc.org50d5ca52012-06-18 13:35:52 +000022class TestPack : public AudioPacketizationCallback {
23 public:
24 TestPack();
25 ~TestPack();
niklase@google.com470e71d2011-07-07 08:21:25 +000026
Henrik Lundin84f75692023-02-01 12:07:10 +000027 void RegisterReceiverACM(acm2::AcmReceiver* acm_receiver);
niklase@google.com470e71d2011-07-07 08:21:25 +000028
Niels Möller87e2d782019-03-07 10:18:23 +010029 int32_t SendData(AudioFrameType frame_type,
kjellander@webrtc.org14665ff2015-03-04 12:58:35 +000030 uint8_t payload_type,
31 uint32_t timestamp,
32 const uint8_t* payload_data,
Minyue Liff0e4db2020-01-23 13:45:50 +010033 size_t payload_size,
34 int64_t absolute_capture_timestamp_ms) override;
tina.legrand@webrtc.org50d5ca52012-06-18 13:35:52 +000035
pkasting@chromium.org4591fbd2014-11-20 22:28:14 +000036 size_t payload_size();
tina.legrand@webrtc.org50d5ca52012-06-18 13:35:52 +000037 uint32_t timestamp_diff();
38 void reset_payload_size();
39
40 private:
Henrik Lundin84f75692023-02-01 12:07:10 +000041 acm2::AcmReceiver* receiver_acm_;
tina.legrand@webrtc.org50d5ca52012-06-18 13:35:52 +000042 uint16_t sequence_number_;
43 uint8_t payload_data_[60 * 32 * 2 * 2];
44 uint32_t timestamp_diff_;
45 uint32_t last_in_timestamp_;
46 uint64_t total_bytes_;
pkasting@chromium.org4591fbd2014-11-20 22:28:14 +000047 size_t payload_size_;
niklase@google.com470e71d2011-07-07 08:21:25 +000048};
49
Karl Wiberg3ff52ff2018-10-01 12:31:22 +020050class TestAllCodecs {
tina.legrand@webrtc.org50d5ca52012-06-18 13:35:52 +000051 public:
Fredrik Solenberg657b2962018-12-05 10:30:25 +010052 TestAllCodecs();
tina.legrand@webrtc.org50d5ca52012-06-18 13:35:52 +000053 ~TestAllCodecs();
niklase@google.com470e71d2011-07-07 08:21:25 +000054
Karl Wiberg3ff52ff2018-10-01 12:31:22 +020055 void Perform();
niklase@google.com470e71d2011-07-07 08:21:25 +000056
tina.legrand@webrtc.org50d5ca52012-06-18 13:35:52 +000057 private:
58 // The default value of '-1' indicates that the registration is based only on
59 // codec name, and a sampling frequency matching is not required.
60 // This is useful for codecs which support several sampling frequency.
61 // Note! Only mono mode is tested in this test.
Henrik Lundin84f75692023-02-01 12:07:10 +000062 void RegisterSendCodec(char* codec_name,
Yves Gerey665174f2018-06-19 15:03:05 +020063 int32_t sampling_freq_hz,
64 int rate,
65 int packet_size,
66 size_t extra_byte);
niklase@google.com470e71d2011-07-07 08:21:25 +000067
tina.legrand@webrtc.org50d5ca52012-06-18 13:35:52 +000068 void Run(TestPack* channel);
69 void OpenOutFile(int test_number);
niklase@google.com470e71d2011-07-07 08:21:25 +000070
kwiberg37478382016-02-14 20:40:57 -080071 std::unique_ptr<AudioCodingModule> acm_a_;
Henrik Lundin84f75692023-02-01 12:07:10 +000072 std::unique_ptr<acm2::AcmReceiver> acm_b_;
tina.legrand@webrtc.org50d5ca52012-06-18 13:35:52 +000073 TestPack* channel_a_to_b_;
74 PCMFile infile_a_;
75 PCMFile outfile_b_;
76 int test_count_;
henrike@webrtc.org6ac22e62014-08-11 21:06:30 +000077 int packet_size_samples_;
pkasting@chromium.org4591fbd2014-11-20 22:28:14 +000078 size_t packet_size_bytes_;
niklase@google.com470e71d2011-07-07 08:21:25 +000079};
80
tina.legrand@webrtc.org50d5ca52012-06-18 13:35:52 +000081} // namespace webrtc
niklase@google.com470e71d2011-07-07 08:21:25 +000082
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020083#endif // MODULES_AUDIO_CODING_TEST_TESTALLCODECS_H_