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 782 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
793 | 793 |
794 InitSessionStats(kVideoChannelName); | 794 InitSessionStats(kVideoChannelName); |
795 EXPECT_CALL(session_, GetTransportStats(_)) | 795 EXPECT_CALL(session_, GetTransportStats(_)) |
796 .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats_), | 796 .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats_), |
797 Return(true))); | 797 Return(true))); |
798 EXPECT_CALL(session_, GetTransport(_)) | 798 EXPECT_CALL(session_, GetTransport(_)) |
799 .WillRepeatedly(Return(static_cast<cricket::Transport*>(NULL))); | 799 .WillRepeatedly(Return(static_cast<cricket::Transport*>(NULL))); |
800 | 800 |
801 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); | 801 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); |
802 cricket::VideoChannel video_channel(rtc::Thread::Current(), | 802 cricket::VideoChannel video_channel(rtc::Thread::Current(), |
803 media_engine_, media_channel, NULL, kVideoChannelName, false); | 803 media_channel, NULL, kVideoChannelName, false); |
804 StatsReports reports; // returned values. | 804 StatsReports reports; // returned values. |
805 cricket::VideoSenderInfo video_sender_info; | 805 cricket::VideoSenderInfo video_sender_info; |
806 cricket::VideoMediaInfo stats_read; | 806 cricket::VideoMediaInfo stats_read; |
807 // The number of bytes must be larger than 0xFFFFFFFF for this test. | 807 // The number of bytes must be larger than 0xFFFFFFFF for this test. |
808 const int64 kBytesSent = 12345678901234LL; | 808 const int64 kBytesSent = 12345678901234LL; |
809 const std::string kBytesSentString("12345678901234"); | 809 const std::string kBytesSentString("12345678901234"); |
810 | 810 |
811 AddOutgoingVideoTrackStats(); | 811 AddOutgoingVideoTrackStats(); |
812 stats.AddStream(stream_); | 812 stats.AddStream(stream_); |
813 | 813 |
(...skipping 22 matching lines...) Expand all Loading... |
836 | 836 |
837 InitSessionStats(kVideoChannelName); | 837 InitSessionStats(kVideoChannelName); |
838 EXPECT_CALL(session_, GetTransportStats(_)) | 838 EXPECT_CALL(session_, GetTransportStats(_)) |
839 .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats_), | 839 .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats_), |
840 Return(true))); | 840 Return(true))); |
841 EXPECT_CALL(session_, GetTransport(_)) | 841 EXPECT_CALL(session_, GetTransport(_)) |
842 .WillRepeatedly(Return(static_cast<cricket::Transport*>(NULL))); | 842 .WillRepeatedly(Return(static_cast<cricket::Transport*>(NULL))); |
843 | 843 |
844 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); | 844 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); |
845 cricket::VideoChannel video_channel(rtc::Thread::Current(), | 845 cricket::VideoChannel video_channel(rtc::Thread::Current(), |
846 media_engine_, media_channel, NULL, kVideoChannelName, false); | 846 media_channel, NULL, kVideoChannelName, false); |
847 | 847 |
848 StatsReports reports; // returned values. | 848 StatsReports reports; // returned values. |
849 cricket::VideoSenderInfo video_sender_info; | 849 cricket::VideoSenderInfo video_sender_info; |
850 cricket::VideoMediaInfo stats_read; | 850 cricket::VideoMediaInfo stats_read; |
851 // Set up an SSRC just to test that we get both kinds of stats back: SSRC and | 851 // Set up an SSRC just to test that we get both kinds of stats back: SSRC and |
852 // BWE. | 852 // BWE. |
853 const int64 kBytesSent = 12345678901234LL; | 853 const int64 kBytesSent = 12345678901234LL; |
854 const std::string kBytesSentString("12345678901234"); | 854 const std::string kBytesSentString("12345678901234"); |
855 | 855 |
856 AddOutgoingVideoTrackStats(); | 856 AddOutgoingVideoTrackStats(); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
915 EXPECT_EQ(NULL, session_report); | 915 EXPECT_EQ(NULL, session_report); |
916 } | 916 } |
917 | 917 |
918 // This test verifies that the empty track report exists in the returned stats | 918 // This test verifies that the empty track report exists in the returned stats |
919 // without calling StatsCollector::UpdateStats. | 919 // without calling StatsCollector::UpdateStats. |
920 TEST_F(StatsCollectorTest, TrackObjectExistsWithoutUpdateStats) { | 920 TEST_F(StatsCollectorTest, TrackObjectExistsWithoutUpdateStats) { |
921 StatsCollectorForTest stats(&session_); | 921 StatsCollectorForTest stats(&session_); |
922 | 922 |
923 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); | 923 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); |
924 cricket::VideoChannel video_channel(rtc::Thread::Current(), | 924 cricket::VideoChannel video_channel(rtc::Thread::Current(), |
925 media_engine_, media_channel, NULL, "video", false); | 925 media_channel, NULL, "video", false); |
926 AddOutgoingVideoTrackStats(); | 926 AddOutgoingVideoTrackStats(); |
927 stats.AddStream(stream_); | 927 stats.AddStream(stream_); |
928 | 928 |
929 // Verfies the existence of the track report. | 929 // Verfies the existence of the track report. |
930 StatsReports reports; | 930 StatsReports reports; |
931 stats.GetStats(NULL, &reports); | 931 stats.GetStats(NULL, &reports); |
932 EXPECT_EQ((size_t)1, reports.size()); | 932 EXPECT_EQ((size_t)1, reports.size()); |
933 EXPECT_EQ(StatsReport::kStatsReportTypeTrack, reports[0]->type()); | 933 EXPECT_EQ(StatsReport::kStatsReportTypeTrack, reports[0]->type()); |
934 EXPECT_EQ(0, reports[0]->timestamp()); | 934 EXPECT_EQ(0, reports[0]->timestamp()); |
935 | 935 |
(...skipping 12 matching lines...) Expand all Loading... |
948 const char kVideoChannelName[] = "video"; | 948 const char kVideoChannelName[] = "video"; |
949 InitSessionStats(kVideoChannelName); | 949 InitSessionStats(kVideoChannelName); |
950 EXPECT_CALL(session_, GetTransportStats(_)) | 950 EXPECT_CALL(session_, GetTransportStats(_)) |
951 .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats_), | 951 .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats_), |
952 Return(true))); | 952 Return(true))); |
953 EXPECT_CALL(session_, GetTransport(_)) | 953 EXPECT_CALL(session_, GetTransport(_)) |
954 .WillRepeatedly(Return(static_cast<cricket::Transport*>(NULL))); | 954 .WillRepeatedly(Return(static_cast<cricket::Transport*>(NULL))); |
955 | 955 |
956 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); | 956 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); |
957 cricket::VideoChannel video_channel(rtc::Thread::Current(), | 957 cricket::VideoChannel video_channel(rtc::Thread::Current(), |
958 media_engine_, media_channel, NULL, kVideoChannelName, false); | 958 media_channel, NULL, kVideoChannelName, false); |
959 AddOutgoingVideoTrackStats(); | 959 AddOutgoingVideoTrackStats(); |
960 stats.AddStream(stream_); | 960 stats.AddStream(stream_); |
961 | 961 |
962 // Constructs an ssrc stats update. | 962 // Constructs an ssrc stats update. |
963 cricket::VideoSenderInfo video_sender_info; | 963 cricket::VideoSenderInfo video_sender_info; |
964 cricket::VideoMediaInfo stats_read; | 964 cricket::VideoMediaInfo stats_read; |
965 const int64 kBytesSent = 12345678901234LL; | 965 const int64 kBytesSent = 12345678901234LL; |
966 | 966 |
967 // Construct a stats value to read. | 967 // Construct a stats value to read. |
968 video_sender_info.add_ssrc(1234); | 968 video_sender_info.add_ssrc(1234); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1010 TEST_F(StatsCollectorTest, TransportObjectLinkedFromSsrcObject) { | 1010 TEST_F(StatsCollectorTest, TransportObjectLinkedFromSsrcObject) { |
1011 StatsCollectorForTest stats(&session_); | 1011 StatsCollectorForTest stats(&session_); |
1012 | 1012 |
1013 // Ignore unused callback (logspam). | 1013 // Ignore unused callback (logspam). |
1014 EXPECT_CALL(session_, GetTransport(_)) | 1014 EXPECT_CALL(session_, GetTransport(_)) |
1015 .WillRepeatedly(Return(static_cast<cricket::Transport*>(NULL))); | 1015 .WillRepeatedly(Return(static_cast<cricket::Transport*>(NULL))); |
1016 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); | 1016 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); |
1017 // The content_name known by the video channel. | 1017 // The content_name known by the video channel. |
1018 const std::string kVcName("vcname"); | 1018 const std::string kVcName("vcname"); |
1019 cricket::VideoChannel video_channel(rtc::Thread::Current(), | 1019 cricket::VideoChannel video_channel(rtc::Thread::Current(), |
1020 media_engine_, media_channel, NULL, kVcName, false); | 1020 media_channel, NULL, kVcName, false); |
1021 AddOutgoingVideoTrackStats(); | 1021 AddOutgoingVideoTrackStats(); |
1022 stats.AddStream(stream_); | 1022 stats.AddStream(stream_); |
1023 | 1023 |
1024 // Constructs an ssrc stats update. | 1024 // Constructs an ssrc stats update. |
1025 cricket::VideoSenderInfo video_sender_info; | 1025 cricket::VideoSenderInfo video_sender_info; |
1026 cricket::VideoMediaInfo stats_read; | 1026 cricket::VideoMediaInfo stats_read; |
1027 const int64 kBytesSent = 12345678901234LL; | 1027 const int64 kBytesSent = 12345678901234LL; |
1028 | 1028 |
1029 // Construct a stats value to read. | 1029 // Construct a stats value to read. |
1030 video_sender_info.add_ssrc(1234); | 1030 video_sender_info.add_ssrc(1234); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1068 | 1068 |
1069 // This test verifies that a remote stats object will not be created for | 1069 // This test verifies that a remote stats object will not be created for |
1070 // an outgoing SSRC where remote stats are not returned. | 1070 // an outgoing SSRC where remote stats are not returned. |
1071 TEST_F(StatsCollectorTest, RemoteSsrcInfoIsAbsent) { | 1071 TEST_F(StatsCollectorTest, RemoteSsrcInfoIsAbsent) { |
1072 StatsCollectorForTest stats(&session_); | 1072 StatsCollectorForTest stats(&session_); |
1073 | 1073 |
1074 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); | 1074 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); |
1075 // The content_name known by the video channel. | 1075 // The content_name known by the video channel. |
1076 const std::string kVcName("vcname"); | 1076 const std::string kVcName("vcname"); |
1077 cricket::VideoChannel video_channel(rtc::Thread::Current(), | 1077 cricket::VideoChannel video_channel(rtc::Thread::Current(), |
1078 media_engine_, media_channel, NULL, kVcName, false); | 1078 media_channel, NULL, kVcName, false); |
1079 AddOutgoingVideoTrackStats(); | 1079 AddOutgoingVideoTrackStats(); |
1080 stats.AddStream(stream_); | 1080 stats.AddStream(stream_); |
1081 | 1081 |
1082 EXPECT_CALL(session_, video_channel()).WillRepeatedly(ReturnNull()); | 1082 EXPECT_CALL(session_, video_channel()).WillRepeatedly(ReturnNull()); |
1083 EXPECT_CALL(session_, voice_channel()).WillRepeatedly(ReturnNull()); | 1083 EXPECT_CALL(session_, voice_channel()).WillRepeatedly(ReturnNull()); |
1084 | 1084 |
1085 stats.UpdateStats(PeerConnectionInterface::kStatsOutputLevelStandard); | 1085 stats.UpdateStats(PeerConnectionInterface::kStatsOutputLevelStandard); |
1086 StatsReports reports; | 1086 StatsReports reports; |
1087 stats.GetStats(NULL, &reports); | 1087 stats.GetStats(NULL, &reports); |
1088 const StatsReport* remote_report = FindNthReportByType(reports, | 1088 const StatsReport* remote_report = FindNthReportByType(reports, |
1089 StatsReport::kStatsReportTypeRemoteSsrc, 1); | 1089 StatsReport::kStatsReportTypeRemoteSsrc, 1); |
1090 EXPECT_TRUE(remote_report == NULL); | 1090 EXPECT_TRUE(remote_report == NULL); |
1091 } | 1091 } |
1092 | 1092 |
1093 // This test verifies that a remote stats object will be created for | 1093 // This test verifies that a remote stats object will be created for |
1094 // an outgoing SSRC where stats are returned. | 1094 // an outgoing SSRC where stats are returned. |
1095 TEST_F(StatsCollectorTest, RemoteSsrcInfoIsPresent) { | 1095 TEST_F(StatsCollectorTest, RemoteSsrcInfoIsPresent) { |
1096 StatsCollectorForTest stats(&session_); | 1096 StatsCollectorForTest stats(&session_); |
1097 | 1097 |
1098 // Ignore unused callback (logspam). | 1098 // Ignore unused callback (logspam). |
1099 EXPECT_CALL(session_, GetTransport(_)) | 1099 EXPECT_CALL(session_, GetTransport(_)) |
1100 .WillRepeatedly(Return(static_cast<cricket::Transport*>(NULL))); | 1100 .WillRepeatedly(Return(static_cast<cricket::Transport*>(NULL))); |
1101 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); | 1101 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); |
1102 // The content_name known by the video channel. | 1102 // The content_name known by the video channel. |
1103 const std::string kVcName("vcname"); | 1103 const std::string kVcName("vcname"); |
1104 cricket::VideoChannel video_channel(rtc::Thread::Current(), | 1104 cricket::VideoChannel video_channel(rtc::Thread::Current(), |
1105 media_engine_, media_channel, NULL, kVcName, false); | 1105 media_channel, NULL, kVcName, false); |
1106 AddOutgoingVideoTrackStats(); | 1106 AddOutgoingVideoTrackStats(); |
1107 stats.AddStream(stream_); | 1107 stats.AddStream(stream_); |
1108 | 1108 |
1109 // Instruct the session to return stats containing the transport channel. | 1109 // Instruct the session to return stats containing the transport channel. |
1110 InitSessionStats(kVcName); | 1110 InitSessionStats(kVcName); |
1111 EXPECT_CALL(session_, GetTransportStats(_)) | 1111 EXPECT_CALL(session_, GetTransportStats(_)) |
1112 .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats_), | 1112 .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats_), |
1113 Return(true))); | 1113 Return(true))); |
1114 | 1114 |
1115 // Constructs an ssrc stats update. | 1115 // Constructs an ssrc stats update. |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1147 const char kVideoChannelName[] = "video"; | 1147 const char kVideoChannelName[] = "video"; |
1148 InitSessionStats(kVideoChannelName); | 1148 InitSessionStats(kVideoChannelName); |
1149 EXPECT_CALL(session_, GetTransportStats(_)) | 1149 EXPECT_CALL(session_, GetTransportStats(_)) |
1150 .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats_), | 1150 .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats_), |
1151 Return(true))); | 1151 Return(true))); |
1152 EXPECT_CALL(session_, GetTransport(_)) | 1152 EXPECT_CALL(session_, GetTransport(_)) |
1153 .WillRepeatedly(Return(static_cast<cricket::Transport*>(NULL))); | 1153 .WillRepeatedly(Return(static_cast<cricket::Transport*>(NULL))); |
1154 | 1154 |
1155 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); | 1155 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); |
1156 cricket::VideoChannel video_channel(rtc::Thread::Current(), | 1156 cricket::VideoChannel video_channel(rtc::Thread::Current(), |
1157 media_engine_, media_channel, NULL, kVideoChannelName, false); | 1157 media_channel, NULL, kVideoChannelName, false); |
1158 AddIncomingVideoTrackStats(); | 1158 AddIncomingVideoTrackStats(); |
1159 stats.AddStream(stream_); | 1159 stats.AddStream(stream_); |
1160 | 1160 |
1161 // Constructs an ssrc stats update. | 1161 // Constructs an ssrc stats update. |
1162 cricket::VideoReceiverInfo video_receiver_info; | 1162 cricket::VideoReceiverInfo video_receiver_info; |
1163 cricket::VideoMediaInfo stats_read; | 1163 cricket::VideoMediaInfo stats_read; |
1164 const int64 kNumOfPacketsConcealed = 54321; | 1164 const int64 kNumOfPacketsConcealed = 54321; |
1165 | 1165 |
1166 // Construct a stats value to read. | 1166 // Construct a stats value to read. |
1167 video_receiver_info.add_ssrc(1234); | 1167 video_receiver_info.add_ssrc(1234); |
(...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1702 cricket::VoiceSenderInfo new_voice_sender_info; | 1702 cricket::VoiceSenderInfo new_voice_sender_info; |
1703 InitVoiceSenderInfo(&new_voice_sender_info); | 1703 InitVoiceSenderInfo(&new_voice_sender_info); |
1704 cricket::VoiceMediaInfo new_stats_read; | 1704 cricket::VoiceMediaInfo new_stats_read; |
1705 reports.clear(); | 1705 reports.clear(); |
1706 SetupAndVerifyAudioTrackStats( | 1706 SetupAndVerifyAudioTrackStats( |
1707 new_audio_track.get(), stream_.get(), &stats, &voice_channel, kVcName, | 1707 new_audio_track.get(), stream_.get(), &stats, &voice_channel, kVcName, |
1708 media_channel, &new_voice_sender_info, NULL, &new_stats_read, &reports); | 1708 media_channel, &new_voice_sender_info, NULL, &new_stats_read, &reports); |
1709 } | 1709 } |
1710 | 1710 |
1711 } // namespace webrtc | 1711 } // namespace webrtc |
OLD | NEW |