Asterisk - The Open Source Telephony Project  18.5.0
Functions
multicast_rtp.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

struct ast_multicast_rtp_optionsast_multicast_rtp_create_options (const char *type, const char *options)
 Create multicast RTP options. More...
 
void ast_multicast_rtp_free_options (struct ast_multicast_rtp_options *mcast_options)
 Free multicast RTP options. More...
 
struct ast_formatast_multicast_rtp_options_get_format (struct ast_multicast_rtp_options *mcast_options)
 Get format specified in multicast options. More...
 

Function Documentation

◆ ast_multicast_rtp_create_options()

struct ast_multicast_rtp_options* ast_multicast_rtp_create_options ( const char *  type,
const char *  options 
)

Create multicast RTP options.

These are passed to the multicast RTP engine on its creation.

Parameters
typeThe type of multicast RTP, either "basic" or "linksys"
optionsMiscellaneous options
Return values
NULLFailure
non-NULLsuccess

Definition at line 140 of file res_rtp_multicast.c.

References ast_app_parse_options(), ast_calloc, ast_log, ast_multicast_rtp_free_options(), ast_strlen_zero, ast_multicast_rtp_options::buf, LOG_WARNING, multicast_rtp_options, NULL, ast_multicast_rtp_options::opt_args, ast_multicast_rtp_options::options, ast_multicast_rtp_options::opts, S_OR, and ast_multicast_rtp_options::type.

Referenced by multicast_rtp_request().

142 {
143  struct ast_multicast_rtp_options *mcast_options;
144  char *pos;
145 
146  mcast_options = ast_calloc(1, sizeof(*mcast_options)
147  + strlen(type)
148  + strlen(S_OR(options, "")) + 2);
149  if (!mcast_options) {
150  return NULL;
151  }
152 
153  pos = mcast_options->buf;
154 
155  /* Safe */
156  strcpy(pos, type);
157  mcast_options->type = pos;
158  pos += strlen(type) + 1;
159 
160  if (!ast_strlen_zero(options)) {
161  strcpy(pos, options); /* Safe */
162  }
163  mcast_options->options = pos;
164 
165  if (ast_app_parse_options(multicast_rtp_options, &mcast_options->opts,
166  mcast_options->opt_args, mcast_options->options)) {
167  ast_log(LOG_WARNING, "Error parsing multicast RTP options\n");
168  ast_multicast_rtp_free_options(mcast_options);
169  return NULL;
170  }
171 
172  return mcast_options;
173 }
static const char type[]
Definition: chan_ooh323.c:109
#define LOG_WARNING
Definition: logger.h:274
void ast_multicast_rtp_free_options(struct ast_multicast_rtp_options *mcast_options)
Free multicast RTP options.
#define NULL
Definition: resample.c:96
#define ast_strlen_zero(foo)
Definition: strings.h:52
static const struct ast_app_option multicast_rtp_options[128]
#define ast_log
Definition: astobj2.c:42
char * opt_args[OPT_ARG_ARRAY_SIZE]
int ast_app_parse_options(const struct ast_app_option *options, struct ast_flags *flags, char **args, char *optstr)
Parses a string containing application options and sets flags/arguments.
Definition: main/app.c:2906
#define ast_calloc(num, len)
A wrapper for calloc()
Definition: astmm.h:204
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one...
Definition: strings.h:79
static struct test_options options

◆ ast_multicast_rtp_free_options()

void ast_multicast_rtp_free_options ( struct ast_multicast_rtp_options mcast_options)

Free multicast RTP options.

This function is NULL-tolerant

Parameters
mcast_optionsOptions to free

Definition at line 175 of file res_rtp_multicast.c.

References ast_free.

Referenced by ast_multicast_rtp_create_options(), and multicast_rtp_request().

176 {
177  ast_free(mcast_options);
178 }
#define ast_free(a)
Definition: astmm.h:182

◆ ast_multicast_rtp_options_get_format()

struct ast_format* ast_multicast_rtp_options_get_format ( struct ast_multicast_rtp_options mcast_options)

Get format specified in multicast options.

Multicast options allow for a format to be selected. This function accesses the selected format and creates an ast_format structure for it.

Parameters
mcast_optionsThe options where a codec was specified
Return values
NULLNo format specified in the options non-NULL The format to use for communication

Definition at line 180 of file res_rtp_multicast.c.

References ast_format_cache_get, ast_strlen_zero, ast_test_flag, multicast_rtp_activate(), multicast_rtp_destroy(), multicast_rtp_new(), multicast_rtp_read(), multicast_rtp_write(), NULL, OPT_ARG_CODEC, ast_multicast_rtp_options::opt_args, OPT_CODEC, and ast_multicast_rtp_options::opts.

Referenced by multicast_rtp_request().

181 {
182  if (ast_test_flag(&mcast_options->opts, OPT_CODEC)
183  && !ast_strlen_zero(mcast_options->opt_args[OPT_ARG_CODEC])) {
184  return ast_format_cache_get(mcast_options->opt_args[OPT_ARG_CODEC]);
185  }
186 
187  return NULL;
188 }
#define ast_test_flag(p, flag)
Definition: utils.h:63
#define NULL
Definition: resample.c:96
#define ast_format_cache_get(name)
Definition: format_cache.h:286
#define ast_strlen_zero(foo)
Definition: strings.h:52
char * opt_args[OPT_ARG_ARRAY_SIZE]