[Asterisk-code-review] res_stasis.c: Added video_single option for bridge creation (asterisk[13])

Friendly Automation asteriskteam at digium.com
Thu Sep 10 09:48:32 CDT 2020


Friendly Automation has submitted this change. ( https://gerrit.asterisk.org/c/asterisk/+/14905 )

Change subject: res_stasis.c: Added video_single option for bridge creation
......................................................................

res_stasis.c: Added video_single option for bridge creation

Currently, it was not possible to create bridge with video_mode single.
This made hard to put the bridge in a vidoe_single mode.
So, added video_single option for Bridge creation using the ARI.
This allows create a bridge with video_mode single.

ASTERISK-29055

Change-Id: I43e720e5c83fc75fafe10fe22808ae7f055da2ae
---
M main/bridge.c
M res/ari/resource_bridges.h
M res/res_stasis.c
M res/stasis/stasis_bridge.c
M res/stasis/stasis_bridge.h
M rest-api/api-docs/bridges.json
6 files changed, 25 insertions(+), 14 deletions(-)

Approvals:
  Joshua Colp: Looks good to me, but someone else must approve
  George Joseph: Looks good to me, approved
  Friendly Automation: Approved for Submit



diff --git a/main/bridge.c b/main/bridge.c
index 351aaf1..d3a87ef 100644
--- a/main/bridge.c
+++ b/main/bridge.c
@@ -3792,13 +3792,15 @@
 	ast_bridge_lock(bridge);
 	cleanup_video_mode(bridge);
 	bridge->softmix.video_mode.mode = AST_BRIDGE_VIDEO_MODE_SINGLE_SRC;
-	bridge->softmix.video_mode.mode_data.single_src_data.chan_vsrc = ast_channel_ref(video_src_chan);
-	ast_verb(5, "Video source in bridge '%s' (%s) is now '%s' (%s)\n",
-		bridge->name, bridge->uniqueid,
-		ast_channel_name(video_src_chan),
-		ast_channel_uniqueid(video_src_chan));
+	if (video_src_chan) {
+		bridge->softmix.video_mode.mode_data.single_src_data.chan_vsrc = ast_channel_ref(video_src_chan);
+		ast_verb(5, "Video source in bridge '%s' (%s) is now '%s' (%s)\n",
+			bridge->name, bridge->uniqueid,
+			ast_channel_name(video_src_chan),
+			ast_channel_uniqueid(video_src_chan));
+		ast_indicate(video_src_chan, AST_CONTROL_VIDUPDATE);
+	}
 	ast_bridge_publish_state(bridge);
-	ast_indicate(video_src_chan, AST_CONTROL_VIDUPDATE);
 	ast_bridge_unlock(bridge);
 }
 
diff --git a/res/ari/resource_bridges.h b/res/ari/resource_bridges.h
index 61fc6bb..6dd252f 100644
--- a/res/ari/resource_bridges.h
+++ b/res/ari/resource_bridges.h
@@ -52,7 +52,7 @@
 void ast_ari_bridges_list(struct ast_variable *headers, struct ast_ari_bridges_list_args *args, struct ast_ari_response *response);
 /*! Argument struct for ast_ari_bridges_create() */
 struct ast_ari_bridges_create_args {
-	/*! Comma separated list of bridge type attributes (mixing, holding, dtmf_events, proxy_media). */
+	/*! Comma separated list of bridge type attributes (mixing, holding, dtmf_events, proxy_media, video_single). */
 	const char *type;
 	/*! Unique ID to give to the bridge being created. */
 	const char *bridge_id;
@@ -82,7 +82,7 @@
 void ast_ari_bridges_create(struct ast_variable *headers, struct ast_ari_bridges_create_args *args, struct ast_ari_response *response);
 /*! Argument struct for ast_ari_bridges_create_with_id() */
 struct ast_ari_bridges_create_with_id_args {
-	/*! Comma separated list of bridge type attributes (mixing, holding, dtmf_events, proxy_media) to set. */
+	/*! Comma separated list of bridge type attributes (mixing, holding, dtmf_events, proxy_media, video_single) to set. */
 	const char *type;
 	/*! Unique ID to give to the bridge being created. */
 	const char *bridge_id;
diff --git a/res/res_stasis.c b/res/res_stasis.c
index 4850f6a..4db58fa 100644
--- a/res/res_stasis.c
+++ b/res/res_stasis.c
@@ -775,6 +775,7 @@
 	int flags = AST_BRIDGE_FLAG_MERGE_INHIBIT_FROM | AST_BRIDGE_FLAG_MERGE_INHIBIT_TO
 		| AST_BRIDGE_FLAG_SWAP_INHIBIT_FROM | AST_BRIDGE_FLAG_SWAP_INHIBIT_TO
 		| AST_BRIDGE_FLAG_TRANSFER_BRIDGE_ONLY;
+	enum ast_bridge_video_mode_type video_mode = AST_BRIDGE_VIDEO_MODE_TALKER_SRC;
 
 	while ((requested_type = strsep(&requested_types, ","))) {
 		requested_type = ast_strip(requested_type);
@@ -787,6 +788,8 @@
 		} else if (!strcmp(requested_type, "dtmf_events") ||
 			!strcmp(requested_type, "proxy_media")) {
 			capabilities &= ~AST_BRIDGE_CAPABILITY_NATIVE;
+		} else if (!strcmp(requested_type, "video_single")) {
+			video_mode = AST_BRIDGE_VIDEO_MODE_SINGLE_SRC;
 		}
 	}
 
@@ -797,7 +800,7 @@
 		return NULL;
 	}
 
-	bridge = bridge_stasis_new(capabilities, flags, name, id);
+	bridge = bridge_stasis_new(capabilities, flags, name, id, video_mode);
 	if (bridge) {
 		if (!ao2_link(app_bridges, bridge)) {
 			ast_bridge_destroy(bridge, 0);
diff --git a/res/stasis/stasis_bridge.c b/res/stasis/stasis_bridge.c
index 1b87b48..00dd4b9 100644
--- a/res/stasis/stasis_bridge.c
+++ b/res/stasis/stasis_bridge.c
@@ -299,7 +299,7 @@
 	ast_bridge_base_v_table.pull(self, bridge_channel);
 }
 
-struct ast_bridge *bridge_stasis_new(uint32_t capabilities, unsigned int flags, const char *name, const char *id)
+struct ast_bridge *bridge_stasis_new(uint32_t capabilities, unsigned int flags, const char *name, const char *id, enum ast_bridge_video_mode_type video_mode)
 {
 	void *bridge;
 
@@ -309,7 +309,12 @@
 		return NULL;
 	}
 
-	ast_bridge_set_talker_src_video_mode(bridge);
+	if (video_mode == AST_BRIDGE_VIDEO_MODE_SINGLE_SRC) {
+		ast_bridge_set_single_src_video_mode(bridge, NULL);
+	} else {
+		ast_bridge_set_talker_src_video_mode(bridge);
+	}
+
 	bridge = bridge_register(bridge);
 
 	return bridge;
diff --git a/res/stasis/stasis_bridge.h b/res/stasis/stasis_bridge.h
index 2590fd7..6e2a48b 100644
--- a/res/stasis/stasis_bridge.h
+++ b/res/stasis/stasis_bridge.h
@@ -50,11 +50,12 @@
  * \param flags Flags that will alter the behavior of the bridge
  * \param name Name given to the bridge by Stasis (optional)
  * \param id Unique ID given to the bridge by Stasis (optional)
+ * \param video_mode Video mode of the bridge
  *
  * \retval a pointer to a new bridge on success
  * \retval NULL on failure
  */
-struct ast_bridge *bridge_stasis_new(uint32_t capabilities, unsigned int flags, const char *name, const char *id);
+struct ast_bridge *bridge_stasis_new(uint32_t capabilities, unsigned int flags, const char *name, const char *id, enum ast_bridge_video_mode_type video_mode);
 
 /*!
  * \internal
diff --git a/rest-api/api-docs/bridges.json b/rest-api/api-docs/bridges.json
index 78bd3af..6268c49 100644
--- a/rest-api/api-docs/bridges.json
+++ b/rest-api/api-docs/bridges.json
@@ -26,7 +26,7 @@
 					"parameters": [
 						{
 							"name": "type",
-							"description": "Comma separated list of bridge type attributes (mixing, holding, dtmf_events, proxy_media).",
+							"description": "Comma separated list of bridge type attributes (mixing, holding, dtmf_events, proxy_media, video_single).",
 							"paramType": "query",
 							"required": false,
 							"allowMultiple": false,
@@ -65,7 +65,7 @@
 					"parameters": [
 						{
 							"name": "type",
-							"description": "Comma separated list of bridge type attributes (mixing, holding, dtmf_events, proxy_media) to set.",
+							"description": "Comma separated list of bridge type attributes (mixing, holding, dtmf_events, proxy_media, video_single) to set.",
 							"paramType": "query",
 							"required": false,
 							"allowMultiple": false,

-- 
To view, visit https://gerrit.asterisk.org/c/asterisk/+/14905
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-Change-Id: I43e720e5c83fc75fafe10fe22808ae7f055da2ae
Gerrit-Change-Number: 14905
Gerrit-PatchSet: 5
Gerrit-Owner: sungtae kim <pchero21 at gmail.com>
Gerrit-Reviewer: Friendly Automation
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Joshua Colp <jcolp at sangoma.com>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20200910/b550629f/attachment-0001.html>


More information about the asterisk-code-review mailing list