]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
- add the ability to configure forced jitterbuffers on h323, jingle,
authorRussell Bryant <russell@russellbryant.com>
Thu, 1 Jun 2006 16:47:28 +0000 (16:47 +0000)
committerRussell Bryant <russell@russellbryant.com>
Thu, 1 Jun 2006 16:47:28 +0000 (16:47 +0000)
  and mgcp channels
- remove the jitterbuffer configuration from the pvt structures in
  the sip, zap, and skinny channel drivers, as copying the same global
  configuration into each pvt structure has no benefit.
- update and fix some typos in jitterbuffer related documentation
(issue #7257, north, with additional updates and modifications)

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@31413 65c4cc65-6c06-0410-ace0-fbb531ad65f3

14 files changed:
channels/chan_h323.c
channels/chan_jingle.c
channels/chan_mgcp.c
channels/chan_oss.c
channels/chan_sip.c
channels/chan_skinny.c
channels/chan_zap.c
channels/h323/h323.conf.sample
configs/alsa.conf.sample
configs/mgcp.conf.sample
configs/oss.conf.sample
configs/sip.conf.sample
configs/skinny.conf.sample
configs/zapata.conf.sample

index 2714d78c18d600cbc3e384f341c0cd49a6d70449..a252f4e64a452b8c6db6f05e7da0bb65143e8139 100644 (file)
@@ -83,6 +83,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 #include "asterisk/dsp.h"
 #include "asterisk/causes.h"
 #include "asterisk/stringfields.h"
+#include "asterisk/abstract_jb.h"
 #ifdef __cplusplus
 }
 #endif
@@ -105,6 +106,16 @@ setcapabilities_cb on_setcapabilities;
 /* global debug flag */
 int h323debug;
 
+/*! Global jitterbuffer configuration - by default, jb is disabled */
+static struct ast_jb_conf default_jbconf =
+{
+       .flags = 0,
+       .max_size = -1,
+       .resync_threshold = -1,
+       .impl = ""
+};
+static struct ast_jb_conf global_jbconf;
+
 /** Variables required by Asterisk */
 static const char desc[] = "The NuFone Network's Open H.323 Channel Driver";
 static const char tdesc[] = "The NuFone Network's Open H.323 Channel Driver";
@@ -788,6 +799,10 @@ static struct ast_channel *__oh323_new(struct oh323_pvt *pvt, int state, const c
                                ch = NULL;
                        }
                }
+
+               /* Configure the new channel jb */
+               if (ch && pvt && pvt->rtp)
+                       ast_jb_configure(ch, &global_jbconf);
        } else  {
                ast_log(LOG_WARNING, "Unable to allocate channel structure\n");
        }
@@ -2020,8 +2035,18 @@ int reload_config(void)
        global_options.dtmfmode = H323_DTMF_RFC2833;
        global_options.capability = GLOBAL_CAPABILITY;
        global_options.bridge = 1;              /* Do native bridging by default */
+
+       /* Copy the default jb config over global_jbconf */
+       memcpy(&global_jbconf, &default_jbconf, sizeof(struct ast_jb_conf));
+
        v = ast_variable_browse(cfg, "general");
-       while(v) {
+       while (v) {
+               /* handle jb conf */
+                if (!ast_jb_read_conf(&global_jbconf, v->name, v->value)) {
+                       v = v->next;
+                       continue;
+               }
+
                /* Create the interface list */
                if (!strcasecmp(v->name, "port")) {
                        h323_signalling_port = (int)strtol(v->value, NULL, 10);
index f335d4b2673e4f60994dd1fe986919500979d90a..3caa2dfe546dcb775214547206782d96bd4ce153 100644 (file)
@@ -69,11 +69,22 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 #include "asterisk/utils.h"
 #include "asterisk/causes.h"
 #include "asterisk/astobj.h"
+#include "asterisk/abstract_jb.h"
 #include "asterisk/jabber.h"
 #include "asterisk/jingle.h"
 
 #define JINGLE_CONFIG "jingle.conf"
 
+/*! Global jitterbuffer configuration - by default, jb is disabled */
+static struct ast_jb_conf default_jbconf =
+{
+       .flags = 0,
+       .max_size = -1,
+       .resync_threshold = -1,
+       .impl = ""
+};
+static struct ast_jb_conf global_jbconf;
+
 enum jingle_protocol {
        AJI_PROTOCOL_UDP = 1,
        AJI_PROTOCOL_SSLTCP = 2,
@@ -773,6 +784,11 @@ static struct ast_channel *jingle_new(struct jingle *client, struct jingle_pvt *
                ast_hangup(tmp);
                tmp = NULL;
        }
+
+       /* Configure the new channel jb */
+       if (tmp && i && i->rtp)
+               ast_jb_configure(tmp, &global_jbconf);
+
        return tmp;
 }
 
@@ -1453,8 +1469,15 @@ static int jingle_load_config(void)
                return 0;
        }
 
+       /* Copy the default jb config over global_jbconf */
+       memcpy(&global_jbconf, &default_jbconf, sizeof(struct ast_jb_conf));
+
        cat = ast_category_browse(cfg, NULL);
        for (var = ast_variable_browse(cfg, "general"); var; var = var->next) {
+               /* handle jb conf */
+               if (!ast_jb_read_conf(&global_jbconf, var->name, var->value))
+                       continue;
+
                if (!strcasecmp(var->name, "allowguest"))
                        allowguest =
                                (ast_true(ast_variable_retrieve(cfg, "general", "allowguest"))) ? 1 : 0;
index de459d7f5ab089502faedaf5655873b21c1e153e..3a49021592bc75609a34e8fce66808ff00768255 100644 (file)
@@ -117,6 +117,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 #include "asterisk/dsp.h"
 #include "asterisk/devicestate.h"
 #include "asterisk/stringfields.h"
+#include "asterisk/abstract_jb.h"
 
 #ifndef IPTOS_MINCOST
 #define IPTOS_MINCOST 0x02
@@ -137,6 +138,16 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 #define INADDR_NONE (in_addr_t)(-1)
 #endif
 
+/*! Global jitterbuffer configuration - by default, jb is disabled */
+static struct ast_jb_conf default_jbconf =
+{
+       .flags = 0,
+       .max_size = -1,
+       .resync_threshold = -1,
+       .impl = ""
+};
+static struct ast_jb_conf global_jbconf;
+
 static const char tdesc[] = "Media Gateway Control Protocol (MGCP)";
 static const char config[] = "mgcp.conf";
 
@@ -353,10 +364,6 @@ struct mgcp_subchannel {
                        This should be obsoleted */
        char cxident[80];
        char callid[80];
-/* SC: obsolete
-       time_t lastouttime;
-       int lastout;
-*/
        int cxmode;
        struct mgcp_request *cx_queue; /*!< SC: pending CX commands */
        ast_mutex_t cx_queue_lock;     /*!< SC: CX queue lock */
@@ -364,10 +371,6 @@ struct mgcp_subchannel {
        int iseq; /* Not used? RTP? */
        int outgoing;
        int alreadygone;
-/* SC: obsolete
-       int messagepending;
-       struct mgcp_message *msgs;
-*/
        struct mgcp_subchannel *next; /* for out circular linked list */
 };
 
@@ -1499,6 +1502,10 @@ static struct ast_channel *mgcp_new(struct mgcp_subchannel *sub, int state)
                        ast_verbose(VERBOSE_PREFIX_3 "MGCP mgcp_new(%s) created in state: %s\n",
                                tmp->name, ast_state2str(state));
                }
+
+               /* Configure the new channel jb */
+               if (tmp && sub && sub->rtp)
+                       ast_jb_configure(tmp, &global_jbconf);
        } else {
                ast_log(LOG_WARNING, "Unable to allocate channel structure\n");
        }
@@ -4165,8 +4172,18 @@ static int reload_config(void)
        }
        memset(&bindaddr, 0, sizeof(bindaddr));
        dtmfmode = 0;
+
+       /* Copy the default jb config over global_jbconf */
+       memcpy(&global_jbconf, &default_jbconf, sizeof(struct ast_jb_conf));
+
        v = ast_variable_browse(cfg, "general");
-       while(v) {
+       while (v) {
+               /* handle jb conf */
+               if (!ast_jb_read_conf(&global_jbconf, v->name, v->value)) {
+                       v = v->next;
+                       continue;
+               }
+
                /* Create the interface list */
                if (!strcasecmp(v->name, "bindaddr")) {
                        if (!(hp = ast_gethostbyname(v->value, &ahp))) {
index 8e1f60413396df5b41f58fa1360f587d7845763f..ef6da80bc556d7708670d8467e8486326b6cd3ab 100644 (file)
@@ -156,13 +156,9 @@ START_CONFIG
     ; jbenable = yes              ; Enables the use of a jitterbuffer on the receiving side of an
                                   ; OSS channel. Defaults to "no". An enabled jitterbuffer will
                                   ; be used only if the sending side can create and the receiving
-                                  ; side can not accept jitter. The ZAP channel can't accept jitter,
-                                  ; thus an enabled jitterbuffer on the receive ZAP side will always
-                                  ; be used if the sending side can create jitter or if ZAP jb is
-                                  ; forced.
-
-    ; jbforce = no                ; Forces the use of a jitterbuffer on the receive side of a ZAP
-                                  ; channel. Defaults to "no".
+                                  ; side can not accept jitter. The OSS channel can't accept jitter,
+                                  ; thus an enabled jitterbuffer on the receive OSS side will always
+                                  ; be used if the sending side can create jitter.
 
     ; jbmaxsize = 200             ; Max length of the jitterbuffer in milliseconds.
 
@@ -171,8 +167,8 @@ START_CONFIG
                                   ; big jumps in/broken timestamps, usualy sent from exotic devices
                                   ; and programs. Defaults to 1000.
 
-    ; jbimpl = fixed              ; Jitterbuffer implementation, used on the receiving side of a SIP
-                                  ; channel. Two implementation are currenlty available - "fixed"
+    ; jbimpl = fixed              ; Jitterbuffer implementation, used on the receiving side of an OSS
+                                  ; channel. Two implementations are currenlty available - "fixed"
                                   ; (with size always equals to jbmax-size) and "adaptive" (with
                                   ; variable size, actually the new jb of IAX2). Defaults to fixed.
 
index 4f49017231ab33d1584a789d4c67a9646219b79b..93bd72df582eb4ad871eceb3ecb4bb5cc3cab468 100644 (file)
@@ -857,7 +857,6 @@ static struct sip_pvt {
        struct ast_variable *chanvars;          /*!< Channel variables to set for inbound call */
        struct sip_pvt *next;                   /*!< Next dialog in chain */
        struct sip_invite_param *options;       /*!< Options for INVITE */
-       struct ast_jb_conf jbconf;
 } *iflist = NULL;
 
 #define FLAG_RESPONSE (1 << 0)
@@ -3357,7 +3356,7 @@ static struct ast_channel *sip_new(struct sip_pvt *i, int state, const char *tit
 
        /* Configure the new channel jb */
        if (tmp && i && i->rtp)
-               ast_jb_configure(tmp, &i->jbconf);
+               ast_jb_configure(tmp, &global_jbconf);
 
        return tmp;
 }
@@ -3693,9 +3692,6 @@ static struct sip_pvt *sip_alloc(ast_string_field callid, struct sockaddr_in *si
                p->noncodeccapability |= AST_RTP_DTMF;
        ast_string_field_set(p, context, default_context);
 
-       /* Assign default jb conf to the new sip_pvt */
-       memcpy(&p->jbconf, &global_jbconf, sizeof(struct ast_jb_conf));
-
        /* Add to active dialog list */
        ast_mutex_lock(&iflock);
        p->next = iflist;
index db10d829f38ee3aa8321b026c4bbe38a7014a535..914297aedb57be9aa798befd8017a9d93a5cd4cb 100644 (file)
@@ -826,8 +826,6 @@ struct skinny_subchannel {
        int nat;
        int outgoing;
        int alreadygone;
-       struct ast_jb_conf jbconf;
-
        struct skinny_subchannel *next;
 };
 
@@ -1615,10 +1613,6 @@ static struct skinny_device *build_device(char *cat, struct ast_variable *v)
                                                        callnums++;
                                                        sub->cxmode = SKINNY_CX_INACTIVE;
                                                        sub->nat = nat;
-
-                                                       /* Assign default jb conf to the new skinny_subchannel */
-                                                       memcpy(&sub->jbconf, &global_jbconf, sizeof(struct ast_jb_conf));
-
                                                        sub->next = l->sub;
                                                        l->sub = sub;
                                                } else {
@@ -2311,7 +2305,7 @@ static struct ast_channel *skinny_new(struct skinny_subchannel *sub, int state)
 
                /* Configure the new channel jb */
                if (tmp && sub && sub->rtp)
-                       ast_jb_configure(tmp, &sub->jbconf);
+                       ast_jb_configure(tmp, &global_jbconf);
        } else {
                ast_log(LOG_WARNING, "Unable to allocate channel structure\n");
        }
@@ -3121,7 +3115,7 @@ static int reload_config(void)
 
        /* load the general section */
        v = ast_variable_browse(cfg, "general");
-       while(v) {
+       while (v) {
                /* handle jb conf */
                if (!ast_jb_read_conf(&global_jbconf, v->name, v->value)) {
                        v = v->next;
index 9ee5ed0a817bf7337767d967b9e1d68114fb4e72..f30a851dd088996adc7600bd58d14736e965cfc4 100644 (file)
@@ -698,8 +698,6 @@ static struct zt_pvt {
 #endif 
        int polarity;
        int dsp_features;
-       struct ast_jb_conf jbconf;
-
 } *iflist = NULL, *ifend = NULL;
 
 static struct ast_channel *zt_request(const char *type, int format, void *data, int *cause);
@@ -5215,7 +5213,7 @@ static struct ast_channel *zt_new(struct zt_pvt *i, int state, int startpbx, int
                ast_log(LOG_WARNING, "Unable to allocate channel structure\n");
        /* Configure the new channel jb */
        if (tmp && i)
-               ast_jb_configure(tmp, &i->jbconf);
+               ast_jb_configure(tmp, &global_jbconf);
        return tmp;
 }
 
@@ -7011,8 +7009,6 @@ static struct zt_pvt *mkintf(int channel, int signalling, int outsignalling, int
                for (x = 0; x < 3; x++)
                        tmp->subs[x].zfd = -1;
                tmp->channel = channel;
-               /* Assign default jb conf to the new zt_pvt */
-               memcpy(&tmp->jbconf, &global_jbconf, sizeof(struct ast_jb_conf));
        }
 
        if (tmp) {
index 42858ed74d66b32bb7358f3fd67cab1077de2237..16439758087beed699b212919c6456c0b190932b 100644 (file)
@@ -63,6 +63,32 @@ allow=gsm            ; Always allow GSM, it's cool :)
 ; use user authentication at all.
 ;
 ;context=default
+;------------------------------ JITTER BUFFER CONFIGURATION --------------------------
+; jbenable = yes              ; Enables the use of a jitterbuffer on the receiving side of a
+                              ; H323 channel. Defaults to "no". An enabled jitterbuffer will
+                              ; be used only if the sending side can create and the receiving
+                              ; side can not accept jitter. The H323 channel can accept jitter,
+                              ; thus an enabled jitterbuffer on the receive H323 side will only
+                              ; be used if the sending side can create jitter and jbforce is
+                              ; also set to yes.
+
+; jbforce = no                ; Forces the use of a jitterbuffer on the receive side of a H323
+                              ; channel. Defaults to "no".
+
+; jbmaxsize = 200             ; Max length of the jitterbuffer in milliseconds.
+
+; jbresyncthreshold = 1000    ; Jump in the frame timestamps over which the jitterbuffer is
+                              ; resynchronized. Useful to improve the quality of the voice, with
+                              ; big jumps in/broken timestamps, usualy sent from exotic devices
+                              ; and programs. Defaults to 1000.
+
+; jbimpl = fixed              ; Jitterbuffer implementation, used on the receiving side of a H323
+                              ; channel. Two implementations are currenlty available - "fixed"
+                              ; (with size always equals to jbmax-size) and "adaptive" (with
+                              ; variable size, actually the new jb of IAX2). Defaults to fixed.
+
+; jblog = no                  ; Enables jitterbuffer frame logging. Defaults to "no".
+;-----------------------------------------------------------------------------------
 ;
 ; H.323 Alias definitions
 ;
index bfe77101f0da5ac241f73232623a095de5036cd8..e391977196436d6bbb0993dcd16da3a96aef7ecc 100644 (file)
@@ -34,13 +34,9 @@ extension=s
 ; jbenable = yes              ; Enables the use of a jitterbuffer on the receiving side of an
                               ; ALSA channel. Defaults to "no". An enabled jitterbuffer will
                               ; be used only if the sending side can create and the receiving
-                              ; side can not accept jitter. The ZAP channel can't accept jitter,
-                              ; thus an enabled jitterbuffer on the receive ZAP side will always
-                              ; be used if the sending side can create jitter or if ZAP jb is
-                              ; forced.
-
-; jbforce = no                ; Forces the use of a jitterbuffer on the receive side of a ZAP
-                              ; channel. Defaults to "no".
+                              ; side can not accept jitter. The ALSA channel can't accept jitter,
+                              ; thus an enabled jitterbuffer on the receive ALSA side will always
+                              ; be used if the sending side can create jitter.
 
 ; jbmaxsize = 200             ; Max length of the jitterbuffer in milliseconds.
 
index 2279977d8e5a4fd8c9058db86cda947a58bedc1c..c80104e324701781bdef8c5027fcf9bdbc723c7b 100644 (file)
@@ -5,6 +5,33 @@
 ;port = 2427
 ;bindaddr = 0.0.0.0
 
+;------------------------------ JITTER BUFFER CONFIGURATION --------------------------
+; jbenable = yes              ; Enables the use of a jitterbuffer on the receiving side of a
+                              ; MGCP channel. Defaults to "no". An enabled jitterbuffer will
+                              ; be used only if the sending side can create and the receiving
+                              ; side can not accept jitter. The MGCP channel can accept jitter,
+                              ; thus an enabled jitterbuffer on the receive MGCP side will only
+                              ; be used if the sending side can create jitter and jbforce is
+                              ; also set to yes.
+
+; jbforce = no                ; Forces the use of a jitterbuffer on the receive side of a MGCP
+                              ; channel. Defaults to "no".
+
+; jbmaxsize = 200             ; Max length of the jitterbuffer in milliseconds.
+
+; jbresyncthreshold = 1000    ; Jump in the frame timestamps over which the jitterbuffer is
+                              ; resynchronized. Useful to improve the quality of the voice, with
+                              ; big jumps in/broken timestamps, usualy sent from exotic devices
+                              ; and programs. Defaults to 1000.
+
+; jbimpl = fixed              ; Jitterbuffer implementation, used on the receiving side of a MGCP
+                              ; channel. Two implementations are currenlty available - "fixed"
+                              ; (with size always equals to jbmax-size) and "adaptive" (with
+                              ; variable size, actually the new jb of IAX2). Defaults to fixed.
+
+; jblog = no                  ; Enables jitterbuffer frame logging. Defaults to "no".
+;-----------------------------------------------------------------------------------
+
 ;[dlinkgw]
 ;host = 192.168.0.64
 ;context = default
index 6997ccb9c28a627aa1babfb159c889a6767264ea..ec42da771be28483bd1e4278d11fc35913dca764 100644 (file)
     ; jbenable = yes              ; Enables the use of a jitterbuffer on the receiving side of an
                                   ; OSS channel. Defaults to "no". An enabled jitterbuffer will
                                   ; be used only if the sending side can create and the receiving
-                                  ; side can not accept jitter. The ZAP channel can't accept jitter,
-                                  ; thus an enabled jitterbuffer on the receive ZAP side will always
-                                  ; be used if the sending side can create jitter or if ZAP jb is
-                                  ; forced.
-
-    ; jbforce = no                ; Forces the use of a jitterbuffer on the receive side of a ZAP
-                                  ; channel. Defaults to "no".
+                                  ; side can not accept jitter. The OSS channel can't accept jitter,
+                                  ; thus an enabled jitterbuffer on the receive OSS side will always
+                                  ; be used if the sending side can create jitter.
 
     ; jbmaxsize = 200             ; Max length of the jitterbuffer in milliseconds.
 
@@ -65,8 +61,8 @@
                                   ; big jumps in/broken timestamps, usualy sent from exotic devices
                                   ; and programs. Defaults to 1000.
 
-    ; jbimpl = fixed              ; Jitterbuffer implementation, used on the receiving side of a SIP
-                                  ; channel. Two implementation are currenlty available - "fixed"
+    ; jbimpl = fixed              ; Jitterbuffer implementation, used on the receiving side of an OSS
+                                  ; channel. Two implementations are currenlty available - "fixed"
                                   ; (with size always equals to jbmax-size) and "adaptive" (with
                                   ; variable size, actually the new jb of IAX2). Defaults to fixed.
 
index 67d6dd21ffeb7d0b98763846d43974c253eff5e3..2b898437bdfd3e9babffbfec78f1c4f77168320c 100644 (file)
@@ -321,7 +321,7 @@ srvlookup=yes                       ; Enable DNS SRV lookups on outbound calls
                               ; and programs. Defaults to 1000.
 
 ; jbimpl = fixed              ; Jitterbuffer implementation, used on the receiving side of a SIP
-                              ; channel. Two implementation are currenlty available - "fixed"
+                              ; channel. Two implementations are currenlty available - "fixed"
                               ; (with size always equals to jbmaxsize) and "adaptive" (with
                               ; variable size, actually the new jb of IAX2). Defaults to fixed.
 
index ab368b1ab7f2eb4e2d1189e86634fb6d2d99f0a2..e18709334dc5c85867ba5d76ca07380839389e94 100644 (file)
@@ -29,7 +29,7 @@ keepAlive=120
                              ; and programs. Defaults to 1000.
 
 ;jbimpl = fixed              ; Jitterbuffer implementation, used on the receiving side of a
-                             ; skinny channel. Two implementation are currently available
+                             ; skinny channel. Two implementations are currently available
                              ; - "fixed" (with size always equals to jbmaxsize)
                              ; - "adaptive" (with variable size, actually the new jb of IAX2).
                              ; Defaults to fixed.
index aacbce0206b23a63161a383a84790e02744121d4..c20ecbe5fcbfde4c8f7a7d15dbd89d70f43643d3 100644 (file)
@@ -501,11 +501,7 @@ immediate=no
                               ; be used only if the sending side can create and the receiving
                               ; side can not accept jitter. The ZAP channel can't accept jitter,
                               ; thus an enabled jitterbuffer on the receive ZAP side will always
-                              ; be used if the sending side can create jitter or if ZAP jb is
-                              ; forced.
-
-; jbforce = no                ; Forces the use of a jitterbuffer on the receive side of a ZAP
-                              ; channel. Defaults to "no".
+                              ; be used if the sending side can create jitter.
 
 ; jbmaxsize = 200             ; Max length of the jitterbuffer in milliseconds.
 
@@ -514,8 +510,8 @@ immediate=no
                               ; big jumps in/broken timestamps, usualy sent from exotic devices
                               ; and programs. Defaults to 1000.
 
-; jbimpl = fixed              ; Jitterbuffer implementation, used on the receiving side of a SIP
-                              ; channel. Two implementation are currenlty available - "fixed"
+; jbimpl = fixed              ; Jitterbuffer implementation, used on the receiving side of a ZAP
+                              ; channel. Two implementations are currenlty available - "fixed"
                               ; (with size always equals to jbmax-size) and "adaptive" (with
                               ; variable size, actually the new jb of IAX2). Defaults to fixed.