Skip to content

Commit

Permalink
improve streamer performance by using static buffers
Browse files Browse the repository at this point in the history
  • Loading branch information
aler9 committed Jul 4, 2020
1 parent adb3909 commit eab4efe
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions streamer.go
Original file line number Diff line number Diff line change
Expand Up @@ -590,9 +590,15 @@ outer:
chanConnError := make(chan struct{})
go func() {
for {
frame := &gortsplib.InterleavedFrame{
Content: make([]byte, 512*1024),
if !s.readCurBuf {
frame.Content = s.readBuf1
} else {
frame.Content = s.readBuf2
}

frame.Content = frame.Content[:cap(frame.Content)]
s.readCurBuf = !s.readCurBuf

err := conn.ReadInterleavedFrame(frame)
if err != nil {
s.log("ERR: %s", err)
Expand Down

0 comments on commit eab4efe

Please sign in to comment.