summaryrefslogtreecommitdiff
path: root/res/ari/resource_bridges.c
diff options
context:
space:
mode:
authorJonathan Rose <jrose@digium.com>2013-08-23 00:26:19 +0000
committerJonathan Rose <jrose@digium.com>2013-08-23 00:26:19 +0000
commit21e22310c72f0c863f73dde8c31208cfdfa5aa3c (patch)
tree5945e2a28d0b42b3abe354e53d79a08c3d8b0450 /res/ari/resource_bridges.c
parentc25c093c676b27f9eaf9847cfeeda8e8cdc46d46 (diff)
ARI: Music on Hold/Background Music for bridges
Adds ARI functions to be able to turn on/off music on hold in a bridge. It actually functions more as a background music without further actions on the bridge since if the rest of the channels in the bridge aren't explicitly muted, they will still be able to communicate. (closes issue ASTERISK-21974) Reported by: Matt Jordan Review: https://reviewboard.asterisk.org/r/2688/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@397505 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'res/ari/resource_bridges.c')
-rw-r--r--res/ari/resource_bridges.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/res/ari/resource_bridges.c b/res/ari/resource_bridges.c
index 348cf972b..670792fc1 100644
--- a/res/ari/resource_bridges.c
+++ b/res/ari/resource_bridges.c
@@ -43,6 +43,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/bridge.h"
#include "asterisk/format_cap.h"
#include "asterisk/file.h"
+#include "asterisk/musiconhold.h"
/*!
* \brief Finds a bridge, filling the response with an error, if appropriate.
@@ -498,6 +499,48 @@ void ast_ari_record_bridge(struct ast_variable *headers, struct ast_record_bridg
ast_ari_response_created(response, recording_url, json);
}
+void ast_ari_moh_start_bridge(struct ast_variable *headers, struct ast_moh_start_bridge_args *args, struct ast_ari_response *response)
+{
+ RAII_VAR(struct ast_bridge *, bridge, find_bridge(response, args->bridge_id), ao2_cleanup);
+ struct ast_channel *moh_channel;
+ const char *moh_class = args->moh_class;
+
+ if (!bridge) {
+ /* The response is provided by find_bridge() */
+ return;
+ }
+
+ moh_channel = stasis_app_bridge_moh_channel(bridge);
+ if (!moh_channel) {
+ ast_ari_response_alloc_failed(response);
+ return;
+ }
+
+ ast_moh_start(moh_channel, moh_class, NULL);
+
+ ast_ari_response_no_content(response);
+
+}
+
+void ast_ari_moh_stop_bridge(struct ast_variable *headers, struct ast_moh_stop_bridge_args *args, struct ast_ari_response *response)
+{
+ RAII_VAR(struct ast_bridge *, bridge, find_bridge(response, args->bridge_id), ao2_cleanup);
+
+ if (!bridge) {
+ /* the response is provided by find_bridge() */
+ return;
+ }
+
+ if (stasis_app_bridge_moh_stop(bridge)) {
+ ast_ari_response_error(
+ response, 409, "Conflict",
+ "Bridge isn't playing music");
+ return;
+ }
+
+ ast_ari_response_no_content(response);
+}
+
void ast_ari_get_bridge(struct ast_variable *headers, struct ast_get_bridge_args *args, struct ast_ari_response *response)
{
RAII_VAR(struct ast_bridge_snapshot *, snapshot, ast_bridge_snapshot_get_latest(args->bridge_id), ao2_cleanup);