提交 bb5d283e authored 作者: Chris Rienzo's avatar Chris Rienzo

mod_rayo: <receivefax> component added. No support for HTTP(S) yet.

上级 90f0fdb9
...@@ -16,6 +16,12 @@ ...@@ -16,6 +16,12 @@
<param name="default-recognizer" value="pocketsphinx"/> <param name="default-recognizer" value="pocketsphinx"/>
</input> </input>
<!-- receivefax component params -->
<receivefax>
<!-- where to store incoming faxes -->
<param name="file-prefix" value="/tmp/"/>
</receivefax>
<!-- XMPP server domain --> <!-- XMPP server domain -->
<domain name="$${rayo_domain_name}" shared-secret="ClueCon"> <domain name="$${rayo_domain_name}" shared-secret="ClueCon">
<!-- use this instead if you want secure XMPP client to server connections. Put .crt and .key file in freeswitch/certs --> <!-- use this instead if you want secure XMPP client to server connections. Put .crt and .key file in freeswitch/certs -->
...@@ -65,6 +71,7 @@ ...@@ -65,6 +71,7 @@
<alias name="speed-down" target="output"><![CDATA[<speed-down xmlns="urn:xmpp:rayo:output:1"/>]]></alias> <alias name="speed-down" target="output"><![CDATA[<speed-down xmlns="urn:xmpp:rayo:output:1"/>]]></alias>
<alias name="volume-up" target="output"><![CDATA[<volume-up xmlns="urn:xmpp:rayo:output:1"/>]]></alias> <alias name="volume-up" target="output"><![CDATA[<volume-up xmlns="urn:xmpp:rayo:output:1"/>]]></alias>
<alias name="volume-down" target="output"><![CDATA[<volume-down xmlns="urn:xmpp:rayo:output:1"/>]]></alias> <alias name="volume-down" target="output"><![CDATA[<volume-down xmlns="urn:xmpp:rayo:output:1"/>]]></alias>
<alias name="receivefax" target="call"><![CDATA[<receivefax xmlns="urn:xmpp:rayo:fax:1"/>]]></alias>
<alias name="record" target="call"><![CDATA[<record xmlns="urn:xmpp:rayo:record:1"/>]]></alias> <alias name="record" target="call"><![CDATA[<record xmlns="urn:xmpp:rayo:record:1"/>]]></alias>
<alias name="record_pause" target="record"><![CDATA[<pause xmlns="urn:xmpp:rayo:record:1"/>]]></alias> <alias name="record_pause" target="record"><![CDATA[<pause xmlns="urn:xmpp:rayo:record:1"/>]]></alias>
<alias name="record_resume" target="record"><![CDATA[<resume xmlns="urn:xmpp:rayo:record:1"/>]]></alias> <alias name="record_resume" target="record"><![CDATA[<resume xmlns="urn:xmpp:rayo:record:1"/>]]></alias>
......
...@@ -14,6 +14,7 @@ LOCAL_OBJS= $(IKS_LA) \ ...@@ -14,6 +14,7 @@ LOCAL_OBJS= $(IKS_LA) \
rayo_input_component.o \ rayo_input_component.o \
rayo_output_component.o \ rayo_output_component.o \
rayo_prompt_component.o \ rayo_prompt_component.o \
rayo_receivefax_component.o \
rayo_record_component.o \ rayo_record_component.o \
sasl.o \ sasl.o \
srgs.o \ srgs.o \
...@@ -27,6 +28,7 @@ LOCAL_SOURCES= \ ...@@ -27,6 +28,7 @@ LOCAL_SOURCES= \
rayo_output_component.c \ rayo_output_component.c \
rayo_prompt_component.c \ rayo_prompt_component.c \
rayo_record_component.c \ rayo_record_component.c \
rayo_receivefax_component.c \
sasl.c \ sasl.c \
srgs.c \ srgs.c \
xmpp_streams.c xmpp_streams.c
......
...@@ -16,6 +16,12 @@ ...@@ -16,6 +16,12 @@
<param name="default-recognizer" value="pocketsphinx"/> <param name="default-recognizer" value="pocketsphinx"/>
</input> </input>
<!-- receivefax component params -->
<receivefax>
<!-- where to store incoming faxes -->
<param name="file-prefix" value="/tmp/"/>
</receivefax>
<!-- XMPP server domain --> <!-- XMPP server domain -->
<domain name="$${rayo_domain_name}" shared-secret="ClueCon"> <domain name="$${rayo_domain_name}" shared-secret="ClueCon">
<!-- use this instead if you want secure XMPP client to server connections. Put .crt and .key file in freeswitch/certs --> <!-- use this instead if you want secure XMPP client to server connections. Put .crt and .key file in freeswitch/certs -->
...@@ -65,6 +71,7 @@ ...@@ -65,6 +71,7 @@
<alias name="speed-down" target="output"><![CDATA[<speed-down xmlns="urn:xmpp:rayo:output:1"/>]]></alias> <alias name="speed-down" target="output"><![CDATA[<speed-down xmlns="urn:xmpp:rayo:output:1"/>]]></alias>
<alias name="volume-up" target="output"><![CDATA[<volume-up xmlns="urn:xmpp:rayo:output:1"/>]]></alias> <alias name="volume-up" target="output"><![CDATA[<volume-up xmlns="urn:xmpp:rayo:output:1"/>]]></alias>
<alias name="volume-down" target="output"><![CDATA[<volume-down xmlns="urn:xmpp:rayo:output:1"/>]]></alias> <alias name="volume-down" target="output"><![CDATA[<volume-down xmlns="urn:xmpp:rayo:output:1"/>]]></alias>
<alias name="receivefax" target="call"><![CDATA[<receivefax xmlns="urn:xmpp:rayo:fax:1"/>]]></alias>
<alias name="record" target="call"><![CDATA[<record xmlns="urn:xmpp:rayo:record:1"/>]]></alias> <alias name="record" target="call"><![CDATA[<record xmlns="urn:xmpp:rayo:record:1"/>]]></alias>
<alias name="record_pause" target="record"><![CDATA[<pause xmlns="urn:xmpp:rayo:record:1"/>]]></alias> <alias name="record_pause" target="record"><![CDATA[<pause xmlns="urn:xmpp:rayo:record:1"/>]]></alias>
<alias name="record_resume" target="record"><![CDATA[<resume xmlns="urn:xmpp:rayo:record:1"/>]]></alias> <alias name="record_resume" target="record"><![CDATA[<resume xmlns="urn:xmpp:rayo:record:1"/>]]></alias>
......
...@@ -126,6 +126,8 @@ struct rayo_call { ...@@ -126,6 +126,8 @@ struct rayo_call {
switch_hash_t *pcps; switch_hash_t *pcps;
/** current idle start time */ /** current idle start time */
switch_time_t idle_start_time; switch_time_t idle_start_time;
/** true if fax is in progress */
int faxing;
/** 1 if joined to call, 2 if joined to mixer */ /** 1 if joined to call, 2 if joined to mixer */
int joined; int joined;
/** pending join */ /** pending join */
...@@ -963,11 +965,35 @@ const char *rayo_call_get_dcp_jid(struct rayo_call *call) ...@@ -963,11 +965,35 @@ const char *rayo_call_get_dcp_jid(struct rayo_call *call)
/** /**
* @param call the Rayo call * @param call the Rayo call
* @return true if joined * @return true if joined (or a join is in progress)
*/ */
static int rayo_call_is_joined(struct rayo_call *call) int rayo_call_is_joined(struct rayo_call *call)
{ {
return call->joined; return call->joined || call->pending_join_request;
}
/**
* @param call to check if faxing
* @return true if faxing is in progress
*/
int rayo_call_is_faxing(struct rayo_call *call)
{
return call->faxing;
}
/**
* Set faxing flag if faxing is not in progress
* @param call the call to flag
* @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)
{
if (!faxing || (faxing && !call->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__)
...@@ -1942,6 +1968,12 @@ static iks *on_rayo_join(struct rayo_actor *call, struct rayo_message *msg, void ...@@ -1942,6 +1968,12 @@ static iks *on_rayo_join(struct rayo_actor *call, struct rayo_message *msg, void
goto done; goto done;
} }
if (rayo_call_is_faxing(RAYO_CALL(call))) {
/* can't join a call while it's faxing */
response = iks_new_error_detailed(msg->payload, STANZA_ERROR_UNEXPECTED_REQUEST, "fax is in progress");
goto done;
}
if (RAYO_CALL(call)->pending_join_request) { if (RAYO_CALL(call)->pending_join_request) {
/* don't allow concurrent join requests */ /* don't allow concurrent join requests */
response = iks_new_error_detailed(msg->payload, STANZA_ERROR_UNEXPECTED_REQUEST, "(un)join request is pending"); response = iks_new_error_detailed(msg->payload, STANZA_ERROR_UNEXPECTED_REQUEST, "(un)join request is pending");
...@@ -3074,12 +3106,22 @@ static switch_status_t rayo_call_on_read_frame(switch_core_session_t *session, s ...@@ -3074,12 +3106,22 @@ static switch_status_t rayo_call_on_read_frame(switch_core_session_t *session, s
switch_time_t idle_start = call->idle_start_time; switch_time_t idle_start = call->idle_start_time;
int idle_duration_ms = (now - idle_start) / 1000; int idle_duration_ms = (now - idle_start) / 1000;
/* detect idle session (rayo-client has stopped controlling call) and terminate call */ /* detect idle session (rayo-client has stopped controlling call) and terminate call */
if (rayo_call_is_joined(call)) { if (rayo_call_is_joined(call) || rayo_call_is_faxing(call)) {
call->idle_start_time = now; call->idle_start_time = now;
} else if (idle_duration_ms > globals.max_idle_ms) { } else if (idle_duration_ms > globals.max_idle_ms) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Ending abandoned call. idle_duration_ms = %i ms\n", idle_duration_ms); switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Ending abandoned call. idle_duration_ms = %i ms\n", idle_duration_ms);
switch_channel_hangup(channel, RAYO_CAUSE_HANGUP); switch_channel_hangup(channel, RAYO_CAUSE_HANGUP);
} }
/* check for break request */
{
const char *break_jid = switch_channel_get_variable(channel, "rayo_read_frame_interrupt");
struct rayo_actor *actor;
if (break_jid && (actor = RAYO_LOCATE(break_jid))) {
RAYO_UNLOCK(actor);
return SWITCH_STATUS_FALSE;
}
}
} }
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
......
...@@ -153,6 +153,9 @@ extern void rayo_actor_destroy(struct rayo_actor *actor, const char *file, int l ...@@ -153,6 +153,9 @@ extern void rayo_actor_destroy(struct rayo_actor *actor, const char *file, int l
#define RAYO_DESTROY(x) rayo_actor_destroy(RAYO_ACTOR(x), __FILE__, __LINE__) #define RAYO_DESTROY(x) rayo_actor_destroy(RAYO_ACTOR(x), __FILE__, __LINE__)
#define RAYO_SEQ_NEXT(x) rayo_actor_seq_next(RAYO_ACTOR(x)) #define RAYO_SEQ_NEXT(x) rayo_actor_seq_next(RAYO_ACTOR(x))
extern int rayo_call_is_joined(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 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)
......
...@@ -226,7 +226,8 @@ switch_status_t rayo_components_load(switch_loadable_module_interface_t **module ...@@ -226,7 +226,8 @@ switch_status_t rayo_components_load(switch_loadable_module_interface_t **module
if (rayo_input_component_load(module_interface, pool, config_file) != SWITCH_STATUS_SUCCESS || if (rayo_input_component_load(module_interface, pool, config_file) != SWITCH_STATUS_SUCCESS ||
rayo_output_component_load(module_interface, pool, config_file) != SWITCH_STATUS_SUCCESS || rayo_output_component_load(module_interface, pool, config_file) != SWITCH_STATUS_SUCCESS ||
rayo_prompt_component_load(module_interface, pool, config_file) != SWITCH_STATUS_SUCCESS || rayo_prompt_component_load(module_interface, pool, config_file) != SWITCH_STATUS_SUCCESS ||
rayo_record_component_load(module_interface, pool, config_file) != SWITCH_STATUS_SUCCESS) { rayo_record_component_load(module_interface, pool, config_file) != SWITCH_STATUS_SUCCESS ||
rayo_receivefax_component_load(module_interface, pool, config_file) != SWITCH_STATUS_SUCCESS) {
return SWITCH_STATUS_TERM; return SWITCH_STATUS_TERM;
} }
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
...@@ -241,6 +242,7 @@ switch_status_t rayo_components_shutdown(void) ...@@ -241,6 +242,7 @@ switch_status_t rayo_components_shutdown(void)
rayo_output_component_shutdown(); rayo_output_component_shutdown();
rayo_prompt_component_shutdown(); rayo_prompt_component_shutdown();
rayo_record_component_shutdown(); rayo_record_component_shutdown();
rayo_receivefax_component_shutdown();
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
......
...@@ -49,6 +49,9 @@ ...@@ -49,6 +49,9 @@
#define RAYO_PROMPT_NS RAYO_BASE "prompt:" RAYO_VERSION #define RAYO_PROMPT_NS RAYO_BASE "prompt:" RAYO_VERSION
#define RAYO_PROMPT_COMPLETE_NS RAYO_BASE "prompt:complete:" RAYO_VERSION #define RAYO_PROMPT_COMPLETE_NS RAYO_BASE "prompt:complete:" RAYO_VERSION
#define RAYO_FAX_NS RAYO_BASE "fax:" RAYO_VERSION
#define RAYO_FAX_COMPLETE_NS RAYO_BASE "fax:complete:" RAYO_VERSION
#define COMPONENT_COMPLETE_STOP "stop", RAYO_EXT_COMPLETE_NS #define COMPONENT_COMPLETE_STOP "stop", RAYO_EXT_COMPLETE_NS
#define COMPONENT_COMPLETE_ERROR "error", RAYO_EXT_COMPLETE_NS #define COMPONENT_COMPLETE_ERROR "error", RAYO_EXT_COMPLETE_NS
#define COMPONENT_COMPLETE_HANGUP "hangup", RAYO_EXT_COMPLETE_NS #define COMPONENT_COMPLETE_HANGUP "hangup", RAYO_EXT_COMPLETE_NS
...@@ -58,12 +61,14 @@ extern switch_status_t rayo_input_component_load(switch_loadable_module_interfac ...@@ -58,12 +61,14 @@ extern switch_status_t rayo_input_component_load(switch_loadable_module_interfac
extern switch_status_t rayo_output_component_load(switch_loadable_module_interface_t **module_interface, switch_memory_pool_t *pool, const char *config_file); extern switch_status_t rayo_output_component_load(switch_loadable_module_interface_t **module_interface, switch_memory_pool_t *pool, const char *config_file);
extern switch_status_t rayo_prompt_component_load(switch_loadable_module_interface_t **module_interface, switch_memory_pool_t *pool, const char *config_file); extern switch_status_t rayo_prompt_component_load(switch_loadable_module_interface_t **module_interface, switch_memory_pool_t *pool, const char *config_file);
extern switch_status_t rayo_record_component_load(switch_loadable_module_interface_t **module_interface, switch_memory_pool_t *pool, const char *config_file); extern switch_status_t rayo_record_component_load(switch_loadable_module_interface_t **module_interface, switch_memory_pool_t *pool, const char *config_file);
extern switch_status_t rayo_receivefax_component_load(switch_loadable_module_interface_t **module_interface, switch_memory_pool_t *pool, const char *config_file);
extern switch_status_t rayo_components_shutdown(void); extern switch_status_t rayo_components_shutdown(void);
extern switch_status_t rayo_input_component_shutdown(void); extern switch_status_t rayo_input_component_shutdown(void);
extern switch_status_t rayo_output_component_shutdown(void); extern switch_status_t rayo_output_component_shutdown(void);
extern switch_status_t rayo_prompt_component_shutdown(void); extern switch_status_t rayo_prompt_component_shutdown(void);
extern switch_status_t rayo_record_component_shutdown(void); extern switch_status_t rayo_record_component_shutdown(void);
extern switch_status_t rayo_receivefax_component_shutdown(void);
extern void rayo_component_send_start(struct rayo_component *component, iks *iq); extern void rayo_component_send_start(struct rayo_component *component, iks *iq);
extern void rayo_component_send_iq_error(struct rayo_component *component, iks *iq, const char *error_name, const char *error_type); extern void rayo_component_send_iq_error(struct rayo_component *component, iks *iq, const char *error_name, const char *error_type);
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
* <input> component validation * <input> component validation
*/ */
ELEMENT(RAYO_INPUT) ELEMENT(RAYO_INPUT)
ATTRIB(xmlns,, any)
STRING_ATTRIB(mode, any, "any,dtmf,voice") STRING_ATTRIB(mode, any, "any,dtmf,voice")
OPTIONAL_ATTRIB(terminator,, dtmf_digit) OPTIONAL_ATTRIB(terminator,, dtmf_digit)
ATTRIB(recognizer,, any) ATTRIB(recognizer,, any)
...@@ -52,6 +53,7 @@ ELEMENT_END ...@@ -52,6 +53,7 @@ ELEMENT_END
* <output> component validation * <output> component validation
*/ */
ELEMENT(RAYO_OUTPUT) ELEMENT(RAYO_OUTPUT)
ATTRIB(xmlns,, any)
ATTRIB(start-offset, 0, not_negative) ATTRIB(start-offset, 0, not_negative)
ATTRIB(start-paused, false, bool) ATTRIB(start-paused, false, bool)
ATTRIB(repeat-interval, 0, not_negative) ATTRIB(repeat-interval, 0, not_negative)
...@@ -65,6 +67,7 @@ ELEMENT_END ...@@ -65,6 +67,7 @@ ELEMENT_END
* <output><seek> validation * <output><seek> validation
*/ */
ELEMENT(RAYO_OUTPUT_SEEK) ELEMENT(RAYO_OUTPUT_SEEK)
ATTRIB(xmlns,, any)
STRING_ATTRIB(direction,, "forward,back") STRING_ATTRIB(direction,, "forward,back")
ATTRIB(amount,-1, positive) ATTRIB(amount,-1, positive)
ELEMENT_END ELEMENT_END
...@@ -73,6 +76,7 @@ ELEMENT_END ...@@ -73,6 +76,7 @@ ELEMENT_END
* <prompt> component validation * <prompt> component validation
*/ */
ELEMENT(RAYO_PROMPT) ELEMENT(RAYO_PROMPT)
ATTRIB(xmlns,, any)
ATTRIB(barge-in, true, bool) ATTRIB(barge-in, true, bool)
ELEMENT_END ELEMENT_END
...@@ -80,6 +84,7 @@ ELEMENT_END ...@@ -80,6 +84,7 @@ ELEMENT_END
* <record> component validation * <record> component validation
*/ */
ELEMENT(RAYO_RECORD) ELEMENT(RAYO_RECORD)
ATTRIB(xmlns,, any)
ATTRIB(format, wav, any) ATTRIB(format, wav, any)
ATTRIB(start-beep, false, bool) ATTRIB(start-beep, false, bool)
ATTRIB(stop-beep, false, bool) ATTRIB(stop-beep, false, bool)
...@@ -95,12 +100,19 @@ ELEMENT_END ...@@ -95,12 +100,19 @@ ELEMENT_END
* <join> command validation * <join> command validation
*/ */
ELEMENT(RAYO_JOIN) ELEMENT(RAYO_JOIN)
ATTRIB(xmlns,, any)
STRING_ATTRIB(direction, duplex, "send,recv,duplex") STRING_ATTRIB(direction, duplex, "send,recv,duplex")
STRING_ATTRIB(media, bridge, "bridge,direct") STRING_ATTRIB(media, bridge, "bridge,direct")
ATTRIB(call-uri,, any) ATTRIB(call-uri,, any)
ATTRIB(mixer-name,, any) ATTRIB(mixer-name,, any)
ELEMENT_END ELEMENT_END
/**
* <receivefax> command validation
*/
ELEMENT(RAYO_RECEIVEFAX)
ATTRIB(xmlns,, any)
ELEMENT_END
/* For Emacs: /* For Emacs:
* Local Variables: * Local Variables:
......
...@@ -37,6 +37,7 @@ ELEMENT_DECL(RAYO_OUTPUT_SEEK) ...@@ -37,6 +37,7 @@ ELEMENT_DECL(RAYO_OUTPUT_SEEK)
ELEMENT_DECL(RAYO_PROMPT) ELEMENT_DECL(RAYO_PROMPT)
ELEMENT_DECL(RAYO_RECORD) ELEMENT_DECL(RAYO_RECORD)
ELEMENT_DECL(RAYO_JOIN) ELEMENT_DECL(RAYO_JOIN)
ELEMENT_DECL(RAYO_RECEIVEFAX)
#endif #endif
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论