mirror of https://bitbucket.org/ausocean/av.git
stream/rtp/encoder.go: more sensible use of encoder buffer
This commit is contained in:
parent
865ce3e7a2
commit
d5a26a98ff
|
@ -73,8 +73,8 @@ func NewEncoder(dst io.Writer, fps int) *Encoder {
|
|||
func (e *Encoder) Write(data []byte) (int, error) {
|
||||
e.buffer = append(e.buffer, data...)
|
||||
for len(e.buffer) >= sendLen {
|
||||
e.Encode(e.buffer[:sendLen])
|
||||
e.buffer = e.buffer[sendLen:]
|
||||
e.Encode(e.buffer)
|
||||
e.buffer = e.buffer[:0]
|
||||
}
|
||||
return len(data), nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue