update gortsplib

This commit is contained in:
aler9 2020-01-20 16:44:02 +01:00
parent 18451c1431
commit f69700a738
4 changed files with 19 additions and 19 deletions

View File

@ -39,7 +39,7 @@ const (
type client struct {
p *program
rconn *gortsplib.Conn
conn *gortsplib.Conn
state clientState
ip net.IP
path string
@ -52,7 +52,7 @@ type client struct {
func newClient(p *program, nconn net.Conn) *client {
c := &client{
p: p,
rconn: gortsplib.NewConn(nconn),
conn: gortsplib.NewConn(nconn),
state: _CLIENT_STATE_STARTING,
}
@ -70,7 +70,7 @@ func (c *client) close() error {
}
delete(c.p.clients, c)
c.rconn.Close()
c.conn.NetConn().Close()
if c.path != "" {
if pub, ok := c.p.publishers[c.path]; ok && pub == c {
@ -89,7 +89,7 @@ func (c *client) close() error {
}
func (c *client) log(format string, args ...interface{}) {
format = "[RTSP client " + c.rconn.RemoteAddr().String() + "] " + format
format = "[RTSP client " + c.conn.NetConn().RemoteAddr().String() + "] " + format
log.Printf(format, args...)
}
@ -101,13 +101,13 @@ func (c *client) run() {
c.close()
}()
ipstr, _, _ := net.SplitHostPort(c.rconn.RemoteAddr().String())
ipstr, _, _ := net.SplitHostPort(c.conn.NetConn().RemoteAddr().String())
c.ip = net.ParseIP(ipstr)
c.log("connected")
for {
req, err := c.rconn.ReadRequest()
req, err := c.conn.ReadRequest()
if err != nil {
if err != io.EOF {
c.log("ERR: %s", err)
@ -123,14 +123,14 @@ func (c *client) run() {
}
func (c *client) writeRes(res *gortsplib.Response) {
c.rconn.WriteResponse(res)
c.conn.WriteResponse(res)
}
func (c *client) writeResError(req *gortsplib.Request, err error) {
c.log("ERR: %s", err)
if cseq, ok := req.Headers["CSeq"]; ok {
c.rconn.WriteResponse(&gortsplib.Response{
c.conn.WriteResponse(&gortsplib.Response{
StatusCode: 400,
Status: "Bad Request",
Headers: map[string]string{
@ -138,7 +138,7 @@ func (c *client) writeResError(req *gortsplib.Request, err error) {
},
})
} else {
c.rconn.WriteResponse(&gortsplib.Response{
c.conn.WriteResponse(&gortsplib.Response{
StatusCode: 400,
Status: "Bad Request",
})
@ -353,7 +353,7 @@ func (c *client) handleRequest(req *gortsplib.Request) bool {
}() {
if _, ok := c.p.protocols[_STREAM_PROTOCOL_UDP]; !ok {
c.log("ERR: udp streaming is disabled")
c.rconn.WriteResponse(&gortsplib.Response{
c.conn.WriteResponse(&gortsplib.Response{
StatusCode: 461,
Status: "Unsupported Transport",
Headers: map[string]string{
@ -426,7 +426,7 @@ func (c *client) handleRequest(req *gortsplib.Request) bool {
} else if _, ok := th["RTP/AVP/TCP"]; ok {
if _, ok := c.p.protocols[_STREAM_PROTOCOL_TCP]; !ok {
c.log("ERR: tcp streaming is disabled")
c.rconn.WriteResponse(&gortsplib.Response{
c.conn.WriteResponse(&gortsplib.Response{
StatusCode: 461,
Status: "Unsupported Transport",
Headers: map[string]string{
@ -521,7 +521,7 @@ func (c *client) handleRequest(req *gortsplib.Request) bool {
}() {
if _, ok := c.p.protocols[_STREAM_PROTOCOL_UDP]; !ok {
c.log("ERR: udp streaming is disabled")
c.rconn.WriteResponse(&gortsplib.Response{
c.conn.WriteResponse(&gortsplib.Response{
StatusCode: 461,
Status: "Unsupported Transport",
Headers: map[string]string{
@ -583,7 +583,7 @@ func (c *client) handleRequest(req *gortsplib.Request) bool {
} else if _, ok := th["RTP/AVP/TCP"]; ok {
if _, ok := c.p.protocols[_STREAM_PROTOCOL_TCP]; !ok {
c.log("ERR: tcp streaming is disabled")
c.rconn.WriteResponse(&gortsplib.Response{
c.conn.WriteResponse(&gortsplib.Response{
StatusCode: 461,
Status: "Unsupported Transport",
Headers: map[string]string{
@ -714,7 +714,7 @@ func (c *client) handleRequest(req *gortsplib.Request) bool {
if c.streamProtocol == _STREAM_PROTOCOL_TCP {
buf := make([]byte, 2048)
for {
_, err := c.rconn.Read(buf)
_, err := c.conn.NetConn().Read(buf)
if err != nil {
if err != io.EOF {
c.log("ERR: %s", err)
@ -804,7 +804,7 @@ func (c *client) handleRequest(req *gortsplib.Request) bool {
if c.streamProtocol == _STREAM_PROTOCOL_TCP {
buf := make([]byte, 2048)
for {
channel, n, err := c.rconn.ReadInterleavedFrame(buf)
channel, n, err := c.conn.ReadInterleavedFrame(buf)
if err != nil {
if _, ok := err.(*net.OpError); ok {
} else if err == io.EOF {

2
go.mod
View File

@ -5,7 +5,7 @@ go 1.13
require (
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 // indirect
github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d // indirect
github.com/aler9/gortsplib v0.0.0-20200120114552-70d65410783c
github.com/aler9/gortsplib v0.0.0-20200120153915-7c3176da7fca
gopkg.in/alecthomas/kingpin.v2 v2.2.6
gortc.io/sdp v0.17.0
)

4
go.sum
View File

@ -2,8 +2,8 @@ github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 h1:JYp7IbQjafo
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d h1:UQZhZ2O0vMHr2cI+DC1Mbh0TJxzA3RcLoMsFw+aXw7E=
github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho=
github.com/aler9/gortsplib v0.0.0-20200120114552-70d65410783c h1:DPTdhbN9SSQgKt6m6/eWbRLok4kA/1NhklNaGM43nqY=
github.com/aler9/gortsplib v0.0.0-20200120114552-70d65410783c/go.mod h1:YiIgmmv0ELkWUy11Jj2h5AgfqLCpy8sIX/l9MmS8+uw=
github.com/aler9/gortsplib v0.0.0-20200120153915-7c3176da7fca h1:s/ofz/a7G7vChSpBgRnYhGFHtYZdVCYPfWJT75pZWAY=
github.com/aler9/gortsplib v0.0.0-20200120153915-7c3176da7fca/go.mod h1:YiIgmmv0ELkWUy11Jj2h5AgfqLCpy8sIX/l9MmS8+uw=
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/pkg/errors v0.8.0 h1:WdK/asTD0HN+q6hsWO3/vpuAkAr+tw6aNJNDFFf0+qw=

View File

@ -136,7 +136,7 @@ func (p *program) forwardTrack(path string, id int, flow trackFlow, frame []byte
}
} else {
c.rconn.WriteInterleavedFrame(trackToInterleavedChannel(id, flow), frame)
c.conn.WriteInterleavedFrame(trackToInterleavedChannel(id, flow), frame)
}
}
}