From 5c468c77d8498088d9ab658ee2173020e7d4bded Mon Sep 17 00:00:00 2001 From: aler9 <46489434+aler9@users.noreply.github.com> Date: Mon, 20 Jan 2020 15:09:28 +0100 Subject: [PATCH] rename rtsplistener into rtsp tcp listener, udplistener into rtsp udp listener --- main.go | 12 ++++++------ rtsplistener.go => rtsp_tcpl.go | 12 ++++++------ udplistener.go => rtsp_udpl.go | 12 ++++++------ 3 files changed, 18 insertions(+), 18 deletions(-) rename rtsplistener.go => rtsp_tcpl.go (59%) rename udplistener.go => rtsp_udpl.go (79%) diff --git a/main.go b/main.go index e7e4c82b..f0ac2488 100644 --- a/main.go +++ b/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 } diff --git a/rtsplistener.go b/rtsp_tcpl.go similarity index 59% rename from rtsplistener.go rename to rtsp_tcpl.go index 1e88846e..b1999629 100644 --- a/rtsplistener.go +++ b/rtsp_tcpl.go @@ -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 { diff --git a/udplistener.go b/rtsp_udpl.go similarity index 79% rename from udplistener.go rename to rtsp_udpl.go index 892aa477..01e8f425 100644 --- a/udplistener.go +++ b/rtsp_udpl.go @@ -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 {