All pastes #950778 Raw Edit

Mine

public text v1 · immutable
·published 2008-03-20 20:43 UTC
rendered paste body
Index: bridges/bridge_softmix.c
===================================================================
--- bridges/bridge_softmix.c    (revision 110330)
+++ bridges/bridge_softmix.c    (working copy)
@@ -23,6 +23,11 @@
  * \author Joshua Colp <jcolp@digium.com>
  *
  * \ingroup bridges
+ *
+ * \todo This bridge operates in 16 kHz mode to support wideband conferencing.
+ * However, in the case that there are not at least 2 channels on the bridge
+ * that support 16 kHz audio, then this should be optimized to fall back to
+ * operating in 8 kHz mode.
  */
 
 #include "asterisk.h"
@@ -46,7 +51,7 @@
 #include "asterisk/slinfactory.h"
 
 #define SOFTMIX_INTERVAL 20 /* Valid options are 10, 20, and 30 */
-#define SOFTMIX_SAMPLES (160*(SOFTMIX_INTERVAL/10))
+#define SOFTMIX_SAMPLES (320 * (SOFTMIX_INTERVAL / 10))
 
 struct softmix_channel {
        ast_mutex_t lock;
@@ -75,7 +80,7 @@
 
        /* Setup frame parameters */
        sc->frame.frametype = AST_FRAME_VOICE;
-       sc->frame.subclass = AST_FORMAT_SLINEAR;
+       sc->frame.subclass = AST_FORMAT_SLINEAR16;
        sc->frame.data = sc->final_buf;
        sc->frame.datalen = sizeof(sc->final_buf);
        sc->frame.samples = SOFTMIX_SAMPLES;
@@ -115,7 +120,7 @@
        ast_mutex_lock(&sc->lock);
 
        /* If a frame was provided add it to the smoother */
-       if (frame->frametype == AST_FRAME_VOICE && frame->subclass == AST_FORMAT_SLINEAR)
+       if (frame->frametype == AST_FRAME_VOICE && frame->subclass == AST_FORMAT_SLINEAR16)
                ast_slinfactory_feed(&sc->factory, frame);
 
        /* If a frame is ready to be written out, do so */
@@ -210,10 +215,10 @@
                        int adjust = abs(skew-previous_skew), new_adjust = 0;
                        if (adjust > 0)
                                new_adjust = abs(adjust-last_adjust);
-                       base = ast_tvadd(base, ast_tv(0, ((SOFTMIX_INTERVAL-new_adjust)+SOFTMIX_INTERVAL)*1000));
+                       base = ast_tvadd(base, ast_tv(0, ((SOFTMIX_INTERVAL - new_adjust) + SOFTMIX_INTERVAL) * 1000));
                        last_adjust = new_adjust;
                } else {
-                       base = ast_tvadd(base, ast_tv(0, (SOFTMIX_INTERVAL*2)*1000));
+                       base = ast_tvadd(base, ast_tv(0, (SOFTMIX_INTERVAL * 2) * 1000));
                }
 
                /* Calculate next time until we should wake up */
@@ -242,7 +247,7 @@
        .name = "softmix",
        .capabilities = AST_BRIDGE_CAPABILITY_MULTIMIX | AST_BRIDGE_CAPABILITY_THREAD | AST_BRIDGE_CAPABILITY_MULTITHREADED,
        .preference = AST_BRIDGE_PREFERENCE_LOW,
-       .formats = AST_FORMAT_SLINEAR,
+       .formats = AST_FORMAT_SLINEAR16,
        .join = softmix_bridge_join,
        .leave = softmix_bridge_leave,
        .write = softmix_bridge_write,