blob: 8cde8cf1ff59a045c2b234fe3933387ef2cc1133 [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
tina.legrand@webrtc.org50d5ca52012-06-18 13:35:52 +000011#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_TEST_TEST_ALL_CODECS_H_
12#define WEBRTC_MODULES_AUDIO_CODING_MAIN_TEST_TEST_ALL_CODECS_H_
niklase@google.com470e71d2011-07-07 08:21:25 +000013
14#include "ACMTest.h"
15#include "Channel.h"
16#include "PCMFile.h"
tina.legrand@webrtc.org50d5ca52012-06-18 13:35:52 +000017#include "typedefs.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
tina.legrand@webrtc.org50d5ca52012-06-18 13:35:52 +000028 int32_t SendData(FrameType frame_type, uint8_t payload_type,
29 uint32_t timestamp, const uint8_t* payload_data,
30 uint16_t payload_size,
31 const RTPFragmentationHeader* fragmentation);
32
33 uint16_t payload_size();
34 uint32_t timestamp_diff();
35 void reset_payload_size();
36
37 private:
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +000038 AudioCodingModule* receiver_acm_;
tina.legrand@webrtc.org50d5ca52012-06-18 13:35:52 +000039 uint16_t sequence_number_;
40 uint8_t payload_data_[60 * 32 * 2 * 2];
41 uint32_t timestamp_diff_;
42 uint32_t last_in_timestamp_;
43 uint64_t total_bytes_;
44 uint16_t payload_size_;
niklase@google.com470e71d2011-07-07 08:21:25 +000045};
46
tina.legrand@webrtc.org50d5ca52012-06-18 13:35:52 +000047class TestAllCodecs : public ACMTest {
48 public:
49 TestAllCodecs(int test_mode);
50 ~TestAllCodecs();
niklase@google.com470e71d2011-07-07 08:21:25 +000051
tina.legrand@webrtc.org50d5ca52012-06-18 13:35:52 +000052 void Perform();
niklase@google.com470e71d2011-07-07 08:21:25 +000053
tina.legrand@webrtc.org50d5ca52012-06-18 13:35:52 +000054 private:
55 // The default value of '-1' indicates that the registration is based only on
56 // codec name, and a sampling frequency matching is not required.
57 // This is useful for codecs which support several sampling frequency.
58 // Note! Only mono mode is tested in this test.
59 void RegisterSendCodec(char side, char* codec_name, int32_t sampling_freq_hz,
60 int rate, int packet_size, int extra_byte);
niklase@google.com470e71d2011-07-07 08:21:25 +000061
tina.legrand@webrtc.org50d5ca52012-06-18 13:35:52 +000062 void Run(TestPack* channel);
63 void OpenOutFile(int test_number);
64 void DisplaySendReceiveCodec();
niklase@google.com470e71d2011-07-07 08:21:25 +000065
tina.legrand@webrtc.org50d5ca52012-06-18 13:35:52 +000066 int test_mode_;
67 AudioCodingModule* acm_a_;
68 AudioCodingModule* acm_b_;
69 TestPack* channel_a_to_b_;
70 PCMFile infile_a_;
71 PCMFile outfile_b_;
72 int test_count_;
73 uint16_t packet_size_samples_;
74 uint16_t packet_size_bytes_;
niklase@google.com470e71d2011-07-07 08:21:25 +000075};
76
tina.legrand@webrtc.org50d5ca52012-06-18 13:35:52 +000077} // namespace webrtc
niklase@google.com470e71d2011-07-07 08:21:25 +000078
tina.legrand@webrtc.org50d5ca52012-06-18 13:35:52 +000079#endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_TEST_TEST_ALL_CODECS_H_