mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-04-29 05:30:14 +00:00
mod_rayo: send/receivefax bugfixes, also allow outbound calls not created with <dial> to be offered
This commit is contained in:
parent
035818aa3a
commit
a5328fe9c3
@ -983,18 +983,13 @@ int rayo_call_is_faxing(struct rayo_call *call)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set faxing flag if faxing is not in progress
|
* Set faxing flag
|
||||||
* @param call the call to flag
|
* @param call the call to flag
|
||||||
* @param faxing true if faxing is in progress
|
* @param faxing true if faxing is in progress
|
||||||
* @return true if set, false if can't set because faxing is already in progress. Reset always succeeds.
|
|
||||||
*/
|
*/
|
||||||
int rayo_call_set_faxing(struct rayo_call *call, int faxing)
|
void rayo_call_set_faxing(struct rayo_call *call, int faxing)
|
||||||
{
|
{
|
||||||
if (!faxing || (faxing && !call->faxing)) {
|
|
||||||
call->faxing = faxing;
|
call->faxing = faxing;
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#define RAYO_MIXER_LOCATE(mixer_name) rayo_mixer_locate(mixer_name, __FILE__, __LINE__)
|
#define RAYO_MIXER_LOCATE(mixer_name) rayo_mixer_locate(mixer_name, __FILE__, __LINE__)
|
||||||
@ -3174,18 +3169,17 @@ SWITCH_STANDARD_APP(rayo_app)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!call) {
|
if (!call) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT, "Missing rayo call!!\n");
|
/* this scenario can only happen if a call was originated through a mechanism other than <dial>
|
||||||
goto done;
|
and then the rayo APP was executed to offer control */
|
||||||
|
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "Outbound call that wasn't created with <dial>, will try to offer control\n");
|
||||||
}
|
}
|
||||||
ok = 1;
|
ok = 1;
|
||||||
} else {
|
}
|
||||||
/* inbound call - offer control */
|
|
||||||
|
if (!call) {
|
||||||
|
/* offer control */
|
||||||
switch_hash_index_t *hi = NULL;
|
switch_hash_index_t *hi = NULL;
|
||||||
iks *offer = NULL;
|
iks *offer = NULL;
|
||||||
if (call) {
|
|
||||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "Call is already under Rayo 3PCC!\n");
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
|
|
||||||
call = rayo_call_create(switch_core_session_get_uuid(session));
|
call = rayo_call_create(switch_core_session_get_uuid(session));
|
||||||
switch_channel_set_variable(switch_core_session_get_channel(session), "rayo_call_jid", RAYO_JID(call));
|
switch_channel_set_variable(switch_core_session_get_channel(session), "rayo_call_jid", RAYO_JID(call));
|
||||||
|
@ -155,7 +155,7 @@ extern void rayo_actor_destroy(struct rayo_actor *actor, const char *file, int l
|
|||||||
|
|
||||||
extern int rayo_call_is_joined(struct rayo_call *call);
|
extern int rayo_call_is_joined(struct rayo_call *call);
|
||||||
extern int rayo_call_is_faxing(struct rayo_call *call);
|
extern int rayo_call_is_faxing(struct rayo_call *call);
|
||||||
extern int rayo_call_set_faxing(struct rayo_call *call, int faxing);
|
extern void rayo_call_set_faxing(struct rayo_call *call, int faxing);
|
||||||
extern const char *rayo_call_get_dcp_jid(struct rayo_call *call);
|
extern const char *rayo_call_get_dcp_jid(struct rayo_call *call);
|
||||||
|
|
||||||
#define rayo_mixer_get_name(mixer) RAYO_ID(mixer)
|
#define rayo_mixer_get_name(mixer) RAYO_ID(mixer)
|
||||||
|
@ -92,7 +92,7 @@ static iks *start_sendfax_component(struct rayo_actor *call, struct rayo_message
|
|||||||
return iks_new_error_detailed(iq, STANZA_ERROR_UNEXPECTED_REQUEST, "can't send fax on a joined call");
|
return iks_new_error_detailed(iq, STANZA_ERROR_UNEXPECTED_REQUEST, "can't send fax on a joined call");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!rayo_call_set_faxing(RAYO_CALL(call), 1)) {
|
if (rayo_call_is_faxing(RAYO_CALL(call))) {
|
||||||
return iks_new_error_detailed(iq, STANZA_ERROR_UNEXPECTED_REQUEST, "fax already in progress");
|
return iks_new_error_detailed(iq, STANZA_ERROR_UNEXPECTED_REQUEST, "fax already in progress");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -199,6 +199,8 @@ static iks *start_sendfax_component(struct rayo_actor *call, struct rayo_message
|
|||||||
/* clear fax interrupt variable */
|
/* clear fax interrupt variable */
|
||||||
switch_channel_set_variable(switch_core_session_get_channel(session), "rayo_read_frame_interrupt", NULL);
|
switch_channel_set_variable(switch_core_session_get_channel(session), "rayo_read_frame_interrupt", NULL);
|
||||||
|
|
||||||
|
rayo_call_set_faxing(RAYO_CALL(call), 1);
|
||||||
|
|
||||||
/* execute txfax APP */
|
/* execute txfax APP */
|
||||||
if (switch_event_create(&execute_event, SWITCH_EVENT_COMMAND) == SWITCH_STATUS_SUCCESS) {
|
if (switch_event_create(&execute_event, SWITCH_EVENT_COMMAND) == SWITCH_STATUS_SUCCESS) {
|
||||||
switch_event_add_header_string(execute_event, SWITCH_STACK_BOTTOM, "call-command", "execute");
|
switch_event_add_header_string(execute_event, SWITCH_STACK_BOTTOM, "call-command", "execute");
|
||||||
@ -214,6 +216,7 @@ static iks *start_sendfax_component(struct rayo_actor *call, struct rayo_message
|
|||||||
if (execute_event) {
|
if (execute_event) {
|
||||||
switch_event_destroy(&execute_event);
|
switch_event_destroy(&execute_event);
|
||||||
}
|
}
|
||||||
|
rayo_call_set_faxing(RAYO_CALL(call), 0);
|
||||||
RAYO_UNLOCK(sendfax_component);
|
RAYO_UNLOCK(sendfax_component);
|
||||||
} else {
|
} else {
|
||||||
/* component starting... */
|
/* component starting... */
|
||||||
@ -221,6 +224,7 @@ static iks *start_sendfax_component(struct rayo_actor *call, struct rayo_message
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
response = iks_new_error_detailed(iq, STANZA_ERROR_INTERNAL_SERVER_ERROR, "failed to create txfax event");
|
response = iks_new_error_detailed(iq, STANZA_ERROR_INTERNAL_SERVER_ERROR, "failed to create txfax event");
|
||||||
|
rayo_call_set_faxing(RAYO_CALL(call), 0);
|
||||||
RAYO_UNLOCK(sendfax_component);
|
RAYO_UNLOCK(sendfax_component);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -255,7 +259,7 @@ static iks *start_receivefax_component(struct rayo_actor *call, struct rayo_mess
|
|||||||
return iks_new_error_detailed(iq, STANZA_ERROR_UNEXPECTED_REQUEST, "can't receive fax on a joined call");
|
return iks_new_error_detailed(iq, STANZA_ERROR_UNEXPECTED_REQUEST, "can't receive fax on a joined call");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!rayo_call_set_faxing(RAYO_CALL(call), 1)) {
|
if (rayo_call_is_faxing(RAYO_CALL(call))) {
|
||||||
return iks_new_error_detailed(iq, STANZA_ERROR_UNEXPECTED_REQUEST, "fax already in progress");
|
return iks_new_error_detailed(iq, STANZA_ERROR_UNEXPECTED_REQUEST, "fax already in progress");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -264,7 +268,7 @@ static iks *start_receivefax_component(struct rayo_actor *call, struct rayo_mess
|
|||||||
receivefax_component = switch_core_alloc(pool, sizeof(*receivefax_component));
|
receivefax_component = switch_core_alloc(pool, sizeof(*receivefax_component));
|
||||||
rayo_component_init((struct rayo_component *)receivefax_component, pool, RAT_CALL_COMPONENT, "receivefax", NULL, call, iks_find_attrib(iq, "from"));
|
rayo_component_init((struct rayo_component *)receivefax_component, pool, RAT_CALL_COMPONENT, "receivefax", NULL, call, iks_find_attrib(iq, "from"));
|
||||||
file_no = rayo_actor_seq_next(call);
|
file_no = rayo_actor_seq_next(call);
|
||||||
receivefax_component->filename = switch_core_sprintf(pool, "%s%s%s-%d",
|
receivefax_component->filename = switch_core_sprintf(pool, "%s%s%s-%d.tif",
|
||||||
globals.file_prefix, SWITCH_PATH_SEPARATOR, switch_core_session_get_uuid(session), file_no);
|
globals.file_prefix, SWITCH_PATH_SEPARATOR, switch_core_session_get_uuid(session), file_no);
|
||||||
if (!strncmp(receivefax_component->filename, "http://", 7) || !strncmp(receivefax_component->filename, "https://", 8)) {
|
if (!strncmp(receivefax_component->filename, "http://", 7) || !strncmp(receivefax_component->filename, "https://", 8)) {
|
||||||
/* This is an HTTP URL, need to PUT after fax is received */
|
/* This is an HTTP URL, need to PUT after fax is received */
|
||||||
@ -298,6 +302,8 @@ static iks *start_receivefax_component(struct rayo_actor *call, struct rayo_mess
|
|||||||
/* clear fax interrupt variable */
|
/* clear fax interrupt variable */
|
||||||
switch_channel_set_variable(switch_core_session_get_channel(session), "rayo_read_frame_interrupt", NULL);
|
switch_channel_set_variable(switch_core_session_get_channel(session), "rayo_read_frame_interrupt", NULL);
|
||||||
|
|
||||||
|
rayo_call_set_faxing(RAYO_CALL(call), 1);
|
||||||
|
|
||||||
/* execute rxfax APP */
|
/* execute rxfax APP */
|
||||||
if (switch_event_create(&execute_event, SWITCH_EVENT_COMMAND) == SWITCH_STATUS_SUCCESS) {
|
if (switch_event_create(&execute_event, SWITCH_EVENT_COMMAND) == SWITCH_STATUS_SUCCESS) {
|
||||||
switch_event_add_header_string(execute_event, SWITCH_STACK_BOTTOM, "call-command", "execute");
|
switch_event_add_header_string(execute_event, SWITCH_STACK_BOTTOM, "call-command", "execute");
|
||||||
@ -313,6 +319,7 @@ static iks *start_receivefax_component(struct rayo_actor *call, struct rayo_mess
|
|||||||
if (execute_event) {
|
if (execute_event) {
|
||||||
switch_event_destroy(&execute_event);
|
switch_event_destroy(&execute_event);
|
||||||
}
|
}
|
||||||
|
rayo_call_set_faxing(RAYO_CALL(call), 0);
|
||||||
RAYO_UNLOCK(receivefax_component);
|
RAYO_UNLOCK(receivefax_component);
|
||||||
} else {
|
} else {
|
||||||
/* component starting... */
|
/* component starting... */
|
||||||
@ -320,6 +327,7 @@ static iks *start_receivefax_component(struct rayo_actor *call, struct rayo_mess
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
response = iks_new_error_detailed(iq, STANZA_ERROR_INTERNAL_SERVER_ERROR, "failed to create rxfax event");
|
response = iks_new_error_detailed(iq, STANZA_ERROR_INTERNAL_SERVER_ERROR, "failed to create rxfax event");
|
||||||
|
rayo_call_set_faxing(RAYO_CALL(call), 0);
|
||||||
RAYO_UNLOCK(receivefax_component);
|
RAYO_UNLOCK(receivefax_component);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user