Pedro Gon?alves wrote: > Benny Prijono wrote: >> >> On Wed, Sep 10, 2008 at 11:02 AM, Pedro Gon?alves >> <pedro.pandre at gmail.com <mailto:pedro.pandre at gmail.com>> wrote: >> >> Hi! >> >> With PJSUA such problem does not occour, which leads me to >> conclude that it must be some problem in my application, >> somewhere around the area where the INVITE is built / sent. >> >> >> Yeah that's what I thought. >> >> >> With your experience, do you have any idea why in this case the >> candidates in use are not some of the candidates included in SDP >> and why they are always 4000 (RTP) and 4001(RTCP)? >> >> >> The default candidates (the c= and a=rtcp lines) are written to SDP >> by pjmedia_endpt_create_sdp(), using the information from the >> sock_info parameter. The sock_info normally comes from >> pjmedia_transport_get_info(). >> >> Looking at your log, I remember that I saw you call >> pjmedia_endpt_create_sdp() in the beginning of the call, before the >> ICE transport initialization completes. Or perhaps even before the >> ICE transport is created at all! I suspect it's the later case, and >> in this case, you need to check where do you get the sock_info from. >> It could be that you put some hardcoded values there. >> >> The correct steps should be like this: >> - create the ICE media transport >> - wait until initialization completes (STUN resolution and TURN >> allocation completes) >> - call pjmedia_transport_get_info() to get the sock_info (the >> default address) >> - call pjmedia_endpt_create_sdp() >> - then proceed with the rest as usual >> (pjmedia_transport_media_create(), pjmedia_transport_encode_sdp(), >> send the INVITE, etc.) >> > You are right, there is a zone which is creating the transport and the > SDP with ports 4000/4001, before ICE transport is created. > I am changing that, following your advice. However I do have a > question: what is the better way to wait for STUN resolution and TURN > allocation to complete? Are there some callbacks that I can use? I see that in pjsua_media.c, in create_ice_media_transports(), line 790, this is being made: PJSUA_UNLOCK(); while (pjsua_var.calls[i].med_tp_ready == PJ_EPENDING) { pjsua_handle_events(100); } PJSUA_LOCK(); I guess I need something similar in my app, and what I am using now is something like: int sleep_time = 100; int ice_create_max_sleeps = 50; while (my_med_transport_status == PJ_EPENDING && sleeps < ice_create_max_sleeps) { pj_thread_sleep(sleep_time); sleeps++; } Is this OK? Probably my solution is not 100% correct, as it seems to me that it is preventing the correct initialization of ICE transport (in the time that can be seen above - 100 * 50 ms = 5secs, my on_ice_complete callback is not being called with PJ_ICE_STRANS_OP_INIT Cheers Pedro Gon?alves