Make RTCStats IDs more concise.
Ultimately, IDs should be random according to spec[1], so we shouldn't rely on the ID to convey easily readable information. By making the IDs shorter we reduce the overhead of string copies and make report dumps a little bit smaller. Drive-by: Add "DEPRECATED_" prefic to the RTCMediaStreamStats ID. [1] https://w3c.github.io/webrtc-pc/#dom-rtcstats-id # Examples of IDs before and after this CL # RTCDataChannel_3 -> D3 RTCPeerConnection -> P RTCTransport_0_1 -> T01 RTCCodec_RTCTransport_0_1_100_minptime=10;useinbandfec=1 -> CIT01_100_minptime=10;useinbandfec=1 RTCInboundRTPAudioStream_6666 -> IA6666 RTCAudioSource_1 -> SA1 RTCOutboundRTPAudioStream_2943129392 -> OA2943129392 RTCRemoteInboundRtpAudioStream_3541280085 -> RIA3541280085 RTCIceCandidate_6cWRqicY -> I6cWRqicY RTCIceCandidatePair_6cWRqicY_haEcM2xD -> CP6cWRqicY_haEcM2xD RTCCertificate_FD1:BC:58:90:DF:E8:40:58:8D:04:91:44:93:4E:6C:52:9E:F0:14:98:AA:67:7B:8B:C8:30:C8:31:D0:84:1B:BF -> CFD1:BC:58:90:DF:E8:40:58:8D:04:91:44:93:4E:6C:52:9E:F0:14:98:AA:67:7B:8B:C8:30:C8:31:D0:84:1B:BF DEPRECATED_RTCMediaStreamTrack_receiver_3 -> DEPRECATED_TI3 RTCMediaStream_45a6e766-5d1a-40f9-a55c-ea8fdefcde49 -> DEPRECATED_S45a6e766-5d1a-40f9-a55c-ea8fdefcde49 Bug: webrtc:14416, webrtc:14419 Change-Id: I11f0a8b8354203fea1df1093d8864a6d47ee71e6 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/273709 Reviewed-by: Taylor Brandstetter <deadbeef@webrtc.org> Commit-Queue: Henrik Boström <hbos@webrtc.org> Cr-Commit-Position: refs/heads/main@{#37992}
This commit is contained in:
parent
a5d80a7646
commit
8dfc90f947
@ -65,22 +65,25 @@ namespace webrtc {
|
||||
|
||||
namespace {
|
||||
|
||||
const char kDirectionInbound = 'I';
|
||||
const char kDirectionOutbound = 'O';
|
||||
|
||||
// TODO(https://crbug.com/webrtc/10656): Consider making IDs less predictable.
|
||||
std::string RTCCertificateIDFromFingerprint(const std::string& fingerprint) {
|
||||
return "RTCCertificate_" + fingerprint;
|
||||
return "CF" + fingerprint;
|
||||
}
|
||||
|
||||
// `direction` is either kDirectionInbound or kDirectionOutbound.
|
||||
std::string RTCCodecStatsIDFromTransportAndCodecParameters(
|
||||
const char direction,
|
||||
const std::string& transport_id,
|
||||
bool inbound,
|
||||
const RtpCodecParameters& codec_params) {
|
||||
char buf[1024];
|
||||
rtc::SimpleStringBuilder sb(buf);
|
||||
sb << "RTCCodec_" << transport_id << (inbound ? "_Recv_" : "_Send_")
|
||||
<< codec_params.payload_type;
|
||||
sb << 'C' << direction << transport_id << '_' << codec_params.payload_type;
|
||||
rtc::StringBuilder fmtp;
|
||||
if (WriteFmtpParameters(codec_params.parameters, &fmtp)) {
|
||||
sb << "_" << fmtp.Release();
|
||||
sb << '_' << fmtp.Release();
|
||||
}
|
||||
return sb.str();
|
||||
}
|
||||
@ -89,20 +92,17 @@ std::string RTCIceCandidatePairStatsIDFromConnectionInfo(
|
||||
const cricket::ConnectionInfo& info) {
|
||||
char buf[4096];
|
||||
rtc::SimpleStringBuilder sb(buf);
|
||||
sb << "RTCIceCandidatePair_" << info.local_candidate.id() << "_"
|
||||
<< info.remote_candidate.id();
|
||||
sb << "CP" << info.local_candidate.id() << "_" << info.remote_candidate.id();
|
||||
return sb.str();
|
||||
}
|
||||
|
||||
const char kSender[] = "sender";
|
||||
const char kReceiver[] = "receiver";
|
||||
|
||||
// `direction` is either kDirectionInbound or kDirectionOutbound.
|
||||
std::string RTCMediaStreamTrackStatsIDFromDirectionAndAttachment(
|
||||
const char* direction,
|
||||
const char direction,
|
||||
int attachment_id) {
|
||||
char buf[1024];
|
||||
rtc::SimpleStringBuilder sb(buf);
|
||||
sb << "DEPRECATED_RTCMediaStreamTrack_" << direction << "_" << attachment_id;
|
||||
sb << "DEPRECATED_T" << direction << attachment_id;
|
||||
return sb.str();
|
||||
}
|
||||
|
||||
@ -111,7 +111,7 @@ std::string RTCTransportStatsIDFromTransportChannel(
|
||||
int channel_component) {
|
||||
char buf[1024];
|
||||
rtc::SimpleStringBuilder sb(buf);
|
||||
sb << "RTCTransport_" << transport_name << "_" << channel_component;
|
||||
sb << 'T' << transport_name << channel_component;
|
||||
return sb.str();
|
||||
}
|
||||
|
||||
@ -119,9 +119,7 @@ std::string RTCInboundRTPStreamStatsIDFromSSRC(cricket::MediaType media_type,
|
||||
uint32_t ssrc) {
|
||||
char buf[1024];
|
||||
rtc::SimpleStringBuilder sb(buf);
|
||||
sb << "RTCInboundRTP"
|
||||
<< (media_type == cricket::MEDIA_TYPE_AUDIO ? "Audio" : "Video")
|
||||
<< "Stream_" << ssrc;
|
||||
sb << 'I' << (media_type == cricket::MEDIA_TYPE_AUDIO ? 'A' : 'V') << ssrc;
|
||||
return sb.str();
|
||||
}
|
||||
|
||||
@ -129,9 +127,7 @@ std::string RTCOutboundRTPStreamStatsIDFromSSRC(cricket::MediaType media_type,
|
||||
uint32_t ssrc) {
|
||||
char buf[1024];
|
||||
rtc::SimpleStringBuilder sb(buf);
|
||||
sb << "RTCOutboundRTP"
|
||||
<< (media_type == cricket::MEDIA_TYPE_AUDIO ? "Audio" : "Video")
|
||||
<< "Stream_" << ssrc;
|
||||
sb << 'O' << (media_type == cricket::MEDIA_TYPE_AUDIO ? 'A' : 'V') << ssrc;
|
||||
return sb.str();
|
||||
}
|
||||
|
||||
@ -140,9 +136,8 @@ std::string RTCRemoteInboundRtpStreamStatsIdFromSourceSsrc(
|
||||
uint32_t source_ssrc) {
|
||||
char buf[1024];
|
||||
rtc::SimpleStringBuilder sb(buf);
|
||||
sb << "RTCRemoteInboundRtp"
|
||||
<< (media_type == cricket::MEDIA_TYPE_AUDIO ? "Audio" : "Video")
|
||||
<< "Stream_" << source_ssrc;
|
||||
sb << "RI" << (media_type == cricket::MEDIA_TYPE_AUDIO ? 'A' : 'V')
|
||||
<< source_ssrc;
|
||||
return sb.str();
|
||||
}
|
||||
|
||||
@ -151,9 +146,8 @@ std::string RTCRemoteOutboundRTPStreamStatsIDFromSSRC(
|
||||
uint32_t source_ssrc) {
|
||||
char buf[1024];
|
||||
rtc::SimpleStringBuilder sb(buf);
|
||||
sb << "RTCRemoteOutboundRTP"
|
||||
<< (media_type == cricket::MEDIA_TYPE_AUDIO ? "Audio" : "Video")
|
||||
<< "Stream_" << source_ssrc;
|
||||
sb << "RO" << (media_type == cricket::MEDIA_TYPE_AUDIO ? 'A' : 'V')
|
||||
<< source_ssrc;
|
||||
return sb.str();
|
||||
}
|
||||
|
||||
@ -162,8 +156,8 @@ std::string RTCMediaSourceStatsIDFromKindAndAttachment(
|
||||
int attachment_id) {
|
||||
char buf[1024];
|
||||
rtc::SimpleStringBuilder sb(buf);
|
||||
sb << "RTC" << (media_type == cricket::MEDIA_TYPE_AUDIO ? "Audio" : "Video")
|
||||
<< "Source_" << attachment_id;
|
||||
sb << 'S' << (media_type == cricket::MEDIA_TYPE_AUDIO ? 'A' : 'V')
|
||||
<< attachment_id;
|
||||
return sb.str();
|
||||
}
|
||||
|
||||
@ -359,8 +353,8 @@ double DoubleAudioLevelFromIntAudioLevel(int audio_level) {
|
||||
|
||||
std::unique_ptr<RTCCodecStats> CodecStatsFromRtpCodecParameters(
|
||||
uint64_t timestamp_us,
|
||||
const char direction,
|
||||
const std::string& transport_id,
|
||||
bool inbound,
|
||||
const RtpCodecParameters& codec_params) {
|
||||
RTC_DCHECK_GE(codec_params.payload_type, 0);
|
||||
RTC_DCHECK_LE(codec_params.payload_type, 127);
|
||||
@ -368,7 +362,7 @@ std::unique_ptr<RTCCodecStats> CodecStatsFromRtpCodecParameters(
|
||||
uint32_t payload_type = static_cast<uint32_t>(codec_params.payload_type);
|
||||
std::unique_ptr<RTCCodecStats> codec_stats(
|
||||
new RTCCodecStats(RTCCodecStatsIDFromTransportAndCodecParameters(
|
||||
transport_id, inbound, codec_params),
|
||||
direction, transport_id, codec_params),
|
||||
timestamp_us));
|
||||
codec_stats->payload_type = payload_type;
|
||||
codec_stats->mime_type = codec_params.mime_type();
|
||||
@ -447,7 +441,7 @@ std::unique_ptr<RTCInboundRTPStreamStats> CreateInboundAudioStreamStats(
|
||||
RTC_DCHECK(codec_param_it != voice_media_info.receive_codecs.end());
|
||||
if (codec_param_it != voice_media_info.receive_codecs.end()) {
|
||||
inbound_audio->codec_id = RTCCodecStatsIDFromTransportAndCodecParameters(
|
||||
transport_id, /*inbound=*/true, codec_param_it->second);
|
||||
kDirectionInbound, transport_id, codec_param_it->second);
|
||||
}
|
||||
}
|
||||
inbound_audio->jitter = static_cast<double>(voice_receiver_info.jitter_ms) /
|
||||
@ -557,7 +551,7 @@ void SetInboundRTPStreamStatsFromVideoReceiverInfo(
|
||||
RTC_DCHECK(codec_param_it != video_media_info.receive_codecs.end());
|
||||
if (codec_param_it != video_media_info.receive_codecs.end()) {
|
||||
inbound_video->codec_id = RTCCodecStatsIDFromTransportAndCodecParameters(
|
||||
transport_id, /*inbound=*/true, codec_param_it->second);
|
||||
kDirectionInbound, transport_id, codec_param_it->second);
|
||||
}
|
||||
}
|
||||
inbound_video->jitter = static_cast<double>(video_receiver_info.jitter_ms) /
|
||||
@ -662,7 +656,7 @@ void SetOutboundRTPStreamStatsFromVoiceSenderInfo(
|
||||
RTC_DCHECK(codec_param_it != voice_media_info.send_codecs.end());
|
||||
if (codec_param_it != voice_media_info.send_codecs.end()) {
|
||||
outbound_audio->codec_id = RTCCodecStatsIDFromTransportAndCodecParameters(
|
||||
transport_id, /*inbound=*/false, codec_param_it->second);
|
||||
kDirectionOutbound, transport_id, codec_param_it->second);
|
||||
}
|
||||
}
|
||||
// `fir_count`, `pli_count` and `sli_count` are only valid for video and are
|
||||
@ -687,7 +681,7 @@ void SetOutboundRTPStreamStatsFromVideoSenderInfo(
|
||||
RTC_DCHECK(codec_param_it != video_media_info.send_codecs.end());
|
||||
if (codec_param_it != video_media_info.send_codecs.end()) {
|
||||
outbound_video->codec_id = RTCCodecStatsIDFromTransportAndCodecParameters(
|
||||
transport_id, /*inbound=*/false, codec_param_it->second);
|
||||
kDirectionOutbound, transport_id, codec_param_it->second);
|
||||
}
|
||||
}
|
||||
outbound_video->fir_count =
|
||||
@ -847,7 +841,7 @@ const std::string& ProduceIceCandidateStats(int64_t timestamp_us,
|
||||
bool is_local,
|
||||
const std::string& transport_id,
|
||||
RTCStatsReport* report) {
|
||||
const std::string& id = "RTCIceCandidate_" + candidate.id();
|
||||
const std::string& id = "I" + candidate.id();
|
||||
const RTCStats* stats = report->Get(id);
|
||||
if (!stats) {
|
||||
std::unique_ptr<RTCIceCandidateStats> candidate_stats;
|
||||
@ -927,8 +921,8 @@ ProduceMediaStreamTrackStatsFromVoiceSenderInfo(
|
||||
int attachment_id) {
|
||||
std::unique_ptr<RTCMediaStreamTrackStats> audio_track_stats(
|
||||
new RTCMediaStreamTrackStats(
|
||||
RTCMediaStreamTrackStatsIDFromDirectionAndAttachment(kSender,
|
||||
attachment_id),
|
||||
RTCMediaStreamTrackStatsIDFromDirectionAndAttachment(
|
||||
kDirectionOutbound, attachment_id),
|
||||
timestamp_us, RTCMediaStreamTrackKind::kAudio));
|
||||
SetMediaStreamTrackStatsFromMediaStreamTrackInterface(
|
||||
audio_track, audio_track_stats.get());
|
||||
@ -962,8 +956,8 @@ ProduceMediaStreamTrackStatsFromVoiceReceiverInfo(
|
||||
// an attachment identifier.
|
||||
std::unique_ptr<RTCMediaStreamTrackStats> audio_track_stats(
|
||||
new RTCMediaStreamTrackStats(
|
||||
RTCMediaStreamTrackStatsIDFromDirectionAndAttachment(kReceiver,
|
||||
attachment_id),
|
||||
RTCMediaStreamTrackStatsIDFromDirectionAndAttachment(
|
||||
kDirectionInbound, attachment_id),
|
||||
timestamp_us, RTCMediaStreamTrackKind::kAudio));
|
||||
SetMediaStreamTrackStatsFromMediaStreamTrackInterface(
|
||||
audio_track, audio_track_stats.get());
|
||||
@ -1016,8 +1010,8 @@ ProduceMediaStreamTrackStatsFromVideoSenderInfo(
|
||||
int attachment_id) {
|
||||
std::unique_ptr<RTCMediaStreamTrackStats> video_track_stats(
|
||||
new RTCMediaStreamTrackStats(
|
||||
RTCMediaStreamTrackStatsIDFromDirectionAndAttachment(kSender,
|
||||
attachment_id),
|
||||
RTCMediaStreamTrackStatsIDFromDirectionAndAttachment(
|
||||
kDirectionOutbound, attachment_id),
|
||||
timestamp_us, RTCMediaStreamTrackKind::kVideo));
|
||||
SetMediaStreamTrackStatsFromMediaStreamTrackInterface(
|
||||
video_track, video_track_stats.get());
|
||||
@ -1045,9 +1039,8 @@ ProduceMediaStreamTrackStatsFromVideoReceiverInfo(
|
||||
int attachment_id) {
|
||||
std::unique_ptr<RTCMediaStreamTrackStats> video_track_stats(
|
||||
new RTCMediaStreamTrackStats(
|
||||
RTCMediaStreamTrackStatsIDFromDirectionAndAttachment(kReceiver,
|
||||
|
||||
attachment_id),
|
||||
RTCMediaStreamTrackStatsIDFromDirectionAndAttachment(
|
||||
kDirectionInbound, attachment_id),
|
||||
timestamp_us, RTCMediaStreamTrackKind::kVideo));
|
||||
SetMediaStreamTrackStatsFromMediaStreamTrackInterface(
|
||||
video_track, video_track_stats.get());
|
||||
@ -1213,7 +1206,7 @@ rtc::scoped_refptr<RTCStatsReport> CreateReportFilteredBySelector(
|
||||
// that reference the track attachment stats for the sender instead.
|
||||
std::string track_id =
|
||||
RTCMediaStreamTrackStatsIDFromDirectionAndAttachment(
|
||||
kSender, sender_selector->AttachmentId());
|
||||
kDirectionOutbound, sender_selector->AttachmentId());
|
||||
for (const auto& stats : *report) {
|
||||
if (stats.type() != RTCOutboundRTPStreamStats::kType)
|
||||
continue;
|
||||
@ -1233,7 +1226,7 @@ rtc::scoped_refptr<RTCStatsReport> CreateReportFilteredBySelector(
|
||||
// that reference the track attachment stats for the receiver instead.
|
||||
std::string track_id =
|
||||
RTCMediaStreamTrackStatsIDFromDirectionAndAttachment(
|
||||
kReceiver, receiver_selector->AttachmentId());
|
||||
kDirectionInbound, receiver_selector->AttachmentId());
|
||||
for (const auto& stats : *report) {
|
||||
if (stats.type() != RTCInboundRTPStreamStats::kType)
|
||||
continue;
|
||||
@ -1618,7 +1611,7 @@ void RTCStatsCollector::ProduceCodecStats_n(
|
||||
continue; // (PT,FMTP) already seen.
|
||||
}
|
||||
report->AddStats(CodecStatsFromRtpCodecParameters(
|
||||
timestamp_us, transport_id, true, codec));
|
||||
timestamp_us, kDirectionInbound, transport_id, codec));
|
||||
}
|
||||
// Outbound
|
||||
for (const auto& pair :
|
||||
@ -1631,7 +1624,7 @@ void RTCStatsCollector::ProduceCodecStats_n(
|
||||
continue; // (PT,FMTP) already seen.
|
||||
}
|
||||
report->AddStats(CodecStatsFromRtpCodecParameters(
|
||||
timestamp_us, transport_id, false, codec));
|
||||
timestamp_us, kDirectionOutbound, transport_id, codec));
|
||||
}
|
||||
}
|
||||
// Video
|
||||
@ -1647,7 +1640,7 @@ void RTCStatsCollector::ProduceCodecStats_n(
|
||||
continue; // (PT,FMTP) already seen.
|
||||
}
|
||||
report->AddStats(CodecStatsFromRtpCodecParameters(
|
||||
timestamp_us, transport_id, true, codec));
|
||||
timestamp_us, kDirectionInbound, transport_id, codec));
|
||||
}
|
||||
// Outbound
|
||||
for (const auto& pair :
|
||||
@ -1660,7 +1653,7 @@ void RTCStatsCollector::ProduceCodecStats_n(
|
||||
continue; // (PT,FMTP) already seen.
|
||||
}
|
||||
report->AddStats(CodecStatsFromRtpCodecParameters(
|
||||
timestamp_us, transport_id, false, codec));
|
||||
timestamp_us, kDirectionOutbound, transport_id, codec));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1674,8 +1667,7 @@ void RTCStatsCollector::ProduceDataChannelStats_s(
|
||||
std::vector<DataChannelStats> data_stats = pc_->GetDataChannelStats();
|
||||
for (const auto& stats : data_stats) {
|
||||
std::unique_ptr<RTCDataChannelStats> data_channel_stats(
|
||||
new RTCDataChannelStats(
|
||||
"RTCDataChannel_" + rtc::ToString(stats.internal_id),
|
||||
new RTCDataChannelStats("D" + rtc::ToString(stats.internal_id),
|
||||
timestamp_us));
|
||||
data_channel_stats->label = std::move(stats.label);
|
||||
data_channel_stats->protocol = std::move(stats.protocol);
|
||||
@ -1805,7 +1797,7 @@ void RTCStatsCollector::ProduceMediaStreamStats_s(
|
||||
for (const auto& sender : stats.transceiver->senders()) {
|
||||
std::string track_id =
|
||||
RTCMediaStreamTrackStatsIDFromDirectionAndAttachment(
|
||||
kSender, sender->internal()->AttachmentId());
|
||||
kDirectionOutbound, sender->internal()->AttachmentId());
|
||||
for (auto& stream_id : sender->stream_ids()) {
|
||||
track_ids[stream_id].push_back(track_id);
|
||||
}
|
||||
@ -1813,7 +1805,7 @@ void RTCStatsCollector::ProduceMediaStreamStats_s(
|
||||
for (const auto& receiver : stats.transceiver->receivers()) {
|
||||
std::string track_id =
|
||||
RTCMediaStreamTrackStatsIDFromDirectionAndAttachment(
|
||||
kReceiver, receiver->internal()->AttachmentId());
|
||||
kDirectionInbound, receiver->internal()->AttachmentId());
|
||||
for (auto& stream : receiver->streams()) {
|
||||
track_ids[stream->id()].push_back(track_id);
|
||||
}
|
||||
@ -1823,7 +1815,7 @@ void RTCStatsCollector::ProduceMediaStreamStats_s(
|
||||
// Build stats for each stream ID known.
|
||||
for (auto& it : track_ids) {
|
||||
std::unique_ptr<RTCMediaStreamStats> stream_stats(
|
||||
new RTCMediaStreamStats("RTCMediaStream_" + it.first, timestamp_us));
|
||||
new RTCMediaStreamStats("DEPRECATED_S" + it.first, timestamp_us));
|
||||
stream_stats->stream_identifier = it.first;
|
||||
stream_stats->track_ids = it.second;
|
||||
report->AddStats(std::move(stream_stats));
|
||||
@ -1961,7 +1953,7 @@ void RTCStatsCollector::ProducePeerConnectionStats_s(
|
||||
rtc::Thread::ScopedDisallowBlockingCalls no_blocking_calls;
|
||||
|
||||
std::unique_ptr<RTCPeerConnectionStats> stats(
|
||||
new RTCPeerConnectionStats("RTCPeerConnection", timestamp_us));
|
||||
new RTCPeerConnectionStats("P", timestamp_us));
|
||||
stats->data_channels_opened = internal_record_.data_channels_opened;
|
||||
stats->data_channels_closed = internal_record_.data_channels_closed;
|
||||
report->AddStats(std::move(stats));
|
||||
@ -2016,7 +2008,7 @@ void RTCStatsCollector::ProduceAudioRTPStreamStats_n(
|
||||
if (audio_track) {
|
||||
inbound_audio->track_id =
|
||||
RTCMediaStreamTrackStatsIDFromDirectionAndAttachment(
|
||||
kReceiver, stats.track_media_info_map
|
||||
kDirectionInbound, stats.track_media_info_map
|
||||
.GetAttachmentIdByTrack(audio_track.get())
|
||||
.value());
|
||||
inbound_audio->track_identifier = audio_track->id();
|
||||
@ -2054,8 +2046,8 @@ void RTCStatsCollector::ProduceAudioRTPStreamStats_n(
|
||||
stats.track_media_info_map.GetAttachmentIdByTrack(audio_track.get())
|
||||
.value();
|
||||
outbound_audio->track_id =
|
||||
RTCMediaStreamTrackStatsIDFromDirectionAndAttachment(kSender,
|
||||
attachment_id);
|
||||
RTCMediaStreamTrackStatsIDFromDirectionAndAttachment(
|
||||
kDirectionOutbound, attachment_id);
|
||||
outbound_audio->media_source_id =
|
||||
RTCMediaSourceStatsIDFromKindAndAttachment(cricket::MEDIA_TYPE_AUDIO,
|
||||
attachment_id);
|
||||
@ -2111,7 +2103,7 @@ void RTCStatsCollector::ProduceVideoRTPStreamStats_n(
|
||||
if (video_track) {
|
||||
inbound_video->track_id =
|
||||
RTCMediaStreamTrackStatsIDFromDirectionAndAttachment(
|
||||
kReceiver, stats.track_media_info_map
|
||||
kDirectionInbound, stats.track_media_info_map
|
||||
.GetAttachmentIdByTrack(video_track.get())
|
||||
.value());
|
||||
inbound_video->track_identifier = video_track->id();
|
||||
@ -2139,8 +2131,8 @@ void RTCStatsCollector::ProduceVideoRTPStreamStats_n(
|
||||
stats.track_media_info_map.GetAttachmentIdByTrack(video_track.get())
|
||||
.value();
|
||||
outbound_video->track_id =
|
||||
RTCMediaStreamTrackStatsIDFromDirectionAndAttachment(kSender,
|
||||
attachment_id);
|
||||
RTCMediaStreamTrackStatsIDFromDirectionAndAttachment(
|
||||
kDirectionOutbound, attachment_id);
|
||||
outbound_video->media_source_id =
|
||||
RTCMediaSourceStatsIDFromKindAndAttachment(cricket::MEDIA_TYPE_VIDEO,
|
||||
attachment_id);
|
||||
|
||||
@ -662,13 +662,13 @@ class RTCStatsCollectorTest : public ::testing::Test {
|
||||
const CertificateInfo& certinfo) {
|
||||
for (size_t i = 0; i < certinfo.fingerprints.size(); ++i) {
|
||||
RTCCertificateStats expected_certificate_stats(
|
||||
"RTCCertificate_" + certinfo.fingerprints[i], report->timestamp_us());
|
||||
"CF" + certinfo.fingerprints[i], report->timestamp_us());
|
||||
expected_certificate_stats.fingerprint = certinfo.fingerprints[i];
|
||||
expected_certificate_stats.fingerprint_algorithm = "sha-1";
|
||||
expected_certificate_stats.base64_certificate = certinfo.pems[i];
|
||||
if (i + 1 < certinfo.fingerprints.size()) {
|
||||
expected_certificate_stats.issuer_certificate_id =
|
||||
"RTCCertificate_" + certinfo.fingerprints[i + 1];
|
||||
"CF" + certinfo.fingerprints[i + 1];
|
||||
}
|
||||
ASSERT_TRUE(report->Get(expected_certificate_stats.id()));
|
||||
EXPECT_EQ(expected_certificate_stats,
|
||||
@ -705,7 +705,7 @@ class RTCStatsCollectorTest : public ::testing::Test {
|
||||
ExampleStatsGraph graph;
|
||||
|
||||
// codec (send)
|
||||
graph.send_codec_id = "RTCCodec_RTCTransport_TransportName_1_Send_1";
|
||||
graph.send_codec_id = "COTTransportName1_1";
|
||||
cricket::VideoMediaInfo video_media_info;
|
||||
RtpCodecParameters send_codec;
|
||||
send_codec.payload_type = 1;
|
||||
@ -713,14 +713,14 @@ class RTCStatsCollectorTest : public ::testing::Test {
|
||||
video_media_info.send_codecs.insert(
|
||||
std::make_pair(send_codec.payload_type, send_codec));
|
||||
// codec (recv)
|
||||
graph.recv_codec_id = "RTCCodec_RTCTransport_TransportName_1_Recv_2";
|
||||
graph.recv_codec_id = "CITTransportName1_2";
|
||||
RtpCodecParameters recv_codec;
|
||||
recv_codec.payload_type = 2;
|
||||
recv_codec.clock_rate = 0;
|
||||
video_media_info.receive_codecs.insert(
|
||||
std::make_pair(recv_codec.payload_type, recv_codec));
|
||||
// outbound-rtp
|
||||
graph.outbound_rtp_id = "RTCOutboundRTPVideoStream_3";
|
||||
graph.outbound_rtp_id = "OV3";
|
||||
video_media_info.senders.push_back(cricket::VideoSenderInfo());
|
||||
video_media_info.senders[0].local_stats.push_back(
|
||||
cricket::SsrcSenderInfo());
|
||||
@ -728,31 +728,30 @@ class RTCStatsCollectorTest : public ::testing::Test {
|
||||
video_media_info.senders[0].codec_payload_type = send_codec.payload_type;
|
||||
video_media_info.aggregated_senders.push_back(video_media_info.senders[0]);
|
||||
// inbound-rtp
|
||||
graph.inbound_rtp_id = "RTCInboundRTPVideoStream_4";
|
||||
graph.inbound_rtp_id = "IV4";
|
||||
video_media_info.receivers.push_back(cricket::VideoReceiverInfo());
|
||||
video_media_info.receivers[0].local_stats.push_back(
|
||||
cricket::SsrcReceiverInfo());
|
||||
video_media_info.receivers[0].local_stats[0].ssrc = 4;
|
||||
video_media_info.receivers[0].codec_payload_type = recv_codec.payload_type;
|
||||
// transport
|
||||
graph.transport_id = "RTCTransport_TransportName_1";
|
||||
graph.transport_id = "TTransportName1";
|
||||
pc_->AddVideoChannel("VideoMid", "TransportName", video_media_info);
|
||||
// track (sender)
|
||||
graph.sender = stats_->SetupLocalTrackAndSender(
|
||||
cricket::MEDIA_TYPE_VIDEO, "LocalVideoTrackID", 3, false, 50);
|
||||
graph.sender_track_id = "DEPRECATED_RTCMediaStreamTrack_sender_" +
|
||||
rtc::ToString(graph.sender->AttachmentId());
|
||||
graph.sender_track_id =
|
||||
"DEPRECATED_TO" + rtc::ToString(graph.sender->AttachmentId());
|
||||
// track (receiver) and stream (remote stream)
|
||||
graph.receiver = stats_->SetupRemoteTrackAndReceiver(
|
||||
cricket::MEDIA_TYPE_VIDEO, "RemoteVideoTrackID", "RemoteStreamId", 4);
|
||||
graph.receiver_track_id = "DEPRECATED_RTCMediaStreamTrack_receiver_" +
|
||||
rtc::ToString(graph.receiver->AttachmentId());
|
||||
graph.remote_stream_id = "RTCMediaStream_RemoteStreamId";
|
||||
graph.receiver_track_id =
|
||||
"DEPRECATED_TI" + rtc::ToString(graph.receiver->AttachmentId());
|
||||
graph.remote_stream_id = "DEPRECATED_SRemoteStreamId";
|
||||
// peer-connection
|
||||
graph.peer_connection_id = "RTCPeerConnection";
|
||||
graph.peer_connection_id = "P";
|
||||
// media-source (kind: video)
|
||||
graph.media_source_id =
|
||||
"RTCVideoSource_" + rtc::ToString(graph.sender->AttachmentId());
|
||||
graph.media_source_id = "SV" + rtc::ToString(graph.sender->AttachmentId());
|
||||
|
||||
// Expected stats graph:
|
||||
//
|
||||
@ -806,7 +805,7 @@ class RTCStatsCollectorTest : public ::testing::Test {
|
||||
ExampleStatsGraph graph;
|
||||
|
||||
// codec (send)
|
||||
graph.send_codec_id = "RTCCodec_RTCTransport_TransportName_1_Send_1";
|
||||
graph.send_codec_id = "COTTransportName1_1";
|
||||
cricket::VoiceMediaInfo media_info;
|
||||
RtpCodecParameters send_codec;
|
||||
send_codec.payload_type = 1;
|
||||
@ -814,27 +813,27 @@ class RTCStatsCollectorTest : public ::testing::Test {
|
||||
media_info.send_codecs.insert(
|
||||
std::make_pair(send_codec.payload_type, send_codec));
|
||||
// codec (recv)
|
||||
graph.recv_codec_id = "RTCCodec_RTCTransport_TransportName_1_Recv_2";
|
||||
graph.recv_codec_id = "CITTransportName1_2";
|
||||
RtpCodecParameters recv_codec;
|
||||
recv_codec.payload_type = 2;
|
||||
recv_codec.clock_rate = 0;
|
||||
media_info.receive_codecs.insert(
|
||||
std::make_pair(recv_codec.payload_type, recv_codec));
|
||||
// outbound-rtp
|
||||
graph.outbound_rtp_id = "RTCOutboundRTPAudioStream_3";
|
||||
graph.outbound_rtp_id = "OA3";
|
||||
media_info.senders.push_back(cricket::VoiceSenderInfo());
|
||||
media_info.senders[0].local_stats.push_back(cricket::SsrcSenderInfo());
|
||||
media_info.senders[0].local_stats[0].ssrc = kLocalSsrc;
|
||||
media_info.senders[0].codec_payload_type = send_codec.payload_type;
|
||||
// inbound-rtp
|
||||
graph.inbound_rtp_id = "RTCInboundRTPAudioStream_4";
|
||||
graph.inbound_rtp_id = "IA4";
|
||||
media_info.receivers.push_back(cricket::VoiceReceiverInfo());
|
||||
media_info.receivers[0].local_stats.push_back(cricket::SsrcReceiverInfo());
|
||||
media_info.receivers[0].local_stats[0].ssrc = kRemoteSsrc;
|
||||
media_info.receivers[0].codec_payload_type = recv_codec.payload_type;
|
||||
// remote-outbound-rtp
|
||||
if (add_remote_outbound_stats) {
|
||||
graph.remote_outbound_rtp_id = "RTCRemoteOutboundRTPAudioStream_4";
|
||||
graph.remote_outbound_rtp_id = "ROA4";
|
||||
media_info.receivers[0].last_sender_report_timestamp_ms =
|
||||
kRemoteOutboundStatsTimestampMs;
|
||||
media_info.receivers[0].last_sender_report_remote_timestamp_ms =
|
||||
@ -848,25 +847,24 @@ class RTCStatsCollectorTest : public ::testing::Test {
|
||||
}
|
||||
|
||||
// transport
|
||||
graph.transport_id = "RTCTransport_TransportName_1";
|
||||
graph.transport_id = "TTransportName1";
|
||||
pc_->AddVoiceChannel("VoiceMid", "TransportName", media_info);
|
||||
// track (sender)
|
||||
graph.sender = stats_->SetupLocalTrackAndSender(
|
||||
cricket::MEDIA_TYPE_AUDIO, "LocalAudioTrackID", kLocalSsrc, false, 50);
|
||||
graph.sender_track_id = "DEPRECATED_RTCMediaStreamTrack_sender_" +
|
||||
rtc::ToString(graph.sender->AttachmentId());
|
||||
graph.sender_track_id =
|
||||
"DEPRECATED_TO" + rtc::ToString(graph.sender->AttachmentId());
|
||||
// track (receiver) and stream (remote stream)
|
||||
graph.receiver = stats_->SetupRemoteTrackAndReceiver(
|
||||
cricket::MEDIA_TYPE_AUDIO, "RemoteAudioTrackID", "RemoteStreamId",
|
||||
kRemoteSsrc);
|
||||
graph.receiver_track_id = "DEPRECATED_RTCMediaStreamTrack_receiver_" +
|
||||
rtc::ToString(graph.receiver->AttachmentId());
|
||||
graph.remote_stream_id = "RTCMediaStream_RemoteStreamId";
|
||||
graph.receiver_track_id =
|
||||
"DEPRECATED_TI" + rtc::ToString(graph.receiver->AttachmentId());
|
||||
graph.remote_stream_id = "DEPRECATED_SRemoteStreamId";
|
||||
// peer-connection
|
||||
graph.peer_connection_id = "RTCPeerConnection";
|
||||
graph.peer_connection_id = "P";
|
||||
// media-source (kind: video)
|
||||
graph.media_source_id =
|
||||
"RTCAudioSource_" + rtc::ToString(graph.sender->AttachmentId());
|
||||
graph.media_source_id = "SA" + rtc::ToString(graph.sender->AttachmentId());
|
||||
|
||||
// Expected stats graph:
|
||||
//
|
||||
@ -1063,25 +1061,24 @@ TEST_F(RTCStatsCollectorTest, CollectRTCCodecStats) {
|
||||
rtc::scoped_refptr<const RTCStatsReport> report = stats_->GetStatsReport();
|
||||
|
||||
RTCCodecStats expected_inbound_audio_codec(
|
||||
"RTCCodec_RTCTransport_TransportName_1_Recv_1_minptime=10;useinbandfec=1",
|
||||
report->timestamp_us());
|
||||
"CITTransportName1_1_minptime=10;useinbandfec=1", report->timestamp_us());
|
||||
expected_inbound_audio_codec.payload_type = 1;
|
||||
expected_inbound_audio_codec.mime_type = "audio/opus";
|
||||
expected_inbound_audio_codec.clock_rate = 1337;
|
||||
expected_inbound_audio_codec.channels = 1;
|
||||
expected_inbound_audio_codec.sdp_fmtp_line = "minptime=10;useinbandfec=1";
|
||||
expected_inbound_audio_codec.transport_id = "RTCTransport_TransportName_1";
|
||||
expected_inbound_audio_codec.transport_id = "TTransportName1";
|
||||
|
||||
RTCCodecStats expected_outbound_audio_codec(
|
||||
"RTCCodec_RTCTransport_TransportName_1_Send_2", report->timestamp_us());
|
||||
RTCCodecStats expected_outbound_audio_codec("COTTransportName1_2",
|
||||
report->timestamp_us());
|
||||
expected_outbound_audio_codec.payload_type = 2;
|
||||
expected_outbound_audio_codec.mime_type = "audio/isac";
|
||||
expected_outbound_audio_codec.clock_rate = 1338;
|
||||
expected_outbound_audio_codec.channels = 2;
|
||||
expected_outbound_audio_codec.transport_id = "RTCTransport_TransportName_1";
|
||||
expected_outbound_audio_codec.transport_id = "TTransportName1";
|
||||
|
||||
RTCCodecStats expected_inbound_video_codec(
|
||||
"RTCCodec_RTCTransport_TransportName_1_Recv_3_level-asymmetry-allowed=1;"
|
||||
"CITTransportName1_3_level-asymmetry-allowed=1;"
|
||||
"packetization-mode=1;profile-level-id=42001f",
|
||||
report->timestamp_us());
|
||||
expected_inbound_video_codec.payload_type = 3;
|
||||
@ -1089,14 +1086,14 @@ TEST_F(RTCStatsCollectorTest, CollectRTCCodecStats) {
|
||||
expected_inbound_video_codec.clock_rate = 1339;
|
||||
expected_inbound_video_codec.sdp_fmtp_line =
|
||||
"level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42001f";
|
||||
expected_inbound_video_codec.transport_id = "RTCTransport_TransportName_1";
|
||||
expected_inbound_video_codec.transport_id = "TTransportName1";
|
||||
|
||||
RTCCodecStats expected_outbound_video_codec(
|
||||
"RTCCodec_RTCTransport_TransportName_1_Send_4", report->timestamp_us());
|
||||
RTCCodecStats expected_outbound_video_codec("COTTransportName1_4",
|
||||
report->timestamp_us());
|
||||
expected_outbound_video_codec.payload_type = 4;
|
||||
expected_outbound_video_codec.mime_type = "video/VP8";
|
||||
expected_outbound_video_codec.clock_rate = 1340;
|
||||
expected_outbound_video_codec.transport_id = "RTCTransport_TransportName_1";
|
||||
expected_outbound_video_codec.transport_id = "TTransportName1";
|
||||
|
||||
ASSERT_TRUE(report->Get(expected_inbound_audio_codec.id()));
|
||||
EXPECT_EQ(
|
||||
@ -1306,7 +1303,7 @@ TEST_F(RTCStatsCollectorTest, CollectRTCDataChannelStats) {
|
||||
pc_->AddSctpDataChannel(rtc::make_ref_counted<MockSctpDataChannel>(
|
||||
0, "MockSctpDataChannel0", DataChannelInterface::kConnecting, "udp", 1, 2,
|
||||
3, 4));
|
||||
RTCDataChannelStats expected_data_channel0("RTCDataChannel_0", 0);
|
||||
RTCDataChannelStats expected_data_channel0("D0", 0);
|
||||
expected_data_channel0.label = "MockSctpDataChannel0";
|
||||
expected_data_channel0.protocol = "udp";
|
||||
expected_data_channel0.data_channel_identifier = 0;
|
||||
@ -1319,7 +1316,7 @@ TEST_F(RTCStatsCollectorTest, CollectRTCDataChannelStats) {
|
||||
pc_->AddSctpDataChannel(rtc::make_ref_counted<MockSctpDataChannel>(
|
||||
1, "MockSctpDataChannel1", DataChannelInterface::kOpen, "tcp", 5, 6, 7,
|
||||
8));
|
||||
RTCDataChannelStats expected_data_channel1("RTCDataChannel_1", 0);
|
||||
RTCDataChannelStats expected_data_channel1("D1", 0);
|
||||
expected_data_channel1.label = "MockSctpDataChannel1";
|
||||
expected_data_channel1.protocol = "tcp";
|
||||
expected_data_channel1.data_channel_identifier = 1;
|
||||
@ -1332,7 +1329,7 @@ TEST_F(RTCStatsCollectorTest, CollectRTCDataChannelStats) {
|
||||
pc_->AddSctpDataChannel(rtc::make_ref_counted<MockSctpDataChannel>(
|
||||
2, "MockSctpDataChannel2", DataChannelInterface::kClosing, "udp", 9, 10,
|
||||
11, 12));
|
||||
RTCDataChannelStats expected_data_channel2("RTCDataChannel_2", 0);
|
||||
RTCDataChannelStats expected_data_channel2("D2", 0);
|
||||
expected_data_channel2.label = "MockSctpDataChannel2";
|
||||
expected_data_channel2.protocol = "udp";
|
||||
expected_data_channel2.data_channel_identifier = 2;
|
||||
@ -1345,7 +1342,7 @@ TEST_F(RTCStatsCollectorTest, CollectRTCDataChannelStats) {
|
||||
pc_->AddSctpDataChannel(rtc::make_ref_counted<MockSctpDataChannel>(
|
||||
3, "MockSctpDataChannel3", DataChannelInterface::kClosed, "tcp", 13, 14,
|
||||
15, 16));
|
||||
RTCDataChannelStats expected_data_channel3("RTCDataChannel_3", 0);
|
||||
RTCDataChannelStats expected_data_channel3("D3", 0);
|
||||
expected_data_channel3.label = "MockSctpDataChannel3";
|
||||
expected_data_channel3.protocol = "tcp";
|
||||
expected_data_channel3.data_channel_identifier = 3;
|
||||
@ -1380,9 +1377,8 @@ TEST_F(RTCStatsCollectorTest, CollectRTCIceCandidateStats) {
|
||||
std::unique_ptr<cricket::Candidate> a_local_host = CreateFakeCandidate(
|
||||
"1.2.3.4", 5, "a_local_host's protocol", rtc::ADAPTER_TYPE_VPN,
|
||||
cricket::LOCAL_PORT_TYPE, 0, rtc::ADAPTER_TYPE_ETHERNET);
|
||||
RTCLocalIceCandidateStats expected_a_local_host(
|
||||
"RTCIceCandidate_" + a_local_host->id(), 0);
|
||||
expected_a_local_host.transport_id = "RTCTransport_a_0";
|
||||
RTCLocalIceCandidateStats expected_a_local_host("I" + a_local_host->id(), 0);
|
||||
expected_a_local_host.transport_id = "Ta0";
|
||||
expected_a_local_host.network_type = "vpn";
|
||||
expected_a_local_host.ip = "1.2.3.4";
|
||||
expected_a_local_host.address = "1.2.3.4";
|
||||
@ -1396,9 +1392,9 @@ TEST_F(RTCStatsCollectorTest, CollectRTCIceCandidateStats) {
|
||||
std::unique_ptr<cricket::Candidate> a_remote_srflx = CreateFakeCandidate(
|
||||
"6.7.8.9", 10, "remote_srflx's protocol", rtc::ADAPTER_TYPE_UNKNOWN,
|
||||
cricket::STUN_PORT_TYPE, 1);
|
||||
RTCRemoteIceCandidateStats expected_a_remote_srflx(
|
||||
"RTCIceCandidate_" + a_remote_srflx->id(), 0);
|
||||
expected_a_remote_srflx.transport_id = "RTCTransport_a_0";
|
||||
RTCRemoteIceCandidateStats expected_a_remote_srflx("I" + a_remote_srflx->id(),
|
||||
0);
|
||||
expected_a_remote_srflx.transport_id = "Ta0";
|
||||
expected_a_remote_srflx.ip = "6.7.8.9";
|
||||
expected_a_remote_srflx.address = "6.7.8.9";
|
||||
expected_a_remote_srflx.port = 10;
|
||||
@ -1409,9 +1405,9 @@ TEST_F(RTCStatsCollectorTest, CollectRTCIceCandidateStats) {
|
||||
std::unique_ptr<cricket::Candidate> a_local_prflx = CreateFakeCandidate(
|
||||
"11.12.13.14", 15, "a_local_prflx's protocol",
|
||||
rtc::ADAPTER_TYPE_CELLULAR_2G, cricket::PRFLX_PORT_TYPE, 2);
|
||||
RTCLocalIceCandidateStats expected_a_local_prflx(
|
||||
"RTCIceCandidate_" + a_local_prflx->id(), 0);
|
||||
expected_a_local_prflx.transport_id = "RTCTransport_a_0";
|
||||
RTCLocalIceCandidateStats expected_a_local_prflx("I" + a_local_prflx->id(),
|
||||
0);
|
||||
expected_a_local_prflx.transport_id = "Ta0";
|
||||
expected_a_local_prflx.network_type = "cellular";
|
||||
expected_a_local_prflx.ip = "11.12.13.14";
|
||||
expected_a_local_prflx.address = "11.12.13.14";
|
||||
@ -1426,9 +1422,9 @@ TEST_F(RTCStatsCollectorTest, CollectRTCIceCandidateStats) {
|
||||
std::unique_ptr<cricket::Candidate> a_remote_relay = CreateFakeCandidate(
|
||||
"16.17.18.19", 20, "a_remote_relay's protocol", rtc::ADAPTER_TYPE_UNKNOWN,
|
||||
cricket::RELAY_PORT_TYPE, 3);
|
||||
RTCRemoteIceCandidateStats expected_a_remote_relay(
|
||||
"RTCIceCandidate_" + a_remote_relay->id(), 0);
|
||||
expected_a_remote_relay.transport_id = "RTCTransport_a_0";
|
||||
RTCRemoteIceCandidateStats expected_a_remote_relay("I" + a_remote_relay->id(),
|
||||
0);
|
||||
expected_a_remote_relay.transport_id = "Ta0";
|
||||
expected_a_remote_relay.ip = "16.17.18.19";
|
||||
expected_a_remote_relay.address = "16.17.18.19";
|
||||
expected_a_remote_relay.port = 20;
|
||||
@ -1442,9 +1438,9 @@ TEST_F(RTCStatsCollectorTest, CollectRTCIceCandidateStats) {
|
||||
a_local_relay->set_relay_protocol("tcp");
|
||||
a_local_relay->set_url("turn:url1");
|
||||
|
||||
RTCLocalIceCandidateStats expected_a_local_relay(
|
||||
"RTCIceCandidate_" + a_local_relay->id(), 0);
|
||||
expected_a_local_relay.transport_id = "RTCTransport_a_0";
|
||||
RTCLocalIceCandidateStats expected_a_local_relay("I" + a_local_relay->id(),
|
||||
0);
|
||||
expected_a_local_relay.transport_id = "Ta0";
|
||||
expected_a_local_relay.network_type = "unknown";
|
||||
expected_a_local_relay.ip = "16.17.18.19";
|
||||
expected_a_local_relay.address = "16.17.18.19";
|
||||
@ -1463,8 +1459,8 @@ TEST_F(RTCStatsCollectorTest, CollectRTCIceCandidateStats) {
|
||||
a_local_relay_prflx->set_relay_protocol("udp");
|
||||
|
||||
RTCLocalIceCandidateStats expected_a_local_relay_prflx(
|
||||
"RTCIceCandidate_" + a_local_relay_prflx->id(), 0);
|
||||
expected_a_local_relay_prflx.transport_id = "RTCTransport_a_0";
|
||||
"I" + a_local_relay_prflx->id(), 0);
|
||||
expected_a_local_relay_prflx.transport_id = "Ta0";
|
||||
expected_a_local_relay_prflx.network_type = "unknown";
|
||||
expected_a_local_relay_prflx.ip = "11.12.13.20";
|
||||
expected_a_local_relay_prflx.address = "11.12.13.20";
|
||||
@ -1483,8 +1479,8 @@ TEST_F(RTCStatsCollectorTest, CollectRTCIceCandidateStats) {
|
||||
rtc::ADAPTER_TYPE_VPN, cricket::LOCAL_PORT_TYPE, 0,
|
||||
rtc::ADAPTER_TYPE_ETHERNET);
|
||||
RTCLocalIceCandidateStats expected_a_local_host_not_paired(
|
||||
"RTCIceCandidate_" + a_local_host_not_paired->id(), 0);
|
||||
expected_a_local_host_not_paired.transport_id = "RTCTransport_a_0";
|
||||
"I" + a_local_host_not_paired->id(), 0);
|
||||
expected_a_local_host_not_paired.transport_id = "Ta0";
|
||||
expected_a_local_host_not_paired.network_type = "vpn";
|
||||
expected_a_local_host_not_paired.ip = "1.2.3.4";
|
||||
expected_a_local_host_not_paired.address = "1.2.3.4";
|
||||
@ -1501,9 +1497,8 @@ TEST_F(RTCStatsCollectorTest, CollectRTCIceCandidateStats) {
|
||||
std::unique_ptr<cricket::Candidate> b_local =
|
||||
CreateFakeCandidate("42.42.42.42", 42, "b_local's protocol",
|
||||
rtc::ADAPTER_TYPE_WIFI, cricket::LOCAL_PORT_TYPE, 42);
|
||||
RTCLocalIceCandidateStats expected_b_local("RTCIceCandidate_" + b_local->id(),
|
||||
0);
|
||||
expected_b_local.transport_id = "RTCTransport_b_0";
|
||||
RTCLocalIceCandidateStats expected_b_local("I" + b_local->id(), 0);
|
||||
expected_b_local.transport_id = "Tb0";
|
||||
expected_b_local.network_type = "wifi";
|
||||
expected_b_local.ip = "42.42.42.42";
|
||||
expected_b_local.address = "42.42.42.42";
|
||||
@ -1517,9 +1512,8 @@ TEST_F(RTCStatsCollectorTest, CollectRTCIceCandidateStats) {
|
||||
std::unique_ptr<cricket::Candidate> b_remote = CreateFakeCandidate(
|
||||
"42.42.42.42", 42, "b_remote's protocol", rtc::ADAPTER_TYPE_UNKNOWN,
|
||||
cricket::LOCAL_PORT_TYPE, 42);
|
||||
RTCRemoteIceCandidateStats expected_b_remote(
|
||||
"RTCIceCandidate_" + b_remote->id(), 0);
|
||||
expected_b_remote.transport_id = "RTCTransport_b_0";
|
||||
RTCRemoteIceCandidateStats expected_b_remote("I" + b_remote->id(), 0);
|
||||
expected_b_remote.transport_id = "Tb0";
|
||||
expected_b_remote.ip = "42.42.42.42";
|
||||
expected_b_remote.address = "42.42.42.42";
|
||||
expected_b_remote.port = 42;
|
||||
@ -1606,8 +1600,8 @@ TEST_F(RTCStatsCollectorTest, CollectRTCIceCandidateStats) {
|
||||
ASSERT_TRUE(report->Get(expected_b_remote.id()));
|
||||
EXPECT_EQ(expected_b_remote, report->Get(expected_b_remote.id())
|
||||
->cast_to<RTCRemoteIceCandidateStats>());
|
||||
EXPECT_TRUE(report->Get("RTCTransport_a_0"));
|
||||
EXPECT_TRUE(report->Get("RTCTransport_b_0"));
|
||||
EXPECT_TRUE(report->Get("Ta0"));
|
||||
EXPECT_TRUE(report->Get("Tb0"));
|
||||
}
|
||||
|
||||
TEST_F(RTCStatsCollectorTest, CollectRTCIceCandidatePairStats) {
|
||||
@ -1652,16 +1646,13 @@ TEST_F(RTCStatsCollectorTest, CollectRTCIceCandidatePairStats) {
|
||||
|
||||
rtc::scoped_refptr<const RTCStatsReport> report = stats_->GetStatsReport();
|
||||
|
||||
RTCIceCandidatePairStats expected_pair("RTCIceCandidatePair_" +
|
||||
local_candidate->id() + "_" +
|
||||
remote_candidate->id(),
|
||||
RTCIceCandidatePairStats expected_pair(
|
||||
"CP" + local_candidate->id() + "_" + remote_candidate->id(),
|
||||
report->timestamp_us());
|
||||
expected_pair.transport_id =
|
||||
"RTCTransport_transport_" +
|
||||
rtc::ToString(cricket::ICE_CANDIDATE_COMPONENT_RTP);
|
||||
expected_pair.local_candidate_id = "RTCIceCandidate_" + local_candidate->id();
|
||||
expected_pair.remote_candidate_id =
|
||||
"RTCIceCandidate_" + remote_candidate->id();
|
||||
"Ttransport" + rtc::ToString(cricket::ICE_CANDIDATE_COMPONENT_RTP);
|
||||
expected_pair.local_candidate_id = "I" + local_candidate->id();
|
||||
expected_pair.remote_candidate_id = "I" + remote_candidate->id();
|
||||
expected_pair.state = RTCStatsIceCandidatePairState::kInProgress;
|
||||
expected_pair.priority = 5555;
|
||||
expected_pair.nominated = false;
|
||||
@ -1780,14 +1771,11 @@ TEST_F(RTCStatsCollectorTest, CollectRTCIceCandidatePairStats) {
|
||||
TEST_F(RTCStatsCollectorTest, CollectRTCPeerConnectionStats) {
|
||||
{
|
||||
rtc::scoped_refptr<const RTCStatsReport> report = stats_->GetStatsReport();
|
||||
RTCPeerConnectionStats expected("RTCPeerConnection",
|
||||
report->timestamp_us());
|
||||
RTCPeerConnectionStats expected("P", report->timestamp_us());
|
||||
expected.data_channels_opened = 0;
|
||||
expected.data_channels_closed = 0;
|
||||
ASSERT_TRUE(report->Get("RTCPeerConnection"));
|
||||
EXPECT_EQ(
|
||||
expected,
|
||||
report->Get("RTCPeerConnection")->cast_to<RTCPeerConnectionStats>());
|
||||
ASSERT_TRUE(report->Get("P"));
|
||||
EXPECT_EQ(expected, report->Get("P")->cast_to<RTCPeerConnectionStats>());
|
||||
}
|
||||
|
||||
// TODO(bugs.webrtc.org/11547): Supply a separate network thread.
|
||||
@ -1808,14 +1796,11 @@ TEST_F(RTCStatsCollectorTest, CollectRTCPeerConnectionStats) {
|
||||
{
|
||||
rtc::scoped_refptr<const RTCStatsReport> report =
|
||||
stats_->GetFreshStatsReport();
|
||||
RTCPeerConnectionStats expected("RTCPeerConnection",
|
||||
report->timestamp_us());
|
||||
RTCPeerConnectionStats expected("P", report->timestamp_us());
|
||||
expected.data_channels_opened = 1;
|
||||
expected.data_channels_closed = 0;
|
||||
ASSERT_TRUE(report->Get("RTCPeerConnection"));
|
||||
EXPECT_EQ(
|
||||
expected,
|
||||
report->Get("RTCPeerConnection")->cast_to<RTCPeerConnectionStats>());
|
||||
ASSERT_TRUE(report->Get("P"));
|
||||
EXPECT_EQ(expected, report->Get("P")->cast_to<RTCPeerConnectionStats>());
|
||||
}
|
||||
|
||||
dummy_channel_b->SignalOpened(dummy_channel_b.get());
|
||||
@ -1824,14 +1809,11 @@ TEST_F(RTCStatsCollectorTest, CollectRTCPeerConnectionStats) {
|
||||
{
|
||||
rtc::scoped_refptr<const RTCStatsReport> report =
|
||||
stats_->GetFreshStatsReport();
|
||||
RTCPeerConnectionStats expected("RTCPeerConnection",
|
||||
report->timestamp_us());
|
||||
RTCPeerConnectionStats expected("P", report->timestamp_us());
|
||||
expected.data_channels_opened = 2;
|
||||
expected.data_channels_closed = 1;
|
||||
ASSERT_TRUE(report->Get("RTCPeerConnection"));
|
||||
EXPECT_EQ(
|
||||
expected,
|
||||
report->Get("RTCPeerConnection")->cast_to<RTCPeerConnectionStats>());
|
||||
ASSERT_TRUE(report->Get("P"));
|
||||
EXPECT_EQ(expected, report->Get("P")->cast_to<RTCPeerConnectionStats>());
|
||||
}
|
||||
|
||||
// Re-opening a data channel (or opening a new data channel that is re-using
|
||||
@ -1841,14 +1823,11 @@ TEST_F(RTCStatsCollectorTest, CollectRTCPeerConnectionStats) {
|
||||
{
|
||||
rtc::scoped_refptr<const RTCStatsReport> report =
|
||||
stats_->GetFreshStatsReport();
|
||||
RTCPeerConnectionStats expected("RTCPeerConnection",
|
||||
report->timestamp_us());
|
||||
RTCPeerConnectionStats expected("P", report->timestamp_us());
|
||||
expected.data_channels_opened = 3;
|
||||
expected.data_channels_closed = 1;
|
||||
ASSERT_TRUE(report->Get("RTCPeerConnection"));
|
||||
EXPECT_EQ(
|
||||
expected,
|
||||
report->Get("RTCPeerConnection")->cast_to<RTCPeerConnectionStats>());
|
||||
ASSERT_TRUE(report->Get("P"));
|
||||
EXPECT_EQ(expected, report->Get("P")->cast_to<RTCPeerConnectionStats>());
|
||||
}
|
||||
|
||||
dummy_channel_a->SignalClosed(dummy_channel_a.get());
|
||||
@ -1857,14 +1836,11 @@ TEST_F(RTCStatsCollectorTest, CollectRTCPeerConnectionStats) {
|
||||
{
|
||||
rtc::scoped_refptr<const RTCStatsReport> report =
|
||||
stats_->GetFreshStatsReport();
|
||||
RTCPeerConnectionStats expected("RTCPeerConnection",
|
||||
report->timestamp_us());
|
||||
RTCPeerConnectionStats expected("P", report->timestamp_us());
|
||||
expected.data_channels_opened = 3;
|
||||
expected.data_channels_closed = 3;
|
||||
ASSERT_TRUE(report->Get("RTCPeerConnection"));
|
||||
EXPECT_EQ(
|
||||
expected,
|
||||
report->Get("RTCPeerConnection")->cast_to<RTCPeerConnectionStats>());
|
||||
ASSERT_TRUE(report->Get("P"));
|
||||
EXPECT_EQ(expected, report->Get("P")->cast_to<RTCPeerConnectionStats>());
|
||||
}
|
||||
}
|
||||
|
||||
@ -1910,7 +1886,7 @@ TEST_F(RTCStatsCollectorTest,
|
||||
RTCMediaStreamTrackKind::kAudio);
|
||||
expected_local_audio_track_ssrc1.track_identifier = local_audio_track->id();
|
||||
expected_local_audio_track_ssrc1.media_source_id =
|
||||
"RTCAudioSource_11"; // Attachment ID = SSRC + 10
|
||||
"SA11"; // Attachment ID = SSRC + 10
|
||||
expected_local_audio_track_ssrc1.remote_source = false;
|
||||
expected_local_audio_track_ssrc1.ended = true;
|
||||
expected_local_audio_track_ssrc1.detached = false;
|
||||
@ -2055,7 +2031,7 @@ TEST_F(RTCStatsCollectorTest,
|
||||
RTCMediaStreamTrackKind::kVideo);
|
||||
expected_local_video_track_ssrc1.track_identifier = local_video_track->id();
|
||||
expected_local_video_track_ssrc1.media_source_id =
|
||||
"RTCVideoSource_11"; // Attachment ID = SSRC + 10
|
||||
"SV11"; // Attachment ID = SSRC + 10
|
||||
expected_local_video_track_ssrc1.remote_source = false;
|
||||
expected_local_video_track_ssrc1.ended = false;
|
||||
expected_local_video_track_ssrc1.detached = false;
|
||||
@ -2207,16 +2183,15 @@ TEST_F(RTCStatsCollectorTest, CollectRTCInboundRTPStreamStats_Audio) {
|
||||
auto stats_of_track_type = report->GetStatsOfType<RTCMediaStreamTrackStats>();
|
||||
ASSERT_EQ(1U, stats_of_track_type.size());
|
||||
|
||||
RTCInboundRTPStreamStats expected_audio("RTCInboundRTPAudioStream_1",
|
||||
report->timestamp_us());
|
||||
RTCInboundRTPStreamStats expected_audio("IA1", report->timestamp_us());
|
||||
expected_audio.ssrc = 1;
|
||||
expected_audio.media_type = "audio";
|
||||
expected_audio.kind = "audio";
|
||||
expected_audio.track_identifier = "RemoteAudioTrackID";
|
||||
expected_audio.mid = "AudioMid";
|
||||
expected_audio.track_id = stats_of_track_type[0]->id();
|
||||
expected_audio.transport_id = "RTCTransport_TransportName_1";
|
||||
expected_audio.codec_id = "RTCCodec_RTCTransport_TransportName_1_Recv_42";
|
||||
expected_audio.transport_id = "TTransportName1";
|
||||
expected_audio.codec_id = "CITTransportName1_42";
|
||||
expected_audio.packets_received = 2;
|
||||
expected_audio.nack_count = 5;
|
||||
expected_audio.fec_packets_discarded = 5566;
|
||||
@ -2327,16 +2302,15 @@ TEST_F(RTCStatsCollectorTest, CollectRTCInboundRTPStreamStats_Video) {
|
||||
|
||||
rtc::scoped_refptr<const RTCStatsReport> report = stats_->GetStatsReport();
|
||||
|
||||
RTCInboundRTPStreamStats expected_video("RTCInboundRTPVideoStream_1",
|
||||
report->timestamp_us());
|
||||
RTCInboundRTPStreamStats expected_video("IV1", report->timestamp_us());
|
||||
expected_video.ssrc = 1;
|
||||
expected_video.media_type = "video";
|
||||
expected_video.kind = "video";
|
||||
expected_video.track_identifier = "RemoteVideoTrackID";
|
||||
expected_video.mid = "VideoMid";
|
||||
expected_video.track_id = IdForType<RTCMediaStreamTrackStats>(report.get());
|
||||
expected_video.transport_id = "RTCTransport_TransportName_1";
|
||||
expected_video.codec_id = "RTCCodec_RTCTransport_TransportName_1_Recv_42";
|
||||
expected_video.transport_id = "TTransportName1";
|
||||
expected_video.codec_id = "CITTransportName1_42";
|
||||
expected_video.fir_count = 5;
|
||||
expected_video.pli_count = 6;
|
||||
expected_video.nack_count = 7;
|
||||
@ -2426,17 +2400,16 @@ TEST_F(RTCStatsCollectorTest, CollectRTCOutboundRTPStreamStats_Audio) {
|
||||
|
||||
rtc::scoped_refptr<const RTCStatsReport> report = stats_->GetStatsReport();
|
||||
|
||||
RTCOutboundRTPStreamStats expected_audio("RTCOutboundRTPAudioStream_1",
|
||||
report->timestamp_us());
|
||||
expected_audio.media_source_id = "RTCAudioSource_50";
|
||||
RTCOutboundRTPStreamStats expected_audio("OA1", report->timestamp_us());
|
||||
expected_audio.media_source_id = "SA50";
|
||||
// `expected_audio.remote_id` should be undefined.
|
||||
expected_audio.mid = "AudioMid";
|
||||
expected_audio.ssrc = 1;
|
||||
expected_audio.media_type = "audio";
|
||||
expected_audio.kind = "audio";
|
||||
expected_audio.track_id = IdForType<RTCMediaStreamTrackStats>(report.get());
|
||||
expected_audio.transport_id = "RTCTransport_TransportName_1";
|
||||
expected_audio.codec_id = "RTCCodec_RTCTransport_TransportName_1_Send_42";
|
||||
expected_audio.transport_id = "TTransportName1";
|
||||
expected_audio.codec_id = "COTTransportName1_42";
|
||||
expected_audio.packets_sent = 2;
|
||||
expected_audio.retransmitted_packets_sent = 20;
|
||||
expected_audio.bytes_sent = 3;
|
||||
@ -2518,15 +2491,15 @@ TEST_F(RTCStatsCollectorTest, CollectRTCOutboundRTPStreamStats_Video) {
|
||||
|
||||
RTCOutboundRTPStreamStats expected_video(stats_of_my_type[0]->id(),
|
||||
report->timestamp_us());
|
||||
expected_video.media_source_id = "RTCVideoSource_50";
|
||||
expected_video.media_source_id = "SV50";
|
||||
// `expected_video.remote_id` should be undefined.
|
||||
expected_video.mid = "VideoMid";
|
||||
expected_video.ssrc = 1;
|
||||
expected_video.media_type = "video";
|
||||
expected_video.kind = "video";
|
||||
expected_video.track_id = stats_of_track_type[0]->id();
|
||||
expected_video.transport_id = "RTCTransport_TransportName_1";
|
||||
expected_video.codec_id = "RTCCodec_RTCTransport_TransportName_1_Send_42";
|
||||
expected_video.transport_id = "TTransportName1";
|
||||
expected_video.codec_id = "COTTransportName1_42";
|
||||
expected_video.fir_count = 2;
|
||||
expected_video.pli_count = 3;
|
||||
expected_video.nack_count = 4;
|
||||
@ -2629,8 +2602,7 @@ TEST_F(RTCStatsCollectorTest, CollectRTCTransportStats) {
|
||||
rtc::scoped_refptr<const RTCStatsReport> report = stats_->GetStatsReport();
|
||||
|
||||
RTCTransportStats expected_rtp_transport(
|
||||
"RTCTransport_transport_" +
|
||||
rtc::ToString(cricket::ICE_CANDIDATE_COMPONENT_RTP),
|
||||
"Ttransport" + rtc::ToString(cricket::ICE_CANDIDATE_COMPONENT_RTP),
|
||||
report->timestamp_us());
|
||||
expected_rtp_transport.bytes_sent = 42;
|
||||
expected_rtp_transport.packets_sent = 1;
|
||||
@ -2678,8 +2650,7 @@ TEST_F(RTCStatsCollectorTest, CollectRTCTransportStats) {
|
||||
report = stats_->GetFreshStatsReport();
|
||||
|
||||
RTCTransportStats expected_rtcp_transport(
|
||||
"RTCTransport_transport_" +
|
||||
rtc::ToString(cricket::ICE_CANDIDATE_COMPONENT_RTCP),
|
||||
"Ttransport" + rtc::ToString(cricket::ICE_CANDIDATE_COMPONENT_RTCP),
|
||||
report->timestamp_us());
|
||||
expected_rtcp_transport.bytes_sent = 1337;
|
||||
expected_rtcp_transport.packets_sent = 1;
|
||||
@ -2711,8 +2682,7 @@ TEST_F(RTCStatsCollectorTest, CollectRTCTransportStats) {
|
||||
report = stats_->GetFreshStatsReport();
|
||||
|
||||
expected_rtcp_transport.selected_candidate_pair_id =
|
||||
"RTCIceCandidatePair_" + rtcp_local_candidate->id() + "_" +
|
||||
rtcp_remote_candidate->id();
|
||||
"CP" + rtcp_local_candidate->id() + "_" + rtcp_remote_candidate->id();
|
||||
|
||||
ASSERT_TRUE(report->Get(expected_rtp_transport.id()));
|
||||
EXPECT_EQ(
|
||||
@ -2737,9 +2707,9 @@ TEST_F(RTCStatsCollectorTest, CollectRTCTransportStats) {
|
||||
report = stats_->GetFreshStatsReport();
|
||||
|
||||
expected_rtp_transport.local_certificate_id =
|
||||
"RTCCertificate_" + local_certinfo->fingerprints[0];
|
||||
"CF" + local_certinfo->fingerprints[0];
|
||||
expected_rtp_transport.remote_certificate_id =
|
||||
"RTCCertificate_" + remote_certinfo->fingerprints[0];
|
||||
"CF" + remote_certinfo->fingerprints[0];
|
||||
|
||||
expected_rtcp_transport.local_certificate_id =
|
||||
*expected_rtp_transport.local_certificate_id;
|
||||
@ -2805,8 +2775,7 @@ TEST_F(RTCStatsCollectorTest, CollectRTCTransportStatsWithCrypto) {
|
||||
rtc::scoped_refptr<const RTCStatsReport> report = stats_->GetStatsReport();
|
||||
|
||||
RTCTransportStats expected_rtp_transport(
|
||||
"RTCTransport_transport_" +
|
||||
rtc::ToString(cricket::ICE_CANDIDATE_COMPONENT_RTP),
|
||||
"Ttransport" + rtc::ToString(cricket::ICE_CANDIDATE_COMPONENT_RTP),
|
||||
report->timestamp_us());
|
||||
expected_rtp_transport.dtls_state = RTCDtlsTransportState::kConnected;
|
||||
expected_rtp_transport.selected_candidate_pair_changes = 1;
|
||||
@ -2861,16 +2830,15 @@ TEST_F(RTCStatsCollectorTest, CollectNoStreamRTCOutboundRTPStreamStats_Audio) {
|
||||
|
||||
rtc::scoped_refptr<const RTCStatsReport> report = stats_->GetStatsReport();
|
||||
|
||||
RTCOutboundRTPStreamStats expected_audio("RTCOutboundRTPAudioStream_1",
|
||||
report->timestamp_us());
|
||||
expected_audio.media_source_id = "RTCAudioSource_50";
|
||||
RTCOutboundRTPStreamStats expected_audio("OA1", report->timestamp_us());
|
||||
expected_audio.media_source_id = "SA50";
|
||||
expected_audio.mid = "AudioMid";
|
||||
expected_audio.ssrc = 1;
|
||||
expected_audio.media_type = "audio";
|
||||
expected_audio.kind = "audio";
|
||||
expected_audio.track_id = IdForType<RTCMediaStreamTrackStats>(report.get());
|
||||
expected_audio.transport_id = "RTCTransport_TransportName_1";
|
||||
expected_audio.codec_id = "RTCCodec_RTCTransport_TransportName_1_Send_42";
|
||||
expected_audio.transport_id = "TTransportName1";
|
||||
expected_audio.codec_id = "COTTransportName1_42";
|
||||
expected_audio.packets_sent = 2;
|
||||
expected_audio.retransmitted_packets_sent = 20;
|
||||
expected_audio.bytes_sent = 3;
|
||||
@ -2909,8 +2877,7 @@ TEST_F(RTCStatsCollectorTest, RTCAudioSourceStatsCollectedForSenderWithTrack) {
|
||||
|
||||
rtc::scoped_refptr<const RTCStatsReport> report = stats_->GetStatsReport();
|
||||
|
||||
RTCAudioSourceStats expected_audio("RTCAudioSource_42",
|
||||
report->timestamp_us());
|
||||
RTCAudioSourceStats expected_audio("SA42", report->timestamp_us());
|
||||
expected_audio.track_identifier = "LocalAudioTrackID";
|
||||
expected_audio.kind = "audio";
|
||||
expected_audio.audio_level = 1.0; // [0,1]
|
||||
@ -2955,8 +2922,7 @@ TEST_F(RTCStatsCollectorTest, RTCVideoSourceStatsCollectedForSenderWithTrack) {
|
||||
|
||||
rtc::scoped_refptr<const RTCStatsReport> report = stats_->GetStatsReport();
|
||||
|
||||
RTCVideoSourceStats expected_video("RTCVideoSource_42",
|
||||
report->timestamp_us());
|
||||
RTCVideoSourceStats expected_video("SV42", report->timestamp_us());
|
||||
expected_video.track_identifier = "LocalVideoTrackID";
|
||||
expected_video.kind = "video";
|
||||
expected_video.width = kVideoSourceWidth;
|
||||
@ -2999,9 +2965,8 @@ TEST_F(RTCStatsCollectorTest,
|
||||
pc_->AddSender(sender);
|
||||
|
||||
rtc::scoped_refptr<const RTCStatsReport> report = stats_->GetStatsReport();
|
||||
ASSERT_TRUE(report->Get("RTCVideoSource_42"));
|
||||
auto video_stats =
|
||||
report->Get("RTCVideoSource_42")->cast_to<RTCVideoSourceStats>();
|
||||
ASSERT_TRUE(report->Get("SV42"));
|
||||
auto video_stats = report->Get("SV42")->cast_to<RTCVideoSourceStats>();
|
||||
EXPECT_FALSE(video_stats.frames_per_second.is_defined());
|
||||
EXPECT_FALSE(video_stats.frames.is_defined());
|
||||
}
|
||||
@ -3030,9 +2995,8 @@ TEST_F(RTCStatsCollectorTest,
|
||||
pc_->AddSender(sender);
|
||||
|
||||
rtc::scoped_refptr<const RTCStatsReport> report = stats_->GetStatsReport();
|
||||
ASSERT_TRUE(report->Get("RTCVideoSource_42"));
|
||||
auto video_stats =
|
||||
report->Get("RTCVideoSource_42")->cast_to<RTCVideoSourceStats>();
|
||||
ASSERT_TRUE(report->Get("SV42"));
|
||||
auto video_stats = report->Get("SV42")->cast_to<RTCVideoSourceStats>();
|
||||
EXPECT_FALSE(video_stats.width.is_defined());
|
||||
EXPECT_FALSE(video_stats.height.is_defined());
|
||||
}
|
||||
@ -3054,7 +3018,7 @@ TEST_F(RTCStatsCollectorTest,
|
||||
pc_->AddSender(sender);
|
||||
|
||||
rtc::scoped_refptr<const RTCStatsReport> report = stats_->GetStatsReport();
|
||||
EXPECT_FALSE(report->Get("RTCAudioSource_42"));
|
||||
EXPECT_FALSE(report->Get("SA42"));
|
||||
}
|
||||
|
||||
// Parameterized tests on cricket::MediaType (audio or video).
|
||||
@ -3067,12 +3031,25 @@ class RTCStatsCollectorTestWithParamKind
|
||||
media_type_ == cricket::MEDIA_TYPE_VIDEO);
|
||||
}
|
||||
|
||||
std::string MediaTypeUpperCase() const {
|
||||
std::string MediaTypeCharStr() const {
|
||||
switch (media_type_) {
|
||||
case cricket::MEDIA_TYPE_AUDIO:
|
||||
return "Audio";
|
||||
return "A";
|
||||
case cricket::MEDIA_TYPE_VIDEO:
|
||||
return "Video";
|
||||
return "V";
|
||||
case cricket::MEDIA_TYPE_DATA:
|
||||
case cricket::MEDIA_TYPE_UNSUPPORTED:
|
||||
RTC_DCHECK_NOTREACHED();
|
||||
return "?";
|
||||
}
|
||||
}
|
||||
|
||||
std::string MediaTypeKind() const {
|
||||
switch (media_type_) {
|
||||
case cricket::MEDIA_TYPE_AUDIO:
|
||||
return "audio";
|
||||
case cricket::MEDIA_TYPE_VIDEO:
|
||||
return "video";
|
||||
case cricket::MEDIA_TYPE_DATA:
|
||||
case cricket::MEDIA_TYPE_UNSUPPORTED:
|
||||
RTC_DCHECK_NOTREACHED();
|
||||
@ -3080,12 +3057,6 @@ class RTCStatsCollectorTestWithParamKind
|
||||
}
|
||||
}
|
||||
|
||||
std::string MediaTypeLowerCase() const {
|
||||
std::string str = MediaTypeUpperCase();
|
||||
std::transform(str.begin(), str.end(), str.begin(), ::tolower);
|
||||
return str;
|
||||
}
|
||||
|
||||
// Adds a sender and channel of the appropriate kind, creating a sender info
|
||||
// with the report block's `source_ssrc` and report block data.
|
||||
void AddSenderInfoAndMediaChannel(
|
||||
@ -3176,20 +3147,18 @@ TEST_P(RTCStatsCollectorTestWithParamKind,
|
||||
|
||||
rtc::scoped_refptr<const RTCStatsReport> report = stats_->GetStatsReport();
|
||||
for (auto ssrc : ssrcs) {
|
||||
std::string stream_id = "Stream_" + std::to_string(ssrc);
|
||||
std::string stream_id = "" + std::to_string(ssrc);
|
||||
RTCRemoteInboundRtpStreamStats expected_remote_inbound_rtp(
|
||||
"RTCRemoteInboundRtp" + MediaTypeUpperCase() + stream_id,
|
||||
kReportBlockTimestampUtcUs);
|
||||
"RI" + MediaTypeCharStr() + stream_id, kReportBlockTimestampUtcUs);
|
||||
expected_remote_inbound_rtp.ssrc = ssrc;
|
||||
expected_remote_inbound_rtp.fraction_lost =
|
||||
static_cast<double>(kFractionLost) / (1 << 8);
|
||||
expected_remote_inbound_rtp.kind = MediaTypeLowerCase();
|
||||
expected_remote_inbound_rtp.kind = MediaTypeKind();
|
||||
expected_remote_inbound_rtp.transport_id =
|
||||
"RTCTransport_TransportName_1"; // 1 for RTP (we have no RTCP
|
||||
"TTransportName1"; // 1 for RTP (we have no RTCP
|
||||
// transport)
|
||||
expected_remote_inbound_rtp.packets_lost = 7;
|
||||
expected_remote_inbound_rtp.local_id =
|
||||
"RTCOutboundRTP" + MediaTypeUpperCase() + stream_id;
|
||||
expected_remote_inbound_rtp.local_id = "O" + MediaTypeCharStr() + stream_id;
|
||||
expected_remote_inbound_rtp.round_trip_time = kRoundTripTimeSample2Seconds;
|
||||
expected_remote_inbound_rtp.total_round_trip_time =
|
||||
kRoundTripTimeSample1Seconds + kRoundTripTimeSample2Seconds;
|
||||
@ -3231,8 +3200,7 @@ TEST_P(RTCStatsCollectorTestWithParamKind,
|
||||
|
||||
rtc::scoped_refptr<const RTCStatsReport> report = stats_->GetStatsReport();
|
||||
|
||||
std::string remote_inbound_rtp_id =
|
||||
"RTCRemoteInboundRtp" + MediaTypeUpperCase() + "Stream_12";
|
||||
std::string remote_inbound_rtp_id = "RI" + MediaTypeCharStr() + "12";
|
||||
ASSERT_TRUE(report->Get(remote_inbound_rtp_id));
|
||||
auto& remote_inbound_rtp = report->Get(remote_inbound_rtp_id)
|
||||
->cast_to<RTCRemoteInboundRtpStreamStats>();
|
||||
@ -3265,8 +3233,7 @@ TEST_P(RTCStatsCollectorTestWithParamKind,
|
||||
|
||||
rtc::scoped_refptr<const RTCStatsReport> report = stats_->GetStatsReport();
|
||||
|
||||
std::string remote_inbound_rtp_id =
|
||||
"RTCRemoteInboundRtp" + MediaTypeUpperCase() + "Stream_12";
|
||||
std::string remote_inbound_rtp_id = "RI" + MediaTypeCharStr() + "12";
|
||||
ASSERT_TRUE(report->Get(remote_inbound_rtp_id));
|
||||
auto& remote_inbound_rtp = report->Get(remote_inbound_rtp_id)
|
||||
->cast_to<RTCRemoteInboundRtpStreamStats>();
|
||||
@ -3306,14 +3273,13 @@ TEST_P(RTCStatsCollectorTestWithParamKind,
|
||||
|
||||
rtc::scoped_refptr<const RTCStatsReport> report = stats_->GetStatsReport();
|
||||
|
||||
std::string remote_inbound_rtp_id =
|
||||
"RTCRemoteInboundRtp" + MediaTypeUpperCase() + "Stream_12";
|
||||
std::string remote_inbound_rtp_id = "RI" + MediaTypeCharStr() + "12";
|
||||
ASSERT_TRUE(report->Get(remote_inbound_rtp_id));
|
||||
auto& remote_inbound_rtp = report->Get(remote_inbound_rtp_id)
|
||||
->cast_to<RTCRemoteInboundRtpStreamStats>();
|
||||
|
||||
EXPECT_TRUE(remote_inbound_rtp.transport_id.is_defined());
|
||||
EXPECT_EQ("RTCTransport_TransportName_2", // 2 for RTCP
|
||||
EXPECT_EQ("TTransportName2", // 2 for RTCP
|
||||
*remote_inbound_rtp.transport_id);
|
||||
EXPECT_TRUE(report->Get(*remote_inbound_rtp.transport_id));
|
||||
}
|
||||
@ -3379,7 +3345,7 @@ TEST_F(RTCStatsCollectorTest,
|
||||
pc_->AddSender(sender);
|
||||
|
||||
rtc::scoped_refptr<const RTCStatsReport> report = stats_->GetStatsReport();
|
||||
EXPECT_FALSE(report->Get("RTCVideoSource_42"));
|
||||
EXPECT_FALSE(report->Get("SV42"));
|
||||
}
|
||||
|
||||
// Test collecting echo return loss stats from the audio processor attached to
|
||||
@ -3412,7 +3378,7 @@ TEST_F(RTCStatsCollectorTest, CollectEchoReturnLossFromTrackAudioProcessor) {
|
||||
RTCMediaStreamTrackKind::kAudio);
|
||||
expected_local_audio_track_ssrc1.track_identifier = local_audio_track->id();
|
||||
expected_local_audio_track_ssrc1.media_source_id =
|
||||
"RTCAudioSource_11"; // Attachment ID = SSRC + 10
|
||||
"SA11"; // Attachment ID = SSRC + 10
|
||||
expected_local_audio_track_ssrc1.remote_source = false;
|
||||
expected_local_audio_track_ssrc1.ended = true;
|
||||
expected_local_audio_track_ssrc1.detached = false;
|
||||
@ -3425,8 +3391,7 @@ TEST_F(RTCStatsCollectorTest, CollectEchoReturnLossFromTrackAudioProcessor) {
|
||||
report->Get(expected_local_audio_track_ssrc1.id())
|
||||
->cast_to<RTCMediaStreamTrackStats>());
|
||||
|
||||
RTCAudioSourceStats expected_audio("RTCAudioSource_11",
|
||||
report->timestamp_us());
|
||||
RTCAudioSourceStats expected_audio("SA11", report->timestamp_us());
|
||||
expected_audio.track_identifier = "LocalAudioTrackID";
|
||||
expected_audio.kind = "audio";
|
||||
expected_audio.audio_level = 0;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user