answer tweak
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@3549 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
efa2322670
commit
efa104e868
|
@ -274,6 +274,12 @@ SWITCH_DECLARE(switch_status_t) switch_channel_perform_answer(switch_channel_t *
|
|||
const char *file,
|
||||
const char *func,
|
||||
int line);
|
||||
|
||||
SWITCH_DECLARE(switch_status_t) switch_channel_perform_mark_answered(switch_channel_t *channel,
|
||||
const char *file,
|
||||
const char *func,
|
||||
int line);
|
||||
|
||||
/*!
|
||||
\brief Answer a channel (initiate/acknowledge a successful connection)
|
||||
\param channel channel to answer
|
||||
|
@ -281,6 +287,12 @@ SWITCH_DECLARE(switch_status_t) switch_channel_perform_answer(switch_channel_t *
|
|||
*/
|
||||
#define switch_channel_answer(channel) switch_channel_perform_answer(channel, __FILE__, __FUNCTION__, __LINE__)
|
||||
|
||||
/*!
|
||||
\brief Mark a channel answered with no indication (for outbound calls)
|
||||
\param channel channel to mark answered
|
||||
\return SWITCH_STATUS_SUCCESS if channel was answered successfully
|
||||
*/
|
||||
#define switch_channel_mark_answered(channel) switch_channel_perform_mark_answered(channel, __FILE__, __FUNCTION__, __LINE__)
|
||||
|
||||
SWITCH_DECLARE(switch_status_t) switch_channel_perform_ringback(switch_channel_t *channel,
|
||||
const char *file,
|
||||
|
|
|
@ -2721,7 +2721,7 @@ static void sip_i_state(int status,
|
|||
if (r_sdp) {
|
||||
if (switch_test_flag(tech_pvt, TFLAG_NOMEDIA)) {
|
||||
switch_set_flag_locked(tech_pvt, TFLAG_ANS);
|
||||
switch_channel_set_flag(channel, CF_ANSWERED);
|
||||
switch_channel_mark_answered(channel);
|
||||
if ((uuid = switch_channel_get_variable(channel, SWITCH_BRIDGE_VARIABLE)) && (other_session = switch_core_session_locate(uuid))) {
|
||||
other_channel = switch_core_session_get_channel(other_session);
|
||||
switch_channel_answer(other_channel);
|
||||
|
@ -2749,7 +2749,7 @@ static void sip_i_state(int status,
|
|||
switch_channel_set_variable(channel, "endpoint_disposition", "ANSWER");
|
||||
tech_choose_port(tech_pvt);
|
||||
activate_rtp(tech_pvt);
|
||||
switch_channel_set_flag(channel, CF_ANSWERED);
|
||||
switch_channel_mark_answered(channel);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2759,7 +2759,7 @@ static void sip_i_state(int status,
|
|||
} else if (switch_test_flag(tech_pvt, TFLAG_EARLY_MEDIA)) {
|
||||
switch_set_flag_locked(tech_pvt, TFLAG_ANS);
|
||||
switch_channel_set_variable(channel, "endpoint_disposition", "ANSWER");
|
||||
switch_channel_set_flag(channel, CF_ANSWERED);
|
||||
switch_channel_mark_answered(channel);
|
||||
return;
|
||||
} //else probably an ack
|
||||
}
|
||||
|
|
|
@ -1049,6 +1049,41 @@ SWITCH_DECLARE(switch_status_t) switch_channel_perform_ringback(switch_channel_t
|
|||
return status;
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(switch_status_t) switch_channel_perform_mark_answered(switch_channel_t *channel,
|
||||
const char *file,
|
||||
const char *func,
|
||||
int line)
|
||||
{
|
||||
switch_event_t *event;
|
||||
|
||||
assert(channel != NULL);
|
||||
|
||||
if (channel->state >= CS_HANGUP) {
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
if (switch_channel_test_flag(channel, CF_ANSWERED)) {
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
if (channel->caller_profile && channel->caller_profile->times) {
|
||||
switch_mutex_lock(channel->profile_mutex);
|
||||
channel->caller_profile->times->answered = switch_time_now();
|
||||
switch_mutex_unlock(channel->profile_mutex);
|
||||
}
|
||||
|
||||
switch_channel_set_flag(channel, CF_ANSWERED);
|
||||
|
||||
if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_ANSWER) == SWITCH_STATUS_SUCCESS) {
|
||||
switch_channel_event_set_data(channel, event);
|
||||
switch_event_fire(&event);
|
||||
}
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_ID_LOG, (char *) file, func, line, SWITCH_LOG_NOTICE, "Channel [%s] has been answered\n", channel->name);
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(switch_status_t) switch_channel_perform_answer(switch_channel_t *channel,
|
||||
const char *file,
|
||||
const char *func,
|
||||
|
@ -1065,21 +1100,7 @@ SWITCH_DECLARE(switch_status_t) switch_channel_perform_answer(switch_channel_t *
|
|||
}
|
||||
|
||||
if (switch_core_session_answer_channel(channel->session) == SWITCH_STATUS_SUCCESS) {
|
||||
switch_event_t *event;
|
||||
|
||||
if (channel->caller_profile && channel->caller_profile->times) {
|
||||
switch_mutex_lock(channel->profile_mutex);
|
||||
channel->caller_profile->times->answered = switch_time_now();
|
||||
switch_mutex_unlock(channel->profile_mutex);
|
||||
}
|
||||
|
||||
switch_channel_set_flag(channel, CF_ANSWERED);
|
||||
switch_log_printf(SWITCH_CHANNEL_ID_LOG, (char *) file, func, line, SWITCH_LOG_NOTICE, "Answer %s!\n", channel->name);
|
||||
if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_ANSWER) == SWITCH_STATUS_SUCCESS) {
|
||||
switch_channel_event_set_data(channel, event);
|
||||
switch_event_fire(&event);
|
||||
}
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
return switch_channel_perform_mark_answered(channel, file, func, line);
|
||||
}
|
||||
|
||||
return SWITCH_STATUS_FALSE;
|
||||
|
|
Loading…
Reference in New Issue