mirror of
https://github.com/bluenviron/mediamtx
synced 2025-01-04 22:10:07 +00:00
rename rtsplistener into rtsp tcp listener, udplistener into rtsp udp listener
This commit is contained in:
parent
16e4fcb372
commit
5c468c77d8
12
main.go
12
main.go
@ -47,9 +47,9 @@ type program struct {
|
||||
rtcpPort int
|
||||
publishKey string
|
||||
mutex sync.RWMutex
|
||||
rtspl *rtspListener
|
||||
rtpl *udpListener
|
||||
rtcpl *udpListener
|
||||
rtspl *rtspTcpListener
|
||||
rtpl *rtspUdpListener
|
||||
rtcpl *rtspUdpListener
|
||||
clients map[*client]struct{}
|
||||
publishers map[string]*client
|
||||
}
|
||||
@ -92,17 +92,17 @@ func newProgram(protocolsStr string, rtspPort int, rtpPort int, rtcpPort int, pu
|
||||
|
||||
var err error
|
||||
|
||||
p.rtpl, err = newUdpListener(p, rtpPort, _TRACK_FLOW_RTP)
|
||||
p.rtpl, err = newRtspUdpListener(p, rtpPort, _TRACK_FLOW_RTP)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
p.rtcpl, err = newUdpListener(p, rtcpPort, _TRACK_FLOW_RTCP)
|
||||
p.rtcpl, err = newRtspUdpListener(p, rtcpPort, _TRACK_FLOW_RTCP)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
p.rtspl, err = newRtspListener(p)
|
||||
p.rtspl, err = newRtspTcpListener(p)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -5,12 +5,12 @@ import (
|
||||
"net"
|
||||
)
|
||||
|
||||
type rtspListener struct {
|
||||
type rtspTcpListener struct {
|
||||
p *program
|
||||
netl *net.TCPListener
|
||||
}
|
||||
|
||||
func newRtspListener(p *program) (*rtspListener, error) {
|
||||
func newRtspTcpListener(p *program) (*rtspTcpListener, error) {
|
||||
netl, err := net.ListenTCP("tcp", &net.TCPAddr{
|
||||
Port: p.rtspPort,
|
||||
})
|
||||
@ -18,7 +18,7 @@ func newRtspListener(p *program) (*rtspListener, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
s := &rtspListener{
|
||||
s := &rtspTcpListener{
|
||||
p: p,
|
||||
netl: netl,
|
||||
}
|
||||
@ -27,11 +27,11 @@ func newRtspListener(p *program) (*rtspListener, error) {
|
||||
return s, nil
|
||||
}
|
||||
|
||||
func (l *rtspListener) log(format string, args ...interface{}) {
|
||||
log.Printf("[RTSP listener] "+format, args...)
|
||||
func (l *rtspTcpListener) log(format string, args ...interface{}) {
|
||||
log.Printf("[RTSP TCP listener] "+format, args...)
|
||||
}
|
||||
|
||||
func (l *rtspListener) run() {
|
||||
func (l *rtspTcpListener) run() {
|
||||
for {
|
||||
nconn, err := l.netl.AcceptTCP()
|
||||
if err != nil {
|
@ -5,13 +5,13 @@ import (
|
||||
"net"
|
||||
)
|
||||
|
||||
type udpListener struct {
|
||||
type rtspUdpListener struct {
|
||||
p *program
|
||||
nconn *net.UDPConn
|
||||
flow trackFlow
|
||||
}
|
||||
|
||||
func newUdpListener(p *program, port int, flow trackFlow) (*udpListener, error) {
|
||||
func newRtspUdpListener(p *program, port int, flow trackFlow) (*rtspUdpListener, error) {
|
||||
nconn, err := net.ListenUDP("udp", &net.UDPAddr{
|
||||
Port: port,
|
||||
})
|
||||
@ -19,7 +19,7 @@ func newUdpListener(p *program, port int, flow trackFlow) (*udpListener, error)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
l := &udpListener{
|
||||
l := &rtspUdpListener{
|
||||
p: p,
|
||||
nconn: nconn,
|
||||
flow: flow,
|
||||
@ -29,17 +29,17 @@ func newUdpListener(p *program, port int, flow trackFlow) (*udpListener, error)
|
||||
return l, nil
|
||||
}
|
||||
|
||||
func (l *udpListener) log(format string, args ...interface{}) {
|
||||
func (l *rtspUdpListener) log(format string, args ...interface{}) {
|
||||
var label string
|
||||
if l.flow == _TRACK_FLOW_RTP {
|
||||
label = "RTP"
|
||||
} else {
|
||||
label = "RTCP"
|
||||
}
|
||||
log.Printf("["+label+" listener] "+format, args...)
|
||||
log.Printf("[RTSP UDP/"+label+" listener] "+format, args...)
|
||||
}
|
||||
|
||||
func (l *udpListener) run() {
|
||||
func (l *rtspUdpListener) run() {
|
||||
buf := make([]byte, 2048) // UDP MTU is 1400
|
||||
|
||||
for {
|
Loading…
Reference in New Issue
Block a user