blob: e79bd69faa09320f77ee8e8fdb3a9870e6b45857 [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
kwiberg@webrtc.org00b8f6b2015-02-26 14:34:55 +000014#include "webrtc/base/scoped_ptr.h"
kjellander3e6db232015-11-26 04:44:54 -080015#include "webrtc/modules/audio_coding/test/ACMTest.h"
16#include "webrtc/modules/audio_coding/test/Channel.h"
17#include "webrtc/modules/audio_coding/test/PCMFile.h"
turaj@webrtc.org6ea3d1c2013-10-02 21:44:33 +000018#include "webrtc/typedefs.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000019
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +000020namespace webrtc {
21
turaj@webrtc.org6ea3d1c2013-10-02 21:44:33 +000022class Config;
23
tina.legrand@webrtc.org50d5ca52012-06-18 13:35:52 +000024class TestPack : public AudioPacketizationCallback {
25 public:
26 TestPack();
27 ~TestPack();
niklase@google.com470e71d2011-07-07 08:21:25 +000028
tina.legrand@webrtc.org50d5ca52012-06-18 13:35:52 +000029 void RegisterReceiverACM(AudioCodingModule* acm);
niklase@google.com470e71d2011-07-07 08:21:25 +000030
kjellander@webrtc.org14665ff2015-03-04 12:58:35 +000031 int32_t SendData(FrameType frame_type,
32 uint8_t payload_type,
33 uint32_t timestamp,
34 const uint8_t* payload_data,
35 size_t payload_size,
36 const RTPFragmentationHeader* fragmentation) override;
tina.legrand@webrtc.org50d5ca52012-06-18 13:35:52 +000037
pkasting@chromium.org4591fbd2014-11-20 22:28:14 +000038 size_t payload_size();
tina.legrand@webrtc.org50d5ca52012-06-18 13:35:52 +000039 uint32_t timestamp_diff();
40 void reset_payload_size();
41
42 private:
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +000043 AudioCodingModule* receiver_acm_;
tina.legrand@webrtc.org50d5ca52012-06-18 13:35:52 +000044 uint16_t sequence_number_;
45 uint8_t payload_data_[60 * 32 * 2 * 2];
46 uint32_t timestamp_diff_;
47 uint32_t last_in_timestamp_;
48 uint64_t total_bytes_;
pkasting@chromium.org4591fbd2014-11-20 22:28:14 +000049 size_t payload_size_;
niklase@google.com470e71d2011-07-07 08:21:25 +000050};
51
tina.legrand@webrtc.org50d5ca52012-06-18 13:35:52 +000052class TestAllCodecs : public ACMTest {
53 public:
henrik.lundin@webrtc.orgadaf8092014-04-17 08:29:10 +000054 explicit TestAllCodecs(int test_mode);
tina.legrand@webrtc.org50d5ca52012-06-18 13:35:52 +000055 ~TestAllCodecs();
niklase@google.com470e71d2011-07-07 08:21:25 +000056
kjellander@webrtc.org14665ff2015-03-04 12:58:35 +000057 void Perform() override;
niklase@google.com470e71d2011-07-07 08:21:25 +000058
tina.legrand@webrtc.org50d5ca52012-06-18 13:35:52 +000059 private:
60 // The default value of '-1' indicates that the registration is based only on
61 // codec name, and a sampling frequency matching is not required.
62 // This is useful for codecs which support several sampling frequency.
63 // Note! Only mono mode is tested in this test.
64 void RegisterSendCodec(char side, char* codec_name, int32_t sampling_freq_hz,
pkasting@chromium.org4591fbd2014-11-20 22:28:14 +000065 int rate, int packet_size, 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);
69 void DisplaySendReceiveCodec();
niklase@google.com470e71d2011-07-07 08:21:25 +000070
tina.legrand@webrtc.org50d5ca52012-06-18 13:35:52 +000071 int test_mode_;
kwiberg@webrtc.org00b8f6b2015-02-26 14:34:55 +000072 rtc::scoped_ptr<AudioCodingModule> acm_a_;
73 rtc::scoped_ptr<AudioCodingModule> acm_b_;
tina.legrand@webrtc.org50d5ca52012-06-18 13:35:52 +000074 TestPack* channel_a_to_b_;
75 PCMFile infile_a_;
76 PCMFile outfile_b_;
77 int test_count_;
henrike@webrtc.org6ac22e62014-08-11 21:06:30 +000078 int packet_size_samples_;
pkasting@chromium.org4591fbd2014-11-20 22:28:14 +000079 size_t packet_size_bytes_;
niklase@google.com470e71d2011-07-07 08:21:25 +000080};
81
tina.legrand@webrtc.org50d5ca52012-06-18 13:35:52 +000082} // namespace webrtc
niklase@google.com470e71d2011-07-07 08:21:25 +000083
kjellander3e6db232015-11-26 04:44:54 -080084#endif // WEBRTC_MODULES_AUDIO_CODING_TEST_TESTALLCODECS_H_