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

Side by Side Diff: webrtc/pc/rtcstatscollector_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/pc/rtcstatscollector.cc ('k') | webrtc/pc/statscollector.cc » ('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 2016 The WebRTC project authors. All Rights Reserved. 2 * Copyright 2016 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 1503 matching lines...) Expand 10 before | Expand all | Expand 10 after
1514 rtc::scoped_refptr<MediaStreamTrackInterface> local_audio_track = 1514 rtc::scoped_refptr<MediaStreamTrackInterface> local_audio_track =
1515 CreateFakeTrack(cricket::MEDIA_TYPE_AUDIO, "LocalAudioTrackID", 1515 CreateFakeTrack(cricket::MEDIA_TYPE_AUDIO, "LocalAudioTrackID",
1516 MediaStreamTrackInterface::kEnded); 1516 MediaStreamTrackInterface::kEnded);
1517 local_stream->AddTrack(static_cast<AudioTrackInterface*>( 1517 local_stream->AddTrack(static_cast<AudioTrackInterface*>(
1518 local_audio_track.get())); 1518 local_audio_track.get()));
1519 1519
1520 cricket::VoiceSenderInfo voice_sender_info_ssrc1; 1520 cricket::VoiceSenderInfo voice_sender_info_ssrc1;
1521 voice_sender_info_ssrc1.local_stats.push_back(cricket::SsrcSenderInfo()); 1521 voice_sender_info_ssrc1.local_stats.push_back(cricket::SsrcSenderInfo());
1522 voice_sender_info_ssrc1.local_stats[0].ssrc = 1; 1522 voice_sender_info_ssrc1.local_stats[0].ssrc = 1;
1523 voice_sender_info_ssrc1.audio_level = 32767; 1523 voice_sender_info_ssrc1.audio_level = 32767;
1524 voice_sender_info_ssrc1.total_input_energy = 0.25;
1525 voice_sender_info_ssrc1.total_input_duration = 0.5;
1524 voice_sender_info_ssrc1.echo_return_loss = 42; 1526 voice_sender_info_ssrc1.echo_return_loss = 42;
1525 voice_sender_info_ssrc1.echo_return_loss_enhancement = 52; 1527 voice_sender_info_ssrc1.echo_return_loss_enhancement = 52;
1526 1528
1527 // Uses default values, the corresponding stats object should contain 1529 // Uses default values, the corresponding stats object should contain
1528 // undefined members. 1530 // undefined members.
1529 cricket::VoiceSenderInfo voice_sender_info_ssrc2; 1531 cricket::VoiceSenderInfo voice_sender_info_ssrc2;
1530 voice_sender_info_ssrc2.local_stats.push_back(cricket::SsrcSenderInfo()); 1532 voice_sender_info_ssrc2.local_stats.push_back(cricket::SsrcSenderInfo());
1531 voice_sender_info_ssrc2.local_stats[0].ssrc = 2; 1533 voice_sender_info_ssrc2.local_stats[0].ssrc = 2;
1532 voice_sender_info_ssrc2.audio_level = 0; 1534 voice_sender_info_ssrc2.audio_level = 0;
1535 voice_sender_info_ssrc2.total_input_energy = 0.0;
1536 voice_sender_info_ssrc2.total_input_duration = 0.0;
1533 voice_sender_info_ssrc2.echo_return_loss = -100; 1537 voice_sender_info_ssrc2.echo_return_loss = -100;
1534 voice_sender_info_ssrc2.echo_return_loss_enhancement = -100; 1538 voice_sender_info_ssrc2.echo_return_loss_enhancement = -100;
1535 1539
1536 // Remote audio track 1540 // Remote audio track
1537 rtc::scoped_refptr<MediaStreamTrackInterface> remote_audio_track = 1541 rtc::scoped_refptr<MediaStreamTrackInterface> remote_audio_track =
1538 CreateFakeTrack(cricket::MEDIA_TYPE_AUDIO, "RemoteAudioTrackID", 1542 CreateFakeTrack(cricket::MEDIA_TYPE_AUDIO, "RemoteAudioTrackID",
1539 MediaStreamTrackInterface::kLive); 1543 MediaStreamTrackInterface::kLive);
1540 remote_stream->AddTrack(static_cast<AudioTrackInterface*>( 1544 remote_stream->AddTrack(static_cast<AudioTrackInterface*>(
1541 remote_audio_track.get())); 1545 remote_audio_track.get()));
1542 1546
1543 cricket::VoiceReceiverInfo voice_receiver_info; 1547 cricket::VoiceReceiverInfo voice_receiver_info;
1544 voice_receiver_info.local_stats.push_back(cricket::SsrcReceiverInfo()); 1548 voice_receiver_info.local_stats.push_back(cricket::SsrcReceiverInfo());
1545 voice_receiver_info.local_stats[0].ssrc = 3; 1549 voice_receiver_info.local_stats[0].ssrc = 3;
1546 voice_receiver_info.audio_level = 16383; 1550 voice_receiver_info.audio_level = 16383;
1551 voice_receiver_info.total_output_energy = 0.125;
1552 voice_receiver_info.total_output_duration = 0.25;
1547 1553
1548 test_->CreateMockRtpSendersReceiversAndChannels( 1554 test_->CreateMockRtpSendersReceiversAndChannels(
1549 { std::make_pair(local_audio_track.get(), voice_sender_info_ssrc1), 1555 { std::make_pair(local_audio_track.get(), voice_sender_info_ssrc1),
1550 std::make_pair(local_audio_track.get(), voice_sender_info_ssrc2) }, 1556 std::make_pair(local_audio_track.get(), voice_sender_info_ssrc2) },
1551 { std::make_pair(remote_audio_track.get(), voice_receiver_info) }, 1557 { std::make_pair(remote_audio_track.get(), voice_receiver_info) },
1552 {}, {}); 1558 {}, {});
1553 1559
1554 rtc::scoped_refptr<const RTCStatsReport> report = GetStatsReport(); 1560 rtc::scoped_refptr<const RTCStatsReport> report = GetStatsReport();
1555 1561
1556 RTCMediaStreamStats expected_local_stream( 1562 RTCMediaStreamStats expected_local_stream(
(...skipping 18 matching lines...) Expand all
1575 RTCMediaStreamStats>()); 1581 RTCMediaStreamStats>());
1576 1582
1577 RTCMediaStreamTrackStats expected_local_audio_track_ssrc1( 1583 RTCMediaStreamTrackStats expected_local_audio_track_ssrc1(
1578 "RTCMediaStreamTrack_local_audio_LocalAudioTrackID_1", 1584 "RTCMediaStreamTrack_local_audio_LocalAudioTrackID_1",
1579 report->timestamp_us(), RTCMediaStreamTrackKind::kAudio); 1585 report->timestamp_us(), RTCMediaStreamTrackKind::kAudio);
1580 expected_local_audio_track_ssrc1.track_identifier = local_audio_track->id(); 1586 expected_local_audio_track_ssrc1.track_identifier = local_audio_track->id();
1581 expected_local_audio_track_ssrc1.remote_source = false; 1587 expected_local_audio_track_ssrc1.remote_source = false;
1582 expected_local_audio_track_ssrc1.ended = true; 1588 expected_local_audio_track_ssrc1.ended = true;
1583 expected_local_audio_track_ssrc1.detached = false; 1589 expected_local_audio_track_ssrc1.detached = false;
1584 expected_local_audio_track_ssrc1.audio_level = 1.0; 1590 expected_local_audio_track_ssrc1.audio_level = 1.0;
1591 expected_local_audio_track_ssrc1.total_audio_energy = 0.25;
1592 expected_local_audio_track_ssrc1.total_samples_duration = 0.5;
1585 expected_local_audio_track_ssrc1.echo_return_loss = 42.0; 1593 expected_local_audio_track_ssrc1.echo_return_loss = 42.0;
1586 expected_local_audio_track_ssrc1.echo_return_loss_enhancement = 52.0; 1594 expected_local_audio_track_ssrc1.echo_return_loss_enhancement = 52.0;
1587 ASSERT_TRUE(report->Get(expected_local_audio_track_ssrc1.id())); 1595 ASSERT_TRUE(report->Get(expected_local_audio_track_ssrc1.id()));
1588 EXPECT_EQ(expected_local_audio_track_ssrc1, 1596 EXPECT_EQ(expected_local_audio_track_ssrc1,
1589 report->Get(expected_local_audio_track_ssrc1.id())->cast_to< 1597 report->Get(expected_local_audio_track_ssrc1.id())->cast_to<
1590 RTCMediaStreamTrackStats>()); 1598 RTCMediaStreamTrackStats>());
1591 1599
1592 RTCMediaStreamTrackStats expected_local_audio_track_ssrc2( 1600 RTCMediaStreamTrackStats expected_local_audio_track_ssrc2(
1593 "RTCMediaStreamTrack_local_audio_LocalAudioTrackID_2", 1601 "RTCMediaStreamTrack_local_audio_LocalAudioTrackID_2",
1594 report->timestamp_us(), RTCMediaStreamTrackKind::kAudio); 1602 report->timestamp_us(), RTCMediaStreamTrackKind::kAudio);
1595 expected_local_audio_track_ssrc2.track_identifier = local_audio_track->id(); 1603 expected_local_audio_track_ssrc2.track_identifier = local_audio_track->id();
1596 expected_local_audio_track_ssrc2.remote_source = false; 1604 expected_local_audio_track_ssrc2.remote_source = false;
1597 expected_local_audio_track_ssrc2.ended = true; 1605 expected_local_audio_track_ssrc2.ended = true;
1598 expected_local_audio_track_ssrc2.detached = false; 1606 expected_local_audio_track_ssrc2.detached = false;
1599 expected_local_audio_track_ssrc2.audio_level = 0.0; 1607 expected_local_audio_track_ssrc2.audio_level = 0.0;
1608 expected_local_audio_track_ssrc2.total_audio_energy = 0.0;
1609 expected_local_audio_track_ssrc2.total_samples_duration = 0.0;
1600 // Should be undefined: |expected_local_audio_track_ssrc2.echo_return_loss| 1610 // Should be undefined: |expected_local_audio_track_ssrc2.echo_return_loss|
1601 // and |expected_local_audio_track_ssrc2.echo_return_loss_enhancement|. 1611 // and |expected_local_audio_track_ssrc2.echo_return_loss_enhancement|.
1602 ASSERT_TRUE(report->Get(expected_local_audio_track_ssrc2.id())); 1612 ASSERT_TRUE(report->Get(expected_local_audio_track_ssrc2.id()));
1603 EXPECT_EQ(expected_local_audio_track_ssrc2, 1613 EXPECT_EQ(expected_local_audio_track_ssrc2,
1604 report->Get(expected_local_audio_track_ssrc2.id())->cast_to< 1614 report->Get(expected_local_audio_track_ssrc2.id())->cast_to<
1605 RTCMediaStreamTrackStats>()); 1615 RTCMediaStreamTrackStats>());
1606 1616
1607 RTCMediaStreamTrackStats expected_remote_audio_track( 1617 RTCMediaStreamTrackStats expected_remote_audio_track(
1608 "RTCMediaStreamTrack_remote_audio_RemoteAudioTrackID_3", 1618 "RTCMediaStreamTrack_remote_audio_RemoteAudioTrackID_3",
1609 report->timestamp_us(), RTCMediaStreamTrackKind::kAudio); 1619 report->timestamp_us(), RTCMediaStreamTrackKind::kAudio);
1610 expected_remote_audio_track.track_identifier = remote_audio_track->id(); 1620 expected_remote_audio_track.track_identifier = remote_audio_track->id();
1611 expected_remote_audio_track.remote_source = true; 1621 expected_remote_audio_track.remote_source = true;
1612 expected_remote_audio_track.ended = false; 1622 expected_remote_audio_track.ended = false;
1613 expected_remote_audio_track.detached = false; 1623 expected_remote_audio_track.detached = false;
1614 expected_remote_audio_track.audio_level = 16383.0 / 32767.0; 1624 expected_remote_audio_track.audio_level = 16383.0 / 32767.0;
1625 expected_remote_audio_track.total_audio_energy = 0.125;
1626 expected_remote_audio_track.total_samples_duration = 0.25;
1615 ASSERT_TRUE(report->Get(expected_remote_audio_track.id())); 1627 ASSERT_TRUE(report->Get(expected_remote_audio_track.id()));
1616 EXPECT_EQ(expected_remote_audio_track, 1628 EXPECT_EQ(expected_remote_audio_track,
1617 report->Get(expected_remote_audio_track.id())->cast_to< 1629 report->Get(expected_remote_audio_track.id())->cast_to<
1618 RTCMediaStreamTrackStats>()); 1630 RTCMediaStreamTrackStats>());
1619 } 1631 }
1620 1632
1621 TEST_F(RTCStatsCollectorTest, 1633 TEST_F(RTCStatsCollectorTest,
1622 CollectRTCMediaStreamStatsAndRTCMediaStreamTrackStats_Video) { 1634 CollectRTCMediaStreamStatsAndRTCMediaStreamTrackStats_Video) {
1623 rtc::scoped_refptr<StreamCollection> local_streams = 1635 rtc::scoped_refptr<StreamCollection> local_streams =
1624 StreamCollection::Create(); 1636 StreamCollection::Create();
(...skipping 688 matching lines...) Expand 10 before | Expand all | Expand 10 after
2313 rtc::scoped_refptr<FakeRTCStatsCollector> collector_; 2325 rtc::scoped_refptr<FakeRTCStatsCollector> collector_;
2314 }; 2326 };
2315 2327
2316 TEST_F(RTCStatsCollectorTestWithFakeCollector, ThreadUsageAndResultsMerging) { 2328 TEST_F(RTCStatsCollectorTestWithFakeCollector, ThreadUsageAndResultsMerging) {
2317 collector_->VerifyThreadUsageAndResultsMerging(); 2329 collector_->VerifyThreadUsageAndResultsMerging();
2318 } 2330 }
2319 2331
2320 } // namespace 2332 } // namespace
2321 2333
2322 } // namespace webrtc 2334 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/pc/rtcstatscollector.cc ('k') | webrtc/pc/statscollector.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698