<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=utf-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    Hi,<br>
    <br>
    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:<br>
    <br>
    This state is only notified through "component-state-changed" -or
    obtained through nice_agent_get_component_state()- when:<br>
    -> A new local candidate has been obtained,<br>
    -> AND the candidate is either Server Reflexive (STUN) or Relayed
    (TURN),<br>
    -> AND the NiceAgent component was in either DISCONNECTED or
    FAILED states.<br>
    <br>
    Shouldn't it also change to that state even if only 'host'
    candidates are being gathered?<br>
    <br>
    Relevant code<br>
    <blockquote>libnice/agent/discovery.c:<br>
          if (nice_address_is_valid (&cand->server) &&<br>
              (cand->type == NICE_CANDIDATE_TYPE_SERVER_REFLEXIVE ||<br>
                  cand->type == NICE_CANDIDATE_TYPE_RELAYED)) {<br>
      <br>
            if (cand->component->state ==
      NICE_COMPONENT_STATE_DISCONNECTED ||<br>
                cand->component->state ==
      NICE_COMPONENT_STATE_FAILED)<br>
              agent_signal_component_state_change (agent,<br>
                  cand->stream->id,<br>
                  cand->component->id,<br>
                  NICE_COMPONENT_STATE_GATHERING);<br>
    </blockquote>
    <br>
    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.<br>
    <br>
    Docs state that: "You must first call nice_agent_gather_candidates()
    [...] before calling nice_agent_set_remote_candidates()"<br>
    <br>
    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<br>
    NICE_COMPONENT_STATE_CONNECTING<br>
    NICE_COMPONENT_STATE_CONNECTED<br>
    NICE_COMPONENT_STATE_READY<br>
    <br>
    specifically, the check ensures that the state is *not* any of<br>
    NICE_COMPONENT_STATE_DISCONNECTED<br>
    NICE_COMPONENT_STATE_FAILED<br>
    <br>
    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').<br>
    <br>
    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?<br>
    <br>
    Kind regards,<br>
    Juan<br>
    <br>
  </body>
</html>