[Asterisk-code-review] stasis_brdige.c: Fixed wrong video_mode shown (asterisk[master])

sungtae kim asteriskteam at digium.com
Fri Jul 10 18:22:12 CDT 2020


sungtae kim has uploaded this change for review. ( https://gerrit.asterisk.org/c/asterisk/+/14633 )


Change subject: stasis_brdige.c: Fixed wrong video_mode shown
......................................................................

stasis_brdige.c: Fixed wrong video_mode shown

Currently, if the bridge has created by the ARI, the video_mode
parameter was
not shown in the BridgeCreated event correctly.

Fixed it and added video_mode shown in the 'bridge show <bridge id>'
cli.

ASTERISK-28987

Change-Id: I8c205126724e34c2bdab9380f523eb62478e4295
---
M main/bridge.c
M res/res_stasis.c
M res/stasis/stasis_bridge.c
M res/stasis/stasis_bridge.h
4 files changed, 19 insertions(+), 12 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/33/14633/1

diff --git a/main/bridge.c b/main/bridge.c
index 7a7b6f6..0444fc7 100644
--- a/main/bridge.c
+++ b/main/bridge.c
@@ -5163,6 +5163,7 @@
 	ast_cli(a->fd, "Subclass: %s\n", snapshot->subclass);
 	ast_cli(a->fd, "Creator: %s\n", snapshot->creator);
 	ast_cli(a->fd, "Name: %s\n", snapshot->name);
+	ast_cli(a->fd, "Video_mode: %u\n", snapshot->video_mode);
 	ast_cli(a->fd, "Video-Source-Id: %s\n", snapshot->video_source_id);
 	ast_cli(a->fd, "Num-Channels: %u\n", snapshot->num_channels);
 	ast_cli(a->fd, "Num-Active: %u\n", snapshot->num_active);
diff --git a/res/res_stasis.c b/res/res_stasis.c
index 64f05ef..f975386 100644
--- a/res/res_stasis.c
+++ b/res/res_stasis.c
@@ -808,22 +808,14 @@
 		return NULL;
 	}
 
-	bridge = bridge_stasis_new(capabilities, flags, name, id);
+	bridge = bridge_stasis_new(capabilities, flags, name, id, video_mode);
 	if (bridge) {
-		if (video_mode == AST_BRIDGE_VIDEO_MODE_SFU) {
-			ast_bridge_set_sfu_video_mode(bridge);
-			/* We require a minimum 5 seconds between video updates to stop floods from clients,
-			 * this should rarely be changed but should become configurable in the future.
-			 */
-			ast_bridge_set_video_update_discard(bridge, 5);
-		} else {
-			ast_bridge_set_talker_src_video_mode(bridge);
-		}
 		if (!ao2_link(app_bridges, bridge)) {
 			ast_bridge_destroy(bridge, 0);
 			bridge = NULL;
 		}
 	}
+
 	return bridge;
 }
 
diff --git a/res/stasis/stasis_bridge.c b/res/stasis/stasis_bridge.c
index d78e59c..d5f70a0 100644
--- a/res/stasis/stasis_bridge.c
+++ b/res/stasis/stasis_bridge.c
@@ -297,12 +297,26 @@
 	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;
 
 	bridge = bridge_alloc(sizeof(struct ast_bridge), &bridge_stasis_v_table);
 	bridge = bridge_base_init(bridge, capabilities, flags, "Stasis", name, id);
+	if (!bridge) {
+		return NULL;
+	}
+
+	if (video_mode == AST_BRIDGE_VIDEO_MODE_SFU) {
+		ast_bridge_set_sfu_video_mode(bridge);
+		/* We require a minimum 5 seconds between video updates to stop floods from clients,
+		 * this should rarely be changed but should become configurable in the future.
+		 */
+		ast_bridge_set_video_update_discard(bridge, 5);
+	} 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..c265c47 100644
--- a/res/stasis/stasis_bridge.h
+++ b/res/stasis/stasis_bridge.h
@@ -54,7 +54,7 @@
  * \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

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

Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Change-Id: I8c205126724e34c2bdab9380f523eb62478e4295
Gerrit-Change-Number: 14633
Gerrit-PatchSet: 1
Gerrit-Owner: sungtae kim <pchero21 at gmail.com>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20200710/328c31d8/attachment.html>


More information about the asterisk-code-review mailing list