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/conversion.h" |
| 15 #include "webrtc/test/fake_voice_engine.h" |
14 | 16 |
15 namespace webrtc { | 17 namespace webrtc { |
| 18 namespace test { |
16 | 19 |
17 TEST(AudioSendStreamTest, ConfigToString) { | 20 TEST(AudioSendStreamTest, ConfigToString) { |
18 const int kAbsSendTimeId = 3; | 21 const int kAbsSendTimeId = 3; |
19 AudioSendStream::Config config(nullptr); | 22 AudioSendStream::Config config(nullptr); |
20 config.rtp.ssrc = 1234; | 23 config.rtp.ssrc = 1234; |
21 config.rtp.extensions.push_back( | 24 config.rtp.extensions.push_back( |
22 RtpExtension(RtpExtension::kAbsSendTime, kAbsSendTimeId)); | 25 RtpExtension(RtpExtension::kAbsSendTime, kAbsSendTimeId)); |
23 config.voe_channel_id = 1; | 26 config.voe_channel_id = 1; |
24 config.cng_payload_type = 42; | 27 config.cng_payload_type = 42; |
25 config.red_payload_type = 17; | 28 config.red_payload_type = 17; |
26 EXPECT_GT(config.ToString().size(), 0u); | 29 EXPECT_GT(config.ToString().size(), 0u); |
27 } | 30 } |
28 | 31 |
29 TEST(AudioSendStreamTest, ConstructDestruct) { | 32 TEST(AudioSendStreamTest, ConstructDestruct) { |
| 33 FakeVoiceEngine voice_engine; |
30 AudioSendStream::Config config(nullptr); | 34 AudioSendStream::Config config(nullptr); |
31 config.voe_channel_id = 1; | 35 config.voe_channel_id = 1; |
32 internal::AudioSendStream send_stream(config); | 36 internal::AudioSendStream send_stream(config, &voice_engine); |
33 } | 37 } |
| 38 |
| 39 TEST(AudioSendStreamTest, GetStats) { |
| 40 FakeVoiceEngine voice_engine; |
| 41 AudioSendStream::Config config(nullptr); |
| 42 config.rtp.ssrc = FakeVoiceEngine::kSendSsrc; |
| 43 config.voe_channel_id = FakeVoiceEngine::kSendChannelId; |
| 44 internal::AudioSendStream send_stream(config, &voice_engine); |
| 45 |
| 46 AudioSendStream::Stats stats = send_stream.GetStats(); |
| 47 const CallStatistics& call_stats = FakeVoiceEngine::kSendCallStats; |
| 48 const CodecInst& codec_inst = FakeVoiceEngine::kSendCodecInst; |
| 49 const ReportBlock& report_block = FakeVoiceEngine::kSendReportBlock; |
| 50 EXPECT_EQ(FakeVoiceEngine::kSendSsrc, stats.local_ssrc); |
| 51 EXPECT_EQ(static_cast<int64_t>(call_stats.bytesSent), stats.bytes_sent); |
| 52 EXPECT_EQ(call_stats.packetsSent, stats.packets_sent); |
| 53 EXPECT_EQ(static_cast<int32_t>(report_block.cumulative_num_packets_lost), |
| 54 stats.packets_lost); |
| 55 EXPECT_EQ(Q8ToFloat(report_block.fraction_lost), stats.fraction_lost); |
| 56 EXPECT_EQ(std::string(codec_inst.plname), stats.codec_name); |
| 57 EXPECT_EQ(static_cast<int32_t>(report_block.extended_highest_sequence_number), |
| 58 stats.ext_seqnum); |
| 59 EXPECT_EQ(static_cast<int32_t>(report_block.interarrival_jitter / |
| 60 (codec_inst.plfreq / 1000)), stats.jitter_ms); |
| 61 EXPECT_EQ(call_stats.rttMs, stats.rtt_ms); |
| 62 EXPECT_EQ(static_cast<int32_t>(FakeVoiceEngine::kSendSpeechInputLevel), |
| 63 stats.audio_level); |
| 64 EXPECT_EQ(-1, stats.aec_quality_min); |
| 65 EXPECT_EQ(FakeVoiceEngine::kSendEchoDelayMedian, stats.echo_delay_median_ms); |
| 66 EXPECT_EQ(FakeVoiceEngine::kSendEchoDelayStdDev, stats.echo_delay_std_ms); |
| 67 EXPECT_EQ(FakeVoiceEngine::kSendEchoReturnLoss, stats.echo_return_loss); |
| 68 EXPECT_EQ(FakeVoiceEngine::kSendEchoReturnLossEnhancement, |
| 69 stats.echo_return_loss_enhancement); |
| 70 EXPECT_EQ(false, stats.typing_noise_detected); |
| 71 } |
| 72 } // namespace test |
34 } // namespace webrtc | 73 } // namespace webrtc |
OLD | NEW |