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 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
485 return time_now_; | 485 return time_now_; |
486 } | 486 } |
487 | 487 |
488 private: | 488 private: |
489 double time_now_; | 489 double time_now_; |
490 }; | 490 }; |
491 | 491 |
492 class StatsCollectorTest : public testing::Test { | 492 class StatsCollectorTest : public testing::Test { |
493 protected: | 493 protected: |
494 StatsCollectorTest() | 494 StatsCollectorTest() |
495 : media_engine_(new cricket::FakeMediaEngine()), | 495 : worker_thread_(rtc::Thread::Current()), |
496 channel_manager_( | 496 network_thread_(rtc::Thread::Current()), |
497 new cricket::ChannelManager(media_engine_, rtc::Thread::Current())), | 497 media_engine_(new cricket::FakeMediaEngine()), |
| 498 channel_manager_(new cricket::ChannelManager(media_engine_, |
| 499 worker_thread_, |
| 500 network_thread_)), |
498 media_controller_( | 501 media_controller_( |
499 webrtc::MediaControllerInterface::Create(cricket::MediaConfig(), | 502 webrtc::MediaControllerInterface::Create(cricket::MediaConfig(), |
500 rtc::Thread::Current(), | 503 worker_thread_, |
501 channel_manager_.get())), | 504 channel_manager_.get())), |
502 session_(media_controller_.get()) { | 505 session_(media_controller_.get()) { |
503 // By default, we ignore session GetStats calls. | 506 // By default, we ignore session GetStats calls. |
504 EXPECT_CALL(session_, GetTransportStats(_)).WillRepeatedly(Return(false)); | 507 EXPECT_CALL(session_, GetTransportStats(_)).WillRepeatedly(Return(false)); |
505 // Add default returns for mock classes. | 508 // Add default returns for mock classes. |
506 EXPECT_CALL(session_, video_channel()).WillRepeatedly(ReturnNull()); | 509 EXPECT_CALL(session_, video_channel()).WillRepeatedly(ReturnNull()); |
507 EXPECT_CALL(session_, voice_channel()).WillRepeatedly(ReturnNull()); | 510 EXPECT_CALL(session_, voice_channel()).WillRepeatedly(ReturnNull()); |
508 EXPECT_CALL(pc_, session()).WillRepeatedly(Return(&session_)); | 511 EXPECT_CALL(pc_, session()).WillRepeatedly(Return(&session_)); |
509 EXPECT_CALL(pc_, sctp_data_channels()) | 512 EXPECT_CALL(pc_, sctp_data_channels()) |
510 .WillRepeatedly(ReturnRef(data_channels_)); | 513 .WillRepeatedly(ReturnRef(data_channels_)); |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
749 EXPECT_EQ(rtc::SSLStreamAdapter::SslCipherSuiteToName( | 752 EXPECT_EQ(rtc::SSLStreamAdapter::SslCipherSuiteToName( |
750 internal::TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA), | 753 internal::TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA), |
751 dtls_cipher_suite); | 754 dtls_cipher_suite); |
752 std::string srtp_crypto_suite = | 755 std::string srtp_crypto_suite = |
753 ExtractStatsValue(StatsReport::kStatsReportTypeComponent, reports, | 756 ExtractStatsValue(StatsReport::kStatsReportTypeComponent, reports, |
754 StatsReport::kStatsValueNameSrtpCipher); | 757 StatsReport::kStatsValueNameSrtpCipher); |
755 EXPECT_EQ(rtc::SrtpCryptoSuiteToName(rtc::SRTP_AES128_CM_SHA1_80), | 758 EXPECT_EQ(rtc::SrtpCryptoSuiteToName(rtc::SRTP_AES128_CM_SHA1_80), |
756 srtp_crypto_suite); | 759 srtp_crypto_suite); |
757 } | 760 } |
758 | 761 |
| 762 rtc::Thread* const worker_thread_; |
| 763 rtc::Thread* const network_thread_; |
759 cricket::FakeMediaEngine* media_engine_; | 764 cricket::FakeMediaEngine* media_engine_; |
760 std::unique_ptr<cricket::ChannelManager> channel_manager_; | 765 std::unique_ptr<cricket::ChannelManager> channel_manager_; |
761 std::unique_ptr<webrtc::MediaControllerInterface> media_controller_; | 766 std::unique_ptr<webrtc::MediaControllerInterface> media_controller_; |
762 MockWebRtcSession session_; | 767 MockWebRtcSession session_; |
763 MockPeerConnection pc_; | 768 MockPeerConnection pc_; |
764 FakeDataChannelProvider data_channel_provider_; | 769 FakeDataChannelProvider data_channel_provider_; |
765 SessionStats session_stats_; | 770 SessionStats session_stats_; |
766 rtc::scoped_refptr<webrtc::MediaStream> stream_; | 771 rtc::scoped_refptr<webrtc::MediaStream> stream_; |
767 rtc::scoped_refptr<webrtc::VideoTrack> track_; | 772 rtc::scoped_refptr<webrtc::VideoTrack> track_; |
768 rtc::scoped_refptr<FakeAudioTrack> audio_track_; | 773 rtc::scoped_refptr<FakeAudioTrack> audio_track_; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
817 .WillRepeatedly(Return(nullptr)); | 822 .WillRepeatedly(Return(nullptr)); |
818 | 823 |
819 const char kVideoChannelName[] = "video"; | 824 const char kVideoChannelName[] = "video"; |
820 | 825 |
821 InitSessionStats(kVideoChannelName); | 826 InitSessionStats(kVideoChannelName); |
822 EXPECT_CALL(session_, GetTransportStats(_)) | 827 EXPECT_CALL(session_, GetTransportStats(_)) |
823 .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats_), | 828 .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats_), |
824 Return(true))); | 829 Return(true))); |
825 | 830 |
826 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); | 831 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); |
827 cricket::VideoChannel video_channel(rtc::Thread::Current(), media_channel, | 832 cricket::VideoChannel video_channel(worker_thread_, network_thread_, |
828 nullptr, kVideoChannelName, false); | 833 media_channel, nullptr, kVideoChannelName, |
| 834 false); |
829 StatsReports reports; // returned values. | 835 StatsReports reports; // returned values. |
830 cricket::VideoSenderInfo video_sender_info; | 836 cricket::VideoSenderInfo video_sender_info; |
831 cricket::VideoMediaInfo stats_read; | 837 cricket::VideoMediaInfo stats_read; |
832 // The number of bytes must be larger than 0xFFFFFFFF for this test. | 838 // The number of bytes must be larger than 0xFFFFFFFF for this test. |
833 const int64_t kBytesSent = 12345678901234LL; | 839 const int64_t kBytesSent = 12345678901234LL; |
834 const std::string kBytesSentString("12345678901234"); | 840 const std::string kBytesSentString("12345678901234"); |
835 | 841 |
836 AddOutgoingVideoTrackStats(); | 842 AddOutgoingVideoTrackStats(); |
837 stats.AddStream(stream_); | 843 stats.AddStream(stream_); |
838 | 844 |
(...skipping 24 matching lines...) Expand all Loading... |
863 .WillRepeatedly(Return(nullptr)); | 869 .WillRepeatedly(Return(nullptr)); |
864 | 870 |
865 const char kVideoChannelName[] = "video"; | 871 const char kVideoChannelName[] = "video"; |
866 | 872 |
867 InitSessionStats(kVideoChannelName); | 873 InitSessionStats(kVideoChannelName); |
868 EXPECT_CALL(session_, GetTransportStats(_)) | 874 EXPECT_CALL(session_, GetTransportStats(_)) |
869 .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats_), | 875 .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats_), |
870 Return(true))); | 876 Return(true))); |
871 | 877 |
872 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); | 878 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); |
873 cricket::VideoChannel video_channel(rtc::Thread::Current(), media_channel, | 879 cricket::VideoChannel video_channel(worker_thread_, network_thread_, |
874 nullptr, kVideoChannelName, false); | 880 media_channel, nullptr, kVideoChannelName, |
| 881 false); |
875 | 882 |
876 StatsReports reports; // returned values. | 883 StatsReports reports; // returned values. |
877 cricket::VideoSenderInfo video_sender_info; | 884 cricket::VideoSenderInfo video_sender_info; |
878 cricket::VideoMediaInfo stats_read; | 885 cricket::VideoMediaInfo stats_read; |
879 // Set up an SSRC just to test that we get both kinds of stats back: SSRC and | 886 // Set up an SSRC just to test that we get both kinds of stats back: SSRC and |
880 // BWE. | 887 // BWE. |
881 const int64_t kBytesSent = 12345678901234LL; | 888 const int64_t kBytesSent = 12345678901234LL; |
882 const std::string kBytesSentString("12345678901234"); | 889 const std::string kBytesSentString("12345678901234"); |
883 | 890 |
884 AddOutgoingVideoTrackStats(); | 891 AddOutgoingVideoTrackStats(); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
938 reports, StatsReport::kStatsReportTypeSession, 2); | 945 reports, StatsReport::kStatsReportTypeSession, 2); |
939 EXPECT_EQ(NULL, session_report); | 946 EXPECT_EQ(NULL, session_report); |
940 } | 947 } |
941 | 948 |
942 // This test verifies that the empty track report exists in the returned stats | 949 // This test verifies that the empty track report exists in the returned stats |
943 // without calling StatsCollector::UpdateStats. | 950 // without calling StatsCollector::UpdateStats. |
944 TEST_F(StatsCollectorTest, TrackObjectExistsWithoutUpdateStats) { | 951 TEST_F(StatsCollectorTest, TrackObjectExistsWithoutUpdateStats) { |
945 StatsCollectorForTest stats(&pc_); | 952 StatsCollectorForTest stats(&pc_); |
946 | 953 |
947 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); | 954 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); |
948 cricket::VideoChannel video_channel(rtc::Thread::Current(), media_channel, | 955 cricket::VideoChannel video_channel(worker_thread_, network_thread_, |
949 nullptr, "video", false); | 956 media_channel, nullptr, "video", false); |
950 AddOutgoingVideoTrackStats(); | 957 AddOutgoingVideoTrackStats(); |
951 stats.AddStream(stream_); | 958 stats.AddStream(stream_); |
952 | 959 |
953 // Verfies the existence of the track report. | 960 // Verfies the existence of the track report. |
954 StatsReports reports; | 961 StatsReports reports; |
955 stats.GetStats(NULL, &reports); | 962 stats.GetStats(NULL, &reports); |
956 EXPECT_EQ((size_t)1, reports.size()); | 963 EXPECT_EQ((size_t)1, reports.size()); |
957 EXPECT_EQ(StatsReport::kStatsReportTypeTrack, reports[0]->type()); | 964 EXPECT_EQ(StatsReport::kStatsReportTypeTrack, reports[0]->type()); |
958 EXPECT_EQ(0, reports[0]->timestamp()); | 965 EXPECT_EQ(0, reports[0]->timestamp()); |
959 | 966 |
(...skipping 14 matching lines...) Expand all Loading... |
974 EXPECT_CALL(session_, GetRemoteSSLCertificate_ReturnsRawPointer(_)) | 981 EXPECT_CALL(session_, GetRemoteSSLCertificate_ReturnsRawPointer(_)) |
975 .WillRepeatedly(Return(nullptr)); | 982 .WillRepeatedly(Return(nullptr)); |
976 | 983 |
977 const char kVideoChannelName[] = "video"; | 984 const char kVideoChannelName[] = "video"; |
978 InitSessionStats(kVideoChannelName); | 985 InitSessionStats(kVideoChannelName); |
979 EXPECT_CALL(session_, GetTransportStats(_)) | 986 EXPECT_CALL(session_, GetTransportStats(_)) |
980 .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats_), | 987 .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats_), |
981 Return(true))); | 988 Return(true))); |
982 | 989 |
983 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); | 990 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); |
984 cricket::VideoChannel video_channel(rtc::Thread::Current(), media_channel, | 991 cricket::VideoChannel video_channel(worker_thread_, network_thread_, |
985 nullptr, kVideoChannelName, false); | 992 media_channel, nullptr, kVideoChannelName, |
| 993 false); |
986 AddOutgoingVideoTrackStats(); | 994 AddOutgoingVideoTrackStats(); |
987 stats.AddStream(stream_); | 995 stats.AddStream(stream_); |
988 | 996 |
989 // Constructs an ssrc stats update. | 997 // Constructs an ssrc stats update. |
990 cricket::VideoSenderInfo video_sender_info; | 998 cricket::VideoSenderInfo video_sender_info; |
991 cricket::VideoMediaInfo stats_read; | 999 cricket::VideoMediaInfo stats_read; |
992 const int64_t kBytesSent = 12345678901234LL; | 1000 const int64_t kBytesSent = 12345678901234LL; |
993 | 1001 |
994 // Construct a stats value to read. | 1002 // Construct a stats value to read. |
995 video_sender_info.add_ssrc(1234); | 1003 video_sender_info.add_ssrc(1234); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1042 StatsCollectorForTest stats(&pc_); | 1050 StatsCollectorForTest stats(&pc_); |
1043 | 1051 |
1044 EXPECT_CALL(session_, GetLocalCertificate(_, _)) | 1052 EXPECT_CALL(session_, GetLocalCertificate(_, _)) |
1045 .WillRepeatedly(Return(false)); | 1053 .WillRepeatedly(Return(false)); |
1046 EXPECT_CALL(session_, GetRemoteSSLCertificate_ReturnsRawPointer(_)) | 1054 EXPECT_CALL(session_, GetRemoteSSLCertificate_ReturnsRawPointer(_)) |
1047 .WillRepeatedly(Return(nullptr)); | 1055 .WillRepeatedly(Return(nullptr)); |
1048 | 1056 |
1049 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); | 1057 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); |
1050 // The transport_name known by the video channel. | 1058 // The transport_name known by the video channel. |
1051 const std::string kVcName("vcname"); | 1059 const std::string kVcName("vcname"); |
1052 cricket::VideoChannel video_channel(rtc::Thread::Current(), media_channel, | 1060 cricket::VideoChannel video_channel(worker_thread_, network_thread_, |
1053 nullptr, kVcName, false); | 1061 media_channel, nullptr, kVcName, false); |
1054 AddOutgoingVideoTrackStats(); | 1062 AddOutgoingVideoTrackStats(); |
1055 stats.AddStream(stream_); | 1063 stats.AddStream(stream_); |
1056 | 1064 |
1057 // Constructs an ssrc stats update. | 1065 // Constructs an ssrc stats update. |
1058 cricket::VideoSenderInfo video_sender_info; | 1066 cricket::VideoSenderInfo video_sender_info; |
1059 cricket::VideoMediaInfo stats_read; | 1067 cricket::VideoMediaInfo stats_read; |
1060 const int64_t kBytesSent = 12345678901234LL; | 1068 const int64_t kBytesSent = 12345678901234LL; |
1061 | 1069 |
1062 // Construct a stats value to read. | 1070 // Construct a stats value to read. |
1063 video_sender_info.add_ssrc(1234); | 1071 video_sender_info.add_ssrc(1234); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1100 } | 1108 } |
1101 | 1109 |
1102 // This test verifies that a remote stats object will not be created for | 1110 // This test verifies that a remote stats object will not be created for |
1103 // an outgoing SSRC where remote stats are not returned. | 1111 // an outgoing SSRC where remote stats are not returned. |
1104 TEST_F(StatsCollectorTest, RemoteSsrcInfoIsAbsent) { | 1112 TEST_F(StatsCollectorTest, RemoteSsrcInfoIsAbsent) { |
1105 StatsCollectorForTest stats(&pc_); | 1113 StatsCollectorForTest stats(&pc_); |
1106 | 1114 |
1107 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); | 1115 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); |
1108 // The transport_name known by the video channel. | 1116 // The transport_name known by the video channel. |
1109 const std::string kVcName("vcname"); | 1117 const std::string kVcName("vcname"); |
1110 cricket::VideoChannel video_channel(rtc::Thread::Current(), media_channel, | 1118 cricket::VideoChannel video_channel(worker_thread_, network_thread_, |
1111 nullptr, kVcName, false); | 1119 media_channel, nullptr, kVcName, false); |
1112 AddOutgoingVideoTrackStats(); | 1120 AddOutgoingVideoTrackStats(); |
1113 stats.AddStream(stream_); | 1121 stats.AddStream(stream_); |
1114 | 1122 |
1115 stats.UpdateStats(PeerConnectionInterface::kStatsOutputLevelStandard); | 1123 stats.UpdateStats(PeerConnectionInterface::kStatsOutputLevelStandard); |
1116 StatsReports reports; | 1124 StatsReports reports; |
1117 stats.GetStats(NULL, &reports); | 1125 stats.GetStats(NULL, &reports); |
1118 const StatsReport* remote_report = FindNthReportByType(reports, | 1126 const StatsReport* remote_report = FindNthReportByType(reports, |
1119 StatsReport::kStatsReportTypeRemoteSsrc, 1); | 1127 StatsReport::kStatsReportTypeRemoteSsrc, 1); |
1120 EXPECT_TRUE(remote_report == NULL); | 1128 EXPECT_TRUE(remote_report == NULL); |
1121 } | 1129 } |
1122 | 1130 |
1123 // This test verifies that a remote stats object will be created for | 1131 // This test verifies that a remote stats object will be created for |
1124 // an outgoing SSRC where stats are returned. | 1132 // an outgoing SSRC where stats are returned. |
1125 TEST_F(StatsCollectorTest, RemoteSsrcInfoIsPresent) { | 1133 TEST_F(StatsCollectorTest, RemoteSsrcInfoIsPresent) { |
1126 StatsCollectorForTest stats(&pc_); | 1134 StatsCollectorForTest stats(&pc_); |
1127 | 1135 |
1128 EXPECT_CALL(session_, GetLocalCertificate(_, _)) | 1136 EXPECT_CALL(session_, GetLocalCertificate(_, _)) |
1129 .WillRepeatedly(Return(false)); | 1137 .WillRepeatedly(Return(false)); |
1130 EXPECT_CALL(session_, GetRemoteSSLCertificate_ReturnsRawPointer(_)) | 1138 EXPECT_CALL(session_, GetRemoteSSLCertificate_ReturnsRawPointer(_)) |
1131 .WillRepeatedly(Return(nullptr)); | 1139 .WillRepeatedly(Return(nullptr)); |
1132 | 1140 |
1133 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); | 1141 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); |
1134 // The transport_name known by the video channel. | 1142 // The transport_name known by the video channel. |
1135 const std::string kVcName("vcname"); | 1143 const std::string kVcName("vcname"); |
1136 cricket::VideoChannel video_channel(rtc::Thread::Current(), media_channel, | 1144 cricket::VideoChannel video_channel(worker_thread_, network_thread_, |
1137 nullptr, kVcName, false); | 1145 media_channel, nullptr, kVcName, false); |
1138 AddOutgoingVideoTrackStats(); | 1146 AddOutgoingVideoTrackStats(); |
1139 stats.AddStream(stream_); | 1147 stats.AddStream(stream_); |
1140 | 1148 |
1141 // Instruct the session to return stats containing the transport channel. | 1149 // Instruct the session to return stats containing the transport channel. |
1142 InitSessionStats(kVcName); | 1150 InitSessionStats(kVcName); |
1143 EXPECT_CALL(session_, GetTransportStats(_)) | 1151 EXPECT_CALL(session_, GetTransportStats(_)) |
1144 .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats_), | 1152 .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats_), |
1145 Return(true))); | 1153 Return(true))); |
1146 | 1154 |
1147 // Constructs an ssrc stats update. | 1155 // Constructs an ssrc stats update. |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1181 EXPECT_CALL(session_, GetRemoteSSLCertificate_ReturnsRawPointer(_)) | 1189 EXPECT_CALL(session_, GetRemoteSSLCertificate_ReturnsRawPointer(_)) |
1182 .WillRepeatedly(Return(nullptr)); | 1190 .WillRepeatedly(Return(nullptr)); |
1183 | 1191 |
1184 const char kVideoChannelName[] = "video"; | 1192 const char kVideoChannelName[] = "video"; |
1185 InitSessionStats(kVideoChannelName); | 1193 InitSessionStats(kVideoChannelName); |
1186 EXPECT_CALL(session_, GetTransportStats(_)) | 1194 EXPECT_CALL(session_, GetTransportStats(_)) |
1187 .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats_), | 1195 .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats_), |
1188 Return(true))); | 1196 Return(true))); |
1189 | 1197 |
1190 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); | 1198 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); |
1191 cricket::VideoChannel video_channel(rtc::Thread::Current(), media_channel, | 1199 cricket::VideoChannel video_channel(worker_thread_, network_thread_, |
1192 nullptr, kVideoChannelName, false); | 1200 media_channel, nullptr, kVideoChannelName, |
| 1201 false); |
1193 AddIncomingVideoTrackStats(); | 1202 AddIncomingVideoTrackStats(); |
1194 stats.AddStream(stream_); | 1203 stats.AddStream(stream_); |
1195 | 1204 |
1196 // Constructs an ssrc stats update. | 1205 // Constructs an ssrc stats update. |
1197 cricket::VideoReceiverInfo video_receiver_info; | 1206 cricket::VideoReceiverInfo video_receiver_info; |
1198 cricket::VideoMediaInfo stats_read; | 1207 cricket::VideoMediaInfo stats_read; |
1199 const int64_t kNumOfPacketsConcealed = 54321; | 1208 const int64_t kNumOfPacketsConcealed = 54321; |
1200 | 1209 |
1201 // Construct a stats value to read. | 1210 // Construct a stats value to read. |
1202 video_receiver_info.add_ssrc(1234); | 1211 video_receiver_info.add_ssrc(1234); |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1493 StatsCollectorForTest stats(&pc_); | 1502 StatsCollectorForTest stats(&pc_); |
1494 | 1503 |
1495 EXPECT_CALL(session_, GetLocalCertificate(_, _)) | 1504 EXPECT_CALL(session_, GetLocalCertificate(_, _)) |
1496 .WillRepeatedly(Return(false)); | 1505 .WillRepeatedly(Return(false)); |
1497 EXPECT_CALL(session_, GetRemoteSSLCertificate_ReturnsRawPointer(_)) | 1506 EXPECT_CALL(session_, GetRemoteSSLCertificate_ReturnsRawPointer(_)) |
1498 .WillRepeatedly(Return(nullptr)); | 1507 .WillRepeatedly(Return(nullptr)); |
1499 | 1508 |
1500 MockVoiceMediaChannel* media_channel = new MockVoiceMediaChannel(); | 1509 MockVoiceMediaChannel* media_channel = new MockVoiceMediaChannel(); |
1501 // The transport_name known by the voice channel. | 1510 // The transport_name known by the voice channel. |
1502 const std::string kVcName("vcname"); | 1511 const std::string kVcName("vcname"); |
1503 cricket::VoiceChannel voice_channel(rtc::Thread::Current(), media_engine_, | 1512 cricket::VoiceChannel voice_channel(worker_thread_, network_thread_, |
1504 media_channel, nullptr, kVcName, false); | 1513 media_engine_, media_channel, nullptr, |
| 1514 kVcName, false); |
1505 AddOutgoingAudioTrackStats(); | 1515 AddOutgoingAudioTrackStats(); |
1506 stats.AddStream(stream_); | 1516 stats.AddStream(stream_); |
1507 stats.AddLocalAudioTrack(audio_track_, kSsrcOfTrack); | 1517 stats.AddLocalAudioTrack(audio_track_, kSsrcOfTrack); |
1508 | 1518 |
1509 cricket::VoiceSenderInfo voice_sender_info; | 1519 cricket::VoiceSenderInfo voice_sender_info; |
1510 InitVoiceSenderInfo(&voice_sender_info); | 1520 InitVoiceSenderInfo(&voice_sender_info); |
1511 | 1521 |
1512 cricket::VoiceMediaInfo stats_read; | 1522 cricket::VoiceMediaInfo stats_read; |
1513 StatsReports reports; // returned values. | 1523 StatsReports reports; // returned values. |
1514 SetupAndVerifyAudioTrackStats( | 1524 SetupAndVerifyAudioTrackStats( |
(...skipping 13 matching lines...) Expand all Loading... |
1528 StatsCollectorForTest stats(&pc_); | 1538 StatsCollectorForTest stats(&pc_); |
1529 | 1539 |
1530 EXPECT_CALL(session_, GetLocalCertificate(_, _)) | 1540 EXPECT_CALL(session_, GetLocalCertificate(_, _)) |
1531 .WillRepeatedly(Return(false)); | 1541 .WillRepeatedly(Return(false)); |
1532 EXPECT_CALL(session_, GetRemoteSSLCertificate_ReturnsRawPointer(_)) | 1542 EXPECT_CALL(session_, GetRemoteSSLCertificate_ReturnsRawPointer(_)) |
1533 .WillRepeatedly(Return(nullptr)); | 1543 .WillRepeatedly(Return(nullptr)); |
1534 | 1544 |
1535 MockVoiceMediaChannel* media_channel = new MockVoiceMediaChannel(); | 1545 MockVoiceMediaChannel* media_channel = new MockVoiceMediaChannel(); |
1536 // The transport_name known by the voice channel. | 1546 // The transport_name known by the voice channel. |
1537 const std::string kVcName("vcname"); | 1547 const std::string kVcName("vcname"); |
1538 cricket::VoiceChannel voice_channel(rtc::Thread::Current(), media_engine_, | 1548 cricket::VoiceChannel voice_channel(worker_thread_, network_thread_, |
1539 media_channel, nullptr, kVcName, false); | 1549 media_engine_, media_channel, nullptr, |
| 1550 kVcName, false); |
1540 AddIncomingAudioTrackStats(); | 1551 AddIncomingAudioTrackStats(); |
1541 stats.AddStream(stream_); | 1552 stats.AddStream(stream_); |
1542 | 1553 |
1543 cricket::VoiceReceiverInfo voice_receiver_info; | 1554 cricket::VoiceReceiverInfo voice_receiver_info; |
1544 InitVoiceReceiverInfo(&voice_receiver_info); | 1555 InitVoiceReceiverInfo(&voice_receiver_info); |
1545 voice_receiver_info.codec_name = "fake_codec"; | 1556 voice_receiver_info.codec_name = "fake_codec"; |
1546 | 1557 |
1547 cricket::VoiceMediaInfo stats_read; | 1558 cricket::VoiceMediaInfo stats_read; |
1548 StatsReports reports; // returned values. | 1559 StatsReports reports; // returned values. |
1549 SetupAndVerifyAudioTrackStats( | 1560 SetupAndVerifyAudioTrackStats( |
1550 audio_track_.get(), stream_.get(), &stats, &voice_channel, kVcName, | 1561 audio_track_.get(), stream_.get(), &stats, &voice_channel, kVcName, |
1551 media_channel, NULL, &voice_receiver_info, &stats_read, &reports); | 1562 media_channel, NULL, &voice_receiver_info, &stats_read, &reports); |
1552 } | 1563 } |
1553 | 1564 |
1554 // This test verifies that a local stats object won't update its statistics | 1565 // This test verifies that a local stats object won't update its statistics |
1555 // after a RemoveLocalAudioTrack() call. | 1566 // after a RemoveLocalAudioTrack() call. |
1556 TEST_F(StatsCollectorTest, GetStatsAfterRemoveAudioStream) { | 1567 TEST_F(StatsCollectorTest, GetStatsAfterRemoveAudioStream) { |
1557 StatsCollectorForTest stats(&pc_); | 1568 StatsCollectorForTest stats(&pc_); |
1558 | 1569 |
1559 EXPECT_CALL(session_, GetLocalCertificate(_, _)) | 1570 EXPECT_CALL(session_, GetLocalCertificate(_, _)) |
1560 .WillRepeatedly(Return(false)); | 1571 .WillRepeatedly(Return(false)); |
1561 EXPECT_CALL(session_, GetRemoteSSLCertificate_ReturnsRawPointer(_)) | 1572 EXPECT_CALL(session_, GetRemoteSSLCertificate_ReturnsRawPointer(_)) |
1562 .WillRepeatedly(Return(nullptr)); | 1573 .WillRepeatedly(Return(nullptr)); |
1563 | 1574 |
1564 MockVoiceMediaChannel* media_channel = new MockVoiceMediaChannel(); | 1575 MockVoiceMediaChannel* media_channel = new MockVoiceMediaChannel(); |
1565 // The transport_name known by the voice channel. | 1576 // The transport_name known by the voice channel. |
1566 const std::string kVcName("vcname"); | 1577 const std::string kVcName("vcname"); |
1567 cricket::VoiceChannel voice_channel(rtc::Thread::Current(), media_engine_, | 1578 cricket::VoiceChannel voice_channel(worker_thread_, network_thread_, |
1568 media_channel, nullptr, kVcName, false); | 1579 media_engine_, media_channel, nullptr, |
| 1580 kVcName, false); |
1569 AddOutgoingAudioTrackStats(); | 1581 AddOutgoingAudioTrackStats(); |
1570 stats.AddStream(stream_); | 1582 stats.AddStream(stream_); |
1571 stats.AddLocalAudioTrack(audio_track_.get(), kSsrcOfTrack); | 1583 stats.AddLocalAudioTrack(audio_track_.get(), kSsrcOfTrack); |
1572 | 1584 |
1573 // Instruct the session to return stats containing the transport channel. | 1585 // Instruct the session to return stats containing the transport channel. |
1574 InitSessionStats(kVcName); | 1586 InitSessionStats(kVcName); |
1575 EXPECT_CALL(session_, GetTransportStats(_)) | 1587 EXPECT_CALL(session_, GetTransportStats(_)) |
1576 .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats_), | 1588 .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats_), |
1577 Return(true))); | 1589 Return(true))); |
1578 | 1590 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1618 StatsCollectorForTest stats(&pc_); | 1630 StatsCollectorForTest stats(&pc_); |
1619 | 1631 |
1620 EXPECT_CALL(session_, GetLocalCertificate(_, _)) | 1632 EXPECT_CALL(session_, GetLocalCertificate(_, _)) |
1621 .WillRepeatedly(Return(false)); | 1633 .WillRepeatedly(Return(false)); |
1622 EXPECT_CALL(session_, GetRemoteSSLCertificate_ReturnsRawPointer(_)) | 1634 EXPECT_CALL(session_, GetRemoteSSLCertificate_ReturnsRawPointer(_)) |
1623 .WillRepeatedly(Return(nullptr)); | 1635 .WillRepeatedly(Return(nullptr)); |
1624 | 1636 |
1625 MockVoiceMediaChannel* media_channel = new MockVoiceMediaChannel(); | 1637 MockVoiceMediaChannel* media_channel = new MockVoiceMediaChannel(); |
1626 // The transport_name known by the voice channel. | 1638 // The transport_name known by the voice channel. |
1627 const std::string kVcName("vcname"); | 1639 const std::string kVcName("vcname"); |
1628 cricket::VoiceChannel voice_channel(rtc::Thread::Current(), media_engine_, | 1640 cricket::VoiceChannel voice_channel(worker_thread_, network_thread_, |
1629 media_channel, nullptr, kVcName, false); | 1641 media_engine_, media_channel, nullptr, |
| 1642 kVcName, false); |
1630 | 1643 |
1631 // Create a local stream with a local audio track and adds it to the stats. | 1644 // Create a local stream with a local audio track and adds it to the stats. |
1632 AddOutgoingAudioTrackStats(); | 1645 AddOutgoingAudioTrackStats(); |
1633 stats.AddStream(stream_); | 1646 stats.AddStream(stream_); |
1634 stats.AddLocalAudioTrack(audio_track_.get(), kSsrcOfTrack); | 1647 stats.AddLocalAudioTrack(audio_track_.get(), kSsrcOfTrack); |
1635 | 1648 |
1636 // Create a remote stream with a remote audio track and adds it to the stats. | 1649 // Create a remote stream with a remote audio track and adds it to the stats. |
1637 rtc::scoped_refptr<webrtc::MediaStream> remote_stream( | 1650 rtc::scoped_refptr<webrtc::MediaStream> remote_stream( |
1638 webrtc::MediaStream::Create("remotestreamlabel")); | 1651 webrtc::MediaStream::Create("remotestreamlabel")); |
1639 rtc::scoped_refptr<FakeAudioTrack> remote_track( | 1652 rtc::scoped_refptr<FakeAudioTrack> remote_track( |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1705 StatsCollectorForTest stats(&pc_); | 1718 StatsCollectorForTest stats(&pc_); |
1706 | 1719 |
1707 EXPECT_CALL(session_, GetLocalCertificate(_, _)) | 1720 EXPECT_CALL(session_, GetLocalCertificate(_, _)) |
1708 .WillRepeatedly(Return(false)); | 1721 .WillRepeatedly(Return(false)); |
1709 EXPECT_CALL(session_, GetRemoteSSLCertificate_ReturnsRawPointer(_)) | 1722 EXPECT_CALL(session_, GetRemoteSSLCertificate_ReturnsRawPointer(_)) |
1710 .WillRepeatedly(Return(nullptr)); | 1723 .WillRepeatedly(Return(nullptr)); |
1711 | 1724 |
1712 MockVoiceMediaChannel* media_channel = new MockVoiceMediaChannel(); | 1725 MockVoiceMediaChannel* media_channel = new MockVoiceMediaChannel(); |
1713 // The transport_name known by the voice channel. | 1726 // The transport_name known by the voice channel. |
1714 const std::string kVcName("vcname"); | 1727 const std::string kVcName("vcname"); |
1715 cricket::VoiceChannel voice_channel(rtc::Thread::Current(), media_engine_, | 1728 cricket::VoiceChannel voice_channel(worker_thread_, network_thread_, |
1716 media_channel, nullptr, kVcName, false); | 1729 media_engine_, media_channel, nullptr, |
| 1730 kVcName, false); |
1717 | 1731 |
1718 // Create a local stream with a local audio track and adds it to the stats. | 1732 // Create a local stream with a local audio track and adds it to the stats. |
1719 AddOutgoingAudioTrackStats(); | 1733 AddOutgoingAudioTrackStats(); |
1720 stats.AddStream(stream_); | 1734 stats.AddStream(stream_); |
1721 stats.AddLocalAudioTrack(audio_track_, kSsrcOfTrack); | 1735 stats.AddLocalAudioTrack(audio_track_, kSsrcOfTrack); |
1722 | 1736 |
1723 cricket::VoiceSenderInfo voice_sender_info; | 1737 cricket::VoiceSenderInfo voice_sender_info; |
1724 voice_sender_info.add_ssrc(kSsrcOfTrack); | 1738 voice_sender_info.add_ssrc(kSsrcOfTrack); |
1725 | 1739 |
1726 cricket::VoiceMediaInfo stats_read; | 1740 cricket::VoiceMediaInfo stats_read; |
(...skipping 19 matching lines...) Expand all Loading... |
1746 cricket::VoiceSenderInfo new_voice_sender_info; | 1760 cricket::VoiceSenderInfo new_voice_sender_info; |
1747 InitVoiceSenderInfo(&new_voice_sender_info); | 1761 InitVoiceSenderInfo(&new_voice_sender_info); |
1748 cricket::VoiceMediaInfo new_stats_read; | 1762 cricket::VoiceMediaInfo new_stats_read; |
1749 reports.clear(); | 1763 reports.clear(); |
1750 SetupAndVerifyAudioTrackStats( | 1764 SetupAndVerifyAudioTrackStats( |
1751 new_audio_track.get(), stream_.get(), &stats, &voice_channel, kVcName, | 1765 new_audio_track.get(), stream_.get(), &stats, &voice_channel, kVcName, |
1752 media_channel, &new_voice_sender_info, NULL, &new_stats_read, &reports); | 1766 media_channel, &new_voice_sender_info, NULL, &new_stats_read, &reports); |
1753 } | 1767 } |
1754 | 1768 |
1755 } // namespace webrtc | 1769 } // namespace webrtc |
OLD | NEW |