#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"
</parameter>
</syntax>
</function>
+ <managerEvent language="en_US" name="MixMonitorStart">
+ <managerEventInstance class="EVENT_FLAG_CALL">
+ <synopsis>Raised when monitoring has started on a channel.</synopsis>
+ <syntax>
+ <channel_snapshot/>
+ </syntax>
+ <see-also>
+ <ref type="managerEvent">MixMonitorStop</ref>
+ <ref type="application">MixMonitor</ref>
+ <ref type="manager">MixMonitor</ref>
+ </see-also>
+ </managerEventInstance>
+ </managerEvent>
+ <managerEvent language="en_US" name="MixMonitorStop">
+ <managerEventInstance class="EVENT_FLAG_CALL">
+ <synopsis>Raised when monitoring has stopped on a channel.</synopsis>
+ <syntax>
+ <channel_snapshot/>
+ </syntax>
+ <see-also>
+ <ref type="managerEvent">MixMonitorStart</ref>
+ <ref type="application">StopMixMonitor</ref>
+ <ref type="manager">StopMixMonitor</ref>
+ </see-also>
+ </managerEventInstance>
+ </managerEvent>
+ <managerEvent language="en_US" name="MixMonitorMute">
+ <managerEventInstance class="EVENT_FLAG_CALL">
+ <synopsis>Raised when monitoring is muted or unmuted on a channel.</synopsis>
+ <syntax>
+ <channel_snapshot/>
+ <parameter name="Direction">
+ <para>Which part of the recording was muted or unmuted: read, write or both
+ (from channel, to channel or both directions).</para>
+ </parameter>
+ <parameter name="State">
+ <para>If the monitoring was muted or unmuted: 1 when muted, 0 when unmuted.</para>
+ </parameter>
+ </syntax>
+ <see-also>
+ <ref type="manager">MixMonitorMute</ref>
+ </see-also>
+ </managerEventInstance>
+ </managerEvent>
+
***/
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);
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;
}
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);
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;
}
const char *direction = astman_get_header(m,"Direction");
int clearmute = 1;
enum ast_audiohook_flags flag;
+ RAII_VAR(struct stasis_message *, stasis_message, NULL, ao2_cleanup);
+ RAII_VAR(struct ast_json *, stasis_message_blob, NULL, ast_json_unref);
if (ast_strlen_zero(direction)) {
astman_send_error(s, m, "No direction specified. Must be read, write or both");
return AMI_SUCCESS;
}
+ stasis_message_blob = ast_json_pack("{s: s, s: b}",
+ "direction", direction,
+ "state", ast_true(state));
+
+ stasis_message = ast_channel_blob_create_from_cache(ast_channel_uniqueid(c),
+ ast_channel_mixmonitor_mute_type(), stasis_message_blob);
+
+ if (stasis_message) {
+ stasis_publish(ast_channel_topic(c), stasis_message);
+ }
+
astman_append(s, "Response: Success\r\n");
if (!ast_strlen_zero(id)) {
; 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
--- /dev/null
+Subject: app_mixmonitor
+
+app_mixmonitor now sends manager events MixMonitorStart, MixMonitorStop and
+MixMonitorMute when the channel monitoring is started, stopped and muted (or
+unmuted) respectively.
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
+ * \brief Message type for muting or unmuting mixmonitor on a channel
+ *
+ * \retval A stasis message type
+ */
+struct stasis_message_type *ast_channel_mixmonitor_mute_type(void);
+
+/*!
+ * \since 18.0.0
* \brief Message type for agent login on a channel
*
* \retval A stasis message type
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 void channel_mixmonitor_mute_cb(void *data, struct stasis_subscription *sub,
+ struct stasis_message *message)
+{
+ RAII_VAR(struct ast_str *, channel_event_string, NULL, ast_free);
+ RAII_VAR(struct ast_str *, event_buffer, ast_str_create(64), ast_free);
+ struct ast_channel_blob *payload = stasis_message_data(message);
+ struct ast_json *direction = ast_json_object_get(payload->blob, "direction");
+ const int state = ast_json_is_true(ast_json_object_get(payload->blob, "state"));
+
+ if (!event_buffer) {
+ return;
+ }
+
+ channel_event_string = ast_manager_build_channel_state_string(payload->snapshot);
+ if (!channel_event_string) {
+ return;
+ }
+
+ if (direction) {
+ ast_str_append(&event_buffer, 0, "Direction: %s\r\n", ast_json_string_get(direction));
+ }
+ ast_str_append(&event_buffer, 0, "State: %s\r\n", state ? "1" : "0");
+
+ manager_event(EVENT_FLAG_CALL, "MixMonitorMute",
+ "%s"
+ "%s",
+ ast_str_buffer(channel_event_string),
+ ast_str_buffer(event_buffer));
+
+}
+
static int dial_status_end(const char *dialstatus)
{
return (strcmp(dialstatus, "RINGING") &&
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);
+
+ ret |= stasis_message_router_add(message_router,
+ ast_channel_mixmonitor_mute_type(), channel_mixmonitor_mute_cb, NULL);
+
/* If somehow we failed to add any routes, just shut down the whole
* thing and fail it.
*/
<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_mixmonitor_mute_type" />
<enum name="ast_channel_agent_login_type" />
<enum name="ast_channel_agent_logoff_type" />
<enum name="ast_channel_talking_start" />
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_mixmonitor_mute_type);
STASIS_MESSAGE_TYPE_DEFN(ast_channel_agent_login_type,
.to_ami = agent_login_to_ami,
);
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_mixmonitor_mute_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);
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_mixmonitor_mute_type);
res |= STASIS_MESSAGE_TYPE_INIT(ast_channel_talking_start);
res |= STASIS_MESSAGE_TYPE_INIT(ast_channel_talking_stop);