diff options
author | Patrick McHardy <kaber@trash.net> | 2011-07-22 16:44:20 +0200 |
---|---|---|
committer | Patrick McHardy <kaber@trash.net> | 2011-07-22 16:44:20 +0200 |
commit | 2b9be10b177024bd663bd5fce19ea0fb76260c27 (patch) | |
tree | f6c296350683ee94c120213bef57e14fd153b23a /res | |
parent | 916e420bf0c8db7a8cb1f60557cd2807652142cf (diff) | |
parent | 28da2a199d7e1624ac56ccb27d3671117f4e2717 (diff) |
Diffstat (limited to 'res')
44 files changed, 613 insertions, 79 deletions
diff --git a/res/res_adsi.c b/res/res_adsi.c index 0a1f623a5..778752495 100644 --- a/res/res_adsi.c +++ b/res/res_adsi.c @@ -30,6 +30,10 @@ * res_adsi to load */ +/*** MODULEINFO + <support_level>extended</support_level> + ***/ + #include "asterisk.h" ASTERISK_FILE_VERSION(__FILE__, "$Revision$") diff --git a/res/res_ael_share.c b/res/res_ael_share.c index 805dfd9a8..f1ae9f33f 100644 --- a/res/res_ael_share.c +++ b/res/res_ael_share.c @@ -25,6 +25,10 @@ * \ingroup applications */ +/*** MODULEINFO + <support_level>extended</support_level> + ***/ + #include "asterisk.h" ASTERISK_FILE_VERSION(__FILE__, "$Revision$") diff --git a/res/res_agi.c b/res/res_agi.c index b57c498df..87ae21a6d 100644 --- a/res/res_agi.c +++ b/res/res_agi.c @@ -25,6 +25,10 @@ * \todo Convert the rest of the AGI commands over to XML documentation */ +/*** MODULEINFO + <support_level>core</support_level> + ***/ + #include "asterisk.h" ASTERISK_FILE_VERSION(__FILE__, "$Revision$") diff --git a/res/res_ais.c b/res/res_ais.c index 9bcceeade..c64e8e674 100644 --- a/res/res_ais.c +++ b/res/res_ais.c @@ -34,6 +34,7 @@ /*** MODULEINFO <depend>ais</depend> + <support_level>extended</support_level> ***/ #include "asterisk.h" diff --git a/res/res_calendar.c b/res/res_calendar.c index e6b724baf..b77553781 100644 --- a/res/res_calendar.c +++ b/res/res_calendar.c @@ -23,6 +23,10 @@ * \todo Support writing attendees */ +/*** MODULEINFO + <support_level>core</support_level> + ***/ + #include "asterisk.h" ASTERISK_FILE_VERSION(__FILE__, "$Revision$") diff --git a/res/res_calendar_caldav.c b/res/res_calendar_caldav.c index dd150afd6..14fce0ca7 100644 --- a/res/res_calendar_caldav.c +++ b/res/res_calendar_caldav.c @@ -24,7 +24,9 @@ <depend>neon</depend> <depend>ical</depend> <depend>libxml2</depend> + <support_level>core</support_level> ***/ + #include "asterisk.h" ASTERISK_FILE_VERSION(__FILE__, "$Revision$") diff --git a/res/res_calendar_ews.c b/res/res_calendar_ews.c index 31df35312..51761127e 100644 --- a/res/res_calendar_ews.c +++ b/res/res_calendar_ews.c @@ -22,7 +22,9 @@ /*** MODULEINFO <depend>neon29</depend> + <support_level>core</support_level> ***/ + #include "asterisk.h" ASTERISK_FILE_VERSION(__FILE__, "$Revision$") diff --git a/res/res_calendar_exchange.c b/res/res_calendar_exchange.c index 2238124db..4a2df1822 100644 --- a/res/res_calendar_exchange.c +++ b/res/res_calendar_exchange.c @@ -24,7 +24,9 @@ <depend>neon</depend> <depend>ical</depend> <depend>iksemel</depend> + <support_level>core</support_level> ***/ + #include "asterisk.h" ASTERISK_FILE_VERSION(__FILE__, "$Revision$") diff --git a/res/res_calendar_icalendar.c b/res/res_calendar_icalendar.c index d503eac35..8ef269e4f 100644 --- a/res/res_calendar_icalendar.c +++ b/res/res_calendar_icalendar.c @@ -23,7 +23,9 @@ /*** MODULEINFO <depend>neon</depend> <depend>ical</depend> + <support_level>core</support_level> ***/ + #include "asterisk.h" ASTERISK_FILE_VERSION(__FILE__, "$Revision$") diff --git a/res/res_clialiases.c b/res/res_clialiases.c index e2558f274..d67f3ba39 100644 --- a/res/res_clialiases.c +++ b/res/res_clialiases.c @@ -26,6 +26,9 @@ * CLI commands. */ +/*** MODULEINFO + <support_level>core</support_level> + ***/ #include "asterisk.h" diff --git a/res/res_clioriginate.c b/res/res_clioriginate.c index f244c165d..8a30be073 100644 --- a/res/res_clioriginate.c +++ b/res/res_clioriginate.c @@ -24,6 +24,10 @@ * */ +/*** MODULEINFO + <support_level>core</support_level> + ***/ + #include "asterisk.h" ASTERISK_FILE_VERSION(__FILE__, "$Revision$"); diff --git a/res/res_config_curl.c b/res/res_config_curl.c index 8488d9bdc..bb8d9b39b 100644 --- a/res/res_config_curl.c +++ b/res/res_config_curl.c @@ -28,6 +28,7 @@ /*** MODULEINFO <depend>curl</depend> + <support_level>core</support_level> ***/ #include "asterisk.h" diff --git a/res/res_config_ldap.c b/res/res_config_ldap.c index adfdacb28..55e1526d5 100644 --- a/res/res_config_ldap.c +++ b/res/res_config_ldap.c @@ -33,6 +33,7 @@ /*** MODULEINFO <depend>ldap</depend> + <support_level>extended</support_level> ***/ #include "asterisk.h" diff --git a/res/res_config_odbc.c b/res/res_config_odbc.c index 8154ecc2b..86cc25c86 100644 --- a/res/res_config_odbc.c +++ b/res/res_config_odbc.c @@ -30,6 +30,7 @@ /*** MODULEINFO <depend>res_odbc</depend> + <support_level>core</support_level> ***/ #include "asterisk.h" @@ -481,7 +482,7 @@ static int update_odbc(const char *database, const char *table, const char *keyf va_list aq; struct custom_prepare_struct cps = { .sql = sql, .extra = lookup }; struct odbc_cache_tables *tableptr; - struct odbc_cache_columns *column; + struct odbc_cache_columns *column = NULL; struct ast_flags connected_flag = { RES_ODBC_CONNECTED }; if (!table) { @@ -519,7 +520,16 @@ static int update_odbc(const char *database, const char *table, const char *keyf while((newparam = va_arg(aq, const char *))) { va_arg(aq, const char *); if ((tableptr && (column = ast_odbc_find_column(tableptr, newparam))) || count > 63) { - snprintf(sql + strlen(sql), sizeof(sql) - strlen(sql), ", %s=?", newparam); + /* NULL test for integer-based columns */ + if (ast_strlen_zero(newparam) && tableptr && column && column->nullable && count < 64 && + (column->type == SQL_INTEGER || column->type == SQL_BIGINT || + column->type == SQL_SMALLINT || column->type == SQL_TINYINT || + column->type == SQL_NUMERIC || column->type == SQL_DECIMAL)) { + snprintf(sql + strlen(sql), sizeof(sql) - strlen(sql), ", %s=NULL", newparam); + cps.skip |= (1LL << count); + } else { + snprintf(sql + strlen(sql), sizeof(sql) - strlen(sql), ", %s=?", newparam); + } } else { /* the column does not exist in the table */ cps.skip |= (1LL << count); } diff --git a/res/res_config_pgsql.c b/res/res_config_pgsql.c index bbc683a47..6ed6bd294 100644 --- a/res/res_config_pgsql.c +++ b/res/res_config_pgsql.c @@ -24,6 +24,7 @@ /*** MODULEINFO <depend>pgsql</depend> + <support_level>extended</support_level> ***/ #include "asterisk.h" diff --git a/res/res_config_sqlite.c b/res/res_config_sqlite.c index 75d353cd5..fbeeac275 100644 --- a/res/res_config_sqlite.c +++ b/res/res_config_sqlite.c @@ -73,6 +73,7 @@ /*** MODULEINFO <depend>sqlite</depend> + <support_level>extended</support_level> ***/ #include "asterisk.h" diff --git a/res/res_convert.c b/res/res_convert.c index 94d6e1e59..c2966a85f 100644 --- a/res/res_convert.c +++ b/res/res_convert.c @@ -26,6 +26,10 @@ * */ +/*** MODULEINFO + <support_level>core</support_level> + ***/ + #include "asterisk.h" ASTERISK_FILE_VERSION(__FILE__, "$Revision$") diff --git a/res/res_crypto.c b/res/res_crypto.c index e25b8a4d6..4ae0851d6 100644 --- a/res/res_crypto.c +++ b/res/res_crypto.c @@ -28,6 +28,7 @@ /*** MODULEINFO <depend>openssl</depend> + <support_level>core</support_level> ***/ #include "asterisk.h" diff --git a/res/res_fax.c b/res/res_fax.c index 431e7086a..8073f2d6e 100644 --- a/res/res_fax.c +++ b/res/res_fax.c @@ -53,6 +53,10 @@ * \ingroup applications */ +/*** MODULEINFO + <support_level>core</support_level> + ***/ + #include "asterisk.h" ASTERISK_FILE_VERSION(__FILE__, "$Revision$") @@ -253,6 +257,8 @@ struct fax_gateway { int framehook; /*! \brief bridged */ int bridged:1; + /*! \brief 1 if a v21 preamble has been detected */ + int detected_v21:1; /*! \brief a flag to track the state of our negotiation */ enum ast_t38_state t38_state; /*! \brief original audio formats */ @@ -2407,10 +2413,10 @@ static struct fax_gateway *fax_gateway_new(struct ast_fax_session_details *detai gateway->framehook = -1; ast_dsp_set_features(gateway->chan_dsp, DSP_FEATURE_FAX_DETECT); - ast_dsp_set_faxmode(gateway->chan_dsp, DSP_FAXMODE_DETECT_CED); + ast_dsp_set_faxmode(gateway->chan_dsp, DSP_FAXMODE_DETECT_V21); ast_dsp_set_features(gateway->peer_dsp, DSP_FEATURE_FAX_DETECT); - ast_dsp_set_faxmode(gateway->peer_dsp, DSP_FAXMODE_DETECT_CED); + ast_dsp_set_faxmode(gateway->peer_dsp, DSP_FAXMODE_DETECT_V21); details->caps = AST_FAX_TECH_GATEWAY; if (!(gateway->s = fax_session_reserve(details, &gateway->token))) { @@ -2465,57 +2471,68 @@ static int fax_gateway_start(struct fax_gateway *gateway, struct ast_fax_session return 0; } -static struct ast_frame *fax_gateway_detect_ced(struct fax_gateway *gateway, struct ast_channel *chan, struct ast_channel *peer, struct ast_channel *active, struct ast_frame *f) +static struct ast_frame *fax_gateway_request_t38(struct fax_gateway *gateway, struct ast_channel *chan, struct ast_frame *f) { - struct ast_frame *dfr = ast_frdup(f); - struct ast_dsp *active_dsp = (active == chan) ? gateway->chan_dsp : gateway->peer_dsp; - struct ast_channel *other = (active == chan) ? peer : chan; + struct ast_frame *fp; + struct ast_control_t38_parameters t38_parameters = { + .request_response = AST_T38_REQUEST_NEGOTIATE, + }; + struct ast_frame control_frame = { + .src = "res_fax", + .frametype = AST_FRAME_CONTROL, + .datalen = sizeof(t38_parameters), + .subclass.integer = AST_CONTROL_T38_PARAMETERS, + .data.ptr = &t38_parameters, + }; - if (!dfr) { + struct ast_fax_session_details *details = find_details(chan); + + if (!details) { + ast_log(LOG_ERROR, "no FAX session details found on chan %s for T.38 gateway session, odd\n", chan->name); + ast_framehook_detach(chan, gateway->framehook); return f; } - if (!(dfr = ast_dsp_process(active, active_dsp, dfr))) { + t38_parameters_fax_to_ast(&t38_parameters, &details->our_t38_parameters); + ao2_ref(details, -1); + + if (!(fp = ast_frisolate(&control_frame))) { + ast_log(LOG_ERROR, "error generating T.38 request control frame on chan %s for T.38 gateway session\n", chan->name); return f; } - if (dfr->frametype == AST_FRAME_DTMF && dfr->subclass.integer == 'e') { - if (ast_channel_get_t38_state(other) == T38_STATE_UNKNOWN) { - struct ast_control_t38_parameters t38_parameters = { - .request_response = AST_T38_REQUEST_NEGOTIATE, - }; - struct ast_frame control_frame = { - .src = "res_fax", - .frametype = AST_FRAME_CONTROL, - .datalen = sizeof(t38_parameters), - .subclass.integer = AST_CONTROL_T38_PARAMETERS, - .data.ptr = &t38_parameters, - }; + gateway->t38_state = T38_STATE_NEGOTIATING; + gateway->timeout_start = ast_tvnow(); - struct ast_fax_session_details *details = find_details(chan); - ast_frfree(dfr); + ast_debug(1, "requesting T.38 for gateway session for %s\n", chan->name); + return fp; +} - if (!details) { - ast_log(LOG_ERROR, "no FAX session details found on chan %s for T.38 gateway session, odd\n", chan->name); - ast_framehook_detach(chan, gateway->framehook); - return f; - } +static struct ast_frame *fax_gateway_detect_v21(struct fax_gateway *gateway, struct ast_channel *chan, struct ast_channel *peer, struct ast_channel *active, struct ast_frame *f) +{ + struct ast_frame *dfr = ast_frdup(f); + struct ast_dsp *active_dsp = (active == chan) ? gateway->chan_dsp : gateway->peer_dsp; + struct ast_channel *other = (active == chan) ? peer : chan; - t38_parameters_fax_to_ast(&t38_parameters, &details->our_t38_parameters); - ao2_ref(details, -1); + if (gateway->detected_v21) { + return f; + } - if (!(dfr = ast_frisolate(&control_frame))) { - ast_log(LOG_ERROR, "error generating T.38 request control frame on chan %s for T.38 gateway session\n", chan->name); - return f; - } + if (!dfr) { + return f; + } - gateway->t38_state = T38_STATE_NEGOTIATING; - gateway->timeout_start = ast_tvnow(); + if (!(dfr = ast_dsp_process(active, active_dsp, dfr))) { + return f; + } - ast_debug(1, "detected CED tone on %s, requesting T.38 on %s for T.38 gateway session\n", active->name, other->name); - return dfr; + if (dfr->frametype == AST_FRAME_DTMF && dfr->subclass.integer == 'g') { + gateway->detected_v21 = 1; + if (ast_channel_get_t38_state(other) == T38_STATE_UNKNOWN) { + ast_debug(1, "detected v21 preamble from %s\n", active->name); + return fax_gateway_request_t38(gateway, chan, f); } else { - ast_debug(1, "detected CED tone on %s, but %s does not support T.38 for T.38 gateway session\n", active->name, other->name); + ast_debug(1, "detected v21 preamble on %s, but %s does not support T.38 for T.38 gateway session\n", active->name, other->name); } } @@ -2568,6 +2585,7 @@ static struct ast_frame *fax_gateway_detect_t38(struct fax_gateway *gateway, str if (control_params->request_response == AST_T38_REQUEST_NEGOTIATE) { enum ast_t38_state state = ast_channel_get_t38_state(other); + if (state == T38_STATE_UNKNOWN) { /* we detected a request to negotiate T.38 and the * other channel appears to support T.38, we'll pass @@ -2607,7 +2625,7 @@ static struct ast_frame *fax_gateway_detect_t38(struct fax_gateway *gateway, str return &ast_null_frame; } else if (gateway->t38_state == T38_STATE_NEGOTIATING) { /* we got a request to negotiate T.38 after we already - * sent one to the other party based on CED tone + * sent one to the other party based on v21 preamble * detection. We'll just pretend we passed this request * through in the first place. */ @@ -2615,12 +2633,12 @@ static struct ast_frame *fax_gateway_detect_t38(struct fax_gateway *gateway, str gateway->t38_state = T38_STATE_UNKNOWN; gateway->timeout_start = ast_tvnow(); - ast_debug(1, "%s is attempting to negotiate T.38 after we already sent a negotiation request based on CED detection\n", active->name); + ast_debug(1, "%s is attempting to negotiate T.38 after we already sent a negotiation request based on v21 preamble detection\n", active->name); ao2_ref(details, -1); return &ast_null_frame; } else if (gateway->t38_state == T38_STATE_NEGOTIATED) { /* we got a request to negotiate T.38 after we already - * sent one to the other party based on CED tone + * sent one to the other party based on v21 preamble * detection and received a response. We need to * respond to this and shut down the gateway. */ @@ -2841,7 +2859,8 @@ static struct ast_frame *fax_gateway_framehook(struct ast_channel *chan, struct gateway->timeout_start = ast_tvnow(); - /* we are bridged, change r/w formats to SLIN for CED detection and T.30 */ + /* we are bridged, change r/w formats to SLIN for v21 preamble + * detection and T.30 */ ast_format_copy(&gateway->chan_read_format, &chan->readformat); ast_format_copy(&gateway->chan_write_format, &chan->readformat); @@ -2916,16 +2935,16 @@ static struct ast_frame *fax_gateway_framehook(struct ast_channel *chan, struct return fax_gateway_detect_t38(gateway, chan, peer, active, f); } - /* not in gateway mode yet, listen for CED */ - /* XXX this should detect a v21 preamble instead of CED */ - if (gateway->t38_state == T38_STATE_UNAVAILABLE && f->frametype == AST_FRAME_VOICE) { - return fax_gateway_detect_ced(gateway, chan, peer, active, f); + if (!gateway->detected_v21 && gateway->t38_state == T38_STATE_UNAVAILABLE && f->frametype == AST_FRAME_VOICE) { + /* not in gateway mode and have not detected v21 yet, listen + * for v21 */ + return fax_gateway_detect_v21(gateway, chan, peer, active, f); } /* in gateway mode, gateway some packets */ if (gateway->t38_state == T38_STATE_NEGOTIATED) { /* framehooks are called in __ast_read() before frame format - * translation is does, so we need to translate here */ + * translation is done, so we need to translate here */ if ((f->frametype == AST_FRAME_VOICE) && (f->subclass.format.id != AST_FORMAT_SLINEAR)) { if (active->readtrans && (f = ast_translate(active->readtrans, f, 1)) == NULL) { f = &ast_null_frame; @@ -2942,6 +2961,25 @@ static struct ast_frame *fax_gateway_framehook(struct ast_channel *chan, struct return f; } + /* force silence on the line if T.38 negotiation might be taking place */ + if (gateway->t38_state != T38_STATE_UNAVAILABLE && gateway->t38_state != T38_STATE_REJECTED) { + if (f->frametype == AST_FRAME_VOICE && f->subclass.format.id == AST_FORMAT_SLINEAR) { + short silence_buf[f->samples]; + struct ast_frame silence_frame = { + .frametype = AST_FRAME_VOICE, + .data.ptr = silence_buf, + .samples = f->samples, + .datalen = sizeof(silence_buf), + }; + ast_format_set(&silence_frame.subclass.format, AST_FORMAT_SLINEAR, 0); + memset(silence_buf, 0, sizeof(silence_buf)); + + return ast_frisolate(&silence_frame); + } else { + return &ast_null_frame; + } + } + return f; } diff --git a/res/res_fax_spandsp.c b/res/res_fax_spandsp.c index 02657583d..296dd07a6 100644 --- a/res/res_fax_spandsp.c +++ b/res/res_fax_spandsp.c @@ -45,6 +45,7 @@ /*** MODULEINFO <depend>spandsp</depend> <depend>res_fax</depend> + <support_level>extended</support_level> ***/ #include "asterisk.h" diff --git a/res/res_format_attr_celt.c b/res/res_format_attr_celt.c new file mode 100644 index 000000000..de3de8c40 --- /dev/null +++ b/res/res_format_attr_celt.c @@ -0,0 +1,181 @@ +/* + * Asterisk -- An open source telephony toolkit. + * + * Copyright (C) 2011, Digium, Inc. + * + * David Vossel <dvossel@digium.com> + * + * See http://www.asterisk.org for more information about + * the Asterisk project. Please do not directly contact + * any of the maintainers of this project for assistance; + * the project provides a web site, mailing lists and IRC + * channels for your use. + * + * This program is free software, distributed under the terms of + * the GNU General Public License Version 2. See the LICENSE file + * at the top of the source tree. + */ + +/*! + * \file + * \brief CELT format attribute interface + * + * \author David Vossel <dvossel@digium.com> + */ + +#include "asterisk.h" + +ASTERISK_FILE_VERSION(__FILE__, "$Revision$") + +#include "asterisk/module.h" +#include "asterisk/format.h" + +/*! + * \brief CELT attribute structure. + * + * \note The only attribute that affects compatibility here is the sample rate. + */ +struct celt_attr { + unsigned int samplerate; + unsigned int maxbitrate; + unsigned int framesize; +}; + +static enum ast_format_cmp_res celt_cmp(const struct ast_format_attr *fattr1, const struct ast_format_attr *fattr2) +{ + struct celt_attr *attr1 = (struct celt_attr *) fattr1; + struct celt_attr *attr2 = (struct celt_attr *) fattr2; + + if (attr1->samplerate == attr2->samplerate) { + return AST_FORMAT_CMP_EQUAL; + } + return AST_FORMAT_CMP_NOT_EQUAL; +} + +static int celt_get_val(const struct ast_format_attr *fattr, int key, void *result) +{ + const struct celt_attr *attr = (struct celt_attr *) fattr; + int *val = result; + + switch (key) { + case CELT_ATTR_KEY_SAMP_RATE: + *val = attr->samplerate; + break; + case CELT_ATTR_KEY_MAX_BITRATE: + *val = attr->maxbitrate; + break; + case CELT_ATTR_KEY_FRAME_SIZE: + *val = attr->framesize; + break; + default: + return -1; + ast_log(LOG_WARNING, "unknown attribute type %d\n", key); + } + return 0; +} + +static int celt_isset(const struct ast_format_attr *fattr, va_list ap) +{ + enum celt_attr_keys key; + const struct celt_attr *attr = (struct celt_attr *) fattr; + + for (key = va_arg(ap, int); + key != AST_FORMAT_ATTR_END; + key = va_arg(ap, int)) + { + switch (key) { + case CELT_ATTR_KEY_SAMP_RATE: + if (attr->samplerate != (va_arg(ap, int))) { + return -1; + } + break; + case CELT_ATTR_KEY_MAX_BITRATE: + if (attr->maxbitrate != (va_arg(ap, int))) { + return -1; + } + break; + case CELT_ATTR_KEY_FRAME_SIZE: + if (attr->framesize != (va_arg(ap, int))) { + return -1; + } + break; + default: + return -1; + ast_log(LOG_WARNING, "unknown attribute type %d\n", key); + } + } + return 0; +} +static int celt_getjoint(const struct ast_format_attr *fattr1, const struct ast_format_attr *fattr2, struct ast_format_attr *result) +{ + struct celt_attr *attr1 = (struct celt_attr *) fattr1; + struct celt_attr *attr2 = (struct celt_attr *) fattr2; + struct celt_attr *attr_res = (struct celt_attr *) result; + + /* sample rate is the only attribute that has any bearing on if joint capabilities exist or not */ + if (attr1->samplerate != attr2->samplerate) { + return -1; + } + /* either would work, they are guaranteed the same at this point. */ + attr_res->samplerate = attr1->samplerate; + /* Take the lowest max bitrate */ + attr_res->maxbitrate = MIN(attr1->maxbitrate, attr2->maxbitrate); + + attr_res->framesize = attr2->framesize; /* TODO figure out what joint framesize means */ + return 0; +} + +static void celt_set(struct ast_format_attr *fattr, va_list ap) +{ + enum celt_attr_keys key; + struct celt_attr *attr = (struct celt_attr *) fattr; + + for (key = va_arg(ap, int); + key != AST_FORMAT_ATTR_END; + key = va_arg(ap, int)) + { + switch (key) { + case CELT_ATTR_KEY_SAMP_RATE: + attr->samplerate = (va_arg(ap, int)); + break; + case CELT_ATTR_KEY_MAX_BITRATE: + attr->maxbitrate = (va_arg(ap, int)); + break; + case CELT_ATTR_KEY_FRAME_SIZE: + attr->framesize = (va_arg(ap, int)); + break; + default: + ast_log(LOG_WARNING, "unknown attribute type %d\n", key); + } + } +} + +static struct ast_format_attr_interface celt_interface = { + .id = AST_FORMAT_CELT, + .format_attr_cmp = celt_cmp, + .format_attr_get_joint = celt_getjoint, + .format_attr_set = celt_set, + .format_attr_isset = celt_isset, + .format_attr_get_val = celt_get_val, +}; + +static int load_module(void) +{ + if (ast_format_attr_reg_interface(&celt_interface)) { + return AST_MODULE_LOAD_DECLINE; + } + + return AST_MODULE_LOAD_SUCCESS; +} + +static int unload_module(void) +{ + ast_format_attr_unreg_interface(&celt_interface); + return 0; +} + +AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "CELT Format Attribute Module", + .load = load_module, + .unload = unload_module, + .load_pri = AST_MODPRI_CHANNEL_DEPEND, +); diff --git a/res/res_format_attr_silk.c b/res/res_format_attr_silk.c new file mode 100644 index 000000000..49122fe80 --- /dev/null +++ b/res/res_format_attr_silk.c @@ -0,0 +1,215 @@ +/* + * Asterisk -- An open source telephony toolkit. + * + * Copyright (C) 2011, Digium, Inc. + * + * David Vossel <dvossel@digium.com> + * + * See http://www.asterisk.org for more information about + * the Asterisk project. Please do not directly contact + * any of the maintainers of this project for assistance; + * the project provides a web site, mailing lists and IRC + * channels for your use. + * + * This program is free software, distributed under the terms of + * the GNU General Public License Version 2. See the LICENSE file + * at the top of the source tree. + */ + +/*! + * \file + * \brief SILK format attribute interface + * + * \author David Vossel <dvossel@digium.com> + */ + +#include "asterisk.h" + +ASTERISK_FILE_VERSION(__FILE__, "$Revision$") + +#include "asterisk/module.h" +#include "asterisk/format.h" + +/*! + * \brief SILK attribute structure. + * + * \note The only attribute that affects compatibility here is the sample rate. + */ +struct silk_attr { + unsigned int samplerate; + unsigned int maxbitrate; + unsigned int dtx; + unsigned int fec; + unsigned int packetloss_percentage; +}; + +static enum ast_format_cmp_res silk_cmp(const struct ast_format_attr *fattr1, const struct ast_format_attr *fattr2) +{ + struct silk_attr *attr1 = (struct silk_attr *) fattr1; + struct silk_attr *attr2 = (struct silk_attr *) fattr2; + + if (attr1->samplerate == attr2->samplerate) { + return AST_FORMAT_CMP_EQUAL; + } + return AST_FORMAT_CMP_NOT_EQUAL; +} + +static int silk_get_val(const struct ast_format_attr *fattr, int key, void *result) +{ + const struct silk_attr *attr = (struct silk_attr *) fattr; + int *val = result; + + switch (key) { + case SILK_ATTR_KEY_SAMP_RATE: + *val = attr->samplerate; + break; + case SILK_ATTR_KEY_MAX_BITRATE: + *val = attr->maxbitrate; + break; + case SILK_ATTR_KEY_DTX: + *val = attr->dtx; + break; + case SILK_ATTR_KEY_FEC: + *val = attr->fec; + break; + case SILK_ATTR_KEY_PACKETLOSS_PERCENTAGE: + *val = attr->packetloss_percentage; + break; + default: + return -1; + ast_log(LOG_WARNING, "unknown attribute type %d\n", key); + } + return 0; +} + +static int silk_isset(const struct ast_format_attr *fattr, va_list ap) +{ + enum silk_attr_keys key; + const struct silk_attr *attr = (struct silk_attr *) fattr; + + for (key = va_arg(ap, int); + key != AST_FORMAT_ATTR_END; + key = va_arg(ap, int)) + { + switch (key) { + case SILK_ATTR_KEY_SAMP_RATE: + if (attr->samplerate != (va_arg(ap, int))) { + return -1; + } + break; + case SILK_ATTR_KEY_MAX_BITRATE: + if (attr->maxbitrate != (va_arg(ap, int))) { + return -1; + } + break; + case SILK_ATTR_KEY_DTX: + if (attr->dtx != (va_arg(ap, int))) { + return -1; + } + break; + case SILK_ATTR_KEY_FEC: + if (attr->fec != (va_arg(ap, int))) { + return -1; + } + break; + case SILK_ATTR_KEY_PACKETLOSS_PERCENTAGE: + if (attr->packetloss_percentage != (va_arg(ap, int))) { + return -1; + } + break; + default: + return -1; + ast_log(LOG_WARNING, "unknown attribute type %d\n", key); + } + } + return 0; +} +static int silk_getjoint(const struct ast_format_attr *fattr1, const struct ast_format_attr *fattr2, struct ast_format_attr *result) +{ + struct silk_attr *attr1 = (struct silk_attr *) fattr1; + struct silk_attr *attr2 = (struct silk_attr *) fattr2; + struct silk_attr *attr_res = (struct silk_attr *) result; + int joint = -1; + + attr_res->samplerate = attr1->samplerate & attr2->samplerate; + /* sample rate is the only attribute that has any bearing on if joint capabilities exist or not */ + if (attr_res->samplerate) { + joint = 0; + } + /* Take the lowest max bitrate */ + attr_res->maxbitrate = MIN(attr1->maxbitrate, attr2->maxbitrate); + + /* Only do dtx if both sides want it. DTX is a trade off between + * computational complexity and bandwidth. */ + attr_res->dtx = attr1->dtx && attr2->dtx ? 1 : 0; + + /* Only do FEC if both sides want it. If a peer specifically requests not + * to receive with FEC, it may be a waste of bandwidth. */ + attr_res->fec = attr1->fec && attr2->fec ? 1 : 0; + + /* Use the maximum packetloss percentage between the two attributes. This affects how + * much redundancy is used in the FEC. */ + attr_res->packetloss_percentage = MAX(attr1->packetloss_percentage, attr2->packetloss_percentage); + return joint; +} + +static void silk_set(struct ast_format_attr *fattr, va_list ap) +{ + enum silk_attr_keys key; + struct silk_attr *attr = (struct silk_attr *) fattr; + + for (key = va_arg(ap, int); + key != AST_FORMAT_ATTR_END; + key = va_arg(ap, int)) + { + switch (key) { + case SILK_ATTR_KEY_SAMP_RATE: + attr->samplerate = (va_arg(ap, int)); + break; + case SILK_ATTR_KEY_MAX_BITRATE: + attr->maxbitrate = (va_arg(ap, int)); + break; + case SILK_ATTR_KEY_DTX: + attr->dtx = (va_arg(ap, int)); + break; + case SILK_ATTR_KEY_FEC: + attr->fec = (va_arg(ap, int)); + break; + case SILK_ATTR_KEY_PACKETLOSS_PERCENTAGE: + attr->packetloss_percentage = (va_arg(ap, int)); + break; + default: + ast_log(LOG_WARNING, "unknown attribute type %d\n", key); + } + } +} + +static struct ast_format_attr_interface silk_interface = { + .id = AST_FORMAT_SILK, + .format_attr_cmp = silk_cmp, + .format_attr_get_joint = silk_getjoint, + .format_attr_set = silk_set, + .format_attr_isset = silk_isset, + .format_attr_get_val = silk_get_val, +}; + +static int load_module(void) +{ + if (ast_format_attr_reg_interface(&silk_interface)) { + return AST_MODULE_LOAD_DECLINE; + } + + return AST_MODULE_LOAD_SUCCESS; +} + +static int unload_module(void) +{ + ast_format_attr_unreg_interface(&silk_interface); + return 0; +} + +AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "SILK Format Attribute Module", + .load = load_module, + .unload = unload_module, + .load_pri = AST_MODPRI_CHANNEL_DEPEND, +); diff --git a/res/res_http_post.c b/res/res_http_post.c index 0f2373730..3dde6484d 100644 --- a/res/res_http_post.c +++ b/res/res_http_post.c @@ -27,6 +27,7 @@ /*** MODULEINFO <depend>gmime</depend> + <support_level>core</support_level> ***/ @@ -37,7 +38,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") #include <sys/stat.h> #include <fcntl.h> #include <gmime/gmime.h> -#if defined (__OpenBSD__) || defined(__FreeBSD__) +#if defined (__OpenBSD__) || defined(__FreeBSD__) || defined(__Darwin__) #include <libgen.h> #endif diff --git a/res/res_jabber.c b/res/res_jabber.c index 61d436a92..46229520a 100644 --- a/res/res_jabber.c +++ b/res/res_jabber.c @@ -33,6 +33,7 @@ /*** MODULEINFO <depend>iksemel</depend> <use type="external">openssl</use> + <support_level>extended</support_level> ***/ #include "asterisk.h" diff --git a/res/res_limit.c b/res/res_limit.c index a6b4fef64..dc07a4caf 100644 --- a/res/res_limit.c +++ b/res/res_limit.c @@ -18,6 +18,9 @@ * \author Tilghman Lesher <res_limit_200607@the-tilghman.com> */ +/*** MODULEINFO + <support_level>core</support_level> + ***/ #include "asterisk.h" diff --git a/res/res_monitor.c b/res/res_monitor.c index d508da13a..61dc4a2d0 100644 --- a/res/res_monitor.c +++ b/res/res_monitor.c @@ -22,6 +22,10 @@ * * \author Mark Spencer <markster@digium.com> */ + +/*** MODULEINFO + <support_level>core</support_level> + ***/ #include "asterisk.h" diff --git a/res/res_musiconhold.c b/res/res_musiconhold.c index cc98543c6..4a052d43d 100644 --- a/res/res_musiconhold.c +++ b/res/res_musiconhold.c @@ -27,6 +27,7 @@ /*** MODULEINFO <conflict>win32</conflict> + <support_level>core</support_level> ***/ #include "asterisk.h" diff --git a/res/res_mutestream.c b/res/res_mutestream.c index 41b2fd831..92d01c7c7 100644 --- a/res/res_mutestream.c +++ b/res/res_mutestream.c @@ -29,6 +29,10 @@ * When we know and understands what happens if we zero out video, we can do that too. */ +/*** MODULEINFO + <support_level>core</support_level> + ***/ + #include "asterisk.h" ASTERISK_FILE_VERSION(__FILE__, "$Revision: 89545 $") diff --git a/res/res_odbc.c b/res/res_odbc.c index b1e72ac8d..1770bb303 100644 --- a/res/res_odbc.c +++ b/res/res_odbc.c @@ -33,6 +33,7 @@ /*** MODULEINFO <depend>generic_odbc</depend> <depend>ltdl</depend> + <support_level>core</support_level> ***/ #include "asterisk.h" diff --git a/res/res_phoneprov.c b/res/res_phoneprov.c index 24d7b6505..c6dc009ea 100644 --- a/res/res_phoneprov.c +++ b/res/res_phoneprov.c @@ -26,6 +26,10 @@ * \author Terry Wilson <twilson@digium.com> */ +/*** MODULEINFO + <support_level>extended</support_level> + ***/ + #include "asterisk.h" #include <sys/ioctl.h> diff --git a/res/res_pktccops.c b/res/res_pktccops.c index 33ecc3817..0572658ac 100644 --- a/res/res_pktccops.c +++ b/res/res_pktccops.c @@ -32,6 +32,7 @@ /*** MODULEINFO <defaultenabled>no</defaultenabled> + <support_level>extended</support_level> ***/ #include "asterisk.h" diff --git a/res/res_realtime.c b/res/res_realtime.c index 1bafe52b7..8b1488fe4 100644 --- a/res/res_realtime.c +++ b/res/res_realtime.c @@ -27,6 +27,10 @@ * \ingroup applications */ +/*** MODULEINFO + <support_level>core</support_level> + ***/ + #include "asterisk.h" ASTERISK_FILE_VERSION(__FILE__, "$Revision$") diff --git a/res/res_rtp_asterisk.c b/res/res_rtp_asterisk.c index 60f7edacf..06af4832d 100644 --- a/res/res_rtp_asterisk.c +++ b/res/res_rtp_asterisk.c @@ -28,6 +28,10 @@ * \ingroup rtp_engines */ +/*** MODULEINFO + <support_level>core</support_level> + ***/ + #include "asterisk.h" ASTERISK_FILE_VERSION(__FILE__, "$Revision$") @@ -143,6 +147,7 @@ struct ast_rtp { unsigned int dtmf_duration; /*!< Total duration in samples since the digit start event */ unsigned int dtmf_timeout; /*!< When this timestamp is reached we consider END frame lost and forcibly abort digit */ unsigned int dtmfsamples; + enum ast_rtp_dtmf_mode dtmfmode;/*!< The current DTMF mode of the RTP stream */ /* DTMF Transmission Variables */ unsigned int lastdigitts; char sending_digit; /*!< boolean - are we sending digits */ @@ -256,6 +261,8 @@ static int ast_rtp_destroy(struct ast_rtp_instance *instance); static int ast_rtp_dtmf_begin(struct ast_rtp_instance *instance, char digit); static int ast_rtp_dtmf_end(struct ast_rtp_instance *instance, char digit); static int ast_rtp_dtmf_end_with_duration(struct ast_rtp_instance *instance, char digit, unsigned int duration); +static int ast_rtp_dtmf_mode_set(struct ast_rtp_instance *instance, enum ast_rtp_dtmf_mode dtmf_mode); +static enum ast_rtp_dtmf_mode ast_rtp_dtmf_mode_get(struct ast_rtp_instance *instance); static void ast_rtp_update_source(struct ast_rtp_instance *instance); static void ast_rtp_change_source(struct ast_rtp_instance *instance); static int ast_rtp_write(struct ast_rtp_instance *instance, struct ast_frame *frame); @@ -282,6 +289,8 @@ static struct ast_rtp_engine asterisk_rtp_engine = { .dtmf_begin = ast_rtp_dtmf_begin, .dtmf_end = ast_rtp_dtmf_end, .dtmf_end_with_duration = ast_rtp_dtmf_end_with_duration, + .dtmf_mode_set = ast_rtp_dtmf_mode_set, + .dtmf_mode_get = ast_rtp_dtmf_mode_get, .update_source = ast_rtp_update_source, .change_source = ast_rtp_change_source, .write = ast_rtp_write, @@ -530,6 +539,19 @@ static int ast_rtp_destroy(struct ast_rtp_instance *instance) return 0; } +static int ast_rtp_dtmf_mode_set(struct ast_rtp_instance *instance, enum ast_rtp_dtmf_mode dtmf_mode) +{ + struct ast_rtp *rtp = ast_rtp_instance_get_data(instance); + rtp->dtmfmode = dtmf_mode; + return 0; +} + +static enum ast_rtp_dtmf_mode ast_rtp_dtmf_mode_get(struct ast_rtp_instance *instance) +{ + struct ast_rtp *rtp = ast_rtp_instance_get_data(instance); + return rtp->dtmfmode; +} + static int ast_rtp_dtmf_begin(struct ast_rtp_instance *instance, char digit) { struct ast_rtp *rtp = ast_rtp_instance_get_data(instance); @@ -1254,6 +1276,7 @@ static int ast_rtp_write(struct ast_rtp_instance *instance, struct ast_frame *fr case AST_FORMAT_SPEEX16: case AST_FORMAT_SPEEX32: case AST_FORMAT_SILK: + case AST_FORMAT_CELT: case AST_FORMAT_G723_1: case AST_FORMAT_SIREN7: case AST_FORMAT_SIREN14: diff --git a/res/res_rtp_multicast.c b/res/res_rtp_multicast.c index 0e930d61f..18256e90e 100644 --- a/res/res_rtp_multicast.c +++ b/res/res_rtp_multicast.c @@ -28,6 +28,10 @@ * \ingroup rtp_engines */ +/*** MODULEINFO + <support_level>core</support_level> + ***/ + #include "asterisk.h" ASTERISK_FILE_VERSION(__FILE__, "$Revision$") diff --git a/res/res_security_log.c b/res/res_security_log.c index 2e3d4af52..3e8c48a24 100644 --- a/res/res_security_log.c +++ b/res/res_security_log.c @@ -27,6 +27,10 @@ * \todo Escape quotes in string payload IE contents */ +/*** MODULEINFO + <support_level>core</support_level> + ***/ + #include "asterisk.h" ASTERISK_FILE_VERSION(__FILE__, "$Revision$"); diff --git a/res/res_smdi.c b/res/res_smdi.c index 3c1ce4c97..e0bde6959 100644 --- a/res/res_smdi.c +++ b/res/res_smdi.c @@ -31,6 +31,10 @@ * polling thread handle it. */ +/*** MODULEINFO + <support_level>extended</support_level> + ***/ + #include "asterisk.h" ASTERISK_FILE_VERSION(__FILE__, "$Revision$") diff --git a/res/res_snmp.c b/res/res_snmp.c index 4bf81a2f0..f717cead0 100644 --- a/res/res_snmp.c +++ b/res/res_snmp.c @@ -19,6 +19,7 @@ /*** MODULEINFO <depend>netsnmp</depend> + <support_level>extended</support_level> ***/ #include "asterisk.h" diff --git a/res/res_speech.c b/res/res_speech.c index 7a8d17e5a..de0c41e08 100644 --- a/res/res_speech.c +++ b/res/res_speech.c @@ -23,6 +23,10 @@ * \author Joshua Colp <jcolp@digium.com> */ +/*** MODULEINFO + <support_level>core</support_level> + ***/ + #include "asterisk.h" ASTERISK_FILE_VERSION(__FILE__, "$Revision$"); diff --git a/res/res_srtp.c b/res/res_srtp.c index 3e9525afd..223b79bbb 100644 --- a/res/res_srtp.c +++ b/res/res_srtp.c @@ -29,7 +29,8 @@ */ /*** MODULEINFO - <depend>srtp</depend> + <depend>srtp</depend> + <support_level>core</support_level> ***/ /* See https://wiki.asterisk.org/wiki/display/AST/Secure+Calling */ diff --git a/res/res_stun_monitor.c b/res/res_stun_monitor.c index 8ce77141d..64ca73eda 100644 --- a/res/res_stun_monitor.c +++ b/res/res_stun_monitor.c @@ -23,6 +23,10 @@ * \author David Vossel <dvossel@digium.com> */ +/*** MODULEINFO + <support_level>core</support_level> + ***/ + #include "asterisk.h" ASTERISK_FILE_VERSION(__FILE__, "$Revision$") diff --git a/res/res_timing_dahdi.c b/res/res_timing_dahdi.c index 41f74f6c9..61dda6a44 100644 --- a/res/res_timing_dahdi.c +++ b/res/res_timing_dahdi.c @@ -25,6 +25,7 @@ /*** MODULEINFO <depend>dahdi</depend> + <support_level>core</support_level> ***/ #include "asterisk.h" diff --git a/res/res_timing_kqueue.c b/res/res_timing_kqueue.c index 1fef5fb99..57091bf41 100644 --- a/res/res_timing_kqueue.c +++ b/res/res_timing_kqueue.c @@ -26,6 +26,7 @@ /*** MODULEINFO <depend>kqueue</depend> <conflict>launchd</conflict> + <support_level>extended</support_level> ***/ #include "asterisk.h" diff --git a/res/res_timing_pthread.c b/res/res_timing_pthread.c index 8cb2898d9..e89ded2d6 100644 --- a/res/res_timing_pthread.c +++ b/res/res_timing_pthread.c @@ -23,6 +23,10 @@ * \brief pthread timing interface */ +/*** MODULEINFO + <support_level>extended</support_level> + ***/ + #include "asterisk.h" ASTERISK_FILE_VERSION(__FILE__, "$Revision$"); diff --git a/res/res_timing_timerfd.c b/res/res_timing_timerfd.c index 3e686f810..80e5ca8a5 100644 --- a/res/res_timing_timerfd.c +++ b/res/res_timing_timerfd.c @@ -25,6 +25,7 @@ /*** MODULEINFO <depend>timerfd</depend> + <support_level>core</support_level> ***/ #include "asterisk.h" @@ -162,35 +163,7 @@ static void timerfd_timer_ack(int handle, unsigned int quantity) uint64_t expirations; int read_result = 0; - struct timerfd_timer *our_timer, find_helper = { - .handle = handle, - }; - - if (!(our_timer = ao2_find(timerfd_timers, &find_helper, OBJ_POINTER))) { - ast_log(LOG_ERROR, "Couldn't find timer with handle %d\n", handle); - return; - } - - if (our_timer->saved_timer.it_value.tv_nsec == 0L) { - ast_log(LOG_DEBUG, "Reading attempt on idle timerfd.\n"); - return; - } - do { - struct itimerspec timer_status; - - if (timerfd_gettime(handle, &timer_status)) { - ast_log(LOG_ERROR, "Call to timerfd_gettime() error: %s\n", strerror(errno)); - expirations = 0; - break; - } - - if ((timer_status.it_value.tv_sec == 0) && (timer_status.it_value.tv_nsec == 0)) { - ast_log(LOG_DEBUG, "Call to timerfd_timer_ack() with disarmed timer - break now.\n"); - expirations = 0; - break; - } - read_result = read(handle, &expirations, sizeof(expirations)); if (read_result == -1) { if (errno == EINTR || errno == EAGAIN) { |