aboutsummaryrefslogtreecommitdiffstats
path: root/main/audiohook.c
diff options
context:
space:
mode:
authormmichelson <mmichelson@f38db490-d61c-443f-a65b-d21fe96a405b>2007-11-30 21:19:57 +0000
committermmichelson <mmichelson@f38db490-d61c-443f-a65b-d21fe96a405b>2007-11-30 21:19:57 +0000
commita7c0447e636acec7aae62d8e86c490ccee1d678f (patch)
tree978560a7d79aeafa387c5164bc30cb9b72770980 /main/audiohook.c
parent7cfa10f05b13911f3595a3db8b058ee587dfd8d5 (diff)
Adding support for the "automixmonitor" dial and queue options.
This works in much the same way as the automonitor, except that instead of using the monitor app, it uses the mixmonitor app. By providing an 'x' or 'X' as a dial or queue option, a DTMF sequence may be entered (as defined in features.conf) to start the one-touch mixmonitor. This patch also introduces some new API calls to the audiohooks code for searching for an audiohook by type and for searching for a running audiohook by type. Big thanks to joetester for writing the initial patch, testing it and patiently waiting for it to be committed. (closes issue #10185, reported and patched by xmarksthespot) git-svn-id: http://svn.digium.com/svn/asterisk/trunk@90388 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main/audiohook.c')
-rw-r--r--main/audiohook.c80
1 files changed, 80 insertions, 0 deletions
diff --git a/main/audiohook.c b/main/audiohook.c
index f1e5f5809..9b9793061 100644
--- a/main/audiohook.c
+++ b/main/audiohook.c
@@ -612,3 +612,83 @@ void ast_audiohook_trigger_wait(struct ast_audiohook *audiohook)
return;
}
+
+/* Count number of channel audiohooks by type, regardless of type */
+int ast_channel_audiohook_count_by_source(struct ast_channel *chan, const char *source, enum ast_audiohook_type type)
+{
+ int count = 0;
+ struct ast_audiohook *ah = NULL;
+
+ if (!chan->audiohooks)
+ return -1;
+
+ switch (type) {
+ case AST_AUDIOHOOK_TYPE_SPY:
+ AST_LIST_TRAVERSE_SAFE_BEGIN(&chan->audiohooks->spy_list, ah, list) {
+ if (!strcmp(ah->source, source)) {
+ count++;
+ }
+ }
+ AST_LIST_TRAVERSE_SAFE_END;
+ break;
+ case AST_AUDIOHOOK_TYPE_WHISPER:
+ AST_LIST_TRAVERSE_SAFE_BEGIN(&chan->audiohooks->whisper_list, ah, list) {
+ if (!strcmp(ah->source, source)) {
+ count++;
+ }
+ }
+ AST_LIST_TRAVERSE_SAFE_END;
+ break;
+ case AST_AUDIOHOOK_TYPE_MANIPULATE:
+ AST_LIST_TRAVERSE_SAFE_BEGIN(&chan->audiohooks->manipulate_list, ah, list) {
+ if (!strcmp(ah->source, source)) {
+ count++;
+ }
+ }
+ AST_LIST_TRAVERSE_SAFE_END;
+ break;
+ default:
+ ast_log(LOG_DEBUG, "Invalid audiohook type supplied, (%d)\n", type);
+ return -1;
+ }
+
+ return count;
+}
+
+/* Count number of channel audiohooks by type that are running */
+int ast_channel_audiohook_count_by_source_running(struct ast_channel *chan, const char *source, enum ast_audiohook_type type)
+{
+ int count = 0;
+ struct ast_audiohook *ah = NULL;
+ if (!chan->audiohooks)
+ return -1;
+
+ switch (type) {
+ case AST_AUDIOHOOK_TYPE_SPY:
+ AST_LIST_TRAVERSE_SAFE_BEGIN(&chan->audiohooks->spy_list, ah, list) {
+ if ((!strcmp(ah->source, source)) && (ah->status == AST_AUDIOHOOK_STATUS_RUNNING))
+ count++;
+ }
+ AST_LIST_TRAVERSE_SAFE_END;
+ break;
+ case AST_AUDIOHOOK_TYPE_WHISPER:
+ AST_LIST_TRAVERSE_SAFE_BEGIN(&chan->audiohooks->whisper_list, ah, list) {
+ if ((!strcmp(ah->source, source)) && (ah->status == AST_AUDIOHOOK_STATUS_RUNNING))
+ count++;
+ }
+ AST_LIST_TRAVERSE_SAFE_END;
+ break;
+ case AST_AUDIOHOOK_TYPE_MANIPULATE:
+ AST_LIST_TRAVERSE_SAFE_BEGIN(&chan->audiohooks->manipulate_list, ah, list) {
+ if ((!strcmp(ah->source, source)) && (ah->status == AST_AUDIOHOOK_STATUS_RUNNING))
+ count++;
+ }
+ AST_LIST_TRAVERSE_SAFE_END;
+ break;
+ default:
+ ast_log(LOG_DEBUG, "Invalid audiohook type supplied, (%d)\n", type);
+ return -1;
+ }
+ return count;
+}
+