stream/rtp/encoder.go: more sensible use of encoder buffer

This commit is contained in:
saxon 2019-02-08 20:20:19 +10:30
parent 865ce3e7a2
commit d5a26a98ff
1 changed files with 2 additions and 2 deletions

View File

@ -73,8 +73,8 @@ func NewEncoder(dst io.Writer, fps int) *Encoder {
func (e *Encoder) Write(data []byte) (int, error) { func (e *Encoder) Write(data []byte) (int, error) {
e.buffer = append(e.buffer, data...) e.buffer = append(e.buffer, data...)
for len(e.buffer) >= sendLen { for len(e.buffer) >= sendLen {
e.Encode(e.buffer[:sendLen]) e.Encode(e.buffer)
e.buffer = e.buffer[sendLen:] e.buffer = e.buffer[:0]
} }
return len(data), nil return len(data), nil
} }