[Asterisk-code-review] ARI: Ability to inhibit COLP frames when adding channels to a bridge (asterisk[master])
Jean Aunis - Prescom
asteriskteam at digium.com
Mon Nov 25 04:57:28 CST 2019
Jean Aunis - Prescom has uploaded this change for review. ( https://gerrit.asterisk.org/c/asterisk/+/13306 )
Change subject: ARI: Ability to inhibit COLP frames when adding channels to a bridge
......................................................................
ARI: Ability to inhibit COLP frames when adding channels to a bridge
This patch adds a new flag "inhibitCOLP" to the addChannel operation in the
Bridges REST API. When set, this flag avoids generating COLP frames when the
specified channels enter the bridge.
ASTERISK-28629
Change-Id: Ib995d4f0c6106279aa448b34b042b68f0f2ca5dc
---
M include/asterisk/bridge_features.h
M include/asterisk/stasis_app.h
M res/ari/resource_bridges.c
M res/ari/resource_bridges.h
M res/res_ari_bridges.c
M res/stasis/control.c
M rest-api/api-docs/bridges.json
7 files changed, 41 insertions(+), 1 deletion(-)
git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/06/13306/1
diff --git a/include/asterisk/bridge_features.h b/include/asterisk/bridge_features.h
index f9af8fb..9b5f70f 100644
--- a/include/asterisk/bridge_features.h
+++ b/include/asterisk/bridge_features.h
@@ -277,6 +277,8 @@
unsigned int mute:1;
/*! TRUE if DTMF should be passed into the bridge tech. */
unsigned int dtmf_passthrough:1;
+ /*! TRUE to avoid generating COLP frames when joining the bridge */
+ unsigned int inhibit_colp:1;
};
/*!
diff --git a/include/asterisk/stasis_app.h b/include/asterisk/stasis_app.h
index 01c7ff4..7c6f658 100644
--- a/include/asterisk/stasis_app.h
+++ b/include/asterisk/stasis_app.h
@@ -838,6 +838,15 @@
struct stasis_app_control *control, int mute);
/*!
+ * \brief Set whether COLP frames should be generated when joining the bridge
+ *
+ * \param control Control whose channel should have its audio muted when bridged
+ * \param mute Whether COLP frames should be generated (0) or not (1).
+ */
+void stasis_app_control_inhibit_colp_in_bridge(
+ struct stasis_app_control *control, int inhibit_colp);
+
+/*!
* \since 12
* \brief Gets the bridge currently associated with a control object.
*
diff --git a/res/ari/resource_bridges.c b/res/ari/resource_bridges.c
index 33e4cd1..369174d 100644
--- a/res/ari/resource_bridges.c
+++ b/res/ari/resource_bridges.c
@@ -221,6 +221,7 @@
if (!stasis_app_control_bridge_features_init(list->controls[i])) {
stasis_app_control_absorb_dtmf_in_bridge(list->controls[i], args->absorb_dtmf);
stasis_app_control_mute_in_bridge(list->controls[i], args->mute);
+ stasis_app_control_inhibit_colp_in_bridge(list->controls[i], args->inhibit_colp);
}
}
diff --git a/res/ari/resource_bridges.h b/res/ari/resource_bridges.h
index 0d0286c..424ed8b 100644
--- a/res/ari/resource_bridges.h
+++ b/res/ari/resource_bridges.h
@@ -154,6 +154,8 @@
int absorb_dtmf;
/*! Mute audio from this channel, preventing it to pass through to the bridge */
int mute;
+ /*! Do not generate COLP frames when joining the bridge */
+ int inhibit_colp;
};
/*!
* \brief Body parsing function for /bridges/{bridgeId}/addChannel.
diff --git a/res/res_ari_bridges.c b/res/res_ari_bridges.c
index 7ef0f68..2cbf9c0 100644
--- a/res/res_ari_bridges.c
+++ b/res/res_ari_bridges.c
@@ -440,6 +440,10 @@
if (field) {
args->mute = ast_json_is_true(field);
}
+ field = ast_json_object_get(body, "inhibitCOLP");
+ if (field) {
+ args->inhibit_colp = ast_json_is_true(field);
+ }
return 0;
}
@@ -515,6 +519,9 @@
if (strcmp(i->name, "mute") == 0) {
args.mute = ast_true(i->value);
} else
+ if (strcmp(i->name, "inhibitCOLP") == 0) {
+ args.inhibit_colp = ast_true(i->value);
+ } else
{}
}
for (i = path_vars; i; i = i->next) {
diff --git a/res/stasis/control.c b/res/stasis/control.c
index 96ddf39..193fe6a 100644
--- a/res/stasis/control.c
+++ b/res/stasis/control.c
@@ -1285,6 +1285,7 @@
{
int res;
struct ast_bridge_features *features;
+ int flags = AST_BRIDGE_IMPART_CHAN_DEPARTABLE;
if (!control || !bridge) {
return -1;
@@ -1332,6 +1333,9 @@
/* Pull bridge features from the control */
features = control->bridge_features;
control->bridge_features = NULL;
+ if(features && features->inhibit_colp) {
+ flags |= AST_BRIDGE_IMPART_INHIBIT_JOIN_COLP;
+ }
ast_assert(stasis_app_get_bridge(control) == NULL);
/* We need to set control->bridge here since bridge_after_cb may be run
@@ -1349,7 +1353,7 @@
chan,
swap,
features, /* features */
- AST_BRIDGE_IMPART_CHAN_DEPARTABLE);
+ flags);
if (res != 0) {
/* ast_bridge_impart failed before it could spawn the depart
* thread. The callbacks aren't called in this case.
@@ -1469,6 +1473,12 @@
control->bridge_features->mute = mute;
}
+void stasis_app_control_inhibit_colp_in_bridge(
+ struct stasis_app_control *control, int inhibit_colp)
+{
+ control->bridge_features->inhibit_colp = inhibit_colp;
+}
+
void control_flush_queue(struct stasis_app_control *control)
{
struct ao2_iterator iter;
diff --git a/rest-api/api-docs/bridges.json b/rest-api/api-docs/bridges.json
index 22743c3..29d8d16 100644
--- a/rest-api/api-docs/bridges.json
+++ b/rest-api/api-docs/bridges.json
@@ -191,6 +191,15 @@
"allowMultiple": false,
"dataType": "boolean",
"defaultValue": false
+ },
+ {
+ "name": "inhibitCOLP",
+ "description": "Do not generate COLP frames when joining the bridge",
+ "paramType": "query",
+ "required": false,
+ "allowMultiple": false,
+ "dataType": "boolean",
+ "defaultValue": false
}
],
"errorResponses": [
--
To view, visit https://gerrit.asterisk.org/c/asterisk/+/13306
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Change-Id: Ib995d4f0c6106279aa448b34b042b68f0f2ca5dc
Gerrit-Change-Number: 13306
Gerrit-PatchSet: 1
Gerrit-Owner: Jean Aunis - Prescom <jean.aunis at prescom.fr>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20191125/8826c9ad/attachment.html>
More information about the asterisk-code-review
mailing list