OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2008 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2008 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
56 engine) { // volume | 56 engine) { // volume |
57 } | 57 } |
58 }; | 58 }; |
59 } // namespace | 59 } // namespace |
60 | 60 |
61 class FakeAudioSink : public webrtc::AudioSinkInterface { | 61 class FakeAudioSink : public webrtc::AudioSinkInterface { |
62 public: | 62 public: |
63 void OnData(const Data& audio) override {} | 63 void OnData(const Data& audio) override {} |
64 }; | 64 }; |
65 | 65 |
66 class FakeAudioRenderer : public cricket::AudioRenderer {}; | |
67 | |
66 class WebRtcVoiceEngineTestFake : public testing::Test { | 68 class WebRtcVoiceEngineTestFake : public testing::Test { |
67 public: | 69 public: |
68 WebRtcVoiceEngineTestFake() : WebRtcVoiceEngineTestFake("") {} | 70 WebRtcVoiceEngineTestFake() : WebRtcVoiceEngineTestFake("") {} |
69 | 71 |
70 explicit WebRtcVoiceEngineTestFake(const char* field_trials) | 72 explicit WebRtcVoiceEngineTestFake(const char* field_trials) |
71 : call_(webrtc::Call::Config()), | 73 : call_(webrtc::Call::Config()), |
72 engine_(new FakeVoEWrapper(&voe_)), | 74 engine_(new FakeVoEWrapper(&voe_)), |
73 channel_(nullptr), | 75 channel_(nullptr), |
76 fake_renderer_(new FakeAudioRenderer()), | |
74 override_field_trials_(field_trials) { | 77 override_field_trials_(field_trials) { |
75 send_parameters_.codecs.push_back(kPcmuCodec); | 78 send_parameters_.codecs.push_back(kPcmuCodec); |
76 recv_parameters_.codecs.push_back(kPcmuCodec); | 79 recv_parameters_.codecs.push_back(kPcmuCodec); |
77 } | 80 } |
78 bool SetupEngine() { | 81 bool SetupEngine() { |
79 if (!engine_.Init(rtc::Thread::Current())) { | 82 if (!engine_.Init(rtc::Thread::Current())) { |
80 return false; | 83 return false; |
81 } | 84 } |
82 channel_ = engine_.CreateChannel(&call_, cricket::MediaConfig(), | 85 channel_ = engine_.CreateChannel(&call_, cricket::MediaConfig(), |
83 cricket::AudioOptions()); | 86 cricket::AudioOptions()); |
84 return (channel_ != nullptr); | 87 return (channel_ != nullptr); |
85 } | 88 } |
86 bool SetupEngineWithRecvStream() { | 89 bool SetupEngineWithRecvStream() { |
87 if (!SetupEngine()) { | 90 if (!SetupEngine()) { |
88 return false; | 91 return false; |
89 } | 92 } |
90 return channel_->AddRecvStream( | 93 return channel_->AddRecvStream( |
91 cricket::StreamParams::CreateLegacy(kSsrc1)); | 94 cricket::StreamParams::CreateLegacy(kSsrc1)); |
92 } | 95 } |
93 bool SetupEngineWithSendStream() { | 96 bool SetupEngineWithSendStream() { |
94 if (!SetupEngine()) { | 97 if (!SetupEngine()) { |
95 return false; | 98 return false; |
96 } | 99 } |
97 return channel_->AddSendStream( | 100 if (!channel_->AddSendStream(cricket::StreamParams::CreateLegacy(kSsrc1))) { |
98 cricket::StreamParams::CreateLegacy(kSsrc1)); | 101 return false; |
102 } | |
103 return channel_->SetAudioSend(kSsrc1, true, nullptr, fake_renderer_.get()); | |
99 } | 104 } |
100 void SetupForMultiSendStream() { | 105 void SetupForMultiSendStream() { |
101 EXPECT_TRUE(SetupEngineWithSendStream()); | 106 EXPECT_TRUE(SetupEngineWithSendStream()); |
102 // Remove stream added in Setup. | 107 // Remove stream added in Setup. |
103 EXPECT_TRUE(call_.GetAudioSendStream(kSsrc1)); | 108 EXPECT_TRUE(call_.GetAudioSendStream(kSsrc1)); |
104 EXPECT_TRUE(channel_->RemoveSendStream(kSsrc1)); | 109 EXPECT_TRUE(channel_->RemoveSendStream(kSsrc1)); |
105 // Verify the channel does not exist. | 110 // Verify the channel does not exist. |
106 EXPECT_FALSE(call_.GetAudioSendStream(kSsrc1)); | 111 EXPECT_FALSE(call_.GetAudioSendStream(kSsrc1)); |
107 } | 112 } |
108 void DeliverPacket(const void* data, int len) { | 113 void DeliverPacket(const void* data, int len) { |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
394 EXPECT_EQ(info.capture_start_ntp_time_ms, stats.capture_start_ntp_time_ms); | 399 EXPECT_EQ(info.capture_start_ntp_time_ms, stats.capture_start_ntp_time_ms); |
395 } | 400 } |
396 | 401 |
397 protected: | 402 protected: |
398 cricket::FakeCall call_; | 403 cricket::FakeCall call_; |
399 cricket::FakeWebRtcVoiceEngine voe_; | 404 cricket::FakeWebRtcVoiceEngine voe_; |
400 cricket::WebRtcVoiceEngine engine_; | 405 cricket::WebRtcVoiceEngine engine_; |
401 cricket::VoiceMediaChannel* channel_; | 406 cricket::VoiceMediaChannel* channel_; |
402 cricket::AudioSendParameters send_parameters_; | 407 cricket::AudioSendParameters send_parameters_; |
403 cricket::AudioRecvParameters recv_parameters_; | 408 cricket::AudioRecvParameters recv_parameters_; |
409 rtc::scoped_ptr<FakeAudioRenderer> fake_renderer_; | |
pthatcher1
2016/03/02 22:18:40
fake_source would be more clear here as well.
Taylor Brandstetter
2016/03/03 00:45:03
Done.
| |
404 | 410 |
405 private: | 411 private: |
406 webrtc::test::ScopedFieldTrials override_field_trials_; | 412 webrtc::test::ScopedFieldTrials override_field_trials_; |
407 }; | 413 }; |
408 | 414 |
409 // Tests that our stub library "works". | 415 // Tests that our stub library "works". |
410 TEST_F(WebRtcVoiceEngineTestFake, StartupShutdown) { | 416 TEST_F(WebRtcVoiceEngineTestFake, StartupShutdown) { |
411 EXPECT_FALSE(voe_.IsInited()); | 417 EXPECT_FALSE(voe_.IsInited()); |
412 EXPECT_TRUE(engine_.Init(rtc::Thread::Current())); | 418 EXPECT_TRUE(engine_.Init(rtc::Thread::Current())); |
413 EXPECT_TRUE(voe_.IsInited()); | 419 EXPECT_TRUE(voe_.IsInited()); |
(...skipping 1609 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2023 // Test that we can add and remove send streams. | 2029 // Test that we can add and remove send streams. |
2024 TEST_F(WebRtcVoiceEngineTestFake, CreateAndDeleteMultipleSendStreams) { | 2030 TEST_F(WebRtcVoiceEngineTestFake, CreateAndDeleteMultipleSendStreams) { |
2025 SetupForMultiSendStream(); | 2031 SetupForMultiSendStream(); |
2026 | 2032 |
2027 // Set the global state for sending. | 2033 // Set the global state for sending. |
2028 EXPECT_TRUE(channel_->SetSend(cricket::SEND_MICROPHONE)); | 2034 EXPECT_TRUE(channel_->SetSend(cricket::SEND_MICROPHONE)); |
2029 | 2035 |
2030 for (uint32_t ssrc : kSsrcs4) { | 2036 for (uint32_t ssrc : kSsrcs4) { |
2031 EXPECT_TRUE(channel_->AddSendStream( | 2037 EXPECT_TRUE(channel_->AddSendStream( |
2032 cricket::StreamParams::CreateLegacy(ssrc))); | 2038 cricket::StreamParams::CreateLegacy(ssrc))); |
2039 EXPECT_TRUE( | |
2040 channel_->SetAudioSend(ssrc, true, nullptr, fake_renderer_.get())); | |
2033 // Verify that we are in a sending state for all the created streams. | 2041 // Verify that we are in a sending state for all the created streams. |
2034 EXPECT_TRUE(voe_.GetSend(GetSendStreamConfig(ssrc).voe_channel_id)); | 2042 EXPECT_TRUE(voe_.GetSend(GetSendStreamConfig(ssrc).voe_channel_id)); |
2035 } | 2043 } |
2036 EXPECT_EQ(arraysize(kSsrcs4), call_.GetAudioSendStreams().size()); | 2044 EXPECT_EQ(arraysize(kSsrcs4), call_.GetAudioSendStreams().size()); |
2037 | 2045 |
2038 // Delete the send streams. | 2046 // Delete the send streams. |
2039 for (uint32_t ssrc : kSsrcs4) { | 2047 for (uint32_t ssrc : kSsrcs4) { |
2040 EXPECT_TRUE(channel_->RemoveSendStream(ssrc)); | 2048 EXPECT_TRUE(channel_->RemoveSendStream(ssrc)); |
2041 EXPECT_FALSE(call_.GetAudioSendStream(ssrc)); | 2049 EXPECT_FALSE(call_.GetAudioSendStream(ssrc)); |
2042 EXPECT_FALSE(channel_->RemoveSendStream(ssrc)); | 2050 EXPECT_FALSE(channel_->RemoveSendStream(ssrc)); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2083 } | 2091 } |
2084 | 2092 |
2085 // Test we can SetSend on all send streams correctly. | 2093 // Test we can SetSend on all send streams correctly. |
2086 TEST_F(WebRtcVoiceEngineTestFake, SetSendWithMultipleSendStreams) { | 2094 TEST_F(WebRtcVoiceEngineTestFake, SetSendWithMultipleSendStreams) { |
2087 SetupForMultiSendStream(); | 2095 SetupForMultiSendStream(); |
2088 | 2096 |
2089 // Create the send channels and they should be a SEND_NOTHING date. | 2097 // Create the send channels and they should be a SEND_NOTHING date. |
2090 for (uint32_t ssrc : kSsrcs4) { | 2098 for (uint32_t ssrc : kSsrcs4) { |
2091 EXPECT_TRUE(channel_->AddSendStream( | 2099 EXPECT_TRUE(channel_->AddSendStream( |
2092 cricket::StreamParams::CreateLegacy(ssrc))); | 2100 cricket::StreamParams::CreateLegacy(ssrc))); |
2101 EXPECT_TRUE( | |
2102 channel_->SetAudioSend(ssrc, true, nullptr, fake_renderer_.get())); | |
2093 int channel_num = voe_.GetLastChannel(); | 2103 int channel_num = voe_.GetLastChannel(); |
2094 EXPECT_FALSE(voe_.GetSend(channel_num)); | 2104 EXPECT_FALSE(voe_.GetSend(channel_num)); |
2095 } | 2105 } |
2096 | 2106 |
2097 // Set the global state for starting sending. | 2107 // Set the global state for starting sending. |
2098 EXPECT_TRUE(channel_->SetSend(cricket::SEND_MICROPHONE)); | 2108 EXPECT_TRUE(channel_->SetSend(cricket::SEND_MICROPHONE)); |
2099 for (uint32_t ssrc : kSsrcs4) { | 2109 for (uint32_t ssrc : kSsrcs4) { |
2100 // Verify that we are in a sending state for all the send streams. | 2110 // Verify that we are in a sending state for all the send streams. |
2101 int channel_num = GetSendStreamConfig(ssrc).voe_channel_id; | 2111 int channel_num = GetSendStreamConfig(ssrc).voe_channel_id; |
2102 EXPECT_TRUE(voe_.GetSend(channel_num)); | 2112 EXPECT_TRUE(voe_.GetSend(channel_num)); |
(...skipping 1189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3292 cricket::WebRtcVoiceEngine engine; | 3302 cricket::WebRtcVoiceEngine engine; |
3293 EXPECT_TRUE(engine.Init(rtc::Thread::Current())); | 3303 EXPECT_TRUE(engine.Init(rtc::Thread::Current())); |
3294 std::unique_ptr<webrtc::Call> call( | 3304 std::unique_ptr<webrtc::Call> call( |
3295 webrtc::Call::Create(webrtc::Call::Config())); | 3305 webrtc::Call::Create(webrtc::Call::Config())); |
3296 cricket::WebRtcVoiceMediaChannel channel(&engine, cricket::MediaConfig(), | 3306 cricket::WebRtcVoiceMediaChannel channel(&engine, cricket::MediaConfig(), |
3297 cricket::AudioOptions(), call.get()); | 3307 cricket::AudioOptions(), call.get()); |
3298 cricket::AudioRecvParameters parameters; | 3308 cricket::AudioRecvParameters parameters; |
3299 parameters.codecs = engine.codecs(); | 3309 parameters.codecs = engine.codecs(); |
3300 EXPECT_TRUE(channel.SetRecvParameters(parameters)); | 3310 EXPECT_TRUE(channel.SetRecvParameters(parameters)); |
3301 } | 3311 } |
OLD | NEW |