[asterisk-commits] mmichelson: branch mmichelson/features_config r390039 - in /team/mmichelson/f...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed May 29 14:22:09 CDT 2013
Author: mmichelson
Date: Wed May 29 14:22:06 2013
New Revision: 390039
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=390039
Log:
Create a function capable of getting both builtin or applicationmap features.
After examining chan_sip's previous use of ast_find_call_feature, it became clear
that it was capable of getting dynamic features as well, so now it is back
to its former self.
Modified:
team/mmichelson/features_config/channels/chan_sip.c
team/mmichelson/features_config/include/asterisk/features.h
team/mmichelson/features_config/include/asterisk/features_config.h
team/mmichelson/features_config/main/features.c
team/mmichelson/features_config/main/features_config.c
Modified: team/mmichelson/features_config/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/features_config/channels/chan_sip.c?view=diff&rev=390039&r1=390038&r2=390039
==============================================================================
--- team/mmichelson/features_config/channels/chan_sip.c (original)
+++ team/mmichelson/features_config/channels/chan_sip.c Wed May 29 14:22:06 2013
@@ -21699,7 +21699,8 @@
* on phone calls.
*/
- struct ast_call_feature *feat = NULL;
+ char feat[FEATURE_MAX_LEN];
+ int feat_res = -1;
int j;
struct ast_frame f = { AST_FRAME_DTMF, };
int suppress_warning = 0; /* Supress warning if the feature is blank */
@@ -21711,25 +21712,24 @@
}
/* first, get the feature string, if it exists */
- ast_rdlock_call_features();
if (p->relatedpeer) {
if (!strcasecmp(c, "on")) {
if (ast_strlen_zero(p->relatedpeer->record_on_feature)) {
suppress_warning = 1;
} else {
- feat = ast_find_call_feature(p->relatedpeer->record_on_feature);
+ feat_res = ast_get_feature(p->owner, p->relatedpeer->record_on_feature, feat, sizeof(feat));
}
} else if (!strcasecmp(c, "off")) {
if (ast_strlen_zero(p->relatedpeer->record_off_feature)) {
suppress_warning = 1;
} else {
- feat = ast_find_call_feature(p->relatedpeer->record_off_feature);
+ feat_res = ast_get_feature(p->owner, p->relatedpeer->record_off_feature, feat, sizeof(feat));
}
} else {
ast_log(LOG_ERROR, "Received INFO requesting to record with invalid value: %s\n", c);
}
}
- if (!feat || ast_strlen_zero(feat->exten)) {
+ if (feat_res || ast_strlen_zero(feat)) {
if (!suppress_warning) {
ast_log(LOG_WARNING, "Recording requested, but no One Touch Monitor registered. (See features.conf)\n");
}
@@ -21740,14 +21740,13 @@
}
/* Send the feature code to the PBX as DTMF, just like the handset had sent it */
f.len = 100;
- for (j = 0; j < strlen(feat->exten); j++) {
- f.subclass.integer = feat->exten[j];
+ for (j = 0; j < strlen(feat); j++) {
+ f.subclass.integer = feat[j];
ast_queue_frame(p->owner, &f);
if (sipdebug) {
ast_verbose("* DTMF-relay event faked: %c\n", f.subclass.integer);
}
}
- ast_unlock_call_features();
ast_debug(1, "Got a Request to Record the channel, state %s\n", c);
transmit_response(p, "200 OK", req);
Modified: team/mmichelson/features_config/include/asterisk/features.h
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/features_config/include/asterisk/features.h?view=diff&rev=390039&r1=390038&r2=390039
==============================================================================
--- team/mmichelson/features_config/include/asterisk/features.h (original)
+++ team/mmichelson/features_config/include/asterisk/features.h Wed May 29 14:22:06 2013
@@ -242,12 +242,6 @@
*/
int ast_feature_detect(struct ast_channel *chan, struct ast_flags *features, const char *code, struct ast_call_feature *feature);
-/*!
- * \brief look for a call feature entry by its sname
- * \param name a string ptr, should match "automon", "blindxfer", "atxfer", etc.
-*/
-struct ast_call_feature *ast_find_call_feature(const char *name);
-
void ast_rdlock_call_features(void);
void ast_unlock_call_features(void);
Modified: team/mmichelson/features_config/include/asterisk/features_config.h
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/features_config/include/asterisk/features_config.h?view=diff&rev=390039&r1=390038&r2=390039
==============================================================================
--- team/mmichelson/features_config/include/asterisk/features_config.h (original)
+++ team/mmichelson/features_config/include/asterisk/features_config.h Wed May 29 14:22:06 2013
@@ -165,6 +165,25 @@
*/
int ast_get_builtin_feature(struct ast_channel *chan, const char *feature, char *buf, size_t len);
+/*!
+ * \brief Get the DTMF code for a call feature
+ *
+ * \note The channel should be locked before calling this function
+ *
+ * If no channel is provided, then the global setting for the option is returned.
+ *
+ * This function is like \ref ast_get_builtin_feature except that it will
+ * also check the applicationmap in addition to the builtin features.
+ *
+ * \param chan The channel to get the option from
+ * \param feature The short name of the feature
+ * \param[out] buf The buffer to write the DTMF value into
+ * \param size The size of the buffer in bytes
+ * \retval 0 Success
+ * \retval non-zero Unrecognized feature name
+ */
+int ast_get_feature(struct ast_channel *chan, const char *feature, char *buf, size_t len);
+
#define FEATURE_MAX_LEN 11
/*!
@@ -190,6 +209,8 @@
/*!
* \brief Get the applicationmap for a given channel.
*
+ * \note The channel should be locked before calling this function.
+ *
* This uses the value of the DYNAMIC_FEATURES channel variable to build a
* custom applicationmap for this channel. The returned container has
* applicationmap_items inside.
Modified: team/mmichelson/features_config/main/features.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/features_config/main/features.c?view=diff&rev=390039&r1=390038&r2=390039
==============================================================================
--- team/mmichelson/features_config/main/features.c (original)
+++ team/mmichelson/features_config/main/features.c Wed May 29 14:22:06 2013
@@ -3028,21 +3028,6 @@
/*!
* \internal
- * \pre Expects features_lock to be at least readlocked
- */
-struct ast_call_feature *ast_find_call_feature(const char *name)
-{
- int x;
- for (x = 0; x < FEATURES_COUNT; x++) {
- if (!strcasecmp(name, builtin_features[x].sname))
- return &builtin_features[x];
- }
-
- return find_dynamic_feature(name);
-}
-
-/*!
- * \internal
* \brief Get the extension for a given builtin feature
*
* \pre expects features_lock to be readlocked
@@ -4044,7 +4029,9 @@
RAII_VAR(struct ao2_container *, applicationmap, NULL, ao2_cleanup);
int res = 0;
+ ast_channel_lock(chan);
applicationmap = ast_get_chan_applicationmap(chan);
+ ast_channel_unlock(chan);
if (!applicationmap) {
return 0;
}
Modified: team/mmichelson/features_config/main/features_config.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/features_config/main/features_config.c?view=diff&rev=390039&r1=390038&r2=390039
==============================================================================
--- team/mmichelson/features_config/main/features_config.c (original)
+++ team/mmichelson/features_config/main/features_config.c Wed May 29 14:22:06 2013
@@ -777,6 +777,37 @@
return featuremap_get(cfg->featuremap, feature, buf, len);
}
+int ast_get_feature(struct ast_channel *chan, const char *feature, char *buf, size_t len)
+{
+ RAII_VAR(struct ao2_container *, applicationmap, NULL, ao2_cleanup);
+ RAII_VAR(struct ast_applicationmap_item *, item, NULL, ao2_cleanup);
+ if (!ast_get_builtin_feature(chan, feature, buf, len)) {
+ return 0;
+ }
+
+ /* Dang, must be in the application map */
+ if (chan) {
+ applicationmap = ast_get_chan_applicationmap(chan);
+ } else {
+ RAII_VAR(struct features_config *, cfg, ao2_global_obj_ref(globals), ao2_cleanup);
+
+ ao2_ref(cfg->applicationmap, +1);
+ applicationmap = cfg->applicationmap;
+ }
+
+ if (!applicationmap) {
+ return -1;
+ }
+
+ item = ao2_find(applicationmap, feature, OBJ_KEY);
+ if (!item) {
+ return -1;
+ }
+
+ ast_copy_string(buf, item->dtmf, len);
+ return 0;
+}
+
static struct ast_applicationmap_item *applicationmap_item_alloc(const char *name,
const char *app, const char *app_data, const char *moh_class, const char *dtmf,
unsigned int activate_on_self)
@@ -830,9 +861,7 @@
return NULL;
}
- ast_channel_lock(chan);
group_names = ast_strdupa(S_OR(pbx_builtin_getvar_helper(chan, "DYNAMIC_FEATURES"), ""));
- ast_channel_unlock(chan);
if (ast_strlen_zero(group_names)) {
return NULL;
}
More information about the asterisk-commits
mailing list