Debian Codegraph @

src/rist-send-grace.h

raw symbols SCIP
1 /* librist. SPDX-License-Identifier: BSD-2-Clause
2 *
3 * Whether a peer that has gone silent may still be sent payload. Kept in a
4 * small standalone header so the decision can be unit-tested without a peer,
5 * a socket or a sender thread.
6 */
7
8 #ifndef RIST_SEND_GRACE_H
9 #define RIST_SEND_GRACE_H
10
11 #include <stdbool.h>
12 #include <stdint.h>
13
14 /* Declaring a peer dead means its return path went quiet, which says nothing
15 * about whether the forward path still works. Cutting a single-path stream the
16 * moment an RTCP reply is late strands a receiver that is otherwise fine, so a
17 * dead peer keeps its place in the send rotation for one recovery buffer window
18 * and is only dropped once that runs out. A bonded leg never reaches this: the
19 * stall check pulls it from the rotation far sooner.
20 *
21 * dead_since is when the peer was declared dead, grace is the window, and both
22 * share one unit with now (RIST_CLOCK ticks). A grace of 0 drops the peer as
23 * soon as it dies. A now behind dead_since keeps sending, which is the safe
24 * reading of a clock that moved backwards. */
25 static inline bool
26 rist_peer_may_send(bool dead, uint64_t dead_since, uint64_t grace, uint64_t now)
27 {
28 if (!dead)
29 return true;
30 if (now < dead_since)
31 return true;
32 return (now - dead_since) <= grace;
33 }
34
35 #endif /* RIST_SEND_GRACE_H */