blob: ef5666171df5405b364ebd0d43860388cd458fde [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 Solenberg657b2962018-12-05 10:30:25 +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
Niels Möller87e2d782019-03-07 10:18:23 +010028 int32_t SendData(AudioFrameType frame_type,
kjellander@webrtc.org14665ff2015-03-04 12:58:35 +000029 uint8_t payload_type,
30 uint32_t timestamp,
31 const uint8_t* payload_data,
Niels Möllerc35b6e62019-04-25 16:31:18 +020032 size_t payload_size) override;
tina.legrand@webrtc.org50d5ca52012-06-18 13:35:52 +000033
pkasting@chromium.org4591fbd2014-11-20 22:28:14 +000034 size_t payload_size();
tina.legrand@webrtc.org50d5ca52012-06-18 13:35:52 +000035 uint32_t timestamp_diff();
36 void reset_payload_size();
37
38 private:
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +000039 AudioCodingModule* receiver_acm_;
tina.legrand@webrtc.org50d5ca52012-06-18 13:35:52 +000040 uint16_t sequence_number_;
41 uint8_t payload_data_[60 * 32 * 2 * 2];
42 uint32_t timestamp_diff_;
43 uint32_t last_in_timestamp_;
44 uint64_t total_bytes_;
pkasting@chromium.org4591fbd2014-11-20 22:28:14 +000045 size_t payload_size_;
niklase@google.com470e71d2011-07-07 08:21:25 +000046};
47
Karl Wiberg3ff52ff2018-10-01 12:31:22 +020048class TestAllCodecs {
tina.legrand@webrtc.org50d5ca52012-06-18 13:35:52 +000049 public:
Fredrik Solenberg657b2962018-12-05 10:30:25 +010050 TestAllCodecs();
tina.legrand@webrtc.org50d5ca52012-06-18 13:35:52 +000051 ~TestAllCodecs();
niklase@google.com470e71d2011-07-07 08:21:25 +000052
Karl Wiberg3ff52ff2018-10-01 12:31:22 +020053 void Perform();
niklase@google.com470e71d2011-07-07 08:21:25 +000054
tina.legrand@webrtc.org50d5ca52012-06-18 13:35:52 +000055 private:
56 // The default value of '-1' indicates that the registration is based only on
57 // codec name, and a sampling frequency matching is not required.
58 // This is useful for codecs which support several sampling frequency.
59 // Note! Only mono mode is tested in this test.
Yves Gerey665174f2018-06-19 15:03:05 +020060 void RegisterSendCodec(char side,
61 char* codec_name,
62 int32_t sampling_freq_hz,
63 int rate,
64 int packet_size,
65 size_t extra_byte);
niklase@google.com470e71d2011-07-07 08:21:25 +000066
tina.legrand@webrtc.org50d5ca52012-06-18 13:35:52 +000067 void Run(TestPack* channel);
68 void OpenOutFile(int test_number);
niklase@google.com470e71d2011-07-07 08:21:25 +000069
kwiberg37478382016-02-14 20:40:57 -080070 std::unique_ptr<AudioCodingModule> acm_a_;
71 std::unique_ptr<AudioCodingModule> acm_b_;
tina.legrand@webrtc.org50d5ca52012-06-18 13:35:52 +000072 TestPack* channel_a_to_b_;
73 PCMFile infile_a_;
74 PCMFile outfile_b_;
75 int test_count_;
henrike@webrtc.org6ac22e62014-08-11 21:06:30 +000076 int packet_size_samples_;
pkasting@chromium.org4591fbd2014-11-20 22:28:14 +000077 size_t packet_size_bytes_;
niklase@google.com470e71d2011-07-07 08:21:25 +000078};
79
tina.legrand@webrtc.org50d5ca52012-06-18 13:35:52 +000080} // namespace webrtc
niklase@google.com470e71d2011-07-07 08:21:25 +000081
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020082#endif // MODULES_AUDIO_CODING_TEST_TESTALLCODECS_H_