rename rtsplistener into rtsp tcp listener, udplistener into rtsp udp listener

This commit is contained in:
aler9 2020-01-20 15:09:28 +01:00
parent 16e4fcb372
commit 5c468c77d8
3 changed files with 18 additions and 18 deletions

12
main.go
View File

@ -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
}

View File

@ -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 {

View File

@ -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 {