Skip to content

Commit 6cb36ab

Browse files
committed
move url parsing into gortsplib
1 parent 02beefc commit 6cb36ab

File tree

3 files changed

+9
-16
lines changed

3 files changed

+9
-16
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ go 1.13
55
require (
66
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 // indirect
77
github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d // indirect
8-
github.com/aler9/gortsplib v0.0.0-20200503140554-28603af339e6
8+
github.com/aler9/gortsplib v0.0.0-20200503173001-aedfa068de59
99
gopkg.in/alecthomas/kingpin.v2 v2.2.6
1010
gortc.io/sdp v0.17.0
1111
)

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 h1:JYp7IbQjafo
22
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
33
github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d h1:UQZhZ2O0vMHr2cI+DC1Mbh0TJxzA3RcLoMsFw+aXw7E=
44
github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho=
5-
github.com/aler9/gortsplib v0.0.0-20200503140554-28603af339e6 h1:41jZy+JIekzJXtYdkCsW9ts7D4jubfEVyjMCl7QY2wY=
6-
github.com/aler9/gortsplib v0.0.0-20200503140554-28603af339e6/go.mod h1:YiIgmmv0ELkWUy11Jj2h5AgfqLCpy8sIX/l9MmS8+uw=
5+
github.com/aler9/gortsplib v0.0.0-20200503173001-aedfa068de59 h1:mcyCJ4cDQ/Wx53Jxce3MaeW3G0tOYMdAcXNRuEO4V9o=
6+
github.com/aler9/gortsplib v0.0.0-20200503173001-aedfa068de59/go.mod h1:YiIgmmv0ELkWUy11Jj2h5AgfqLCpy8sIX/l9MmS8+uw=
77
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
88
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
99
github.com/pkg/errors v0.8.0 h1:WdK/asTD0HN+q6hsWO3/vpuAkAr+tw6aNJNDFFf0+qw=

server-client.go

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"io"
66
"log"
77
"net"
8-
"net/url"
98
"os/exec"
109
"strconv"
1110
"strings"
@@ -236,14 +235,8 @@ func (c *serverClient) handleRequest(req *gortsplib.Request) bool {
236235
return false
237236
}
238237

239-
ur, err := url.Parse(req.Url)
240-
if err != nil {
241-
c.writeResError(req, gortsplib.StatusBadRequest, fmt.Errorf("unable to parse path '%s'", req.Url))
242-
return false
243-
}
244-
245238
path := func() string {
246-
ret := ur.Path
239+
ret := req.Url.Path
247240

248241
// remove leading slash
249242
if len(ret) > 1 {
@@ -306,7 +299,7 @@ func (c *serverClient) handleRequest(req *gortsplib.Request) bool {
306299
StatusCode: gortsplib.StatusOK,
307300
Header: gortsplib.Header{
308301
"CSeq": []string{cseq[0]},
309-
"Content-Base": []string{req.Url},
302+
"Content-Base": []string{req.Url.String()},
310303
"Content-Type": []string{"application/sdp"},
311304
},
312305
Content: sdp,
@@ -441,7 +434,7 @@ func (c *serverClient) handleRequest(req *gortsplib.Request) bool {
441434
return false
442435
}
443436

444-
err = func() error {
437+
err := func() error {
445438
c.p.mutex.Lock()
446439
defer c.p.mutex.Unlock()
447440

@@ -500,7 +493,7 @@ func (c *serverClient) handleRequest(req *gortsplib.Request) bool {
500493
return false
501494
}
502495

503-
err = func() error {
496+
err := func() error {
504497
c.p.mutex.Lock()
505498
defer c.p.mutex.Unlock()
506499

@@ -588,7 +581,7 @@ func (c *serverClient) handleRequest(req *gortsplib.Request) bool {
588581
return false
589582
}
590583

591-
err = func() error {
584+
err := func() error {
592585
c.p.mutex.Lock()
593586
defer c.p.mutex.Unlock()
594587

@@ -637,7 +630,7 @@ func (c *serverClient) handleRequest(req *gortsplib.Request) bool {
637630
}
638631

639632
var interleaved string
640-
err = func() error {
633+
err := func() error {
641634
c.p.mutex.Lock()
642635
defer c.p.mutex.Unlock()
643636

0 commit comments

Comments
 (0)