niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1 | /* |
tina.legrand@webrtc.org | ae1c454 | 2012-03-12 08:41:30 +0000 | [diff] [blame] | 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 3 | * |
| 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.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 11 | #ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_TEST_TEST_STEREO_H_ |
| 12 | #define WEBRTC_MODULES_AUDIO_CODING_MAIN_TEST_TEST_STEREO_H_ |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 13 | |
tina.legrand@webrtc.org | 16b6b90 | 2012-04-12 11:02:38 +0000 | [diff] [blame] | 14 | #include <math.h> |
| 15 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 16 | #include "ACMTest.h" |
| 17 | #include "Channel.h" |
| 18 | #include "PCMFile.h" |
| 19 | |
tina.legrand@webrtc.org | 554ae1a | 2011-12-16 10:09:04 +0000 | [diff] [blame] | 20 | namespace webrtc { |
| 21 | |
tina.legrand@webrtc.org | 16b6b90 | 2012-04-12 11:02:38 +0000 | [diff] [blame] | 22 | enum StereoMonoMode { |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 23 | kNotSet, |
| 24 | kMono, |
| 25 | kStereo |
tina.legrand@webrtc.org | 16b6b90 | 2012-04-12 11:02:38 +0000 | [diff] [blame] | 26 | }; |
| 27 | |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 28 | class TestPackStereo : public AudioPacketizationCallback { |
| 29 | public: |
| 30 | TestPackStereo(); |
| 31 | ~TestPackStereo(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 32 | |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 33 | void RegisterReceiverACM(AudioCodingModule* acm); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 34 | |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 35 | virtual WebRtc_Word32 SendData(const FrameType frame_type, |
| 36 | const WebRtc_UWord8 payload_type, |
| 37 | const WebRtc_UWord32 timestamp, |
| 38 | const WebRtc_UWord8* payload_data, |
| 39 | const WebRtc_UWord16 payload_size, |
| 40 | const RTPFragmentationHeader* fragmentation); |
| 41 | |
| 42 | WebRtc_UWord16 payload_size(); |
| 43 | WebRtc_UWord32 timestamp_diff(); |
| 44 | 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_; |
| 50 | WebRtc_Word16 seq_no_; |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 51 | WebRtc_UWord32 timestamp_diff_; |
| 52 | WebRtc_UWord32 last_in_timestamp_; |
| 53 | WebRtc_UWord64 total_bytes_; |
| 54 | WebRtc_UWord16 payload_size_; |
| 55 | StereoMonoMode codec_mode_; |
| 56 | // Simulate packet losses |
| 57 | bool lost_packet_; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 58 | }; |
| 59 | |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 60 | class TestStereo : public ACMTest { |
| 61 | public: |
| 62 | TestStereo(int test_mode); |
| 63 | ~TestStereo(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 64 | |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 65 | 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.org | 3ddc974 | 2012-06-27 09:25:50 +0000 | [diff] [blame] | 70 | void RegisterSendCodec(char side, char* codec_name, |
| 71 | WebRtc_Word32 samp_freq_hz, int rate, int pack_size, |
| 72 | int channels, int payload_type); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 73 | |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 74 | void Run(TestPackStereo* channel, int in_channels, int out_channels, |
| 75 | int percent_loss = 0); |
| 76 | void OpenOutFile(WebRtc_Word16 test_number); |
| 77 | void DisplaySendReceiveCodec(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 78 | |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 79 | WebRtc_Word32 SendData(const FrameType frame_type, |
| 80 | const WebRtc_UWord8 payload_type, |
| 81 | const WebRtc_UWord32 timestamp, |
| 82 | const WebRtc_UWord8* payload_data, |
| 83 | const WebRtc_UWord16 payload_size, |
| 84 | const RTPFragmentationHeader* fragmentation); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 85 | |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 86 | int test_mode_; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 87 | |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 88 | AudioCodingModule* acm_a_; |
| 89 | AudioCodingModule* acm_b_; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 90 | |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 91 | TestPackStereo* channel_a2b_; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 92 | |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 93 | PCMFile* in_file_stereo_; |
| 94 | PCMFile* in_file_mono_; |
| 95 | PCMFile out_file_; |
| 96 | WebRtc_Word16 test_cntr_; |
| 97 | WebRtc_UWord16 pack_size_samp_; |
| 98 | WebRtc_UWord16 pack_size_bytes_; |
| 99 | int counter_; |
tina.legrand@webrtc.org | ae1c454 | 2012-03-12 08:41:30 +0000 | [diff] [blame] | 100 | |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 101 | // Payload types for stereo codecs and CNG |
| 102 | int g722_pltype_; |
| 103 | int l16_8khz_pltype_; |
| 104 | int l16_16khz_pltype_; |
| 105 | int l16_32khz_pltype_; |
| 106 | int pcma_pltype_; |
| 107 | int pcmu_pltype_; |
| 108 | int celt_pltype_; |
| 109 | int cn_8khz_pltype_; |
| 110 | int cn_16khz_pltype_; |
| 111 | int cn_32khz_pltype_; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 112 | }; |
| 113 | |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 114 | } // namespace webrtc |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 115 | |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 116 | #endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_TEST_TEST_STEREO_H_ |