Skip to content

Commit 45c0416

Browse files
committed
use a custom sdp library to handle non-canonical sdp (#41)
1 parent bed388d commit 45c0416

File tree

7 files changed

+26
-17
lines changed

7 files changed

+26
-17
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,8 @@ make run
172172
Related projects
173173
* https://github.com/aler9/gortsplib
174174
* https://github.com/flaviostutz/rtsp-relay
175+
* https://github.com/pion/sdp (SDP library used internally)
176+
* https://github.com/pion/rtcp (RTCP library used internally)
175177

176178
IETF Standards
177179
* RTSP 1.0 https://tools.ietf.org/html/rfc2326

go.mod

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ 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-20200718114958-1d365c8c9369
9-
github.com/pion/sdp v1.3.0
10-
github.com/stretchr/testify v1.5.1
8+
github.com/aler9/gortsplib v0.0.0-20200719094715-6806ec79c031
9+
github.com/aler9/sdp/v3 v3.0.0-20200719093237-2c3d108a7436
10+
github.com/stretchr/testify v1.6.1
1111
gopkg.in/alecthomas/kingpin.v2 v2.2.6
1212
gopkg.in/yaml.v2 v2.2.2
1313
)

go.sum

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,30 @@ 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-20200718114958-1d365c8c9369 h1:7t451d8q3yYtUwQM6GqJPCek13BC0yeh0tQqWrxyuck=
6-
github.com/aler9/gortsplib v0.0.0-20200718114958-1d365c8c9369/go.mod h1:17dcA4Qak5TLqgun8OR0wnSbFQIg4cvYVSf1nbCt+qU=
5+
github.com/aler9/gortsplib v0.0.0-20200719094715-6806ec79c031 h1:Kb+H1mkbmzbAIcX0++A8kHwdhpQiNe6reFcWNUATcVk=
6+
github.com/aler9/gortsplib v0.0.0-20200719094715-6806ec79c031/go.mod h1:kBMvjIdOHRjLdV+oT28JD72JUPpJuwxOc9u72GG8GpY=
7+
github.com/aler9/sdp/v3 v3.0.0-20200719093237-2c3d108a7436 h1:W0iNErWKvSAyJBNVx+qQoyFrWOFVgS6f/WEME/D3EZc=
8+
github.com/aler9/sdp/v3 v3.0.0-20200719093237-2c3d108a7436/go.mod h1:OnlEK3QI7YtM+ShZWtGajmOHLZ3bjU80AcIS5e34i1U=
79
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
810
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
11+
github.com/pion/randutil v0.1.0 h1:CFG1UdESneORglEsnimhUjf33Rwjubwj6xfiOXBa3mA=
12+
github.com/pion/randutil v0.1.0/go.mod h1:XcJrSMMbbMRhASFVOlj/5hQial/Y8oH/HVo7TBZq+j8=
913
github.com/pion/rtcp v1.2.3 h1:2wrhKnqgSz91Q5nzYTO07mQXztYPtxL8a0XOss4rJqA=
1014
github.com/pion/rtcp v1.2.3/go.mod h1:zGhIv0RPRF0Z1Wiij22pUt5W/c9fevqSzT4jje/oK7I=
11-
github.com/pion/sdp v1.3.0 h1:21lpgEILHyolpsIrbCBagZaAPj4o057cFjzaFebkVOs=
12-
github.com/pion/sdp v1.3.0/go.mod h1:ceA2lTyftydQTuCIbUNoH77aAt6CiQJaRpssA4Gee8I=
13-
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
14-
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
1515
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
1616
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
1717
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
1818
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
1919
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
2020
github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4=
2121
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
22+
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
23+
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
2224
gopkg.in/alecthomas/kingpin.v2 v2.2.6 h1:jMFz6MfLP0/4fUyZle81rXUoxOBFi19VUFKVDOQfozc=
2325
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
2426
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
2527
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
2628
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
2729
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
30+
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
31+
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"os"
1111

1212
"github.com/aler9/gortsplib"
13-
"github.com/pion/sdp"
13+
"github.com/aler9/sdp/v3"
1414
"gopkg.in/alecthomas/kingpin.v2"
1515
)
1616

server-client.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
"time"
1212

1313
"github.com/aler9/gortsplib"
14-
"github.com/pion/sdp"
14+
"github.com/aler9/sdp/v3"
1515
)
1616

1717
const (
@@ -405,7 +405,7 @@ func (c *serverClient) handleRequest(req *gortsplib.Request) bool {
405405
}
406406

407407
sdpParsed := &sdp.SessionDescription{}
408-
err = sdpParsed.Unmarshal(string(req.Content))
408+
err = sdpParsed.Unmarshal(req.Content)
409409
if err != nil {
410410
c.writeResError(req, gortsplib.StatusBadRequest, fmt.Errorf("invalid SDP: %s", err))
411411
return false

source.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"time"
99

1010
"github.com/aler9/gortsplib"
11-
"github.com/pion/sdp"
11+
"github.com/aler9/sdp/v3"
1212
)
1313

1414
const (

utils.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"strconv"
77

88
"github.com/aler9/gortsplib"
9-
"github.com/pion/sdp"
9+
"github.com/aler9/sdp/v3"
1010
)
1111

1212
func parseIpCidrList(in []string) ([]interface{}, error) {
@@ -76,8 +76,11 @@ func (db *doubleBuffer) swap() []byte {
7676

7777
func sdpForServer(tracks []*gortsplib.Track) (*sdp.SessionDescription, []byte) {
7878
sout := &sdp.SessionDescription{
79-
SessionName: "Stream",
80-
Origin: sdp.Origin{
79+
SessionName: func() *sdp.SessionName {
80+
ret := sdp.SessionName("Stream")
81+
return &ret
82+
}(),
83+
Origin: &sdp.Origin{
8184
Username: "-",
8285
NetworkType: "IN",
8386
AddressType: "IP4",
@@ -118,6 +121,6 @@ func sdpForServer(tracks []*gortsplib.Track) (*sdp.SessionDescription, []byte) {
118121
sout.MediaDescriptions = append(sout.MediaDescriptions, mout)
119122
}
120123

121-
bytsout := []byte(sout.Marshal())
124+
bytsout, _ := sout.Marshal()
122125
return sout, bytsout
123126
}

0 commit comments

Comments
 (0)