solenberg | c7a8b08 | 2015-10-16 14:35:07 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2015 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 "testing/gtest/include/gtest/gtest.h" |
| 12 | |
| 13 | #include "webrtc/audio/audio_send_stream.h" |
solenberg | 85a0496 | 2015-10-27 03:35:21 -0700 | [diff] [blame] | 14 | #include "webrtc/audio/conversion.h" |
| 15 | #include "webrtc/test/fake_voice_engine.h" |
solenberg | c7a8b08 | 2015-10-16 14:35:07 -0700 | [diff] [blame] | 16 | |
| 17 | namespace webrtc { |
solenberg | 85a0496 | 2015-10-27 03:35:21 -0700 | [diff] [blame] | 18 | namespace test { |
solenberg | c7a8b08 | 2015-10-16 14:35:07 -0700 | [diff] [blame] | 19 | |
| 20 | TEST(AudioSendStreamTest, ConfigToString) { |
| 21 | const int kAbsSendTimeId = 3; |
| 22 | AudioSendStream::Config config(nullptr); |
| 23 | config.rtp.ssrc = 1234; |
| 24 | config.rtp.extensions.push_back( |
| 25 | RtpExtension(RtpExtension::kAbsSendTime, kAbsSendTimeId)); |
| 26 | config.voe_channel_id = 1; |
| 27 | config.cng_payload_type = 42; |
| 28 | config.red_payload_type = 17; |
solenberg | 85a0496 | 2015-10-27 03:35:21 -0700 | [diff] [blame] | 29 | EXPECT_EQ("{rtp: {ssrc: 1234, extensions: [{name: " |
| 30 | "http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time, id: 3}]}, " |
| 31 | "voe_channel_id: 1, cng_payload_type: 42, red_payload_type: 17}", |
| 32 | config.ToString()); |
solenberg | c7a8b08 | 2015-10-16 14:35:07 -0700 | [diff] [blame] | 33 | } |
| 34 | |
| 35 | TEST(AudioSendStreamTest, ConstructDestruct) { |
solenberg | 85a0496 | 2015-10-27 03:35:21 -0700 | [diff] [blame] | 36 | FakeVoiceEngine voice_engine; |
solenberg | c7a8b08 | 2015-10-16 14:35:07 -0700 | [diff] [blame] | 37 | AudioSendStream::Config config(nullptr); |
| 38 | config.voe_channel_id = 1; |
solenberg | 85a0496 | 2015-10-27 03:35:21 -0700 | [diff] [blame] | 39 | internal::AudioSendStream send_stream(config, &voice_engine); |
solenberg | c7a8b08 | 2015-10-16 14:35:07 -0700 | [diff] [blame] | 40 | } |
solenberg | 85a0496 | 2015-10-27 03:35:21 -0700 | [diff] [blame] | 41 | |
| 42 | TEST(AudioSendStreamTest, GetStats) { |
| 43 | FakeVoiceEngine voice_engine; |
| 44 | AudioSendStream::Config config(nullptr); |
| 45 | config.rtp.ssrc = FakeVoiceEngine::kSendSsrc; |
| 46 | config.voe_channel_id = FakeVoiceEngine::kSendChannelId; |
| 47 | internal::AudioSendStream send_stream(config, &voice_engine); |
| 48 | |
| 49 | AudioSendStream::Stats stats = send_stream.GetStats(); |
| 50 | const CallStatistics& call_stats = FakeVoiceEngine::kSendCallStats; |
| 51 | const CodecInst& codec_inst = FakeVoiceEngine::kSendCodecInst; |
| 52 | const ReportBlock& report_block = FakeVoiceEngine::kSendReportBlock; |
| 53 | EXPECT_EQ(FakeVoiceEngine::kSendSsrc, stats.local_ssrc); |
| 54 | EXPECT_EQ(static_cast<int64_t>(call_stats.bytesSent), stats.bytes_sent); |
| 55 | EXPECT_EQ(call_stats.packetsSent, stats.packets_sent); |
| 56 | EXPECT_EQ(static_cast<int32_t>(report_block.cumulative_num_packets_lost), |
| 57 | stats.packets_lost); |
| 58 | EXPECT_EQ(Q8ToFloat(report_block.fraction_lost), stats.fraction_lost); |
| 59 | EXPECT_EQ(std::string(codec_inst.plname), stats.codec_name); |
| 60 | EXPECT_EQ(static_cast<int32_t>(report_block.extended_highest_sequence_number), |
| 61 | stats.ext_seqnum); |
| 62 | EXPECT_EQ(static_cast<int32_t>(report_block.interarrival_jitter / |
| 63 | (codec_inst.plfreq / 1000)), stats.jitter_ms); |
| 64 | EXPECT_EQ(call_stats.rttMs, stats.rtt_ms); |
| 65 | EXPECT_EQ(static_cast<int32_t>(FakeVoiceEngine::kSendSpeechInputLevel), |
| 66 | stats.audio_level); |
| 67 | EXPECT_EQ(-1, stats.aec_quality_min); |
| 68 | EXPECT_EQ(FakeVoiceEngine::kSendEchoDelayMedian, stats.echo_delay_median_ms); |
| 69 | EXPECT_EQ(FakeVoiceEngine::kSendEchoDelayStdDev, stats.echo_delay_std_ms); |
| 70 | EXPECT_EQ(FakeVoiceEngine::kSendEchoReturnLoss, stats.echo_return_loss); |
| 71 | EXPECT_EQ(FakeVoiceEngine::kSendEchoReturnLossEnhancement, |
| 72 | stats.echo_return_loss_enhancement); |
| 73 | EXPECT_FALSE(stats.typing_noise_detected); |
| 74 | } |
| 75 | } // namespace test |
solenberg | c7a8b08 | 2015-10-16 14:35:07 -0700 | [diff] [blame] | 76 | } // namespace webrtc |