[asterisk-commits] file: branch file/gulp_fax r393890 - in /team/file/gulp_fax: channels/ includ...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue Jul 9 12:21:07 CDT 2013
Author: file
Date: Tue Jul 9 12:21:05 2013
New Revision: 393890
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=393890
Log:
Add configuration options for fax and implement the faxdetect option.
Modified:
team/file/gulp_fax/channels/chan_gulp.c
team/file/gulp_fax/include/asterisk/res_sip.h
team/file/gulp_fax/include/asterisk/res_sip_session.h
team/file/gulp_fax/res/res_sip.c
team/file/gulp_fax/res/res_sip/sip_configuration.c
team/file/gulp_fax/res/res_sip_session.c
Modified: team/file/gulp_fax/channels/chan_gulp.c
URL: http://svnview.digium.com/svn/asterisk/team/file/gulp_fax/channels/chan_gulp.c?view=diff&rev=393890&r1=393889&r2=393890
==============================================================================
--- team/file/gulp_fax/channels/chan_gulp.c (original)
+++ team/file/gulp_fax/channels/chan_gulp.c Tue Jul 9 12:21:05 2013
@@ -570,7 +570,6 @@
ast_rtp_instance_set_channel_id(pvt->media[SIP_MEDIA_VIDEO]->rtp, ast_channel_uniqueid(chan));
}
-
if (ast_format_cap_is_empty(session->req_caps) || !ast_format_cap_has_joint(session->req_caps, session->endpoint->codecs)) {
ast_format_cap_copy(ast_channel_nativeformats(chan), session->endpoint->codecs);
} else {
@@ -639,6 +638,55 @@
}
return 0;
+}
+
+/*! \brief Internal helper function called when CNG tone is detected */
+static struct ast_frame *gulp_cng_tone_detected(struct ast_sip_session *session, struct ast_frame *f)
+{
+ const char *target_context;
+ int exists;
+
+ /* If we only needed this DSP for fax detection purposes we can just drop it now */
+ if (session->endpoint->dtmf == AST_SIP_DTMF_INBAND) {
+ ast_dsp_set_features(session->dsp, DSP_FEATURE_DIGIT_DETECT);
+ } else {
+ ast_dsp_free(session->dsp);
+ session->dsp = NULL;
+ }
+
+ /* If already executing in the fax extension don't do anything */
+ if (!strcmp(ast_channel_exten(session->channel), "fax")) {
+ return f;
+ }
+
+ target_context = S_OR(ast_channel_macrocontext(session->channel), ast_channel_context(session->channel));
+
+ /* We need to luck the channel here because ast_exists_extension has the
+ * potential to start and stop an autoservice on the channel. Such action
+ * is prone to deadlock if the channel is locked.
+ */
+ ast_channel_unlock(session->channel);
+ exists = ast_exists_extension(session->channel, target_context, "fax", 1,
+ S_COR(ast_channel_caller(session->channel)->id.number.valid,
+ ast_channel_caller(session->channel)->id.number.str, NULL));
+ ast_channel_lock(session->channel);
+
+ if (exists) {
+ ast_verb(2, "Redirecting '%s' to fax extension due to CNG detection\n",
+ ast_channel_name(session->channel));
+ pbx_builtin_setvar_helper(session->channel, "FAXEXTEN", ast_channel_exten(session->channel));
+ if (ast_async_goto(session->channel, target_context, "fax", 1)) {
+ ast_log(LOG_ERROR, "Failed to async goto '%s' into fax extension in '%s'\n",
+ ast_channel_name(session->channel), target_context);
+ }
+ ast_frfree(f);
+ f = &ast_null_frame;
+ } else {
+ ast_log(LOG_NOTICE, "FAX CNG detected on '%s' but no fax extension in '%s'\n",
+ ast_channel_name(session->channel), target_context);
+ }
+
+ return f;
}
/*! \brief Function called by core to read any waiting frames */
@@ -691,8 +739,13 @@
f = ast_dsp_process(ast, session->dsp, f);
if (f && (f->frametype == AST_FRAME_DTMF)) {
- ast_debug(3, "* Detected inband DTMF '%c' on '%s'\n", f->subclass.integer,
- ast_channel_name(ast));
+ if (f->subclass.integer == 'f') {
+ ast_debug(3, "Fax CNG detected on %s\n", ast_channel_name(ast));
+ f = gulp_cng_tone_detected(session, f);
+ } else {
+ ast_debug(3, "* Detected inband DTMF '%c' on '%s'\n", f->subclass.integer,
+ ast_channel_name(ast));
+ }
}
}
Modified: team/file/gulp_fax/include/asterisk/res_sip.h
URL: http://svnview.digium.com/svn/asterisk/team/file/gulp_fax/include/asterisk/res_sip.h?view=diff&rev=393890&r1=393889&r2=393890
==============================================================================
--- team/file/gulp_fax/include/asterisk/res_sip.h (original)
+++ team/file/gulp_fax/include/asterisk/res_sip.h Tue Jul 9 12:21:05 2013
@@ -32,6 +32,8 @@
#include "asterisk/dnsmgr.h"
/* Needed for ast_endpoint */
#include "asterisk/endpoints.h"
+/* Needed for ast_t38_ec_modes */
+#include "asterisk/udptl.h"
/* Needed for pj_sockaddr */
#include <pjlib.h>
@@ -408,6 +410,14 @@
struct ast_endpoint *persistent;
/*! The number of channels at which busy device state is returned */
unsigned int devicestate_busy_at;
+ /*! Whether T.38 UDPTL support is enabled or not */
+ unsigned int t38udptl;
+ /*! Error correction setting for T.38 UDPTL */
+ enum ast_t38_ec_modes t38udptl_ec;
+ /*! Explicit T.38 max datagram value, may be 0 to indicate the remote side can be trusted */
+ unsigned int t38udptl_maxdatagram;
+ /*! Whether fax detection is enabled or not (CNG tone detection) */
+ unsigned int faxdetect;
};
/*!
Modified: team/file/gulp_fax/include/asterisk/res_sip_session.h
URL: http://svnview.digium.com/svn/asterisk/team/file/gulp_fax/include/asterisk/res_sip_session.h?view=diff&rev=393890&r1=393889&r2=393890
==============================================================================
--- team/file/gulp_fax/include/asterisk/res_sip_session.h (original)
+++ team/file/gulp_fax/include/asterisk/res_sip_session.h Tue Jul 9 12:21:05 2013
@@ -44,6 +44,7 @@
struct pjmedia_sdp_session;
struct ast_rtp_instance;
struct ast_dsp;
+struct ast_udptl;
struct ast_sip_session_sdp_handler;
@@ -51,8 +52,12 @@
* \brief A structure containing SIP session media information
*/
struct ast_sip_session_media {
- /*! \brief RTP instance itself */
- struct ast_rtp_instance *rtp;
+ union {
+ /*! \brief RTP instance itself */
+ struct ast_rtp_instance *rtp;
+ /*! \brief UDPTL instance itself */
+ struct ast_udptl *udptl;
+ };
/*! \brief Direct media address */
struct ast_sockaddr direct_media_addr;
/*! \brief SDP handler that setup the RTP */
Modified: team/file/gulp_fax/res/res_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/file/gulp_fax/res/res_sip.c?view=diff&rev=393890&r1=393889&r2=393890
==============================================================================
--- team/file/gulp_fax/res/res_sip.c (original)
+++ team/file/gulp_fax/res/res_sip.c Tue Jul 9 12:21:05 2013
@@ -386,6 +386,43 @@
Gulp channel driver will return busy as the device state instead of in use.
</para></description>
</configOption>
+ <configOption name="t38udptl" default="no">
+ <synopsis>Whether T.38 UDPTL support is enabled or not</synopsis>
+ <description><para>
+ If set to yes T.38 UDPTL support will be enabled, and T.38 negotiation requests will be accepted
+ and relayed.
+ </para></description>
+ </configOption>
+ <configOption name="t38udptl_ec" default="none">
+ <synopsis>T.38 UDPTL error correction method</synopsis>
+ <description>
+ <enumlist>
+ <enum name="none"><para>
+ No error correction should be used.
+ </para></enum>
+ <enum name="fec"><para>
+ Forward error correction should be used.
+ </para></enum>
+ <enum name="redundancy"><para>
+ Redundacy error correction should be used.
+ </para></enum>
+ </enumlist>
+ </description>
+ </configOption>
+ <configOption name="t38udptl_maxdatagram" default="0">
+ <synopsis>T.38 UDPTL maximum datagram size</synopsis>
+ <description><para>
+ This option can be set to override the maximum datagram of a remote endpoint for broken
+ endpoints.
+ </para></description>
+ </configOption>
+ <configOption name="faxdetect" default="no">
+ <synopsis>Whether CNG tone detection is enabled</synopsis>
+ <description><para>
+ This option can be set to send the session to the fax extension when a CNG tone is
+ detected.
+ </para></description>
+ </configOption>
</configObject>
<configObject name="auth">
<synopsis>Authentication type</synopsis>
Modified: team/file/gulp_fax/res/res_sip/sip_configuration.c
URL: http://svnview.digium.com/svn/asterisk/team/file/gulp_fax/res/res_sip/sip_configuration.c?view=diff&rev=393890&r1=393889&r2=393890
==============================================================================
--- team/file/gulp_fax/res/res_sip/sip_configuration.c (original)
+++ team/file/gulp_fax/res/res_sip/sip_configuration.c Tue Jul 9 12:21:05 2013
@@ -511,6 +511,24 @@
ast_get_namedgroups(var->value))) {
return -1;
}
+ } else {
+ return -1;
+ }
+
+ return 0;
+}
+
+static int t38udptl_ec_handler(const struct aco_option *opt,
+ struct ast_variable *var, void *obj)
+{
+ struct ast_sip_endpoint *endpoint = obj;
+
+ if (!strcmp(var->value, "none")) {
+ endpoint->t38udptl_ec = UDPTL_ERROR_CORRECTION_NONE;
+ } else if (!strcmp(var->value, "fec")) {
+ endpoint->t38udptl_ec = UDPTL_ERROR_CORRECTION_FEC;
+ } else if (!strcmp(var->value, "redundancy")) {
+ endpoint->t38udptl_ec = UDPTL_ERROR_CORRECTION_REDUNDANCY;
} else {
return -1;
}
@@ -658,6 +676,10 @@
ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "namedcallgroup", "", named_groups_handler, NULL, 0, 0);
ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "namedpickupgroup", "", named_groups_handler, NULL, 0, 0);
ast_sorcery_object_field_register(sip_sorcery, "endpoint", "devicestate_busy_at", "0", OPT_UINT_T, 0, FLDSET(struct ast_sip_endpoint, devicestate_busy_at));
+ ast_sorcery_object_field_register(sip_sorcery, "endpoint", "t38udptl", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, t38udptl));
+ ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "t38udptl_ec", "none", t38udptl_ec_handler, NULL, 0, 0);
+ ast_sorcery_object_field_register(sip_sorcery, "endpoint", "t38udptl_maxdatagram", "0", OPT_UINT_T, 0, FLDSET(struct ast_sip_endpoint, t38udptl_maxdatagram));
+ ast_sorcery_object_field_register(sip_sorcery, "endpoint", "faxdetect", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, faxdetect));
if (ast_sip_initialize_sorcery_transport(sip_sorcery)) {
ast_log(LOG_ERROR, "Failed to register SIP transport support with sorcery\n");
Modified: team/file/gulp_fax/res/res_sip_session.c
URL: http://svnview.digium.com/svn/asterisk/team/file/gulp_fax/res/res_sip_session.c?view=diff&rev=393890&r1=393889&r2=393890
==============================================================================
--- team/file/gulp_fax/res/res_sip_session.c (original)
+++ team/file/gulp_fax/res/res_sip_session.c Tue Jul 9 12:21:05 2013
@@ -974,6 +974,7 @@
{
RAII_VAR(struct ast_sip_session *, session, ao2_alloc(sizeof(*session), session_destructor), ao2_cleanup);
struct ast_sip_session_supplement *iter;
+ int dsp_features = 0;
if (!session) {
return NULL;
}
@@ -1004,11 +1005,19 @@
session->req_caps = ast_format_cap_alloc_nolock();
if (endpoint->dtmf == AST_SIP_DTMF_INBAND) {
+ dsp_features |= DSP_FEATURE_DIGIT_DETECT;
+ }
+
+ if (endpoint->faxdetect) {
+ dsp_features |= DSP_FEATURE_FAX_DETECT;
+ }
+
+ if (dsp_features) {
if (!(session->dsp = ast_dsp_new())) {
return NULL;
}
- ast_dsp_set_features(session->dsp, DSP_FEATURE_DIGIT_DETECT);
+ ast_dsp_set_features(session->dsp, dsp_features);
}
if (add_supplements(session)) {
More information about the asterisk-commits
mailing list