| OLD | NEW |
| 1 /* | 1 /* |
| 2 * libjingle | 2 * libjingle |
| 3 * Copyright 2014 Google Inc. | 3 * Copyright 2014 Google Inc. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
| 9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 // Error return values | 77 // Error return values |
| 78 const char kNotFound[] = "NOT FOUND"; | 78 const char kNotFound[] = "NOT FOUND"; |
| 79 | 79 |
| 80 // Constant names for track identification. | 80 // Constant names for track identification. |
| 81 const char kLocalTrackId[] = "local_track_id"; | 81 const char kLocalTrackId[] = "local_track_id"; |
| 82 const char kRemoteTrackId[] = "remote_track_id"; | 82 const char kRemoteTrackId[] = "remote_track_id"; |
| 83 const uint32_t kSsrcOfTrack = 1234; | 83 const uint32_t kSsrcOfTrack = 1234; |
| 84 | 84 |
| 85 class MockWebRtcSession : public webrtc::WebRtcSession { | 85 class MockWebRtcSession : public webrtc::WebRtcSession { |
| 86 public: | 86 public: |
| 87 explicit MockWebRtcSession(cricket::ChannelManager* channel_manager) | 87 explicit MockWebRtcSession(webrtc::MediaControllerInterface* media_controller) |
| 88 : WebRtcSession(channel_manager, | 88 : WebRtcSession(media_controller, |
| 89 rtc::Thread::Current(), | 89 rtc::Thread::Current(), |
| 90 rtc::Thread::Current(), | 90 rtc::Thread::Current(), |
| 91 nullptr) {} | 91 nullptr) {} |
| 92 MOCK_METHOD0(voice_channel, cricket::VoiceChannel*()); | 92 MOCK_METHOD0(voice_channel, cricket::VoiceChannel*()); |
| 93 MOCK_METHOD0(video_channel, cricket::VideoChannel*()); | 93 MOCK_METHOD0(video_channel, cricket::VideoChannel*()); |
| 94 // Libjingle uses "local" for a outgoing track, and "remote" for a incoming | 94 // Libjingle uses "local" for a outgoing track, and "remote" for a incoming |
| 95 // track. | 95 // track. |
| 96 MOCK_METHOD2(GetLocalTrackIdBySsrc, bool(uint32_t, std::string*)); | 96 MOCK_METHOD2(GetLocalTrackIdBySsrc, bool(uint32_t, std::string*)); |
| 97 MOCK_METHOD2(GetRemoteTrackIdBySsrc, bool(uint32_t, std::string*)); | 97 MOCK_METHOD2(GetRemoteTrackIdBySsrc, bool(uint32_t, std::string*)); |
| 98 MOCK_METHOD1(GetTransportStats, bool(SessionStats*)); | 98 MOCK_METHOD1(GetTransportStats, bool(SessionStats*)); |
| (...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 499 private: | 499 private: |
| 500 double time_now_; | 500 double time_now_; |
| 501 }; | 501 }; |
| 502 | 502 |
| 503 class StatsCollectorTest : public testing::Test { | 503 class StatsCollectorTest : public testing::Test { |
| 504 protected: | 504 protected: |
| 505 StatsCollectorTest() | 505 StatsCollectorTest() |
| 506 : media_engine_(new cricket::FakeMediaEngine()), | 506 : media_engine_(new cricket::FakeMediaEngine()), |
| 507 channel_manager_( | 507 channel_manager_( |
| 508 new cricket::ChannelManager(media_engine_, rtc::Thread::Current())), | 508 new cricket::ChannelManager(media_engine_, rtc::Thread::Current())), |
| 509 session_(channel_manager_.get()) { | 509 media_controller_( |
| 510 webrtc::MediaControllerInterface::Create(rtc::Thread::Current(), |
| 511 channel_manager_.get())), |
| 512 session_(media_controller_.get()) { |
| 510 // By default, we ignore session GetStats calls. | 513 // By default, we ignore session GetStats calls. |
| 511 EXPECT_CALL(session_, GetTransportStats(_)).WillRepeatedly(Return(false)); | 514 EXPECT_CALL(session_, GetTransportStats(_)).WillRepeatedly(Return(false)); |
| 512 // Add default returns for mock classes. | 515 // Add default returns for mock classes. |
| 513 EXPECT_CALL(session_, video_channel()).WillRepeatedly(ReturnNull()); | 516 EXPECT_CALL(session_, video_channel()).WillRepeatedly(ReturnNull()); |
| 514 EXPECT_CALL(session_, voice_channel()).WillRepeatedly(ReturnNull()); | 517 EXPECT_CALL(session_, voice_channel()).WillRepeatedly(ReturnNull()); |
| 515 EXPECT_CALL(pc_, session()).WillRepeatedly(Return(&session_)); | 518 EXPECT_CALL(pc_, session()).WillRepeatedly(Return(&session_)); |
| 516 EXPECT_CALL(pc_, sctp_data_channels()) | 519 EXPECT_CALL(pc_, sctp_data_channels()) |
| 517 .WillRepeatedly(ReturnRef(data_channels_)); | 520 .WillRepeatedly(ReturnRef(data_channels_)); |
| 518 } | 521 } |
| 519 | 522 |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 753 dtls_cipher); | 756 dtls_cipher); |
| 754 std::string srtp_cipher = ExtractStatsValue( | 757 std::string srtp_cipher = ExtractStatsValue( |
| 755 StatsReport::kStatsReportTypeComponent, | 758 StatsReport::kStatsReportTypeComponent, |
| 756 reports, | 759 reports, |
| 757 StatsReport::kStatsValueNameSrtpCipher); | 760 StatsReport::kStatsValueNameSrtpCipher); |
| 758 EXPECT_EQ("the-srtp-cipher", srtp_cipher); | 761 EXPECT_EQ("the-srtp-cipher", srtp_cipher); |
| 759 } | 762 } |
| 760 | 763 |
| 761 cricket::FakeMediaEngine* media_engine_; | 764 cricket::FakeMediaEngine* media_engine_; |
| 762 rtc::scoped_ptr<cricket::ChannelManager> channel_manager_; | 765 rtc::scoped_ptr<cricket::ChannelManager> channel_manager_; |
| 766 rtc::scoped_ptr<webrtc::MediaControllerInterface> media_controller_; |
| 763 MockWebRtcSession session_; | 767 MockWebRtcSession session_; |
| 764 MockPeerConnection pc_; | 768 MockPeerConnection pc_; |
| 765 FakeDataChannelProvider data_channel_provider_; | 769 FakeDataChannelProvider data_channel_provider_; |
| 766 SessionStats session_stats_; | 770 SessionStats session_stats_; |
| 767 rtc::scoped_refptr<webrtc::MediaStream> stream_; | 771 rtc::scoped_refptr<webrtc::MediaStream> stream_; |
| 768 rtc::scoped_refptr<webrtc::VideoTrack> track_; | 772 rtc::scoped_refptr<webrtc::VideoTrack> track_; |
| 769 rtc::scoped_refptr<FakeAudioTrack> audio_track_; | 773 rtc::scoped_refptr<FakeAudioTrack> audio_track_; |
| 770 std::vector<rtc::scoped_refptr<DataChannel>> data_channels_; | 774 std::vector<rtc::scoped_refptr<DataChannel>> data_channels_; |
| 771 }; | 775 }; |
| 772 | 776 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 818 .WillRepeatedly(Return(false)); | 822 .WillRepeatedly(Return(false)); |
| 819 | 823 |
| 820 const char kVideoChannelName[] = "video"; | 824 const char kVideoChannelName[] = "video"; |
| 821 | 825 |
| 822 InitSessionStats(kVideoChannelName); | 826 InitSessionStats(kVideoChannelName); |
| 823 EXPECT_CALL(session_, GetTransportStats(_)) | 827 EXPECT_CALL(session_, GetTransportStats(_)) |
| 824 .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats_), | 828 .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats_), |
| 825 Return(true))); | 829 Return(true))); |
| 826 | 830 |
| 827 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); | 831 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); |
| 828 cricket::VideoChannel video_channel(rtc::Thread::Current(), | 832 cricket::VideoChannel video_channel(rtc::Thread::Current(), media_channel, |
| 829 media_channel, NULL, kVideoChannelName, false); | 833 nullptr, kVideoChannelName, false); |
| 830 StatsReports reports; // returned values. | 834 StatsReports reports; // returned values. |
| 831 cricket::VideoSenderInfo video_sender_info; | 835 cricket::VideoSenderInfo video_sender_info; |
| 832 cricket::VideoMediaInfo stats_read; | 836 cricket::VideoMediaInfo stats_read; |
| 833 // The number of bytes must be larger than 0xFFFFFFFF for this test. | 837 // The number of bytes must be larger than 0xFFFFFFFF for this test. |
| 834 const int64_t kBytesSent = 12345678901234LL; | 838 const int64_t kBytesSent = 12345678901234LL; |
| 835 const std::string kBytesSentString("12345678901234"); | 839 const std::string kBytesSentString("12345678901234"); |
| 836 | 840 |
| 837 AddOutgoingVideoTrackStats(); | 841 AddOutgoingVideoTrackStats(); |
| 838 stats.AddStream(stream_); | 842 stats.AddStream(stream_); |
| 839 | 843 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 864 .WillRepeatedly(Return(false)); | 868 .WillRepeatedly(Return(false)); |
| 865 | 869 |
| 866 const char kVideoChannelName[] = "video"; | 870 const char kVideoChannelName[] = "video"; |
| 867 | 871 |
| 868 InitSessionStats(kVideoChannelName); | 872 InitSessionStats(kVideoChannelName); |
| 869 EXPECT_CALL(session_, GetTransportStats(_)) | 873 EXPECT_CALL(session_, GetTransportStats(_)) |
| 870 .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats_), | 874 .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats_), |
| 871 Return(true))); | 875 Return(true))); |
| 872 | 876 |
| 873 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); | 877 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); |
| 874 cricket::VideoChannel video_channel(rtc::Thread::Current(), | 878 cricket::VideoChannel video_channel(rtc::Thread::Current(), media_channel, |
| 875 media_channel, NULL, kVideoChannelName, false); | 879 nullptr, kVideoChannelName, false); |
| 876 | 880 |
| 877 StatsReports reports; // returned values. | 881 StatsReports reports; // returned values. |
| 878 cricket::VideoSenderInfo video_sender_info; | 882 cricket::VideoSenderInfo video_sender_info; |
| 879 cricket::VideoMediaInfo stats_read; | 883 cricket::VideoMediaInfo stats_read; |
| 880 // Set up an SSRC just to test that we get both kinds of stats back: SSRC and | 884 // Set up an SSRC just to test that we get both kinds of stats back: SSRC and |
| 881 // BWE. | 885 // BWE. |
| 882 const int64_t kBytesSent = 12345678901234LL; | 886 const int64_t kBytesSent = 12345678901234LL; |
| 883 const std::string kBytesSentString("12345678901234"); | 887 const std::string kBytesSentString("12345678901234"); |
| 884 | 888 |
| 885 AddOutgoingVideoTrackStats(); | 889 AddOutgoingVideoTrackStats(); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 939 reports, StatsReport::kStatsReportTypeSession, 2); | 943 reports, StatsReport::kStatsReportTypeSession, 2); |
| 940 EXPECT_EQ(NULL, session_report); | 944 EXPECT_EQ(NULL, session_report); |
| 941 } | 945 } |
| 942 | 946 |
| 943 // This test verifies that the empty track report exists in the returned stats | 947 // This test verifies that the empty track report exists in the returned stats |
| 944 // without calling StatsCollector::UpdateStats. | 948 // without calling StatsCollector::UpdateStats. |
| 945 TEST_F(StatsCollectorTest, TrackObjectExistsWithoutUpdateStats) { | 949 TEST_F(StatsCollectorTest, TrackObjectExistsWithoutUpdateStats) { |
| 946 StatsCollectorForTest stats(&pc_); | 950 StatsCollectorForTest stats(&pc_); |
| 947 | 951 |
| 948 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); | 952 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); |
| 949 cricket::VideoChannel video_channel(rtc::Thread::Current(), | 953 cricket::VideoChannel video_channel(rtc::Thread::Current(), media_channel, |
| 950 media_channel, NULL, "video", false); | 954 nullptr, "video", false); |
| 951 AddOutgoingVideoTrackStats(); | 955 AddOutgoingVideoTrackStats(); |
| 952 stats.AddStream(stream_); | 956 stats.AddStream(stream_); |
| 953 | 957 |
| 954 // Verfies the existence of the track report. | 958 // Verfies the existence of the track report. |
| 955 StatsReports reports; | 959 StatsReports reports; |
| 956 stats.GetStats(NULL, &reports); | 960 stats.GetStats(NULL, &reports); |
| 957 EXPECT_EQ((size_t)1, reports.size()); | 961 EXPECT_EQ((size_t)1, reports.size()); |
| 958 EXPECT_EQ(StatsReport::kStatsReportTypeTrack, reports[0]->type()); | 962 EXPECT_EQ(StatsReport::kStatsReportTypeTrack, reports[0]->type()); |
| 959 EXPECT_EQ(0, reports[0]->timestamp()); | 963 EXPECT_EQ(0, reports[0]->timestamp()); |
| 960 | 964 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 975 EXPECT_CALL(session_, GetRemoteSSLCertificate(_, _)) | 979 EXPECT_CALL(session_, GetRemoteSSLCertificate(_, _)) |
| 976 .WillRepeatedly(Return(false)); | 980 .WillRepeatedly(Return(false)); |
| 977 | 981 |
| 978 const char kVideoChannelName[] = "video"; | 982 const char kVideoChannelName[] = "video"; |
| 979 InitSessionStats(kVideoChannelName); | 983 InitSessionStats(kVideoChannelName); |
| 980 EXPECT_CALL(session_, GetTransportStats(_)) | 984 EXPECT_CALL(session_, GetTransportStats(_)) |
| 981 .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats_), | 985 .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats_), |
| 982 Return(true))); | 986 Return(true))); |
| 983 | 987 |
| 984 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); | 988 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); |
| 985 cricket::VideoChannel video_channel(rtc::Thread::Current(), | 989 cricket::VideoChannel video_channel(rtc::Thread::Current(), media_channel, |
| 986 media_channel, NULL, kVideoChannelName, false); | 990 nullptr, kVideoChannelName, false); |
| 987 AddOutgoingVideoTrackStats(); | 991 AddOutgoingVideoTrackStats(); |
| 988 stats.AddStream(stream_); | 992 stats.AddStream(stream_); |
| 989 | 993 |
| 990 // Constructs an ssrc stats update. | 994 // Constructs an ssrc stats update. |
| 991 cricket::VideoSenderInfo video_sender_info; | 995 cricket::VideoSenderInfo video_sender_info; |
| 992 cricket::VideoMediaInfo stats_read; | 996 cricket::VideoMediaInfo stats_read; |
| 993 const int64_t kBytesSent = 12345678901234LL; | 997 const int64_t kBytesSent = 12345678901234LL; |
| 994 | 998 |
| 995 // Construct a stats value to read. | 999 // Construct a stats value to read. |
| 996 video_sender_info.add_ssrc(1234); | 1000 video_sender_info.add_ssrc(1234); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1039 StatsCollectorForTest stats(&pc_); | 1043 StatsCollectorForTest stats(&pc_); |
| 1040 | 1044 |
| 1041 EXPECT_CALL(session_, GetLocalCertificate(_, _)) | 1045 EXPECT_CALL(session_, GetLocalCertificate(_, _)) |
| 1042 .WillRepeatedly(Return(false)); | 1046 .WillRepeatedly(Return(false)); |
| 1043 EXPECT_CALL(session_, GetRemoteSSLCertificate(_, _)) | 1047 EXPECT_CALL(session_, GetRemoteSSLCertificate(_, _)) |
| 1044 .WillRepeatedly(Return(false)); | 1048 .WillRepeatedly(Return(false)); |
| 1045 | 1049 |
| 1046 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); | 1050 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); |
| 1047 // The transport_name known by the video channel. | 1051 // The transport_name known by the video channel. |
| 1048 const std::string kVcName("vcname"); | 1052 const std::string kVcName("vcname"); |
| 1049 cricket::VideoChannel video_channel(rtc::Thread::Current(), | 1053 cricket::VideoChannel video_channel(rtc::Thread::Current(), media_channel, |
| 1050 media_channel, NULL, kVcName, false); | 1054 nullptr, kVcName, false); |
| 1051 AddOutgoingVideoTrackStats(); | 1055 AddOutgoingVideoTrackStats(); |
| 1052 stats.AddStream(stream_); | 1056 stats.AddStream(stream_); |
| 1053 | 1057 |
| 1054 // Constructs an ssrc stats update. | 1058 // Constructs an ssrc stats update. |
| 1055 cricket::VideoSenderInfo video_sender_info; | 1059 cricket::VideoSenderInfo video_sender_info; |
| 1056 cricket::VideoMediaInfo stats_read; | 1060 cricket::VideoMediaInfo stats_read; |
| 1057 const int64_t kBytesSent = 12345678901234LL; | 1061 const int64_t kBytesSent = 12345678901234LL; |
| 1058 | 1062 |
| 1059 // Construct a stats value to read. | 1063 // Construct a stats value to read. |
| 1060 video_sender_info.add_ssrc(1234); | 1064 video_sender_info.add_ssrc(1234); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1097 } | 1101 } |
| 1098 | 1102 |
| 1099 // This test verifies that a remote stats object will not be created for | 1103 // This test verifies that a remote stats object will not be created for |
| 1100 // an outgoing SSRC where remote stats are not returned. | 1104 // an outgoing SSRC where remote stats are not returned. |
| 1101 TEST_F(StatsCollectorTest, RemoteSsrcInfoIsAbsent) { | 1105 TEST_F(StatsCollectorTest, RemoteSsrcInfoIsAbsent) { |
| 1102 StatsCollectorForTest stats(&pc_); | 1106 StatsCollectorForTest stats(&pc_); |
| 1103 | 1107 |
| 1104 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); | 1108 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); |
| 1105 // The transport_name known by the video channel. | 1109 // The transport_name known by the video channel. |
| 1106 const std::string kVcName("vcname"); | 1110 const std::string kVcName("vcname"); |
| 1107 cricket::VideoChannel video_channel(rtc::Thread::Current(), | 1111 cricket::VideoChannel video_channel(rtc::Thread::Current(), media_channel, |
| 1108 media_channel, NULL, kVcName, false); | 1112 nullptr, kVcName, false); |
| 1109 AddOutgoingVideoTrackStats(); | 1113 AddOutgoingVideoTrackStats(); |
| 1110 stats.AddStream(stream_); | 1114 stats.AddStream(stream_); |
| 1111 | 1115 |
| 1112 stats.UpdateStats(PeerConnectionInterface::kStatsOutputLevelStandard); | 1116 stats.UpdateStats(PeerConnectionInterface::kStatsOutputLevelStandard); |
| 1113 StatsReports reports; | 1117 StatsReports reports; |
| 1114 stats.GetStats(NULL, &reports); | 1118 stats.GetStats(NULL, &reports); |
| 1115 const StatsReport* remote_report = FindNthReportByType(reports, | 1119 const StatsReport* remote_report = FindNthReportByType(reports, |
| 1116 StatsReport::kStatsReportTypeRemoteSsrc, 1); | 1120 StatsReport::kStatsReportTypeRemoteSsrc, 1); |
| 1117 EXPECT_TRUE(remote_report == NULL); | 1121 EXPECT_TRUE(remote_report == NULL); |
| 1118 } | 1122 } |
| 1119 | 1123 |
| 1120 // This test verifies that a remote stats object will be created for | 1124 // This test verifies that a remote stats object will be created for |
| 1121 // an outgoing SSRC where stats are returned. | 1125 // an outgoing SSRC where stats are returned. |
| 1122 TEST_F(StatsCollectorTest, RemoteSsrcInfoIsPresent) { | 1126 TEST_F(StatsCollectorTest, RemoteSsrcInfoIsPresent) { |
| 1123 StatsCollectorForTest stats(&pc_); | 1127 StatsCollectorForTest stats(&pc_); |
| 1124 | 1128 |
| 1125 EXPECT_CALL(session_, GetLocalCertificate(_, _)) | 1129 EXPECT_CALL(session_, GetLocalCertificate(_, _)) |
| 1126 .WillRepeatedly(Return(false)); | 1130 .WillRepeatedly(Return(false)); |
| 1127 EXPECT_CALL(session_, GetRemoteSSLCertificate(_, _)) | 1131 EXPECT_CALL(session_, GetRemoteSSLCertificate(_, _)) |
| 1128 .WillRepeatedly(Return(false)); | 1132 .WillRepeatedly(Return(false)); |
| 1129 | 1133 |
| 1130 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); | 1134 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); |
| 1131 // The transport_name known by the video channel. | 1135 // The transport_name known by the video channel. |
| 1132 const std::string kVcName("vcname"); | 1136 const std::string kVcName("vcname"); |
| 1133 cricket::VideoChannel video_channel(rtc::Thread::Current(), | 1137 cricket::VideoChannel video_channel(rtc::Thread::Current(), media_channel, |
| 1134 media_channel, NULL, kVcName, false); | 1138 nullptr, kVcName, false); |
| 1135 AddOutgoingVideoTrackStats(); | 1139 AddOutgoingVideoTrackStats(); |
| 1136 stats.AddStream(stream_); | 1140 stats.AddStream(stream_); |
| 1137 | 1141 |
| 1138 // Instruct the session to return stats containing the transport channel. | 1142 // Instruct the session to return stats containing the transport channel. |
| 1139 InitSessionStats(kVcName); | 1143 InitSessionStats(kVcName); |
| 1140 EXPECT_CALL(session_, GetTransportStats(_)) | 1144 EXPECT_CALL(session_, GetTransportStats(_)) |
| 1141 .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats_), | 1145 .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats_), |
| 1142 Return(true))); | 1146 Return(true))); |
| 1143 | 1147 |
| 1144 // Constructs an ssrc stats update. | 1148 // Constructs an ssrc stats update. |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1178 EXPECT_CALL(session_, GetRemoteSSLCertificate(_, _)) | 1182 EXPECT_CALL(session_, GetRemoteSSLCertificate(_, _)) |
| 1179 .WillRepeatedly(Return(false)); | 1183 .WillRepeatedly(Return(false)); |
| 1180 | 1184 |
| 1181 const char kVideoChannelName[] = "video"; | 1185 const char kVideoChannelName[] = "video"; |
| 1182 InitSessionStats(kVideoChannelName); | 1186 InitSessionStats(kVideoChannelName); |
| 1183 EXPECT_CALL(session_, GetTransportStats(_)) | 1187 EXPECT_CALL(session_, GetTransportStats(_)) |
| 1184 .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats_), | 1188 .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats_), |
| 1185 Return(true))); | 1189 Return(true))); |
| 1186 | 1190 |
| 1187 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); | 1191 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); |
| 1188 cricket::VideoChannel video_channel(rtc::Thread::Current(), | 1192 cricket::VideoChannel video_channel(rtc::Thread::Current(), media_channel, |
| 1189 media_channel, NULL, kVideoChannelName, false); | 1193 nullptr, kVideoChannelName, false); |
| 1190 AddIncomingVideoTrackStats(); | 1194 AddIncomingVideoTrackStats(); |
| 1191 stats.AddStream(stream_); | 1195 stats.AddStream(stream_); |
| 1192 | 1196 |
| 1193 // Constructs an ssrc stats update. | 1197 // Constructs an ssrc stats update. |
| 1194 cricket::VideoReceiverInfo video_receiver_info; | 1198 cricket::VideoReceiverInfo video_receiver_info; |
| 1195 cricket::VideoMediaInfo stats_read; | 1199 cricket::VideoMediaInfo stats_read; |
| 1196 const int64_t kNumOfPacketsConcealed = 54321; | 1200 const int64_t kNumOfPacketsConcealed = 54321; |
| 1197 | 1201 |
| 1198 // Construct a stats value to read. | 1202 // Construct a stats value to read. |
| 1199 video_receiver_info.add_ssrc(1234); | 1203 video_receiver_info.add_ssrc(1234); |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1487 StatsCollectorForTest stats(&pc_); | 1491 StatsCollectorForTest stats(&pc_); |
| 1488 | 1492 |
| 1489 EXPECT_CALL(session_, GetLocalCertificate(_, _)) | 1493 EXPECT_CALL(session_, GetLocalCertificate(_, _)) |
| 1490 .WillRepeatedly(Return(false)); | 1494 .WillRepeatedly(Return(false)); |
| 1491 EXPECT_CALL(session_, GetRemoteSSLCertificate(_, _)) | 1495 EXPECT_CALL(session_, GetRemoteSSLCertificate(_, _)) |
| 1492 .WillRepeatedly(Return(false)); | 1496 .WillRepeatedly(Return(false)); |
| 1493 | 1497 |
| 1494 MockVoiceMediaChannel* media_channel = new MockVoiceMediaChannel(); | 1498 MockVoiceMediaChannel* media_channel = new MockVoiceMediaChannel(); |
| 1495 // The transport_name known by the voice channel. | 1499 // The transport_name known by the voice channel. |
| 1496 const std::string kVcName("vcname"); | 1500 const std::string kVcName("vcname"); |
| 1497 cricket::VoiceChannel voice_channel(rtc::Thread::Current(), | 1501 cricket::VoiceChannel voice_channel(rtc::Thread::Current(), media_engine_, |
| 1498 media_engine_, media_channel, NULL, kVcName, false); | 1502 media_channel, nullptr, kVcName, false); |
| 1499 AddOutgoingAudioTrackStats(); | 1503 AddOutgoingAudioTrackStats(); |
| 1500 stats.AddStream(stream_); | 1504 stats.AddStream(stream_); |
| 1501 stats.AddLocalAudioTrack(audio_track_, kSsrcOfTrack); | 1505 stats.AddLocalAudioTrack(audio_track_, kSsrcOfTrack); |
| 1502 | 1506 |
| 1503 cricket::VoiceSenderInfo voice_sender_info; | 1507 cricket::VoiceSenderInfo voice_sender_info; |
| 1504 InitVoiceSenderInfo(&voice_sender_info); | 1508 InitVoiceSenderInfo(&voice_sender_info); |
| 1505 | 1509 |
| 1506 cricket::VoiceMediaInfo stats_read; | 1510 cricket::VoiceMediaInfo stats_read; |
| 1507 StatsReports reports; // returned values. | 1511 StatsReports reports; // returned values. |
| 1508 SetupAndVerifyAudioTrackStats( | 1512 SetupAndVerifyAudioTrackStats( |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1522 StatsCollectorForTest stats(&pc_); | 1526 StatsCollectorForTest stats(&pc_); |
| 1523 | 1527 |
| 1524 EXPECT_CALL(session_, GetLocalCertificate(_, _)) | 1528 EXPECT_CALL(session_, GetLocalCertificate(_, _)) |
| 1525 .WillRepeatedly(Return(false)); | 1529 .WillRepeatedly(Return(false)); |
| 1526 EXPECT_CALL(session_, GetRemoteSSLCertificate(_, _)) | 1530 EXPECT_CALL(session_, GetRemoteSSLCertificate(_, _)) |
| 1527 .WillRepeatedly(Return(false)); | 1531 .WillRepeatedly(Return(false)); |
| 1528 | 1532 |
| 1529 MockVoiceMediaChannel* media_channel = new MockVoiceMediaChannel(); | 1533 MockVoiceMediaChannel* media_channel = new MockVoiceMediaChannel(); |
| 1530 // The transport_name known by the voice channel. | 1534 // The transport_name known by the voice channel. |
| 1531 const std::string kVcName("vcname"); | 1535 const std::string kVcName("vcname"); |
| 1532 cricket::VoiceChannel voice_channel(rtc::Thread::Current(), | 1536 cricket::VoiceChannel voice_channel(rtc::Thread::Current(), media_engine_, |
| 1533 media_engine_, media_channel, NULL, kVcName, false); | 1537 media_channel, nullptr, kVcName, false); |
| 1534 AddIncomingAudioTrackStats(); | 1538 AddIncomingAudioTrackStats(); |
| 1535 stats.AddStream(stream_); | 1539 stats.AddStream(stream_); |
| 1536 | 1540 |
| 1537 cricket::VoiceReceiverInfo voice_receiver_info; | 1541 cricket::VoiceReceiverInfo voice_receiver_info; |
| 1538 InitVoiceReceiverInfo(&voice_receiver_info); | 1542 InitVoiceReceiverInfo(&voice_receiver_info); |
| 1539 voice_receiver_info.codec_name = "fake_codec"; | 1543 voice_receiver_info.codec_name = "fake_codec"; |
| 1540 | 1544 |
| 1541 cricket::VoiceMediaInfo stats_read; | 1545 cricket::VoiceMediaInfo stats_read; |
| 1542 StatsReports reports; // returned values. | 1546 StatsReports reports; // returned values. |
| 1543 SetupAndVerifyAudioTrackStats( | 1547 SetupAndVerifyAudioTrackStats( |
| 1544 audio_track_.get(), stream_.get(), &stats, &voice_channel, kVcName, | 1548 audio_track_.get(), stream_.get(), &stats, &voice_channel, kVcName, |
| 1545 media_channel, NULL, &voice_receiver_info, &stats_read, &reports); | 1549 media_channel, NULL, &voice_receiver_info, &stats_read, &reports); |
| 1546 } | 1550 } |
| 1547 | 1551 |
| 1548 // This test verifies that a local stats object won't update its statistics | 1552 // This test verifies that a local stats object won't update its statistics |
| 1549 // after a RemoveLocalAudioTrack() call. | 1553 // after a RemoveLocalAudioTrack() call. |
| 1550 TEST_F(StatsCollectorTest, GetStatsAfterRemoveAudioStream) { | 1554 TEST_F(StatsCollectorTest, GetStatsAfterRemoveAudioStream) { |
| 1551 StatsCollectorForTest stats(&pc_); | 1555 StatsCollectorForTest stats(&pc_); |
| 1552 | 1556 |
| 1553 EXPECT_CALL(session_, GetLocalCertificate(_, _)) | 1557 EXPECT_CALL(session_, GetLocalCertificate(_, _)) |
| 1554 .WillRepeatedly(Return(false)); | 1558 .WillRepeatedly(Return(false)); |
| 1555 EXPECT_CALL(session_, GetRemoteSSLCertificate(_, _)) | 1559 EXPECT_CALL(session_, GetRemoteSSLCertificate(_, _)) |
| 1556 .WillRepeatedly(Return(false)); | 1560 .WillRepeatedly(Return(false)); |
| 1557 | 1561 |
| 1558 MockVoiceMediaChannel* media_channel = new MockVoiceMediaChannel(); | 1562 MockVoiceMediaChannel* media_channel = new MockVoiceMediaChannel(); |
| 1559 // The transport_name known by the voice channel. | 1563 // The transport_name known by the voice channel. |
| 1560 const std::string kVcName("vcname"); | 1564 const std::string kVcName("vcname"); |
| 1561 cricket::VoiceChannel voice_channel(rtc::Thread::Current(), | 1565 cricket::VoiceChannel voice_channel(rtc::Thread::Current(), media_engine_, |
| 1562 media_engine_, media_channel, NULL, kVcName, false); | 1566 media_channel, nullptr, kVcName, false); |
| 1563 AddOutgoingAudioTrackStats(); | 1567 AddOutgoingAudioTrackStats(); |
| 1564 stats.AddStream(stream_); | 1568 stats.AddStream(stream_); |
| 1565 stats.AddLocalAudioTrack(audio_track_.get(), kSsrcOfTrack); | 1569 stats.AddLocalAudioTrack(audio_track_.get(), kSsrcOfTrack); |
| 1566 | 1570 |
| 1567 // Instruct the session to return stats containing the transport channel. | 1571 // Instruct the session to return stats containing the transport channel. |
| 1568 InitSessionStats(kVcName); | 1572 InitSessionStats(kVcName); |
| 1569 EXPECT_CALL(session_, GetTransportStats(_)) | 1573 EXPECT_CALL(session_, GetTransportStats(_)) |
| 1570 .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats_), | 1574 .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats_), |
| 1571 Return(true))); | 1575 Return(true))); |
| 1572 | 1576 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1612 StatsCollectorForTest stats(&pc_); | 1616 StatsCollectorForTest stats(&pc_); |
| 1613 | 1617 |
| 1614 EXPECT_CALL(session_, GetLocalCertificate(_, _)) | 1618 EXPECT_CALL(session_, GetLocalCertificate(_, _)) |
| 1615 .WillRepeatedly(Return(false)); | 1619 .WillRepeatedly(Return(false)); |
| 1616 EXPECT_CALL(session_, GetRemoteSSLCertificate(_, _)) | 1620 EXPECT_CALL(session_, GetRemoteSSLCertificate(_, _)) |
| 1617 .WillRepeatedly(Return(false)); | 1621 .WillRepeatedly(Return(false)); |
| 1618 | 1622 |
| 1619 MockVoiceMediaChannel* media_channel = new MockVoiceMediaChannel(); | 1623 MockVoiceMediaChannel* media_channel = new MockVoiceMediaChannel(); |
| 1620 // The transport_name known by the voice channel. | 1624 // The transport_name known by the voice channel. |
| 1621 const std::string kVcName("vcname"); | 1625 const std::string kVcName("vcname"); |
| 1622 cricket::VoiceChannel voice_channel(rtc::Thread::Current(), | 1626 cricket::VoiceChannel voice_channel(rtc::Thread::Current(), media_engine_, |
| 1623 media_engine_, media_channel, NULL, kVcName, false); | 1627 media_channel, nullptr, kVcName, false); |
| 1624 | 1628 |
| 1625 // Create a local stream with a local audio track and adds it to the stats. | 1629 // Create a local stream with a local audio track and adds it to the stats. |
| 1626 AddOutgoingAudioTrackStats(); | 1630 AddOutgoingAudioTrackStats(); |
| 1627 stats.AddStream(stream_); | 1631 stats.AddStream(stream_); |
| 1628 stats.AddLocalAudioTrack(audio_track_.get(), kSsrcOfTrack); | 1632 stats.AddLocalAudioTrack(audio_track_.get(), kSsrcOfTrack); |
| 1629 | 1633 |
| 1630 // Create a remote stream with a remote audio track and adds it to the stats. | 1634 // Create a remote stream with a remote audio track and adds it to the stats. |
| 1631 rtc::scoped_refptr<webrtc::MediaStream> remote_stream( | 1635 rtc::scoped_refptr<webrtc::MediaStream> remote_stream( |
| 1632 webrtc::MediaStream::Create("remotestreamlabel")); | 1636 webrtc::MediaStream::Create("remotestreamlabel")); |
| 1633 rtc::scoped_refptr<FakeAudioTrack> remote_track( | 1637 rtc::scoped_refptr<FakeAudioTrack> remote_track( |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1699 StatsCollectorForTest stats(&pc_); | 1703 StatsCollectorForTest stats(&pc_); |
| 1700 | 1704 |
| 1701 EXPECT_CALL(session_, GetLocalCertificate(_, _)) | 1705 EXPECT_CALL(session_, GetLocalCertificate(_, _)) |
| 1702 .WillRepeatedly(Return(false)); | 1706 .WillRepeatedly(Return(false)); |
| 1703 EXPECT_CALL(session_, GetRemoteSSLCertificate(_, _)) | 1707 EXPECT_CALL(session_, GetRemoteSSLCertificate(_, _)) |
| 1704 .WillRepeatedly(Return(false)); | 1708 .WillRepeatedly(Return(false)); |
| 1705 | 1709 |
| 1706 MockVoiceMediaChannel* media_channel = new MockVoiceMediaChannel(); | 1710 MockVoiceMediaChannel* media_channel = new MockVoiceMediaChannel(); |
| 1707 // The transport_name known by the voice channel. | 1711 // The transport_name known by the voice channel. |
| 1708 const std::string kVcName("vcname"); | 1712 const std::string kVcName("vcname"); |
| 1709 cricket::VoiceChannel voice_channel(rtc::Thread::Current(), | 1713 cricket::VoiceChannel voice_channel(rtc::Thread::Current(), media_engine_, |
| 1710 media_engine_, media_channel, NULL, kVcName, false); | 1714 media_channel, nullptr, kVcName, false); |
| 1711 | 1715 |
| 1712 // Create a local stream with a local audio track and adds it to the stats. | 1716 // Create a local stream with a local audio track and adds it to the stats. |
| 1713 AddOutgoingAudioTrackStats(); | 1717 AddOutgoingAudioTrackStats(); |
| 1714 stats.AddStream(stream_); | 1718 stats.AddStream(stream_); |
| 1715 stats.AddLocalAudioTrack(audio_track_, kSsrcOfTrack); | 1719 stats.AddLocalAudioTrack(audio_track_, kSsrcOfTrack); |
| 1716 | 1720 |
| 1717 cricket::VoiceSenderInfo voice_sender_info; | 1721 cricket::VoiceSenderInfo voice_sender_info; |
| 1718 voice_sender_info.add_ssrc(kSsrcOfTrack); | 1722 voice_sender_info.add_ssrc(kSsrcOfTrack); |
| 1719 | 1723 |
| 1720 cricket::VoiceMediaInfo stats_read; | 1724 cricket::VoiceMediaInfo stats_read; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1740 cricket::VoiceSenderInfo new_voice_sender_info; | 1744 cricket::VoiceSenderInfo new_voice_sender_info; |
| 1741 InitVoiceSenderInfo(&new_voice_sender_info); | 1745 InitVoiceSenderInfo(&new_voice_sender_info); |
| 1742 cricket::VoiceMediaInfo new_stats_read; | 1746 cricket::VoiceMediaInfo new_stats_read; |
| 1743 reports.clear(); | 1747 reports.clear(); |
| 1744 SetupAndVerifyAudioTrackStats( | 1748 SetupAndVerifyAudioTrackStats( |
| 1745 new_audio_track.get(), stream_.get(), &stats, &voice_channel, kVcName, | 1749 new_audio_track.get(), stream_.get(), &stats, &voice_channel, kVcName, |
| 1746 media_channel, &new_voice_sender_info, NULL, &new_stats_read, &reports); | 1750 media_channel, &new_voice_sender_info, NULL, &new_stats_read, &reports); |
| 1747 } | 1751 } |
| 1748 | 1752 |
| 1749 } // namespace webrtc | 1753 } // namespace webrtc |
| OLD | NEW |