mirror of
https://github.com/aler9/rtsp-simple-server
synced 2025-11-01 11:32:42 +08:00
improve performance by using static buffers instead of make()
This commit is contained in:
33
main.go
33
main.go
@@ -11,7 +11,6 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/aler9/gortsplib"
|
||||
"gopkg.in/alecthomas/kingpin.v2"
|
||||
"gortc.io/sdp"
|
||||
)
|
||||
@@ -586,30 +585,22 @@ func (p *program) forwardTrack(path string, id int, trackFlowType trackFlowType,
|
||||
if c.path == path && c.state == _CLIENT_STATE_PLAY {
|
||||
if c.streamProtocol == _STREAM_PROTOCOL_UDP {
|
||||
if trackFlowType == _TRACK_FLOW_RTP {
|
||||
p.udplRtp.write <- &udpWrite{
|
||||
addr: &net.UDPAddr{
|
||||
IP: c.ip(),
|
||||
Zone: c.zone(),
|
||||
Port: c.streamTracks[id].rtpPort,
|
||||
},
|
||||
buf: frame,
|
||||
}
|
||||
p.udplRtp.write(&net.UDPAddr{
|
||||
IP: c.ip(),
|
||||
Zone: c.zone(),
|
||||
Port: c.streamTracks[id].rtpPort,
|
||||
}, frame)
|
||||
|
||||
} else {
|
||||
p.udplRtcp.write <- &udpWrite{
|
||||
addr: &net.UDPAddr{
|
||||
IP: c.ip(),
|
||||
Zone: c.zone(),
|
||||
Port: c.streamTracks[id].rtcpPort,
|
||||
},
|
||||
buf: frame,
|
||||
}
|
||||
p.udplRtcp.write(&net.UDPAddr{
|
||||
IP: c.ip(),
|
||||
Zone: c.zone(),
|
||||
Port: c.streamTracks[id].rtcpPort,
|
||||
}, frame)
|
||||
}
|
||||
|
||||
} else {
|
||||
c.write <- &gortsplib.InterleavedFrame{
|
||||
Channel: trackToInterleavedChannel(id, trackFlowType),
|
||||
Content: frame,
|
||||
}
|
||||
c.writeFrame(trackToInterleavedChannel(id, trackFlowType), frame)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user