-
Notifications
You must be signed in to change notification settings - Fork 2
/
rtp_queue.go
95 lines (77 loc) · 2.4 KB
/
rtp_queue.go
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
package scream
import "C"
import (
"sync"
)
// RTPQueue implements a simple RTP packet queue. One RTPQueue should be used
// per SSRC stream.
type RTPQueue interface {
// SizeOfNextRTP returns the size of the next item in the queue.
SizeOfNextRTP() int
// SeqNrOfNextRTP returns the RTP sequence number of the next item in the queue
SeqNrOfNextRTP() uint16
// SeqNrOfLastRTP returns the RTP sequence number of the last item in the queue
SeqNrOfLastRTP() uint16
// BytesInQueue returns the total number of bytes in the queue, i.e. the
// sum of the sizes of all items in the queue.
BytesInQueue() int
// SizeOfQueue returns the number of items in the queue.
SizeOfQueue() int
// GetDelay returns the delay of the last item in the queue.
// ts is given in seconds.
GetDelay(ts float64) float64
// GetSizeOfLastFrame returns the size of the latest pushed item.
GetSizeOfLastFrame() int
// Clear empties the queue.
Clear() int
}
var srcPipelinesLock sync.Mutex
var rtpQueues = map[uint32]RTPQueue{}
//export goClear
func goClear(id C.int) C.int {
srcPipelinesLock.Lock()
defer srcPipelinesLock.Unlock()
return C.int(rtpQueues[uint32(id)].Clear())
}
//export goSizeOfNextRtp
func goSizeOfNextRtp(id C.int) C.int {
srcPipelinesLock.Lock()
defer srcPipelinesLock.Unlock()
return C.int(rtpQueues[uint32(id)].SizeOfNextRTP())
}
//export goSeqNrOfNextRtp
func goSeqNrOfNextRtp(id C.int) C.int {
srcPipelinesLock.Lock()
defer srcPipelinesLock.Unlock()
return C.int(rtpQueues[uint32(id)].SeqNrOfNextRTP())
}
//export goSeqNrOfLastRtp
func goSeqNrOfLastRtp(id C.int) C.int {
srcPipelinesLock.Lock()
defer srcPipelinesLock.Unlock()
return C.int(rtpQueues[uint32(id)].SeqNrOfLastRTP())
}
//export goBytesInQueue
func goBytesInQueue(id C.int) C.int {
srcPipelinesLock.Lock()
defer srcPipelinesLock.Unlock()
return C.int(rtpQueues[uint32(id)].BytesInQueue())
}
//export goSizeOfQueue
func goSizeOfQueue(id C.int) C.int {
srcPipelinesLock.Lock()
defer srcPipelinesLock.Unlock()
return C.int(rtpQueues[uint32(id)].SizeOfQueue())
}
//export goGetDelay
func goGetDelay(id C.int, currTs C.float) C.float {
srcPipelinesLock.Lock()
defer srcPipelinesLock.Unlock()
return C.float(rtpQueues[uint32(id)].GetDelay(float64(currTs)))
}
//export goGetSizeOfLastFrame
func goGetSizeOfLastFrame(id C.int) C.int {
srcPipelinesLock.Lock()
defer srcPipelinesLock.Unlock()
return C.int(rtpQueues[uint32(id)].GetSizeOfLastFrame())
}