Asterisk - The Open Source Telephony Project  18.5.0
Functions | Variables
func_jitterbuffer.c File Reference

Put a jitterbuffer on the read side of a channel. More...

#include "asterisk.h"
#include "asterisk/module.h"
#include "asterisk/channel.h"
#include "asterisk/framehook.h"
#include "asterisk/frame.h"
#include "asterisk/pbx.h"
#include "asterisk/abstract_jb.h"
#include "asterisk/timing.h"
#include "asterisk/app.h"
Include dependency graph for func_jitterbuffer.c:

Go to the source code of this file.

Functions

static void __reg_module (void)
 
static void __unreg_module (void)
 
struct ast_moduleAST_MODULE_SELF_SYM (void)
 
static int jb_helper (struct ast_channel *chan, const char *cmd, char *data, const char *value)
 
static int load_module (void)
 
static int unload_module (void)
 

Variables

static struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Jitter buffer for read side of channel." , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = "30ef0c93b36035ec78c9cfd712d36d9b" , .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, .support_level = AST_MODULE_SUPPORT_CORE, }
 
static const struct ast_module_infoast_module_info = &__mod_info
 
static struct ast_custom_function jb_function
 

Detailed Description

Put a jitterbuffer on the read side of a channel.

Author
David Vossel dvoss.nosp@m.el@d.nosp@m.igium.nosp@m..com

Definition in file func_jitterbuffer.c.

Function Documentation

◆ __reg_module()

static void __reg_module ( void  )
static

Definition at line 196 of file func_jitterbuffer.c.

◆ __unreg_module()

static void __unreg_module ( void  )
static

Definition at line 196 of file func_jitterbuffer.c.

◆ AST_MODULE_SELF_SYM()

struct ast_module* AST_MODULE_SELF_SYM ( void  )

Definition at line 196 of file func_jitterbuffer.c.

◆ jb_helper()

static int jb_helper ( struct ast_channel chan,
const char *  cmd,
char *  data,
const char *  value 
)
static

Definition at line 115 of file func_jitterbuffer.c.

References args, AST_APP_ARG, ast_copy_string(), AST_DECLARE_APP_ARGS, ast_jb_conf_default(), ast_jb_create_framehook(), ast_jb_read_conf(), ast_log, AST_STANDARD_APP_ARGS, ast_strdupa, ast_strlen_zero, ast_jb_conf::impl, LOG_WARNING, ast_jb_conf::max_size, parse(), ast_jb_conf::resync_threshold, and ast_jb_conf::target_extra.

116 {
117  struct ast_jb_conf jb_conf;
118 
119  if (!chan) {
120  ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd);
121  return -1;
122  }
123 
124  /* Initialize and set jb_conf */
126 
127  /* Now check user options to see if any of the defaults need to change. */
128  if (!ast_strlen_zero(data)) {
129  if (strcasecmp(data, "fixed") &&
130  strcasecmp(data, "adaptive") &&
131  strcasecmp(data, "disabled")) {
132  ast_log(LOG_WARNING, "Unknown Jitterbuffer type %s. Failed to create jitterbuffer.\n", data);
133  return -1;
134  }
135  ast_copy_string(jb_conf.impl, data, sizeof(jb_conf.impl));
136  }
137 
138  if (!ast_strlen_zero(value) && strcasecmp(value, "default")) {
139  char *parse = ast_strdupa(value);
140  int res = 0;
145  AST_APP_ARG(sync_video);
146  );
147 
148  AST_STANDARD_APP_ARGS(args, parse);
149  if (!ast_strlen_zero(args.max_size)) {
150  res |= ast_jb_read_conf(&jb_conf,
151  "jbmaxsize",
152  args.max_size);
153  }
154  if (!ast_strlen_zero(args.resync_threshold)) {
155  res |= ast_jb_read_conf(&jb_conf,
156  "jbresyncthreshold",
157  args.resync_threshold);
158  }
159  if (!ast_strlen_zero(args.target_extra)) {
160  res |= ast_jb_read_conf(&jb_conf,
161  "jbtargetextra",
162  args.target_extra);
163  }
164  if (!ast_strlen_zero(args.sync_video)) {
165  res |= ast_jb_read_conf(&jb_conf,
166  "jbsyncvideo",
167  args.sync_video);
168  }
169  if (res) {
170  ast_log(LOG_WARNING, "Invalid jitterbuffer parameters %s\n", value);
171  }
172  }
173 
174  ast_jb_create_framehook(chan, &jb_conf, 0);
175 
176  return 0;
177 }
void ast_jb_create_framehook(struct ast_channel *chan, struct ast_jb_conf *jb_conf, int prefer_existing)
Applies a jitterbuffer framehook to a channel based on a provided jitterbuffer config.
Definition: abstract_jb.c:1257
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the 'standard' argument separation process for an application.
#define LOG_WARNING
Definition: logger.h:274
int ast_jb_read_conf(struct ast_jb_conf *conf, const char *varname, const char *value)
Sets jitterbuffer configuration property.
Definition: abstract_jb.c:545
const char * args
int value
Definition: syslog.c:37
#define ast_strlen_zero(foo)
Definition: strings.h:52
void ast_jb_conf_default(struct ast_jb_conf *conf)
Sets the contents of an ast_jb_conf struct to the default jitterbuffer settings.
Definition: abstract_jb.c:890
long resync_threshold
Resynchronization threshold of the jitterbuffer implementation.
Definition: abstract_jb.h:76
#define ast_log
Definition: astobj2.c:42
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:300
long target_extra
amount of additional jitterbuffer adjustment
Definition: abstract_jb.h:80
static void parse(struct mgcp_request *req)
Definition: chan_mgcp.c:1872
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:401
long max_size
Max size of the jitterbuffer implementation.
Definition: abstract_jb.h:74
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
General jitterbuffer configuration.
Definition: abstract_jb.h:69
#define AST_APP_ARG(name)
Define an application argument.

◆ load_module()

static int load_module ( void  )
static

Definition at line 190 of file func_jitterbuffer.c.

References ast_custom_function_register, AST_MODULE_LOAD_DECLINE, and AST_MODULE_LOAD_SUCCESS.

191 {
194 }
Module has failed to load, may be in an inconsistent state.
Definition: module.h:78
#define ast_custom_function_register(acf)
Register a custom function.
Definition: pbx.h:1508
static struct ast_custom_function jb_function

◆ unload_module()

static int unload_module ( void  )
static

Definition at line 185 of file func_jitterbuffer.c.

References ast_custom_function_unregister().

186 {
188 }
int ast_custom_function_unregister(struct ast_custom_function *acf)
Unregister a custom function.
static struct ast_custom_function jb_function

Variable Documentation

◆ __mod_info

struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Jitter buffer for read side of channel." , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = "30ef0c93b36035ec78c9cfd712d36d9b" , .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, .support_level = AST_MODULE_SUPPORT_CORE, }
static

Definition at line 196 of file func_jitterbuffer.c.

◆ ast_module_info

const struct ast_module_info* ast_module_info = &__mod_info
static

Definition at line 196 of file func_jitterbuffer.c.

◆ jb_function

struct ast_custom_function jb_function
static
Initial value:
= {
.name = "JITTERBUFFER",
.write = jb_helper,
}
static int jb_helper(struct ast_channel *chan, const char *cmd, char *data, const char *value)

Definition at line 180 of file func_jitterbuffer.c.