UltraGrid
UltraGrid Low-Latency High-Resolution Transmission System
Loading...
Searching...
No Matches
gui
QT
util
ssrc_container.hpp
Go to the documentation of this file.
1
#ifndef SSRC_CONTAINER_HPP_1b2b8951b25f
2
#define SSRC_CONTAINER_HPP_1b2b8951b25f
3
4
#include <vector>
5
6
template
<
typename
T,
typename
Ts_type>
7
class
SSRC_container
{
8
public
:
9
struct
Holder
{
10
T
item
;
11
uint32_t
ssrc
;
12
Ts_type
timestamp
;
13
};
14
15
void
insert
(uint32_t ssrc,
const
T&
item
, Ts_type timestamp);
16
const
std::vector<Holder>&
get
()
const
{
return
items
; }
17
void
remove_timed_out
(Ts_type timeout, Ts_type now);
18
void
clear
() {
items
.clear(); }
19
20
private
:
21
std::vector<Holder>
items
;
22
};
23
24
template
<
typename
T,
typename
Ts_type>
25
inline
void
SSRC_container<T, Ts_type>::insert
(uint32_t ssrc,
const
T&
item
, Ts_type timestamp){
26
Holder
*h =
nullptr
;
27
for
(
auto
& i : items){
28
if
(i.ssrc == ssrc){
29
h = &i;
30
}
31
}
32
33
if
(!h){
34
Holder
newItem = {};
35
newItem.
ssrc
= ssrc;
36
items.push_back(newItem);
37
h = &items.back();
38
}
39
40
h->
item
=
item
;
41
h->
timestamp
= timestamp;
42
}
43
44
template
<
typename
T,
typename
Ts_type>
45
inline
void
SSRC_container<T, Ts_type>::remove_timed_out
(Ts_type timeout, Ts_type now){
46
auto
endIt = std::remove_if(items.begin(), items.end(),
47
[now, timeout](
const
Holder
& h){ return now - h.timestamp > timeout; });
48
49
items.erase(endIt, items.end());
50
}
51
52
#endif
//SSRC_CONTAINER_HPP_1b2b8951b25f
SSRC_container
Definition
ssrc_container.hpp:7
SSRC_container::insert
void insert(uint32_t ssrc, const T &item, Ts_type timestamp)
Definition
ssrc_container.hpp:25
SSRC_container::clear
void clear()
Definition
ssrc_container.hpp:18
SSRC_container::get
const std::vector< Holder > & get() const
Definition
ssrc_container.hpp:16
SSRC_container::remove_timed_out
void remove_timed_out(Ts_type timeout, Ts_type now)
Definition
ssrc_container.hpp:45
SSRC_container::items
std::vector< Holder > items
Definition
ssrc_container.hpp:21
SSRC_container::Holder
Definition
ssrc_container.hpp:9
SSRC_container::Holder::timestamp
Ts_type timestamp
Definition
ssrc_container.hpp:12
SSRC_container::Holder::item
T item
Definition
ssrc_container.hpp:10
SSRC_container::Holder::ssrc
uint32_t ssrc
Definition
ssrc_container.hpp:11
item
Definition
hd-rum.c:27
Generated on Wed Sep 25 2024 14:27:13 for UltraGrid by
1.12.0