diff options
Diffstat (limited to 'channels')
-rw-r--r-- | channels/chan_dahdi.c | 15 | ||||
-rw-r--r-- | channels/chan_dahdi.h | 5 | ||||
-rw-r--r-- | channels/chan_pjsip.c | 41 | ||||
-rw-r--r-- | channels/sip/config_parser.c | 7 | ||||
-rw-r--r-- | channels/sip/reqresp_parser.c | 23 |
5 files changed, 78 insertions, 13 deletions
diff --git a/channels/chan_dahdi.c b/channels/chan_dahdi.c index e4b7c0ee8..b18dac91c 100644 --- a/channels/chan_dahdi.c +++ b/channels/chan_dahdi.c @@ -2345,7 +2345,6 @@ static void my_pri_ss7_open_media(void *p) if (pvt->dsp_features && pvt->dsp) { ast_dsp_set_features(pvt->dsp, pvt->dsp_features); - pvt->dsp_features = 0; } } #endif /* defined(HAVE_PRI) || defined(HAVE_SS7) */ @@ -8640,6 +8639,15 @@ static struct ast_frame *dahdi_read(struct ast_channel *ast) /* Perform busy detection etc on the dahdi line */ int mute; + if ((p->dsp_features & DSP_FEATURE_FAX_DETECT) + && p->faxdetect_timeout + && p->faxdetect_timeout <= ast_channel_get_up_time(ast)) { + p->dsp_features &= ~DSP_FEATURE_FAX_DETECT; + ast_dsp_set_features(p->dsp, p->dsp_features); + ast_debug(1, "Channel driver fax CNG detection timeout on %s\n", + ast_channel_name(ast)); + } + f = ast_dsp_process(ast, p->dsp, &p->subs[idx].f); /* Check if DSP code thinks we should be muting this frame and mute the conference if so */ @@ -12539,6 +12547,7 @@ static struct dahdi_pvt *mkintf(int channel, const struct dahdi_chan_conf *conf, tmp->callprogress = conf->chan.callprogress; tmp->waitfordialtone = conf->chan.waitfordialtone; tmp->dialtone_detect = conf->chan.dialtone_detect; + tmp->faxdetect_timeout = conf->chan.faxdetect_timeout; tmp->cancallforward = conf->chan.cancallforward; tmp->dtmfrelax = conf->chan.dtmfrelax; tmp->callwaiting = tmp->permcallwaiting; @@ -17790,6 +17799,10 @@ static int process_dahdi(struct dahdi_chan_conf *confp, const char *cat, struct confp->chan.callprogress |= CALLPROGRESS_FAX_OUTGOING; } else if (!strcasecmp(v->value, "both") || ast_true(v->value)) confp->chan.callprogress |= CALLPROGRESS_FAX_INCOMING | CALLPROGRESS_FAX_OUTGOING; + } else if (!strcasecmp(v->name, "faxdetect_timeout")) { + if (sscanf(v->value, "%30u", &confp->chan.faxdetect_timeout) != 1) { + confp->chan.faxdetect_timeout = 0; + } } else if (!strcasecmp(v->name, "echocancel")) { process_echocancel(confp, v->value, v->lineno); } else if (!strcasecmp(v->name, "echotraining")) { diff --git a/channels/chan_dahdi.h b/channels/chan_dahdi.h index 4bb5d19a2..ab5c1eba9 100644 --- a/channels/chan_dahdi.h +++ b/channels/chan_dahdi.h @@ -612,6 +612,11 @@ struct dahdi_pvt { */ int dialtone_detect; int dialtone_scanning_time_elapsed; /*!< Amount of audio scanned for dialtone, in frames */ + /*! + * \brief The number of seconds into call to disable fax detection. (0 = disabled) + * \note Set from the "faxdetect_timeout" value read in from chan_dahdi.conf + */ + unsigned int faxdetect_timeout; struct timeval waitingfordt; /*!< Time we started waiting for dialtone */ struct timeval flashtime; /*!< Last flash-hook time */ /*! \brief Opaque DSP configuration structure. */ diff --git a/channels/chan_pjsip.c b/channels/chan_pjsip.c index a0ad424a4..2e87393a6 100644 --- a/channels/chan_pjsip.c +++ b/channels/chan_pjsip.c @@ -612,10 +612,12 @@ static struct ast_frame *chan_pjsip_cng_tone_detected(struct ast_sip_session *se { const char *target_context; int exists; + int dsp_features; - /* If we only needed this DSP for fax detection purposes we can just drop it now */ - if (session->endpoint->dtmf == AST_SIP_DTMF_INBAND || session->endpoint->dtmf == AST_SIP_DTMF_AUTO) { - ast_dsp_set_features(session->dsp, DSP_FEATURE_DIGIT_DETECT); + dsp_features = ast_dsp_get_features(session->dsp); + dsp_features &= ~DSP_FEATURE_FAX_DETECT; + if (dsp_features) { + ast_dsp_set_features(session->dsp, dsp_features); } else { ast_dsp_free(session->dsp); session->dsp = NULL; @@ -662,6 +664,7 @@ static struct ast_frame *chan_pjsip_cng_tone_detected(struct ast_sip_session *se static struct ast_frame *chan_pjsip_read(struct ast_channel *ast) { struct ast_sip_channel_pvt *channel = ast_channel_tech_pvt(ast); + struct ast_sip_session *session; struct chan_pjsip_pvt *pvt = channel->pvt; struct ast_frame *f; struct ast_sip_session_media *media = NULL; @@ -699,22 +702,42 @@ static struct ast_frame *chan_pjsip_read(struct ast_channel *ast) return f; } - if (ast_format_cap_iscompatible_format(channel->session->endpoint->media.codecs, f->subclass.format) == AST_FORMAT_CMP_NOT_EQUAL) { + session = channel->session; + + if (ast_format_cap_iscompatible_format(session->endpoint->media.codecs, f->subclass.format) == AST_FORMAT_CMP_NOT_EQUAL) { ast_debug(1, "Oooh, got a frame with format of %s on channel '%s' when endpoint '%s' is not configured for it\n", ast_format_get_name(f->subclass.format), ast_channel_name(ast), - ast_sorcery_object_get_id(channel->session->endpoint)); + ast_sorcery_object_get_id(session->endpoint)); ast_frfree(f); return &ast_null_frame; } - if (channel->session->dsp) { - f = ast_dsp_process(ast, channel->session->dsp, f); + if (session->dsp) { + int dsp_features; + dsp_features = ast_dsp_get_features(session->dsp); + if ((dsp_features & DSP_FEATURE_FAX_DETECT) + && session->endpoint->faxdetect_timeout + && session->endpoint->faxdetect_timeout <= ast_channel_get_up_time(ast)) { + dsp_features &= ~DSP_FEATURE_FAX_DETECT; + if (dsp_features) { + ast_dsp_set_features(session->dsp, dsp_features); + } else { + ast_dsp_free(session->dsp); + session->dsp = NULL; + } + ast_debug(3, "Channel driver fax CNG detection timeout on %s\n", + ast_channel_name(ast)); + } + } + if (session->dsp) { + f = ast_dsp_process(ast, session->dsp, f); if (f && (f->frametype == AST_FRAME_DTMF)) { if (f->subclass.integer == 'f') { - ast_debug(3, "Fax CNG detected on %s\n", ast_channel_name(ast)); - f = chan_pjsip_cng_tone_detected(channel->session, f); + ast_debug(3, "Channel driver fax CNG detected on %s\n", + ast_channel_name(ast)); + f = chan_pjsip_cng_tone_detected(session, f); } else { ast_debug(3, "* Detected inband DTMF '%c' on '%s'\n", f->subclass.integer, ast_channel_name(ast)); diff --git a/channels/sip/config_parser.c b/channels/sip/config_parser.c index 56d04b260..036f7f7d2 100644 --- a/channels/sip/config_parser.c +++ b/channels/sip/config_parser.c @@ -274,6 +274,7 @@ int sip_parse_register_line(struct sip_registry *reg, int default_expiry, const return 0; } +#ifdef TEST_FRAMEWORK AST_TEST_DEFINE(sip_parse_register_line_test) { int res = AST_TEST_PASS; @@ -643,6 +644,7 @@ alloc_fail: ast_test_status_update(test, "Out of memory. \n"); return res; } +#endif int sip_parse_host(char *line, int lineno, char **hostname, int *portnum, enum ast_transport *transport) { @@ -708,6 +710,7 @@ int sip_parse_host(char *line, int lineno, char **hostname, int *portnum, enum a return 0; } +#ifdef TEST_FRAMEWORK AST_TEST_DEFINE(sip_parse_host_line_test) { int res = AST_TEST_PASS; @@ -787,6 +790,7 @@ AST_TEST_DEFINE(sip_parse_host_line_test) return res; } +#endif /*! \brief Parse the comma-separated nat= option values */ void sip_parse_nat_option(const char *value, struct ast_flags *mask, struct ast_flags *flags) @@ -834,6 +838,7 @@ void sip_parse_nat_option(const char *value, struct ast_flags *mask, struct ast_ } } +#ifdef TEST_FRAMEWORK #define TEST_FORCE_RPORT 1 << 0 #define TEST_COMEDIA 1 << 1 #define TEST_AUTO_FORCE_RPORT 1 << 2 @@ -904,6 +909,8 @@ AST_TEST_DEFINE(sip_parse_nat_test) return res; } +#endif + /*! \brief SIP test registration */ void sip_config_parser_register_tests(void) { diff --git a/channels/sip/reqresp_parser.c b/channels/sip/reqresp_parser.c index 298b8cb95..358d6e568 100644 --- a/channels/sip/reqresp_parser.c +++ b/channels/sip/reqresp_parser.c @@ -258,7 +258,7 @@ int parse_uri_full(char *uri, const char *scheme, char **user, char **pass, return error; } - +#ifdef TEST_FRAMEWORK AST_TEST_DEFINE(sip_parse_uri_full_test) { int res = AST_TEST_PASS; @@ -514,7 +514,7 @@ AST_TEST_DEFINE(sip_parse_uri_full_test) return res; } - +#endif int parse_uri(char *uri, const char *scheme, char **user, char **pass, char **hostport, char **transport) { @@ -530,6 +530,7 @@ int parse_uri(char *uri, const char *scheme, char **user, char **pass, return ret; } +#ifdef TEST_FRAMEWORK AST_TEST_DEFINE(sip_parse_uri_test) { int res = AST_TEST_PASS; @@ -687,6 +688,7 @@ AST_TEST_DEFINE(sip_parse_uri_test) return res; } +#endif /*! \brief Get caller id name from SIP headers, copy into output buffer * @@ -817,6 +819,7 @@ const char *get_calleridname(const char *input, char *output, size_t outputsize) return input; } +#ifdef TEST_FRAMEWORK AST_TEST_DEFINE(get_calleridname_test) { int res = AST_TEST_PASS; @@ -899,6 +902,7 @@ AST_TEST_DEFINE(get_calleridname_test) return res; } +#endif int get_name_and_number(const char *hdr, char **name, char **number) { @@ -940,6 +944,7 @@ int get_name_and_number(const char *hdr, char **name, char **number) return 0; } +#ifdef TEST_FRAMEWORK AST_TEST_DEFINE(get_name_and_number_test) { int res = AST_TEST_PASS; @@ -1044,6 +1049,7 @@ AST_TEST_DEFINE(get_name_and_number_test) return res; } +#endif int get_in_brackets_const(const char *src,const char **start,int *length) { @@ -1176,6 +1182,7 @@ char *get_in_brackets(char *tmp) return out; } +#ifdef TEST_FRAMEWORK AST_TEST_DEFINE(get_in_brackets_test) { int res = AST_TEST_PASS; @@ -1252,7 +1259,7 @@ AST_TEST_DEFINE(get_in_brackets_test) return res; } - +#endif int parse_name_andor_addr(char *uri, const char *scheme, char **name, char **user, char **pass, char **hostport, @@ -1298,6 +1305,7 @@ int parse_name_andor_addr(char *uri, const char *scheme, char **name, return parse_uri_full(uri, scheme, user, pass, hostport, params, headers, residue2); } +#ifdef TEST_FRAMEWORK AST_TEST_DEFINE(parse_name_andor_addr_test) { int res = AST_TEST_PASS; @@ -1427,6 +1435,7 @@ AST_TEST_DEFINE(parse_name_andor_addr_test) return res; } +#endif int get_comma(char *in, char **out) { @@ -1523,6 +1532,7 @@ int parse_contact_header(char *contactheader, struct contactliststruct *contactl return last; } +#ifdef TEST_FRAMEWORK AST_TEST_DEFINE(parse_contact_header_test) { int res = AST_TEST_PASS; @@ -1668,6 +1678,7 @@ AST_TEST_DEFINE(parse_contact_header_test) return res; } +#endif /*! * \brief Parse supported header in incoming packet @@ -1755,6 +1766,7 @@ unsigned int parse_sip_options(const char *options, char *unsupported, size_t un return profile; } +#ifdef TEST_FRAMEWORK AST_TEST_DEFINE(sip_parse_options_test) { int res = AST_TEST_PASS; @@ -1892,6 +1904,7 @@ AST_TEST_DEFINE(sip_parse_options_test) return res; } +#endif /*! \brief helper routine for sip_uri_cmp to compare URI parameters * @@ -2246,6 +2259,7 @@ int sip_uri_cmp(const char *input1, const char *input2) #define URI_CMP_MATCH 0 #define URI_CMP_NOMATCH 1 +#ifdef TEST_FRAMEWORK AST_TEST_DEFINE(sip_uri_cmp_test) { static const struct { @@ -2362,6 +2376,7 @@ AST_TEST_DEFINE(sip_uri_cmp_test) return test_res; } +#endif void free_via(struct sip_via *v) { @@ -2448,6 +2463,7 @@ struct sip_via *parse_via(const char *header) return v; } +#ifdef TEST_FRAMEWORK AST_TEST_DEFINE(parse_via_test) { int res = AST_TEST_PASS; @@ -2625,6 +2641,7 @@ AST_TEST_DEFINE(parse_via_test) } return res; } +#endif void sip_request_parser_register_tests(void) { |