gb28181 sdp 序列化测试
This commit is contained in:
parent
322568c7a2
commit
f7881ee1ae
@ -4,6 +4,7 @@ import (
|
||||
"github.com/duke-git/lancet/v2/formatter"
|
||||
"github.com/pion/sdp"
|
||||
"io"
|
||||
"net"
|
||||
"regexp"
|
||||
"strings"
|
||||
"testing"
|
||||
@ -55,3 +56,48 @@ f=
|
||||
pretty, _ := formatter.Pretty(session)
|
||||
t.Logf("%s\n", pretty)
|
||||
}
|
||||
|
||||
func TestSDP_Marshal(t *testing.T) {
|
||||
description := sdp.NewJSEPSessionDescription(false)
|
||||
description.SessionName = "Play"
|
||||
|
||||
description.ConnectionInformation = &sdp.ConnectionInformation{
|
||||
NetworkType: "IN",
|
||||
AddressType: "IP4",
|
||||
Address: &sdp.Address{IP: net.ParseIP("10.10.10.200")},
|
||||
}
|
||||
|
||||
description.Origin.Username = "00000000000000000002"
|
||||
description.Origin.SessionID = 0
|
||||
description.Origin.SessionVersion = 0
|
||||
description.Origin.UnicastAddress = "10.10.10.200"
|
||||
|
||||
media := &sdp.MediaDescription{
|
||||
MediaName: sdp.MediaName{
|
||||
Media: "video",
|
||||
Port: sdp.RangedPort{Value: 5080},
|
||||
Protos: []string{"RTP", "AVP"},
|
||||
Formats: []string{"99", "125", "126", "96", "97", "98"},
|
||||
},
|
||||
Attributes: []sdp.Attribute{
|
||||
{Key: "rtpmap", Value: "99 H265/90000"},
|
||||
{Key: "fmtp", Value: "125 profile-level-id=42e01e"},
|
||||
{Key: "rtpmap", Value: "125 H264S/90000"},
|
||||
{Key: "fmtp", Value: "126 profile-level-id=42e01e"},
|
||||
{Key: "rtpmap", Value: "126 H264/90000"},
|
||||
{Key: "rtpmap", Value: "96 PS/90000"},
|
||||
{Key: "rtpmap", Value: "97 MPEG4/90000"},
|
||||
{Key: "rtpmap", Value: "98 H264/90000"},
|
||||
{Key: "sendonly"},
|
||||
},
|
||||
}
|
||||
|
||||
description.MediaDescriptions = append(description.MediaDescriptions, media)
|
||||
sdpResp := description.Marshal()
|
||||
|
||||
// 添加 y= 和 f= 字段
|
||||
sdpResp += "y=501000001\r\n"
|
||||
sdpResp += "f=\r\n"
|
||||
|
||||
t.Logf("\n%s\n", sdpResp)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user