Asterisk - The Open Source Telephony Project GIT-master-f36a736
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.

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
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}
#define ast_calloc(num, len)
A wrapper for calloc()
Definition: astmm.h:202
#define ast_log
Definition: astobj2.c:42
static const char type[]
Definition: chan_ooh323.c:109
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:3066
#define LOG_WARNING
static const struct ast_app_option multicast_rtp_options[128]
void ast_multicast_rtp_free_options(struct ast_multicast_rtp_options *mcast_options)
Free multicast RTP options.
#define NULL
Definition: resample.c:96
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one.
Definition: strings.h:80
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:65
char * opt_args[OPT_ARG_ARRAY_SIZE]
static struct test_options options

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, options, ast_multicast_rtp_options::opts, S_OR, type, and ast_multicast_rtp_options::type.

Referenced by multicast_rtp_request().

◆ 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.

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

References ast_free.

Referenced by ast_multicast_rtp_create_options(), and multicast_rtp_request().

◆ 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-NULLThe format to use for communication

Definition at line 180 of file res_rtp_multicast.c.

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_format_cache_get(name)
Retrieve a named format from the cache.
Definition: format_cache.h:278
@ OPT_ARG_CODEC
@ OPT_CODEC
#define ast_test_flag(p, flag)
Definition: utils.h:63

References ast_format_cache_get, ast_strlen_zero(), ast_test_flag, NULL, OPT_ARG_CODEC, ast_multicast_rtp_options::opt_args, OPT_CODEC, and ast_multicast_rtp_options::opts.

Referenced by multicast_rtp_request().