Allow users to pass custom 'CandidateSelectorControlling` and `CandidateSelectorControlled`
We have had two asks for custom ICE selection logic.
@lisay-yan in https://github.com/pion/webrtc/pull/2539 wants to effectively disable ICE. Just take the best candidate right away
@gbfarah wants to always take whatever the latest traffic coming in is in https://github.com/pion/webrtc/issues/2585
These are both greats ideas. However I am worried about the unintended side effects. I don't want to accidentally add a security/interoperability issue into Pion. I would like to support everyones use case though!
To do this I think we should make CandidatePairSelector a public interface (it is private now)
type CandidatePairSelector interface {
Start(agent CandidatePairSelectorAgent)
ContactCandidates(agent CandidatePairSelectorAgent)
PingCandidate(agent CandidatePairSelectorAgent, local, remote Candidate)
HandleSuccessResponse(agent CandidatePairSelectorAgent, m *stun.Message, local, remote Candidate, remoteAddr net.Addr)
HandleBindingRequest(agent CandidatePairSelectorAgent, m *stun.Message, local, remote Candidate)
}
We will also create a new interface. This will allow us to selectively expose private APIs that users will need. We can add things as needed.
type CandidatePairSelectorAgent interface {
GetSelectedPair()
GetBestAvailableCandidatePair()
}
Users via AgentConfig can then pass in their CandidatePairSelectorControlling and CandidatePairSelectorControlled
Do you think this is an ok path forward @at-wat and @stv0g ?
I support the idea of making them customizable via interfaces. Its a good compromise of providing flexibility to the users without adding all these special use cases into the package itself.
Also, I think we can expect that users who implement their own versions of these interfaces really know what they are doing. This wouldnt be the case if we support these special features behind a simple boolean option.
Great! I will start a PR soon