feat: play rtsp h264

This commit is contained in:
langhuihui
2024-06-27 20:42:14 +08:00
parent 2dbb40dc78
commit 0e28086d02
9 changed files with 153 additions and 54 deletions

View File

@@ -1,7 +1,9 @@
package util
import (
"math/rand"
"testing"
"time"
)
func TestBuffer(t *testing.T) {
@@ -16,3 +18,32 @@ func TestBuffer(t *testing.T) {
}
})
}
func TestReadBytesTo(t *testing.T) {
t.Run(t.Name(), func(t *testing.T) {
s := RandomString(100)
t.Logf("s:%s", s)
var m Memory
m.Append([]byte(s))
r := m.NewReader()
seededRand := rand.New(rand.NewSource(time.Now().UnixNano()))
var total []byte
for {
i := seededRand.Intn(10)
if i == 0 {
continue
}
buf := make([]byte, i)
n := r.ReadBytesTo(buf)
t.Logf("n:%d buf:%s", n, string(buf))
total = append(total, buf[:n]...)
if n == 0 {
if string(total) != s {
t.Logf("total:%s", total)
t.Fail()
}
return
}
}
})
}