OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2015 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 |
11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
12 | 12 |
13 #include "webrtc/audio/audio_send_stream.h" | 13 #include "webrtc/audio/audio_send_stream.h" |
14 #include "webrtc/audio/audio_state.h" | 14 #include "webrtc/audio/audio_state.h" |
15 #include "webrtc/audio/conversion.h" | 15 #include "webrtc/audio/conversion.h" |
| 16 #include "webrtc/test/mock_voe_channel_proxy.h" |
16 #include "webrtc/test/mock_voice_engine.h" | 17 #include "webrtc/test/mock_voice_engine.h" |
17 | 18 |
18 namespace webrtc { | 19 namespace webrtc { |
19 namespace test { | 20 namespace test { |
20 namespace { | 21 namespace { |
21 | 22 |
22 using testing::_; | 23 using testing::_; |
23 using testing::Return; | 24 using testing::Return; |
24 | 25 |
25 const int kChannelId = 1; | 26 const int kChannelId = 1; |
26 const uint32_t kSsrc = 1234; | 27 const uint32_t kSsrc = 1234; |
27 const char* kCName = "foo_name"; | 28 const char* kCName = "foo_name"; |
28 const int kAudioLevelId = 2; | 29 const int kAudioLevelId = 2; |
29 const int kAbsSendTimeId = 3; | 30 const int kAbsSendTimeId = 3; |
30 const int kEchoDelayMedian = 254; | 31 const int kEchoDelayMedian = 254; |
31 const int kEchoDelayStdDev = -3; | 32 const int kEchoDelayStdDev = -3; |
32 const int kEchoReturnLoss = -65; | 33 const int kEchoReturnLoss = -65; |
33 const int kEchoReturnLossEnhancement = 101; | 34 const int kEchoReturnLossEnhancement = 101; |
34 const unsigned int kSpeechInputLevel = 96; | 35 const unsigned int kSpeechInputLevel = 96; |
35 const CallStatistics kCallStats = { | 36 const CallStatistics kCallStats = { |
36 1345, 1678, 1901, 1234, 112, 13456, 17890, 1567, -1890, -1123}; | 37 1345, 1678, 1901, 1234, 112, 13456, 17890, 1567, -1890, -1123}; |
37 const CodecInst kCodecInst = {-121, "codec_name_send", 48000, -231, -451, -671}; | 38 const CodecInst kCodecInst = {-121, "codec_name_send", 48000, -231, -451, -671}; |
38 const ReportBlock kReportBlock = {456, 780, 123, 567, 890, 132, 143, 13354}; | 39 const ReportBlock kReportBlock = {456, 780, 123, 567, 890, 132, 143, 13354}; |
39 | 40 |
40 struct ConfigHelper { | 41 struct ConfigHelper { |
41 ConfigHelper() : stream_config_(nullptr) { | 42 ConfigHelper() : stream_config_(nullptr) { |
| 43 using testing::Invoke; |
42 using testing::StrEq; | 44 using testing::StrEq; |
43 | 45 |
44 EXPECT_CALL(voice_engine_, | 46 EXPECT_CALL(voice_engine_, |
45 RegisterVoiceEngineObserver(_)).WillOnce(Return(0)); | 47 RegisterVoiceEngineObserver(_)).WillOnce(Return(0)); |
46 EXPECT_CALL(voice_engine_, | 48 EXPECT_CALL(voice_engine_, |
47 DeRegisterVoiceEngineObserver()).WillOnce(Return(0)); | 49 DeRegisterVoiceEngineObserver()).WillOnce(Return(0)); |
48 AudioState::Config config; | 50 AudioState::Config config; |
49 config.voice_engine = &voice_engine_; | 51 config.voice_engine = &voice_engine_; |
50 audio_state_ = AudioState::Create(config); | 52 audio_state_ = AudioState::Create(config); |
51 | 53 |
52 EXPECT_CALL(voice_engine_, SetRTCPStatus(kChannelId, true)) | 54 EXPECT_CALL(voice_engine_, ChannelProxyFactory(kChannelId)) |
53 .WillOnce(Return(0)); | 55 .WillOnce(Invoke([this](int channel_id) { |
54 EXPECT_CALL(voice_engine_, SetLocalSSRC(kChannelId, kSsrc)) | 56 EXPECT_FALSE(channel_proxy_); |
55 .WillOnce(Return(0)); | 57 channel_proxy_ = new testing::StrictMock<MockVoEChannelProxy>(); |
56 EXPECT_CALL(voice_engine_, SetRTCP_CNAME(kChannelId, StrEq(kCName))) | 58 EXPECT_CALL(*channel_proxy_, SetRTCPStatus(true)).Times(1); |
57 .WillOnce(Return(0)); | 59 EXPECT_CALL(*channel_proxy_, SetLocalSSRC(kSsrc)).Times(1); |
| 60 EXPECT_CALL(*channel_proxy_, SetRTCP_CNAME(StrEq(kCName))).Times(1); |
| 61 return channel_proxy_; |
| 62 })); |
58 EXPECT_CALL(voice_engine_, | 63 EXPECT_CALL(voice_engine_, |
59 SetSendAbsoluteSenderTimeStatus(kChannelId, true, kAbsSendTimeId)) | 64 SetSendAbsoluteSenderTimeStatus(kChannelId, true, kAbsSendTimeId)) |
60 .WillOnce(Return(0)); | 65 .WillOnce(Return(0)); |
61 EXPECT_CALL(voice_engine_, | 66 EXPECT_CALL(voice_engine_, |
62 SetSendAudioLevelIndicationStatus(kChannelId, true, kAudioLevelId)) | 67 SetSendAudioLevelIndicationStatus(kChannelId, true, kAudioLevelId)) |
63 .WillOnce(Return(0)); | 68 .WillOnce(Return(0)); |
64 stream_config_.voe_channel_id = kChannelId; | 69 stream_config_.voe_channel_id = kChannelId; |
65 stream_config_.rtp.ssrc = kSsrc; | 70 stream_config_.rtp.ssrc = kSsrc; |
66 stream_config_.rtp.c_name = kCName; | 71 stream_config_.rtp.c_name = kCName; |
67 stream_config_.rtp.extensions.push_back( | 72 stream_config_.rtp.extensions.push_back( |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 Return(0))); | 107 Return(0))); |
103 EXPECT_CALL(voice_engine_, GetEcDelayMetrics(_, _, _)) | 108 EXPECT_CALL(voice_engine_, GetEcDelayMetrics(_, _, _)) |
104 .WillRepeatedly(DoAll(SetArgReferee<0>(kEchoDelayMedian), | 109 .WillRepeatedly(DoAll(SetArgReferee<0>(kEchoDelayMedian), |
105 SetArgReferee<1>(kEchoDelayStdDev), Return(0))); | 110 SetArgReferee<1>(kEchoDelayStdDev), Return(0))); |
106 } | 111 } |
107 | 112 |
108 private: | 113 private: |
109 testing::StrictMock<MockVoiceEngine> voice_engine_; | 114 testing::StrictMock<MockVoiceEngine> voice_engine_; |
110 rtc::scoped_refptr<AudioState> audio_state_; | 115 rtc::scoped_refptr<AudioState> audio_state_; |
111 AudioSendStream::Config stream_config_; | 116 AudioSendStream::Config stream_config_; |
| 117 testing::StrictMock<MockVoEChannelProxy>* channel_proxy_ = nullptr; |
112 }; | 118 }; |
113 } // namespace | 119 } // namespace |
114 | 120 |
115 TEST(AudioSendStreamTest, ConfigToString) { | 121 TEST(AudioSendStreamTest, ConfigToString) { |
116 AudioSendStream::Config config(nullptr); | 122 AudioSendStream::Config config(nullptr); |
117 config.rtp.ssrc = kSsrc; | 123 config.rtp.ssrc = kSsrc; |
118 config.rtp.extensions.push_back( | 124 config.rtp.extensions.push_back( |
119 RtpExtension(RtpExtension::kAbsSendTime, kAbsSendTimeId)); | 125 RtpExtension(RtpExtension::kAbsSendTime, kAbsSendTimeId)); |
120 config.rtp.c_name = kCName; | 126 config.rtp.c_name = kCName; |
121 config.voe_channel_id = kChannelId; | 127 config.voe_channel_id = kChannelId; |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 static_cast<internal::AudioState*>(helper.audio_state().get()); | 177 static_cast<internal::AudioState*>(helper.audio_state().get()); |
172 VoiceEngineObserver* voe_observer = | 178 VoiceEngineObserver* voe_observer = |
173 static_cast<VoiceEngineObserver*>(internal_audio_state); | 179 static_cast<VoiceEngineObserver*>(internal_audio_state); |
174 voe_observer->CallbackOnError(-1, VE_TYPING_NOISE_WARNING); | 180 voe_observer->CallbackOnError(-1, VE_TYPING_NOISE_WARNING); |
175 EXPECT_TRUE(send_stream.GetStats().typing_noise_detected); | 181 EXPECT_TRUE(send_stream.GetStats().typing_noise_detected); |
176 voe_observer->CallbackOnError(-1, VE_TYPING_NOISE_OFF_WARNING); | 182 voe_observer->CallbackOnError(-1, VE_TYPING_NOISE_OFF_WARNING); |
177 EXPECT_FALSE(send_stream.GetStats().typing_noise_detected); | 183 EXPECT_FALSE(send_stream.GetStats().typing_noise_detected); |
178 } | 184 } |
179 } // namespace test | 185 } // namespace test |
180 } // namespace webrtc | 186 } // namespace webrtc |
OLD | NEW |