@@ -14,7 +14,9 @@ import (
1414)
1515
1616const (
17- sourceRetryInterval = 5 * time .Second
17+ sourceRetryInterval = 5 * time .Second
18+ sourceUdpReadBufferSize = 2048
19+ sourceTcpReadBufferSize = 128 * 1024
1820)
1921
2022type source struct {
@@ -26,7 +28,6 @@ type source struct {
2628 tracks []* gortsplib.Track
2729 serverSdpText []byte
2830 serverSdpParsed * sdp.SessionDescription
29- readBuf * doubleBuffer
3031
3132 terminate chan struct {}
3233 done chan struct {}
@@ -71,7 +72,6 @@ func newSource(p *program, path string, sourceStr string, sourceProtocol string)
7172 path : path ,
7273 u : u ,
7374 proto : proto ,
74- readBuf : newDoubleBuffer (512 * 1024 ),
7575 terminate : make (chan struct {}),
7676 done : make (chan struct {}),
7777 }
@@ -226,7 +226,7 @@ func (s *source) runUdp(conn *gortsplib.ConnClient) bool {
226226 go func (trackId int , l * gortsplib.ConnClientUdpListener ) {
227227 defer wg .Done ()
228228
229- doubleBuf := newDoubleBuffer (2048 )
229+ doubleBuf := newDoubleBuffer (sourceUdpReadBufferSize )
230230 for {
231231 buf := doubleBuf .swap ()
232232
@@ -243,7 +243,7 @@ func (s *source) runUdp(conn *gortsplib.ConnClient) bool {
243243 go func (trackId int , l * gortsplib.ConnClientUdpListener ) {
244244 defer wg .Done ()
245245
246- doubleBuf := newDoubleBuffer (2048 )
246+ doubleBuf := newDoubleBuffer (sourceUdpReadBufferSize )
247247 for {
248248 buf := doubleBuf .swap ()
249249
@@ -309,11 +309,12 @@ func (s *source) runTcp(conn *gortsplib.ConnClient) bool {
309309 s .p .events <- programEventStreamerReady {s }
310310
311311 frame := & gortsplib.InterleavedFrame {}
312+ doubleBuf := newDoubleBuffer (sourceTcpReadBufferSize )
312313
313314 tcpConnDone := make (chan error )
314315 go func () {
315316 for {
316- frame .Content = s . readBuf .swap ()
317+ frame .Content = doubleBuf .swap ()
317318 frame .Content = frame .Content [:cap (frame .Content )]
318319
319320 err := conn .ReadFrame (frame )
0 commit comments