summaryrefslogtreecommitdiff
path: root/res/res_monitor.c
diff options
context:
space:
mode:
authorMatthew Jordan <mjordan@digium.com>2013-05-24 20:44:07 +0000
committerMatthew Jordan <mjordan@digium.com>2013-05-24 20:44:07 +0000
commit06be8463b683333c79845402d55168ef1b582fa9 (patch)
tree2fe0871cfec4d5edf3aae763541ff7efa32a444a /res/res_monitor.c
parentc1b51fd2654736fd7c614d1571f904e236006651 (diff)
Migrate a large number of AMI events over to Stasis-Core
This patch moves a number of AMI events over to the Stasis-Core message bus. This includes: * ChanSpyStart/Stop * MonitorStart/Stop * MusicOnHoldStart/Stop * FullyBooted/Reload * All Voicemail/MWI related events In addition, it adds some Stasis-Core and AMI support for generic AMI messages, refactors the message router in AMI to use a single router with topic forwarding for the topics that AMI cares about, and refactors MWI message types and topics to be more name compliant. Review: https://reviewboard.asterisk.org/r/2532 (closes issue ASTERISK-21462) git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@389733 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'res/res_monitor.c')
-rw-r--r--res/res_monitor.c29
1 files changed, 17 insertions, 12 deletions
diff --git a/res/res_monitor.c b/res/res_monitor.c
index 9aca24a0d..72911b5b1 100644
--- a/res/res_monitor.c
+++ b/res/res_monitor.c
@@ -40,8 +40,10 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/file.h"
#include "asterisk/pbx.h"
#include "asterisk/module.h"
-#include "asterisk/manager.h"
#include "asterisk/cli.h"
+#include "asterisk/manager.h"
+#include "asterisk/stasis.h"
+#include "asterisk/stasis_channels.h"
#define AST_API_MODULE
#include "asterisk/monitor.h"
#include "asterisk/app.h"
@@ -291,6 +293,7 @@ int AST_OPTIONAL_API_NAME(ast_monitor_start)(struct ast_channel *chan, const cha
const char *fname_base, int need_lock, int stream_action)
{
int res = 0;
+ RAII_VAR(struct stasis_message *, message, NULL, ao2_cleanup);
LOCK_IF_NEEDED(chan, need_lock);
@@ -393,11 +396,12 @@ int AST_OPTIONAL_API_NAME(ast_monitor_start)(struct ast_channel *chan, const cha
/* so we know this call has been monitored in case we need to bill for it or something */
pbx_builtin_setvar_helper(chan, "__MONITORED","true");
- ast_manager_event(chan, EVENT_FLAG_CALL, "MonitorStart",
- "Channel: %s\r\n"
- "Uniqueid: %s\r\n",
- ast_channel_name(chan),
- ast_channel_uniqueid(chan));
+ message = ast_channel_cached_blob_create(chan,
+ ast_channel_monitor_start_type(),
+ NULL);
+ if (message) {
+ stasis_publish(ast_channel_topic(chan), message);
+ }
} else {
ast_debug(1,"Cannot start monitoring %s, already monitored\n", ast_channel_name(chan));
res = -1;
@@ -437,6 +441,7 @@ static const char *get_soxmix_format(const char *format)
int AST_OPTIONAL_API_NAME(ast_monitor_stop)(struct ast_channel *chan, int need_lock)
{
int delfiles = 0;
+ RAII_VAR(struct stasis_message *, message, NULL, ao2_cleanup);
LOCK_IF_NEEDED(chan, need_lock);
@@ -511,12 +516,12 @@ int AST_OPTIONAL_API_NAME(ast_monitor_stop)(struct ast_channel *chan, int need_l
ast_free(ast_channel_monitor(chan));
ast_channel_monitor_set(chan, NULL);
- ast_manager_event(chan, EVENT_FLAG_CALL, "MonitorStop",
- "Channel: %s\r\n"
- "Uniqueid: %s\r\n",
- ast_channel_name(chan),
- ast_channel_uniqueid(chan)
- );
+ message = ast_channel_cached_blob_create(chan,
+ ast_channel_monitor_stop_type(),
+ NULL);
+ if (message) {
+ stasis_publish(ast_channel_topic(chan), message);
+ }
pbx_builtin_setvar_helper(chan, "MONITORED", NULL);
}
pbx_builtin_setvar_helper(chan, "AUTO_MONITOR", NULL);