Perfect, this is exactly what I was looking for. Maybe in the future there could be two more functions in the nice api for this? Anyway, now I&#39;m going to implement a small rendezvous server to make this candidate exchange...<div>
<br></div><div>Thanks again, Youness<br>
<br><br><div class="gmail_quote">On Fri, Jan 13, 2012 at 10:09 PM, Youness Alaoui <span dir="ltr">&lt;<a href="mailto:youness.alaoui@collabora.co.uk">youness.alaoui@collabora.co.uk</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Should be fairly easy to serialize, it&#39;s not such a big structure. All you need<br>
is the type, component id, address and priority.<br>
Here it explains how to encode it into a string for the SDP protocol :<br>
<a href="http://tools.ietf.org/html/rfc5245#section-15" target="_blank">http://tools.ietf.org/html/rfc5245#section-15</a><br>
You can do simpler with something like :<br>
<br>
nice_address_to_string(cand-&gt;addr, addr_string);<br>
sprintf(out, &quot;CANDIDATE: %s %d %d %s %s\n&quot;,<br>
       cand-&gt;foundation, cand-&gt;component_id, cand-&gt;priority,<br>
       cand-&gt;transport == NICE_CANDIDATE_TRANSPORT_UDP ? &quot;UDP&quot; : &quot;UNK&quot;,<br>
       addr_string, nice_address_get_port(cand-&gt;addr),<br>
       cand-&gt;type == NICE_CANDIDATE_TYPE_HOST ? &quot;host&quot; :<br>
       cand-&gt;type == NICE_CANDIDATE_TYPE_SERVER_REFLEXIVE ? &quot;srv&quot; : &quot;relay&quot;)<br>
<br>
and read it with :<br>
<br>
sscanf (in, &quot;CANDIDATE: %s %d %d %s %s\n&quot;,<br>
       foundation, component_id, priority,<br>
       transport_str, addr_string, addr_port, type_str);<br>
cand = nice_candidate_new(memcmp(type_str, &quot;host&quot;) == 0 ?<br>
                          NICE_CANDIDATE_TYPE_HOST :<br>
                          memcmp(type_str, &quot;srv&quot;) == 0 ?<br>
                          NICE_CANDIDATE_TYPE_SERVER_REFLEXIVE :<br>
                          NICE_CANDIDATE_TYPE_RELAY_REFLEXIVE);<br>
memcpy(cand-&gt;foundation, foundation, NICE_CANDIDATE_MAX_FOUNDATION);<br>
cand-&gt;component_id = component_id;<br>
cand-&gt;priority = priority;<br>
cand-&gt;transport = NICE_CANDIDATE_TRANSPORT_UDP;<br>
nice_address_set_from_string(cand-&gt;addr, addr_string);<br>
nice_address_set_port(cand-&gt;addr, addr_port);<br>
<br>
This should do it.. don&#39;t forget to also send out your credentials separately.<br>
<br>
Hope this helps,<br>
Youness.<br>
<div class="im HOEnZb"><br>
On 01/13/2012 03:36 PM, Eduardo Bezerra wrote:<br>
&gt; Yes, I guess I&#39;ll need some 3rd guy in the middle to allow the two peers to<br>
&gt; connect to each other (and then, hopefully, communicate directly). But how to<br>
&gt; you go from a NiceCandidate struct of a peer (which contains several other<br>
&gt; structs and unions) to, say, a string? Such string could be sent to the<br>
&gt; 3rd-party and forwarded to the other peer, which would parse it and recreate the<br>
&gt; NiceCandidate struct, for each received remote candidate... The thing is that I<br>
&gt; want different platforms to communicate, so there should be some &quot;protocol&quot; to<br>
&gt; send the candidates info...<br>
&gt;<br>
&gt;<br>
&gt; On Fri, Jan 13, 2012 at 8:49 PM, Youness Alaoui &lt;<a href="mailto:youness.alaoui@collabora.co.uk">youness.alaoui@collabora.co.uk</a><br>
</div><div class="im HOEnZb">&gt; &lt;mailto:<a href="mailto:youness.alaoui@collabora.co.uk">youness.alaoui@collabora.co.uk</a>&gt;&gt; wrote:<br>
&gt;<br>
&gt;     Hi,<br>
&gt;<br>
&gt;     Thanks Tiago for taking over while I was asleep! Nice to see all this activity<br>
&gt;     and to have Eduardo&#39;s tests successful! :)<br>
&gt;     Having a nat friendly retwork as one of the peers guarantees success, if you<br>
&gt;     have two nat-hostile networks, then it depends on the type of NATs involved, if<br>
&gt;     both are symmetric NATs, then it will fail, if at least one of them is not a<br>
&gt;     symmetric NAT, then it should succeed (c.f.<br>
&gt;     <a href="http://en.wikipedia.org/wiki/Network_address_translation#Methods_of_Port_translation" target="_blank">http://en.wikipedia.org/wiki/Network_address_translation#Methods_of_Port_translation</a><br>
&gt;     )<br>
&gt;<br>
&gt;     libnice does not provide any serialization method, you will still always need a<br>
&gt;     third party server to do the candidate exchange and that will depend on the<br>
&gt;     protocol used by this server, could be XMPP, could be SIP, could be custom, it<br>
&gt;     really all depends on what your needs are and what the server supports/accepts.<br>
&gt;<br>
&gt;     Youness.<br>
&gt;<br>
&gt;<br>
&gt;<br>
</div><div class="HOEnZb"><div class="h5">&gt; _______________________________________________<br>
&gt; Nice mailing list<br>
&gt; <a href="mailto:Nice@lists.freedesktop.org">Nice@lists.freedesktop.org</a><br>
&gt; <a href="http://lists.freedesktop.org/mailman/listinfo/nice" target="_blank">http://lists.freedesktop.org/mailman/listinfo/nice</a><br>
<br>
<br>
</div></div><br>_______________________________________________<br>
Nice mailing list<br>
<a href="mailto:Nice@lists.freedesktop.org">Nice@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/nice" target="_blank">http://lists.freedesktop.org/mailman/listinfo/nice</a><br>
<br></blockquote></div><br></div>