Advertisement
igor_b

FS-2828 work around

Dec 17th, 2011
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.40 KB | None | 0 0
  1. diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.c b/src/mod/endpoints/mod_sofia/mod_sofia.c
  2. index c058efb..b74571c 100644
  3. --- a/src/mod/endpoints/mod_sofia/mod_sofia.c
  4. +++ b/src/mod/endpoints/mod_sofia/mod_sofia.c
  5. @@ -2454,6 +2454,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
  6. case SWITCH_MESSAGE_INDICATE_RINGING:
  7. {
  8. switch_ring_ready_t ring_ready_val = msg->numeric_arg;
  9. + const char *val = NULL;
  10.  
  11. if (sofia_test_pflag(tech_pvt->profile, PFLAG_3PCC_PROXY) && sofia_test_flag(tech_pvt, TFLAG_3PCC)) {
  12. switch_channel_mark_ring_ready(channel);
  13. @@ -2464,7 +2465,8 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
  14. }
  15.  
  16. if (!switch_channel_test_flag(channel, CF_RING_READY) && !sofia_test_flag(tech_pvt, TFLAG_BYE) &&
  17. - !switch_channel_test_flag(channel, CF_EARLY_MEDIA) && !switch_channel_test_flag(channel, CF_ANSWERED)) {
  18. + (((val = switch_channel_get_variable(channel, "forward_180_after_183")) && switch_true(val)) ||
  19. + !switch_channel_test_flag(channel, CF_EARLY_MEDIA)) && !switch_channel_test_flag(channel, CF_ANSWERED)) {
  20. char *extra_header = sofia_glue_get_extra_headers(channel, SOFIA_SIP_PROGRESS_HEADER_PREFIX);
  21. const char *call_info = switch_channel_get_variable(channel, "presence_call_info_full");
  22. char *cid = generate_pai_str(tech_pvt);
  23. diff --git a/src/mod/endpoints/mod_sofia/sofia.c b/src/mod/endpoints/mod_sofia/sofia.c
  24. index 759d8f1..1c41a2b 100644
  25. --- a/src/mod/endpoints/mod_sofia/sofia.c
  26. +++ b/src/mod/endpoints/mod_sofia/sofia.c
  27. @@ -5293,6 +5293,8 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
  28. int is_dup_sdp = 0;
  29. switch_event_t *s_event = NULL;
  30. char *p;
  31. + int forward_180_after_183 = 0;
  32. + //const char *igor;
  33.  
  34. tl_gets(tags,
  35. NUTAG_CALLSTATE_REF(ss_state),
  36. @@ -5310,7 +5312,11 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
  37. goto done;
  38. }
  39. }
  40. -
  41. +/*
  42. + if ((igor = switch_channel_get_variable(channel, "forward_180_after_183")) && switch_true(igor)) {
  43. + forward_180_after_183 = 1;
  44. + }
  45. +*/
  46. if (status > 100 && status < 300 && tech_pvt && !sofia_use_soa(tech_pvt) && !r_sdp && tech_pvt->last_sdp_str) {
  47. r_sdp = tech_pvt->last_sdp_str;
  48. }
  49. @@ -5354,12 +5360,36 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
  50. }
  51.  
  52. if (session) {
  53. - if ((switch_channel_test_flag(channel, CF_EARLY_MEDIA) || switch_channel_test_flag(channel, CF_ANSWERED)) && (status == 180 || status == 183) && !r_sdp) {
  54. + const char *val = NULL;
  55. + const char *bnumber = NULL;
  56. + bnumber = switch_channel_get_variable(channel, "destination_number");
  57. + if ((val = switch_channel_get_variable(channel, "forward_180_after_183")) && switch_true(val)) {
  58. + forward_180_after_183 = 1;
  59. + }
  60. +
  61. + if ((switch_channel_test_flag(channel, CF_EARLY_MEDIA)) && (status == 180 || status == 183) &&
  62. + ((val = switch_channel_get_variable(channel, "forward_180_after_183")) && switch_true(val))) {
  63. + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "IGOR %s Channel %s skipping state [%s][%d][%s]\n", bnumber,
  64. + switch_channel_get_name(channel), nua_callstate_name(ss_state), status, val);
  65. + forward_180_after_183 = 1;
  66. +
  67. +/*
  68. + if ((switch_channel_test_flag(channel, CF_EARLY_MEDIA) || switch_channel_test_flag(channel, CF_ANSWERED)) && (status == 180 || status == 183) &&
  69. + ((status == 180) && (switch_channel_test_flag(channel, CF_EARLY_MEDIA)) &&
  70. + ((val = switch_channel_get_variable(channel, "forward_180_after_183")) && switch_true(val)))) {
  71. + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "IGOR %s Channel %s skipping state [%s][%d][%s]\n", bnumber,
  72. + switch_channel_get_name(channel), nua_callstate_name(ss_state), status, val);
  73. + forward_180_after_183 = 1;
  74. +*/
  75. + } else if ((switch_channel_test_flag(channel, CF_EARLY_MEDIA) || switch_channel_test_flag(channel, CF_ANSWERED)) && (status == 180 || status == 183) && !r_sdp) {
  76. /* Must you send 180 after 183 w/sdp ? sheesh */
  77. - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Channel %s skipping state [%s][%d]\n",
  78. +// switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Channel %s skipping state [%s][%d]\n",
  79. + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "IIII %s Channel %s skipping state [%s][%d]\n", bnumber,
  80. switch_channel_get_name(channel), nua_callstate_name(ss_state), status);
  81. goto done;
  82. } else if (switch_channel_test_flag(channel, CF_EARLY_MEDIA) && (status == 180 || status == 183) && r_sdp) {
  83. + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "ZZZZ Channel %s skipping state [%s][%d]\n",
  84. + switch_channel_get_name(channel), nua_callstate_name(ss_state), status);
  85. sofia_set_flag_locked(tech_pvt, TFLAG_REINVITE);
  86. }
  87.  
  88. @@ -5452,14 +5482,32 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
  89. case nua_callstate_calling:
  90. break;
  91. case nua_callstate_proceeding:
  92. -
  93. + if (1 == 1) {
  94. + const char *bnumber;
  95. + bnumber = switch_channel_get_variable(channel, "destination_number");
  96. + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "WWWW %s Channel %s status %i - %i\n", bnumber,
  97. + switch_channel_get_name(channel), status, forward_180_after_183);
  98. + }
  99. switch (status) {
  100. case 180:
  101. switch_channel_mark_ring_ready(channel);
  102. + if (forward_180_after_183) {
  103. +// IGOR switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Forwarding 180 Ringing after 183 (Early-Media) %s\n",
  104. + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Forwarding 180 Ringing after 183 (Early-Media) %s\n",
  105. + switch_channel_get_name(channel));
  106. + }
  107. break;
  108. case 182:
  109. switch_channel_mark_ring_ready_value(channel, SWITCH_RING_READY_QUEUED);
  110. break;
  111. + case 183:
  112. + if (forward_180_after_183) {
  113. +// IGOR switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Forwarding 180 Ringing after 183 (Early-Media) %s\n",
  114. + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "QQQQ Forwarding 180 Ringing after 183 (Early-Media) %s\n",
  115. + switch_channel_get_name(channel));
  116. + switch_channel_mark_ring_ready(channel);
  117. + }
  118. + break;
  119. default:
  120. break;
  121. }
  122. diff --git a/src/switch_channel.c b/src/switch_channel.c
  123. index a0b5b9c..372addf 100644
  124. --- a/src/switch_channel.c
  125. +++ b/src/switch_channel.c
  126. @@ -2983,6 +2983,7 @@ SWITCH_DECLARE(switch_status_t) switch_channel_perform_pre_answer(switch_channel
  127. {
  128. switch_core_session_message_t msg = { 0 };
  129. switch_status_t status = SWITCH_STATUS_SUCCESS;
  130. + const char *val = NULL;
  131.  
  132. switch_assert(channel != NULL);
  133.  
  134. @@ -2994,7 +2995,7 @@ SWITCH_DECLARE(switch_status_t) switch_channel_perform_pre_answer(switch_channel
  135. return SWITCH_STATUS_SUCCESS;
  136. }
  137.  
  138. - if (switch_channel_test_flag(channel, CF_EARLY_MEDIA)) {
  139. + if ((switch_channel_test_flag(channel, CF_EARLY_MEDIA)) && (!((val = switch_channel_get_variable(channel, "forward_180_after_183")) && switch_true(val)))) {
  140. return SWITCH_STATUS_SUCCESS;
  141. }
  142.  
  143. diff --git a/src/switch_ivr_bridge.c b/src/switch_ivr_bridge.c
  144. index 6fd926d..60acde2 100644
  145. --- a/src/switch_ivr_bridge.c
  146. +++ b/src/switch_ivr_bridge.c
  147. @@ -161,7 +161,7 @@ typedef struct switch_ivr_bridge_data switch_ivr_bridge_data_t;
  148. static void *audio_bridge_thread(switch_thread_t *thread, void *obj)
  149. {
  150. switch_ivr_bridge_data_t *data = obj;
  151. - int stream_id = 0, pre_b = 0, ans_a = 0, ans_b = 0, originator = 0;
  152. + int stream_id = 0, pre_b = 0, ans_a = 0, ans_b = 0, ring_b = 0, originator = 0;
  153. switch_input_callback_function_t input_callback;
  154. switch_core_session_message_t msg = { 0 };
  155. void *user_data;
  156. @@ -182,6 +182,7 @@ static void *audio_bridge_thread(switch_thread_t *thread, void *obj)
  157. time_t answer_limit = 0;
  158. const char *exec_app = NULL;
  159. const char *exec_data = NULL;
  160. + uint8_t forward_180_after_183 = 0;
  161.  
  162. #ifdef SWITCH_VIDEO_IN_THREADS
  163. switch_thread_t *vid_thread = NULL;
  164. @@ -228,7 +229,11 @@ static void *audio_bridge_thread(switch_thread_t *thread, void *obj)
  165. }
  166. }
  167.  
  168. -
  169. + if (!switch_channel_test_flag(chan_a, CF_ANSWERED)) {
  170. + const char *val = switch_channel_get_variable(chan_a, "forward_180_after_183");
  171. + forward_180_after_183 = switch_true(val);
  172. + }
  173. +
  174. switch_channel_set_flag(chan_a, CF_BRIDGED);
  175.  
  176. switch_channel_wait_for_flag(chan_b, CF_BRIDGED, SWITCH_TRUE, 10000, chan_a);
  177. @@ -425,6 +430,9 @@ static void *audio_bridge_thread(switch_thread_t *thread, void *obj)
  178. goto end_of_bridge_loop;
  179. }
  180. pre_b = 1;
  181. + } else if (!ring_b && switch_channel_test_flag(chan_b, CF_RING_READY) && switch_channel_test_flag(chan_b, CF_EARLY_MEDIA) && forward_180_after_183) {
  182. + switch_channel_ring_ready(chan_a);
  183. + ring_b = 1;
  184. }
  185. if (!pre_b) {
  186. switch_yield(10000);
  187. diff --git a/src/switch_ivr_originate.c b/src/switch_ivr_originate.c
  188. index 582ca2e..508f473 100644
  189. --- a/src/switch_ivr_originate.c
  190. +++ b/src/switch_ivr_originate.c
  191. @@ -113,6 +113,7 @@ typedef struct {
  192. uint8_t gen_ringback;
  193. uint8_t ignore_early_media;
  194. uint8_t ignore_ring_ready;
  195. + uint8_t forward_180_after_183;
  196. int monitor_early_media_ring_count;
  197. int monitor_early_media_ring_total;
  198. int cancel_timeout;
  199. @@ -473,6 +474,10 @@ static uint8_t check_channel_status(originate_global_t *oglobals, originate_stat
  200. if (oglobals->sending_ringback == 1) {
  201. send_ringback++;
  202. pindex = (uint32_t) i;
  203. +
  204. + if (oglobals->forward_180_after_183 && switch_channel_test_flag(originate_status[i].peer_channel, CF_EARLY_MEDIA)) {
  205. + switch_channel_ring_ready_value(caller_channel, ring_ready_val);
  206. + }
  207. } else {
  208. if (!oglobals->ring_ready) {
  209. oglobals->ring_ready = ring_ready_val;
  210. @@ -483,6 +488,9 @@ static uint8_t check_channel_status(originate_global_t *oglobals, originate_stat
  211. switch_channel_ring_ready_value(caller_channel, ring_ready_val);
  212. oglobals->sent_ring = ring_ready_val;
  213. }
  214. + } else if (!oglobals->sent_ring) {
  215. + switch_channel_ring_ready_value(caller_channel, ring_ready_val);
  216. + oglobals->sent_ring = ring_ready_val;
  217. }
  218. }
  219. }
  220. @@ -1961,6 +1969,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
  221. ok = 1;
  222. } else if (!strcasecmp((char *) hi->name, "language")) {
  223. ok = 1;
  224. + } else if (!strcasecmp((char *) hi->name, "forward_180_after_183")) {
  225. + ok = 1;
  226. }
  227.  
  228. if (ok && !switch_event_get_header(var_event, hi->name)) {
  229. @@ -2080,6 +2090,12 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
  230. }
  231. }
  232.  
  233. + if ((var_val = switch_event_get_header(var_event, "forward_180_after_183"))) {
  234. + if (switch_true(var_val)) {
  235. + oglobals.forward_180_after_183 = 1;
  236. + }
  237. + }
  238. +
  239. if ((var_val = switch_event_get_header(var_event, "originate_continue_on_timeout")) && switch_true(var_val)) {
  240. oglobals.continue_on_timeout = 1;
  241. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement