remove sdp

This commit is contained in:
aler9
2020-07-12 14:57:34 +02:00
parent fb7d7b008e
commit c87fdcdbff
3 changed files with 1 additions and 85 deletions

5
go.mod
View File

@@ -2,7 +2,4 @@ module github.com/aler9/gortsplib
go 1.13
require (
github.com/stretchr/testify v1.4.0
gortc.io/sdp v0.18.2
)
require github.com/stretchr/testify v1.4.0

4
go.sum
View File

@@ -1,7 +1,5 @@
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.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
@@ -11,5 +9,3 @@ gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gortc.io/sdp v0.18.2 h1:w2L1h9rgMZwGQz/bYMxTQ36POQ114ETpYUX1pFfSsLg=
gortc.io/sdp v0.18.2/go.mod h1:Oj8tpRIx+Zx6lyrQR9+HHegByfbaz92A9wPSWrQhTI4=

77
sdp.go
View File

@@ -1,77 +0,0 @@
package gortsplib
import (
"fmt"
"strconv"
"gortc.io/sdp"
)
// SDPParse parses a SDP document.
func SDPParse(in []byte) (*sdp.Message, error) {
s, err := sdp.DecodeSession(in, nil)
if err != nil {
return nil, err
}
m := &sdp.Message{}
d := sdp.NewDecoder(s)
err = d.Decode(m)
if err != nil {
// allow empty Origins
if err.Error() != "failed to decode message: DecodeError in section s: origin address not set" {
return nil, err
}
}
if len(m.Medias) == 0 {
return nil, fmt.Errorf("no tracks defined")
}
return m, nil
}
// SDPFilter removes everything from a SDP document, except the bare minimum.
func SDPFilter(msgIn *sdp.Message, byteIn []byte) (*sdp.Message, []byte) {
msgOut := &sdp.Message{}
msgOut.Name = "Stream"
msgOut.Origin = sdp.Origin{
Username: "-",
NetworkType: "IN",
AddressType: "IP4",
Address: "127.0.0.1",
}
for i, m := range msgIn.Medias {
var attributes []sdp.Attribute
for _, attr := range m.Attributes {
if attr.Key == "rtpmap" || attr.Key == "fmtp" {
attributes = append(attributes, attr)
}
}
// control attribute is mandatory, and is the path that is appended
// to the stream path in SETUP
attributes = append(attributes, sdp.Attribute{
Key: "control",
Value: "trackID=" + strconv.FormatInt(int64(i), 10),
})
msgOut.Medias = append(msgOut.Medias, sdp.Media{
Bandwidths: m.Bandwidths,
Description: sdp.MediaDescription{
Type: m.Description.Type,
Protocol: "RTP/AVP", // override protocol
Formats: m.Description.Formats,
},
Attributes: attributes,
})
}
sdps := sdp.Session{}
sdps = msgOut.Append(sdps)
byteOut := sdps.AppendTo(nil)
return msgOut, byteOut
}