i am not exactly sure what are you trying to do but in general the ringback situation is simple: if you receive: 180 without SDP you should play local ringback 180 /183 with SDP you should not play local ringback as the voice path is open. and there is data coming from upstream either tones or announcements. Rgds On Aug 9, 2011, at 5:31 AM, anilgpt wrote: Hi all, I am facing a problem with outgoing call ring-back. This is how it goes. I make call to a PSTN, and at times i get 180 and other i get 183, where i am playing ringtone from file. Here again the ring-back stream may contain tone data or simply silence, which i am unable to detect. When i get a stream from server during ringback, whether it be silence or not, on_call_media_state is called, where i am stopping the ringtone played from and audio file if PJSUA_CALL_MEDIA_ACTIVE. Is there any way to handle this scenario. I have done a few changed to code like below, so that the ringback tone from server is ignored, instead tone will be played from local file. Please let me know if it is acceptable to use media as in the code given below and if there is any risk that PJSIP_SC_OK will not get called when call is accepted. Thanks in advance Anil Sample: static void on_call_state(pjsua_call_id call_id, pjsip_event *e) { pjsua_call_info call_info; PJ_UNUSED_ARG(e); pjsua_call_get_info(call_id, &call_info); if (call_info.state == PJSIP_INV_STATE_DISCONNECTED) { .... setStatus("CALL","Disconnected"); if (call_id == g_current_call) { find_next_call(); } .... } else if(call_info.state == PJSIP_INV_STATE_INCOMING) { .... setStatus("CALL","Calling"); .... } else if (call_info.state == PJSIP_INV_STATE_CALLING) { .... g_current_call = call_id; setStatus("CALL","Dialing");\ .... } else { if (call_info.last_status ==PJSIP_SC_RINGING) { setStatus("CALL","Ringing");//play ringbacktone } if (call_info.last_status ==PJSIP_SC_PROGRESS) { setStatus("CALL","Ringing"); //play ringbacktone } if (call_info.last_status ==PJSIP_SC_OK) { callmedia(call_id); // Connect media once call is accepted setStatus("CALL","Connected"); } if (g_current_call==PJSUA_INVALID_ID) g_current_call = call_id; } } static void on_call_media_state(pjsua_call_id call_id) { // Removed the entire code here. Once call is connected, callmedia(...) will be called from state PJSIP_SC_OK in callback on_call_state(...) } //Start Media once connected static void callmedia(pjsua_call_id call_id) { pjsua_call_info call_info; pjsua_call_get_info(call_id, &call_info); if (call_info.media_status == PJSUA_CALL_MEDIA_ACTIVE) { pj_bool_t connect_sound = PJ_TRUE; /* Put call in conference with other calls, if desired */ if (app_config.auto_conf) { pjsua_call_id call_ids[PJSUA_MAX_CALLS]; unsigned call_cnt=PJ_ARRAY_SIZE(call_ids); unsigned i; /* Get all calls, and establish media connection between * this call and other calls. */ pjsua_enum_calls(call_ids, &call_cnt); for (i=0; i<call_cnt; ++i) { if (call_ids[i] == call_id) continue; if (!pjsua_call_has_media(call_ids[i])) continue; pjsua_conf_connect(call_info.conf_slot, pjsua_call_get_conf_port(call_ids[i])); pjsua_conf_connect(pjsua_call_get_conf_port(call_ids[i]), call_info.conf_slot); } connect_sound = PJ_TRUE; } if (connect_sound) { pjsua_conf_connect(call_info.conf_slot, 0); pjsua_conf_connect(0, call_info.conf_slot); setStatus("CALL","RingBackStop"); } } } _______________________________________________ Visit our blog: http://blog.pjsip.org pjsip mailing list pjsip at lists.pjsip.org<mailto:pjsip at lists.pjsip.org> http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org ------ Alejandro Orellana Savant Systems, LLC 770 Main Street Osterville, Ma. 02655 (508) 683-2547 (W) (508) 683-2647 (F) Alejandro.Orellana at savantav.com<mailto:tim.locascio at savantav.com> Statement of Confidentiality The contents of this e-mail message and any attachments are confidential and are intended solely for the addressee. The information may also be legally privileged. This transmission is sent in trust, and the sole purpose of delivery to the intended recipient. If you have received this transmission in error, any use, reproduction or dissemination of this transmission is strictly prohibited. If you are not the intended recipient, please immediately notify the sender by reply e-mail or at 508.683-2500 and delete this message and its attachments, if any. Statement of Confidentiality The contents of this e-mail message and any attachments are confidential and are intended solely for the addressee. The information may also be legally privileged. This transmission is sent in trust, and the sole purpose of delivery to the intended recipient. If you have received this transmission in error, any use, reproduction or dissemination of this transmission is strictly prohibited. If you are not the intended recipient, please immediately notify the sender by reply e-mail or at 508.683.2500 and delete this message and its attachments, if any. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.pjsip.org/pipermail/pjsip_lists.pjsip.org/attachments/20110809/fc43a810/attachment.html>