mirror of
https://github.com/aler9/gortsplib
synced 2025-10-06 15:46:51 +08:00
remove pointer from Write() methods
This commit is contained in:
@@ -408,11 +408,11 @@ func (c *ClientConn) Setup(mode headers.TransportMode, track *Track,
|
|||||||
return StreamProtocolUDP
|
return StreamProtocolUDP
|
||||||
}()
|
}()
|
||||||
|
|
||||||
transport := &headers.Transport{
|
th := headers.Transport{
|
||||||
Protocol: proto,
|
Protocol: proto,
|
||||||
Delivery: func() *base.StreamDelivery {
|
Delivery: func() *base.StreamDelivery {
|
||||||
ret := base.StreamDeliveryUnicast
|
v := base.StreamDeliveryUnicast
|
||||||
return &ret
|
return &v
|
||||||
}(),
|
}(),
|
||||||
Mode: &mode,
|
Mode: &mode,
|
||||||
}
|
}
|
||||||
@@ -469,10 +469,10 @@ func (c *ClientConn) Setup(mode headers.TransportMode, track *Track,
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
transport.ClientPorts = &[2]int{rtpPort, rtcpPort}
|
th.ClientPorts = &[2]int{rtpPort, rtcpPort}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
transport.InterleavedIds = &[2]int{(track.ID * 2), (track.ID * 2) + 1}
|
th.InterleavedIds = &[2]int{(track.ID * 2), (track.ID * 2) + 1}
|
||||||
}
|
}
|
||||||
|
|
||||||
trackURL, err := track.URL()
|
trackURL, err := track.URL()
|
||||||
@@ -488,7 +488,7 @@ func (c *ClientConn) Setup(mode headers.TransportMode, track *Track,
|
|||||||
Method: base.Setup,
|
Method: base.Setup,
|
||||||
URL: trackURL,
|
URL: trackURL,
|
||||||
Header: base.Header{
|
Header: base.Header{
|
||||||
"Transport": transport.Write(),
|
"Transport": th.Write(),
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -519,7 +519,7 @@ func (c *ClientConn) Setup(mode headers.TransportMode, track *Track,
|
|||||||
return res, fmt.Errorf("bad status code: %d (%s)", res.StatusCode, res.StatusMessage)
|
return res, fmt.Errorf("bad status code: %d (%s)", res.StatusCode, res.StatusMessage)
|
||||||
}
|
}
|
||||||
|
|
||||||
th, err := headers.ReadTransport(res.Header["Transport"])
|
thRes, err := headers.ReadTransport(res.Header["Transport"])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if proto == StreamProtocolUDP {
|
if proto == StreamProtocolUDP {
|
||||||
rtpListener.close()
|
rtpListener.close()
|
||||||
@@ -529,18 +529,18 @@ func (c *ClientConn) Setup(mode headers.TransportMode, track *Track,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if proto == StreamProtocolUDP {
|
if proto == StreamProtocolUDP {
|
||||||
if th.ServerPorts == nil {
|
if thRes.ServerPorts == nil {
|
||||||
rtpListener.close()
|
rtpListener.close()
|
||||||
rtcpListener.close()
|
rtcpListener.close()
|
||||||
return nil, fmt.Errorf("server ports not provided")
|
return nil, fmt.Errorf("server ports not provided")
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if th.InterleavedIds == nil ||
|
if thRes.InterleavedIds == nil ||
|
||||||
(*th.InterleavedIds)[0] != (*transport.InterleavedIds)[0] ||
|
(*thRes.InterleavedIds)[0] != (*th.InterleavedIds)[0] ||
|
||||||
(*th.InterleavedIds)[1] != (*transport.InterleavedIds)[1] {
|
(*thRes.InterleavedIds)[1] != (*th.InterleavedIds)[1] {
|
||||||
return nil, fmt.Errorf("transport header does not have interleaved ids %v (%s)",
|
return nil, fmt.Errorf("transport header does not have interleaved ids %v (%s)",
|
||||||
*transport.InterleavedIds, res.Header["Transport"])
|
*th.InterleavedIds, res.Header["Transport"])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -564,14 +564,14 @@ func (c *ClientConn) Setup(mode headers.TransportMode, track *Track,
|
|||||||
if proto == StreamProtocolUDP {
|
if proto == StreamProtocolUDP {
|
||||||
rtpListener.remoteIP = c.nconn.RemoteAddr().(*net.TCPAddr).IP
|
rtpListener.remoteIP = c.nconn.RemoteAddr().(*net.TCPAddr).IP
|
||||||
rtpListener.remoteZone = c.nconn.RemoteAddr().(*net.TCPAddr).Zone
|
rtpListener.remoteZone = c.nconn.RemoteAddr().(*net.TCPAddr).Zone
|
||||||
rtpListener.remotePort = (*th.ServerPorts)[0]
|
rtpListener.remotePort = (*thRes.ServerPorts)[0]
|
||||||
rtpListener.trackID = track.ID
|
rtpListener.trackID = track.ID
|
||||||
rtpListener.streamType = StreamTypeRtp
|
rtpListener.streamType = StreamTypeRtp
|
||||||
c.udpRtpListeners[track.ID] = rtpListener
|
c.udpRtpListeners[track.ID] = rtpListener
|
||||||
|
|
||||||
rtcpListener.remoteIP = c.nconn.RemoteAddr().(*net.TCPAddr).IP
|
rtcpListener.remoteIP = c.nconn.RemoteAddr().(*net.TCPAddr).IP
|
||||||
rtcpListener.remoteZone = c.nconn.RemoteAddr().(*net.TCPAddr).Zone
|
rtcpListener.remoteZone = c.nconn.RemoteAddr().(*net.TCPAddr).Zone
|
||||||
rtcpListener.remotePort = (*th.ServerPorts)[1]
|
rtcpListener.remotePort = (*thRes.ServerPorts)[1]
|
||||||
rtcpListener.trackID = track.ID
|
rtcpListener.trackID = track.ID
|
||||||
rtcpListener.streamType = StreamTypeRtcp
|
rtcpListener.streamType = StreamTypeRtcp
|
||||||
c.udpRtcpListeners[track.ID] = rtcpListener
|
c.udpRtcpListeners[track.ID] = rtcpListener
|
||||||
|
@@ -99,14 +99,14 @@ func (ac *Client) GenerateHeader(method base.Method, ur *base.URL) base.HeaderVa
|
|||||||
response := md5Hex(md5Hex(ac.user+":"+ac.realm+":"+ac.pass) + ":" +
|
response := md5Hex(md5Hex(ac.user+":"+ac.realm+":"+ac.pass) + ":" +
|
||||||
ac.nonce + ":" + md5Hex(string(method)+":"+urStr))
|
ac.nonce + ":" + md5Hex(string(method)+":"+urStr))
|
||||||
|
|
||||||
return (&headers.Auth{
|
return headers.Auth{
|
||||||
Method: headers.AuthDigest,
|
Method: headers.AuthDigest,
|
||||||
Username: &ac.user,
|
Username: &ac.user,
|
||||||
Realm: &ac.realm,
|
Realm: &ac.realm,
|
||||||
Nonce: &ac.nonce,
|
Nonce: &ac.nonce,
|
||||||
URI: &urStr,
|
URI: &urStr,
|
||||||
Response: &response,
|
Response: &response,
|
||||||
}).Write()
|
}.Write()
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
@@ -53,11 +53,11 @@ func (as *Server) GenerateHeader() base.HeaderValue {
|
|||||||
}).Write()...)
|
}).Write()...)
|
||||||
|
|
||||||
case headers.AuthDigest:
|
case headers.AuthDigest:
|
||||||
ret = append(ret, (&headers.Auth{
|
ret = append(ret, headers.Auth{
|
||||||
Method: headers.AuthDigest,
|
Method: headers.AuthDigest,
|
||||||
Realm: &as.realm,
|
Realm: &as.realm,
|
||||||
Nonce: &as.nonce,
|
Nonce: &as.nonce,
|
||||||
}).Write()...)
|
}.Write()...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ret
|
return ret
|
||||||
|
@@ -168,7 +168,7 @@ func ReadAuth(v base.HeaderValue) (*Auth, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Write encodes an Authenticate or a WWW-Authenticate header.
|
// Write encodes an Authenticate or a WWW-Authenticate header.
|
||||||
func (ha *Auth) Write() base.HeaderValue {
|
func (ha Auth) Write() base.HeaderValue {
|
||||||
ret := ""
|
ret := ""
|
||||||
|
|
||||||
switch ha.Method {
|
switch ha.Method {
|
||||||
|
@@ -63,7 +63,7 @@ func ReadSession(v base.HeaderValue) (*Session, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Write encodes a Session header
|
// Write encodes a Session header
|
||||||
func (hs *Session) Write() base.HeaderValue {
|
func (hs Session) Write() base.HeaderValue {
|
||||||
val := hs.Session
|
val := hs.Session
|
||||||
|
|
||||||
if hs.Timeout != nil {
|
if hs.Timeout != nil {
|
||||||
|
@@ -201,7 +201,7 @@ func ReadTransport(v base.HeaderValue) (*Transport, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Write encodes a Transport header
|
// Write encodes a Transport header
|
||||||
func (ht *Transport) Write() base.HeaderValue {
|
func (ht Transport) Write() base.HeaderValue {
|
||||||
var vals []string
|
var vals []string
|
||||||
|
|
||||||
if ht.Protocol == base.StreamProtocolUDP {
|
if ht.Protocol == base.StreamProtocolUDP {
|
||||||
|
Reference in New Issue
Block a user