mirror of
https://github.com/aler9/gortsplib
synced 2025-10-04 23:02:45 +08:00
remove duplicate methods
This commit is contained in:
@@ -363,8 +363,8 @@ outer:
|
|||||||
|
|
||||||
case req := <-s.sessionRequest:
|
case req := <-s.sessionRequest:
|
||||||
if ss, ok := s.sessions[req.id]; ok {
|
if ss, ok := s.sessions[req.id]; ok {
|
||||||
if !req.sc.ip().Equal(ss.ip()) ||
|
if !req.sc.ip().Equal(ss.author.ip()) ||
|
||||||
req.sc.zone() != ss.zone() {
|
req.sc.zone() != ss.author.zone() {
|
||||||
req.res <- sessionRequestRes{
|
req.res <- sessionRequestRes{
|
||||||
res: &base.Response{
|
res: &base.Response{
|
||||||
StatusCode: base.StatusBadRequest,
|
StatusCode: base.StatusBadRequest,
|
||||||
|
@@ -218,14 +218,6 @@ func (ss *ServerSession) AnnouncedTracks() []ServerSessionAnnouncedTrack {
|
|||||||
return ss.announcedTracks
|
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 {
|
func (ss *ServerSession) checkState(allowed map[ServerSessionState]struct{}) error {
|
||||||
if _, ok := allowed[ss.state]; ok {
|
if _, ok := allowed[ss.state]; ok {
|
||||||
return nil
|
return nil
|
||||||
@@ -849,7 +841,7 @@ func (ss *ServerSession) handleRequest(sc *ServerConn, req *base.Request) (*base
|
|||||||
case TransportUDP:
|
case TransportUDP:
|
||||||
for trackID, track := range ss.setuppedTracks {
|
for trackID, track := range ss.setuppedTracks {
|
||||||
// readers can send RTCP packets
|
// 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
|
// open the firewall by sending packets to the counterpart
|
||||||
ss.WriteFrame(trackID, StreamTypeRTCP,
|
ss.WriteFrame(trackID, StreamTypeRTCP,
|
||||||
@@ -923,8 +915,8 @@ func (ss *ServerSession) handleRequest(sc *ServerConn, req *base.Request) (*base
|
|||||||
switch *ss.setuppedTransport {
|
switch *ss.setuppedTransport {
|
||||||
case TransportUDP:
|
case TransportUDP:
|
||||||
for trackID, track := range ss.setuppedTracks {
|
for trackID, track := range ss.setuppedTracks {
|
||||||
ss.s.udpRTPListener.addClient(ss.ip(), track.udpRTPPort, ss, trackID, true)
|
ss.s.udpRTPListener.addClient(ss.author.ip(), track.udpRTPPort, ss, trackID, true)
|
||||||
ss.s.udpRTCPListener.addClient(ss.ip(), track.udpRTCPPort, ss, trackID, true)
|
ss.s.udpRTCPListener.addClient(ss.author.ip(), track.udpRTCPPort, ss, trackID, true)
|
||||||
|
|
||||||
// open the firewall by sending packets to the counterpart
|
// open the firewall by sending packets to the counterpart
|
||||||
ss.WriteFrame(trackID, StreamTypeRTP,
|
ss.WriteFrame(trackID, StreamTypeRTP,
|
||||||
@@ -1069,14 +1061,14 @@ func (ss *ServerSession) WriteFrame(trackID int, streamType StreamType, payload
|
|||||||
|
|
||||||
if streamType == StreamTypeRTP {
|
if streamType == StreamTypeRTP {
|
||||||
ss.s.udpRTPListener.write(payload, &net.UDPAddr{
|
ss.s.udpRTPListener.write(payload, &net.UDPAddr{
|
||||||
IP: ss.ip(),
|
IP: ss.author.ip(),
|
||||||
Zone: ss.zone(),
|
Zone: ss.author.zone(),
|
||||||
Port: track.udpRTPPort,
|
Port: track.udpRTPPort,
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
ss.s.udpRTCPListener.write(payload, &net.UDPAddr{
|
ss.s.udpRTCPListener.write(payload, &net.UDPAddr{
|
||||||
IP: ss.ip(),
|
IP: ss.author.ip(),
|
||||||
Zone: ss.zone(),
|
Zone: ss.author.zone(),
|
||||||
Port: track.udpRTCPPort,
|
Port: track.udpRTCPPort,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@@ -132,8 +132,8 @@ func (st *ServerStream) readerAdd(
|
|||||||
// check whether client ports are already in use by another reader.
|
// check whether client ports are already in use by another reader.
|
||||||
for r := range st.readersUnicast {
|
for r := range st.readersUnicast {
|
||||||
if *r.setuppedTransport == TransportUDP &&
|
if *r.setuppedTransport == TransportUDP &&
|
||||||
r.ip().Equal(ss.ip()) &&
|
r.author.ip().Equal(ss.author.ip()) &&
|
||||||
r.zone() == ss.zone() {
|
r.author.zone() == ss.author.zone() {
|
||||||
for _, rt := range r.setuppedTracks {
|
for _, rt := range r.setuppedTracks {
|
||||||
if rt.udpRTPPort == clientPorts[0] {
|
if rt.udpRTPPort == clientPorts[0] {
|
||||||
return liberrors.ErrServerUDPPortsAlreadyInUse{Port: rt.udpRTPPort}
|
return liberrors.ErrServerUDPPortsAlreadyInUse{Port: rt.udpRTPPort}
|
||||||
@@ -199,7 +199,7 @@ func (st *ServerStream) readerSetActive(ss *ServerSession) {
|
|||||||
default: // UDPMulticast
|
default: // UDPMulticast
|
||||||
for trackID := range ss.setuppedTracks {
|
for trackID := range ss.setuppedTracks {
|
||||||
st.multicastListeners[trackID].rtcpListener.addClient(
|
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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user