blob: 6d6f380d2933eba5fa8863aaa2424e0db939fc22 [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
kjellander3e6db232015-11-26 04:44:54 -080011#ifndef WEBRTC_MODULES_AUDIO_CODING_TEST_TESTALLCODECS_H_
12#define WEBRTC_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
kjellander3e6db232015-11-26 04:44:54 -080016#include "webrtc/modules/audio_coding/test/ACMTest.h"
17#include "webrtc/modules/audio_coding/test/Channel.h"
18#include "webrtc/modules/audio_coding/test/PCMFile.h"
turaj@webrtc.org6ea3d1c2013-10-02 21:44:33 +000019#include "webrtc/typedefs.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000020
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +000021namespace webrtc {
22
turaj@webrtc.org6ea3d1c2013-10-02 21:44:33 +000023class Config;
24
tina.legrand@webrtc.org50d5ca52012-06-18 13:35:52 +000025class TestPack : public AudioPacketizationCallback {
26 public:
27 TestPack();
28 ~TestPack();
niklase@google.com470e71d2011-07-07 08:21:25 +000029
tina.legrand@webrtc.org50d5ca52012-06-18 13:35:52 +000030 void RegisterReceiverACM(AudioCodingModule* acm);
niklase@google.com470e71d2011-07-07 08:21:25 +000031
kjellander@webrtc.org14665ff2015-03-04 12:58:35 +000032 int32_t SendData(FrameType frame_type,
33 uint8_t payload_type,
34 uint32_t timestamp,
35 const uint8_t* payload_data,
36 size_t payload_size,
37 const RTPFragmentationHeader* fragmentation) override;
tina.legrand@webrtc.org50d5ca52012-06-18 13:35:52 +000038
pkasting@chromium.org4591fbd2014-11-20 22:28:14 +000039 size_t payload_size();
tina.legrand@webrtc.org50d5ca52012-06-18 13:35:52 +000040 uint32_t timestamp_diff();
41 void reset_payload_size();
42
43 private:
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +000044 AudioCodingModule* receiver_acm_;
tina.legrand@webrtc.org50d5ca52012-06-18 13:35:52 +000045 uint16_t sequence_number_;
46 uint8_t payload_data_[60 * 32 * 2 * 2];
47 uint32_t timestamp_diff_;
48 uint32_t last_in_timestamp_;
49 uint64_t total_bytes_;
pkasting@chromium.org4591fbd2014-11-20 22:28:14 +000050 size_t payload_size_;
niklase@google.com470e71d2011-07-07 08:21:25 +000051};
52
tina.legrand@webrtc.org50d5ca52012-06-18 13:35:52 +000053class TestAllCodecs : public ACMTest {
54 public:
henrik.lundin@webrtc.orgadaf8092014-04-17 08:29:10 +000055 explicit TestAllCodecs(int test_mode);
tina.legrand@webrtc.org50d5ca52012-06-18 13:35:52 +000056 ~TestAllCodecs();
niklase@google.com470e71d2011-07-07 08:21:25 +000057
kjellander@webrtc.org14665ff2015-03-04 12:58:35 +000058 void Perform() override;
niklase@google.com470e71d2011-07-07 08:21:25 +000059
tina.legrand@webrtc.org50d5ca52012-06-18 13:35:52 +000060 private:
61 // The default value of '-1' indicates that the registration is based only on
62 // codec name, and a sampling frequency matching is not required.
63 // This is useful for codecs which support several sampling frequency.
64 // Note! Only mono mode is tested in this test.
65 void RegisterSendCodec(char side, char* codec_name, int32_t sampling_freq_hz,
pkasting@chromium.org4591fbd2014-11-20 22:28:14 +000066 int rate, int packet_size, 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);
70 void DisplaySendReceiveCodec();
niklase@google.com470e71d2011-07-07 08:21:25 +000071
tina.legrand@webrtc.org50d5ca52012-06-18 13:35:52 +000072 int test_mode_;
kwiberg37478382016-02-14 20:40:57 -080073 std::unique_ptr<AudioCodingModule> acm_a_;
74 std::unique_ptr<AudioCodingModule> acm_b_;
tina.legrand@webrtc.org50d5ca52012-06-18 13:35:52 +000075 TestPack* channel_a_to_b_;
76 PCMFile infile_a_;
77 PCMFile outfile_b_;
78 int test_count_;
henrike@webrtc.org6ac22e62014-08-11 21:06:30 +000079 int packet_size_samples_;
pkasting@chromium.org4591fbd2014-11-20 22:28:14 +000080 size_t packet_size_bytes_;
niklase@google.com470e71d2011-07-07 08:21:25 +000081};
82
tina.legrand@webrtc.org50d5ca52012-06-18 13:35:52 +000083} // namespace webrtc
niklase@google.com470e71d2011-07-07 08:21:25 +000084
kjellander3e6db232015-11-26 04:44:54 -080085#endif // WEBRTC_MODULES_AUDIO_CODING_TEST_TESTALLCODECS_H_