OLD | NEW |
| (Empty) |
1 /* | |
2 * Copyright (c) 2014 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 #include "webrtc/test/testsupport/fileutils.h" | |
12 #include "webrtc/voice_engine/test/auto_test/fixtures/before_streaming_fixture.h
" | |
13 | |
14 BeforeStreamingFixture::BeforeStreamingFixture() | |
15 : channel_(voe_base_->CreateChannel()), | |
16 transport_(NULL) { | |
17 EXPECT_GE(channel_, 0); | |
18 | |
19 fake_microphone_input_file_ = | |
20 webrtc::test::ResourcePath("voice_engine/audio_long16", "pcm"); | |
21 | |
22 SetUpLocalPlayback(); | |
23 RestartFakeMicrophone(); | |
24 } | |
25 | |
26 BeforeStreamingFixture::~BeforeStreamingFixture() { | |
27 voe_file_->StopPlayingFileAsMicrophone(channel_); | |
28 PausePlaying(); | |
29 | |
30 EXPECT_EQ(0, voe_network_->DeRegisterExternalTransport(channel_)); | |
31 voe_base_->DeleteChannel(channel_); | |
32 delete transport_; | |
33 } | |
34 | |
35 void BeforeStreamingFixture::SwitchToManualMicrophone() { | |
36 EXPECT_EQ(0, voe_file_->StopPlayingFileAsMicrophone(channel_)); | |
37 | |
38 TEST_LOG("You need to speak manually into the microphone for this test.\n"); | |
39 TEST_LOG("Please start speaking now.\n"); | |
40 Sleep(1000); | |
41 } | |
42 | |
43 void BeforeStreamingFixture::RestartFakeMicrophone() { | |
44 EXPECT_EQ(0, voe_file_->StartPlayingFileAsMicrophone( | |
45 channel_, fake_microphone_input_file_.c_str(), true, true)); | |
46 } | |
47 | |
48 void BeforeStreamingFixture::PausePlaying() { | |
49 EXPECT_EQ(0, voe_base_->StopSend(channel_)); | |
50 EXPECT_EQ(0, voe_base_->StopPlayout(channel_)); | |
51 } | |
52 | |
53 void BeforeStreamingFixture::ResumePlaying() { | |
54 EXPECT_EQ(0, voe_base_->StartPlayout(channel_)); | |
55 EXPECT_EQ(0, voe_base_->StartSend(channel_)); | |
56 } | |
57 | |
58 void BeforeStreamingFixture::WaitForTransmittedPackets(int32_t packet_count) { | |
59 transport_->WaitForTransmittedPackets(packet_count); | |
60 } | |
61 | |
62 void BeforeStreamingFixture::SetUpLocalPlayback() { | |
63 transport_ = new LoopBackTransport(voe_network_, channel_); | |
64 EXPECT_EQ(0, voe_network_->RegisterExternalTransport(channel_, *transport_)); | |
65 | |
66 webrtc::CodecInst codec; | |
67 codec.channels = 1; | |
68 codec.pacsize = 160; | |
69 codec.plfreq = 8000; | |
70 codec.pltype = 0; | |
71 codec.rate = 64000; | |
72 #if defined(_MSC_VER) && defined(_WIN32) | |
73 _snprintf(codec.plname, RTP_PAYLOAD_NAME_SIZE - 1, "PCMU"); | |
74 #else | |
75 snprintf(codec.plname, RTP_PAYLOAD_NAME_SIZE, "PCMU"); | |
76 #endif | |
77 voe_codec_->SetSendCodec(channel_, codec); | |
78 } | |
OLD | NEW |