mirror of
https://github.com/pion/webrtc.git
synced 2025-09-27 03:25:58 +08:00
Fix trailing space in rtcp-fb with no Parameter
Media construction would always do "%s %s" even if no Parameter was available. This commit fixes that by checking if Parameter is empty or not. Resolves #3207
This commit is contained in:
8
sdp.go
8
sdp.go
@@ -541,7 +541,7 @@ func addSenderSDP(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//nolint:cyclop
|
//nolint:cyclop, gocognit
|
||||||
func addTransceiverSDP(
|
func addTransceiverSDP(
|
||||||
descr *sdp.SessionDescription,
|
descr *sdp.SessionDescription,
|
||||||
isPlanB bool,
|
isPlanB bool,
|
||||||
@@ -575,7 +575,11 @@ func addTransceiverSDP(
|
|||||||
media.WithCodec(uint8(codec.PayloadType), name, codec.ClockRate, codec.Channels, codec.SDPFmtpLine)
|
media.WithCodec(uint8(codec.PayloadType), name, codec.ClockRate, codec.Channels, codec.SDPFmtpLine)
|
||||||
|
|
||||||
for _, feedback := range codec.RTPCodecCapability.RTCPFeedback {
|
for _, feedback := range codec.RTPCodecCapability.RTCPFeedback {
|
||||||
media.WithValueAttribute("rtcp-fb", fmt.Sprintf("%d %s %s", codec.PayloadType, feedback.Type, feedback.Parameter))
|
if feedback.Parameter == "" {
|
||||||
|
media.WithValueAttribute("rtcp-fb", fmt.Sprintf("%d %s", codec.PayloadType, feedback.Type))
|
||||||
|
} else {
|
||||||
|
media.WithValueAttribute("rtcp-fb", fmt.Sprintf("%d %s %s", codec.PayloadType, feedback.Type, feedback.Parameter))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if len(codecs) == 0 {
|
if len(codecs) == 0 {
|
||||||
|
36
sdp_test.go
36
sdp_test.go
@@ -1057,6 +1057,42 @@ func TestPopulateSDP(t *testing.T) { //nolint:cyclop,maintidx
|
|||||||
_, ok := offerSdp.Attribute(sdp.AttrKeyGroup)
|
_, ok := offerSdp.Attribute(sdp.AttrKeyGroup)
|
||||||
assert.False(t, ok)
|
assert.False(t, ok)
|
||||||
})
|
})
|
||||||
|
t.Run("rtcp-fb trailing space", func(t *testing.T) {
|
||||||
|
se := SettingEngine{}
|
||||||
|
|
||||||
|
me := &MediaEngine{}
|
||||||
|
assert.NoError(t, me.RegisterDefaultCodecs())
|
||||||
|
api := NewAPI(WithMediaEngine(me))
|
||||||
|
|
||||||
|
tr := &RTPTransceiver{kind: RTPCodecTypeVideo, api: api, codecs: me.videoCodecs}
|
||||||
|
mediaSections := []mediaSection{{id: "0", transceivers: []*RTPTransceiver{tr}}}
|
||||||
|
|
||||||
|
d := &sdp.SessionDescription{}
|
||||||
|
|
||||||
|
offerSdp, err := populateSDP(
|
||||||
|
d,
|
||||||
|
false,
|
||||||
|
[]DTLSFingerprint{},
|
||||||
|
se.sdpMediaLevelFingerprints,
|
||||||
|
se.candidates.ICELite,
|
||||||
|
true,
|
||||||
|
me,
|
||||||
|
connectionRoleFromDtlsRole(defaultDtlsRoleOffer),
|
||||||
|
[]ICECandidate{},
|
||||||
|
ICEParameters{},
|
||||||
|
mediaSections,
|
||||||
|
ICEGatheringStateComplete,
|
||||||
|
nil,
|
||||||
|
se.getSCTPMaxMessageSize(),
|
||||||
|
)
|
||||||
|
assert.Nil(t, err)
|
||||||
|
|
||||||
|
for _, desc := range offerSdp.MediaDescriptions {
|
||||||
|
for _, a := range desc.Attributes {
|
||||||
|
assert.False(t, strings.HasSuffix(a.String(), " "))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGetRIDs(t *testing.T) {
|
func TestGetRIDs(t *testing.T) {
|
||||||
|
Reference in New Issue
Block a user