| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 TearDown(); | 100 TearDown(); |
| 101 } | 101 } |
| 102 | 102 |
| 103 void SetUp(bool legacy_agc, int tx_port, int rx_port) { | 103 void SetUp(bool legacy_agc, int tx_port, int rx_port) { |
| 104 VoEAudioProcessing* audio = VoEAudioProcessing::GetInterface(voe_); | 104 VoEAudioProcessing* audio = VoEAudioProcessing::GetInterface(voe_); |
| 105 VoENetwork* network = VoENetwork::GetInterface(voe_); | 105 VoENetwork* network = VoENetwork::GetInterface(voe_); |
| 106 { | 106 { |
| 107 webrtc::Config config; | 107 webrtc::Config config; |
| 108 config.Set<ExperimentalAgc>(new ExperimentalAgc(!legacy_agc)); | 108 config.Set<ExperimentalAgc>(new ExperimentalAgc(!legacy_agc)); |
| 109 AudioProcessing* audioproc = AudioProcessing::Create(config); | 109 AudioProcessing* audioproc = AudioProcessing::Create(config); |
| 110 CHECK_EQ(0, base_->Init(nullptr, audioproc)); | 110 RTC_CHECK_EQ(0, base_->Init(nullptr, audioproc)); |
| 111 // Set this stuff after Init, to override the default voice engine | 111 // Set this stuff after Init, to override the default voice engine |
| 112 // settings. | 112 // settings. |
| 113 audioproc->gain_control()->Enable(true); | 113 audioproc->gain_control()->Enable(true); |
| 114 audioproc->high_pass_filter()->Enable(FLAGS_highpass); | 114 audioproc->high_pass_filter()->Enable(FLAGS_highpass); |
| 115 audioproc->noise_suppression()->Enable(FLAGS_ns); | 115 audioproc->noise_suppression()->Enable(FLAGS_ns); |
| 116 audioproc->echo_cancellation()->Enable(FLAGS_aec); | 116 audioproc->echo_cancellation()->Enable(FLAGS_aec); |
| 117 } | 117 } |
| 118 channel_ = base_->CreateChannel(); | 118 channel_ = base_->CreateChannel(); |
| 119 CHECK_NE(-1, channel_); | 119 RTC_CHECK_NE(-1, channel_); |
| 120 | 120 |
| 121 channel_transport_.reset( | 121 channel_transport_.reset( |
| 122 new test::VoiceChannelTransport(network, channel_)); | 122 new test::VoiceChannelTransport(network, channel_)); |
| 123 CHECK_EQ(0, channel_transport_->SetSendDestination("127.0.0.1", tx_port)); | 123 RTC_CHECK_EQ(0, |
| 124 CHECK_EQ(0, channel_transport_->SetLocalReceiver(rx_port)); | 124 channel_transport_->SetSendDestination("127.0.0.1", tx_port)); |
| 125 RTC_CHECK_EQ(0, channel_transport_->SetLocalReceiver(rx_port)); |
| 125 | 126 |
| 126 CHECK_EQ(0, hardware_->SetRecordingDevice(capture_idx_)); | 127 RTC_CHECK_EQ(0, hardware_->SetRecordingDevice(capture_idx_)); |
| 127 CHECK_EQ(0, hardware_->SetPlayoutDevice(render_idx_)); | 128 RTC_CHECK_EQ(0, hardware_->SetPlayoutDevice(render_idx_)); |
| 128 | 129 |
| 129 CodecInst codec_params = {}; | 130 CodecInst codec_params = {}; |
| 130 bool codec_found = false; | 131 bool codec_found = false; |
| 131 for (int i = 0; i < codec_->NumOfCodecs(); i++) { | 132 for (int i = 0; i < codec_->NumOfCodecs(); i++) { |
| 132 CHECK_EQ(0, codec_->GetCodec(i, codec_params)); | 133 RTC_CHECK_EQ(0, codec_->GetCodec(i, codec_params)); |
| 133 if (FLAGS_pt == codec_params.pltype) { | 134 if (FLAGS_pt == codec_params.pltype) { |
| 134 codec_found = true; | 135 codec_found = true; |
| 135 break; | 136 break; |
| 136 } | 137 } |
| 137 } | 138 } |
| 138 CHECK(codec_found); | 139 RTC_CHECK(codec_found); |
| 139 CHECK_EQ(0, codec_->SetSendCodec(channel_, codec_params)); | 140 RTC_CHECK_EQ(0, codec_->SetSendCodec(channel_, codec_params)); |
| 140 | 141 |
| 141 audio->Release(); | 142 audio->Release(); |
| 142 network->Release(); | 143 network->Release(); |
| 143 } | 144 } |
| 144 | 145 |
| 145 void TearDown() { | 146 void TearDown() { |
| 146 Stop(); | 147 Stop(); |
| 147 channel_transport_.reset(nullptr); | 148 channel_transport_.reset(nullptr); |
| 148 CHECK_EQ(0, base_->DeleteChannel(channel_)); | 149 RTC_CHECK_EQ(0, base_->DeleteChannel(channel_)); |
| 149 CHECK_EQ(0, base_->Terminate()); | 150 RTC_CHECK_EQ(0, base_->Terminate()); |
| 150 hardware_->Release(); | 151 hardware_->Release(); |
| 151 base_->Release(); | 152 base_->Release(); |
| 152 codec_->Release(); | 153 codec_->Release(); |
| 153 CHECK(VoiceEngine::Delete(voe_)); | 154 RTC_CHECK(VoiceEngine::Delete(voe_)); |
| 154 } | 155 } |
| 155 | 156 |
| 156 void PrintDevices() { | 157 void PrintDevices() { |
| 157 int num_devices = 0; | 158 int num_devices = 0; |
| 158 char device_name[128] = {0}; | 159 char device_name[128] = {0}; |
| 159 char guid[128] = {0}; | 160 char guid[128] = {0}; |
| 160 CHECK_EQ(0, hardware_->GetNumOfRecordingDevices(num_devices)); | 161 RTC_CHECK_EQ(0, hardware_->GetNumOfRecordingDevices(num_devices)); |
| 161 printf("Capture devices:\n"); | 162 printf("Capture devices:\n"); |
| 162 for (int i = 0; i < num_devices; i++) { | 163 for (int i = 0; i < num_devices; i++) { |
| 163 CHECK_EQ(0, hardware_->GetRecordingDeviceName(i, device_name, guid)); | 164 RTC_CHECK_EQ(0, hardware_->GetRecordingDeviceName(i, device_name, guid)); |
| 164 printf("%d: %s\n", i, device_name); | 165 printf("%d: %s\n", i, device_name); |
| 165 } | 166 } |
| 166 CHECK_EQ(0, hardware_->GetNumOfPlayoutDevices(num_devices)); | 167 RTC_CHECK_EQ(0, hardware_->GetNumOfPlayoutDevices(num_devices)); |
| 167 printf("Render devices:\n"); | 168 printf("Render devices:\n"); |
| 168 for (int i = 0; i < num_devices; i++) { | 169 for (int i = 0; i < num_devices; i++) { |
| 169 CHECK_EQ(0, hardware_->GetPlayoutDeviceName(i, device_name, guid)); | 170 RTC_CHECK_EQ(0, hardware_->GetPlayoutDeviceName(i, device_name, guid)); |
| 170 printf("%d: %s\n", i, device_name); | 171 printf("%d: %s\n", i, device_name); |
| 171 } | 172 } |
| 172 } | 173 } |
| 173 | 174 |
| 174 void PrintCodecs() { | 175 void PrintCodecs() { |
| 175 CodecInst params = {0}; | 176 CodecInst params = {0}; |
| 176 printf("Codecs:\n"); | 177 printf("Codecs:\n"); |
| 177 for (int i = 0; i < codec_->NumOfCodecs(); i++) { | 178 for (int i = 0; i < codec_->NumOfCodecs(); i++) { |
| 178 CHECK_EQ(0, codec_->GetCodec(i, params)); | 179 RTC_CHECK_EQ(0, codec_->GetCodec(i, params)); |
| 179 printf("%d %s/%d/%d\n", params.pltype, params.plname, params.plfreq, | 180 printf("%d %s/%d/%d\n", params.pltype, params.plname, params.plfreq, |
| 180 params.channels); | 181 params.channels); |
| 181 } | 182 } |
| 182 } | 183 } |
| 183 | 184 |
| 184 void StartSending() { CHECK_EQ(0, base_->StartSend(channel_)); } | 185 void StartSending() { RTC_CHECK_EQ(0, base_->StartSend(channel_)); } |
| 185 | 186 |
| 186 void StartPlaying(Pan pan, const std::string& filename) { | 187 void StartPlaying(Pan pan, const std::string& filename) { |
| 187 VoEVolumeControl* volume = VoEVolumeControl::GetInterface(voe_); | 188 VoEVolumeControl* volume = VoEVolumeControl::GetInterface(voe_); |
| 188 VoEFile* file = VoEFile::GetInterface(voe_); | 189 VoEFile* file = VoEFile::GetInterface(voe_); |
| 189 if (pan == PanLeft) { | 190 if (pan == PanLeft) { |
| 190 volume->SetOutputVolumePan(channel_, 1, 0); | 191 volume->SetOutputVolumePan(channel_, 1, 0); |
| 191 } else if (pan == PanRight) { | 192 } else if (pan == PanRight) { |
| 192 volume->SetOutputVolumePan(channel_, 0, 1); | 193 volume->SetOutputVolumePan(channel_, 0, 1); |
| 193 } | 194 } |
| 194 if (filename != "") { | 195 if (filename != "") { |
| 195 printf("playing file\n"); | 196 printf("playing file\n"); |
| 196 CHECK_EQ( | 197 RTC_CHECK_EQ( |
| 197 0, file->StartPlayingFileLocally(channel_, filename.c_str(), true, | 198 0, file->StartPlayingFileLocally(channel_, filename.c_str(), true, |
| 198 kFileFormatPcm16kHzFile, 1.0, 0, 0)); | 199 kFileFormatPcm16kHzFile, 1.0, 0, 0)); |
| 199 } | 200 } |
| 200 CHECK_EQ(0, base_->StartReceive(channel_)); | 201 RTC_CHECK_EQ(0, base_->StartReceive(channel_)); |
| 201 CHECK_EQ(0, base_->StartPlayout(channel_)); | 202 RTC_CHECK_EQ(0, base_->StartPlayout(channel_)); |
| 202 volume->Release(); | 203 volume->Release(); |
| 203 file->Release(); | 204 file->Release(); |
| 204 } | 205 } |
| 205 | 206 |
| 206 void Stop() { | 207 void Stop() { |
| 207 CHECK_EQ(0, base_->StopSend(channel_)); | 208 RTC_CHECK_EQ(0, base_->StopSend(channel_)); |
| 208 CHECK_EQ(0, base_->StopPlayout(channel_)); | 209 RTC_CHECK_EQ(0, base_->StopPlayout(channel_)); |
| 209 } | 210 } |
| 210 | 211 |
| 211 private: | 212 private: |
| 212 VoiceEngine* voe_; | 213 VoiceEngine* voe_; |
| 213 VoEBase* base_; | 214 VoEBase* base_; |
| 214 VoEHardware* hardware_; | 215 VoEHardware* hardware_; |
| 215 VoECodec* codec_; | 216 VoECodec* codec_; |
| 216 int channel_; | 217 int channel_; |
| 217 int capture_idx_; | 218 int capture_idx_; |
| 218 int render_idx_; | 219 int render_idx_; |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 webrtc::PrintDevices(); | 274 webrtc::PrintDevices(); |
| 274 } | 275 } |
| 275 if (FLAGS_codecs) { | 276 if (FLAGS_codecs) { |
| 276 webrtc::PrintCodecs(); | 277 webrtc::PrintCodecs(); |
| 277 } | 278 } |
| 278 if (!FLAGS_devices && !FLAGS_codecs) { | 279 if (!FLAGS_devices && !FLAGS_codecs) { |
| 279 webrtc::RunHarness(); | 280 webrtc::RunHarness(); |
| 280 } | 281 } |
| 281 return 0; | 282 return 0; |
| 282 } | 283 } |
| OLD | NEW |