gb28181 sdp 解析
This commit is contained in:
parent
0d5faca617
commit
d997352b66
2
go.mod
2
go.mod
@ -26,6 +26,8 @@ require (
|
||||
github.com/mattn/go-colorable v0.1.14 // indirect
|
||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||
github.com/mitchellh/mapstructure v1.5.0 // indirect
|
||||
github.com/pion/sdp v1.3.0 // indirect
|
||||
github.com/pkg/errors v0.9.1 // indirect
|
||||
github.com/sagikazarmark/locafero v0.4.0 // indirect
|
||||
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
|
||||
github.com/satori/go.uuid v1.2.1-0.20181028125025-b2ce2384e17b // indirect
|
||||
|
3
go.sum
3
go.sum
@ -47,6 +47,9 @@ github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyua
|
||||
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
|
||||
github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM=
|
||||
github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs=
|
||||
github.com/pion/sdp v1.3.0 h1:21lpgEILHyolpsIrbCBagZaAPj4o057cFjzaFebkVOs=
|
||||
github.com/pion/sdp v1.3.0/go.mod h1:ceA2lTyftydQTuCIbUNoH77aAt6CiQJaRpssA4Gee8I=
|
||||
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/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
|
||||
|
53
test/sdp_test.go
Normal file
53
test/sdp_test.go
Normal file
@ -0,0 +1,53 @@
|
||||
package test
|
||||
|
||||
import (
|
||||
"github.com/pion/sdp"
|
||||
"io"
|
||||
"regexp"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestSDP(t *testing.T) {
|
||||
req := `v=0
|
||||
o=00000000000000000002 0 0 IN IP4 10.10.10.200
|
||||
s=Play
|
||||
c=IN IP4 10.10.10.200
|
||||
t=0 0
|
||||
m=video 5080 RTP/AVP 99 125 126 96 97 98
|
||||
a=recvonly
|
||||
a=rtpmap:99 H265/90000
|
||||
a=fmtp:125 profile-level-id=42e01e
|
||||
a=rtpmap:125 H264S/90000
|
||||
a=fmtp:126 profile-level-id=42e01e
|
||||
a=rtpmap:126 H264/90000
|
||||
a=rtpmap:96 PS/90000
|
||||
a=rtpmap:97 MPEG4/90000
|
||||
a=rtpmap:98 H264/90000
|
||||
a=setup:active
|
||||
a=connection:new
|
||||
a=streamnumber:0
|
||||
y=501000001
|
||||
f=
|
||||
`
|
||||
// 匹配 28181 协议的 ssrc
|
||||
ssrcReg := regexp.MustCompile("y=(.*)")
|
||||
matchSsrc := ssrcReg.FindStringSubmatch(req)
|
||||
ssrc := matchSsrc[1]
|
||||
t.Log("y= ", ssrc)
|
||||
req = strings.Replace(req, matchSsrc[0], "", 1)
|
||||
|
||||
// 匹配 28181 协议的 format
|
||||
formatReg := regexp.MustCompile("f=(.*)")
|
||||
matchFormat := formatReg.FindStringSubmatch(req)
|
||||
format := matchFormat[1]
|
||||
t.Log("f= ", format)
|
||||
req = strings.Replace(req, matchFormat[0], "", 1)
|
||||
|
||||
session := &sdp.SessionDescription{}
|
||||
err := session.Unmarshal(req)
|
||||
if err != nil && err != io.EOF {
|
||||
t.Error(err)
|
||||
}
|
||||
t.Logf("%#v\n", session)
|
||||
}
|
Loading…
Reference in New Issue
Block a user