[Asterisk-code-review] app_confbridge/bridge_softmix: Add ability to force estimated bitrate (asterisk[16])

Friendly Automation asteriskteam at digium.com
Thu Oct 1 08:01:19 CDT 2020


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

Change subject: app_confbridge/bridge_softmix:  Add ability to force estimated bitrate
......................................................................

app_confbridge/bridge_softmix:  Add ability to force estimated bitrate

app_confbridge now has the ability to set the estimated bitrate on an
SFU bridge.  To use it, set a bridge profile's remb_behavior to "force"
and set remb_estimated_bitrate to a rate in bits per second.  The
remb_estimated_bitrate parameter is ignored if remb_behavior is something
other than "force".

Change-Id: Idce6464ff014a37ea3b82944452e56cc4d75ab0a
---
M apps/app_confbridge.c
M apps/confbridge/conf_config_parser.c
M apps/confbridge/include/confbridge.h
M bridges/bridge_softmix.c
M configs/samples/confbridge.conf.sample
A doc/CHANGES-staging/app_confbridge.txt
M include/asterisk/bridge.h
M main/bridge.c
8 files changed, 70 insertions(+), 3 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/apps/app_confbridge.c b/apps/app_confbridge.c
index b71bbe9..457870a 100644
--- a/apps/app_confbridge.c
+++ b/apps/app_confbridge.c
@@ -1730,6 +1730,9 @@
 				ast_brige_set_remb_behavior(conference->bridge, AST_BRIDGE_VIDEO_SFU_REMB_LOWEST_ALL);
 			} else if (ast_test_flag(&conference->b_profile, BRIDGE_OPT_REMB_BEHAVIOR_HIGHEST_ALL)) {
 				ast_brige_set_remb_behavior(conference->bridge, AST_BRIDGE_VIDEO_SFU_REMB_HIGHEST_ALL);
+			} else if (ast_test_flag(&conference->b_profile, BRIDGE_OPT_REMB_BEHAVIOR_FORCE)) {
+				ast_brige_set_remb_behavior(conference->bridge, AST_BRIDGE_VIDEO_SFU_REMB_FORCE);
+				ast_bridge_set_remb_estimated_bitrate(conference->bridge, conference->b_profile.remb_estimated_bitrate);
 			}
 		}
 
diff --git a/apps/confbridge/conf_config_parser.c b/apps/confbridge/conf_config_parser.c
index 3814d30..656acc6 100644
--- a/apps/confbridge/conf_config_parser.c
+++ b/apps/confbridge/conf_config_parser.c
@@ -533,8 +533,22 @@
 								<para>The highest estimated maximum bitrate of all receivers in the bridge
 								is taken and sent to each sender.</para>
 							</enum>
+							<enum name="force">
+								<para>The bitrate configured in <literal>remb_estimated_bitrate</literal>
+								is sent to each sender.</para>
+							</enum>
 						</enumlist>
 					</description>
+					<see-also><ref type="configOption">remb_estimated_bitrate</ref></see-also>
+				</configOption>
+				<configOption name="remb_estimated_bitrate">
+					<synopsis>Sets the estimated bitrate sent to each participant in REMB reports</synopsis>
+					<description><para>
+					    When <literal>remb_behavior</literal> is set to <literal>force</literal>,
+					    this options sets the estimated bitrate (in bits per second) sent to each participant
+					    in REMB reports.
+					</para></description>
+					<see-also><ref type="configOption">remb_behavior</ref></see-also>
 				</configOption>
 				<configOption name="enable_events" default="no">
 					<synopsis>Enables events for this bridge</synopsis>
@@ -2159,7 +2173,9 @@
 		BRIDGE_OPT_REMB_BEHAVIOR_HIGHEST |
 		BRIDGE_OPT_REMB_BEHAVIOR_AVERAGE_ALL |
 		BRIDGE_OPT_REMB_BEHAVIOR_LOWEST_ALL |
-		BRIDGE_OPT_REMB_BEHAVIOR_HIGHEST_ALL);
+		BRIDGE_OPT_REMB_BEHAVIOR_HIGHEST_ALL |
+		BRIDGE_OPT_REMB_BEHAVIOR_FORCE
+		);
 
 	if (!strcasecmp(var->value, "average")) {
 		ast_set_flag(b_profile, BRIDGE_OPT_REMB_BEHAVIOR_AVERAGE);
@@ -2173,6 +2189,8 @@
 		ast_set_flag(b_profile, BRIDGE_OPT_REMB_BEHAVIOR_LOWEST_ALL);
 	} else if (!strcasecmp(var->value, "highest_all")) {
 		ast_set_flag(b_profile, BRIDGE_OPT_REMB_BEHAVIOR_HIGHEST_ALL);
+	} else if (!strcasecmp(var->value, "force")) {
+		ast_set_flag(b_profile, BRIDGE_OPT_REMB_BEHAVIOR_FORCE);
 	} else {
 		return -1;
 	}
@@ -2419,6 +2437,7 @@
 	aco_option_register(&cfg_info, "video_update_discard", ACO_EXACT, bridge_types, "2000", OPT_UINT_T, 0, FLDSET(struct bridge_profile, video_update_discard));
 	aco_option_register(&cfg_info, "remb_send_interval", ACO_EXACT, bridge_types, "0", OPT_UINT_T, 0, FLDSET(struct bridge_profile, remb_send_interval));
 	aco_option_register_custom(&cfg_info, "remb_behavior", ACO_EXACT, bridge_types, "average", remb_behavior_handler, 0);
+	aco_option_register(&cfg_info, "remb_estimated_bitrate", ACO_EXACT, bridge_types, "0", OPT_UINT_T, 0, FLDSET(struct bridge_profile, remb_estimated_bitrate));
 	aco_option_register(&cfg_info, "enable_events", ACO_EXACT, bridge_types, "no", OPT_BOOLFLAG_T, 1, FLDSET(struct bridge_profile, flags), BRIDGE_OPT_ENABLE_EVENTS);
 	/* This option should only be used with the CONFBRIDGE dialplan function */
 	aco_option_register_custom(&cfg_info, "template", ACO_EXACT, bridge_types, NULL, bridge_template_handler, 0);
diff --git a/apps/confbridge/include/confbridge.h b/apps/confbridge/include/confbridge.h
index e48292a..f413359 100644
--- a/apps/confbridge/include/confbridge.h
+++ b/apps/confbridge/include/confbridge.h
@@ -87,6 +87,7 @@
 	BRIDGE_OPT_REMB_BEHAVIOR_AVERAGE_ALL = (1 << 12), /*!< The average of all REMB reports in the entire bridge is sent to each sender */
 	BRIDGE_OPT_REMB_BEHAVIOR_LOWEST_ALL = (1 << 13), /*!< The lowest estimated maximum bitrate from all receivers is sent to each sender */
 	BRIDGE_OPT_REMB_BEHAVIOR_HIGHEST_ALL = (1 << 14), /*!< The highest estimated maximum bitrate from all receivers is sent to each sender */
+	BRIDGE_OPT_REMB_BEHAVIOR_FORCE = (1 << 15), /*!< Force the REMB estimated bitrate to that specifiec in remb_estimated_bitrate */
 };
 
 enum conf_menu_action_id {
@@ -235,6 +236,7 @@
 	char regcontext[AST_MAX_CONTEXT];
 	unsigned int video_update_discard; /*!< Amount of time after sending a video update request that subsequent requests should be discarded */
 	unsigned int remb_send_interval; /*!< Interval at which a combined REMB frame is sent to video sources */
+	unsigned int remb_estimated_bitrate; /*!< Bitrate sent when BRIDGE_OPT_REMB_BEHAVIOR_FORCE is set */
 };
 
 /*! \brief The structure that represents a conference bridge */
diff --git a/bridges/bridge_softmix.c b/bridges/bridge_softmix.c
index 5acd794..d51a55f 100644
--- a/bridges/bridge_softmix.c
+++ b/bridges/bridge_softmix.c
@@ -1396,6 +1396,7 @@
 	case AST_BRIDGE_VIDEO_SFU_REMB_AVERAGE:
 	case AST_BRIDGE_VIDEO_SFU_REMB_LOWEST:
 	case AST_BRIDGE_VIDEO_SFU_REMB_HIGHEST:
+	case AST_BRIDGE_VIDEO_SFU_REMB_FORCE:
 		/* These will never actually get hit due to being handled by remb_collect_report below */
 		break;
 	}
@@ -1417,6 +1418,12 @@
 	/* We evenly divide the available maximum bitrate across the video sources
 	 * to this receiver so each source gets an equal slice.
 	 */
+
+	if (bridge->softmix.video_mode.mode_data.sfu_data.remb_behavior == AST_BRIDGE_VIDEO_SFU_REMB_FORCE) {
+		softmix_data->bitrate = bridge->softmix.video_mode.mode_data.sfu_data.estimated_bitrate;
+		return;
+	}
+
 	bitrate = (sc->remb.br_mantissa << sc->remb.br_exp) / AST_VECTOR_SIZE(&sc->video_sources);
 
 	/* If this receiver has no bitrate yet ignore it */
@@ -1462,6 +1469,9 @@
 		case AST_BRIDGE_VIDEO_SFU_REMB_HIGHEST_ALL:
 			/* These will never actually get hit due to being handled by remb_collect_report_all above */
 			break;
+		case AST_BRIDGE_VIDEO_SFU_REMB_FORCE:
+			/* Don't do anything, we've already forced it */
+			break;
 		}
 	}
 
diff --git a/configs/samples/confbridge.conf.sample b/configs/samples/confbridge.conf.sample
index 02edaa5..7749c93 100644
--- a/configs/samples/confbridge.conf.sample
+++ b/configs/samples/confbridge.conf.sample
@@ -264,8 +264,11 @@
                            ; the highest maximum bitrate is forwarded to the sender. If set to "average_all" a single average
                            ; is generated from every receiver and the same value is sent to every sender. If set to
                            ; "lowest_all" the lowest maximum bitrate of all receivers is sent to every sender. If set to
-                           ; "highest_all" the highest maximum bitrate of all receivers is sent to every sender. This
-                           ; defaults to "average".
+                           ; "highest_all" the highest maximum bitrate of all receivers is sent to every sender.
+                           ; When set to "force", the value set in remb_estimated_bitrate is sent to every sender.
+                           ; This defaults to "average".
+;remb_estimated_bitrate=0  ; When remb_behavior is set to 'force', this options sets the estimated bitrate
+                           ; (in bits per second) sent to each participant in REMB reports.
 
 ;enable_events=no          ; If enabled, recipients who joined the bridge via a channel driver
                            ; that supports Enhanced Messaging (currently only chan_pjsip) will
diff --git a/doc/CHANGES-staging/app_confbridge.txt b/doc/CHANGES-staging/app_confbridge.txt
new file mode 100644
index 0000000..092e392
--- /dev/null
+++ b/doc/CHANGES-staging/app_confbridge.txt
@@ -0,0 +1,7 @@
+Subject: app_confbridge
+
+app_confbridge now has the ability to force the estimated bitrate on an SFU
+bridge.  To use it, set a bridge profile's remb_behavior to "force" and
+set remb_estimated_bitrate to a rate in bits per second.  The
+remb_estimated_bitrate parameter is ignored if remb_behavior is something
+other than "force".
diff --git a/include/asterisk/bridge.h b/include/asterisk/bridge.h
index a17aa00..533d117 100644
--- a/include/asterisk/bridge.h
+++ b/include/asterisk/bridge.h
@@ -140,6 +140,8 @@
 	AST_BRIDGE_VIDEO_SFU_REMB_LOWEST_ALL,
 	/*! The highest reported bitrate from all channels in the bridge is forwarded to each sender */
 	AST_BRIDGE_VIDEO_SFU_REMB_HIGHEST_ALL,
+	/*! Force the REMB estimated bitrate to a specified value */
+	AST_BRIDGE_VIDEO_SFU_REMB_FORCE,
 };
 
 /*! \brief This is used for selective forwarding unit configuration */
@@ -148,6 +150,8 @@
 	unsigned int remb_send_interval;
 	/*! How the combined REMB report is generated */
 	enum ast_bridge_video_sfu_remb_behavior remb_behavior;
+	/*! The estimated bitrate when behavior is "force" */
+	float estimated_bitrate;
 };
 
 /*! \brief Data structure that defines a video source mode */
@@ -989,6 +993,16 @@
 void ast_brige_set_remb_behavior(struct ast_bridge *bridge, enum ast_bridge_video_sfu_remb_behavior behavior);
 
 /*!
+ * \brief Force the REMB report estimated bitrate to a specific max value
+ *
+ * \param bridge Bridge to set the REMB behavior on
+ * \param estimated_bitrate The estimated bitrate in bits per second
+ *
+ * \note This can only be called when the bridge has been set to the SFU video mode.
+ */
+void ast_bridge_set_remb_estimated_bitrate(struct ast_bridge *bridge, float estimated_bitrate);
+
+/*!
  * \brief Update information about talker energy for talker src video mode.
  */
 void ast_bridge_update_talker_src_video_mode(struct ast_bridge *bridge, struct ast_channel *chan, int talker_energy, int is_keyfame);
diff --git a/main/bridge.c b/main/bridge.c
index cf3cc32..9afb5a4 100644
--- a/main/bridge.c
+++ b/main/bridge.c
@@ -3890,6 +3890,15 @@
 	ast_bridge_unlock(bridge);
 }
 
+void ast_bridge_set_remb_estimated_bitrate(struct ast_bridge *bridge, float estimated_bitrate)
+{
+	ast_assert(bridge->softmix.video_mode.mode == AST_BRIDGE_VIDEO_MODE_SFU);
+
+	ast_bridge_lock(bridge);
+	bridge->softmix.video_mode.mode_data.sfu_data.estimated_bitrate = estimated_bitrate;
+	ast_bridge_unlock(bridge);
+}
+
 void ast_bridge_update_talker_src_video_mode(struct ast_bridge *bridge, struct ast_channel *chan, int talker_energy, int is_keyframe)
 {
 	struct ast_bridge_video_talker_src_data *data;

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

Gerrit-Project: asterisk
Gerrit-Branch: 16
Gerrit-Change-Id: Idce6464ff014a37ea3b82944452e56cc4d75ab0a
Gerrit-Change-Number: 14939
Gerrit-PatchSet: 3
Gerrit-Owner: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Benjamin Keith Ford <bford at digium.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/20201001/648439aa/attachment-0001.html>


More information about the asterisk-code-review mailing list