blob: 3125efeb0b9c4eacac4e3cda8159f1d85df2f614 [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
Fredrik Solenberg056f9732018-12-03 15:22:16 +010016#include "modules/audio_coding/include/audio_coding_module.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020017#include "modules/audio_coding/test/PCMFile.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000018
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +000019namespace webrtc {
20
tina.legrand@webrtc.org50d5ca52012-06-18 13:35:52 +000021class TestPack : public AudioPacketizationCallback {
22 public:
23 TestPack();
24 ~TestPack();
niklase@google.com470e71d2011-07-07 08:21:25 +000025
tina.legrand@webrtc.org50d5ca52012-06-18 13:35:52 +000026 void RegisterReceiverACM(AudioCodingModule* acm);
niklase@google.com470e71d2011-07-07 08:21:25 +000027
kjellander@webrtc.org14665ff2015-03-04 12:58:35 +000028 int32_t SendData(FrameType frame_type,
29 uint8_t payload_type,
30 uint32_t timestamp,
31 const uint8_t* payload_data,
32 size_t payload_size,
33 const RTPFragmentationHeader* fragmentation) override;
tina.legrand@webrtc.org50d5ca52012-06-18 13:35:52 +000034
pkasting@chromium.org4591fbd2014-11-20 22:28:14 +000035 size_t payload_size();
tina.legrand@webrtc.org50d5ca52012-06-18 13:35:52 +000036 uint32_t timestamp_diff();
37 void reset_payload_size();
38
39 private:
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +000040 AudioCodingModule* receiver_acm_;
tina.legrand@webrtc.org50d5ca52012-06-18 13:35:52 +000041 uint16_t sequence_number_;
42 uint8_t payload_data_[60 * 32 * 2 * 2];
43 uint32_t timestamp_diff_;
44 uint32_t last_in_timestamp_;
45 uint64_t total_bytes_;
pkasting@chromium.org4591fbd2014-11-20 22:28:14 +000046 size_t payload_size_;
niklase@google.com470e71d2011-07-07 08:21:25 +000047};
48
Karl Wiberg3ff52ff2018-10-01 12:31:22 +020049class TestAllCodecs {
tina.legrand@webrtc.org50d5ca52012-06-18 13:35:52 +000050 public:
Fredrik Solenberg056f9732018-12-03 15:22:16 +010051 TestAllCodecs();
tina.legrand@webrtc.org50d5ca52012-06-18 13:35:52 +000052 ~TestAllCodecs();
niklase@google.com470e71d2011-07-07 08:21:25 +000053
Karl Wiberg3ff52ff2018-10-01 12:31:22 +020054 void Perform();
niklase@google.com470e71d2011-07-07 08:21:25 +000055
tina.legrand@webrtc.org50d5ca52012-06-18 13:35:52 +000056 private:
57 // The default value of '-1' indicates that the registration is based only on
58 // codec name, and a sampling frequency matching is not required.
59 // This is useful for codecs which support several sampling frequency.
60 // Note! Only mono mode is tested in this test.
Yves Gerey665174f2018-06-19 15:03:05 +020061 void RegisterSendCodec(char side,
62 char* codec_name,
63 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_;
72 std::unique_ptr<AudioCodingModule> 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_