OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2014 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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 } | 91 } |
92 }; | 92 }; |
93 | 93 |
94 class FakeAudioTrack | 94 class FakeAudioTrack |
95 : public webrtc::MediaStreamTrack<webrtc::AudioTrackInterface> { | 95 : public webrtc::MediaStreamTrack<webrtc::AudioTrackInterface> { |
96 public: | 96 public: |
97 explicit FakeAudioTrack(const std::string& id) | 97 explicit FakeAudioTrack(const std::string& id) |
98 : webrtc::MediaStreamTrack<webrtc::AudioTrackInterface>(id), | 98 : webrtc::MediaStreamTrack<webrtc::AudioTrackInterface>(id), |
99 processor_(new rtc::RefCountedObject<FakeAudioProcessor>()) {} | 99 processor_(new rtc::RefCountedObject<FakeAudioProcessor>()) {} |
100 std::string kind() const override { return "audio"; } | 100 std::string kind() const override { return "audio"; } |
101 webrtc::AudioSourceInterface* GetSource() const override { return NULL; } | 101 webrtc::AudioSourceInterface* GetSource() const override { return nullptr; } |
102 void AddSink(webrtc::AudioTrackSinkInterface* sink) override {} | 102 void AddSink(webrtc::AudioTrackSinkInterface* sink) override {} |
103 void RemoveSink(webrtc::AudioTrackSinkInterface* sink) override {} | 103 void RemoveSink(webrtc::AudioTrackSinkInterface* sink) override {} |
104 bool GetSignalLevel(int* level) override { | 104 bool GetSignalLevel(int* level) override { |
105 *level = 1; | 105 *level = 1; |
106 return true; | 106 return true; |
107 } | 107 } |
108 rtc::scoped_refptr<webrtc::AudioProcessorInterface> GetAudioProcessor() | 108 rtc::scoped_refptr<webrtc::AudioProcessorInterface> GetAudioProcessor() |
109 override { | 109 override { |
110 return processor_; | 110 return processor_; |
111 } | 111 } |
(...skipping 21 matching lines...) Expand all Loading... |
133 }; | 133 }; |
134 | 134 |
135 class FakeAudioTrackWithInitValue | 135 class FakeAudioTrackWithInitValue |
136 : public webrtc::MediaStreamTrack<webrtc::AudioTrackInterface> { | 136 : public webrtc::MediaStreamTrack<webrtc::AudioTrackInterface> { |
137 public: | 137 public: |
138 explicit FakeAudioTrackWithInitValue(const std::string& id) | 138 explicit FakeAudioTrackWithInitValue(const std::string& id) |
139 : webrtc::MediaStreamTrack<webrtc::AudioTrackInterface>(id), | 139 : webrtc::MediaStreamTrack<webrtc::AudioTrackInterface>(id), |
140 processor_( | 140 processor_( |
141 new rtc::RefCountedObject<FakeAudioProcessorWithInitValue>()) {} | 141 new rtc::RefCountedObject<FakeAudioProcessorWithInitValue>()) {} |
142 std::string kind() const override { return "audio"; } | 142 std::string kind() const override { return "audio"; } |
143 webrtc::AudioSourceInterface* GetSource() const override { return NULL; } | 143 webrtc::AudioSourceInterface* GetSource() const override { return nullptr; } |
144 void AddSink(webrtc::AudioTrackSinkInterface* sink) override {} | 144 void AddSink(webrtc::AudioTrackSinkInterface* sink) override {} |
145 void RemoveSink(webrtc::AudioTrackSinkInterface* sink) override {} | 145 void RemoveSink(webrtc::AudioTrackSinkInterface* sink) override {} |
146 bool GetSignalLevel(int* level) override { | 146 bool GetSignalLevel(int* level) override { |
147 *level = 1; | 147 *level = 1; |
148 return true; | 148 return true; |
149 } | 149 } |
150 rtc::scoped_refptr<webrtc::AudioProcessorInterface> GetAudioProcessor() | 150 rtc::scoped_refptr<webrtc::AudioProcessorInterface> GetAudioProcessor() |
151 override { | 151 override { |
152 return processor_; | 152 return processor_; |
153 } | 153 } |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 } | 251 } |
252 | 252 |
253 void CheckCertChainReports(const StatsReports& reports, | 253 void CheckCertChainReports(const StatsReports& reports, |
254 const std::vector<std::string>& ders, | 254 const std::vector<std::string>& ders, |
255 const StatsReport::Id& start_id) { | 255 const StatsReport::Id& start_id) { |
256 StatsReport::Id cert_id; | 256 StatsReport::Id cert_id; |
257 const StatsReport::Id* certificate_id = &start_id; | 257 const StatsReport::Id* certificate_id = &start_id; |
258 size_t i = 0; | 258 size_t i = 0; |
259 while (true) { | 259 while (true) { |
260 const StatsReport* report = FindReportById(reports, *certificate_id); | 260 const StatsReport* report = FindReportById(reports, *certificate_id); |
261 ASSERT_TRUE(report != NULL); | 261 ASSERT_TRUE(report != nullptr); |
262 | 262 |
263 std::string der_base64; | 263 std::string der_base64; |
264 EXPECT_TRUE(GetValue( | 264 EXPECT_TRUE(GetValue( |
265 report, StatsReport::kStatsValueNameDer, &der_base64)); | 265 report, StatsReport::kStatsValueNameDer, &der_base64)); |
266 std::string der = rtc::Base64::Decode(der_base64, rtc::Base64::DO_STRICT); | 266 std::string der = rtc::Base64::Decode(der_base64, rtc::Base64::DO_STRICT); |
267 EXPECT_EQ(ders[i], der); | 267 EXPECT_EQ(ders[i], der); |
268 | 268 |
269 std::string fingerprint_algorithm; | 269 std::string fingerprint_algorithm; |
270 EXPECT_TRUE(GetValue( | 270 EXPECT_TRUE(GetValue( |
271 report, | 271 report, |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
559 stream_ = webrtc::MediaStream::Create("streamlabel"); | 559 stream_ = webrtc::MediaStream::Create("streamlabel"); |
560 track_ = webrtc::VideoTrack::Create(kRemoteTrackId, | 560 track_ = webrtc::VideoTrack::Create(kRemoteTrackId, |
561 webrtc::FakeVideoTrackSource::Create()); | 561 webrtc::FakeVideoTrackSource::Create()); |
562 stream_->AddTrack(track_); | 562 stream_->AddTrack(track_); |
563 EXPECT_CALL(session_, GetRemoteTrackIdBySsrc(kSsrcOfTrack, _)) | 563 EXPECT_CALL(session_, GetRemoteTrackIdBySsrc(kSsrcOfTrack, _)) |
564 .WillRepeatedly(DoAll(SetArgPointee<1>(kRemoteTrackId), Return(true))); | 564 .WillRepeatedly(DoAll(SetArgPointee<1>(kRemoteTrackId), Return(true))); |
565 } | 565 } |
566 | 566 |
567 // Adds a outgoing audio track with a given SSRC into the stats. | 567 // Adds a outgoing audio track with a given SSRC into the stats. |
568 void AddOutgoingAudioTrackStats() { | 568 void AddOutgoingAudioTrackStats() { |
569 if (stream_ == NULL) | 569 if (stream_ == nullptr) |
570 stream_ = webrtc::MediaStream::Create("streamlabel"); | 570 stream_ = webrtc::MediaStream::Create("streamlabel"); |
571 | 571 |
572 audio_track_ = new rtc::RefCountedObject<FakeAudioTrack>( | 572 audio_track_ = new rtc::RefCountedObject<FakeAudioTrack>( |
573 kLocalTrackId); | 573 kLocalTrackId); |
574 stream_->AddTrack(audio_track_); | 574 stream_->AddTrack(audio_track_); |
575 EXPECT_CALL(session_, GetLocalTrackIdBySsrc(kSsrcOfTrack, _)) | 575 EXPECT_CALL(session_, GetLocalTrackIdBySsrc(kSsrcOfTrack, _)) |
576 .WillOnce(DoAll(SetArgPointee<1>(kLocalTrackId), Return(true))); | 576 .WillOnce(DoAll(SetArgPointee<1>(kLocalTrackId), Return(true))); |
577 } | 577 } |
578 | 578 |
579 // Adds a incoming audio track with a given SSRC into the stats. | 579 // Adds a incoming audio track with a given SSRC into the stats. |
580 void AddIncomingAudioTrackStats() { | 580 void AddIncomingAudioTrackStats() { |
581 if (stream_ == NULL) | 581 if (stream_ == nullptr) |
582 stream_ = webrtc::MediaStream::Create("streamlabel"); | 582 stream_ = webrtc::MediaStream::Create("streamlabel"); |
583 | 583 |
584 audio_track_ = new rtc::RefCountedObject<FakeAudioTrack>( | 584 audio_track_ = new rtc::RefCountedObject<FakeAudioTrack>( |
585 kRemoteTrackId); | 585 kRemoteTrackId); |
586 stream_->AddTrack(audio_track_); | 586 stream_->AddTrack(audio_track_); |
587 EXPECT_CALL(session_, GetRemoteTrackIdBySsrc(kSsrcOfTrack, _)) | 587 EXPECT_CALL(session_, GetRemoteTrackIdBySsrc(kSsrcOfTrack, _)) |
588 .WillOnce(DoAll(SetArgPointee<1>(kRemoteTrackId), Return(true))); | 588 .WillOnce(DoAll(SetArgPointee<1>(kRemoteTrackId), Return(true))); |
589 } | 589 } |
590 | 590 |
591 void AddDataChannel(cricket::DataChannelType type, | 591 void AddDataChannel(cricket::DataChannelType type, |
(...skipping 18 matching lines...) Expand all Loading... |
610 webrtc::StatsCollector* stats, | 610 webrtc::StatsCollector* stats, |
611 cricket::VoiceChannel* voice_channel, | 611 cricket::VoiceChannel* voice_channel, |
612 const std::string& vc_name, | 612 const std::string& vc_name, |
613 MockVoiceMediaChannel* media_channel, | 613 MockVoiceMediaChannel* media_channel, |
614 cricket::VoiceSenderInfo* voice_sender_info, | 614 cricket::VoiceSenderInfo* voice_sender_info, |
615 cricket::VoiceReceiverInfo* voice_receiver_info, | 615 cricket::VoiceReceiverInfo* voice_receiver_info, |
616 cricket::VoiceMediaInfo* stats_read, | 616 cricket::VoiceMediaInfo* stats_read, |
617 StatsReports* reports) { | 617 StatsReports* reports) { |
618 // A track can't have both sender report and recv report at the same time | 618 // A track can't have both sender report and recv report at the same time |
619 // for now, this might change in the future though. | 619 // for now, this might change in the future though. |
620 EXPECT_TRUE((voice_sender_info == NULL) ^ (voice_receiver_info == NULL)); | 620 EXPECT_TRUE((voice_sender_info == nullptr) ^ |
| 621 (voice_receiver_info == nullptr)); |
621 | 622 |
622 // Instruct the session to return stats containing the transport channel. | 623 // Instruct the session to return stats containing the transport channel. |
623 InitSessionStats(vc_name); | 624 InitSessionStats(vc_name); |
624 EXPECT_CALL(session_, GetStats(_)).WillRepeatedly(Invoke( | 625 EXPECT_CALL(session_, GetStats(_)).WillRepeatedly(Invoke( |
625 [this](const ChannelNamePairs&) { | 626 [this](const ChannelNamePairs&) { |
626 return std::unique_ptr<SessionStats>( | 627 return std::unique_ptr<SessionStats>( |
627 new SessionStats(session_stats_)); | 628 new SessionStats(session_stats_)); |
628 })); | 629 })); |
629 | 630 |
630 // Constructs an ssrc stats update. | 631 // Constructs an ssrc stats update. |
631 if (voice_sender_info) | 632 if (voice_sender_info) |
632 stats_read->senders.push_back(*voice_sender_info); | 633 stats_read->senders.push_back(*voice_sender_info); |
633 if (voice_receiver_info) | 634 if (voice_receiver_info) |
634 stats_read->receivers.push_back(*voice_receiver_info); | 635 stats_read->receivers.push_back(*voice_receiver_info); |
635 | 636 |
636 EXPECT_CALL(session_, voice_channel()).WillRepeatedly( | 637 EXPECT_CALL(session_, voice_channel()).WillRepeatedly( |
637 Return(voice_channel)); | 638 Return(voice_channel)); |
638 EXPECT_CALL(session_, video_channel()).WillRepeatedly(ReturnNull()); | 639 EXPECT_CALL(session_, video_channel()).WillRepeatedly(ReturnNull()); |
639 EXPECT_CALL(*media_channel, GetStats(_)) | 640 EXPECT_CALL(*media_channel, GetStats(_)) |
640 .WillOnce(DoAll(SetArgPointee<0>(*stats_read), Return(true))); | 641 .WillOnce(DoAll(SetArgPointee<0>(*stats_read), Return(true))); |
641 | 642 |
642 stats->UpdateStats(PeerConnectionInterface::kStatsOutputLevelStandard); | 643 stats->UpdateStats(PeerConnectionInterface::kStatsOutputLevelStandard); |
643 stats->ClearUpdateStatsCacheForTest(); | 644 stats->ClearUpdateStatsCacheForTest(); |
644 stats->GetStats(NULL, reports); | 645 stats->GetStats(nullptr, reports); |
645 | 646 |
646 // Verify the existence of the track report. | 647 // Verify the existence of the track report. |
647 const StatsReport* report = FindNthReportByType( | 648 const StatsReport* report = FindNthReportByType( |
648 *reports, StatsReport::kStatsReportTypeSsrc, 1); | 649 *reports, StatsReport::kStatsReportTypeSsrc, 1); |
649 EXPECT_FALSE(report == NULL); | 650 EXPECT_FALSE(report == nullptr); |
650 EXPECT_EQ(stats->GetTimeNow(), report->timestamp()); | 651 EXPECT_EQ(stats->GetTimeNow(), report->timestamp()); |
651 std::string track_id = ExtractSsrcStatsValue( | 652 std::string track_id = ExtractSsrcStatsValue( |
652 *reports, StatsReport::kStatsValueNameTrackId); | 653 *reports, StatsReport::kStatsValueNameTrackId); |
653 EXPECT_EQ(audio_track->id(), track_id); | 654 EXPECT_EQ(audio_track->id(), track_id); |
654 std::string ssrc_id = ExtractSsrcStatsValue( | 655 std::string ssrc_id = ExtractSsrcStatsValue( |
655 *reports, StatsReport::kStatsValueNameSsrc); | 656 *reports, StatsReport::kStatsValueNameSsrc); |
656 EXPECT_EQ(rtc::ToString<uint32_t>(kSsrcOfTrack), ssrc_id); | 657 EXPECT_EQ(rtc::ToString<uint32_t>(kSsrcOfTrack), ssrc_id); |
657 | 658 |
658 std::string media_type = ExtractSsrcStatsValue(*reports, | 659 std::string media_type = ExtractSsrcStatsValue(*reports, |
659 StatsReport::kStatsValueNameMediaType); | 660 StatsReport::kStatsValueNameMediaType); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
724 transport_stats.transport_name)) | 725 transport_stats.transport_name)) |
725 .WillOnce(Return(remote_cert.release())); | 726 .WillOnce(Return(remote_cert.release())); |
726 EXPECT_CALL(session_, GetStats(_)).WillOnce(Invoke( | 727 EXPECT_CALL(session_, GetStats(_)).WillOnce(Invoke( |
727 [&session_stats](const ChannelNamePairs&) { | 728 [&session_stats](const ChannelNamePairs&) { |
728 return std::unique_ptr<SessionStats>( | 729 return std::unique_ptr<SessionStats>( |
729 new SessionStats(session_stats)); | 730 new SessionStats(session_stats)); |
730 })); | 731 })); |
731 | 732 |
732 stats.UpdateStats(PeerConnectionInterface::kStatsOutputLevelStandard); | 733 stats.UpdateStats(PeerConnectionInterface::kStatsOutputLevelStandard); |
733 | 734 |
734 stats.GetStats(NULL, &reports); | 735 stats.GetStats(nullptr, &reports); |
735 | 736 |
736 const StatsReport* channel_report = FindNthReportByType( | 737 const StatsReport* channel_report = FindNthReportByType( |
737 reports, StatsReport::kStatsReportTypeComponent, 1); | 738 reports, StatsReport::kStatsReportTypeComponent, 1); |
738 EXPECT_TRUE(channel_report != NULL); | 739 EXPECT_TRUE(channel_report != nullptr); |
739 | 740 |
740 // Check local certificate chain. | 741 // Check local certificate chain. |
741 std::string local_certificate_id = ExtractStatsValue( | 742 std::string local_certificate_id = ExtractStatsValue( |
742 StatsReport::kStatsReportTypeComponent, | 743 StatsReport::kStatsReportTypeComponent, |
743 reports, | 744 reports, |
744 StatsReport::kStatsValueNameLocalCertificateId); | 745 StatsReport::kStatsValueNameLocalCertificateId); |
745 if (local_ders.size() > 0) { | 746 if (local_ders.size() > 0) { |
746 EXPECT_NE(kNotFound, local_certificate_id); | 747 EXPECT_NE(kNotFound, local_certificate_id); |
747 StatsReport::Id id(IdFromCertIdString(local_certificate_id)); | 748 StatsReport::Id id(IdFromCertIdString(local_certificate_id)); |
748 CheckCertChainReports(reports, local_ders, id); | 749 CheckCertChainReports(reports, local_ders, id); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
799 const int id = -1; | 800 const int id = -1; |
800 const std::string state = DataChannelInterface::DataStateString( | 801 const std::string state = DataChannelInterface::DataStateString( |
801 DataChannelInterface::DataState::kConnecting); | 802 DataChannelInterface::DataState::kConnecting); |
802 | 803 |
803 AddDataChannel(cricket::DCT_SCTP, label, id); | 804 AddDataChannel(cricket::DCT_SCTP, label, id); |
804 StatsCollectorForTest stats(&pc_); | 805 StatsCollectorForTest stats(&pc_); |
805 | 806 |
806 stats.UpdateStats(PeerConnectionInterface::kStatsOutputLevelStandard); | 807 stats.UpdateStats(PeerConnectionInterface::kStatsOutputLevelStandard); |
807 | 808 |
808 StatsReports reports; | 809 StatsReports reports; |
809 stats.GetStats(NULL, &reports); | 810 stats.GetStats(nullptr, &reports); |
810 | 811 |
811 const StatsReport* report = | 812 const StatsReport* report = |
812 FindNthReportByType(reports, StatsReport::kStatsReportTypeDataChannel, 1); | 813 FindNthReportByType(reports, StatsReport::kStatsReportTypeDataChannel, 1); |
813 | 814 |
814 std::string value_in_report; | 815 std::string value_in_report; |
815 EXPECT_FALSE(GetValue(report, StatsReport::kStatsValueNameDataChannelId, | 816 EXPECT_FALSE(GetValue(report, StatsReport::kStatsValueNameDataChannelId, |
816 &value_in_report)); | 817 &value_in_report)); |
817 } | 818 } |
818 | 819 |
819 // Verify that ExtractDataInfo populates reports. | 820 // Verify that ExtractDataInfo populates reports. |
820 TEST_F(StatsCollectorTest, ExtractDataInfo) { | 821 TEST_F(StatsCollectorTest, ExtractDataInfo) { |
821 const std::string label = "hacks"; | 822 const std::string label = "hacks"; |
822 const int id = 31337; | 823 const int id = 31337; |
823 const std::string state = DataChannelInterface::DataStateString( | 824 const std::string state = DataChannelInterface::DataStateString( |
824 DataChannelInterface::DataState::kConnecting); | 825 DataChannelInterface::DataState::kConnecting); |
825 | 826 |
826 AddDataChannel(cricket::DCT_SCTP, label, id); | 827 AddDataChannel(cricket::DCT_SCTP, label, id); |
827 StatsCollectorForTest stats(&pc_); | 828 StatsCollectorForTest stats(&pc_); |
828 | 829 |
829 stats.UpdateStats(PeerConnectionInterface::kStatsOutputLevelStandard); | 830 stats.UpdateStats(PeerConnectionInterface::kStatsOutputLevelStandard); |
830 | 831 |
831 StatsReports reports; | 832 StatsReports reports; |
832 stats.GetStats(NULL, &reports); | 833 stats.GetStats(nullptr, &reports); |
833 | 834 |
834 const StatsReport* report = | 835 const StatsReport* report = |
835 FindNthReportByType(reports, StatsReport::kStatsReportTypeDataChannel, 1); | 836 FindNthReportByType(reports, StatsReport::kStatsReportTypeDataChannel, 1); |
836 | 837 |
837 StatsReport::Id reportId = StatsReport::NewTypedIntId( | 838 StatsReport::Id reportId = StatsReport::NewTypedIntId( |
838 StatsReport::kStatsReportTypeDataChannel, id); | 839 StatsReport::kStatsReportTypeDataChannel, id); |
839 | 840 |
840 EXPECT_TRUE(reportId->Equals(report->id())); | 841 EXPECT_TRUE(reportId->Equals(report->id())); |
841 | 842 |
842 EXPECT_EQ(stats.GetTimeNow(), report->timestamp()); | 843 EXPECT_EQ(stats.GetTimeNow(), report->timestamp()); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
890 video_sender_info.add_ssrc(1234); | 891 video_sender_info.add_ssrc(1234); |
891 video_sender_info.bytes_sent = kBytesSent; | 892 video_sender_info.bytes_sent = kBytesSent; |
892 stats_read.senders.push_back(video_sender_info); | 893 stats_read.senders.push_back(video_sender_info); |
893 | 894 |
894 EXPECT_CALL(session_, video_channel()).WillRepeatedly(Return(&video_channel)); | 895 EXPECT_CALL(session_, video_channel()).WillRepeatedly(Return(&video_channel)); |
895 EXPECT_CALL(session_, voice_channel()).WillRepeatedly(ReturnNull()); | 896 EXPECT_CALL(session_, voice_channel()).WillRepeatedly(ReturnNull()); |
896 EXPECT_CALL(*media_channel, GetStats(_)) | 897 EXPECT_CALL(*media_channel, GetStats(_)) |
897 .WillOnce(DoAll(SetArgPointee<0>(stats_read), | 898 .WillOnce(DoAll(SetArgPointee<0>(stats_read), |
898 Return(true))); | 899 Return(true))); |
899 stats.UpdateStats(PeerConnectionInterface::kStatsOutputLevelStandard); | 900 stats.UpdateStats(PeerConnectionInterface::kStatsOutputLevelStandard); |
900 stats.GetStats(NULL, &reports); | 901 stats.GetStats(nullptr, &reports); |
901 std::string result = ExtractSsrcStatsValue(reports, | 902 std::string result = ExtractSsrcStatsValue(reports, |
902 StatsReport::kStatsValueNameBytesSent); | 903 StatsReport::kStatsValueNameBytesSent); |
903 EXPECT_EQ(kBytesSentString, result); | 904 EXPECT_EQ(kBytesSentString, result); |
904 } | 905 } |
905 | 906 |
906 // Test that BWE information is reported via stats. | 907 // Test that BWE information is reported via stats. |
907 TEST_F(StatsCollectorTest, BandwidthEstimationInfoIsReported) { | 908 TEST_F(StatsCollectorTest, BandwidthEstimationInfoIsReported) { |
908 StatsCollectorForTest stats(&pc_); | 909 StatsCollectorForTest stats(&pc_); |
909 | 910 |
910 EXPECT_CALL(session_, GetLocalCertificate(_, _)) | 911 EXPECT_CALL(session_, GetLocalCertificate(_, _)) |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
946 const std::string kTargetEncBitrateString("123456"); | 947 const std::string kTargetEncBitrateString("123456"); |
947 bwe.target_enc_bitrate = kTargetEncBitrate; | 948 bwe.target_enc_bitrate = kTargetEncBitrate; |
948 stats_read.bw_estimations.push_back(bwe); | 949 stats_read.bw_estimations.push_back(bwe); |
949 | 950 |
950 EXPECT_CALL(session_, video_channel()).WillRepeatedly(Return(&video_channel)); | 951 EXPECT_CALL(session_, video_channel()).WillRepeatedly(Return(&video_channel)); |
951 EXPECT_CALL(session_, voice_channel()).WillRepeatedly(ReturnNull()); | 952 EXPECT_CALL(session_, voice_channel()).WillRepeatedly(ReturnNull()); |
952 EXPECT_CALL(*media_channel, GetStats(_)) | 953 EXPECT_CALL(*media_channel, GetStats(_)) |
953 .WillOnce(DoAll(SetArgPointee<0>(stats_read), Return(true))); | 954 .WillOnce(DoAll(SetArgPointee<0>(stats_read), Return(true))); |
954 | 955 |
955 stats.UpdateStats(PeerConnectionInterface::kStatsOutputLevelStandard); | 956 stats.UpdateStats(PeerConnectionInterface::kStatsOutputLevelStandard); |
956 stats.GetStats(NULL, &reports); | 957 stats.GetStats(nullptr, &reports); |
957 std::string result = ExtractSsrcStatsValue(reports, | 958 std::string result = ExtractSsrcStatsValue(reports, |
958 StatsReport::kStatsValueNameBytesSent); | 959 StatsReport::kStatsValueNameBytesSent); |
959 EXPECT_EQ(kBytesSentString, result); | 960 EXPECT_EQ(kBytesSentString, result); |
960 result = ExtractBweStatsValue(reports, | 961 result = ExtractBweStatsValue(reports, |
961 StatsReport::kStatsValueNameTargetEncBitrate); | 962 StatsReport::kStatsValueNameTargetEncBitrate); |
962 EXPECT_EQ(kTargetEncBitrateString, result); | 963 EXPECT_EQ(kTargetEncBitrateString, result); |
963 } | 964 } |
964 | 965 |
965 // This test verifies that an object of type "googSession" always | 966 // This test verifies that an object of type "googSession" always |
966 // exists in the returned stats. | 967 // exists in the returned stats. |
967 TEST_F(StatsCollectorTest, SessionObjectExists) { | 968 TEST_F(StatsCollectorTest, SessionObjectExists) { |
968 StatsCollectorForTest stats(&pc_); | 969 StatsCollectorForTest stats(&pc_); |
969 | 970 |
970 StatsReports reports; // returned values. | 971 StatsReports reports; // returned values. |
971 stats.UpdateStats(PeerConnectionInterface::kStatsOutputLevelStandard); | 972 stats.UpdateStats(PeerConnectionInterface::kStatsOutputLevelStandard); |
972 stats.GetStats(NULL, &reports); | 973 stats.GetStats(nullptr, &reports); |
973 const StatsReport* session_report = FindNthReportByType( | 974 const StatsReport* session_report = FindNthReportByType( |
974 reports, StatsReport::kStatsReportTypeSession, 1); | 975 reports, StatsReport::kStatsReportTypeSession, 1); |
975 EXPECT_FALSE(session_report == NULL); | 976 EXPECT_FALSE(session_report == nullptr); |
976 } | 977 } |
977 | 978 |
978 // This test verifies that only one object of type "googSession" exists | 979 // This test verifies that only one object of type "googSession" exists |
979 // in the returned stats. | 980 // in the returned stats. |
980 TEST_F(StatsCollectorTest, OnlyOneSessionObjectExists) { | 981 TEST_F(StatsCollectorTest, OnlyOneSessionObjectExists) { |
981 StatsCollectorForTest stats(&pc_); | 982 StatsCollectorForTest stats(&pc_); |
982 | 983 |
983 StatsReports reports; // returned values. | 984 StatsReports reports; // returned values. |
984 stats.UpdateStats(PeerConnectionInterface::kStatsOutputLevelStandard); | 985 stats.UpdateStats(PeerConnectionInterface::kStatsOutputLevelStandard); |
985 stats.UpdateStats(PeerConnectionInterface::kStatsOutputLevelStandard); | 986 stats.UpdateStats(PeerConnectionInterface::kStatsOutputLevelStandard); |
986 stats.GetStats(NULL, &reports); | 987 stats.GetStats(nullptr, &reports); |
987 const StatsReport* session_report = FindNthReportByType( | 988 const StatsReport* session_report = FindNthReportByType( |
988 reports, StatsReport::kStatsReportTypeSession, 1); | 989 reports, StatsReport::kStatsReportTypeSession, 1); |
989 EXPECT_FALSE(session_report == NULL); | 990 EXPECT_FALSE(session_report == nullptr); |
990 session_report = FindNthReportByType( | 991 session_report = FindNthReportByType( |
991 reports, StatsReport::kStatsReportTypeSession, 2); | 992 reports, StatsReport::kStatsReportTypeSession, 2); |
992 EXPECT_EQ(NULL, session_report); | 993 EXPECT_EQ(nullptr, session_report); |
993 } | 994 } |
994 | 995 |
995 // This test verifies that the empty track report exists in the returned stats | 996 // This test verifies that the empty track report exists in the returned stats |
996 // without calling StatsCollector::UpdateStats. | 997 // without calling StatsCollector::UpdateStats. |
997 TEST_F(StatsCollectorTest, TrackObjectExistsWithoutUpdateStats) { | 998 TEST_F(StatsCollectorTest, TrackObjectExistsWithoutUpdateStats) { |
998 StatsCollectorForTest stats(&pc_); | 999 StatsCollectorForTest stats(&pc_); |
999 | 1000 |
1000 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); | 1001 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); |
1001 cricket::VideoChannel video_channel( | 1002 cricket::VideoChannel video_channel( |
1002 worker_thread_, network_thread_, nullptr, media_channel, "video", | 1003 worker_thread_, network_thread_, nullptr, media_channel, "video", |
1003 kDefaultRtcpMuxRequired, kDefaultSrtpRequired); | 1004 kDefaultRtcpMuxRequired, kDefaultSrtpRequired); |
1004 AddOutgoingVideoTrackStats(); | 1005 AddOutgoingVideoTrackStats(); |
1005 stats.AddStream(stream_); | 1006 stats.AddStream(stream_); |
1006 | 1007 |
1007 // Verfies the existence of the track report. | 1008 // Verfies the existence of the track report. |
1008 StatsReports reports; | 1009 StatsReports reports; |
1009 stats.GetStats(NULL, &reports); | 1010 stats.GetStats(nullptr, &reports); |
1010 EXPECT_EQ((size_t)1, reports.size()); | 1011 EXPECT_EQ((size_t)1, reports.size()); |
1011 EXPECT_EQ(StatsReport::kStatsReportTypeTrack, reports[0]->type()); | 1012 EXPECT_EQ(StatsReport::kStatsReportTypeTrack, reports[0]->type()); |
1012 EXPECT_EQ(0, reports[0]->timestamp()); | 1013 EXPECT_EQ(0, reports[0]->timestamp()); |
1013 | 1014 |
1014 std::string trackValue = | 1015 std::string trackValue = |
1015 ExtractStatsValue(StatsReport::kStatsReportTypeTrack, | 1016 ExtractStatsValue(StatsReport::kStatsReportTypeTrack, |
1016 reports, | 1017 reports, |
1017 StatsReport::kStatsValueNameTrackId); | 1018 StatsReport::kStatsValueNameTrackId); |
1018 EXPECT_EQ(kLocalTrackId, trackValue); | 1019 EXPECT_EQ(kLocalTrackId, trackValue); |
1019 } | 1020 } |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1054 stats_read.senders.push_back(video_sender_info); | 1055 stats_read.senders.push_back(video_sender_info); |
1055 | 1056 |
1056 EXPECT_CALL(session_, video_channel()).WillRepeatedly(Return(&video_channel)); | 1057 EXPECT_CALL(session_, video_channel()).WillRepeatedly(Return(&video_channel)); |
1057 EXPECT_CALL(session_, voice_channel()).WillRepeatedly(ReturnNull()); | 1058 EXPECT_CALL(session_, voice_channel()).WillRepeatedly(ReturnNull()); |
1058 EXPECT_CALL(*media_channel, GetStats(_)) | 1059 EXPECT_CALL(*media_channel, GetStats(_)) |
1059 .WillOnce(DoAll(SetArgPointee<0>(stats_read), | 1060 .WillOnce(DoAll(SetArgPointee<0>(stats_read), |
1060 Return(true))); | 1061 Return(true))); |
1061 | 1062 |
1062 stats.UpdateStats(PeerConnectionInterface::kStatsOutputLevelStandard); | 1063 stats.UpdateStats(PeerConnectionInterface::kStatsOutputLevelStandard); |
1063 StatsReports reports; | 1064 StatsReports reports; |
1064 stats.GetStats(NULL, &reports); | 1065 stats.GetStats(nullptr, &reports); |
1065 // |reports| should contain at least one session report, one track report, | 1066 // |reports| should contain at least one session report, one track report, |
1066 // and one ssrc report. | 1067 // and one ssrc report. |
1067 EXPECT_LE((size_t)3, reports.size()); | 1068 EXPECT_LE((size_t)3, reports.size()); |
1068 const StatsReport* track_report = FindNthReportByType( | 1069 const StatsReport* track_report = FindNthReportByType( |
1069 reports, StatsReport::kStatsReportTypeTrack, 1); | 1070 reports, StatsReport::kStatsReportTypeTrack, 1); |
1070 EXPECT_TRUE(track_report); | 1071 EXPECT_TRUE(track_report); |
1071 | 1072 |
1072 // Get report for the specific |track|. | 1073 // Get report for the specific |track|. |
1073 reports.clear(); | 1074 reports.clear(); |
1074 stats.GetStats(track_, &reports); | 1075 stats.GetStats(track_, &reports); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1130 | 1131 |
1131 InitSessionStats(kVcName); | 1132 InitSessionStats(kVcName); |
1132 EXPECT_CALL(session_, GetStats(_)).WillRepeatedly(Invoke( | 1133 EXPECT_CALL(session_, GetStats(_)).WillRepeatedly(Invoke( |
1133 [this](const ChannelNamePairs&) { | 1134 [this](const ChannelNamePairs&) { |
1134 return std::unique_ptr<SessionStats>( | 1135 return std::unique_ptr<SessionStats>( |
1135 new SessionStats(session_stats_)); | 1136 new SessionStats(session_stats_)); |
1136 })); | 1137 })); |
1137 | 1138 |
1138 stats.UpdateStats(PeerConnectionInterface::kStatsOutputLevelStandard); | 1139 stats.UpdateStats(PeerConnectionInterface::kStatsOutputLevelStandard); |
1139 StatsReports reports; | 1140 StatsReports reports; |
1140 stats.GetStats(NULL, &reports); | 1141 stats.GetStats(nullptr, &reports); |
1141 std::string transport_id = ExtractStatsValue( | 1142 std::string transport_id = ExtractStatsValue( |
1142 StatsReport::kStatsReportTypeSsrc, | 1143 StatsReport::kStatsReportTypeSsrc, |
1143 reports, | 1144 reports, |
1144 StatsReport::kStatsValueNameTransportId); | 1145 StatsReport::kStatsValueNameTransportId); |
1145 ASSERT_NE(kNotFound, transport_id); | 1146 ASSERT_NE(kNotFound, transport_id); |
1146 // Transport id component ID will always be 1. | 1147 // Transport id component ID will always be 1. |
1147 // This has assumptions about how the ID is constructed. As is, this is | 1148 // This has assumptions about how the ID is constructed. As is, this is |
1148 // OK since this is for testing purposes only, but if we ever need this | 1149 // OK since this is for testing purposes only, but if we ever need this |
1149 // in production, we should add a generic method that does this. | 1150 // in production, we should add a generic method that does this. |
1150 size_t index = transport_id.find('-'); | 1151 size_t index = transport_id.find('-'); |
1151 ASSERT_NE(std::string::npos, index); | 1152 ASSERT_NE(std::string::npos, index); |
1152 std::string content = transport_id.substr(index + 1); | 1153 std::string content = transport_id.substr(index + 1); |
1153 index = content.rfind('-'); | 1154 index = content.rfind('-'); |
1154 ASSERT_NE(std::string::npos, index); | 1155 ASSERT_NE(std::string::npos, index); |
1155 content = content.substr(0, index); | 1156 content = content.substr(0, index); |
1156 StatsReport::Id id(StatsReport::NewComponentId(content, 1)); | 1157 StatsReport::Id id(StatsReport::NewComponentId(content, 1)); |
1157 ASSERT_EQ(transport_id, id->ToString()); | 1158 ASSERT_EQ(transport_id, id->ToString()); |
1158 const StatsReport* transport_report = FindReportById(reports, id); | 1159 const StatsReport* transport_report = FindReportById(reports, id); |
1159 ASSERT_FALSE(transport_report == NULL); | 1160 ASSERT_FALSE(transport_report == nullptr); |
1160 } | 1161 } |
1161 | 1162 |
1162 // This test verifies that a remote stats object will not be created for | 1163 // This test verifies that a remote stats object will not be created for |
1163 // an outgoing SSRC where remote stats are not returned. | 1164 // an outgoing SSRC where remote stats are not returned. |
1164 TEST_F(StatsCollectorTest, RemoteSsrcInfoIsAbsent) { | 1165 TEST_F(StatsCollectorTest, RemoteSsrcInfoIsAbsent) { |
1165 StatsCollectorForTest stats(&pc_); | 1166 StatsCollectorForTest stats(&pc_); |
1166 | 1167 |
1167 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); | 1168 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); |
1168 // The transport_name known by the video channel. | 1169 // The transport_name known by the video channel. |
1169 const std::string kVcName("vcname"); | 1170 const std::string kVcName("vcname"); |
1170 cricket::VideoChannel video_channel( | 1171 cricket::VideoChannel video_channel( |
1171 worker_thread_, network_thread_, nullptr, media_channel, kVcName, | 1172 worker_thread_, network_thread_, nullptr, media_channel, kVcName, |
1172 kDefaultRtcpMuxRequired, kDefaultSrtpRequired); | 1173 kDefaultRtcpMuxRequired, kDefaultSrtpRequired); |
1173 AddOutgoingVideoTrackStats(); | 1174 AddOutgoingVideoTrackStats(); |
1174 stats.AddStream(stream_); | 1175 stats.AddStream(stream_); |
1175 | 1176 |
1176 stats.UpdateStats(PeerConnectionInterface::kStatsOutputLevelStandard); | 1177 stats.UpdateStats(PeerConnectionInterface::kStatsOutputLevelStandard); |
1177 StatsReports reports; | 1178 StatsReports reports; |
1178 stats.GetStats(NULL, &reports); | 1179 stats.GetStats(nullptr, &reports); |
1179 const StatsReport* remote_report = FindNthReportByType(reports, | 1180 const StatsReport* remote_report = FindNthReportByType(reports, |
1180 StatsReport::kStatsReportTypeRemoteSsrc, 1); | 1181 StatsReport::kStatsReportTypeRemoteSsrc, 1); |
1181 EXPECT_TRUE(remote_report == NULL); | 1182 EXPECT_TRUE(remote_report == nullptr); |
1182 } | 1183 } |
1183 | 1184 |
1184 // This test verifies that a remote stats object will be created for | 1185 // This test verifies that a remote stats object will be created for |
1185 // an outgoing SSRC where stats are returned. | 1186 // an outgoing SSRC where stats are returned. |
1186 TEST_F(StatsCollectorTest, RemoteSsrcInfoIsPresent) { | 1187 TEST_F(StatsCollectorTest, RemoteSsrcInfoIsPresent) { |
1187 StatsCollectorForTest stats(&pc_); | 1188 StatsCollectorForTest stats(&pc_); |
1188 | 1189 |
1189 EXPECT_CALL(session_, GetLocalCertificate(_, _)) | 1190 EXPECT_CALL(session_, GetLocalCertificate(_, _)) |
1190 .WillRepeatedly(Return(false)); | 1191 .WillRepeatedly(Return(false)); |
1191 EXPECT_CALL(session_, GetRemoteSSLCertificate_ReturnsRawPointer(_)) | 1192 EXPECT_CALL(session_, GetRemoteSSLCertificate_ReturnsRawPointer(_)) |
(...skipping 28 matching lines...) Expand all Loading... |
1220 stats_read.senders.push_back(video_sender_info); | 1221 stats_read.senders.push_back(video_sender_info); |
1221 | 1222 |
1222 EXPECT_CALL(session_, video_channel()).WillRepeatedly(Return(&video_channel)); | 1223 EXPECT_CALL(session_, video_channel()).WillRepeatedly(Return(&video_channel)); |
1223 EXPECT_CALL(session_, voice_channel()).WillRepeatedly(ReturnNull()); | 1224 EXPECT_CALL(session_, voice_channel()).WillRepeatedly(ReturnNull()); |
1224 EXPECT_CALL(*media_channel, GetStats(_)) | 1225 EXPECT_CALL(*media_channel, GetStats(_)) |
1225 .WillRepeatedly(DoAll(SetArgPointee<0>(stats_read), | 1226 .WillRepeatedly(DoAll(SetArgPointee<0>(stats_read), |
1226 Return(true))); | 1227 Return(true))); |
1227 | 1228 |
1228 stats.UpdateStats(PeerConnectionInterface::kStatsOutputLevelStandard); | 1229 stats.UpdateStats(PeerConnectionInterface::kStatsOutputLevelStandard); |
1229 StatsReports reports; | 1230 StatsReports reports; |
1230 stats.GetStats(NULL, &reports); | 1231 stats.GetStats(nullptr, &reports); |
1231 | 1232 |
1232 const StatsReport* remote_report = FindNthReportByType(reports, | 1233 const StatsReport* remote_report = FindNthReportByType(reports, |
1233 StatsReport::kStatsReportTypeRemoteSsrc, 1); | 1234 StatsReport::kStatsReportTypeRemoteSsrc, 1); |
1234 EXPECT_FALSE(remote_report == NULL); | 1235 EXPECT_FALSE(remote_report == nullptr); |
1235 EXPECT_EQ(12345.678, remote_report->timestamp()); | 1236 EXPECT_EQ(12345.678, remote_report->timestamp()); |
1236 } | 1237 } |
1237 | 1238 |
1238 // This test verifies that the empty track report exists in the returned stats | 1239 // This test verifies that the empty track report exists in the returned stats |
1239 // when StatsCollector::UpdateStats is called with ssrc stats. | 1240 // when StatsCollector::UpdateStats is called with ssrc stats. |
1240 TEST_F(StatsCollectorTest, ReportsFromRemoteTrack) { | 1241 TEST_F(StatsCollectorTest, ReportsFromRemoteTrack) { |
1241 StatsCollectorForTest stats(&pc_); | 1242 StatsCollectorForTest stats(&pc_); |
1242 | 1243 |
1243 EXPECT_CALL(session_, GetLocalCertificate(_, _)) | 1244 EXPECT_CALL(session_, GetLocalCertificate(_, _)) |
1244 .WillRepeatedly(Return(false)); | 1245 .WillRepeatedly(Return(false)); |
(...skipping 26 matching lines...) Expand all Loading... |
1271 stats_read.receivers.push_back(video_receiver_info); | 1272 stats_read.receivers.push_back(video_receiver_info); |
1272 | 1273 |
1273 EXPECT_CALL(session_, video_channel()).WillRepeatedly(Return(&video_channel)); | 1274 EXPECT_CALL(session_, video_channel()).WillRepeatedly(Return(&video_channel)); |
1274 EXPECT_CALL(session_, voice_channel()).WillRepeatedly(ReturnNull()); | 1275 EXPECT_CALL(session_, voice_channel()).WillRepeatedly(ReturnNull()); |
1275 EXPECT_CALL(*media_channel, GetStats(_)) | 1276 EXPECT_CALL(*media_channel, GetStats(_)) |
1276 .WillOnce(DoAll(SetArgPointee<0>(stats_read), | 1277 .WillOnce(DoAll(SetArgPointee<0>(stats_read), |
1277 Return(true))); | 1278 Return(true))); |
1278 | 1279 |
1279 stats.UpdateStats(PeerConnectionInterface::kStatsOutputLevelStandard); | 1280 stats.UpdateStats(PeerConnectionInterface::kStatsOutputLevelStandard); |
1280 StatsReports reports; | 1281 StatsReports reports; |
1281 stats.GetStats(NULL, &reports); | 1282 stats.GetStats(nullptr, &reports); |
1282 // |reports| should contain at least one session report, one track report, | 1283 // |reports| should contain at least one session report, one track report, |
1283 // and one ssrc report. | 1284 // and one ssrc report. |
1284 EXPECT_LE(static_cast<size_t>(3), reports.size()); | 1285 EXPECT_LE(static_cast<size_t>(3), reports.size()); |
1285 const StatsReport* track_report = FindNthReportByType( | 1286 const StatsReport* track_report = FindNthReportByType( |
1286 reports, StatsReport::kStatsReportTypeTrack, 1); | 1287 reports, StatsReport::kStatsReportTypeTrack, 1); |
1287 EXPECT_TRUE(track_report); | 1288 EXPECT_TRUE(track_report); |
1288 EXPECT_EQ(stats.GetTimeNow(), track_report->timestamp()); | 1289 EXPECT_EQ(stats.GetTimeNow(), track_report->timestamp()); |
1289 | 1290 |
1290 std::string ssrc_id = ExtractSsrcStatsValue( | 1291 std::string ssrc_id = ExtractSsrcStatsValue( |
1291 reports, StatsReport::kStatsValueNameSsrc); | 1292 reports, StatsReport::kStatsValueNameSsrc); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1326 c = cricket::Candidate(); | 1327 c = cricket::Candidate(); |
1327 EXPECT_GT(c.id().length(), 0u); | 1328 EXPECT_GT(c.id().length(), 0u); |
1328 c.set_type(cricket::PRFLX_PORT_TYPE); | 1329 c.set_type(cricket::PRFLX_PORT_TYPE); |
1329 c.set_protocol(cricket::UDP_PROTOCOL_NAME); | 1330 c.set_protocol(cricket::UDP_PROTOCOL_NAME); |
1330 c.set_address(remote_address); | 1331 c.set_address(remote_address); |
1331 c.set_priority(priority); | 1332 c.set_priority(priority); |
1332 c.set_network_type(network_type); | 1333 c.set_network_type(network_type); |
1333 report_id = AddCandidateReport(&stats, c, false)->id()->ToString(); | 1334 report_id = AddCandidateReport(&stats, c, false)->id()->ToString(); |
1334 EXPECT_EQ("Cand-" + c.id(), report_id); | 1335 EXPECT_EQ("Cand-" + c.id(), report_id); |
1335 | 1336 |
1336 stats.GetStats(NULL, &reports); | 1337 stats.GetStats(nullptr, &reports); |
1337 | 1338 |
1338 // Verify the local candidate report is populated correctly. | 1339 // Verify the local candidate report is populated correctly. |
1339 EXPECT_EQ( | 1340 EXPECT_EQ( |
1340 local_ip, | 1341 local_ip, |
1341 ExtractStatsValue(StatsReport::kStatsReportTypeIceLocalCandidate, reports, | 1342 ExtractStatsValue(StatsReport::kStatsReportTypeIceLocalCandidate, reports, |
1342 StatsReport::kStatsValueNameCandidateIPAddress)); | 1343 StatsReport::kStatsValueNameCandidateIPAddress)); |
1343 EXPECT_EQ( | 1344 EXPECT_EQ( |
1344 rtc::ToString<int>(local_port), | 1345 rtc::ToString<int>(local_port), |
1345 ExtractStatsValue(StatsReport::kStatsReportTypeIceLocalCandidate, reports, | 1346 ExtractStatsValue(StatsReport::kStatsReportTypeIceLocalCandidate, reports, |
1346 StatsReport::kStatsValueNameCandidatePortNumber)); | 1347 StatsReport::kStatsValueNameCandidatePortNumber)); |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1455 transport_stats; | 1456 transport_stats; |
1456 | 1457 |
1457 // Configure MockWebRtcSession | 1458 // Configure MockWebRtcSession |
1458 EXPECT_CALL(session_, GetStats(_)).WillRepeatedly(Invoke( | 1459 EXPECT_CALL(session_, GetStats(_)).WillRepeatedly(Invoke( |
1459 [&session_stats](const ChannelNamePairs&) { | 1460 [&session_stats](const ChannelNamePairs&) { |
1460 return std::unique_ptr<SessionStats>( | 1461 return std::unique_ptr<SessionStats>( |
1461 new SessionStats(session_stats)); | 1462 new SessionStats(session_stats)); |
1462 })); | 1463 })); |
1463 | 1464 |
1464 stats.UpdateStats(PeerConnectionInterface::kStatsOutputLevelStandard); | 1465 stats.UpdateStats(PeerConnectionInterface::kStatsOutputLevelStandard); |
1465 stats.GetStats(NULL, &reports); | 1466 stats.GetStats(nullptr, &reports); |
1466 | 1467 |
1467 // Check that the local certificate is absent. | 1468 // Check that the local certificate is absent. |
1468 std::string local_certificate_id = ExtractStatsValue( | 1469 std::string local_certificate_id = ExtractStatsValue( |
1469 StatsReport::kStatsReportTypeComponent, | 1470 StatsReport::kStatsReportTypeComponent, |
1470 reports, | 1471 reports, |
1471 StatsReport::kStatsValueNameLocalCertificateId); | 1472 StatsReport::kStatsValueNameLocalCertificateId); |
1472 ASSERT_EQ(kNotFound, local_certificate_id); | 1473 ASSERT_EQ(kNotFound, local_certificate_id); |
1473 | 1474 |
1474 // Check that the remote certificate is absent. | 1475 // Check that the remote certificate is absent. |
1475 std::string remote_certificate_id = ExtractStatsValue( | 1476 std::string remote_certificate_id = ExtractStatsValue( |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1513 session_stats.transport_stats[transport_stats.transport_name] = | 1514 session_stats.transport_stats[transport_stats.transport_name] = |
1514 transport_stats; | 1515 transport_stats; |
1515 | 1516 |
1516 // Configure MockWebRtcSession | 1517 // Configure MockWebRtcSession |
1517 EXPECT_CALL(session_, GetStats(_)).WillRepeatedly(Invoke( | 1518 EXPECT_CALL(session_, GetStats(_)).WillRepeatedly(Invoke( |
1518 [&session_stats](const ChannelNamePairs&) { | 1519 [&session_stats](const ChannelNamePairs&) { |
1519 return std::unique_ptr<SessionStats>( | 1520 return std::unique_ptr<SessionStats>( |
1520 new SessionStats(session_stats)); | 1521 new SessionStats(session_stats)); |
1521 })); | 1522 })); |
1522 stats.UpdateStats(PeerConnectionInterface::kStatsOutputLevelStandard); | 1523 stats.UpdateStats(PeerConnectionInterface::kStatsOutputLevelStandard); |
1523 stats.GetStats(NULL, &reports); | 1524 stats.GetStats(nullptr, &reports); |
1524 | 1525 |
1525 // Check that the local certificate is absent. | 1526 // Check that the local certificate is absent. |
1526 std::string local_certificate_id = ExtractStatsValue( | 1527 std::string local_certificate_id = ExtractStatsValue( |
1527 StatsReport::kStatsReportTypeComponent, | 1528 StatsReport::kStatsReportTypeComponent, |
1528 reports, | 1529 reports, |
1529 StatsReport::kStatsValueNameLocalCertificateId); | 1530 StatsReport::kStatsValueNameLocalCertificateId); |
1530 ASSERT_EQ(kNotFound, local_certificate_id); | 1531 ASSERT_EQ(kNotFound, local_certificate_id); |
1531 | 1532 |
1532 // Check that the remote certificate is absent. | 1533 // Check that the remote certificate is absent. |
1533 std::string remote_certificate_id = ExtractStatsValue( | 1534 std::string remote_certificate_id = ExtractStatsValue( |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1565 .WillRepeatedly(Return(nullptr)); | 1566 .WillRepeatedly(Return(nullptr)); |
1566 | 1567 |
1567 MockVoiceMediaChannel* media_channel = new MockVoiceMediaChannel(); | 1568 MockVoiceMediaChannel* media_channel = new MockVoiceMediaChannel(); |
1568 // The transport_name known by the voice channel. | 1569 // The transport_name known by the voice channel. |
1569 const std::string kVcName("vcname"); | 1570 const std::string kVcName("vcname"); |
1570 cricket::VoiceChannel voice_channel( | 1571 cricket::VoiceChannel voice_channel( |
1571 worker_thread_, network_thread_, nullptr, media_engine_, media_channel, | 1572 worker_thread_, network_thread_, nullptr, media_engine_, media_channel, |
1572 kVcName, kDefaultRtcpMuxRequired, kDefaultSrtpRequired); | 1573 kVcName, kDefaultRtcpMuxRequired, kDefaultSrtpRequired); |
1573 | 1574 |
1574 // Create a local stream with a local audio track and adds it to the stats. | 1575 // Create a local stream with a local audio track and adds it to the stats. |
1575 if (stream_ == NULL) | 1576 if (stream_ == nullptr) |
1576 stream_ = webrtc::MediaStream::Create("streamlabel"); | 1577 stream_ = webrtc::MediaStream::Create("streamlabel"); |
1577 | 1578 |
1578 rtc::scoped_refptr<FakeAudioTrackWithInitValue> local_track( | 1579 rtc::scoped_refptr<FakeAudioTrackWithInitValue> local_track( |
1579 new rtc::RefCountedObject<FakeAudioTrackWithInitValue>(kLocalTrackId)); | 1580 new rtc::RefCountedObject<FakeAudioTrackWithInitValue>(kLocalTrackId)); |
1580 stream_->AddTrack(local_track); | 1581 stream_->AddTrack(local_track); |
1581 EXPECT_CALL(session_, GetLocalTrackIdBySsrc(kSsrcOfTrack, _)) | 1582 EXPECT_CALL(session_, GetLocalTrackIdBySsrc(kSsrcOfTrack, _)) |
1582 .WillOnce(DoAll(SetArgPointee<1>(kLocalTrackId), Return(true))); | 1583 .WillOnce(DoAll(SetArgPointee<1>(kLocalTrackId), Return(true))); |
1583 stats.AddStream(stream_); | 1584 stats.AddStream(stream_); |
1584 stats.AddLocalAudioTrack(local_track.get(), kSsrcOfTrack); | 1585 stats.AddLocalAudioTrack(local_track.get(), kSsrcOfTrack); |
1585 | 1586 |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1684 stats.AddStream(stream_); | 1685 stats.AddStream(stream_); |
1685 stats.AddLocalAudioTrack(audio_track_, kSsrcOfTrack); | 1686 stats.AddLocalAudioTrack(audio_track_, kSsrcOfTrack); |
1686 | 1687 |
1687 cricket::VoiceSenderInfo voice_sender_info; | 1688 cricket::VoiceSenderInfo voice_sender_info; |
1688 InitVoiceSenderInfo(&voice_sender_info); | 1689 InitVoiceSenderInfo(&voice_sender_info); |
1689 | 1690 |
1690 cricket::VoiceMediaInfo stats_read; | 1691 cricket::VoiceMediaInfo stats_read; |
1691 StatsReports reports; // returned values. | 1692 StatsReports reports; // returned values. |
1692 SetupAndVerifyAudioTrackStats( | 1693 SetupAndVerifyAudioTrackStats( |
1693 audio_track_.get(), stream_.get(), &stats, &voice_channel, kVcName, | 1694 audio_track_.get(), stream_.get(), &stats, &voice_channel, kVcName, |
1694 media_channel, &voice_sender_info, NULL, &stats_read, &reports); | 1695 media_channel, &voice_sender_info, nullptr, &stats_read, &reports); |
1695 | 1696 |
1696 // Verify that there is no remote report for the local audio track because | 1697 // Verify that there is no remote report for the local audio track because |
1697 // we did not set it up. | 1698 // we did not set it up. |
1698 const StatsReport* remote_report = FindNthReportByType(reports, | 1699 const StatsReport* remote_report = FindNthReportByType(reports, |
1699 StatsReport::kStatsReportTypeRemoteSsrc, 1); | 1700 StatsReport::kStatsReportTypeRemoteSsrc, 1); |
1700 EXPECT_TRUE(remote_report == NULL); | 1701 EXPECT_TRUE(remote_report == nullptr); |
1701 } | 1702 } |
1702 | 1703 |
1703 // This test verifies that audio receive streams populate stats reports | 1704 // This test verifies that audio receive streams populate stats reports |
1704 // correctly. | 1705 // correctly. |
1705 TEST_F(StatsCollectorTest, GetStatsFromRemoteStream) { | 1706 TEST_F(StatsCollectorTest, GetStatsFromRemoteStream) { |
1706 StatsCollectorForTest stats(&pc_); | 1707 StatsCollectorForTest stats(&pc_); |
1707 | 1708 |
1708 EXPECT_CALL(session_, GetLocalCertificate(_, _)) | 1709 EXPECT_CALL(session_, GetLocalCertificate(_, _)) |
1709 .WillRepeatedly(Return(false)); | 1710 .WillRepeatedly(Return(false)); |
1710 EXPECT_CALL(session_, GetRemoteSSLCertificate_ReturnsRawPointer(_)) | 1711 EXPECT_CALL(session_, GetRemoteSSLCertificate_ReturnsRawPointer(_)) |
1711 .WillRepeatedly(Return(nullptr)); | 1712 .WillRepeatedly(Return(nullptr)); |
1712 | 1713 |
1713 MockVoiceMediaChannel* media_channel = new MockVoiceMediaChannel(); | 1714 MockVoiceMediaChannel* media_channel = new MockVoiceMediaChannel(); |
1714 // The transport_name known by the voice channel. | 1715 // The transport_name known by the voice channel. |
1715 const std::string kVcName("vcname"); | 1716 const std::string kVcName("vcname"); |
1716 cricket::VoiceChannel voice_channel( | 1717 cricket::VoiceChannel voice_channel( |
1717 worker_thread_, network_thread_, nullptr, media_engine_, media_channel, | 1718 worker_thread_, network_thread_, nullptr, media_engine_, media_channel, |
1718 kVcName, kDefaultRtcpMuxRequired, kDefaultSrtpRequired); | 1719 kVcName, kDefaultRtcpMuxRequired, kDefaultSrtpRequired); |
1719 AddIncomingAudioTrackStats(); | 1720 AddIncomingAudioTrackStats(); |
1720 stats.AddStream(stream_); | 1721 stats.AddStream(stream_); |
1721 | 1722 |
1722 cricket::VoiceReceiverInfo voice_receiver_info; | 1723 cricket::VoiceReceiverInfo voice_receiver_info; |
1723 InitVoiceReceiverInfo(&voice_receiver_info); | 1724 InitVoiceReceiverInfo(&voice_receiver_info); |
1724 voice_receiver_info.codec_name = "fake_codec"; | 1725 voice_receiver_info.codec_name = "fake_codec"; |
1725 | 1726 |
1726 cricket::VoiceMediaInfo stats_read; | 1727 cricket::VoiceMediaInfo stats_read; |
1727 StatsReports reports; // returned values. | 1728 StatsReports reports; // returned values. |
1728 SetupAndVerifyAudioTrackStats( | 1729 SetupAndVerifyAudioTrackStats(audio_track_.get(), stream_.get(), &stats, |
1729 audio_track_.get(), stream_.get(), &stats, &voice_channel, kVcName, | 1730 &voice_channel, kVcName, media_channel, nullptr, |
1730 media_channel, NULL, &voice_receiver_info, &stats_read, &reports); | 1731 &voice_receiver_info, &stats_read, &reports); |
1731 } | 1732 } |
1732 | 1733 |
1733 // This test verifies that a local stats object won't update its statistics | 1734 // This test verifies that a local stats object won't update its statistics |
1734 // after a RemoveLocalAudioTrack() call. | 1735 // after a RemoveLocalAudioTrack() call. |
1735 TEST_F(StatsCollectorTest, GetStatsAfterRemoveAudioStream) { | 1736 TEST_F(StatsCollectorTest, GetStatsAfterRemoveAudioStream) { |
1736 StatsCollectorForTest stats(&pc_); | 1737 StatsCollectorForTest stats(&pc_); |
1737 | 1738 |
1738 EXPECT_CALL(session_, GetLocalCertificate(_, _)) | 1739 EXPECT_CALL(session_, GetLocalCertificate(_, _)) |
1739 .WillRepeatedly(Return(false)); | 1740 .WillRepeatedly(Return(false)); |
1740 EXPECT_CALL(session_, GetRemoteSSLCertificate_ReturnsRawPointer(_)) | 1741 EXPECT_CALL(session_, GetRemoteSSLCertificate_ReturnsRawPointer(_)) |
(...skipping 26 matching lines...) Expand all Loading... |
1767 stats_read.senders.push_back(voice_sender_info); | 1768 stats_read.senders.push_back(voice_sender_info); |
1768 | 1769 |
1769 EXPECT_CALL(session_, voice_channel()).WillRepeatedly(Return(&voice_channel)); | 1770 EXPECT_CALL(session_, voice_channel()).WillRepeatedly(Return(&voice_channel)); |
1770 EXPECT_CALL(session_, video_channel()).WillRepeatedly(ReturnNull()); | 1771 EXPECT_CALL(session_, video_channel()).WillRepeatedly(ReturnNull()); |
1771 EXPECT_CALL(*media_channel, GetStats(_)) | 1772 EXPECT_CALL(*media_channel, GetStats(_)) |
1772 .WillRepeatedly(DoAll(SetArgPointee<0>(stats_read), | 1773 .WillRepeatedly(DoAll(SetArgPointee<0>(stats_read), |
1773 Return(true))); | 1774 Return(true))); |
1774 | 1775 |
1775 StatsReports reports; // returned values. | 1776 StatsReports reports; // returned values. |
1776 stats.UpdateStats(PeerConnectionInterface::kStatsOutputLevelStandard); | 1777 stats.UpdateStats(PeerConnectionInterface::kStatsOutputLevelStandard); |
1777 stats.GetStats(NULL, &reports); | 1778 stats.GetStats(nullptr, &reports); |
1778 | 1779 |
1779 // The report will exist since we don't remove them in RemoveStream(). | 1780 // The report will exist since we don't remove them in RemoveStream(). |
1780 const StatsReport* report = FindNthReportByType( | 1781 const StatsReport* report = FindNthReportByType( |
1781 reports, StatsReport::kStatsReportTypeSsrc, 1); | 1782 reports, StatsReport::kStatsReportTypeSsrc, 1); |
1782 EXPECT_FALSE(report == NULL); | 1783 EXPECT_FALSE(report == nullptr); |
1783 EXPECT_EQ(stats.GetTimeNow(), report->timestamp()); | 1784 EXPECT_EQ(stats.GetTimeNow(), report->timestamp()); |
1784 std::string track_id = ExtractSsrcStatsValue( | 1785 std::string track_id = ExtractSsrcStatsValue( |
1785 reports, StatsReport::kStatsValueNameTrackId); | 1786 reports, StatsReport::kStatsValueNameTrackId); |
1786 EXPECT_EQ(kLocalTrackId, track_id); | 1787 EXPECT_EQ(kLocalTrackId, track_id); |
1787 std::string ssrc_id = ExtractSsrcStatsValue( | 1788 std::string ssrc_id = ExtractSsrcStatsValue( |
1788 reports, StatsReport::kStatsValueNameSsrc); | 1789 reports, StatsReport::kStatsValueNameSsrc); |
1789 EXPECT_EQ(rtc::ToString<uint32_t>(kSsrcOfTrack), ssrc_id); | 1790 EXPECT_EQ(rtc::ToString<uint32_t>(kSsrcOfTrack), ssrc_id); |
1790 | 1791 |
1791 // Verifies the values in the track report, no value will be changed by the | 1792 // Verifies the values in the track report, no value will be changed by the |
1792 // AudioTrackInterface::GetSignalValue() and | 1793 // AudioTrackInterface::GetSignalValue() and |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1906 stats.AddStream(stream_); | 1907 stats.AddStream(stream_); |
1907 stats.AddLocalAudioTrack(audio_track_, kSsrcOfTrack); | 1908 stats.AddLocalAudioTrack(audio_track_, kSsrcOfTrack); |
1908 | 1909 |
1909 cricket::VoiceSenderInfo voice_sender_info; | 1910 cricket::VoiceSenderInfo voice_sender_info; |
1910 voice_sender_info.add_ssrc(kSsrcOfTrack); | 1911 voice_sender_info.add_ssrc(kSsrcOfTrack); |
1911 | 1912 |
1912 cricket::VoiceMediaInfo stats_read; | 1913 cricket::VoiceMediaInfo stats_read; |
1913 StatsReports reports; // returned values. | 1914 StatsReports reports; // returned values. |
1914 SetupAndVerifyAudioTrackStats( | 1915 SetupAndVerifyAudioTrackStats( |
1915 audio_track_.get(), stream_.get(), &stats, &voice_channel, kVcName, | 1916 audio_track_.get(), stream_.get(), &stats, &voice_channel, kVcName, |
1916 media_channel, &voice_sender_info, NULL, &stats_read, &reports); | 1917 media_channel, &voice_sender_info, nullptr, &stats_read, &reports); |
1917 | 1918 |
1918 // Remove the previous audio track from the stream. | 1919 // Remove the previous audio track from the stream. |
1919 stream_->RemoveTrack(audio_track_.get()); | 1920 stream_->RemoveTrack(audio_track_.get()); |
1920 stats.RemoveLocalAudioTrack(audio_track_.get(), kSsrcOfTrack); | 1921 stats.RemoveLocalAudioTrack(audio_track_.get(), kSsrcOfTrack); |
1921 | 1922 |
1922 // Create a new audio track and adds it to the stream and stats. | 1923 // Create a new audio track and adds it to the stream and stats. |
1923 static const std::string kNewTrackId = "new_track_id"; | 1924 static const std::string kNewTrackId = "new_track_id"; |
1924 rtc::scoped_refptr<FakeAudioTrack> new_audio_track( | 1925 rtc::scoped_refptr<FakeAudioTrack> new_audio_track( |
1925 new rtc::RefCountedObject<FakeAudioTrack>(kNewTrackId)); | 1926 new rtc::RefCountedObject<FakeAudioTrack>(kNewTrackId)); |
1926 EXPECT_CALL(session_, GetLocalTrackIdBySsrc(kSsrcOfTrack, _)) | 1927 EXPECT_CALL(session_, GetLocalTrackIdBySsrc(kSsrcOfTrack, _)) |
1927 .WillOnce(DoAll(SetArgPointee<1>(kNewTrackId), Return(true))); | 1928 .WillOnce(DoAll(SetArgPointee<1>(kNewTrackId), Return(true))); |
1928 stream_->AddTrack(new_audio_track); | 1929 stream_->AddTrack(new_audio_track); |
1929 | 1930 |
1930 stats.AddLocalAudioTrack(new_audio_track, kSsrcOfTrack); | 1931 stats.AddLocalAudioTrack(new_audio_track, kSsrcOfTrack); |
1931 stats.ClearUpdateStatsCacheForTest(); | 1932 stats.ClearUpdateStatsCacheForTest(); |
1932 cricket::VoiceSenderInfo new_voice_sender_info; | 1933 cricket::VoiceSenderInfo new_voice_sender_info; |
1933 InitVoiceSenderInfo(&new_voice_sender_info); | 1934 InitVoiceSenderInfo(&new_voice_sender_info); |
1934 cricket::VoiceMediaInfo new_stats_read; | 1935 cricket::VoiceMediaInfo new_stats_read; |
1935 reports.clear(); | 1936 reports.clear(); |
1936 SetupAndVerifyAudioTrackStats( | 1937 SetupAndVerifyAudioTrackStats(new_audio_track.get(), stream_.get(), &stats, |
1937 new_audio_track.get(), stream_.get(), &stats, &voice_channel, kVcName, | 1938 &voice_channel, kVcName, media_channel, |
1938 media_channel, &new_voice_sender_info, NULL, &new_stats_read, &reports); | 1939 &new_voice_sender_info, nullptr, |
| 1940 &new_stats_read, &reports); |
1939 } | 1941 } |
1940 | 1942 |
1941 // This test verifies that stats are correctly set in video send ssrc stats. | 1943 // This test verifies that stats are correctly set in video send ssrc stats. |
1942 TEST_F(StatsCollectorTest, VerifyVideoSendSsrcStats) { | 1944 TEST_F(StatsCollectorTest, VerifyVideoSendSsrcStats) { |
1943 StatsCollectorForTest stats(&pc_); | 1945 StatsCollectorForTest stats(&pc_); |
1944 | 1946 |
1945 EXPECT_CALL(session_, GetLocalCertificate(_, _)) | 1947 EXPECT_CALL(session_, GetLocalCertificate(_, _)) |
1946 .WillRepeatedly(Return(false)); | 1948 .WillRepeatedly(Return(false)); |
1947 EXPECT_CALL(session_, GetRemoteSSLCertificate_ReturnsRawPointer(_)) | 1949 EXPECT_CALL(session_, GetRemoteSSLCertificate_ReturnsRawPointer(_)) |
1948 .WillRepeatedly(Return(nullptr)); | 1950 .WillRepeatedly(Return(nullptr)); |
(...skipping 22 matching lines...) Expand all Loading... |
1971 video_sender_info.add_ssrc(1234); | 1973 video_sender_info.add_ssrc(1234); |
1972 video_sender_info.frames_encoded = 10; | 1974 video_sender_info.frames_encoded = 10; |
1973 video_sender_info.qp_sum = rtc::Optional<uint64_t>(11); | 1975 video_sender_info.qp_sum = rtc::Optional<uint64_t>(11); |
1974 stats_read.senders.push_back(video_sender_info); | 1976 stats_read.senders.push_back(video_sender_info); |
1975 | 1977 |
1976 EXPECT_CALL(session_, video_channel()).WillRepeatedly(Return(&video_channel)); | 1978 EXPECT_CALL(session_, video_channel()).WillRepeatedly(Return(&video_channel)); |
1977 EXPECT_CALL(session_, voice_channel()).WillRepeatedly(ReturnNull()); | 1979 EXPECT_CALL(session_, voice_channel()).WillRepeatedly(ReturnNull()); |
1978 EXPECT_CALL(*media_channel, GetStats(_)) | 1980 EXPECT_CALL(*media_channel, GetStats(_)) |
1979 .WillOnce(DoAll(SetArgPointee<0>(stats_read), Return(true))); | 1981 .WillOnce(DoAll(SetArgPointee<0>(stats_read), Return(true))); |
1980 stats.UpdateStats(PeerConnectionInterface::kStatsOutputLevelStandard); | 1982 stats.UpdateStats(PeerConnectionInterface::kStatsOutputLevelStandard); |
1981 stats.GetStats(NULL, &reports); | 1983 stats.GetStats(nullptr, &reports); |
1982 EXPECT_EQ(rtc::ToString(video_sender_info.frames_encoded), | 1984 EXPECT_EQ(rtc::ToString(video_sender_info.frames_encoded), |
1983 ExtractSsrcStatsValue(reports, | 1985 ExtractSsrcStatsValue(reports, |
1984 StatsReport::kStatsValueNameFramesEncoded)); | 1986 StatsReport::kStatsValueNameFramesEncoded)); |
1985 EXPECT_EQ(rtc::ToString(*video_sender_info.qp_sum), | 1987 EXPECT_EQ(rtc::ToString(*video_sender_info.qp_sum), |
1986 ExtractSsrcStatsValue(reports, StatsReport::kStatsValueNameQpSum)); | 1988 ExtractSsrcStatsValue(reports, StatsReport::kStatsValueNameQpSum)); |
1987 } | 1989 } |
1988 | 1990 |
1989 // This test verifies that stats are correctly set in video receive ssrc stats. | 1991 // This test verifies that stats are correctly set in video receive ssrc stats. |
1990 TEST_F(StatsCollectorTest, VerifyVideoReceiveSsrcStats) { | 1992 TEST_F(StatsCollectorTest, VerifyVideoReceiveSsrcStats) { |
1991 StatsCollectorForTest stats(&pc_); | 1993 StatsCollectorForTest stats(&pc_); |
(...skipping 27 matching lines...) Expand all Loading... |
2019 video_receiver_info.add_ssrc(1234); | 2021 video_receiver_info.add_ssrc(1234); |
2020 video_receiver_info.frames_decoded = 10; | 2022 video_receiver_info.frames_decoded = 10; |
2021 video_receiver_info.qp_sum = rtc::Optional<uint64_t>(11); | 2023 video_receiver_info.qp_sum = rtc::Optional<uint64_t>(11); |
2022 stats_read.receivers.push_back(video_receiver_info); | 2024 stats_read.receivers.push_back(video_receiver_info); |
2023 | 2025 |
2024 EXPECT_CALL(session_, video_channel()).WillRepeatedly(Return(&video_channel)); | 2026 EXPECT_CALL(session_, video_channel()).WillRepeatedly(Return(&video_channel)); |
2025 EXPECT_CALL(session_, voice_channel()).WillRepeatedly(ReturnNull()); | 2027 EXPECT_CALL(session_, voice_channel()).WillRepeatedly(ReturnNull()); |
2026 EXPECT_CALL(*media_channel, GetStats(_)) | 2028 EXPECT_CALL(*media_channel, GetStats(_)) |
2027 .WillOnce(DoAll(SetArgPointee<0>(stats_read), Return(true))); | 2029 .WillOnce(DoAll(SetArgPointee<0>(stats_read), Return(true))); |
2028 stats.UpdateStats(PeerConnectionInterface::kStatsOutputLevelStandard); | 2030 stats.UpdateStats(PeerConnectionInterface::kStatsOutputLevelStandard); |
2029 stats.GetStats(NULL, &reports); | 2031 stats.GetStats(nullptr, &reports); |
2030 EXPECT_EQ(rtc::ToString(video_receiver_info.frames_decoded), | 2032 EXPECT_EQ(rtc::ToString(video_receiver_info.frames_decoded), |
2031 ExtractSsrcStatsValue(reports, | 2033 ExtractSsrcStatsValue(reports, |
2032 StatsReport::kStatsValueNameFramesDecoded)); | 2034 StatsReport::kStatsValueNameFramesDecoded)); |
2033 EXPECT_EQ(rtc::ToString(*video_receiver_info.qp_sum), | 2035 EXPECT_EQ(rtc::ToString(*video_receiver_info.qp_sum), |
2034 ExtractSsrcStatsValue(reports, StatsReport::kStatsValueNameQpSum)); | 2036 ExtractSsrcStatsValue(reports, StatsReport::kStatsValueNameQpSum)); |
2035 } | 2037 } |
2036 | 2038 |
2037 } // namespace webrtc | 2039 } // namespace webrtc |
OLD | NEW |