codec/lex/lex_test.go: rtpRead.Read() checks for incomplete reads of packets buffer and resizes accordingly

This commit is contained in:
Saxon 2019-05-09 14:35:21 +09:30
parent c31c76e1f5
commit 1fb4381b8e
1 changed files with 5 additions and 1 deletions

View File

@ -45,7 +45,11 @@ func (r *rtpReader) Read(p []byte) (int, error) {
} }
b := r.packets[r.idx] b := r.packets[r.idx]
n := copy(p, b) n := copy(p, b)
r.idx++ if n < len(r.packets[r.idx]) {
r.packets[r.idx] = r.packets[r.idx][n:]
} else {
r.idx++
}
return n, nil return n, nil
} }