Ensure that data channel transport stats are included
The RTCStatsCollector was only iterating through RtpTransceivers
in order to find the active transports for which to generate stats.
But for data channel only connections, there were no
RtpTransceivers so no transports were being identified.
This CL changes the stats collector to include the transport names
of the SCTP and RTP data channel if active.
Bug: chromium:826972
Change-Id: I762b253b3bbf0f0d7861bc281b8908decbb9b0d9
Reviewed-on: https://webrtc-review.googlesource.com/65788
Reviewed-by: Taylor Brandstetter <deadbeef@webrtc.org>
Commit-Queue: Steve Anton <steveanton@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#22697}
diff --git a/pc/peerconnection_integrationtest.cc b/pc/peerconnection_integrationtest.cc
index 6dbf320..a249d79 100644
--- a/pc/peerconnection_integrationtest.cc
+++ b/pc/peerconnection_integrationtest.cc
@@ -86,6 +86,7 @@
using webrtc::PeerConnectionFactory;
using webrtc::PeerConnectionProxy;
using webrtc::RTCErrorType;
+using webrtc::RTCTransportStats;
using webrtc::RtpSenderInterface;
using webrtc::RtpReceiverInterface;
using webrtc::RtpSenderInterface;
@@ -4076,6 +4077,27 @@
EXPECT_EQ(sent_packets_a, sent_packets_b);
}
+// Test that transport stats are generated by the RTCStatsCollector for a
+// connection that only involves data channels. This is a regression test for
+// crbug.com/826972.
+#ifdef HAVE_SCTP
+TEST_P(PeerConnectionIntegrationTest,
+ TransportStatsReportedForDataChannelOnlyConnection) {
+ ASSERT_TRUE(CreatePeerConnectionWrappers());
+ ConnectFakeSignaling();
+ caller()->CreateDataChannel();
+
+ caller()->CreateAndSetAndSignalOffer();
+ ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_TRUE_WAIT(callee()->data_channel(), kDefaultTimeout);
+
+ auto caller_report = caller()->NewGetStats();
+ EXPECT_EQ(1u, caller_report->GetStatsOfType<RTCTransportStats>().size());
+ auto callee_report = callee()->NewGetStats();
+ EXPECT_EQ(1u, callee_report->GetStatsOfType<RTCTransportStats>().size());
+}
+#endif // HAVE_SCTP
+
INSTANTIATE_TEST_CASE_P(PeerConnectionIntegrationTest,
PeerConnectionIntegrationTest,
Values(SdpSemantics::kPlanB,