blob: 03539ffd84645259bc782319d696dff177e06734 [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
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020016#include "modules/audio_coding/test/ACMTest.h"
17#include "modules/audio_coding/test/Channel.h"
18#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
tina.legrand@webrtc.org50d5ca52012-06-18 13:35:52 +000027 void RegisterReceiverACM(AudioCodingModule* acm);
niklase@google.com470e71d2011-07-07 08:21:25 +000028
kjellander@webrtc.org14665ff2015-03-04 12:58:35 +000029 int32_t SendData(FrameType frame_type,
30 uint8_t payload_type,
31 uint32_t timestamp,
32 const uint8_t* payload_data,
33 size_t payload_size,
34 const RTPFragmentationHeader* fragmentation) 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:
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +000041 AudioCodingModule* 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
tina.legrand@webrtc.org50d5ca52012-06-18 13:35:52 +000050class TestAllCodecs : public ACMTest {
51 public:
henrik.lundin@webrtc.orgadaf8092014-04-17 08:29:10 +000052 explicit TestAllCodecs(int test_mode);
tina.legrand@webrtc.org50d5ca52012-06-18 13:35:52 +000053 ~TestAllCodecs();
niklase@google.com470e71d2011-07-07 08:21:25 +000054
kjellander@webrtc.org14665ff2015-03-04 12:58:35 +000055 void Perform() override;
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.
Yves Gerey665174f2018-06-19 15:03:05 +020062 void RegisterSendCodec(char side,
63 char* codec_name,
64 int32_t sampling_freq_hz,
65 int rate,
66 int packet_size,
67 size_t extra_byte);
niklase@google.com470e71d2011-07-07 08:21:25 +000068
tina.legrand@webrtc.org50d5ca52012-06-18 13:35:52 +000069 void Run(TestPack* channel);
70 void OpenOutFile(int test_number);
71 void DisplaySendReceiveCodec();
niklase@google.com470e71d2011-07-07 08:21:25 +000072
tina.legrand@webrtc.org50d5ca52012-06-18 13:35:52 +000073 int test_mode_;
kwiberg37478382016-02-14 20:40:57 -080074 std::unique_ptr<AudioCodingModule> acm_a_;
75 std::unique_ptr<AudioCodingModule> acm_b_;
tina.legrand@webrtc.org50d5ca52012-06-18 13:35:52 +000076 TestPack* channel_a_to_b_;
77 PCMFile infile_a_;
78 PCMFile outfile_b_;
79 int test_count_;
henrike@webrtc.org6ac22e62014-08-11 21:06:30 +000080 int packet_size_samples_;
pkasting@chromium.org4591fbd2014-11-20 22:28:14 +000081 size_t packet_size_bytes_;
niklase@google.com470e71d2011-07-07 08:21:25 +000082};
83
tina.legrand@webrtc.org50d5ca52012-06-18 13:35:52 +000084} // namespace webrtc
niklase@google.com470e71d2011-07-07 08:21:25 +000085
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020086#endif // MODULES_AUDIO_CODING_TEST_TESTALLCODECS_H_