webrtc_m130/stats/rtcstats_objects.cc

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

452 lines
19 KiB
C++
Raw Normal View History

/*
* Copyright 2016 The WebRTC Project Authors. All rights reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include "api/stats/rtcstats_objects.h"
#include <utility>
#include "api/stats/attribute.h"
#include "api/stats/rtc_stats.h"
#include "rtc_base/checks.h"
namespace webrtc {
// clang-format off
WEBRTC_RTCSTATS_IMPL(RTCCertificateStats, RTCStats, "certificate",
AttributeInit("fingerprint", &fingerprint),
AttributeInit("fingerprintAlgorithm", &fingerprint_algorithm),
AttributeInit("base64Certificate", &base64_certificate),
AttributeInit("issuerCertificateId", &issuer_certificate_id))
// clang-format on
RTCCertificateStats::RTCCertificateStats(std::string id, Timestamp timestamp)
: RTCStats(std::move(id), timestamp) {}
RTCCertificateStats::~RTCCertificateStats() {}
// clang-format off
WEBRTC_RTCSTATS_IMPL(RTCCodecStats, RTCStats, "codec",
AttributeInit("transportId", &transport_id),
AttributeInit("payloadType", &payload_type),
AttributeInit("mimeType", &mime_type),
AttributeInit("clockRate", &clock_rate),
AttributeInit("channels", &channels),
AttributeInit("sdpFmtpLine", &sdp_fmtp_line))
// clang-format on
RTCCodecStats::RTCCodecStats(std::string id, Timestamp timestamp)
: RTCStats(std::move(id), timestamp) {}
RTCCodecStats::~RTCCodecStats() {}
// clang-format off
WEBRTC_RTCSTATS_IMPL(RTCDataChannelStats, RTCStats, "data-channel",
AttributeInit("label", &label),
AttributeInit("protocol", &protocol),
AttributeInit("dataChannelIdentifier", &data_channel_identifier),
AttributeInit("state", &state),
AttributeInit("messagesSent", &messages_sent),
AttributeInit("bytesSent", &bytes_sent),
AttributeInit("messagesReceived", &messages_received),
AttributeInit("bytesReceived", &bytes_received))
// clang-format on
RTCDataChannelStats::RTCDataChannelStats(std::string id, Timestamp timestamp)
: RTCStats(std::move(id), timestamp) {}
RTCDataChannelStats::~RTCDataChannelStats() {}
// clang-format off
WEBRTC_RTCSTATS_IMPL(RTCIceCandidatePairStats, RTCStats, "candidate-pair",
AttributeInit("transportId", &transport_id),
AttributeInit("localCandidateId", &local_candidate_id),
AttributeInit("remoteCandidateId", &remote_candidate_id),
AttributeInit("state", &state),
AttributeInit("priority", &priority),
AttributeInit("nominated", &nominated),
AttributeInit("writable", &writable),
AttributeInit("packetsSent", &packets_sent),
AttributeInit("packetsReceived", &packets_received),
AttributeInit("bytesSent", &bytes_sent),
AttributeInit("bytesReceived", &bytes_received),
AttributeInit("totalRoundTripTime", &total_round_trip_time),
AttributeInit("currentRoundTripTime", &current_round_trip_time),
AttributeInit("availableOutgoingBitrate", &available_outgoing_bitrate),
AttributeInit("availableIncomingBitrate", &available_incoming_bitrate),
AttributeInit("requestsReceived", &requests_received),
AttributeInit("requestsSent", &requests_sent),
AttributeInit("responsesReceived", &responses_received),
AttributeInit("responsesSent", &responses_sent),
AttributeInit("consentRequestsSent", &consent_requests_sent),
AttributeInit("packetsDiscardedOnSend", &packets_discarded_on_send),
AttributeInit("bytesDiscardedOnSend", &bytes_discarded_on_send),
AttributeInit("lastPacketReceivedTimestamp",
&last_packet_received_timestamp),
AttributeInit("lastPacketSentTimestamp", &last_packet_sent_timestamp))
// clang-format on
RTCIceCandidatePairStats::RTCIceCandidatePairStats(std::string id,
Timestamp timestamp)
: RTCStats(std::move(id), timestamp) {}
RTCIceCandidatePairStats::~RTCIceCandidatePairStats() {}
// clang-format off
2018-03-20 13:24:20 +01:00
WEBRTC_RTCSTATS_IMPL(RTCIceCandidateStats, RTCStats, "abstract-ice-candidate",
AttributeInit("transportId", &transport_id),
AttributeInit("isRemote", &is_remote),
AttributeInit("networkType", &network_type),
AttributeInit("ip", &ip),
AttributeInit("address", &address),
AttributeInit("port", &port),
AttributeInit("protocol", &protocol),
AttributeInit("relayProtocol", &relay_protocol),
AttributeInit("candidateType", &candidate_type),
AttributeInit("priority", &priority),
AttributeInit("url", &url),
AttributeInit("foundation", &foundation),
AttributeInit("relatedAddress", &related_address),
AttributeInit("relatedPort", &related_port),
AttributeInit("usernameFragment", &username_fragment),
AttributeInit("tcpType", &tcp_type),
AttributeInit("vpn", &vpn),
AttributeInit("networkAdapterType", &network_adapter_type))
// clang-format on
RTCIceCandidateStats::RTCIceCandidateStats(std::string id,
Timestamp timestamp,
bool is_remote)
: RTCStats(std::move(id), timestamp), is_remote(is_remote) {}
RTCIceCandidateStats::~RTCIceCandidateStats() {}
const char RTCLocalIceCandidateStats::kType[] = "local-candidate";
RTCLocalIceCandidateStats::RTCLocalIceCandidateStats(std::string id,
Timestamp timestamp)
: RTCIceCandidateStats(std::move(id), timestamp, false) {}
2018-03-20 13:24:20 +01:00
std::unique_ptr<RTCStats> RTCLocalIceCandidateStats::copy() const {
return std::make_unique<RTCLocalIceCandidateStats>(*this);
2018-03-20 13:24:20 +01:00
}
const char* RTCLocalIceCandidateStats::type() const {
return kType;
}
const char RTCRemoteIceCandidateStats::kType[] = "remote-candidate";
RTCRemoteIceCandidateStats::RTCRemoteIceCandidateStats(std::string id,
Timestamp timestamp)
: RTCIceCandidateStats(std::move(id), timestamp, true) {}
2018-03-20 13:24:20 +01:00
std::unique_ptr<RTCStats> RTCRemoteIceCandidateStats::copy() const {
return std::make_unique<RTCRemoteIceCandidateStats>(*this);
2018-03-20 13:24:20 +01:00
}
const char* RTCRemoteIceCandidateStats::type() const {
return kType;
}
// clang-format off
WEBRTC_RTCSTATS_IMPL(RTCPeerConnectionStats, RTCStats, "peer-connection",
AttributeInit("dataChannelsOpened", &data_channels_opened),
AttributeInit("dataChannelsClosed", &data_channels_closed))
// clang-format on
RTCPeerConnectionStats::RTCPeerConnectionStats(std::string id,
Timestamp timestamp)
: RTCStats(std::move(id), timestamp) {}
RTCPeerConnectionStats::~RTCPeerConnectionStats() {}
// clang-format off
WEBRTC_RTCSTATS_IMPL(RTCRtpStreamStats, RTCStats, "rtp",
AttributeInit("ssrc", &ssrc),
AttributeInit("kind", &kind),
AttributeInit("transportId", &transport_id),
AttributeInit("codecId", &codec_id))
// clang-format on
RTCRtpStreamStats::RTCRtpStreamStats(std::string id, Timestamp timestamp)
: RTCStats(std::move(id), timestamp) {}
RTCRtpStreamStats::~RTCRtpStreamStats() {}
// clang-format off
WEBRTC_RTCSTATS_IMPL(
RTCReceivedRtpStreamStats, RTCRtpStreamStats, "received-rtp",
AttributeInit("jitter", &jitter),
AttributeInit("packetsLost", &packets_lost))
// clang-format on
RTCReceivedRtpStreamStats::RTCReceivedRtpStreamStats(std::string id,
Timestamp timestamp)
: RTCRtpStreamStats(std::move(id), timestamp) {}
RTCReceivedRtpStreamStats::~RTCReceivedRtpStreamStats() {}
// clang-format off
WEBRTC_RTCSTATS_IMPL(RTCSentRtpStreamStats, RTCRtpStreamStats, "sent-rtp",
AttributeInit("packetsSent", &packets_sent),
AttributeInit("bytesSent", &bytes_sent))
// clang-format on
RTCSentRtpStreamStats::RTCSentRtpStreamStats(std::string id,
Timestamp timestamp)
: RTCRtpStreamStats(std::move(id), timestamp) {}
RTCSentRtpStreamStats::~RTCSentRtpStreamStats() {}
// clang-format off
WEBRTC_RTCSTATS_IMPL(
RTCInboundRtpStreamStats, RTCReceivedRtpStreamStats, "inbound-rtp",
AttributeInit("playoutId", &playout_id),
AttributeInit("trackIdentifier", &track_identifier),
AttributeInit("mid", &mid),
AttributeInit("remoteId", &remote_id),
AttributeInit("packetsReceived", &packets_received),
AttributeInit("packetsDiscarded", &packets_discarded),
AttributeInit("fecPacketsReceived", &fec_packets_received),
AttributeInit("fecBytesReceived", &fec_bytes_received),
AttributeInit("fecPacketsDiscarded", &fec_packets_discarded),
AttributeInit("fecSsrc", &fec_ssrc),
AttributeInit("bytesReceived", &bytes_received),
AttributeInit("headerBytesReceived", &header_bytes_received),
AttributeInit("retransmittedPacketsReceived",
&retransmitted_packets_received),
AttributeInit("retransmittedBytesReceived", &retransmitted_bytes_received),
AttributeInit("rtxSsrc", &rtx_ssrc),
AttributeInit("lastPacketReceivedTimestamp",
&last_packet_received_timestamp),
AttributeInit("jitterBufferDelay", &jitter_buffer_delay),
AttributeInit("jitterBufferTargetDelay", &jitter_buffer_target_delay),
AttributeInit("jitterBufferMinimumDelay", &jitter_buffer_minimum_delay),
AttributeInit("jitterBufferEmittedCount", &jitter_buffer_emitted_count),
AttributeInit("totalSamplesReceived", &total_samples_received),
AttributeInit("concealedSamples", &concealed_samples),
AttributeInit("silentConcealedSamples", &silent_concealed_samples),
AttributeInit("concealmentEvents", &concealment_events),
AttributeInit("insertedSamplesForDeceleration",
&inserted_samples_for_deceleration),
AttributeInit("removedSamplesForAcceleration",
&removed_samples_for_acceleration),
AttributeInit("audioLevel", &audio_level),
AttributeInit("totalAudioEnergy", &total_audio_energy),
AttributeInit("totalSamplesDuration", &total_samples_duration),
AttributeInit("framesReceived", &frames_received),
AttributeInit("frameWidth", &frame_width),
AttributeInit("frameHeight", &frame_height),
AttributeInit("framesPerSecond", &frames_per_second),
AttributeInit("framesDecoded", &frames_decoded),
AttributeInit("keyFramesDecoded", &key_frames_decoded),
AttributeInit("framesDropped", &frames_dropped),
AttributeInit("totalDecodeTime", &total_decode_time),
AttributeInit("totalProcessingDelay", &total_processing_delay),
AttributeInit("totalAssemblyTime", &total_assembly_time),
AttributeInit("framesAssembledFromMultiplePackets",
&frames_assembled_from_multiple_packets),
AttributeInit("totalInterFrameDelay", &total_inter_frame_delay),
AttributeInit("totalSquaredInterFrameDelay",
&total_squared_inter_frame_delay),
AttributeInit("pauseCount", &pause_count),
AttributeInit("totalPausesDuration", &total_pauses_duration),
AttributeInit("freezeCount", &freeze_count),
AttributeInit("totalFreezesDuration", &total_freezes_duration),
AttributeInit("contentType", &content_type),
AttributeInit("estimatedPlayoutTimestamp", &estimated_playout_timestamp),
AttributeInit("decoderImplementation", &decoder_implementation),
AttributeInit("firCount", &fir_count),
AttributeInit("pliCount", &pli_count),
AttributeInit("nackCount", &nack_count),
AttributeInit("qpSum", &qp_sum),
AttributeInit("totalCorruptionProbability", &total_corruption_probability),
AttributeInit("totalSquaredCorruptionProbability",
&total_squared_corruption_probability),
AttributeInit("corruptionMeasurements", &corruption_measurements),
AttributeInit("googTimingFrameInfo", &goog_timing_frame_info),
AttributeInit("powerEfficientDecoder", &power_efficient_decoder),
AttributeInit("jitterBufferFlushes", &jitter_buffer_flushes),
AttributeInit("delayedPacketOutageSamples", &delayed_packet_outage_samples),
AttributeInit("relativePacketArrivalDelay", &relative_packet_arrival_delay),
AttributeInit("interruptionCount", &interruption_count),
AttributeInit("totalInterruptionDuration", &total_interruption_duration),
AttributeInit("minPlayoutDelay", &min_playout_delay))
// clang-format on
RTCInboundRtpStreamStats::RTCInboundRtpStreamStats(std::string id,
Timestamp timestamp)
: RTCReceivedRtpStreamStats(std::move(id), timestamp) {}
RTCInboundRtpStreamStats::~RTCInboundRtpStreamStats() {}
// clang-format off
WEBRTC_RTCSTATS_IMPL(
RTCOutboundRtpStreamStats, RTCSentRtpStreamStats, "outbound-rtp",
AttributeInit("mediaSourceId", &media_source_id),
AttributeInit("remoteId", &remote_id),
AttributeInit("mid", &mid),
AttributeInit("rid", &rid),
AttributeInit("retransmittedPacketsSent", &retransmitted_packets_sent),
AttributeInit("headerBytesSent", &header_bytes_sent),
AttributeInit("retransmittedBytesSent", &retransmitted_bytes_sent),
AttributeInit("targetBitrate", &target_bitrate),
AttributeInit("framesEncoded", &frames_encoded),
AttributeInit("keyFramesEncoded", &key_frames_encoded),
AttributeInit("totalEncodeTime", &total_encode_time),
AttributeInit("totalEncodedBytesTarget", &total_encoded_bytes_target),
AttributeInit("frameWidth", &frame_width),
AttributeInit("frameHeight", &frame_height),
AttributeInit("framesPerSecond", &frames_per_second),
AttributeInit("framesSent", &frames_sent),
AttributeInit("hugeFramesSent", &huge_frames_sent),
AttributeInit("totalPacketSendDelay", &total_packet_send_delay),
AttributeInit("qualityLimitationReason", &quality_limitation_reason),
AttributeInit("qualityLimitationDurations", &quality_limitation_durations),
AttributeInit("qualityLimitationResolutionChanges",
&quality_limitation_resolution_changes),
AttributeInit("contentType", &content_type),
AttributeInit("encoderImplementation", &encoder_implementation),
AttributeInit("firCount", &fir_count),
AttributeInit("pliCount", &pli_count),
AttributeInit("nackCount", &nack_count),
AttributeInit("qpSum", &qp_sum),
AttributeInit("active", &active),
AttributeInit("powerEfficientEncoder", &power_efficient_encoder),
AttributeInit("scalabilityMode", &scalability_mode),
AttributeInit("rtxSsrc", &rtx_ssrc))
// clang-format on
RTCOutboundRtpStreamStats::RTCOutboundRtpStreamStats(std::string id,
Timestamp timestamp)
: RTCSentRtpStreamStats(std::move(id), timestamp) {}
RTCOutboundRtpStreamStats::~RTCOutboundRtpStreamStats() {}
// clang-format off
WEBRTC_RTCSTATS_IMPL(
RTCRemoteInboundRtpStreamStats, RTCReceivedRtpStreamStats,
"remote-inbound-rtp",
AttributeInit("localId", &local_id),
AttributeInit("roundTripTime", &round_trip_time),
AttributeInit("fractionLost", &fraction_lost),
AttributeInit("totalRoundTripTime", &total_round_trip_time),
AttributeInit("roundTripTimeMeasurements", &round_trip_time_measurements))
// clang-format on
RTCRemoteInboundRtpStreamStats::RTCRemoteInboundRtpStreamStats(
std::string id,
Timestamp timestamp)
: RTCReceivedRtpStreamStats(std::move(id), timestamp) {}
RTCRemoteInboundRtpStreamStats::~RTCRemoteInboundRtpStreamStats() {}
// clang-format off
WEBRTC_RTCSTATS_IMPL(
RTCRemoteOutboundRtpStreamStats, RTCSentRtpStreamStats,
"remote-outbound-rtp",
AttributeInit("localId", &local_id),
AttributeInit("remoteTimestamp", &remote_timestamp),
AttributeInit("reportsSent", &reports_sent),
AttributeInit("roundTripTime", &round_trip_time),
AttributeInit("roundTripTimeMeasurements", &round_trip_time_measurements),
AttributeInit("totalRoundTripTime", &total_round_trip_time))
// clang-format on
RTCRemoteOutboundRtpStreamStats::RTCRemoteOutboundRtpStreamStats(
std::string id,
Timestamp timestamp)
: RTCSentRtpStreamStats(std::move(id), timestamp) {}
RTCRemoteOutboundRtpStreamStats::~RTCRemoteOutboundRtpStreamStats() {}
// clang-format off
WEBRTC_RTCSTATS_IMPL(RTCMediaSourceStats, RTCStats, "parent-media-source",
AttributeInit("trackIdentifier", &track_identifier),
AttributeInit("kind", &kind))
// clang-format on
RTCMediaSourceStats::RTCMediaSourceStats(std::string id, Timestamp timestamp)
: RTCStats(std::move(id), timestamp) {}
RTCMediaSourceStats::~RTCMediaSourceStats() {}
// clang-format off
[getStats] Implement "media-source" audio levels, fixing Chrome bug. Implements RTCAudioSourceStats members: - audioLevel - totalAudioEnergy - totalSamplesDuration In this CL description these are collectively referred to as the audio levels. The audio levels are removed from sending "track" stats (in Chrome, these are now reported as undefined instead of 0). Background: For sending tracks, audio levels were always reported as 0 in Chrome (https://crbug.com/736403), while audio levels were correctly reported for receiving tracks. This problem affected the standard getStats() but not the legacy getStats(), blocking some people from migrating. This was likely not a problem in native third_party/webrtc code because the delivery of audio frames from device to send-stream uses a different code path outside of chromium. A recent PR (https://github.com/w3c/webrtc-stats/pull/451) moved the send-side audio levels to the RTCAudioSourceStats, while keeping the receive-side audio levels on the "track" stats. This allows an implementation to report the audio levels even if samples are not sent onto the network (such as if an ICE connection has not been established yet), reflecting some of the current implementation. Changes: 1. Audio levels are added to RTCAudioSourceStats. Send-side audio "track" stats are left undefined. Receive-side audio "track" stats are not changed in this CL and continue to work. 2. Audio level computation is moved from the AudioState and AudioTransportImpl to the AudioSendStream. This is because a) the AudioTransportImpl::RecordedDataIsAvailable() code path is not exercised in chromium, and b) audio levels should, per-spec, not be calculated on a per-call basis, for which the AudioState is defined. 3. The audio level computation is now performed in AudioSendStream::SendAudioData(), a code path used by both native and chromium code. 4. Comments are added to document behavior of existing code, such as AudioLevel and AudioSendStream::SendAudioData(). Note: In this CL, just like before this CL, audio level is only calculated after an AudioSendStream has been created. This means that before an O/A negotiation, audio levels are unavailable. According to spec, if we have an audio source, we should have audio levels. An immediate solution to this would have been to calculate the audio level at pc/rtp_sender.cc. The problem is that the LocalAudioSinkAdapter::OnData() code path, while exercised in chromium, is not exercised in native code. The issue of calculating audio levels on a per-source bases rather than on a per-send stream basis is left to https://crbug.com/webrtc/10771, an existing "media-source" bug. This CL can be verified manually in Chrome at: https://codepen.io/anon/pen/vqRGyq Bug: chromium:736403, webrtc:10771 Change-Id: I8036cd9984f3b187c3177470a8c0d6670a201a5a Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/143789 Reviewed-by: Oskar Sundbom <ossu@webrtc.org> Reviewed-by: Stefan Holmer <stefan@webrtc.org> Commit-Queue: Henrik Boström <hbos@webrtc.org> Cr-Commit-Position: refs/heads/master@{#28480}
2019-07-03 17:11:10 +02:00
WEBRTC_RTCSTATS_IMPL(RTCAudioSourceStats, RTCMediaSourceStats, "media-source",
AttributeInit("audioLevel", &audio_level),
AttributeInit("totalAudioEnergy", &total_audio_energy),
AttributeInit("totalSamplesDuration", &total_samples_duration),
AttributeInit("echoReturnLoss", &echo_return_loss),
AttributeInit("echoReturnLossEnhancement", &echo_return_loss_enhancement))
// clang-format on
RTCAudioSourceStats::RTCAudioSourceStats(std::string id, Timestamp timestamp)
: RTCMediaSourceStats(std::move(id), timestamp) {}
RTCAudioSourceStats::~RTCAudioSourceStats() {}
// clang-format off
WEBRTC_RTCSTATS_IMPL(RTCVideoSourceStats, RTCMediaSourceStats, "media-source",
AttributeInit("width", &width),
AttributeInit("height", &height),
AttributeInit("frames", &frames),
AttributeInit("framesPerSecond", &frames_per_second))
// clang-format on
RTCVideoSourceStats::RTCVideoSourceStats(std::string id, Timestamp timestamp)
: RTCMediaSourceStats(std::move(id), timestamp) {}
RTCVideoSourceStats::~RTCVideoSourceStats() {}
// clang-format off
WEBRTC_RTCSTATS_IMPL(RTCTransportStats, RTCStats, "transport",
AttributeInit("bytesSent", &bytes_sent),
AttributeInit("packetsSent", &packets_sent),
AttributeInit("bytesReceived", &bytes_received),
AttributeInit("packetsReceived", &packets_received),
AttributeInit("rtcpTransportStatsId", &rtcp_transport_stats_id),
AttributeInit("dtlsState", &dtls_state),
AttributeInit("selectedCandidatePairId", &selected_candidate_pair_id),
AttributeInit("localCertificateId", &local_certificate_id),
AttributeInit("remoteCertificateId", &remote_certificate_id),
AttributeInit("tlsVersion", &tls_version),
AttributeInit("dtlsCipher", &dtls_cipher),
AttributeInit("dtlsRole", &dtls_role),
AttributeInit("srtpCipher", &srtp_cipher),
AttributeInit("selectedCandidatePairChanges",
&selected_candidate_pair_changes),
AttributeInit("iceRole", &ice_role),
AttributeInit("iceLocalUsernameFragment", &ice_local_username_fragment),
AttributeInit("iceState", &ice_state))
// clang-format on
RTCTransportStats::RTCTransportStats(std::string id, Timestamp timestamp)
: RTCStats(std::move(id), timestamp) {}
RTCTransportStats::~RTCTransportStats() {}
// clang-format off
WEBRTC_RTCSTATS_IMPL(RTCAudioPlayoutStats, RTCStats, "media-playout",
AttributeInit("kind", &kind),
AttributeInit("synthesizedSamplesDuration", &synthesized_samples_duration),
AttributeInit("synthesizedSamplesEvents", &synthesized_samples_events),
AttributeInit("totalSamplesDuration", &total_samples_duration),
AttributeInit("totalPlayoutDelay", &total_playout_delay),
AttributeInit("totalSamplesCount", &total_samples_count))
// clang-format on
RTCAudioPlayoutStats::RTCAudioPlayoutStats(const std::string& id,
Timestamp timestamp)
: RTCStats(std::move(id), timestamp), kind("audio") {}
RTCAudioPlayoutStats::~RTCAudioPlayoutStats() {}
} // namespace webrtc