diff --git a/mediainfo.go b/mediainfo.go index 5c5b0eb..a3ec737 100644 --- a/mediainfo.go +++ b/mediainfo.go @@ -15,6 +15,8 @@ type MediaInfo struct { simulcast bool simulcastInfo *SimulcastInfo bitrate int + Protocal string + Payloads string } func NewMediaInfo(id string, mtype string) *MediaInfo { diff --git a/sdpinfo.go b/sdpinfo.go index 053994d..f6d5555 100644 --- a/sdpinfo.go +++ b/sdpinfo.go @@ -231,6 +231,8 @@ func (s *SDPInfo) Answer(ice *ICEInfo, dtls *DTLSInfo, candidates []*CandidateIn supported := medias[media.GetType()] if supported != nil { answer := media.AnswerCapability(supported) + answer.Payloads = media.Payloads + answer.Protocal = media.Protocal sdpInfo.AddMedia(answer) } } @@ -284,7 +286,7 @@ func (s *SDPInfo) String() string { mediaMap := &transform.MediaStruct{ Type: media.GetType(), Port: media.GetPort(), - Protocal: "UDP/TLS/RTP/SAVP", + Protocal: media.Protocal, // "UDP/TLS/RTP/SAVP", Fmtp: []*transform.FmtpStruct{}, Rtp: []*transform.RtpStruct{}, RtcpFb: []*transform.RtcpFbStruct{}, @@ -422,7 +424,15 @@ func (s *SDPInfo) String() string { payloads = append(payloads, rtp.Payload) } - mediaMap.Payloads = intArrayToString(payloads, " ") + if strings.ToLower(media.mtype) == "application" { + mediaMap.Payloads = media.Payloads + mediaMap.SctpPort = 5000 + mediaMap.SctpMaxSize = 256 * 1024 + mediaMap.RtcpMux = "" + mediaMap.RtcpRsize = "" + } else { + mediaMap.Payloads = intArrayToString(payloads, " ") + } for id, uri := range media.GetExtensions() { @@ -761,6 +771,8 @@ func Parse(sdp string) (*SDPInfo, error) { } mediaInfo := NewMediaInfo(mid, media) + mediaInfo.Payloads = md.Payloads + mediaInfo.Protocal = md.Protocal ufrag := md.IceUfrag pwd := md.IcePwd diff --git a/transform/grammer.go b/transform/grammer.go index 1a0453a..7d42474 100644 --- a/transform/grammer.go +++ b/transform/grammer.go @@ -535,6 +535,32 @@ var rulesMap map[byte][]*Rule = map[byte][]*Rule{ } }, }, + + // a=sctp-port:5000 + &Rule{ + Name: "sctp-port", + Push: "", + Reg: regexp.MustCompile("^sctp-port:(\\d+)"), + Names: []string{}, + Types: []rune{'d'}, + Format: "", + FormatFunc: func(obj *gabs.Container) string { + return "sctp-port:%d" + }, + }, + + // a=max-message-size:262144 + &Rule{ + Name: "sctp-max-message-size", + Push: "", + Reg: regexp.MustCompile("^max-message-size:(\\d+)"), + Names: []string{}, + Types: []rune{'d'}, + Format: "", + FormatFunc: func(obj *gabs.Container) string { + return "max-message-size:%d" + }, + }, // a=x-google-flag:conference &Rule{ Name: "xGoogleFlag", diff --git a/transform/sdpstruct.go b/transform/sdpstruct.go index 1daf820..26de3d6 100644 --- a/transform/sdpstruct.go +++ b/transform/sdpstruct.go @@ -143,6 +143,8 @@ type MediaStruct struct { Candidates []*CandidateStruct `json:"candidates,omitempty"` Bandwidth []*BandwithStruct `json:"bandwidth,omitempty"` Simulcast *SimulcastStruct `json:"simulcast,omitempty"` + SctpPort int `json:"sctp-port,omitempty"` + SctpMaxSize int `json:"sctp-max-message-size,omitempty"` } type SdpStruct struct {