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'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"><<a href="mailto:youness.alaoui@collabora.co.uk">youness.alaoui@collabora.co.uk</a>></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'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->addr, addr_string);<br>
sprintf(out, "CANDIDATE: %s %d %d %s %s\n",<br>
cand->foundation, cand->component_id, cand->priority,<br>
cand->transport == NICE_CANDIDATE_TRANSPORT_UDP ? "UDP" : "UNK",<br>
addr_string, nice_address_get_port(cand->addr),<br>
cand->type == NICE_CANDIDATE_TYPE_HOST ? "host" :<br>
cand->type == NICE_CANDIDATE_TYPE_SERVER_REFLEXIVE ? "srv" : "relay")<br>
<br>
and read it with :<br>
<br>
sscanf (in, "CANDIDATE: %s %d %d %s %s\n",<br>
foundation, component_id, priority,<br>
transport_str, addr_string, addr_port, type_str);<br>
cand = nice_candidate_new(memcmp(type_str, "host") == 0 ?<br>
NICE_CANDIDATE_TYPE_HOST :<br>
memcmp(type_str, "srv") == 0 ?<br>
NICE_CANDIDATE_TYPE_SERVER_REFLEXIVE :<br>
NICE_CANDIDATE_TYPE_RELAY_REFLEXIVE);<br>
memcpy(cand->foundation, foundation, NICE_CANDIDATE_MAX_FOUNDATION);<br>
cand->component_id = component_id;<br>
cand->priority = priority;<br>
cand->transport = NICE_CANDIDATE_TRANSPORT_UDP;<br>
nice_address_set_from_string(cand->addr, addr_string);<br>
nice_address_set_port(cand->addr, addr_port);<br>
<br>
This should do it.. don'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>
> Yes, I guess I'll need some 3rd guy in the middle to allow the two peers to<br>
> connect to each other (and then, hopefully, communicate directly). But how to<br>
> you go from a NiceCandidate struct of a peer (which contains several other<br>
> structs and unions) to, say, a string? Such string could be sent to the<br>
> 3rd-party and forwarded to the other peer, which would parse it and recreate the<br>
> NiceCandidate struct, for each received remote candidate... The thing is that I<br>
> want different platforms to communicate, so there should be some "protocol" to<br>
> send the candidates info...<br>
><br>
><br>
> On Fri, Jan 13, 2012 at 8:49 PM, Youness Alaoui <<a href="mailto:youness.alaoui@collabora.co.uk">youness.alaoui@collabora.co.uk</a><br>
</div><div class="im HOEnZb">> <mailto:<a href="mailto:youness.alaoui@collabora.co.uk">youness.alaoui@collabora.co.uk</a>>> wrote:<br>
><br>
> Hi,<br>
><br>
> Thanks Tiago for taking over while I was asleep! Nice to see all this activity<br>
> and to have Eduardo's tests successful! :)<br>
> Having a nat friendly retwork as one of the peers guarantees success, if you<br>
> have two nat-hostile networks, then it depends on the type of NATs involved, if<br>
> both are symmetric NATs, then it will fail, if at least one of them is not a<br>
> symmetric NAT, then it should succeed (c.f.<br>
> <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>
> )<br>
><br>
> libnice does not provide any serialization method, you will still always need a<br>
> third party server to do the candidate exchange and that will depend on the<br>
> protocol used by this server, could be XMPP, could be SIP, could be custom, it<br>
> really all depends on what your needs are and what the server supports/accepts.<br>
><br>
> Youness.<br>
><br>
><br>
><br>
</div><div class="HOEnZb"><div class="h5">> _______________________________________________<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>
<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>