[libnice] 'Gathering' state not triggered for 'host' candidates
Juan Navarro
juan.navarro at gmx.es
Thu Sep 21 18:54:01 UTC 2017
Hi,
my local unit tests have been failing due to an issue with the change
logic of the NiceAgent's component state NICE_COMPONENT_STATE_GATHERING:
This state is only notified through "component-state-changed" -or
obtained through nice_agent_get_component_state()- when:
-> A new local candidate has been obtained,
-> AND the candidate is either Server Reflexive (STUN) or Relayed (TURN),
-> AND the NiceAgent component was in either DISCONNECTED or FAILED states.
Shouldn't it also change to that state even if only 'host' candidates
are being gathered?
Relevant code
libnice/agent/discovery.c:
if (nice_address_is_valid (&cand->server) &&
(cand->type == NICE_CANDIDATE_TYPE_SERVER_REFLEXIVE ||
cand->type == NICE_CANDIDATE_TYPE_RELAYED)) {
if (cand->component->state ==
NICE_COMPONENT_STATE_DISCONNECTED ||
cand->component->state == NICE_COMPONENT_STATE_FAILED)
agent_signal_component_state_change (agent,
cand->stream->id,
cand->component->id,
NICE_COMPONENT_STATE_GATHERING);
In my failing test, I have two peers which gather local candidates and
exchange them in order to check that a connection can be established.
The signals "new-candidate-full" of each peer will trigger a call to the
function "nice_agent_set_remote_candidates()" on the other peer.
Docs state that: "You must first call nice_agent_gather_candidates()
[...] before calling nice_agent_set_remote_candidates()"
So, to prevent mistakes, before the actual call to
"nice_agent_set_remote_candidates()", a security check is done by
calling "nice_agent_get_component_state()" with the appropriate
parameters, and ensuring that the result is one of
NICE_COMPONENT_STATE_GATHERING
NICE_COMPONENT_STATE_CONNECTING
NICE_COMPONENT_STATE_CONNECTED
NICE_COMPONENT_STATE_READY
specifically, the check ensures that the state is *not* any of
NICE_COMPONENT_STATE_DISCONNECTED
NICE_COMPONENT_STATE_FAILED
However, as you may imagine already, the state is DISCONNECTED during
the test, even if both peers have already gathered multiple local
candidates (of type 'host').
As far as I understand, the component state should change to GATHERING
as soon as the first local candidate is found, regardless of it being
type "host" or any other. Is there some spec I'm forgetting/not
understanding about this?
Kind regards,
Juan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/nice/attachments/20170921/012e5612/attachment.html>
More information about the nice
mailing list