mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-03-06 10:26:41 +00:00
more cleanup from refactor of originate code
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@11289 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
b0c518cbcd
commit
0b0ce769f8
@ -50,7 +50,8 @@ typedef enum {
|
|||||||
TFLAG_WRITE = (1 << 2),
|
TFLAG_WRITE = (1 << 2),
|
||||||
TFLAG_CNG = (1 << 3),
|
TFLAG_CNG = (1 << 3),
|
||||||
TFLAG_BRIDGE = (1 << 4),
|
TFLAG_BRIDGE = (1 << 4),
|
||||||
TFLAG_BOWOUT = (1 << 5)
|
TFLAG_BOWOUT = (1 << 5),
|
||||||
|
TFLAG_BLEG = (1 << 6)
|
||||||
} TFLAGS;
|
} TFLAGS;
|
||||||
|
|
||||||
struct private_object {
|
struct private_object {
|
||||||
@ -211,7 +212,7 @@ static switch_status_t channel_on_init(switch_core_session_t *session)
|
|||||||
channel = switch_core_session_get_channel(session);
|
channel = switch_core_session_get_channel(session);
|
||||||
switch_assert(channel != NULL);
|
switch_assert(channel != NULL);
|
||||||
|
|
||||||
if (!switch_test_flag(tech_pvt, TFLAG_OUTBOUND)) {
|
if (switch_test_flag(tech_pvt, TFLAG_OUTBOUND) && !switch_test_flag(tech_pvt, TFLAG_BLEG)) {
|
||||||
|
|
||||||
if (!(b_session = switch_core_session_request(loopback_endpoint_interface, NULL))) {
|
if (!(b_session = switch_core_session_request(loopback_endpoint_interface, NULL))) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Failure.\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Failure.\n");
|
||||||
@ -247,7 +248,8 @@ static switch_status_t channel_on_init(switch_core_session_t *session)
|
|||||||
|
|
||||||
switch_set_flag_locked(tech_pvt, TFLAG_LINKED);
|
switch_set_flag_locked(tech_pvt, TFLAG_LINKED);
|
||||||
switch_set_flag_locked(b_tech_pvt, TFLAG_LINKED);
|
switch_set_flag_locked(b_tech_pvt, TFLAG_LINKED);
|
||||||
switch_set_flag_locked(b_tech_pvt, TFLAG_OUTBOUND);
|
switch_set_flag_locked(b_tech_pvt, TFLAG_BLEG);
|
||||||
|
|
||||||
|
|
||||||
switch_channel_set_flag(channel, CF_ACCEPT_CNG);
|
switch_channel_set_flag(channel, CF_ACCEPT_CNG);
|
||||||
//switch_ivr_transfer_variable(session, tech_pvt->other_session, "process_cdr");
|
//switch_ivr_transfer_variable(session, tech_pvt->other_session, "process_cdr");
|
||||||
@ -608,18 +610,14 @@ static switch_status_t channel_receive_message(switch_core_session_t *session, s
|
|||||||
|
|
||||||
switch (msg->message_id) {
|
switch (msg->message_id) {
|
||||||
case SWITCH_MESSAGE_INDICATE_ANSWER:
|
case SWITCH_MESSAGE_INDICATE_ANSWER:
|
||||||
if (tech_pvt->other_channel) {
|
if (tech_pvt->other_channel && !switch_test_flag(tech_pvt, TFLAG_OUTBOUND)) {
|
||||||
if (switch_test_flag(tech_pvt, TFLAG_OUTBOUND)) {
|
|
||||||
switch_channel_mark_answered(tech_pvt->other_channel);
|
switch_channel_mark_answered(tech_pvt->other_channel);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case SWITCH_MESSAGE_INDICATE_PROGRESS:
|
case SWITCH_MESSAGE_INDICATE_PROGRESS:
|
||||||
if (tech_pvt->other_channel) {
|
if (tech_pvt->other_channel && !switch_test_flag(tech_pvt, TFLAG_OUTBOUND)) {
|
||||||
if (switch_test_flag(tech_pvt, TFLAG_OUTBOUND)) {
|
|
||||||
switch_channel_mark_pre_answered(tech_pvt->other_channel);
|
switch_channel_mark_pre_answered(tech_pvt->other_channel);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case SWITCH_MESSAGE_INDICATE_BRIDGE:
|
case SWITCH_MESSAGE_INDICATE_BRIDGE:
|
||||||
{
|
{
|
||||||
@ -703,7 +701,7 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
|
|||||||
switch_snprintf(name, sizeof(name), "loopback/%s-a", caller_profile->destination_number);
|
switch_snprintf(name, sizeof(name), "loopback/%s-a", caller_profile->destination_number);
|
||||||
switch_channel_set_name(channel, name);
|
switch_channel_set_name(channel, name);
|
||||||
switch_channel_set_flag(channel, CF_OUTBOUND);
|
switch_channel_set_flag(channel, CF_OUTBOUND);
|
||||||
|
switch_set_flag_locked(tech_pvt, TFLAG_OUTBOUND);
|
||||||
switch_channel_set_caller_profile(channel, caller_profile);
|
switch_channel_set_caller_profile(channel, caller_profile);
|
||||||
tech_pvt->caller_profile = caller_profile;
|
tech_pvt->caller_profile = caller_profile;
|
||||||
} else {
|
} else {
|
||||||
|
@ -571,6 +571,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_wait_for_answer(switch_core_session_t
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (read_frame && !pass) {
|
if (read_frame && !pass) {
|
||||||
|
|
||||||
if (ringback.fh) {
|
if (ringback.fh) {
|
||||||
switch_size_t mlen, olen;
|
switch_size_t mlen, olen;
|
||||||
unsigned int pos = 0;
|
unsigned int pos = 0;
|
||||||
@ -711,7 +712,6 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
|
|||||||
switch_event_t *var_event = NULL;
|
switch_event_t *var_event = NULL;
|
||||||
uint8_t fail_on_single_reject = 0;
|
uint8_t fail_on_single_reject = 0;
|
||||||
char *fail_on_single_reject_var = NULL;
|
char *fail_on_single_reject_var = NULL;
|
||||||
uint8_t ring_ready = 0;
|
|
||||||
char *loop_data = NULL;
|
char *loop_data = NULL;
|
||||||
uint32_t progress_timelimit_sec = 0;
|
uint32_t progress_timelimit_sec = 0;
|
||||||
uint32_t per_channel_timelimit_sec[MAX_PEERS] = { 0 };
|
uint32_t per_channel_timelimit_sec[MAX_PEERS] = { 0 };
|
||||||
@ -941,7 +941,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ((var_val = switch_event_get_header(var_event, "ring_ready")) && switch_true(var_val)) {
|
if ((var_val = switch_event_get_header(var_event, "ring_ready")) && switch_true(var_val)) {
|
||||||
ring_ready = 1;
|
oglobals.ring_ready = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((var_val = switch_event_get_header(var_event, "originate_timeout"))) {
|
if ((var_val = switch_event_get_header(var_event, "originate_timeout"))) {
|
||||||
@ -1471,7 +1471,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
|
|||||||
|
|
||||||
while ((!caller_channel || switch_channel_ready(caller_channel)) && check_channel_status(&oglobals, originate_status, and_argc)) {
|
while ((!caller_channel || switch_channel_ready(caller_channel)) && check_channel_status(&oglobals, originate_status, and_argc)) {
|
||||||
time_t elapsed = switch_timestamp(NULL) - start;
|
time_t elapsed = switch_timestamp(NULL) - start;
|
||||||
if (caller_channel && !oglobals.sent_ring && ring_ready && !oglobals.return_ring_ready) {
|
if (caller_channel && !oglobals.sent_ring && oglobals.ring_ready && !oglobals.return_ring_ready) {
|
||||||
switch_channel_ring_ready(caller_channel);
|
switch_channel_ring_ready(caller_channel);
|
||||||
oglobals.sent_ring = 1;
|
oglobals.sent_ring = 1;
|
||||||
}
|
}
|
||||||
@ -1519,7 +1519,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
|
|||||||
|
|
||||||
if (originate_status[0].peer_session
|
if (originate_status[0].peer_session
|
||||||
&& switch_core_session_dequeue_message(originate_status[0].peer_session, &message) == SWITCH_STATUS_SUCCESS) {
|
&& switch_core_session_dequeue_message(originate_status[0].peer_session, &message) == SWITCH_STATUS_SUCCESS) {
|
||||||
if (oglobals.session && !ringback_data && or_argc == 1 && and_argc == 1) { /* when there is only 1 channel to call and bridge and no ringback */
|
if (oglobals.session && !ringback_data && or_argc == 1 && and_argc == 1) {
|
||||||
|
/* when there is only 1 channel to call and bridge and no ringback */
|
||||||
switch_core_session_receive_message(oglobals.session, message);
|
switch_core_session_receive_message(oglobals.session, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1542,7 +1543,6 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
|
|||||||
|
|
||||||
if (switch_channel_media_ready(caller_channel)) {
|
if (switch_channel_media_ready(caller_channel)) {
|
||||||
tstatus = switch_core_session_read_frame(oglobals.session, &read_frame, SWITCH_IO_FLAG_NONE, 0);
|
tstatus = switch_core_session_read_frame(oglobals.session, &read_frame, SWITCH_IO_FLAG_NONE, 0);
|
||||||
|
|
||||||
if (!SWITCH_READ_ACCEPTABLE(tstatus)) {
|
if (!SWITCH_READ_ACCEPTABLE(tstatus)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1550,7 +1550,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
|
|||||||
read_frame = NULL;
|
read_frame = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ring_ready && read_frame && !pass) {
|
if (oglobals.ring_ready && read_frame && !pass) {
|
||||||
if (ringback.fh) {
|
if (ringback.fh) {
|
||||||
switch_size_t mlen, olen;
|
switch_size_t mlen, olen;
|
||||||
unsigned int pos = 0;
|
unsigned int pos = 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user