voip_statistics.h (3524B)
1 /* 2 * Copyright (c) 2020 The WebRTC project authors. All Rights Reserved. 3 * 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 6 * tree. An additional intellectual property rights grant can be found 7 * in the file PATENTS. All contributing project authors may 8 * be found in the AUTHORS file in the root of the source tree. 9 */ 10 11 #ifndef API_VOIP_VOIP_STATISTICS_H_ 12 #define API_VOIP_VOIP_STATISTICS_H_ 13 14 #include <cstdint> 15 #include <optional> 16 17 #include "api/neteq/neteq.h" 18 #include "api/voip/voip_base.h" 19 20 namespace webrtc { 21 22 struct IngressStatistics { 23 // Stats included from api/neteq/neteq.h. 24 NetEqLifetimeStatistics neteq_stats; 25 26 // Represents the total duration in seconds of all samples that have been 27 // received. 28 // https://w3c.github.io/webrtc-stats/#dom-rtcinboundrtpstreamstats-totalsamplesduration 29 double total_duration = 0.0; 30 }; 31 32 // Remote statistics obtained via remote RTCP SR/RR report received. 33 struct RemoteRtcpStatistics { 34 // Jitter as defined in RFC 3550 [6.4.1] expressed in seconds. 35 double jitter = 0.0; 36 37 // Cumulative packets lost as defined in RFC 3550 [6.4.1] 38 int64_t packets_lost = 0; 39 40 // Fraction lost as defined in RFC 3550 [6.4.1] expressed as a floating 41 // pointer number. 42 double fraction_lost = 0.0; 43 44 // https://w3c.github.io/webrtc-stats/#dom-rtcremoteinboundrtpstreamstats-roundtriptime 45 std::optional<double> round_trip_time; 46 47 // Last time (not RTP timestamp) when RTCP report received in milliseconds. 48 int64_t last_report_received_timestamp_ms; 49 }; 50 51 struct ChannelStatistics { 52 // https://w3c.github.io/webrtc-stats/#dom-rtcsentrtpstreamstats-packetssent 53 uint64_t packets_sent = 0; 54 55 // https://w3c.github.io/webrtc-stats/#dom-rtcsentrtpstreamstats-bytessent 56 uint64_t bytes_sent = 0; 57 58 // https://w3c.github.io/webrtc-stats/#dom-rtcreceivedrtpstreamstats-packetsreceived 59 uint64_t packets_received = 0; 60 61 // https://w3c.github.io/webrtc-stats/#dom-rtcinboundrtpstreamstats-bytesreceived 62 uint64_t bytes_received = 0; 63 64 // https://w3c.github.io/webrtc-stats/#dom-rtcreceivedrtpstreamstats-jitter 65 double jitter = 0.0; 66 67 // https://w3c.github.io/webrtc-stats/#dom-rtcreceivedrtpstreamstats-packetslost 68 int64_t packets_lost = 0; 69 70 // SSRC from remote media endpoint as indicated either by RTP header in RFC 71 // 3550 [5.1] or RTCP SSRC of sender in RFC 3550 [6.4.1]. 72 std::optional<uint32_t> remote_ssrc; 73 74 std::optional<RemoteRtcpStatistics> remote_rtcp; 75 }; 76 77 // VoipStatistics interface provides the interfaces for querying metrics around 78 // the jitter buffer (NetEq) performance. 79 class VoipStatistics { 80 public: 81 // Gets the audio ingress statistics by `ingress_stats` reference. 82 // Returns following VoipResult; 83 // kOk - successfully set provided IngressStatistics reference. 84 // kInvalidArgument - `channel_id` is invalid. 85 virtual VoipResult GetIngressStatistics(ChannelId channel_id, 86 IngressStatistics& ingress_stats) = 0; 87 88 // Gets the channel statistics by `channel_stats` reference. 89 // Returns following VoipResult; 90 // kOk - successfully set provided ChannelStatistics reference. 91 // kInvalidArgument - `channel_id` is invalid. 92 virtual VoipResult GetChannelStatistics(ChannelId channel_id, 93 ChannelStatistics& channel_stats) = 0; 94 95 protected: 96 virtual ~VoipStatistics() = default; 97 }; 98 99 } // namespace webrtc 100 101 #endif // API_VOIP_VOIP_STATISTICS_H_