| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | |
| 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 | |
| 11 // Sets up a simple VoiceEngine loopback call with the default audio devices | |
| 12 // and runs forever. Some parameters can be configured through command-line | |
| 13 // flags. | |
| 14 | |
| 15 #include <memory> | |
| 16 | |
| 17 #include "gflags/gflags.h" | |
| 18 #include "testing/gtest/include/gtest/gtest.h" | |
| 19 | |
| 20 #include "webrtc/test/channel_transport/channel_transport.h" | |
| 21 #include "webrtc/voice_engine/include/voe_audio_processing.h" | |
| 22 #include "webrtc/voice_engine/include/voe_base.h" | |
| 23 #include "webrtc/voice_engine/include/voe_codec.h" | |
| 24 #include "webrtc/voice_engine/include/voe_hardware.h" | |
| 25 #include "webrtc/voice_engine/include/voe_network.h" | |
| 26 | |
| 27 DEFINE_string(render, "render", "render device name"); | |
| 28 DEFINE_string(codec, "ISAC", "codec name"); | |
| 29 DEFINE_int32(rate, 16000, "codec sample rate in Hz"); | |
| 30 | |
| 31 namespace webrtc { | |
| 32 namespace test { | |
| 33 | |
| 34 void RunHarness() { | |
| 35 VoiceEngine* voe = VoiceEngine::Create(); | |
| 36 ASSERT_TRUE(voe != NULL); | |
| 37 VoEAudioProcessing* audio = VoEAudioProcessing::GetInterface(voe); | |
| 38 ASSERT_TRUE(audio != NULL); | |
| 39 VoEBase* base = VoEBase::GetInterface(voe); | |
| 40 ASSERT_TRUE(base != NULL); | |
| 41 VoECodec* codec = VoECodec::GetInterface(voe); | |
| 42 ASSERT_TRUE(codec != NULL); | |
| 43 VoEHardware* hardware = VoEHardware::GetInterface(voe); | |
| 44 ASSERT_TRUE(hardware != NULL); | |
| 45 VoENetwork* network = VoENetwork::GetInterface(voe); | |
| 46 ASSERT_TRUE(network != NULL); | |
| 47 | |
| 48 ASSERT_EQ(0, base->Init()); | |
| 49 int channel = base->CreateChannel(); | |
| 50 ASSERT_NE(-1, channel); | |
| 51 | |
| 52 std::unique_ptr<VoiceChannelTransport> voice_channel_transport( | |
| 53 new VoiceChannelTransport(network, channel)); | |
| 54 | |
| 55 ASSERT_EQ(0, voice_channel_transport->SetSendDestination("127.0.0.1", 1234)); | |
| 56 ASSERT_EQ(0, voice_channel_transport->SetLocalReceiver(1234)); | |
| 57 | |
| 58 CodecInst codec_params = {0}; | |
| 59 bool codec_found = false; | |
| 60 for (int i = 0; i < codec->NumOfCodecs(); i++) { | |
| 61 ASSERT_EQ(0, codec->GetCodec(i, codec_params)); | |
| 62 if (FLAGS_codec.compare(codec_params.plname) == 0 && | |
| 63 FLAGS_rate == codec_params.plfreq) { | |
| 64 codec_found = true; | |
| 65 break; | |
| 66 } | |
| 67 } | |
| 68 ASSERT_TRUE(codec_found); | |
| 69 ASSERT_EQ(0, codec->SetSendCodec(channel, codec_params)); | |
| 70 | |
| 71 int num_devices = 0; | |
| 72 ASSERT_EQ(0, hardware->GetNumOfPlayoutDevices(num_devices)); | |
| 73 char device_name[128] = {0}; | |
| 74 char guid[128] = {0}; | |
| 75 bool device_found = false; | |
| 76 int device_index; | |
| 77 for (device_index = 0; device_index < num_devices; device_index++) { | |
| 78 ASSERT_EQ(0, hardware->GetPlayoutDeviceName(device_index, device_name, | |
| 79 guid)); | |
| 80 if (FLAGS_render.compare(device_name) == 0) { | |
| 81 device_found = true; | |
| 82 break; | |
| 83 } | |
| 84 } | |
| 85 ASSERT_TRUE(device_found); | |
| 86 ASSERT_EQ(0, hardware->SetPlayoutDevice(device_index)); | |
| 87 | |
| 88 // Disable all audio processing. | |
| 89 ASSERT_EQ(0, audio->SetAgcStatus(false)); | |
| 90 ASSERT_EQ(0, audio->SetEcStatus(false)); | |
| 91 ASSERT_EQ(0, audio->EnableHighPassFilter(false)); | |
| 92 ASSERT_EQ(0, audio->SetNsStatus(false)); | |
| 93 | |
| 94 ASSERT_EQ(0, base->StartReceive(channel)); | |
| 95 ASSERT_EQ(0, base->StartPlayout(channel)); | |
| 96 ASSERT_EQ(0, base->StartSend(channel)); | |
| 97 | |
| 98 // Run forever... | |
| 99 while (1) { | |
| 100 } | |
| 101 } | |
| 102 | |
| 103 } // namespace test | |
| 104 } // namespace webrtc | |
| 105 | |
| 106 int main(int argc, char** argv) { | |
| 107 google::ParseCommandLineFlags(&argc, &argv, true); | |
| 108 webrtc::test::RunHarness(); | |
| 109 } | |
| OLD | NEW |