forked from Monibuca/engine
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathb.go
More file actions
34 lines (29 loc) · 649 Bytes
/
b.go
File metadata and controls
34 lines (29 loc) · 649 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package engine
type TSSlice []uint32
func (s TSSlice) Len() int { return len(s) }
func (s TSSlice) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
func (s TSSlice) Less(i, j int) bool { return s[i] < s[j] }
type B struct {
TSSlice
data []*RTPNalu
MaxTS uint32
}
func (b *B) Push(x interface{}) {
p := x.(*RTPNalu)
if p.PTS > b.MaxTS {
b.MaxTS = p.PTS
}
b.TSSlice = append(b.TSSlice, p.PTS)
b.data = append(b.data, p)
}
func (b *B) Pop() interface{} {
l := b.Len()-1
defer func() {
b.TSSlice = b.TSSlice[:l]
b.data = b.data[:l]
}()
return struct {
DTS uint32
*RTPNalu
}{DTS: b.TSSlice[l], RTPNalu: b.data[l]}
}