@ -42,7 +42,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
# include "asterisk/utils.h"
# include "asterisk/abstract_jb.h"
# include " scx_ jitterbuf.h"
# include " fixed jitterbuf.h"
# include "jitterbuf.h"
/*! Internal jb flags */
@ -89,49 +89,49 @@ struct ast_jb_impl
} ;
/* Implementation functions */
/* scx */
static void * jb_create_ scx ( struct ast_jb_conf * general_config , long resynch_threshold ) ;
static void jb_destroy_ scx ( void * jb ) ;
static int jb_put_first_ scx ( void * jb , struct ast_frame * fin , long now ) ;
static int jb_put_ scx ( void * jb , struct ast_frame * fin , long now ) ;
static int jb_get_ scx ( void * jb , struct ast_frame * * fout , long now , long interpl ) ;
static long jb_next_ scx ( void * jb ) ;
static int jb_remove_ scx ( void * jb , struct ast_frame * * fout ) ;
static void jb_force_resynch_ scx ( void * jb ) ;
/* stevek */
static void * jb_create_ stevek ( struct ast_jb_conf * general_config , long resynch_threshold ) ;
static void jb_destroy_ stevek ( void * jb ) ;
static int jb_put_first_ stevek ( void * jb , struct ast_frame * fin , long now ) ;
static int jb_put_ stevek ( void * jb , struct ast_frame * fin , long now ) ;
static int jb_get_ stevek ( void * jb , struct ast_frame * * fout , long now , long interpl ) ;
static long jb_next_ stevek ( void * jb ) ;
static int jb_remove_ stevek ( void * jb , struct ast_frame * * fout ) ;
static void jb_force_resynch_ stevek ( void * jb ) ;
/* fixed */
static void * jb_create_ fixed ( struct ast_jb_conf * general_config , long resynch_threshold ) ;
static void jb_destroy_ fixed ( void * jb ) ;
static int jb_put_first_ fixed ( void * jb , struct ast_frame * fin , long now ) ;
static int jb_put_ fixed ( void * jb , struct ast_frame * fin , long now ) ;
static int jb_get_ fixed ( void * jb , struct ast_frame * * fout , long now , long interpl ) ;
static long jb_next_ fixed ( void * jb ) ;
static int jb_remove_ fixed ( void * jb , struct ast_frame * * fout ) ;
static void jb_force_resynch_ fixed ( void * jb ) ;
/* adaptive */
static void * jb_create_ adaptive ( struct ast_jb_conf * general_config , long resynch_threshold ) ;
static void jb_destroy_ adaptive ( void * jb ) ;
static int jb_put_first_ adaptive ( void * jb , struct ast_frame * fin , long now ) ;
static int jb_put_ adaptive ( void * jb , struct ast_frame * fin , long now ) ;
static int jb_get_ adaptive ( void * jb , struct ast_frame * * fout , long now , long interpl ) ;
static long jb_next_ adaptive ( void * jb ) ;
static int jb_remove_ adaptive ( void * jb , struct ast_frame * * fout ) ;
static void jb_force_resynch_ adaptive ( void * jb ) ;
/* Available jb implementations */
static struct ast_jb_impl avail_impl [ ] =
{
{
. name = " fixed " ,
. create = jb_create_ scx ,
. destroy = jb_destroy_ scx ,
. put_first = jb_put_first_ scx ,
. put = jb_put_ scx ,
. get = jb_get_ scx ,
. next = jb_next_ scx ,
. remove = jb_remove_ scx ,
. force_resync = jb_force_resynch_ scx
. create = jb_create_ fixed ,
. destroy = jb_destroy_ fixed ,
. put_first = jb_put_first_ fixed ,
. put = jb_put_ fixed ,
. get = jb_get_ fixed ,
. next = jb_next_ fixed ,
. remove = jb_remove_ fixed ,
. force_resync = jb_force_resynch_ fixed
} ,
{
. name = " adaptive " ,
. create = jb_create_ stevek ,
. destroy = jb_destroy_ stevek ,
. put_first = jb_put_first_ stevek ,
. put = jb_put_ stevek ,
. get = jb_get_ stevek ,
. next = jb_next_ stevek ,
. remove = jb_remove_ stevek ,
. force_resync = jb_force_resynch_ stevek
. create = jb_create_ adaptive ,
. destroy = jb_destroy_ adaptive ,
. put_first = jb_put_first_ adaptive ,
. put = jb_put_ adaptive ,
. get = jb_get_ adaptive ,
. next = jb_next_ adaptive ,
. remove = jb_remove_ adaptive ,
. force_resync = jb_force_resynch_ adaptive
}
} ;
@ -147,9 +147,9 @@ enum {
} ;
/* Translations between impl and abstract return codes */
static int scx _to_abstract_code[ ] =
static int fixed _to_abstract_code[ ] =
{ JB_IMPL_OK , JB_IMPL_DROP , JB_IMPL_INTERP , JB_IMPL_NOFRAME } ;
static int stevek _to_abstract_code[ ] =
static int adaptive _to_abstract_code[ ] =
{ JB_IMPL_OK , JB_IMPL_NOFRAME , JB_IMPL_NOFRAME , JB_IMPL_INTERP , JB_IMPL_DROP , JB_IMPL_OK } ;
/* JB_GET actions (used only for the frames log) */
@ -467,7 +467,7 @@ static int create_jb(struct ast_channel *chan, struct ast_frame *frr)
res = jbimpl - > put_first ( jbobj , frr , now ) ;
/* The result of putting the first frame should not differ from OK. However, its possible
some implementations ( i . e . stevek ' s when resynch_threshold is specified ) to drop it . */
some implementations ( i . e . adaptive ' s when resynch_threshold is specified ) to drop it . */
if ( res ! = JB_IMPL_OK ) {
ast_log ( LOG_WARNING , " Failed to put first frame in the jitterbuffer on channel '%s' \n " , chan - > name ) ;
/*
@ -615,170 +615,170 @@ void ast_jb_get_config(const struct ast_channel *chan, struct ast_jb_conf *conf)
/* Implementation functions */
/* scx */
/* fixed */
static void * jb_create_ scx ( struct ast_jb_conf * general_config , long resynch_threshold )
static void * jb_create_ fixed ( struct ast_jb_conf * general_config , long resynch_threshold )
{
struct scx _jb_conf conf ;
struct fixed _jb_conf conf ;
conf . jbsize = general_config - > max_size ;
conf . resync_threshold = resynch_threshold ;
return scx _jb_new( & conf ) ;
return fixed _jb_new( & conf ) ;
}
static void jb_destroy_ scx ( void * jb )
static void jb_destroy_ fixed ( void * jb )
{
struct scx_jb * scxjb = ( struct scx _jb * ) jb ;
struct fixed_jb * fixedjb = ( struct fixed _jb * ) jb ;
/* destroy the jb */
scx_jb_destroy( scx jb) ;
fixed_jb_destroy( fixed jb) ;
}
static int jb_put_first_ scx ( void * jb , struct ast_frame * fin , long now )
static int jb_put_first_ fixed ( void * jb , struct ast_frame * fin , long now )
{
struct scx_jb * scxjb = ( struct scx _jb * ) jb ;
struct fixed_jb * fixedjb = ( struct fixed _jb * ) jb ;
int res ;
res = scx_jb_put_first( scx jb, fin , fin - > len , fin - > ts , now ) ;
res = fixed_jb_put_first( fixed jb, fin , fin - > len , fin - > ts , now ) ;
return scx _to_abstract_code[ res ] ;
return fixed _to_abstract_code[ res ] ;
}
static int jb_put_ scx ( void * jb , struct ast_frame * fin , long now )
static int jb_put_ fixed ( void * jb , struct ast_frame * fin , long now )
{
struct scx_jb * scxjb = ( struct scx _jb * ) jb ;
struct fixed_jb * fixedjb = ( struct fixed _jb * ) jb ;
int res ;
res = scx_jb_put( scx jb, fin , fin - > len , fin - > ts , now ) ;
res = fixed_jb_put( fixed jb, fin , fin - > len , fin - > ts , now ) ;
return scx _to_abstract_code[ res ] ;
return fixed _to_abstract_code[ res ] ;
}
static int jb_get_ scx ( void * jb , struct ast_frame * * fout , long now , long interpl )
static int jb_get_ fixed ( void * jb , struct ast_frame * * fout , long now , long interpl )
{
struct scx_jb * scxjb = ( struct scx _jb * ) jb ;
struct scx _jb_frame frame ;
struct fixed_jb * fixedjb = ( struct fixed _jb * ) jb ;
struct fixed _jb_frame frame ;
int res ;
res = scx_jb_get( scx jb, & frame , now , interpl ) ;
res = fixed_jb_get( fixed jb, & frame , now , interpl ) ;
* fout = frame . data ;
return scx _to_abstract_code[ res ] ;
return fixed _to_abstract_code[ res ] ;
}
static long jb_next_ scx ( void * jb )
static long jb_next_ fixed ( void * jb )
{
struct scx_jb * scxjb = ( struct scx _jb * ) jb ;
struct fixed_jb * fixedjb = ( struct fixed _jb * ) jb ;
return scx_jb_next( scx jb) ;
return fixed_jb_next( fixed jb) ;
}
static int jb_remove_ scx ( void * jb , struct ast_frame * * fout )
static int jb_remove_ fixed ( void * jb , struct ast_frame * * fout )
{
struct scx_jb * scxjb = ( struct scx _jb * ) jb ;
struct scx _jb_frame frame ;
struct fixed_jb * fixedjb = ( struct fixed _jb * ) jb ;
struct fixed _jb_frame frame ;
int res ;
res = scx_jb_remove( scx jb, & frame ) ;
res = fixed_jb_remove( fixed jb, & frame ) ;
* fout = frame . data ;
return scx _to_abstract_code[ res ] ;
return fixed _to_abstract_code[ res ] ;
}
static void jb_force_resynch_ scx ( void * jb )
static void jb_force_resynch_ fixed ( void * jb )
{
struct scx_jb * scxjb = ( struct scx _jb * ) jb ;
struct fixed_jb * fixedjb = ( struct fixed _jb * ) jb ;
scx_jb_set_force_resynch( scx jb) ;
fixed_jb_set_force_resynch( fixed jb) ;
}
/* stevek */
/* adaptive */
static void * jb_create_ stevek ( struct ast_jb_conf * general_config , long resynch_threshold )
static void * jb_create_ adaptive ( struct ast_jb_conf * general_config , long resynch_threshold )
{
jb_conf jbconf ;
jitterbuf * stevek jb;
jitterbuf * adaptive jb;
stevek jb = jb_new ( ) ;
if ( stevek jb) {
adaptive jb = jb_new ( ) ;
if ( adaptive jb) {
jbconf . max_jitterbuf = general_config - > max_size ;
jbconf . resync_threshold = general_config - > resync_threshold ;
jbconf . max_contig_interp = 10 ;
jb_setconf ( stevek jb, & jbconf ) ;
jb_setconf ( adaptive jb, & jbconf ) ;
}
return stevek jb;
return adaptive jb;
}
static void jb_destroy_ stevek ( void * jb )
static void jb_destroy_ adaptive ( void * jb )
{
jitterbuf * stevek jb = ( jitterbuf * ) jb ;
jitterbuf * adaptive jb = ( jitterbuf * ) jb ;
jb_destroy ( stevek jb) ;
jb_destroy ( adaptive jb) ;
}
static int jb_put_first_ stevek ( void * jb , struct ast_frame * fin , long now )
static int jb_put_first_ adaptive ( void * jb , struct ast_frame * fin , long now )
{
return jb_put_ stevek ( jb , fin , now ) ;
return jb_put_ adaptive ( jb , fin , now ) ;
}
static int jb_put_ stevek ( void * jb , struct ast_frame * fin , long now )
static int jb_put_ adaptive ( void * jb , struct ast_frame * fin , long now )
{
jitterbuf * stevek jb = ( jitterbuf * ) jb ;
jitterbuf * adaptive jb = ( jitterbuf * ) jb ;
int res ;
res = jb_put ( stevek jb, fin , JB_TYPE_VOICE , fin - > len , fin - > ts , now ) ;
res = jb_put ( adaptive jb, fin , JB_TYPE_VOICE , fin - > len , fin - > ts , now ) ;
return stevek _to_abstract_code[ res ] ;
return adaptive _to_abstract_code[ res ] ;
}
static int jb_get_ stevek ( void * jb , struct ast_frame * * fout , long now , long interpl )
static int jb_get_ adaptive ( void * jb , struct ast_frame * * fout , long now , long interpl )
{
jitterbuf * stevek jb = ( jitterbuf * ) jb ;
jitterbuf * adaptive jb = ( jitterbuf * ) jb ;
jb_frame frame ;
int res ;
res = jb_get ( stevek jb, & frame , now , interpl ) ;
res = jb_get ( adaptive jb, & frame , now , interpl ) ;
* fout = frame . data ;
return stevek _to_abstract_code[ res ] ;
return adaptive _to_abstract_code[ res ] ;
}
static long jb_next_ stevek ( void * jb )
static long jb_next_ adaptive ( void * jb )
{
jitterbuf * stevek jb = ( jitterbuf * ) jb ;
jitterbuf * adaptive jb = ( jitterbuf * ) jb ;
return jb_next ( stevek jb) ;
return jb_next ( adaptive jb) ;
}
static int jb_remove_ stevek ( void * jb , struct ast_frame * * fout )
static int jb_remove_ adaptive ( void * jb , struct ast_frame * * fout )
{
jitterbuf * stevek jb = ( jitterbuf * ) jb ;
jitterbuf * adaptive jb = ( jitterbuf * ) jb ;
jb_frame frame ;
int res ;
res = jb_getall ( stevek jb, & frame ) ;
res = jb_getall ( adaptive jb, & frame ) ;
* fout = frame . data ;
return stevek _to_abstract_code[ res ] ;
return adaptive _to_abstract_code[ res ] ;
}
static void jb_force_resynch_ stevek ( void * jb )
static void jb_force_resynch_ adaptive ( void * jb )
{
}