Skip to content

Commit d220e01

Browse files
author
dave.seddon
committed
TrackIntToStringMap
1 parent a955818 commit d220e01

File tree

2 files changed

+50
-4
lines changed

2 files changed

+50
-4
lines changed

cmd/goTrackRTPer/goTrackRTPer.go

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717

1818
const (
1919
loopsCst = math.MaxInt32
20+
randnCst = 10
2021

2122
debugLevelCst = 11
2223

@@ -46,6 +47,7 @@ func main() {
4647
go initSignalHandler(cancel)
4748

4849
loops := flag.Int("loops", loopsCst, "loops")
50+
randn := flag.Int("randn", randnCst, "randn")
4951

5052
version := flag.Bool("version", false, "version")
5153

@@ -71,14 +73,24 @@ func main() {
7173
fmt.Println("loops:", loops)
7274

7375
var s uint16
76+
var seq uint16
7477
for i := 0; i < *loops; i++ {
75-
tax, err := tr.PacketArrival(s)
78+
79+
r := uint16(FastRandN(uint32(*randn)) + 1) // FastRandN can return zero (0)
80+
p := FastRandN(2)
81+
log.Printf("i:%d, s:%d, p:%d", i, s, p)
82+
if p == 1 {
83+
log.Printf("i:%d, s:%d, seq:%d", i, s, seq)
84+
seq = s - r
85+
} else {
86+
seq = s + r
87+
}
88+
89+
_, err := tr.PacketArrival(seq)
7690
if err != nil {
7791
log.Fatal("PacketArrival:", err)
7892
}
79-
if i > *aw+*bw && tax.Len < 100 {
80-
log.Fatalf("tax.Len:%d should be < 100:", tax.Len)
81-
}
93+
8294
s++
8395
}
8496

trackRTP.go

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,40 @@ const (
8080
SubCategoryJump
8181
)
8282

83+
type TrackIntToStringMap struct {
84+
posMap map[int]string
85+
catMap map[int]string
86+
subCatMap map[int]string
87+
}
88+
89+
func NewMaps() *TrackIntToStringMap {
90+
91+
pm := make(map[int]string)
92+
pm[PositionUnknown] = "Unknown"
93+
pm[PositionInit] = "Init"
94+
pm[PositionBehind] = "Behind"
95+
pm[PositionDuplicate] = "Duplicate"
96+
97+
cm := make(map[int]string)
98+
cm[CategoryUnknown] = "Unknown"
99+
cm[CategoryRestart] = "Restart"
100+
cm[CategoryBuffer] = "Buffer"
101+
cm[CategoryWindow] = "Window"
102+
103+
sm := make(map[int]string)
104+
sm[SubCategoryUnknown] = "Unknown"
105+
sm[SubCategoryNext] = "Next"
106+
sm[SubCategoryDuplicate] = "Duplicate"
107+
sm[SubCategoryAlready] = "Already"
108+
sm[SubCategoryJump] = "Jump"
109+
110+
return &TrackIntToStringMap{
111+
posMap: pm,
112+
catMap: cm,
113+
subCatMap: sm,
114+
}
115+
}
116+
83117
// New creates a Tracker
84118
// aw = ahead window
85119
// bw = behind window

0 commit comments

Comments
 (0)