mirror of
https://github.com/mollyim/webrtc.git
synced 2025-05-13 05:40:42 +01:00

Bug: webrtc:13757 Change-Id: I358ab99c899b9de5f0135d5293101e7abda4aa31 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/265682 Auto-Submit: Danil Chapovalov <danilchap@webrtc.org> Commit-Queue: Åsa Persson <asapersson@webrtc.org> Reviewed-by: Åsa Persson <asapersson@webrtc.org> Cr-Commit-Position: refs/heads/main@{#37198}
77 lines
2.4 KiB
C++
77 lines
2.4 KiB
C++
/*
|
|
* Copyright (c) 2018 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.
|
|
*/
|
|
|
|
#ifndef MODULES_RTP_RTCP_INCLUDE_RTCP_STATISTICS_H_
|
|
#define MODULES_RTP_RTCP_INCLUDE_RTCP_STATISTICS_H_
|
|
|
|
#include <stdint.h>
|
|
|
|
#include "absl/strings/string_view.h"
|
|
|
|
namespace webrtc {
|
|
|
|
// Statistics for RTCP packet types.
|
|
struct RtcpPacketTypeCounter {
|
|
RtcpPacketTypeCounter()
|
|
: nack_packets(0),
|
|
fir_packets(0),
|
|
pli_packets(0),
|
|
nack_requests(0),
|
|
unique_nack_requests(0) {}
|
|
|
|
void Add(const RtcpPacketTypeCounter& other) {
|
|
nack_packets += other.nack_packets;
|
|
fir_packets += other.fir_packets;
|
|
pli_packets += other.pli_packets;
|
|
nack_requests += other.nack_requests;
|
|
unique_nack_requests += other.unique_nack_requests;
|
|
}
|
|
|
|
void Subtract(const RtcpPacketTypeCounter& other) {
|
|
nack_packets -= other.nack_packets;
|
|
fir_packets -= other.fir_packets;
|
|
pli_packets -= other.pli_packets;
|
|
nack_requests -= other.nack_requests;
|
|
unique_nack_requests -= other.unique_nack_requests;
|
|
}
|
|
|
|
int UniqueNackRequestsInPercent() const {
|
|
if (nack_requests == 0) {
|
|
return 0;
|
|
}
|
|
return static_cast<int>((unique_nack_requests * 100.0f / nack_requests) +
|
|
0.5f);
|
|
}
|
|
|
|
uint32_t nack_packets; // Number of RTCP NACK packets.
|
|
uint32_t fir_packets; // Number of RTCP FIR packets.
|
|
uint32_t pli_packets; // Number of RTCP PLI packets.
|
|
uint32_t nack_requests; // Number of NACKed RTP packets.
|
|
uint32_t unique_nack_requests; // Number of unique NACKed RTP packets.
|
|
};
|
|
|
|
class RtcpPacketTypeCounterObserver {
|
|
public:
|
|
virtual ~RtcpPacketTypeCounterObserver() {}
|
|
virtual void RtcpPacketTypesCounterUpdated(
|
|
uint32_t ssrc,
|
|
const RtcpPacketTypeCounter& packet_counter) = 0;
|
|
};
|
|
|
|
// Invoked for each cname passed in RTCP SDES blocks.
|
|
class RtcpCnameCallback {
|
|
public:
|
|
virtual ~RtcpCnameCallback() = default;
|
|
|
|
virtual void OnCname(uint32_t ssrc, absl::string_view cname) = 0;
|
|
};
|
|
|
|
} // namespace webrtc
|
|
#endif // MODULES_RTP_RTCP_INCLUDE_RTCP_STATISTICS_H_
|