diff --git a/pkg/rtc/transport.go b/pkg/rtc/transport.go index 5b10381f..bcdef1fc 100644 --- a/pkg/rtc/transport.go +++ b/pkg/rtc/transport.go @@ -695,7 +695,7 @@ func (t *PCTransport) filterCandidates(sd webrtc.SessionDescription) webrtc.Sess filterAttributes := func(attrs []sdp.Attribute) []sdp.Attribute { filteredAttrs := make([]sdp.Attribute, 0, len(attrs)) for _, a := range attrs { - if a.Key == "candidate" { + if a.Key == sdp.AttrKeyCandidate { if t.preferTCP { if strings.Contains(a.Value, "tcp") { filteredAttrs = append(filteredAttrs, a) @@ -729,7 +729,7 @@ func (t *PCTransport) filterCandidates(sd webrtc.SessionDescription) webrtc.Sess func getMidValue(media *sdp.MediaDescription) string { for _, attr := range media.Attributes { - if attr.Key == "mid" { + if attr.Key == sdp.AttrKeyMID { return attr.Value } } diff --git a/pkg/rtc/transport_test.go b/pkg/rtc/transport_test.go index 6d74ebec..ff504642 100644 --- a/pkg/rtc/transport_test.go +++ b/pkg/rtc/transport_test.go @@ -314,18 +314,18 @@ func TestFilteringCandidates(t *testing.T) { done := false for _, m := range parsed.MediaDescriptions { for _, a := range m.Attributes { - if a.Key == "candidate" { + if a.Key == sdp.AttrKeyCandidate { for idx, aa := range m.Attributes { - if aa.Key == "end-of-candidates" { + if aa.Key == sdp.AttrKeyEndOfCandidates { modifiedAttributes := make([]sdp.Attribute, idx) copy(modifiedAttributes, m.Attributes[:idx]) modifiedAttributes = append(modifiedAttributes, []sdp.Attribute{ { - Key: "candidate", + Key: sdp.AttrKeyCandidate, Value: "054225987 1 tcp 2124414975 159.203.70.248 7881 typ host tcptype passive", }, { - Key: "candidate", + Key: sdp.AttrKeyCandidate, Value: "054225987 2 tcp 2124414975 159.203.70.248 7881 typ host tcptype passive", }, }...) @@ -350,11 +350,11 @@ func TestFilteringCandidates(t *testing.T) { parsed, err = offer.Unmarshal() require.NoError(t, err) - getNumTransportTypeCandidates := func(sdp *sdp.SessionDescription) (int, int) { + getNumTransportTypeCandidates := func(sd *sdp.SessionDescription) (int, int) { numUDPCandidates := 0 numTCPCandidates := 0 - for _, a := range sdp.Attributes { - if a.Key == "candidate" { + for _, a := range sd.Attributes { + if a.Key == sdp.AttrKeyCandidate { if strings.Contains(a.Value, "udp") { numUDPCandidates++ } @@ -363,9 +363,9 @@ func TestFilteringCandidates(t *testing.T) { } } } - for _, m := range sdp.MediaDescriptions { + for _, m := range sd.MediaDescriptions { for _, a := range m.Attributes { - if a.Key == "candidate" { + if a.Key == sdp.AttrKeyCandidate { if strings.Contains(a.Value, "udp") { numUDPCandidates++ }