From eb7bf2614bce675b00ffec6dd735a0ef06e66c59 Mon Sep 17 00:00:00 2001 From: aler9 <46489434+aler9@users.noreply.github.com> Date: Wed, 27 Oct 2021 19:15:22 +0200 Subject: [PATCH] remove duplicate methods --- server.go | 4 ++-- serversession.go | 22 +++++++--------------- serverstream.go | 6 +++--- 3 files changed, 12 insertions(+), 20 deletions(-) diff --git a/server.go b/server.go index 21c9c7a6..e82c76aa 100644 --- a/server.go +++ b/server.go @@ -363,8 +363,8 @@ outer: case req := <-s.sessionRequest: if ss, ok := s.sessions[req.id]; ok { - if !req.sc.ip().Equal(ss.ip()) || - req.sc.zone() != ss.zone() { + if !req.sc.ip().Equal(ss.author.ip()) || + req.sc.zone() != ss.author.zone() { req.res <- sessionRequestRes{ res: &base.Response{ StatusCode: base.StatusBadRequest, diff --git a/serversession.go b/serversession.go index d479a3e2..daf96f82 100644 --- a/serversession.go +++ b/serversession.go @@ -218,14 +218,6 @@ func (ss *ServerSession) AnnouncedTracks() []ServerSessionAnnouncedTrack { return ss.announcedTracks } -func (ss *ServerSession) ip() net.IP { - return ss.author.ip() -} - -func (ss *ServerSession) zone() string { - return ss.author.zone() -} - func (ss *ServerSession) checkState(allowed map[ServerSessionState]struct{}) error { if _, ok := allowed[ss.state]; ok { return nil @@ -849,7 +841,7 @@ func (ss *ServerSession) handleRequest(sc *ServerConn, req *base.Request) (*base case TransportUDP: for trackID, track := range ss.setuppedTracks { // readers can send RTCP packets - sc.s.udpRTCPListener.addClient(ss.ip(), track.udpRTCPPort, ss, trackID, false) + sc.s.udpRTCPListener.addClient(ss.author.ip(), track.udpRTCPPort, ss, trackID, false) // open the firewall by sending packets to the counterpart ss.WriteFrame(trackID, StreamTypeRTCP, @@ -923,8 +915,8 @@ func (ss *ServerSession) handleRequest(sc *ServerConn, req *base.Request) (*base switch *ss.setuppedTransport { case TransportUDP: for trackID, track := range ss.setuppedTracks { - ss.s.udpRTPListener.addClient(ss.ip(), track.udpRTPPort, ss, trackID, true) - ss.s.udpRTCPListener.addClient(ss.ip(), track.udpRTCPPort, ss, trackID, true) + ss.s.udpRTPListener.addClient(ss.author.ip(), track.udpRTPPort, ss, trackID, true) + ss.s.udpRTCPListener.addClient(ss.author.ip(), track.udpRTCPPort, ss, trackID, true) // open the firewall by sending packets to the counterpart ss.WriteFrame(trackID, StreamTypeRTP, @@ -1069,14 +1061,14 @@ func (ss *ServerSession) WriteFrame(trackID int, streamType StreamType, payload if streamType == StreamTypeRTP { ss.s.udpRTPListener.write(payload, &net.UDPAddr{ - IP: ss.ip(), - Zone: ss.zone(), + IP: ss.author.ip(), + Zone: ss.author.zone(), Port: track.udpRTPPort, }) } else { ss.s.udpRTCPListener.write(payload, &net.UDPAddr{ - IP: ss.ip(), - Zone: ss.zone(), + IP: ss.author.ip(), + Zone: ss.author.zone(), Port: track.udpRTCPPort, }) } diff --git a/serverstream.go b/serverstream.go index bdb0ad4e..ad2e5702 100644 --- a/serverstream.go +++ b/serverstream.go @@ -132,8 +132,8 @@ func (st *ServerStream) readerAdd( // check whether client ports are already in use by another reader. for r := range st.readersUnicast { if *r.setuppedTransport == TransportUDP && - r.ip().Equal(ss.ip()) && - r.zone() == ss.zone() { + r.author.ip().Equal(ss.author.ip()) && + r.author.zone() == ss.author.zone() { for _, rt := range r.setuppedTracks { if rt.udpRTPPort == clientPorts[0] { return liberrors.ErrServerUDPPortsAlreadyInUse{Port: rt.udpRTPPort} @@ -199,7 +199,7 @@ func (st *ServerStream) readerSetActive(ss *ServerSession) { default: // UDPMulticast for trackID := range ss.setuppedTracks { st.multicastListeners[trackID].rtcpListener.addClient( - ss.ip(), st.multicastListeners[trackID].rtcpListener.port(), ss, trackID, false) + ss.author.ip(), st.multicastListeners[trackID].rtcpListener.port(), ss, trackID, false) } } }