summaryrefslogtreecommitdiff
path: root/bridges/bridge_softmix.c
diff options
context:
space:
mode:
Diffstat (limited to 'bridges/bridge_softmix.c')
-rw-r--r--bridges/bridge_softmix.c75
1 files changed, 62 insertions, 13 deletions
diff --git a/bridges/bridge_softmix.c b/bridges/bridge_softmix.c
index f0a3fb42d..e3513a788 100644
--- a/bridges/bridge_softmix.c
+++ b/bridges/bridge_softmix.c
@@ -36,6 +36,7 @@
#include "asterisk/stream.h"
#include "asterisk/test.h"
#include "asterisk/vector.h"
+#include "asterisk/message.h"
#include "bridge_softmix/include/bridge_softmix_internal.h"
/*! The minimum sample rate of the bridge. */
@@ -1121,6 +1122,42 @@ cleanup:
/*!
* \internal
+ * \brief Determine what to do with a text frame.
+ * \since 13.22.0
+ * \since 15.5.0
+ *
+ * \param bridge Which bridge is getting the frame
+ * \param bridge_channel Which channel is writing the frame.
+ * \param frame What is being written.
+ *
+ * \return Nothing
+ */
+static void softmix_bridge_write_text(struct ast_bridge *bridge,
+ struct ast_bridge_channel *bridge_channel, struct ast_frame *frame)
+{
+ if (DEBUG_ATLEAST(1)) {
+ struct ast_msg_data *msg = frame->data.ptr;
+ char frame_type[64];
+
+ ast_frame_type2str(frame->frametype, frame_type, sizeof(frame_type));
+
+ if (frame->frametype == AST_FRAME_TEXT_DATA) {
+ ast_log(LOG_DEBUG, "Received %s frame from '%s:%s': %s\n", frame_type,
+ ast_msg_data_get_attribute(msg, AST_MSG_DATA_ATTR_FROM),
+ ast_channel_name(bridge_channel->chan),
+ ast_msg_data_get_attribute(msg, AST_MSG_DATA_ATTR_BODY));
+ } else {
+ ast_log(LOG_DEBUG, "Received %s frame from '%s': %.*s\n", frame_type,
+ ast_channel_name(bridge_channel->chan), frame->datalen,
+ (char *)frame->data.ptr);
+ }
+ }
+
+ ast_bridge_queue_everyone_else(bridge, bridge_channel, frame);
+}
+
+/*!
+ * \internal
* \brief Determine what to do with a control frame.
* \since 12.0.0
*
@@ -1247,6 +1284,10 @@ static int softmix_bridge_write(struct ast_bridge *bridge, struct ast_bridge_cha
case AST_FRAME_VIDEO:
softmix_bridge_write_video(bridge, bridge_channel, frame);
break;
+ case AST_FRAME_TEXT:
+ case AST_FRAME_TEXT_DATA:
+ softmix_bridge_write_text(bridge, bridge_channel, frame);
+ break;
case AST_FRAME_CONTROL:
res = softmix_bridge_write_control(bridge, bridge_channel, frame);
break;
@@ -1318,6 +1359,12 @@ static void remb_collect_report(struct ast_bridge *bridge, struct ast_bridge_cha
break;
}
}
+
+ /* After the report is integrated we reset this to 0 in case they stop producing
+ * REMB reports.
+ */
+ sc->remb.br_mantissa = 0;
+ sc->remb.br_exp = 0;
}
static void remb_send_report(struct ast_bridge_channel *bridge_channel, struct softmix_channel *sc)
@@ -1328,20 +1375,18 @@ static void remb_send_report(struct ast_bridge_channel *bridge_channel, struct s
return;
}
- /* If we have a new bitrate then use it for the REMB, if not we use the previous
- * one until we know otherwise. This way the bitrate doesn't drop to 0 all of a sudden.
+ /* We always do this calculation as even when the bitrate is zero the browser
+ * still prefers it to be accurate instead of lying.
*/
- if (sc->remb_collector->bitrate) {
- sc->remb_collector->feedback.remb.br_mantissa = sc->remb_collector->bitrate;
- sc->remb_collector->feedback.remb.br_exp = 0;
+ sc->remb_collector->feedback.remb.br_mantissa = sc->remb_collector->bitrate;
+ sc->remb_collector->feedback.remb.br_exp = 0;
- /* The mantissa only has 18 bits available, so while it exceeds them we bump
- * up the exp.
- */
- while (sc->remb_collector->feedback.remb.br_mantissa > 0x3ffff) {
- sc->remb_collector->feedback.remb.br_mantissa = sc->remb_collector->feedback.remb.br_mantissa >> 1;
- sc->remb_collector->feedback.remb.br_exp++;
- }
+ /* The mantissa only has 18 bits available, so while it exceeds them we bump
+ * up the exp.
+ */
+ while (sc->remb_collector->feedback.remb.br_mantissa > 0x3ffff) {
+ sc->remb_collector->feedback.remb.br_mantissa = sc->remb_collector->feedback.remb.br_mantissa >> 1;
+ sc->remb_collector->feedback.remb.br_exp++;
}
for (i = 0; i < AST_VECTOR_SIZE(&bridge_channel->stream_map.to_bridge); ++i) {
@@ -2062,6 +2107,7 @@ static void softmix_bridge_stream_topology_changed(struct ast_bridge *bridge, st
struct ast_bridge_channel *participant;
struct ast_vector_int media_types;
int nths[AST_MEDIA_TYPE_END] = {0};
+ int idx;
switch (bridge->softmix.video_mode.mode) {
case AST_BRIDGE_VIDEO_MODE_NONE:
@@ -2080,7 +2126,10 @@ static void softmix_bridge_stream_topology_changed(struct ast_bridge *bridge, st
* When channels end up getting added back in they'll reuse their existing
* collector and won't need to allocate a new one (unless they were just added).
*/
- AST_VECTOR_RESET(&softmix_data->remb_collectors, ao2_cleanup);
+ for (idx = 0; idx < AST_VECTOR_SIZE(&softmix_data->remb_collectors); ++idx) {
+ ao2_cleanup(AST_VECTOR_GET(&softmix_data->remb_collectors, idx));
+ AST_VECTOR_REPLACE(&softmix_data->remb_collectors, idx, NULL);
+ }
/* First traversal: re-initialize all of the participants' stream maps */
AST_LIST_TRAVERSE(&bridge->channels, participant, entry) {