Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 |
| 11 #include "webrtc/api/rtcstatscollector.h" | 11 #include "webrtc/api/rtcstatscollector.h" |
| 12 | 12 |
| 13 #include <memory> | 13 #include <memory> |
| 14 #include <ostream> | 14 #include <ostream> |
| 15 #include <string> | 15 #include <string> |
| 16 #include <vector> | 16 #include <vector> |
| 17 | 17 |
| 18 #include "webrtc/api/jsepsessiondescription.h" | |
| 18 #include "webrtc/api/mediastream.h" | 19 #include "webrtc/api/mediastream.h" |
| 19 #include "webrtc/api/mediastreamtrack.h" | 20 #include "webrtc/api/mediastreamtrack.h" |
| 20 #include "webrtc/api/jsepsessiondescription.h" | 21 #include "webrtc/api/rtpparameters.h" |
| 21 #include "webrtc/api/stats/rtcstats_objects.h" | 22 #include "webrtc/api/stats/rtcstats_objects.h" |
| 22 #include "webrtc/api/stats/rtcstatsreport.h" | 23 #include "webrtc/api/stats/rtcstatsreport.h" |
| 23 #include "webrtc/api/test/mock_datachannel.h" | 24 #include "webrtc/api/test/mock_datachannel.h" |
| 24 #include "webrtc/api/test/mock_peerconnection.h" | 25 #include "webrtc/api/test/mock_peerconnection.h" |
| 25 #include "webrtc/api/test/mock_webrtcsession.h" | 26 #include "webrtc/api/test/mock_webrtcsession.h" |
| 26 #include "webrtc/base/checks.h" | 27 #include "webrtc/base/checks.h" |
| 27 #include "webrtc/base/fakeclock.h" | 28 #include "webrtc/base/fakeclock.h" |
| 28 #include "webrtc/base/fakesslidentity.h" | 29 #include "webrtc/base/fakesslidentity.h" |
| 29 #include "webrtc/base/gunit.h" | 30 #include "webrtc/base/gunit.h" |
| 30 #include "webrtc/base/logging.h" | 31 #include "webrtc/base/logging.h" |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 45 using testing::ReturnRef; | 46 using testing::ReturnRef; |
| 46 using testing::SetArgPointee; | 47 using testing::SetArgPointee; |
| 47 | 48 |
| 48 namespace webrtc { | 49 namespace webrtc { |
| 49 | 50 |
| 50 // These are used by gtest code, such as if |EXPECT_EQ| fails. | 51 // These are used by gtest code, such as if |EXPECT_EQ| fails. |
| 51 void PrintTo(const RTCCertificateStats& stats, ::std::ostream* os) { | 52 void PrintTo(const RTCCertificateStats& stats, ::std::ostream* os) { |
| 52 *os << stats.ToString(); | 53 *os << stats.ToString(); |
| 53 } | 54 } |
| 54 | 55 |
| 56 void PrintTo(const RTCCodecStats& stats, ::std::ostream* os) { | |
| 57 *os << stats.ToString(); | |
| 58 } | |
| 59 | |
| 55 void PrintTo(const RTCDataChannelStats& stats, ::std::ostream* os) { | 60 void PrintTo(const RTCDataChannelStats& stats, ::std::ostream* os) { |
| 56 *os << stats.ToString(); | 61 *os << stats.ToString(); |
| 57 } | 62 } |
| 58 | 63 |
| 59 void PrintTo(const RTCIceCandidatePairStats& stats, ::std::ostream* os) { | 64 void PrintTo(const RTCIceCandidatePairStats& stats, ::std::ostream* os) { |
| 60 *os << stats.ToString(); | 65 *os << stats.ToString(); |
| 61 } | 66 } |
| 62 | 67 |
| 63 void PrintTo(const RTCLocalIceCandidateStats& stats, ::std::ostream* os) { | 68 void PrintTo(const RTCLocalIceCandidateStats& stats, ::std::ostream* os) { |
| 64 *os << stats.ToString(); | 69 *os << stats.ToString(); |
| (...skipping 734 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 799 if (transport_name == "transport") | 804 if (transport_name == "transport") |
| 800 return remote_certinfo->certificate->ssl_certificate().GetReference(); | 805 return remote_certinfo->certificate->ssl_certificate().GetReference(); |
| 801 return static_cast<rtc::SSLCertificate*>(nullptr); | 806 return static_cast<rtc::SSLCertificate*>(nullptr); |
| 802 })); | 807 })); |
| 803 | 808 |
| 804 rtc::scoped_refptr<const RTCStatsReport> report = GetStatsReport(); | 809 rtc::scoped_refptr<const RTCStatsReport> report = GetStatsReport(); |
| 805 ExpectReportContainsCertificateInfo(report, *local_certinfo.get()); | 810 ExpectReportContainsCertificateInfo(report, *local_certinfo.get()); |
| 806 ExpectReportContainsCertificateInfo(report, *remote_certinfo.get()); | 811 ExpectReportContainsCertificateInfo(report, *remote_certinfo.get()); |
| 807 } | 812 } |
| 808 | 813 |
| 814 TEST_F(RTCStatsCollectorTest, CollectRTCCodecStats) { | |
| 815 MockVoiceMediaChannel* voice_media_channel = new MockVoiceMediaChannel(); | |
| 816 cricket::VoiceChannel voice_channel( | |
| 817 test_->worker_thread(), test_->network_thread(), test_->media_engine(), | |
| 818 voice_media_channel, nullptr, "VoiceContentName", false); | |
| 819 | |
| 820 MockVideoMediaChannel* video_media_channel = new MockVideoMediaChannel(); | |
| 821 cricket::VideoChannel video_channel( | |
| 822 test_->worker_thread(), test_->network_thread(), video_media_channel, | |
| 823 nullptr, "VideoContentName", false); | |
|
Taylor Brandstetter
2016/11/17 22:01:51
To test the scenario I described where a payload t
| |
| 824 | |
| 825 // Audio | |
| 826 cricket::VoiceMediaInfo voice_media_info; | |
| 827 | |
| 828 RtpCodecParameters inbound_audio_codec; | |
| 829 inbound_audio_codec.payload_type = 1; | |
| 830 inbound_audio_codec.mime_type = "opus"; | |
| 831 inbound_audio_codec.clock_rate = 1337; | |
| 832 voice_media_info.receive_codecs.insert( | |
| 833 std::make_pair(inbound_audio_codec.payload_type, inbound_audio_codec)); | |
| 834 | |
| 835 RtpCodecParameters outbound_audio_codec; | |
| 836 outbound_audio_codec.payload_type = 2; | |
| 837 outbound_audio_codec.mime_type = "isac"; | |
| 838 outbound_audio_codec.clock_rate = 1338; | |
| 839 voice_media_info.send_codecs.insert( | |
| 840 std::make_pair(outbound_audio_codec.payload_type, outbound_audio_codec)); | |
| 841 | |
| 842 EXPECT_CALL(*voice_media_channel, GetStats(_)) | |
| 843 .WillOnce(DoAll(SetArgPointee<0>(voice_media_info), Return(true))); | |
| 844 | |
| 845 // Video | |
| 846 cricket::VideoMediaInfo video_media_info; | |
| 847 | |
| 848 RtpCodecParameters inbound_video_codec; | |
| 849 inbound_video_codec.payload_type = 3; | |
| 850 inbound_video_codec.mime_type = "H264"; | |
| 851 inbound_video_codec.clock_rate = 1339; | |
| 852 video_media_info.receive_codecs.insert( | |
| 853 std::make_pair(inbound_video_codec.payload_type, inbound_video_codec)); | |
| 854 | |
| 855 RtpCodecParameters outbound_video_codec; | |
| 856 outbound_video_codec.payload_type = 4; | |
| 857 outbound_video_codec.mime_type = "VP8"; | |
| 858 outbound_video_codec.clock_rate = 1340; | |
| 859 video_media_info.send_codecs.insert( | |
| 860 std::make_pair(outbound_video_codec.payload_type, outbound_video_codec)); | |
| 861 | |
| 862 EXPECT_CALL(*video_media_channel, GetStats(_)) | |
| 863 .WillOnce(DoAll(SetArgPointee<0>(video_media_info), Return(true))); | |
| 864 | |
| 865 SessionStats session_stats; | |
| 866 session_stats.proxy_to_transport["VoiceContentName"] = "TransportName"; | |
| 867 session_stats.proxy_to_transport["VideoContentName"] = "TransportName"; | |
| 868 session_stats.transport_stats["TransportName"].transport_name = | |
| 869 "TransportName"; | |
| 870 | |
| 871 EXPECT_CALL(test_->session(), GetTransportStats(_)) | |
| 872 .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats), Return(true))); | |
| 873 EXPECT_CALL(test_->session(), voice_channel()) | |
| 874 .WillRepeatedly(Return(&voice_channel)); | |
| 875 EXPECT_CALL(test_->session(), video_channel()) | |
| 876 .WillRepeatedly(Return(&video_channel)); | |
| 877 | |
| 878 rtc::scoped_refptr<const RTCStatsReport> report = GetStatsReport(); | |
| 879 | |
| 880 RTCCodecStats expected_inbound_audio_codec( | |
| 881 "RTCCodec_InboundAudio_1", report->timestamp_us()); | |
| 882 expected_inbound_audio_codec.payload_type = 1; | |
| 883 expected_inbound_audio_codec.codec = "audio/opus"; | |
| 884 expected_inbound_audio_codec.clock_rate = 1337; | |
| 885 | |
| 886 RTCCodecStats expected_outbound_audio_codec( | |
| 887 "RTCCodec_OutboundAudio_2", report->timestamp_us()); | |
| 888 expected_outbound_audio_codec.payload_type = 2; | |
| 889 expected_outbound_audio_codec.codec = "audio/isac"; | |
| 890 expected_outbound_audio_codec.clock_rate = 1338; | |
| 891 | |
| 892 RTCCodecStats expected_inbound_video_codec( | |
| 893 "RTCCodec_InboundVideo_3", report->timestamp_us()); | |
| 894 expected_inbound_video_codec.payload_type = 3; | |
| 895 expected_inbound_video_codec.codec = "video/H264"; | |
| 896 expected_inbound_video_codec.clock_rate = 1339; | |
| 897 | |
| 898 RTCCodecStats expected_outbound_video_codec( | |
| 899 "RTCCodec_OutboundVideo_4", report->timestamp_us()); | |
| 900 expected_outbound_video_codec.payload_type = 4; | |
| 901 expected_outbound_video_codec.codec = "video/VP8"; | |
| 902 expected_outbound_video_codec.clock_rate = 1340; | |
| 903 | |
| 904 ASSERT(report->Get(expected_inbound_audio_codec.id())); | |
| 905 EXPECT_EQ(expected_inbound_audio_codec, | |
| 906 report->Get(expected_inbound_audio_codec.id())->cast_to< | |
| 907 RTCCodecStats>()); | |
| 908 | |
| 909 ASSERT(report->Get(expected_outbound_audio_codec.id())); | |
| 910 EXPECT_EQ(expected_outbound_audio_codec, | |
| 911 report->Get(expected_outbound_audio_codec.id())->cast_to< | |
| 912 RTCCodecStats>()); | |
| 913 | |
| 914 ASSERT(report->Get(expected_inbound_video_codec.id())); | |
| 915 EXPECT_EQ(expected_inbound_video_codec, | |
| 916 report->Get(expected_inbound_video_codec.id())->cast_to< | |
| 917 RTCCodecStats>()); | |
| 918 | |
| 919 ASSERT(report->Get(expected_outbound_video_codec.id())); | |
| 920 EXPECT_EQ(expected_outbound_video_codec, | |
| 921 report->Get(expected_outbound_video_codec.id())->cast_to< | |
| 922 RTCCodecStats>()); | |
| 923 } | |
| 924 | |
| 809 TEST_F(RTCStatsCollectorTest, CollectRTCCertificateStatsMultiple) { | 925 TEST_F(RTCStatsCollectorTest, CollectRTCCertificateStatsMultiple) { |
| 810 std::unique_ptr<CertificateInfo> audio_local_certinfo = | 926 std::unique_ptr<CertificateInfo> audio_local_certinfo = |
| 811 CreateFakeCertificateAndInfoFromDers( | 927 CreateFakeCertificateAndInfoFromDers( |
| 812 std::vector<std::string>({ "(local) audio" })); | 928 std::vector<std::string>({ "(local) audio" })); |
| 813 audio_local_certinfo = CreateFakeCertificateAndInfoFromDers( | 929 audio_local_certinfo = CreateFakeCertificateAndInfoFromDers( |
| 814 audio_local_certinfo->ders); | 930 audio_local_certinfo->ders); |
| 815 std::unique_ptr<CertificateInfo> audio_remote_certinfo = | 931 std::unique_ptr<CertificateInfo> audio_remote_certinfo = |
| 816 CreateFakeCertificateAndInfoFromDers( | 932 CreateFakeCertificateAndInfoFromDers( |
| 817 std::vector<std::string>({ "(remote) audio" })); | 933 std::vector<std::string>({ "(remote) audio" })); |
| 818 audio_remote_certinfo = CreateFakeCertificateAndInfoFromDers( | 934 audio_remote_certinfo = CreateFakeCertificateAndInfoFromDers( |
| (...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1319 test_->worker_thread(), test_->network_thread(), test_->media_engine(), | 1435 test_->worker_thread(), test_->network_thread(), test_->media_engine(), |
| 1320 voice_media_channel, nullptr, "VoiceContentName", false); | 1436 voice_media_channel, nullptr, "VoiceContentName", false); |
| 1321 | 1437 |
| 1322 cricket::VoiceMediaInfo voice_media_info; | 1438 cricket::VoiceMediaInfo voice_media_info; |
| 1323 voice_media_info.receivers.push_back(cricket::VoiceReceiverInfo()); | 1439 voice_media_info.receivers.push_back(cricket::VoiceReceiverInfo()); |
| 1324 voice_media_info.receivers[0].local_stats.push_back( | 1440 voice_media_info.receivers[0].local_stats.push_back( |
| 1325 cricket::SsrcReceiverInfo()); | 1441 cricket::SsrcReceiverInfo()); |
| 1326 voice_media_info.receivers[0].local_stats[0].ssrc = 1; | 1442 voice_media_info.receivers[0].local_stats[0].ssrc = 1; |
| 1327 voice_media_info.receivers[0].packets_rcvd = 2; | 1443 voice_media_info.receivers[0].packets_rcvd = 2; |
| 1328 voice_media_info.receivers[0].bytes_rcvd = 3; | 1444 voice_media_info.receivers[0].bytes_rcvd = 3; |
| 1445 voice_media_info.receivers[0].codec_payload_type = rtc::Optional<int>(42); | |
| 1329 voice_media_info.receivers[0].jitter_ms = 4500; | 1446 voice_media_info.receivers[0].jitter_ms = 4500; |
| 1330 voice_media_info.receivers[0].fraction_lost = 5.5f; | 1447 voice_media_info.receivers[0].fraction_lost = 5.5f; |
| 1331 EXPECT_CALL(*voice_media_channel, GetStats(_)) | 1448 EXPECT_CALL(*voice_media_channel, GetStats(_)) |
| 1332 .WillOnce(DoAll(SetArgPointee<0>(voice_media_info), Return(true))); | 1449 .WillOnce(DoAll(SetArgPointee<0>(voice_media_info), Return(true))); |
| 1333 | 1450 |
| 1334 SessionStats session_stats; | 1451 SessionStats session_stats; |
| 1335 session_stats.proxy_to_transport["VoiceContentName"] = "TransportName"; | 1452 session_stats.proxy_to_transport["VoiceContentName"] = "TransportName"; |
| 1336 session_stats.transport_stats["TransportName"].transport_name = | 1453 session_stats.transport_stats["TransportName"].transport_name = |
| 1337 "TransportName"; | 1454 "TransportName"; |
| 1338 | 1455 |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 1349 | 1466 |
| 1350 rtc::scoped_refptr<const RTCStatsReport> report = GetStatsReport(); | 1467 rtc::scoped_refptr<const RTCStatsReport> report = GetStatsReport(); |
| 1351 | 1468 |
| 1352 RTCInboundRTPStreamStats expected_audio( | 1469 RTCInboundRTPStreamStats expected_audio( |
| 1353 "RTCInboundRTPAudioStream_1", report->timestamp_us()); | 1470 "RTCInboundRTPAudioStream_1", report->timestamp_us()); |
| 1354 expected_audio.ssrc = "1"; | 1471 expected_audio.ssrc = "1"; |
| 1355 expected_audio.is_remote = false; | 1472 expected_audio.is_remote = false; |
| 1356 expected_audio.media_type = "audio"; | 1473 expected_audio.media_type = "audio"; |
| 1357 expected_audio.transport_id = "RTCTransport_TransportName_" + | 1474 expected_audio.transport_id = "RTCTransport_TransportName_" + |
| 1358 rtc::ToString<>(cricket::ICE_CANDIDATE_COMPONENT_RTP); | 1475 rtc::ToString<>(cricket::ICE_CANDIDATE_COMPONENT_RTP); |
| 1476 expected_audio.codec_id = "RTCCodec_InboundAudio_42"; | |
| 1359 expected_audio.packets_received = 2; | 1477 expected_audio.packets_received = 2; |
| 1360 expected_audio.bytes_received = 3; | 1478 expected_audio.bytes_received = 3; |
| 1361 expected_audio.jitter = 4.5; | 1479 expected_audio.jitter = 4.5; |
| 1362 expected_audio.fraction_lost = 5.5; | 1480 expected_audio.fraction_lost = 5.5; |
| 1363 | 1481 |
| 1364 ASSERT(report->Get(expected_audio.id())); | 1482 ASSERT(report->Get(expected_audio.id())); |
| 1365 const RTCInboundRTPStreamStats& audio = report->Get( | 1483 const RTCInboundRTPStreamStats& audio = report->Get( |
| 1366 expected_audio.id())->cast_to<RTCInboundRTPStreamStats>(); | 1484 expected_audio.id())->cast_to<RTCInboundRTPStreamStats>(); |
| 1367 EXPECT_EQ(audio, expected_audio); | 1485 EXPECT_EQ(audio, expected_audio); |
| 1368 | 1486 |
| 1369 EXPECT_TRUE(report->Get(*expected_audio.transport_id)); | 1487 EXPECT_TRUE(report->Get(*expected_audio.transport_id)); |
| 1370 } | 1488 } |
| 1371 | 1489 |
| 1372 TEST_F(RTCStatsCollectorTest, CollectRTCInboundRTPStreamStats_Video) { | 1490 TEST_F(RTCStatsCollectorTest, CollectRTCInboundRTPStreamStats_Video) { |
| 1373 MockVideoMediaChannel* video_media_channel = new MockVideoMediaChannel(); | 1491 MockVideoMediaChannel* video_media_channel = new MockVideoMediaChannel(); |
| 1374 cricket::VideoChannel video_channel( | 1492 cricket::VideoChannel video_channel( |
| 1375 test_->worker_thread(), test_->network_thread(), video_media_channel, | 1493 test_->worker_thread(), test_->network_thread(), video_media_channel, |
| 1376 nullptr, "VideoContentName", false); | 1494 nullptr, "VideoContentName", false); |
| 1377 | 1495 |
| 1378 cricket::VideoMediaInfo video_media_info; | 1496 cricket::VideoMediaInfo video_media_info; |
| 1379 video_media_info.receivers.push_back(cricket::VideoReceiverInfo()); | 1497 video_media_info.receivers.push_back(cricket::VideoReceiverInfo()); |
| 1380 video_media_info.receivers[0].local_stats.push_back( | 1498 video_media_info.receivers[0].local_stats.push_back( |
| 1381 cricket::SsrcReceiverInfo()); | 1499 cricket::SsrcReceiverInfo()); |
| 1382 video_media_info.receivers[0].local_stats[0].ssrc = 1; | 1500 video_media_info.receivers[0].local_stats[0].ssrc = 1; |
| 1383 video_media_info.receivers[0].packets_rcvd = 2; | 1501 video_media_info.receivers[0].packets_rcvd = 2; |
| 1384 video_media_info.receivers[0].bytes_rcvd = 3; | 1502 video_media_info.receivers[0].bytes_rcvd = 3; |
| 1385 video_media_info.receivers[0].fraction_lost = 4.5f; | 1503 video_media_info.receivers[0].fraction_lost = 4.5f; |
| 1504 video_media_info.receivers[0].codec_payload_type = rtc::Optional<int>(42); | |
| 1386 EXPECT_CALL(*video_media_channel, GetStats(_)) | 1505 EXPECT_CALL(*video_media_channel, GetStats(_)) |
| 1387 .WillOnce(DoAll(SetArgPointee<0>(video_media_info), Return(true))); | 1506 .WillOnce(DoAll(SetArgPointee<0>(video_media_info), Return(true))); |
| 1388 | 1507 |
| 1389 SessionStats session_stats; | 1508 SessionStats session_stats; |
| 1390 session_stats.proxy_to_transport["VideoContentName"] = "TransportName"; | 1509 session_stats.proxy_to_transport["VideoContentName"] = "TransportName"; |
| 1391 session_stats.transport_stats["TransportName"].transport_name = | 1510 session_stats.transport_stats["TransportName"].transport_name = |
| 1392 "TransportName"; | 1511 "TransportName"; |
| 1393 | 1512 |
| 1394 // Make sure the associated |RTCTransportStats| is created. | 1513 // Make sure the associated |RTCTransportStats| is created. |
| 1395 cricket::TransportChannelStats channel_stats; | 1514 cricket::TransportChannelStats channel_stats; |
| 1396 channel_stats.component = cricket::ICE_CANDIDATE_COMPONENT_RTP; | 1515 channel_stats.component = cricket::ICE_CANDIDATE_COMPONENT_RTP; |
| 1397 session_stats.transport_stats["TransportName"].channel_stats.push_back( | 1516 session_stats.transport_stats["TransportName"].channel_stats.push_back( |
| 1398 channel_stats); | 1517 channel_stats); |
| 1399 | 1518 |
| 1400 EXPECT_CALL(test_->session(), GetTransportStats(_)) | 1519 EXPECT_CALL(test_->session(), GetTransportStats(_)) |
| 1401 .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats), Return(true))); | 1520 .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats), Return(true))); |
| 1402 EXPECT_CALL(test_->session(), video_channel()) | 1521 EXPECT_CALL(test_->session(), video_channel()) |
| 1403 .WillRepeatedly(Return(&video_channel)); | 1522 .WillRepeatedly(Return(&video_channel)); |
| 1404 | 1523 |
| 1405 rtc::scoped_refptr<const RTCStatsReport> report = GetStatsReport(); | 1524 rtc::scoped_refptr<const RTCStatsReport> report = GetStatsReport(); |
| 1406 | 1525 |
| 1407 RTCInboundRTPStreamStats expected_audio( | 1526 RTCInboundRTPStreamStats expected_video( |
| 1408 "RTCInboundRTPVideoStream_1", report->timestamp_us()); | 1527 "RTCInboundRTPVideoStream_1", report->timestamp_us()); |
| 1409 expected_audio.ssrc = "1"; | 1528 expected_video.ssrc = "1"; |
| 1410 expected_audio.is_remote = false; | 1529 expected_video.is_remote = false; |
| 1411 expected_audio.media_type = "video"; | 1530 expected_video.media_type = "video"; |
| 1412 expected_audio.transport_id = "RTCTransport_TransportName_" + | 1531 expected_video.transport_id = "RTCTransport_TransportName_" + |
| 1413 rtc::ToString<>(cricket::ICE_CANDIDATE_COMPONENT_RTP); | 1532 rtc::ToString<>(cricket::ICE_CANDIDATE_COMPONENT_RTP); |
| 1414 expected_audio.packets_received = 2; | 1533 expected_video.codec_id = "RTCCodec_InboundVideo_42"; |
|
hta-webrtc
2016/11/23 07:37:35
Nit: Since IDs are defined by the spec to be opaqu
hbos
2016/11/23 09:40:59
Done here and three other places. (in/out audio/vi
| |
| 1415 expected_audio.bytes_received = 3; | 1534 expected_video.packets_received = 2; |
| 1416 expected_audio.fraction_lost = 4.5; | 1535 expected_video.bytes_received = 3; |
| 1536 expected_video.fraction_lost = 4.5; | |
| 1417 | 1537 |
| 1418 ASSERT(report->Get(expected_audio.id())); | 1538 ASSERT(report->Get(expected_video.id())); |
| 1419 const RTCInboundRTPStreamStats& audio = report->Get( | 1539 const RTCInboundRTPStreamStats& audio = report->Get( |
| 1420 expected_audio.id())->cast_to<RTCInboundRTPStreamStats>(); | 1540 expected_video.id())->cast_to<RTCInboundRTPStreamStats>(); |
| 1421 EXPECT_EQ(audio, expected_audio); | 1541 EXPECT_EQ(audio, expected_video); |
| 1422 | 1542 |
| 1423 EXPECT_TRUE(report->Get(*expected_audio.transport_id)); | 1543 EXPECT_TRUE(report->Get(*expected_video.transport_id)); |
| 1424 } | 1544 } |
| 1425 | 1545 |
| 1426 TEST_F(RTCStatsCollectorTest, CollectRTCOutboundRTPStreamStats_Audio) { | 1546 TEST_F(RTCStatsCollectorTest, CollectRTCOutboundRTPStreamStats_Audio) { |
| 1427 MockVoiceMediaChannel* voice_media_channel = new MockVoiceMediaChannel(); | 1547 MockVoiceMediaChannel* voice_media_channel = new MockVoiceMediaChannel(); |
| 1428 cricket::VoiceChannel voice_channel( | 1548 cricket::VoiceChannel voice_channel( |
| 1429 test_->worker_thread(), test_->network_thread(), test_->media_engine(), | 1549 test_->worker_thread(), test_->network_thread(), test_->media_engine(), |
| 1430 voice_media_channel, nullptr, "VoiceContentName", false); | 1550 voice_media_channel, nullptr, "VoiceContentName", false); |
| 1431 | 1551 |
| 1432 cricket::VoiceMediaInfo voice_media_info; | 1552 cricket::VoiceMediaInfo voice_media_info; |
| 1433 voice_media_info.senders.push_back(cricket::VoiceSenderInfo()); | 1553 voice_media_info.senders.push_back(cricket::VoiceSenderInfo()); |
| 1434 voice_media_info.senders[0].local_stats.push_back(cricket::SsrcSenderInfo()); | 1554 voice_media_info.senders[0].local_stats.push_back(cricket::SsrcSenderInfo()); |
| 1435 voice_media_info.senders[0].local_stats[0].ssrc = 1; | 1555 voice_media_info.senders[0].local_stats[0].ssrc = 1; |
| 1436 voice_media_info.senders[0].packets_sent = 2; | 1556 voice_media_info.senders[0].packets_sent = 2; |
| 1437 voice_media_info.senders[0].bytes_sent = 3; | 1557 voice_media_info.senders[0].bytes_sent = 3; |
| 1438 voice_media_info.senders[0].rtt_ms = 4500; | 1558 voice_media_info.senders[0].rtt_ms = 4500; |
| 1559 voice_media_info.senders[0].codec_payload_type = rtc::Optional<int>(42); | |
| 1439 EXPECT_CALL(*voice_media_channel, GetStats(_)) | 1560 EXPECT_CALL(*voice_media_channel, GetStats(_)) |
| 1440 .WillOnce(DoAll(SetArgPointee<0>(voice_media_info), Return(true))); | 1561 .WillOnce(DoAll(SetArgPointee<0>(voice_media_info), Return(true))); |
| 1441 | 1562 |
| 1442 SessionStats session_stats; | 1563 SessionStats session_stats; |
| 1443 session_stats.proxy_to_transport["VoiceContentName"] = "TransportName"; | 1564 session_stats.proxy_to_transport["VoiceContentName"] = "TransportName"; |
| 1444 session_stats.transport_stats["TransportName"].transport_name = | 1565 session_stats.transport_stats["TransportName"].transport_name = |
| 1445 "TransportName"; | 1566 "TransportName"; |
| 1446 | 1567 |
| 1447 // Make sure the associated |RTCTransportStats| is created. | 1568 // Make sure the associated |RTCTransportStats| is created. |
| 1448 cricket::TransportChannelStats channel_stats; | 1569 cricket::TransportChannelStats channel_stats; |
| 1449 channel_stats.component = cricket::ICE_CANDIDATE_COMPONENT_RTP; | 1570 channel_stats.component = cricket::ICE_CANDIDATE_COMPONENT_RTP; |
| 1450 session_stats.transport_stats["TransportName"].channel_stats.push_back( | 1571 session_stats.transport_stats["TransportName"].channel_stats.push_back( |
| 1451 channel_stats); | 1572 channel_stats); |
| 1452 | 1573 |
| 1453 EXPECT_CALL(test_->session(), GetTransportStats(_)) | 1574 EXPECT_CALL(test_->session(), GetTransportStats(_)) |
| 1454 .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats), Return(true))); | 1575 .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats), Return(true))); |
| 1455 EXPECT_CALL(test_->session(), voice_channel()) | 1576 EXPECT_CALL(test_->session(), voice_channel()) |
| 1456 .WillRepeatedly(Return(&voice_channel)); | 1577 .WillRepeatedly(Return(&voice_channel)); |
| 1457 | 1578 |
| 1458 rtc::scoped_refptr<const RTCStatsReport> report = GetStatsReport(); | 1579 rtc::scoped_refptr<const RTCStatsReport> report = GetStatsReport(); |
| 1459 | 1580 |
| 1460 RTCOutboundRTPStreamStats expected_audio( | 1581 RTCOutboundRTPStreamStats expected_audio( |
| 1461 "RTCOutboundRTPAudioStream_1", report->timestamp_us()); | 1582 "RTCOutboundRTPAudioStream_1", report->timestamp_us()); |
| 1462 expected_audio.ssrc = "1"; | 1583 expected_audio.ssrc = "1"; |
| 1463 expected_audio.is_remote = false; | 1584 expected_audio.is_remote = false; |
| 1464 expected_audio.media_type = "audio"; | 1585 expected_audio.media_type = "audio"; |
| 1465 expected_audio.transport_id = "RTCTransport_TransportName_" + | 1586 expected_audio.transport_id = "RTCTransport_TransportName_" + |
| 1466 rtc::ToString<>(cricket::ICE_CANDIDATE_COMPONENT_RTP); | 1587 rtc::ToString<>(cricket::ICE_CANDIDATE_COMPONENT_RTP); |
| 1588 expected_audio.codec_id = "RTCCodec_OutboundAudio_42"; | |
|
hta-webrtc
2016/11/23 07:37:35
As above.
hbos
2016/11/23 09:40:59
Done.
| |
| 1467 expected_audio.packets_sent = 2; | 1589 expected_audio.packets_sent = 2; |
| 1468 expected_audio.bytes_sent = 3; | 1590 expected_audio.bytes_sent = 3; |
| 1469 expected_audio.round_trip_time = 4.5; | 1591 expected_audio.round_trip_time = 4.5; |
| 1470 | 1592 |
| 1471 ASSERT(report->Get(expected_audio.id())); | 1593 ASSERT(report->Get(expected_audio.id())); |
| 1472 const RTCOutboundRTPStreamStats& audio = report->Get( | 1594 const RTCOutboundRTPStreamStats& audio = report->Get( |
| 1473 expected_audio.id())->cast_to<RTCOutboundRTPStreamStats>(); | 1595 expected_audio.id())->cast_to<RTCOutboundRTPStreamStats>(); |
| 1474 EXPECT_EQ(audio, expected_audio); | 1596 EXPECT_EQ(audio, expected_audio); |
| 1475 | 1597 |
| 1476 EXPECT_TRUE(report->Get(*expected_audio.transport_id)); | 1598 EXPECT_TRUE(report->Get(*expected_audio.transport_id)); |
| 1477 } | 1599 } |
| 1478 | 1600 |
| 1479 TEST_F(RTCStatsCollectorTest, CollectRTCOutboundRTPStreamStats_Video) { | 1601 TEST_F(RTCStatsCollectorTest, CollectRTCOutboundRTPStreamStats_Video) { |
| 1480 MockVideoMediaChannel* video_media_channel = new MockVideoMediaChannel(); | 1602 MockVideoMediaChannel* video_media_channel = new MockVideoMediaChannel(); |
| 1481 cricket::VideoChannel video_channel( | 1603 cricket::VideoChannel video_channel( |
| 1482 test_->worker_thread(), test_->network_thread(), video_media_channel, | 1604 test_->worker_thread(), test_->network_thread(), video_media_channel, |
| 1483 nullptr, "VideoContentName", false); | 1605 nullptr, "VideoContentName", false); |
| 1484 | 1606 |
| 1485 cricket::VideoMediaInfo video_media_info; | 1607 cricket::VideoMediaInfo video_media_info; |
| 1486 video_media_info.senders.push_back(cricket::VideoSenderInfo()); | 1608 video_media_info.senders.push_back(cricket::VideoSenderInfo()); |
| 1487 video_media_info.senders[0].local_stats.push_back(cricket::SsrcSenderInfo()); | 1609 video_media_info.senders[0].local_stats.push_back(cricket::SsrcSenderInfo()); |
| 1488 video_media_info.senders[0].local_stats[0].ssrc = 1; | 1610 video_media_info.senders[0].local_stats[0].ssrc = 1; |
| 1489 video_media_info.senders[0].firs_rcvd = 2; | 1611 video_media_info.senders[0].firs_rcvd = 2; |
| 1490 video_media_info.senders[0].plis_rcvd = 3; | 1612 video_media_info.senders[0].plis_rcvd = 3; |
| 1491 video_media_info.senders[0].nacks_rcvd = 4; | 1613 video_media_info.senders[0].nacks_rcvd = 4; |
| 1492 video_media_info.senders[0].packets_sent = 5; | 1614 video_media_info.senders[0].packets_sent = 5; |
| 1493 video_media_info.senders[0].bytes_sent = 6; | 1615 video_media_info.senders[0].bytes_sent = 6; |
| 1494 video_media_info.senders[0].rtt_ms = 7500; | 1616 video_media_info.senders[0].rtt_ms = 7500; |
| 1617 video_media_info.senders[0].codec_payload_type = rtc::Optional<int>(42); | |
| 1495 EXPECT_CALL(*video_media_channel, GetStats(_)) | 1618 EXPECT_CALL(*video_media_channel, GetStats(_)) |
| 1496 .WillOnce(DoAll(SetArgPointee<0>(video_media_info), Return(true))); | 1619 .WillOnce(DoAll(SetArgPointee<0>(video_media_info), Return(true))); |
| 1497 | 1620 |
| 1498 SessionStats session_stats; | 1621 SessionStats session_stats; |
| 1499 session_stats.proxy_to_transport["VideoContentName"] = "TransportName"; | 1622 session_stats.proxy_to_transport["VideoContentName"] = "TransportName"; |
| 1500 session_stats.transport_stats["TransportName"].transport_name = | 1623 session_stats.transport_stats["TransportName"].transport_name = |
| 1501 "TransportName"; | 1624 "TransportName"; |
| 1502 | 1625 |
| 1503 // Make sure the associated |RTCTransportStats| is created. | 1626 // Make sure the associated |RTCTransportStats| is created. |
| 1504 cricket::TransportChannelStats channel_stats; | 1627 cricket::TransportChannelStats channel_stats; |
| 1505 channel_stats.component = cricket::ICE_CANDIDATE_COMPONENT_RTP; | 1628 channel_stats.component = cricket::ICE_CANDIDATE_COMPONENT_RTP; |
| 1506 session_stats.transport_stats["TransportName"].channel_stats.push_back( | 1629 session_stats.transport_stats["TransportName"].channel_stats.push_back( |
| 1507 channel_stats); | 1630 channel_stats); |
| 1508 | 1631 |
| 1509 EXPECT_CALL(test_->session(), GetTransportStats(_)) | 1632 EXPECT_CALL(test_->session(), GetTransportStats(_)) |
| 1510 .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats), Return(true))); | 1633 .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats), Return(true))); |
| 1511 EXPECT_CALL(test_->session(), video_channel()) | 1634 EXPECT_CALL(test_->session(), video_channel()) |
| 1512 .WillRepeatedly(Return(&video_channel)); | 1635 .WillRepeatedly(Return(&video_channel)); |
| 1513 | 1636 |
| 1514 rtc::scoped_refptr<const RTCStatsReport> report = GetStatsReport(); | 1637 rtc::scoped_refptr<const RTCStatsReport> report = GetStatsReport(); |
| 1515 | 1638 |
| 1516 RTCOutboundRTPStreamStats expected_video( | 1639 RTCOutboundRTPStreamStats expected_video( |
| 1517 "RTCOutboundRTPVideoStream_1", report->timestamp_us()); | 1640 "RTCOutboundRTPVideoStream_1", report->timestamp_us()); |
| 1518 expected_video.ssrc = "1"; | 1641 expected_video.ssrc = "1"; |
| 1519 expected_video.is_remote = false; | 1642 expected_video.is_remote = false; |
| 1520 expected_video.media_type = "video"; | 1643 expected_video.media_type = "video"; |
| 1521 expected_video.transport_id = "RTCTransport_TransportName_" + | 1644 expected_video.transport_id = "RTCTransport_TransportName_" + |
| 1522 rtc::ToString<>(cricket::ICE_CANDIDATE_COMPONENT_RTP); | 1645 rtc::ToString<>(cricket::ICE_CANDIDATE_COMPONENT_RTP); |
| 1646 expected_video.codec_id = "RTCCodec_OutboundVideo_42"; | |
| 1523 expected_video.fir_count = 2; | 1647 expected_video.fir_count = 2; |
| 1524 expected_video.pli_count = 3; | 1648 expected_video.pli_count = 3; |
| 1525 expected_video.nack_count = 4; | 1649 expected_video.nack_count = 4; |
| 1526 expected_video.packets_sent = 5; | 1650 expected_video.packets_sent = 5; |
| 1527 expected_video.bytes_sent = 6; | 1651 expected_video.bytes_sent = 6; |
| 1528 expected_video.round_trip_time = 7.5; | 1652 expected_video.round_trip_time = 7.5; |
| 1529 | 1653 |
| 1530 ASSERT(report->Get(expected_video.id())); | 1654 ASSERT(report->Get(expected_video.id())); |
| 1531 const RTCOutboundRTPStreamStats& video = report->Get( | 1655 const RTCOutboundRTPStreamStats& video = report->Get( |
| 1532 expected_video.id())->cast_to<RTCOutboundRTPStreamStats>(); | 1656 expected_video.id())->cast_to<RTCOutboundRTPStreamStats>(); |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1647 rtc::scoped_refptr<FakeRTCStatsCollector> collector_; | 1771 rtc::scoped_refptr<FakeRTCStatsCollector> collector_; |
| 1648 }; | 1772 }; |
| 1649 | 1773 |
| 1650 TEST_F(RTCStatsCollectorTestWithFakeCollector, ThreadUsageAndResultsMerging) { | 1774 TEST_F(RTCStatsCollectorTestWithFakeCollector, ThreadUsageAndResultsMerging) { |
| 1651 collector_->VerifyThreadUsageAndResultsMerging(); | 1775 collector_->VerifyThreadUsageAndResultsMerging(); |
| 1652 } | 1776 } |
| 1653 | 1777 |
| 1654 } // namespace | 1778 } // namespace |
| 1655 | 1779 |
| 1656 } // namespace webrtc | 1780 } // namespace webrtc |
| OLD | NEW |