mirror of
https://github.com/aler9/gortsplib
synced 2025-10-05 23:26:54 +08:00
move subfolders in pkg/
This commit is contained in:
38
pkg/base/utils.go
Normal file
38
pkg/base/utils.go
Normal file
@@ -0,0 +1,38 @@
|
||||
package base
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
const (
|
||||
rtspMaxContentLength = 4096
|
||||
)
|
||||
|
||||
func readByteEqual(rb *bufio.Reader, cmp byte) error {
|
||||
byt, err := rb.ReadByte()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if byt != cmp {
|
||||
return fmt.Errorf("expected '%c', got '%c'", cmp, byt)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func readBytesLimited(rb *bufio.Reader, delim byte, n int) ([]byte, error) {
|
||||
for i := 1; i <= n; i++ {
|
||||
byts, err := rb.Peek(i)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if byts[len(byts)-1] == delim {
|
||||
rb.Discard(len(byts))
|
||||
return byts, nil
|
||||
}
|
||||
}
|
||||
return nil, fmt.Errorf("buffer length exceeds %d", n)
|
||||
}
|
Reference in New Issue
Block a user