MCPcopy Create free account
hub / github.com/pion/ice / AddExtension

Method AddExtension

candidate_base.go:655–684  ·  view source on GitHub ↗
(ext CandidateExtension)

Source from the content-addressed store, hash-verified

653}
654
655func (c *candidateBase) AddExtension(ext CandidateExtension) error {
656 if ext.Key == "tcptype" {
657 tcpType := NewTCPType(ext.Value)
658 if tcpType == TCPTypeUnspecified {
659 return fmt.Errorf("%w: invalid or unsupported TCPtype %s", errParseTCPType, ext.Value)
660 }
661
662 c.tcpType = tcpType
663
664 return nil
665 }
666
667 if ext.Key == "" {
668 return fmt.Errorf("%w: key is empty", errParseExtension)
669 }
670
671 // per spec, Extensions aren't explicitly unique, we only set the first one.
672 // If the exteion is set multiple times.
673 for i := range c.extensions {
674 if c.extensions[i].Key == ext.Key {
675 c.extensions[i] = ext
676
677 return nil
678 }
679 }
680
681 c.extensions = append(c.extensions, ext)
682
683 return nil
684}
685
686func (c *candidateBase) RemoveExtension(key string) (ok bool) {
687 if key == "tcptype" {

Callers

nothing calls this directly

Calls 2

NewTCPTypeFunction · 0.85
ErrorfMethod · 0.45

Tested by

no test coverage detected