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 |
(...skipping 22 matching lines...) Expand all Loading... |
33 const int kAbsSendTimeId = 3; | 33 const int kAbsSendTimeId = 3; |
34 const int kEchoDelayMedian = 254; | 34 const int kEchoDelayMedian = 254; |
35 const int kEchoDelayStdDev = -3; | 35 const int kEchoDelayStdDev = -3; |
36 const int kEchoReturnLoss = -65; | 36 const int kEchoReturnLoss = -65; |
37 const int kEchoReturnLossEnhancement = 101; | 37 const int kEchoReturnLossEnhancement = 101; |
38 const unsigned int kSpeechInputLevel = 96; | 38 const unsigned int kSpeechInputLevel = 96; |
39 const CallStatistics kCallStats = { | 39 const CallStatistics kCallStats = { |
40 1345, 1678, 1901, 1234, 112, 13456, 17890, 1567, -1890, -1123}; | 40 1345, 1678, 1901, 1234, 112, 13456, 17890, 1567, -1890, -1123}; |
41 const CodecInst kCodecInst = {-121, "codec_name_send", 48000, -231, -451, -671}; | 41 const CodecInst kCodecInst = {-121, "codec_name_send", 48000, -231, -451, -671}; |
42 const ReportBlock kReportBlock = {456, 780, 123, 567, 890, 132, 143, 13354}; | 42 const ReportBlock kReportBlock = {456, 780, 123, 567, 890, 132, 143, 13354}; |
| 43 const int kTelephoneEventPayloadType = 123; |
| 44 const uint8_t kTelephoneEventCode = 45; |
| 45 const uint32_t kTelephoneEventDuration = 6789; |
43 | 46 |
44 struct ConfigHelper { | 47 struct ConfigHelper { |
45 ConfigHelper() : stream_config_(nullptr) { | 48 ConfigHelper() : stream_config_(nullptr) { |
46 using testing::Invoke; | 49 using testing::Invoke; |
47 using testing::StrEq; | 50 using testing::StrEq; |
48 | 51 |
49 EXPECT_CALL(voice_engine_, | 52 EXPECT_CALL(voice_engine_, |
50 RegisterVoiceEngineObserver(_)).WillOnce(Return(0)); | 53 RegisterVoiceEngineObserver(_)).WillOnce(Return(0)); |
51 EXPECT_CALL(voice_engine_, | 54 EXPECT_CALL(voice_engine_, |
52 DeRegisterVoiceEngineObserver()).WillOnce(Return(0)); | 55 DeRegisterVoiceEngineObserver()).WillOnce(Return(0)); |
(...skipping 19 matching lines...) Expand all Loading... |
72 stream_config_.rtp.c_name = kCName; | 75 stream_config_.rtp.c_name = kCName; |
73 stream_config_.rtp.extensions.push_back( | 76 stream_config_.rtp.extensions.push_back( |
74 RtpExtension(RtpExtension::kAudioLevel, kAudioLevelId)); | 77 RtpExtension(RtpExtension::kAudioLevel, kAudioLevelId)); |
75 stream_config_.rtp.extensions.push_back( | 78 stream_config_.rtp.extensions.push_back( |
76 RtpExtension(RtpExtension::kAbsSendTime, kAbsSendTimeId)); | 79 RtpExtension(RtpExtension::kAbsSendTime, kAbsSendTimeId)); |
77 } | 80 } |
78 | 81 |
79 AudioSendStream::Config& config() { return stream_config_; } | 82 AudioSendStream::Config& config() { return stream_config_; } |
80 rtc::scoped_refptr<AudioState> audio_state() { return audio_state_; } | 83 rtc::scoped_refptr<AudioState> audio_state() { return audio_state_; } |
81 | 84 |
| 85 void SetupMockForSendTelephoneEvent() { |
| 86 EXPECT_TRUE(channel_proxy_); |
| 87 EXPECT_CALL(*channel_proxy_, |
| 88 SetSendTelephoneEventPayloadType(kTelephoneEventPayloadType)) |
| 89 .WillOnce(Return(true)); |
| 90 EXPECT_CALL(*channel_proxy_, |
| 91 SendTelephoneEventOutband(kTelephoneEventCode, kTelephoneEventDuration)) |
| 92 .WillOnce(Return(true)); |
| 93 } |
| 94 |
82 void SetupMockForGetStats() { | 95 void SetupMockForGetStats() { |
83 using testing::DoAll; | 96 using testing::DoAll; |
84 using testing::SetArgReferee; | 97 using testing::SetArgReferee; |
85 | 98 |
86 std::vector<ReportBlock> report_blocks; | 99 std::vector<ReportBlock> report_blocks; |
87 webrtc::ReportBlock block = kReportBlock; | 100 webrtc::ReportBlock block = kReportBlock; |
88 report_blocks.push_back(block); // Has wrong SSRC. | 101 report_blocks.push_back(block); // Has wrong SSRC. |
89 block.source_SSRC = kSsrc; | 102 block.source_SSRC = kSsrc; |
90 report_blocks.push_back(block); // Correct block. | 103 report_blocks.push_back(block); // Correct block. |
91 block.fraction_lost = 0; | 104 block.fraction_lost = 0; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 "c_name: foo_name}, voe_channel_id: 1, cng_payload_type: 42, " | 148 "c_name: foo_name}, voe_channel_id: 1, cng_payload_type: 42, " |
136 "red_payload_type: 17}", | 149 "red_payload_type: 17}", |
137 config.ToString()); | 150 config.ToString()); |
138 } | 151 } |
139 | 152 |
140 TEST(AudioSendStreamTest, ConstructDestruct) { | 153 TEST(AudioSendStreamTest, ConstructDestruct) { |
141 ConfigHelper helper; | 154 ConfigHelper helper; |
142 internal::AudioSendStream send_stream(helper.config(), helper.audio_state()); | 155 internal::AudioSendStream send_stream(helper.config(), helper.audio_state()); |
143 } | 156 } |
144 | 157 |
| 158 TEST(AudioSendStreamTest, SendTelephoneEvent) { |
| 159 ConfigHelper helper; |
| 160 internal::AudioSendStream send_stream(helper.config(), helper.audio_state()); |
| 161 helper.SetupMockForSendTelephoneEvent(); |
| 162 EXPECT_TRUE(send_stream.SendTelephoneEvent(kTelephoneEventPayloadType, |
| 163 kTelephoneEventCode, kTelephoneEventDuration)); |
| 164 } |
| 165 |
145 TEST(AudioSendStreamTest, GetStats) { | 166 TEST(AudioSendStreamTest, GetStats) { |
146 ConfigHelper helper; | 167 ConfigHelper helper; |
147 internal::AudioSendStream send_stream(helper.config(), helper.audio_state()); | 168 internal::AudioSendStream send_stream(helper.config(), helper.audio_state()); |
148 helper.SetupMockForGetStats(); | 169 helper.SetupMockForGetStats(); |
149 AudioSendStream::Stats stats = send_stream.GetStats(); | 170 AudioSendStream::Stats stats = send_stream.GetStats(); |
150 EXPECT_EQ(kSsrc, stats.local_ssrc); | 171 EXPECT_EQ(kSsrc, stats.local_ssrc); |
151 EXPECT_EQ(static_cast<int64_t>(kCallStats.bytesSent), stats.bytes_sent); | 172 EXPECT_EQ(static_cast<int64_t>(kCallStats.bytesSent), stats.bytes_sent); |
152 EXPECT_EQ(kCallStats.packetsSent, stats.packets_sent); | 173 EXPECT_EQ(kCallStats.packetsSent, stats.packets_sent); |
153 EXPECT_EQ(static_cast<int32_t>(kReportBlock.cumulative_num_packets_lost), | 174 EXPECT_EQ(static_cast<int32_t>(kReportBlock.cumulative_num_packets_lost), |
154 stats.packets_lost); | 175 stats.packets_lost); |
(...skipping 24 matching lines...) Expand all Loading... |
179 static_cast<internal::AudioState*>(helper.audio_state().get()); | 200 static_cast<internal::AudioState*>(helper.audio_state().get()); |
180 VoiceEngineObserver* voe_observer = | 201 VoiceEngineObserver* voe_observer = |
181 static_cast<VoiceEngineObserver*>(internal_audio_state); | 202 static_cast<VoiceEngineObserver*>(internal_audio_state); |
182 voe_observer->CallbackOnError(-1, VE_TYPING_NOISE_WARNING); | 203 voe_observer->CallbackOnError(-1, VE_TYPING_NOISE_WARNING); |
183 EXPECT_TRUE(send_stream.GetStats().typing_noise_detected); | 204 EXPECT_TRUE(send_stream.GetStats().typing_noise_detected); |
184 voe_observer->CallbackOnError(-1, VE_TYPING_NOISE_OFF_WARNING); | 205 voe_observer->CallbackOnError(-1, VE_TYPING_NOISE_OFF_WARNING); |
185 EXPECT_FALSE(send_stream.GetStats().typing_noise_detected); | 206 EXPECT_FALSE(send_stream.GetStats().typing_noise_detected); |
186 } | 207 } |
187 } // namespace test | 208 } // namespace test |
188 } // namespace webrtc | 209 } // namespace webrtc |
OLD | NEW |