Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(49)

Side by Side Diff: webrtc/audio/audio_send_stream_unittest.cc

Issue 2964593002: Adding stats that can be used to compute output audio levels. (Closed)
Patch Set: Add test coverage in AudioSendStreamTest. Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/audio/audio_send_stream.cc ('k') | webrtc/call/audio_receive_stream.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 const uint32_t kSsrc = 1234; 48 const uint32_t kSsrc = 1234;
49 const char* kCName = "foo_name"; 49 const char* kCName = "foo_name";
50 const int kAudioLevelId = 2; 50 const int kAudioLevelId = 2;
51 const int kTransportSequenceNumberId = 4; 51 const int kTransportSequenceNumberId = 4;
52 const int kEchoDelayMedian = 254; 52 const int kEchoDelayMedian = 254;
53 const int kEchoDelayStdDev = -3; 53 const int kEchoDelayStdDev = -3;
54 const int kEchoReturnLoss = -65; 54 const int kEchoReturnLoss = -65;
55 const int kEchoReturnLossEnhancement = 101; 55 const int kEchoReturnLossEnhancement = 101;
56 const float kResidualEchoLikelihood = -1.0f; 56 const float kResidualEchoLikelihood = -1.0f;
57 const int32_t kSpeechInputLevel = 96; 57 const int32_t kSpeechInputLevel = 96;
58 const double kTotalInputEnergy = 0.25;
59 const double kTotalInputDuration = 0.5;
58 const CallStatistics kCallStats = { 60 const CallStatistics kCallStats = {
59 1345, 1678, 1901, 1234, 112, 13456, 17890, 1567, -1890, -1123}; 61 1345, 1678, 1901, 1234, 112, 13456, 17890, 1567, -1890, -1123};
60 const ReportBlock kReportBlock = {456, 780, 123, 567, 890, 132, 143, 13354}; 62 const ReportBlock kReportBlock = {456, 780, 123, 567, 890, 132, 143, 13354};
61 const int kTelephoneEventPayloadType = 123; 63 const int kTelephoneEventPayloadType = 123;
62 const int kTelephoneEventPayloadFrequency = 65432; 64 const int kTelephoneEventPayloadFrequency = 65432;
63 const int kTelephoneEventCode = 45; 65 const int kTelephoneEventCode = 45;
64 const int kTelephoneEventDuration = 6789; 66 const int kTelephoneEventDuration = 6789;
65 const CodecInst kIsacCodec = {103, "isac", 16000, 320, 1, 32000}; 67 const CodecInst kIsacCodec = {103, "isac", 16000, 320, 1, 32000};
66 constexpr int kIsacPayloadType = 103; 68 constexpr int kIsacPayloadType = 103;
67 const SdpAudioFormat kIsacFormat = {"isac", 16000, 1}; 69 const SdpAudioFormat kIsacFormat = {"isac", 16000, 1};
68 const SdpAudioFormat kOpusFormat = {"opus", 48000, 2}; 70 const SdpAudioFormat kOpusFormat = {"opus", 48000, 2};
69 const SdpAudioFormat kG722Format = {"g722", 8000, 1}; 71 const SdpAudioFormat kG722Format = {"g722", 8000, 1};
70 const AudioCodecSpec kCodecSpecs[] = { 72 const AudioCodecSpec kCodecSpecs[] = {
71 {kIsacFormat, {16000, 1, 32000, 10000, 32000}}, 73 {kIsacFormat, {16000, 1, 32000, 10000, 32000}},
72 {kOpusFormat, {48000, 1, 32000, 6000, 510000}}, 74 {kOpusFormat, {48000, 1, 32000, 6000, 510000}},
73 {kG722Format, {16000, 1, 64000}}}; 75 {kG722Format, {16000, 1, 64000}}};
74 76
75 class MockLimitObserver : public BitrateAllocator::LimitObserver { 77 class MockLimitObserver : public BitrateAllocator::LimitObserver {
76 public: 78 public:
77 MOCK_METHOD2(OnAllocationLimitsChanged, 79 MOCK_METHOD2(OnAllocationLimitsChanged,
78 void(uint32_t min_send_bitrate_bps, 80 void(uint32_t min_send_bitrate_bps,
79 uint32_t max_padding_bitrate_bps)); 81 uint32_t max_padding_bitrate_bps));
80 }; 82 };
81 83
82 class MockTransmitMixer : public voe::TransmitMixer { 84 class MockTransmitMixer : public voe::TransmitMixer {
83 public: 85 public:
84 MOCK_CONST_METHOD0(AudioLevelFullRange, int16_t()); 86 MOCK_CONST_METHOD0(AudioLevelFullRange, int16_t());
87 MOCK_CONST_METHOD0(GetTotalInputEnergy, double());
88 MOCK_CONST_METHOD0(GetTotalInputDuration, double());
85 }; 89 };
86 90
87 std::unique_ptr<MockAudioEncoder> SetupAudioEncoderMock( 91 std::unique_ptr<MockAudioEncoder> SetupAudioEncoderMock(
88 int payload_type, 92 int payload_type,
89 const SdpAudioFormat& format) { 93 const SdpAudioFormat& format) {
90 for (const auto& spec : kCodecSpecs) { 94 for (const auto& spec : kCodecSpecs) {
91 if (format == spec.format) { 95 if (format == spec.format) {
92 std::unique_ptr<MockAudioEncoder> encoder(new MockAudioEncoder); 96 std::unique_ptr<MockAudioEncoder> encoder(new MockAudioEncoder);
93 ON_CALL(*encoder.get(), SampleRateHz()) 97 ON_CALL(*encoder.get(), SampleRateHz())
94 .WillByDefault(Return(spec.info.sample_rate_hz)); 98 .WillByDefault(Return(spec.info.sample_rate_hz));
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 EXPECT_TRUE(channel_proxy_); 279 EXPECT_TRUE(channel_proxy_);
276 EXPECT_CALL(*channel_proxy_, GetRTCPStatistics()) 280 EXPECT_CALL(*channel_proxy_, GetRTCPStatistics())
277 .WillRepeatedly(Return(kCallStats)); 281 .WillRepeatedly(Return(kCallStats));
278 EXPECT_CALL(*channel_proxy_, GetRemoteRTCPReportBlocks()) 282 EXPECT_CALL(*channel_proxy_, GetRemoteRTCPReportBlocks())
279 .WillRepeatedly(Return(report_blocks)); 283 .WillRepeatedly(Return(report_blocks));
280 EXPECT_CALL(voice_engine_, transmit_mixer()) 284 EXPECT_CALL(voice_engine_, transmit_mixer())
281 .WillRepeatedly(Return(&transmit_mixer_)); 285 .WillRepeatedly(Return(&transmit_mixer_));
282 286
283 EXPECT_CALL(transmit_mixer_, AudioLevelFullRange()) 287 EXPECT_CALL(transmit_mixer_, AudioLevelFullRange())
284 .WillRepeatedly(Return(kSpeechInputLevel)); 288 .WillRepeatedly(Return(kSpeechInputLevel));
289 EXPECT_CALL(transmit_mixer_, GetTotalInputEnergy())
290 .WillRepeatedly(Return(kTotalInputEnergy));
291 EXPECT_CALL(transmit_mixer_, GetTotalInputDuration())
292 .WillRepeatedly(Return(kTotalInputDuration));
285 293
286 // We have to set the instantaneous value, the average, min and max. We only 294 // We have to set the instantaneous value, the average, min and max. We only
287 // care about the instantaneous value, so we set all to the same value. 295 // care about the instantaneous value, so we set all to the same value.
288 audio_processing_stats_.echo_return_loss.Set( 296 audio_processing_stats_.echo_return_loss.Set(
289 kEchoReturnLoss, kEchoReturnLoss, kEchoReturnLoss, kEchoReturnLoss); 297 kEchoReturnLoss, kEchoReturnLoss, kEchoReturnLoss, kEchoReturnLoss);
290 audio_processing_stats_.echo_return_loss_enhancement.Set( 298 audio_processing_stats_.echo_return_loss_enhancement.Set(
291 kEchoReturnLossEnhancement, kEchoReturnLossEnhancement, 299 kEchoReturnLossEnhancement, kEchoReturnLossEnhancement,
292 kEchoReturnLossEnhancement, kEchoReturnLossEnhancement); 300 kEchoReturnLossEnhancement, kEchoReturnLossEnhancement);
293 audio_processing_stats_.delay_median = kEchoDelayMedian; 301 audio_processing_stats_.delay_median = kEchoDelayMedian;
294 audio_processing_stats_.delay_standard_deviation = kEchoDelayStdDev; 302 audio_processing_stats_.delay_standard_deviation = kEchoDelayStdDev;
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 stats.packets_lost); 417 stats.packets_lost);
410 EXPECT_EQ(Q8ToFloat(kReportBlock.fraction_lost), stats.fraction_lost); 418 EXPECT_EQ(Q8ToFloat(kReportBlock.fraction_lost), stats.fraction_lost);
411 EXPECT_EQ(std::string(kIsacCodec.plname), stats.codec_name); 419 EXPECT_EQ(std::string(kIsacCodec.plname), stats.codec_name);
412 EXPECT_EQ(static_cast<int32_t>(kReportBlock.extended_highest_sequence_number), 420 EXPECT_EQ(static_cast<int32_t>(kReportBlock.extended_highest_sequence_number),
413 stats.ext_seqnum); 421 stats.ext_seqnum);
414 EXPECT_EQ(static_cast<int32_t>(kReportBlock.interarrival_jitter / 422 EXPECT_EQ(static_cast<int32_t>(kReportBlock.interarrival_jitter /
415 (kIsacCodec.plfreq / 1000)), 423 (kIsacCodec.plfreq / 1000)),
416 stats.jitter_ms); 424 stats.jitter_ms);
417 EXPECT_EQ(kCallStats.rttMs, stats.rtt_ms); 425 EXPECT_EQ(kCallStats.rttMs, stats.rtt_ms);
418 EXPECT_EQ(static_cast<int32_t>(kSpeechInputLevel), stats.audio_level); 426 EXPECT_EQ(static_cast<int32_t>(kSpeechInputLevel), stats.audio_level);
427 EXPECT_EQ(kTotalInputEnergy, stats.total_input_energy);
428 EXPECT_EQ(kTotalInputDuration, stats.total_input_duration);
419 EXPECT_EQ(-1, stats.aec_quality_min); 429 EXPECT_EQ(-1, stats.aec_quality_min);
420 EXPECT_EQ(kEchoDelayMedian, stats.echo_delay_median_ms); 430 EXPECT_EQ(kEchoDelayMedian, stats.echo_delay_median_ms);
421 EXPECT_EQ(kEchoDelayStdDev, stats.echo_delay_std_ms); 431 EXPECT_EQ(kEchoDelayStdDev, stats.echo_delay_std_ms);
422 EXPECT_EQ(kEchoReturnLoss, stats.echo_return_loss); 432 EXPECT_EQ(kEchoReturnLoss, stats.echo_return_loss);
423 EXPECT_EQ(kEchoReturnLossEnhancement, stats.echo_return_loss_enhancement); 433 EXPECT_EQ(kEchoReturnLossEnhancement, stats.echo_return_loss_enhancement);
424 EXPECT_EQ(kResidualEchoLikelihood, stats.residual_echo_likelihood); 434 EXPECT_EQ(kResidualEchoLikelihood, stats.residual_echo_likelihood);
425 EXPECT_FALSE(stats.typing_noise_detected); 435 EXPECT_FALSE(stats.typing_noise_detected);
426 } 436 }
427 437
428 TEST(AudioSendStreamTest, GetStatsTypingNoiseDetected) { 438 TEST(AudioSendStreamTest, GetStatsTypingNoiseDetected) {
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 stream_config.send_codec_spec->cng_payload_type = rtc::Optional<int>(105); 546 stream_config.send_codec_spec->cng_payload_type = rtc::Optional<int>(105);
537 internal::AudioSendStream send_stream( 547 internal::AudioSendStream send_stream(
538 stream_config, helper.audio_state(), helper.worker_queue(), 548 stream_config, helper.audio_state(), helper.worker_queue(),
539 helper.transport(), helper.bitrate_allocator(), helper.event_log(), 549 helper.transport(), helper.bitrate_allocator(), helper.event_log(),
540 helper.rtcp_rtt_stats(), rtc::Optional<RtpState>()); 550 helper.rtcp_rtt_stats(), rtc::Optional<RtpState>());
541 send_stream.Reconfigure(stream_config); 551 send_stream.Reconfigure(stream_config);
542 } 552 }
543 553
544 } // namespace test 554 } // namespace test
545 } // namespace webrtc 555 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/audio/audio_send_stream.cc ('k') | webrtc/call/audio_receive_stream.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698