summaryrefslogtreecommitdiff
path: root/main/audiohook.c
diff options
context:
space:
mode:
authorMark Michelson <mmichelson@digium.com>2007-11-30 21:19:57 +0000
committerMark Michelson <mmichelson@digium.com>2007-11-30 21:19:57 +0000
commit6b08c442c78b8b6622ae25505458f320b189e492 (patch)
tree978560a7d79aeafa387c5164bc30cb9b72770980 /main/audiohook.c
parentfac74808203c697677a87d34ccc409a3fe203a95 (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: https://origsvn.digium.com/svn/asterisk/trunk@90388 65c4cc65-6c06-0410-ace0-fbb531ad65f3
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;
+}
+