OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2016 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
574 EXPECT_FALSE(delivered_report_); | 574 EXPECT_FALSE(delivered_report_); |
575 ++produced_on_signaling_thread_; | 575 ++produced_on_signaling_thread_; |
576 } | 576 } |
577 | 577 |
578 rtc::scoped_refptr<RTCStatsReport> signaling_report = | 578 rtc::scoped_refptr<RTCStatsReport> signaling_report = |
579 RTCStatsReport::Create(0); | 579 RTCStatsReport::Create(0); |
580 signaling_report->AddStats(std::unique_ptr<const RTCStats>( | 580 signaling_report->AddStats(std::unique_ptr<const RTCStats>( |
581 new RTCTestStats("SignalingThreadStats", timestamp_us))); | 581 new RTCTestStats("SignalingThreadStats", timestamp_us))); |
582 AddPartialResults(signaling_report); | 582 AddPartialResults(signaling_report); |
583 } | 583 } |
584 void ProducePartialResultsOnNetworkThread(int64_t timestamp_us) override { | 584 void ProducePartialResultsOnNetworkThread( |
| 585 int64_t timestamp_us, |
| 586 const Call::Stats& call_stats) override { |
585 EXPECT_TRUE(network_thread_->IsCurrent()); | 587 EXPECT_TRUE(network_thread_->IsCurrent()); |
586 { | 588 { |
587 rtc::CritScope cs(&lock_); | 589 rtc::CritScope cs(&lock_); |
588 EXPECT_FALSE(delivered_report_); | 590 EXPECT_FALSE(delivered_report_); |
589 ++produced_on_network_thread_; | 591 ++produced_on_network_thread_; |
590 } | 592 } |
591 | 593 |
592 rtc::scoped_refptr<RTCStatsReport> network_report = | 594 rtc::scoped_refptr<RTCStatsReport> network_report = |
593 RTCStatsReport::Create(0); | 595 RTCStatsReport::Create(0); |
594 network_report->AddStats(std::unique_ptr<const RTCStats>( | 596 network_report->AddStats(std::unique_ptr<const RTCStats>( |
(...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1256 | 1258 |
1257 // Mock the session to return the desired candidates. | 1259 // Mock the session to return the desired candidates. |
1258 EXPECT_CALL(test_->session(), GetStats(_)).WillRepeatedly(Invoke( | 1260 EXPECT_CALL(test_->session(), GetStats(_)).WillRepeatedly(Invoke( |
1259 [&session_stats](const ChannelNamePairs&) { | 1261 [&session_stats](const ChannelNamePairs&) { |
1260 return std::unique_ptr<SessionStats>(new SessionStats(session_stats)); | 1262 return std::unique_ptr<SessionStats>(new SessionStats(session_stats)); |
1261 })); | 1263 })); |
1262 | 1264 |
1263 // Mock the session to return bandwidth estimation info. These should only | 1265 // Mock the session to return bandwidth estimation info. These should only |
1264 // be used for a selected candidate pair. | 1266 // be used for a selected candidate pair. |
1265 cricket::VideoMediaInfo video_media_info; | 1267 cricket::VideoMediaInfo video_media_info; |
1266 video_media_info.bw_estimations.push_back(cricket::BandwidthEstimationInfo()); | |
1267 video_media_info.bw_estimations[0].available_send_bandwidth = 8888; | |
1268 video_media_info.bw_estimations[0].available_recv_bandwidth = 9999; | |
1269 EXPECT_CALL(*video_media_channel, GetStats(_)) | 1268 EXPECT_CALL(*video_media_channel, GetStats(_)) |
1270 .WillOnce(DoAll(SetArgPointee<0>(video_media_info), Return(true))); | 1269 .WillOnce(DoAll(SetArgPointee<0>(video_media_info), Return(true))); |
1271 EXPECT_CALL(test_->session(), video_channel()) | 1270 EXPECT_CALL(test_->session(), video_channel()) |
1272 .WillRepeatedly(Return(&video_channel)); | 1271 .WillRepeatedly(Return(&video_channel)); |
1273 | 1272 |
1274 rtc::scoped_refptr<const RTCStatsReport> report = GetStatsReport(); | 1273 rtc::scoped_refptr<const RTCStatsReport> report = GetStatsReport(); |
1275 | 1274 |
1276 RTCIceCandidatePairStats expected_pair("RTCIceCandidatePair_" + | 1275 RTCIceCandidatePairStats expected_pair("RTCIceCandidatePair_" + |
1277 local_candidate->id() + "_" + | 1276 local_candidate->id() + "_" + |
1278 remote_candidate->id(), | 1277 remote_candidate->id(), |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1338 EXPECT_EQ( | 1337 EXPECT_EQ( |
1339 expected_pair, | 1338 expected_pair, |
1340 report->Get(expected_pair.id())->cast_to<RTCIceCandidatePairStats>()); | 1339 report->Get(expected_pair.id())->cast_to<RTCIceCandidatePairStats>()); |
1341 EXPECT_TRUE(report->Get(*expected_pair.transport_id)); | 1340 EXPECT_TRUE(report->Get(*expected_pair.transport_id)); |
1342 | 1341 |
1343 // Make pair the current pair, clear bandwidth and "GetStats" again. | 1342 // Make pair the current pair, clear bandwidth and "GetStats" again. |
1344 session_stats.transport_stats["transport"] | 1343 session_stats.transport_stats["transport"] |
1345 .channel_stats[0] | 1344 .channel_stats[0] |
1346 .connection_infos[0] | 1345 .connection_infos[0] |
1347 .best_connection = true; | 1346 .best_connection = true; |
1348 video_media_info.bw_estimations[0].available_send_bandwidth = 0; | |
1349 video_media_info.bw_estimations[0].available_recv_bandwidth = 0; | |
1350 EXPECT_CALL(*video_media_channel, GetStats(_)) | 1347 EXPECT_CALL(*video_media_channel, GetStats(_)) |
1351 .WillOnce(DoAll(SetArgPointee<0>(video_media_info), Return(true))); | 1348 .WillOnce(DoAll(SetArgPointee<0>(video_media_info), Return(true))); |
1352 collector_->ClearCachedStatsReport(); | 1349 collector_->ClearCachedStatsReport(); |
1353 report = GetStatsReport(); | 1350 report = GetStatsReport(); |
1354 // |expected_pair.available_[outgoing/incoming]_bitrate| should still be | 1351 // |expected_pair.available_[outgoing/incoming]_bitrate| should still be |
1355 // undefined because bandwidth is not set. | 1352 // undefined because bandwidth is not set. |
1356 ASSERT_TRUE(report->Get(expected_pair.id())); | 1353 ASSERT_TRUE(report->Get(expected_pair.id())); |
1357 EXPECT_EQ( | 1354 EXPECT_EQ( |
1358 expected_pair, | 1355 expected_pair, |
1359 report->Get(expected_pair.id())->cast_to<RTCIceCandidatePairStats>()); | 1356 report->Get(expected_pair.id())->cast_to<RTCIceCandidatePairStats>()); |
1360 EXPECT_TRUE(report->Get(*expected_pair.transport_id)); | 1357 EXPECT_TRUE(report->Get(*expected_pair.transport_id)); |
1361 | 1358 |
1362 // Set bandwidth and "GetStats" again. | 1359 // Set bandwidth and "GetStats" again. |
1363 video_media_info.bw_estimations[0].available_send_bandwidth = 888; | 1360 webrtc::Call::Stats call_stats; |
1364 video_media_info.bw_estimations[0].available_recv_bandwidth = 999; | 1361 const int kSendBandwidth = 888; |
| 1362 call_stats.send_bandwidth_bps = kSendBandwidth; |
| 1363 const int kRecvBandwidth = 999; |
| 1364 call_stats.recv_bandwidth_bps = kRecvBandwidth; |
| 1365 EXPECT_CALL(test_->session(), GetCallStats()) |
| 1366 .WillRepeatedly(Return(call_stats)); |
1365 EXPECT_CALL(*video_media_channel, GetStats(_)) | 1367 EXPECT_CALL(*video_media_channel, GetStats(_)) |
1366 .WillOnce(DoAll(SetArgPointee<0>(video_media_info), Return(true))); | 1368 .WillOnce(DoAll(SetArgPointee<0>(video_media_info), Return(true))); |
1367 collector_->ClearCachedStatsReport(); | 1369 collector_->ClearCachedStatsReport(); |
1368 report = GetStatsReport(); | 1370 report = GetStatsReport(); |
1369 expected_pair.available_outgoing_bitrate = 888; | 1371 expected_pair.available_outgoing_bitrate = kSendBandwidth; |
1370 expected_pair.available_incoming_bitrate = 999; | 1372 expected_pair.available_incoming_bitrate = kRecvBandwidth; |
1371 ASSERT_TRUE(report->Get(expected_pair.id())); | 1373 ASSERT_TRUE(report->Get(expected_pair.id())); |
1372 EXPECT_EQ( | 1374 EXPECT_EQ( |
1373 expected_pair, | 1375 expected_pair, |
1374 report->Get(expected_pair.id())->cast_to<RTCIceCandidatePairStats>()); | 1376 report->Get(expected_pair.id())->cast_to<RTCIceCandidatePairStats>()); |
1375 EXPECT_TRUE(report->Get(*expected_pair.transport_id)); | 1377 EXPECT_TRUE(report->Get(*expected_pair.transport_id)); |
1376 | 1378 |
1377 RTCLocalIceCandidateStats expected_local_candidate( | 1379 RTCLocalIceCandidateStats expected_local_candidate( |
1378 *expected_pair.local_candidate_id, report->timestamp_us()); | 1380 *expected_pair.local_candidate_id, report->timestamp_us()); |
1379 expected_local_candidate.transport_id = *expected_pair.transport_id; | 1381 expected_local_candidate.transport_id = *expected_pair.transport_id; |
1380 expected_local_candidate.ip = "42.42.42.42"; | 1382 expected_local_candidate.ip = "42.42.42.42"; |
(...skipping 932 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2313 rtc::scoped_refptr<FakeRTCStatsCollector> collector_; | 2315 rtc::scoped_refptr<FakeRTCStatsCollector> collector_; |
2314 }; | 2316 }; |
2315 | 2317 |
2316 TEST_F(RTCStatsCollectorTestWithFakeCollector, ThreadUsageAndResultsMerging) { | 2318 TEST_F(RTCStatsCollectorTestWithFakeCollector, ThreadUsageAndResultsMerging) { |
2317 collector_->VerifyThreadUsageAndResultsMerging(); | 2319 collector_->VerifyThreadUsageAndResultsMerging(); |
2318 } | 2320 } |
2319 | 2321 |
2320 } // namespace | 2322 } // namespace |
2321 | 2323 |
2322 } // namespace webrtc | 2324 } // namespace webrtc |
OLD | NEW |