From 53e7d3641181fd2d26ab6554910f415cbc82f1f8 Mon Sep 17 00:00:00 2001 From: aler9 <46489434+aler9@users.noreply.github.com> Date: Sat, 11 Jul 2020 10:24:42 +0200 Subject: [PATCH] cleanup --- main.go | 10 +++++----- server-client.go | 10 +++++----- server-udpl.go | 2 +- streamer.go | 6 +++--- utils.go | 14 +++++++------- 5 files changed, 21 insertions(+), 21 deletions(-) diff --git a/main.go b/main.go index aff23070..e71c37b2 100644 --- a/main.go +++ b/main.go @@ -394,12 +394,12 @@ func newProgram(sargs []string, stdin io.Reader) (*program, error) { http.DefaultServeMux = http.NewServeMux() } - p.udplRtp, err = newServerUdpListener(p, conf.RtpPort, _TRACK_FLOW_RTP) + p.udplRtp, err = newServerUdpListener(p, conf.RtpPort, _TRACK_FLOW_TYPE_RTP) if err != nil { return nil, err } - p.udplRtcp, err = newServerUdpListener(p, conf.RtcpPort, _TRACK_FLOW_RTCP) + p.udplRtcp, err = newServerUdpListener(p, conf.RtcpPort, _TRACK_FLOW_TYPE_RTCP) if err != nil { return nil, err } @@ -570,7 +570,7 @@ outer: } for i, t := range cl.streamTracks { - if evt.trackFlowType == _TRACK_FLOW_RTP { + if evt.trackFlowType == _TRACK_FLOW_TYPE_RTP { if t.rtpPort == evt.addr.Port { return cl, i } @@ -676,7 +676,7 @@ func (p *program) forwardTrack(path string, id int, trackFlowType trackFlowType, for c := range p.clients { if c.path == path && c.state == _CLIENT_STATE_PLAY { if c.streamProtocol == _STREAM_PROTOCOL_UDP { - if trackFlowType == _TRACK_FLOW_RTP { + if trackFlowType == _TRACK_FLOW_TYPE_RTP { p.udplRtp.write(&net.UDPAddr{ IP: c.ip(), Zone: c.zone(), @@ -692,7 +692,7 @@ func (p *program) forwardTrack(path string, id int, trackFlowType trackFlowType, } } else { - c.writeFrame(trackToInterleavedChannel(id, trackFlowType), frame) + c.writeFrame(trackFlowTypeToInterleavedChannel(id, trackFlowType), frame) } } } diff --git a/server-client.go b/server-client.go index d6937c0c..53a53293 100644 --- a/server-client.go +++ b/server-client.go @@ -18,10 +18,10 @@ const ( _UDP_STREAM_DEAD_AFTER = 10 * time.Second ) -type clientState int +type serverClientState int const ( - _CLIENT_STATE_STARTING clientState = iota + _CLIENT_STATE_STARTING serverClientState = iota _CLIENT_STATE_ANNOUNCE _CLIENT_STATE_PRE_PLAY _CLIENT_STATE_PLAY @@ -29,7 +29,7 @@ const ( _CLIENT_STATE_RECORD ) -func (cs clientState) String() string { +func (cs serverClientState) String() string { switch cs { case _CLIENT_STATE_STARTING: return "STARTING" @@ -55,7 +55,7 @@ func (cs clientState) String() string { type serverClient struct { p *program conn *gortsplib.ConnServer - state clientState + state serverClientState path string authUser string authPass string @@ -887,7 +887,7 @@ func (c *serverClient) handleRequest(req *gortsplib.Request) bool { switch recvt := recv.(type) { case *gortsplib.InterleavedFrame: - trackId, trackFlowType := interleavedChannelToTrack(frame.Channel) + trackId, trackFlowType := interleavedChannelToTrackFlowType(frame.Channel) if trackId >= len(c.streamTracks) { c.log("ERR: invalid track id '%d'", trackId) diff --git a/server-udpl.go b/server-udpl.go index 5d35e963..3d3957d3 100644 --- a/server-udpl.go +++ b/server-udpl.go @@ -51,7 +51,7 @@ func newServerUdpListener(p *program, port int, trackFlowType trackFlowType) (*s func (l *serverUdpListener) log(format string, args ...interface{}) { var label string - if l.trackFlowType == _TRACK_FLOW_RTP { + if l.trackFlowType == _TRACK_FLOW_TYPE_RTP { label = "RTP" } else { label = "RTCP" diff --git a/streamer.go b/streamer.go index f462a11c..da0858dd 100644 --- a/streamer.go +++ b/streamer.go @@ -272,13 +272,13 @@ func (s *streamer) runUdp(conn *gortsplib.ConnClient) bool { var err error udplRtp, err = newStreamerUdpListener(s.p, rtpPort, s, i, - _TRACK_FLOW_RTP, publisherIp) + _TRACK_FLOW_TYPE_RTP, publisherIp) if err != nil { continue } udplRtcp, err = newStreamerUdpListener(s.p, rtcpPort, s, i, - _TRACK_FLOW_RTCP, publisherIp) + _TRACK_FLOW_TYPE_RTCP, publisherIp) if err != nil { udplRtp.close() continue @@ -606,7 +606,7 @@ outer: break } - trackId, trackFlowType := interleavedChannelToTrack(frame.Channel) + trackId, trackFlowType := interleavedChannelToTrackFlowType(frame.Channel) s.p.events <- programEventStreamerFrame{s, trackId, trackFlowType, frame.Content} } diff --git a/utils.go b/utils.go index 878537bb..4525734d 100644 --- a/utils.go +++ b/utils.go @@ -32,19 +32,19 @@ func parseIpCidrList(in []string) ([]interface{}, error) { type trackFlowType int const ( - _TRACK_FLOW_RTP trackFlowType = iota - _TRACK_FLOW_RTCP + _TRACK_FLOW_TYPE_RTP trackFlowType = iota + _TRACK_FLOW_TYPE_RTCP ) -func interleavedChannelToTrack(channel uint8) (int, trackFlowType) { +func interleavedChannelToTrackFlowType(channel uint8) (int, trackFlowType) { if (channel % 2) == 0 { - return int(channel / 2), _TRACK_FLOW_RTP + return int(channel / 2), _TRACK_FLOW_TYPE_RTP } - return int((channel - 1) / 2), _TRACK_FLOW_RTCP + return int((channel - 1) / 2), _TRACK_FLOW_TYPE_RTCP } -func trackToInterleavedChannel(id int, trackFlowType trackFlowType) uint8 { - if trackFlowType == _TRACK_FLOW_RTP { +func trackFlowTypeToInterleavedChannel(id int, trackFlowType trackFlowType) uint8 { + if trackFlowType == _TRACK_FLOW_TYPE_RTP { return uint8(id * 2) } return uint8((id * 2) + 1)