Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
packet_counter.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2024 Roc Streaming authors
3  *
4  * This Source Code Form is subject to the terms of the Mozilla Public
5  * License, v. 2.0. If a copy of the MPL was not distributed with this
6  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7  */
8 
9 //! @file roc_rtcp/packet_counter.h
10 //! @brief Packet counter.
11 
12 #ifndef ROC_RTCP_PACKET_COUNTER_H_
13 #define ROC_RTCP_PACKET_COUNTER_H_
14 
15 #include "roc_core/stddefs.h"
16 
17 namespace roc {
18 namespace rtcp {
19 
20 //! Computes number of packets in interval.
22 public:
23  //! Initialize.
25 
26  //! Update and return packet counter.
27  //! @p begin defines interval beginning.
28  //! @p end defines interval end (exclusive).
29  //! Packet counter is computes as the maximum seen distance from begin to end.
30  //! If begin changes, the maximum is cleared.
31  //! If end wraps around 32-bit boundary, this is taken into account.
32  uint64_t update(uint32_t begin, uint32_t end);
33 
34 private:
35  bool first_update_;
36 
37  uint64_t begin64_;
38  uint64_t end64_hi_;
39  uint32_t end64_lo_;
40 
41  uint64_t counter_;
42 };
43 
44 } // namespace rtcp
45 } // namespace roc
46 
47 #endif // ROC_RTCP_PACKET_COUNTER_H_
Computes number of packets in interval.
uint64_t update(uint32_t begin, uint32_t end)
Update and return packet counter. begin defines interval beginning. end defines interval end (exclusi...
PacketCounter()
Initialize.
Root namespace.
Commonly used types and functions.