github.com/pion/webrtc/v4@v4.0.1/icecandidatepair.go (about)

     1  // SPDX-FileCopyrightText: 2023 The Pion community <https://pion.ly>
     2  // SPDX-License-Identifier: MIT
     3  
     4  package webrtc
     5  
     6  import "fmt"
     7  
     8  // ICECandidatePair represents an ICE Candidate pair
     9  type ICECandidatePair struct {
    10  	statsID string
    11  	Local   *ICECandidate
    12  	Remote  *ICECandidate
    13  }
    14  
    15  func newICECandidatePairStatsID(localID, remoteID string) string {
    16  	return fmt.Sprintf("%s-%s", localID, remoteID)
    17  }
    18  
    19  func (p *ICECandidatePair) String() string {
    20  	return fmt.Sprintf("(local) %s <-> (remote) %s", p.Local, p.Remote)
    21  }
    22  
    23  // NewICECandidatePair returns an initialized *ICECandidatePair
    24  // for the given pair of ICECandidate instances
    25  func NewICECandidatePair(local, remote *ICECandidate) *ICECandidatePair {
    26  	statsID := newICECandidatePairStatsID(local.statsID, remote.statsID)
    27  	return &ICECandidatePair{
    28  		statsID: statsID,
    29  		Local:   local,
    30  		Remote:  remote,
    31  	}
    32  }