Surface ICE candidates that match an updated candidate filter.
After this change an ICE agent can surface candidates that do not match the previous filter but are allowed by the updated one. The candidate filter, as part of the internal implementation in the ICE transport, manifests the RTCIceTransportPolicy field in RTCConfiguration. This new feature would allow an ICE agent to gather new candidates when the transport policy changes from e.g. 'relay' to 'all' without an ICE restart. A caveat in the current implementation remains, and a candidate can surface multiple times if the transport policy, or the candidate filter directly, performs multiple transitions from a value that disallows to one that allows the underlying candidate type. For example, if the transport policy is updated by 'all' -> 'relay' -> 'all', the same host candidate can surface after the second update. Bug: webrtc:8939 Change-Id: I92c2e07dafab225c702c5de28f47958a0d3270cc Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/132282 Commit-Queue: Qingsi Wang <qingsi@webrtc.org> Reviewed-by: Jeroen de Borst <jeroendb@webrtc.org> Reviewed-by: Seth Hampson <shampson@webrtc.org> Cr-Commit-Position: refs/heads/master@{#27674}
This commit is contained in:
@ -125,6 +125,15 @@ class RTC_EXPORT BasicPortAllocatorSession : public PortAllocatorSession,
|
||||
rtc::Thread* network_thread() { return network_thread_; }
|
||||
rtc::PacketSocketFactory* socket_factory() { return socket_factory_; }
|
||||
|
||||
// If the new filter allows new types of candidates compared to the previous
|
||||
// filter, gathered candidates that were discarded because of not matching the
|
||||
// previous filter will be signaled if they match the new one.
|
||||
//
|
||||
// We do not perform any regathering since the port allocator flags decide
|
||||
// the type of candidates to gather and the candidate filter only controls the
|
||||
// signaling of candidates. As a result, with the candidate filter changed
|
||||
// alone, all newly allowed candidates for signaling should already be
|
||||
// gathered by the respective cricket::Port.
|
||||
void SetCandidateFilter(uint32_t filter) override;
|
||||
void StartGettingPorts() override;
|
||||
void StopGettingPorts() override;
|
||||
@ -158,6 +167,14 @@ class RTC_EXPORT BasicPortAllocatorSession : public PortAllocatorSession,
|
||||
private:
|
||||
class PortData {
|
||||
public:
|
||||
enum State {
|
||||
STATE_INPROGRESS, // Still gathering candidates.
|
||||
STATE_COMPLETE, // All candidates allocated and ready for process.
|
||||
STATE_ERROR, // Error in gathering candidates.
|
||||
STATE_PRUNED // Pruned by higher priority ports on the same network
|
||||
// interface. Only TURN ports may be pruned.
|
||||
};
|
||||
|
||||
PortData() {}
|
||||
PortData(Port* port, AllocationSequence* seq)
|
||||
: port_(port), sequence_(seq) {}
|
||||
@ -165,6 +182,7 @@ class RTC_EXPORT BasicPortAllocatorSession : public PortAllocatorSession,
|
||||
Port* port() const { return port_; }
|
||||
AllocationSequence* sequence() const { return sequence_; }
|
||||
bool has_pairable_candidate() const { return has_pairable_candidate_; }
|
||||
State state() const { return state_; }
|
||||
bool complete() const { return state_ == STATE_COMPLETE; }
|
||||
bool error() const { return state_ == STATE_ERROR; }
|
||||
bool pruned() const { return state_ == STATE_PRUNED; }
|
||||
@ -187,20 +205,12 @@ class RTC_EXPORT BasicPortAllocatorSession : public PortAllocatorSession,
|
||||
}
|
||||
has_pairable_candidate_ = has_pairable_candidate;
|
||||
}
|
||||
void set_complete() { state_ = STATE_COMPLETE; }
|
||||
void set_error() {
|
||||
RTC_DCHECK(state_ == STATE_INPROGRESS);
|
||||
state_ = STATE_ERROR;
|
||||
void set_state(State state) {
|
||||
RTC_DCHECK(state != STATE_ERROR || state_ == STATE_INPROGRESS);
|
||||
state_ = state;
|
||||
}
|
||||
|
||||
private:
|
||||
enum State {
|
||||
STATE_INPROGRESS, // Still gathering candidates.
|
||||
STATE_COMPLETE, // All candidates allocated and ready for process.
|
||||
STATE_ERROR, // Error in gathering candidates.
|
||||
STATE_PRUNED // Pruned by higher priority ports on the same network
|
||||
// interface. Only TURN ports may be pruned.
|
||||
};
|
||||
Port* port_ = nullptr;
|
||||
AllocationSequence* sequence_ = nullptr;
|
||||
bool has_pairable_candidate_ = false;
|
||||
|
||||
Reference in New Issue
Block a user