blob: 8aefa7fc40586a322e50ce7f418ce2197c979a61 [file] [log] [blame]
niklase@google.com470e71d2011-07-07 08:21:25 +00001/*
tina.legrand@webrtc.orgae1c4542012-03-12 08:41:30 +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
turaj@webrtc.org6ea3d1c2013-10-02 21:44:33 +000011#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_TEST_TESTSTEREO_H_
12#define WEBRTC_MODULES_AUDIO_CODING_MAIN_TEST_TESTSTEREO_H_
niklase@google.com470e71d2011-07-07 08:21:25 +000013
tina.legrand@webrtc.org16b6b902012-04-12 11:02:38 +000014#include <math.h>
15
andrew@webrtc.org89df0922013-09-12 01:27:43 +000016#include "webrtc/system_wrappers/interface/scoped_ptr.h"
turaj@webrtc.org6ea3d1c2013-10-02 21:44:33 +000017#include "webrtc/modules/audio_coding/main/test/ACMTest.h"
18#include "webrtc/modules/audio_coding/main/test/Channel.h"
19#include "webrtc/modules/audio_coding/main/test/PCMFile.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000020
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +000021namespace webrtc {
22
tina.legrand@webrtc.org16b6b902012-04-12 11:02:38 +000023enum StereoMonoMode {
tina.legrand@webrtc.orga6ecd1e2012-04-26 07:54:30 +000024 kNotSet,
25 kMono,
26 kStereo
tina.legrand@webrtc.org16b6b902012-04-12 11:02:38 +000027};
28
tina.legrand@webrtc.orga6ecd1e2012-04-26 07:54:30 +000029class TestPackStereo : public AudioPacketizationCallback {
30 public:
31 TestPackStereo();
32 ~TestPackStereo();
niklase@google.com470e71d2011-07-07 08:21:25 +000033
tina.legrand@webrtc.orga6ecd1e2012-04-26 07:54:30 +000034 void RegisterReceiverACM(AudioCodingModule* acm);
niklase@google.com470e71d2011-07-07 08:21:25 +000035
henrike@webrtc.org47658f12014-09-10 22:14:59 +000036 virtual int32_t SendData(
37 const FrameType frame_type,
38 const uint8_t payload_type,
39 const uint32_t timestamp,
40 const uint8_t* payload_data,
41 const uint16_t payload_size,
42 const RTPFragmentationHeader* fragmentation) OVERRIDE;
tina.legrand@webrtc.orga6ecd1e2012-04-26 07:54:30 +000043
pbos@webrtc.org0946a562013-04-09 00:28:06 +000044 uint16_t payload_size();
45 uint32_t timestamp_diff();
tina.legrand@webrtc.orga6ecd1e2012-04-26 07:54:30 +000046 void reset_payload_size();
47 void set_codec_mode(StereoMonoMode mode);
48 void set_lost_packet(bool lost);
49
50 private:
51 AudioCodingModule* receiver_acm_;
pbos@webrtc.org0946a562013-04-09 00:28:06 +000052 int16_t seq_no_;
53 uint32_t timestamp_diff_;
54 uint32_t last_in_timestamp_;
55 uint64_t total_bytes_;
henrike@webrtc.org6ac22e62014-08-11 21:06:30 +000056 int payload_size_;
tina.legrand@webrtc.orga6ecd1e2012-04-26 07:54:30 +000057 StereoMonoMode codec_mode_;
58 // Simulate packet losses
59 bool lost_packet_;
niklase@google.com470e71d2011-07-07 08:21:25 +000060};
61
tina.legrand@webrtc.orga6ecd1e2012-04-26 07:54:30 +000062class TestStereo : public ACMTest {
63 public:
henrik.lundin@webrtc.orgadaf8092014-04-17 08:29:10 +000064 explicit TestStereo(int test_mode);
tina.legrand@webrtc.orga6ecd1e2012-04-26 07:54:30 +000065 ~TestStereo();
niklase@google.com470e71d2011-07-07 08:21:25 +000066
henrike@webrtc.org47658f12014-09-10 22:14:59 +000067 virtual void Perform() OVERRIDE;
tina.legrand@webrtc.orga6ecd1e2012-04-26 07:54:30 +000068 private:
69 // The default value of '-1' indicates that the registration is based only on
70 // codec name and a sampling frequncy matching is not required. This is useful
71 // for codecs which support several sampling frequency.
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +000072 void RegisterSendCodec(char side, char* codec_name, int32_t samp_freq_hz,
73 int rate, int pack_size, int channels,
74 int payload_type);
niklase@google.com470e71d2011-07-07 08:21:25 +000075
tina.legrand@webrtc.orga6ecd1e2012-04-26 07:54:30 +000076 void Run(TestPackStereo* channel, int in_channels, int out_channels,
77 int percent_loss = 0);
pbos@webrtc.org0946a562013-04-09 00:28:06 +000078 void OpenOutFile(int16_t test_number);
tina.legrand@webrtc.orga6ecd1e2012-04-26 07:54:30 +000079 void DisplaySendReceiveCodec();
niklase@google.com470e71d2011-07-07 08:21:25 +000080
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +000081 int32_t SendData(const FrameType frame_type, const uint8_t payload_type,
82 const uint32_t timestamp, const uint8_t* payload_data,
pbos@webrtc.org0946a562013-04-09 00:28:06 +000083 const uint16_t payload_size,
84 const RTPFragmentationHeader* fragmentation);
niklase@google.com470e71d2011-07-07 08:21:25 +000085
tina.legrand@webrtc.orga6ecd1e2012-04-26 07:54:30 +000086 int test_mode_;
niklase@google.com470e71d2011-07-07 08:21:25 +000087
andrew@webrtc.org89df0922013-09-12 01:27:43 +000088 scoped_ptr<AudioCodingModule> acm_a_;
89 scoped_ptr<AudioCodingModule> acm_b_;
niklase@google.com470e71d2011-07-07 08:21:25 +000090
tina.legrand@webrtc.orga6ecd1e2012-04-26 07:54:30 +000091 TestPackStereo* channel_a2b_;
niklase@google.com470e71d2011-07-07 08:21:25 +000092
tina.legrand@webrtc.orga6ecd1e2012-04-26 07:54:30 +000093 PCMFile* in_file_stereo_;
94 PCMFile* in_file_mono_;
95 PCMFile out_file_;
pbos@webrtc.org0946a562013-04-09 00:28:06 +000096 int16_t test_cntr_;
97 uint16_t pack_size_samp_;
98 uint16_t pack_size_bytes_;
tina.legrand@webrtc.orga6ecd1e2012-04-26 07:54:30 +000099 int counter_;
tina.legrand@webrtc.org0ad3c1a2012-11-07 08:07:29 +0000100 char* send_codec_name_;
tina.legrand@webrtc.orgae1c4542012-03-12 08:41:30 +0000101
tina.legrand@webrtc.orga6ecd1e2012-04-26 07:54:30 +0000102 // Payload types for stereo codecs and CNG
103 int g722_pltype_;
104 int l16_8khz_pltype_;
105 int l16_16khz_pltype_;
106 int l16_32khz_pltype_;
107 int pcma_pltype_;
108 int pcmu_pltype_;
109 int celt_pltype_;
tina.legrand@webrtc.org0ad3c1a2012-11-07 08:07:29 +0000110 int opus_pltype_;
tina.legrand@webrtc.orga6ecd1e2012-04-26 07:54:30 +0000111 int cn_8khz_pltype_;
112 int cn_16khz_pltype_;
113 int cn_32khz_pltype_;
niklase@google.com470e71d2011-07-07 08:21:25 +0000114};
115
tina.legrand@webrtc.orga6ecd1e2012-04-26 07:54:30 +0000116} // namespace webrtc
niklase@google.com470e71d2011-07-07 08:21:25 +0000117
turaj@webrtc.org6ea3d1c2013-10-02 21:44:33 +0000118#endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_TEST_TESTSTEREO_H_