blob: ecfce5e14cb44915d227358aec69c726a3968613 [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
tina.legrand@webrtc.orga6ecd1e2012-04-26 07:54:30 +000011#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_TEST_TEST_STEREO_H_
12#define WEBRTC_MODULES_AUDIO_CODING_MAIN_TEST_TEST_STEREO_H_
niklase@google.com470e71d2011-07-07 08:21:25 +000013
tina.legrand@webrtc.org16b6b902012-04-12 11:02:38 +000014#include <math.h>
15
niklase@google.com470e71d2011-07-07 08:21:25 +000016#include "ACMTest.h"
17#include "Channel.h"
18#include "PCMFile.h"
19
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +000020namespace webrtc {
21
tina.legrand@webrtc.org16b6b902012-04-12 11:02:38 +000022enum StereoMonoMode {
tina.legrand@webrtc.orga6ecd1e2012-04-26 07:54:30 +000023 kNotSet,
24 kMono,
25 kStereo
tina.legrand@webrtc.org16b6b902012-04-12 11:02:38 +000026};
27
tina.legrand@webrtc.orga6ecd1e2012-04-26 07:54:30 +000028class TestPackStereo : public AudioPacketizationCallback {
29 public:
30 TestPackStereo();
31 ~TestPackStereo();
niklase@google.com470e71d2011-07-07 08:21:25 +000032
tina.legrand@webrtc.orga6ecd1e2012-04-26 07:54:30 +000033 void RegisterReceiverACM(AudioCodingModule* acm);
niklase@google.com470e71d2011-07-07 08:21:25 +000034
pbos@webrtc.org0946a562013-04-09 00:28:06 +000035 virtual int32_t SendData(const FrameType frame_type,
36 const uint8_t payload_type,
37 const uint32_t timestamp,
38 const uint8_t* payload_data,
39 const uint16_t payload_size,
40 const RTPFragmentationHeader* fragmentation);
tina.legrand@webrtc.orga6ecd1e2012-04-26 07:54:30 +000041
pbos@webrtc.org0946a562013-04-09 00:28:06 +000042 uint16_t payload_size();
43 uint32_t timestamp_diff();
tina.legrand@webrtc.orga6ecd1e2012-04-26 07:54:30 +000044 void reset_payload_size();
45 void set_codec_mode(StereoMonoMode mode);
46 void set_lost_packet(bool lost);
47
48 private:
49 AudioCodingModule* receiver_acm_;
pbos@webrtc.org0946a562013-04-09 00:28:06 +000050 int16_t seq_no_;
51 uint32_t timestamp_diff_;
52 uint32_t last_in_timestamp_;
53 uint64_t total_bytes_;
54 uint16_t payload_size_;
tina.legrand@webrtc.orga6ecd1e2012-04-26 07:54:30 +000055 StereoMonoMode codec_mode_;
56 // Simulate packet losses
57 bool lost_packet_;
niklase@google.com470e71d2011-07-07 08:21:25 +000058};
59
tina.legrand@webrtc.orga6ecd1e2012-04-26 07:54:30 +000060class TestStereo : public ACMTest {
61 public:
62 TestStereo(int test_mode);
63 ~TestStereo();
niklase@google.com470e71d2011-07-07 08:21:25 +000064
tina.legrand@webrtc.orga6ecd1e2012-04-26 07:54:30 +000065 void Perform();
66 private:
67 // The default value of '-1' indicates that the registration is based only on
68 // codec name and a sampling frequncy matching is not required. This is useful
69 // for codecs which support several sampling frequency.
tina.legrand@webrtc.org3ddc9742012-06-27 09:25:50 +000070 void RegisterSendCodec(char side, char* codec_name,
pbos@webrtc.org0946a562013-04-09 00:28:06 +000071 int32_t samp_freq_hz, int rate, int pack_size,
tina.legrand@webrtc.org3ddc9742012-06-27 09:25:50 +000072 int channels, int payload_type);
niklase@google.com470e71d2011-07-07 08:21:25 +000073
tina.legrand@webrtc.orga6ecd1e2012-04-26 07:54:30 +000074 void Run(TestPackStereo* channel, int in_channels, int out_channels,
75 int percent_loss = 0);
pbos@webrtc.org0946a562013-04-09 00:28:06 +000076 void OpenOutFile(int16_t test_number);
tina.legrand@webrtc.orga6ecd1e2012-04-26 07:54:30 +000077 void DisplaySendReceiveCodec();
niklase@google.com470e71d2011-07-07 08:21:25 +000078
pbos@webrtc.org0946a562013-04-09 00:28:06 +000079 int32_t SendData(const FrameType frame_type,
80 const uint8_t payload_type,
81 const uint32_t timestamp,
82 const uint8_t* payload_data,
83 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
tina.legrand@webrtc.orga6ecd1e2012-04-26 07:54:30 +000088 AudioCodingModule* acm_a_;
89 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
tina.legrand@webrtc.orga6ecd1e2012-04-26 07:54:30 +0000118#endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_TEST_TEST_STEREO_H_