Skip to content

Commit

Permalink
move url parsing into gortsplib
Browse files Browse the repository at this point in the history
  • Loading branch information
aler9 committed May 3, 2020
1 parent 02beefc commit 6cb36ab
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 16 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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-20200503140554-28603af339e6
github.com/aler9/gortsplib v0.0.0-20200503173001-aedfa068de59
gopkg.in/alecthomas/kingpin.v2 v2.2.6
gortc.io/sdp v0.17.0
)
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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-20200503140554-28603af339e6 h1:41jZy+JIekzJXtYdkCsW9ts7D4jubfEVyjMCl7QY2wY=
github.com/aler9/gortsplib v0.0.0-20200503140554-28603af339e6/go.mod h1:YiIgmmv0ELkWUy11Jj2h5AgfqLCpy8sIX/l9MmS8+uw=
github.com/aler9/gortsplib v0.0.0-20200503173001-aedfa068de59 h1:mcyCJ4cDQ/Wx53Jxce3MaeW3G0tOYMdAcXNRuEO4V9o=
github.com/aler9/gortsplib v0.0.0-20200503173001-aedfa068de59/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=
Expand Down
19 changes: 6 additions & 13 deletions server-client.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"io"
"log"
"net"
"net/url"
"os/exec"
"strconv"
"strings"
Expand Down Expand Up @@ -236,14 +235,8 @@ func (c *serverClient) handleRequest(req *gortsplib.Request) bool {
return false
}

ur, err := url.Parse(req.Url)
if err != nil {
c.writeResError(req, gortsplib.StatusBadRequest, fmt.Errorf("unable to parse path '%s'", req.Url))
return false
}

path := func() string {
ret := ur.Path
ret := req.Url.Path

// remove leading slash
if len(ret) > 1 {
Expand Down Expand Up @@ -306,7 +299,7 @@ func (c *serverClient) handleRequest(req *gortsplib.Request) bool {
StatusCode: gortsplib.StatusOK,
Header: gortsplib.Header{
"CSeq": []string{cseq[0]},
"Content-Base": []string{req.Url},
"Content-Base": []string{req.Url.String()},
"Content-Type": []string{"application/sdp"},
},
Content: sdp,
Expand Down Expand Up @@ -441,7 +434,7 @@ func (c *serverClient) handleRequest(req *gortsplib.Request) bool {
return false
}

err = func() error {
err := func() error {
c.p.mutex.Lock()
defer c.p.mutex.Unlock()

Expand Down Expand Up @@ -500,7 +493,7 @@ func (c *serverClient) handleRequest(req *gortsplib.Request) bool {
return false
}

err = func() error {
err := func() error {
c.p.mutex.Lock()
defer c.p.mutex.Unlock()

Expand Down Expand Up @@ -588,7 +581,7 @@ func (c *serverClient) handleRequest(req *gortsplib.Request) bool {
return false
}

err = func() error {
err := func() error {
c.p.mutex.Lock()
defer c.p.mutex.Unlock()

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

var interleaved string
err = func() error {
err := func() error {
c.p.mutex.Lock()
defer c.p.mutex.Unlock()

Expand Down

0 comments on commit 6cb36ab

Please sign in to comment.