[Asterisk-code-review] app_mixmonitor: Add AMI events MixMonitorStart and MixMonitorStop. (asterisk[master])
Sébastien Duthil
asteriskteam at digium.com
Thu Jan 14 16:14:05 CST 2021
Sébastien Duthil has uploaded this change for review. ( https://gerrit.asterisk.org/c/asterisk/+/15325 )
Change subject: app_mixmonitor: Add AMI events MixMonitorStart and MixMonitorStop.
......................................................................
app_mixmonitor: Add AMI events MixMonitorStart and MixMonitorStop.
Change-Id: I1862d58264c2c8b5d8983272cb29734b184d67c5
---
M apps/app_mixmonitor.c
M configs/samples/stasis.conf.sample
M include/asterisk/stasis_channels.h
M main/manager_channels.c
M main/stasis.c
M main/stasis_channels.c
6 files changed, 67 insertions(+), 1 deletion(-)
git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/25/15325/1
diff --git a/apps/app_mixmonitor.c b/apps/app_mixmonitor.c
index 239901f..50b119a 100644
--- a/apps/app_mixmonitor.c
+++ b/apps/app_mixmonitor.c
@@ -51,6 +51,8 @@
#include "asterisk/channel.h"
#include "asterisk/autochan.h"
#include "asterisk/manager.h"
+#include "asterisk/stasis.h"
+#include "asterisk/stasis_channels.h"
#include "asterisk/callerid.h"
#include "asterisk/mod_format.h"
#include "asterisk/linkedlists.h"
@@ -1077,6 +1079,7 @@
struct ast_flags flags = { 0 };
char *recipients = NULL;
char *parse;
+ RAII_VAR(struct stasis_message *, message, NULL, ao2_cleanup);
AST_DECLARE_APP_ARGS(args,
AST_APP_ARG(filename);
AST_APP_ARG(options);
@@ -1197,6 +1200,13 @@
ast_module_unref(ast_module_info->self);
}
+ message = ast_channel_blob_create_from_cache(ast_channel_uniqueid(chan),
+ ast_channel_mixmonitor_start_type(),
+ NULL);
+ if (message) {
+ stasis_publish(ast_channel_topic(chan), message);
+ }
+
return 0;
}
@@ -1206,6 +1216,7 @@
char *parse = "";
struct mixmonitor_ds *mixmonitor_ds;
const char *beep_id = NULL;
+ RAII_VAR(struct stasis_message *, message, NULL, ao2_cleanup);
AST_DECLARE_APP_ARGS(args,
AST_APP_ARG(mixmonid);
@@ -1263,6 +1274,13 @@
ast_beep_stop(chan, beep_id);
}
+ message = ast_channel_blob_create_from_cache(ast_channel_uniqueid(chan),
+ ast_channel_mixmonitor_stop_type(),
+ NULL);
+ if (message) {
+ stasis_publish(ast_channel_topic(chan), message);
+ }
+
return 0;
}
diff --git a/configs/samples/stasis.conf.sample b/configs/samples/stasis.conf.sample
index e591e76..46a240e 100644
--- a/configs/samples/stasis.conf.sample
+++ b/configs/samples/stasis.conf.sample
@@ -63,6 +63,8 @@
; decline=ast_channel_moh_stop_type
; decline=ast_channel_monitor_start_type
; decline=ast_channel_monitor_stop_type
+; decline=ast_channel_mixmonitor_start_type
+; decline=ast_channel_mixmonitor_stop_type
; decline=ast_channel_agent_login_type
; decline=ast_channel_agent_logoff_type
; decline=ast_channel_talking_start
diff --git a/include/asterisk/stasis_channels.h b/include/asterisk/stasis_channels.h
index 9c47984..152d545 100644
--- a/include/asterisk/stasis_channels.h
+++ b/include/asterisk/stasis_channels.h
@@ -590,7 +590,23 @@
struct stasis_message_type *ast_channel_monitor_stop_type(void);
/*!
- * \since 12.0.0
+ * \since 18
+ * \brief Message type for starting mixmonitor on a channel
+ *
+ * \retval A stasis message type
+ */
+struct stasis_message_type *ast_channel_mixmonitor_start_type(void);
+
+/*!
+ * \since 18
+ * \brief Message type for stopping mixmonitor on a channel
+ *
+ * \retval A stasis message type
+ */
+struct stasis_message_type *ast_channel_mixmonitor_stop_type(void);
+
+/*!
+ * \since 18.0.0
* \brief Message type for agent login on a channel
*
* \retval A stasis message type
diff --git a/main/manager_channels.c b/main/manager_channels.c
index 73b76c8..6dc32ee 100644
--- a/main/manager_channels.c
+++ b/main/manager_channels.c
@@ -1116,6 +1116,22 @@
publish_basic_channel_event("MonitorStop", EVENT_FLAG_CALL, payload->snapshot);
}
+static void channel_mixmonitor_start_cb(void *data, struct stasis_subscription *sub,
+ struct stasis_message *message)
+{
+ struct ast_channel_blob *payload = stasis_message_data(message);
+
+ publish_basic_channel_event("MixMonitorStart", EVENT_FLAG_CALL, payload->snapshot);
+}
+
+static void channel_mixmonitor_stop_cb(void *data, struct stasis_subscription *sub,
+ struct stasis_message *message)
+{
+ struct ast_channel_blob *payload = stasis_message_data(message);
+
+ publish_basic_channel_event("MixMonitorStop", EVENT_FLAG_CALL, payload->snapshot);
+}
+
static int dial_status_end(const char *dialstatus)
{
return (strcmp(dialstatus, "RINGING") &&
@@ -1320,6 +1336,12 @@
ret |= stasis_message_router_add(message_router,
ast_channel_monitor_stop_type(), channel_monitor_stop_cb, NULL);
+ ret |= stasis_message_router_add(message_router,
+ ast_channel_mixmonitor_start_type(), channel_mixmonitor_start_cb, NULL);
+
+ ret |= stasis_message_router_add(message_router,
+ ast_channel_mixmonitor_stop_type(), channel_mixmonitor_stop_cb, NULL);
+
/* If somehow we failed to add any routes, just shut down the whole
* thing and fail it.
*/
diff --git a/main/stasis.c b/main/stasis.c
index 44d5973..b2172e9 100644
--- a/main/stasis.c
+++ b/main/stasis.c
@@ -130,6 +130,8 @@
<enum name="ast_channel_moh_stop_type" />
<enum name="ast_channel_monitor_start_type" />
<enum name="ast_channel_monitor_stop_type" />
+ <enum name="ast_channel_mixmonitor_start_type" />
+ <enum name="ast_channel_mixmonitor_stop_type" />
<enum name="ast_channel_agent_login_type" />
<enum name="ast_channel_agent_logoff_type" />
<enum name="ast_channel_talking_start" />
diff --git a/main/stasis_channels.c b/main/stasis_channels.c
index 3d213c7..925f75c 100644
--- a/main/stasis_channels.c
+++ b/main/stasis_channels.c
@@ -1606,6 +1606,8 @@
STASIS_MESSAGE_TYPE_DEFN(ast_channel_moh_stop_type);
STASIS_MESSAGE_TYPE_DEFN(ast_channel_monitor_start_type);
STASIS_MESSAGE_TYPE_DEFN(ast_channel_monitor_stop_type);
+STASIS_MESSAGE_TYPE_DEFN(ast_channel_mixmonitor_start_type);
+STASIS_MESSAGE_TYPE_DEFN(ast_channel_mixmonitor_stop_type);
STASIS_MESSAGE_TYPE_DEFN(ast_channel_agent_login_type,
.to_ami = agent_login_to_ami,
);
@@ -1649,6 +1651,8 @@
STASIS_MESSAGE_TYPE_CLEANUP(ast_channel_moh_stop_type);
STASIS_MESSAGE_TYPE_CLEANUP(ast_channel_monitor_start_type);
STASIS_MESSAGE_TYPE_CLEANUP(ast_channel_monitor_stop_type);
+ STASIS_MESSAGE_TYPE_CLEANUP(ast_channel_mixmonitor_start_type);
+ STASIS_MESSAGE_TYPE_CLEANUP(ast_channel_mixmonitor_stop_type);
STASIS_MESSAGE_TYPE_CLEANUP(ast_channel_agent_login_type);
STASIS_MESSAGE_TYPE_CLEANUP(ast_channel_agent_logoff_type);
STASIS_MESSAGE_TYPE_CLEANUP(ast_channel_talking_start);
@@ -1699,6 +1703,8 @@
res |= STASIS_MESSAGE_TYPE_INIT(ast_channel_moh_stop_type);
res |= STASIS_MESSAGE_TYPE_INIT(ast_channel_monitor_start_type);
res |= STASIS_MESSAGE_TYPE_INIT(ast_channel_monitor_stop_type);
+ res |= STASIS_MESSAGE_TYPE_INIT(ast_channel_mixmonitor_start_type);
+ res |= STASIS_MESSAGE_TYPE_INIT(ast_channel_mixmonitor_stop_type);
res |= STASIS_MESSAGE_TYPE_INIT(ast_channel_talking_start);
res |= STASIS_MESSAGE_TYPE_INIT(ast_channel_talking_stop);
--
To view, visit https://gerrit.asterisk.org/c/asterisk/+/15325
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Change-Id: I1862d58264c2c8b5d8983272cb29734b184d67c5
Gerrit-Change-Number: 15325
Gerrit-PatchSet: 1
Gerrit-Owner: Sébastien Duthil <sduthil at wazo.community>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20210114/5cf70ee2/attachment.html>
More information about the asterisk-code-review
mailing list