Skip to content
This repository has been archived by the owner on Nov 5, 2020. It is now read-only.

Commit

Permalink
support timeout in session header
Browse files Browse the repository at this point in the history
  • Loading branch information
aler9 committed Apr 10, 2020
1 parent 1873417 commit a4bd1df
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 9 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-20200313131835-13b7bffbba39
github.com/aler9/gortsplib v0.0.0-20200410165230-e085d60e5979
gopkg.in/alecthomas/kingpin.v2 v2.2.6
gopkg.in/yaml.v2 v2.2.2
gortc.io/sdp v0.17.0
Expand Down
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-20200313131835-13b7bffbba39 h1:9Vb9v7wBSp+mAtqb+5IJQRarQlycp2ksrv4wRrsMPZI=
github.com/aler9/gortsplib v0.0.0-20200313131835-13b7bffbba39/go.mod h1:YiIgmmv0ELkWUy11Jj2h5AgfqLCpy8sIX/l9MmS8+uw=
github.com/aler9/gortsplib v0.0.0-20200410165230-e085d60e5979 h1:8W+hVHm0tpNubksM0tPXb0+XS9RVA/PY3l/unU2xQDU=
github.com/aler9/gortsplib v0.0.0-20200410165230-e085d60e5979/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
27 changes: 21 additions & 6 deletions stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,13 @@ func (s *stream) run() {
return
}

if sx, ok := res.Header["Session"]; ok && len(sx) == 1 {
conn.SetSession(sx[0])
if sxRaw, ok := res.Header["Session"]; ok && len(sxRaw) == 1 {
sx, err := gortsplib.ReadHeaderSession(sxRaw[0])
if err != nil {
s.log("ERR: unable to parse session: %s", err)
return
}
conn.SetSession(sx.Session)
}

res, err = writeReqReadRes(conn, &gortsplib.Request{
Expand Down Expand Up @@ -383,8 +388,13 @@ func (s *stream) runUdp(conn *gortsplib.ConnClient) {
return
}

if sx, ok := res.Header["Session"]; ok && len(sx) == 1 {
conn.SetSession(sx[0])
if sxRaw, ok := res.Header["Session"]; ok && len(sxRaw) == 1 {
sx, err := gortsplib.ReadHeaderSession(sxRaw[0])
if err != nil {
s.log("ERR: unable to parse session: %s", err)
return
}
conn.SetSession(sx.Session)
}

tsRaw, ok := res.Header["Transport"]
Expand Down Expand Up @@ -546,8 +556,13 @@ func (s *stream) runTcp(conn *gortsplib.ConnClient) {
return
}

if sx, ok := res.Header["Session"]; ok && len(sx) == 1 {
conn.SetSession(sx[0])
if sxRaw, ok := res.Header["Session"]; ok && len(sxRaw) == 1 {
sx, err := gortsplib.ReadHeaderSession(sxRaw[0])
if err != nil {
s.log("ERR: unable to parse session: %s", err)
return
}
conn.SetSession(sx.Session)
}

if res.StatusCode != 200 {
Expand Down

0 comments on commit a4bd1df

Please sign in to comment.