[Asterisk-code-review] app_confbridge/bridge_softmix: Add ability to set max bitrate (asterisk[16])
George Joseph
asteriskteam at digium.com
Thu Sep 24 13:47:43 CDT 2020
George Joseph has uploaded this change for review. ( https://gerrit.asterisk.org/c/asterisk/+/14939 )
Change subject: app_confbridge/bridge_softmix: Add ability to set max bitrate
......................................................................
app_confbridge/bridge_softmix: Add ability to set max bitrate
app_confbridge now has the ability to set the maximum bitrate on an SFU
bridge. To use it, set a bridge profile's remb_behavior to "force" and
set remb_max_bitrate to a rate in bits per second. The
remb_max_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, 68 insertions(+), 2 deletions(-)
git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/39/14939/1
diff --git a/apps/app_confbridge.c b/apps/app_confbridge.c
index b71bbe9..9232f9c 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_max_bitrate(conference->bridge, conference->b_profile.remb_max_bitrate);
}
}
diff --git a/apps/confbridge/conf_config_parser.c b/apps/confbridge/conf_config_parser.c
index 3814d30..a889358 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_max_bitrate</literal>
+ is sent to each sender.</para>
+ </enum>
</enumlist>
</description>
+ <see-also><ref type="configOption">remb_max_bitrate</ref></see-also>
+ </configOption>
+ <configOption name="remb_max_bitrate">
+ <synopsis>Sets the maximum 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 maximum 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,7 +2437,8 @@
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, "enable_events", ACO_EXACT, bridge_types, "no", OPT_BOOLFLAG_T, 1, FLDSET(struct bridge_profile, flags), BRIDGE_OPT_ENABLE_EVENTS);
+ aco_option_register(&cfg_info, "remb_max_bitrate", ACO_EXACT, bridge_types, "0", OPT_UINT_T, 0, FLDSET(struct bridge_profile, remb_max_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..31ab55f 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 bitrate to that specifiec in remb_max_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_max_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..7eb8749 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.max_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..7d814a1 100644
--- a/configs/samples/confbridge.conf.sample
+++ b/configs/samples/confbridge.conf.sample
@@ -266,6 +266,8 @@
; "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".
+;remb_force_max_bitrate=0 ; When remb_behavior is set to 'force', this options sets the maximum 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..68b1599
--- /dev/null
+++ b/doc/CHANGES-staging/app_confbridge.txt
@@ -0,0 +1,7 @@
+Subject: app_confbridge
+
+app_confbridge now has the ability to set the maximum bitrate on an SFU
+bridge. To use it, set a bridge profile's remb_behavior to "force" and
+set remb_max_bitrate to a rate in bits per second. The
+remb_max_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..d009006 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 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 maximum bitrate when behavior is "force" */
+ float max_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 bitrate to a specific max value
+ *
+ * \param bridge Bridge to set the REMB behavior on
+ * \param max_bitrate The maximum 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_max_bitrate(struct ast_bridge *bridge, float max_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..d09e996 100644
--- a/main/bridge.c
+++ b/main/bridge.c
@@ -3890,6 +3890,15 @@
ast_bridge_unlock(bridge);
}
+void ast_bridge_set_remb_max_bitrate(struct ast_bridge *bridge, float max_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.max_bitrate = max_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: 1
Gerrit-Owner: George Joseph <gjoseph at digium.com>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20200924/dcc59442/attachment-0001.html>
More information about the asterisk-code-review
mailing list