Asterisk - The Open Source Telephony Project GIT-master-f36a736
Data Structures | Functions | Variables
res_format_attr_opus.c File Reference

Opus format attribute interface. More...

#include "asterisk.h"
#include <ctype.h>
#include "asterisk/module.h"
#include "asterisk/format.h"
#include "asterisk/astobj2.h"
#include "asterisk/logger.h"
#include "asterisk/strings.h"
#include "asterisk/utils.h"
#include "asterisk/opus.h"
Include dependency graph for res_format_attr_opus.c:

Go to the source code of this file.

Data Structures

struct  opus_attr
 Opus attribute structure. More...
 

Functions

static void __reg_module (void)
 
static void __unreg_module (void)
 
struct ast_moduleAST_MODULE_SELF_SYM (void)
 
static int load_module (void)
 
static int opus_clone (const struct ast_format *src, struct ast_format *dst)
 
static void opus_destroy (struct ast_format *format)
 
static void opus_generate_sdp_fmtp (const struct ast_format *format, unsigned int payload, struct ast_str **str)
 
static const void * opus_get (const struct ast_format *format, const char *name)
 
static struct ast_formatopus_getjoint (const struct ast_format *format1, const struct ast_format *format2)
 
static struct ast_formatopus_parse_sdp_fmtp (const struct ast_format *format, const char *attributes)
 
static struct ast_formatopus_set (const struct ast_format *format, const char *name, const char *value)
 
static void sdp_fmtp_get (const char *attributes, const char *name, int *attr)
 
static int unload_module (void)
 

Variables

static struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_LOAD_ORDER , .description = "Opus Format Attribute Module" , .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 = AST_BUILDOPT_SUM, .support_level = AST_MODULE_SUPPORT_CORE, .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_REALTIME_DRIVER }
 
static const struct ast_module_infoast_module_info = &__mod_info
 
static struct opus_attr default_opus_attr
 
static struct ast_format_interface opus_interface
 

Detailed Description

Opus format attribute interface.

Author
Lorenzo Miniero loren.nosp@m.zo@m.nosp@m.eetec.nosp@m.ho.c.nosp@m.om

Definition in file res_format_attr_opus.c.

Function Documentation

◆ __reg_module()

static void __reg_module ( void  )
static

Definition at line 417 of file res_format_attr_opus.c.

◆ __unreg_module()

static void __unreg_module ( void  )
static

Definition at line 417 of file res_format_attr_opus.c.

◆ AST_MODULE_SELF_SYM()

struct ast_module * AST_MODULE_SELF_SYM ( void  )

Definition at line 417 of file res_format_attr_opus.c.

◆ load_module()

static int load_module ( void  )
static

Definition at line 398 of file res_format_attr_opus.c.

399{
402 }
403
405}
int __ast_format_interface_register(const char *codec, const struct ast_format_interface *interface, struct ast_module *mod)
Register a format interface for use with the provided codec.
Definition: format.c:90
@ AST_MODULE_LOAD_SUCCESS
Definition: module.h:70
@ AST_MODULE_LOAD_DECLINE
Module has failed to load, may be in an inconsistent state.
Definition: module.h:78
static struct ast_format_interface opus_interface
struct ast_module * self
Definition: module.h:356

References __ast_format_interface_register(), AST_MODULE_LOAD_DECLINE, AST_MODULE_LOAD_SUCCESS, opus_interface, and ast_module_info::self.

◆ opus_clone()

static int opus_clone ( const struct ast_format src,
struct ast_format dst 
)
static

Definition at line 87 of file res_format_attr_opus.c.

88{
89 struct opus_attr *original = ast_format_get_attribute_data(src);
90 struct opus_attr *attr = ast_malloc(sizeof(*attr));
91
92 if (!attr) {
93 return -1;
94 }
95
96 *attr = original ? *original : default_opus_attr;
97 ao2_bump(attr->data);
98
101
102 return 0;
103}
#define ast_malloc(len)
A wrapper for malloc()
Definition: astmm.h:191
#define ao2_bump(obj)
Bump refcount on an AO2 object by one, returning the object.
Definition: astobj2.h:480
void ast_format_set_channel_count(struct ast_format *format, unsigned int channel_count)
Set the channel count on a format.
Definition: format.c:140
void * ast_format_get_attribute_data(const struct ast_format *format)
Get the attribute data on a format.
Definition: format.c:125
void ast_format_set_attribute_data(struct ast_format *format, void *attribute_data)
Set the attribute data on a format.
Definition: format.c:130
unsigned int ast_format_get_channel_count(const struct ast_format *format)
Get the channel count on a format.
Definition: format.c:135
static struct opus_attr default_opus_attr
Opus attribute structure.

References ao2_bump, ast_format_get_attribute_data(), ast_format_get_channel_count(), ast_format_set_attribute_data(), ast_format_set_channel_count(), ast_malloc, opus_attr::data, and default_opus_attr.

◆ opus_destroy()

static void opus_destroy ( struct ast_format format)
static

Definition at line 75 of file res_format_attr_opus.c.

76{
77 struct opus_attr *attr = ast_format_get_attribute_data(format);
78
79 if (!attr) {
80 return;
81 }
82
83 ao2_cleanup(attr->data);
84 ast_free(attr);
85}
#define ast_free(a)
Definition: astmm.h:180
#define ao2_cleanup(obj)
Definition: astobj2.h:1934

References ao2_cleanup, ast_format_get_attribute_data(), ast_free, and opus_attr::data.

◆ opus_generate_sdp_fmtp()

static void opus_generate_sdp_fmtp ( const struct ast_format format,
unsigned int  payload,
struct ast_str **  str 
)
static

Definition at line 177 of file res_format_attr_opus.c.

178{
179 struct opus_attr *attr = ast_format_get_attribute_data(format);
180 int base_fmtp_size;
181 int original_size;
182
183 if (!attr) {
184 /*
185 * (Only) cached formats do not have attribute data assigned because
186 * they were created before this attribute module was registered.
187 * Therefore, we assume the default attribute values here.
188 */
189 attr = &default_opus_attr;
190 }
191
192 original_size = ast_str_strlen(*str);
193 base_fmtp_size = ast_str_append(str, 0, "a=fmtp:%u ", payload);
194
196 ast_str_append(str, 0, "%s=%d;",
198 }
199
201 ast_str_append(str, 0, "%s=%d;",
203 }
204
205 if (CODEC_OPUS_DEFAULT_BITRATE != attr->maxbitrate || attr->maxbitrate > 0) {
206 ast_str_append(str, 0, "%s=%d;",
208 }
209
210 if (CODEC_OPUS_DEFAULT_STEREO != attr->stereo) {
211 ast_str_append(str, 0, "%s=%d;",
213 }
214
216 ast_str_append(str, 0, "%s=%d;",
218 }
219
220 if (CODEC_OPUS_DEFAULT_CBR != attr->cbr) {
221 ast_str_append(str, 0, "%s=%d;",
222 CODEC_OPUS_ATTR_CBR, attr->cbr);
223 }
224
225 if (CODEC_OPUS_DEFAULT_FEC!= attr->fec) {
226 ast_str_append(str, 0, "%s=%d;",
227 CODEC_OPUS_ATTR_FEC, attr->fec);
228 }
229
230 if (CODEC_OPUS_DEFAULT_DTX != attr->dtx) {
231 ast_str_append(str, 0, "%s=%d;",
232 CODEC_OPUS_ATTR_DTX, attr->dtx);
233 }
234
235 if (base_fmtp_size == ast_str_strlen(*str) - original_size) {
236 ast_str_truncate(*str, original_size);
237 } else {
238 ast_str_truncate(*str, -1);
239 ast_str_append(str, 0, "\r\n");
240 }
241}
const char * str
Definition: app_jack.c:147
#define CODEC_OPUS_ATTR_CBR
Decoder prefers a constant (1) vs variable (0) bitrate.
Definition: opus.h:45
#define CODEC_OPUS_ATTR_MAX_AVERAGE_BITRATE
Maximum average received bit rate (in bits per second)
Definition: opus.h:39
#define CODEC_OPUS_ATTR_MAX_PLAYBACK_RATE
Maximum sampling rate an endpoint is capable of receiving.
Definition: opus.h:29
#define CODEC_OPUS_DEFAULT_SAMPLE_RATE
Default attribute values.
Definition: opus.h:54
#define CODEC_OPUS_ATTR_DTX
Use discontinuous transmission (1) or not (0)
Definition: opus.h:49
#define CODEC_OPUS_DEFAULT_STEREO
Definition: opus.h:62
#define CODEC_OPUS_ATTR_STEREO
Decode stereo (1) vs mono (0)
Definition: opus.h:41
#define CODEC_OPUS_DEFAULT_BITRATE
Definition: opus.h:58
#define CODEC_OPUS_DEFAULT_FEC
Definition: opus.h:60
#define CODEC_OPUS_DEFAULT_DTX
Definition: opus.h:61
#define CODEC_OPUS_ATTR_SPROP_STEREO
Likeliness of sender producing stereo (1) vs mono (0)
Definition: opus.h:43
#define CODEC_OPUS_ATTR_SPROP_MAX_CAPTURE_RATE
Maximum sampling rate an endpoint is capable of sending.
Definition: opus.h:33
#define CODEC_OPUS_ATTR_FEC
Use forward error correction (1) or not (0)
Definition: opus.h:47
#define CODEC_OPUS_DEFAULT_CBR
Definition: opus.h:59
char * ast_str_truncate(struct ast_str *buf, ssize_t len)
Truncates the enclosed string to the given length.
Definition: strings.h:786
int ast_str_append(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Append to a thread local dynamic string.
Definition: strings.h:1139
size_t ast_str_strlen(const struct ast_str *buf)
Returns the current length of the string stored within buf.
Definition: strings.h:730

References ast_format_get_attribute_data(), ast_str_append(), ast_str_strlen(), ast_str_truncate(), opus_attr::cbr, CODEC_OPUS_ATTR_CBR, CODEC_OPUS_ATTR_DTX, CODEC_OPUS_ATTR_FEC, CODEC_OPUS_ATTR_MAX_AVERAGE_BITRATE, CODEC_OPUS_ATTR_MAX_PLAYBACK_RATE, CODEC_OPUS_ATTR_SPROP_MAX_CAPTURE_RATE, CODEC_OPUS_ATTR_SPROP_STEREO, CODEC_OPUS_ATTR_STEREO, CODEC_OPUS_DEFAULT_BITRATE, CODEC_OPUS_DEFAULT_CBR, CODEC_OPUS_DEFAULT_DTX, CODEC_OPUS_DEFAULT_FEC, CODEC_OPUS_DEFAULT_SAMPLE_RATE, CODEC_OPUS_DEFAULT_STEREO, default_opus_attr, opus_attr::dtx, opus_attr::fec, opus_attr::maxbitrate, opus_attr::maxplayrate, opus_attr::spropmaxcapturerate, opus_attr::spropstereo, opus_attr::stereo, and str.

◆ opus_get()

static const void * opus_get ( const struct ast_format format,
const char *  name 
)
static

Definition at line 350 of file res_format_attr_opus.c.

351{
352 struct opus_attr *attr = ast_format_get_attribute_data(format);
353 int *val = NULL;
354
355 if (!attr) {
356 return NULL;
357 }
358
359 if (!strcasecmp(name, CODEC_OPUS_ATTR_DATA)) {
360 return ao2_bump(attr->data);
361 } else if (!strcasecmp(name, CODEC_OPUS_ATTR_MAX_PLAYBACK_RATE)) {
362 val = &attr->maxplayrate;
363 } else if (!strcasecmp(name, CODEC_OPUS_ATTR_SPROP_MAX_CAPTURE_RATE)) {
364 val = &attr->spropmaxcapturerate;
365 } else if (!strcasecmp(name, CODEC_OPUS_ATTR_MAX_PTIME)) {
366 val = &attr->maxptime;
367 } else if (!strcasecmp(name, CODEC_OPUS_ATTR_PTIME)) {
368 val = &attr->ptime;
369 } else if (!strcasecmp(name, CODEC_OPUS_ATTR_MAX_AVERAGE_BITRATE)) {
370 val = &attr->maxbitrate;
371 } else if (!strcasecmp(name, CODEC_OPUS_ATTR_STEREO)) {
372 val = &attr->stereo;
373 } else if (!strcasecmp(name, CODEC_OPUS_ATTR_SPROP_STEREO)) {
374 val = &attr->spropstereo;
375 } else if (!strcasecmp(name, CODEC_OPUS_ATTR_CBR)) {
376 val = &attr->cbr;
377 } else if (!strcasecmp(name, CODEC_OPUS_ATTR_FEC)) {
378 val = &attr->fec;
379 } else if (!strcasecmp(name, CODEC_OPUS_ATTR_DTX)) {
380 val = &attr->dtx;
381 } else {
382 ast_log(LOG_WARNING, "unknown attribute type %s\n", name);
383 }
384
385 return val;
386}
#define ast_log
Definition: astobj2.c:42
static const char name[]
Definition: format_mp3.c:68
#define LOG_WARNING
#define CODEC_OPUS_ATTR_PTIME
Duration of packet (in milliseconds)
Definition: opus.h:37
#define CODEC_OPUS_ATTR_MAX_PTIME
Maximum duration of packet (in milliseconds)
Definition: opus.h:35
#define CODEC_OPUS_ATTR_DATA
Custom data object.
Definition: opus.h:51
#define NULL
Definition: resample.c:96
Definition: ast_expr2.c:325

References ao2_bump, ast_format_get_attribute_data(), ast_log, opus_attr::cbr, CODEC_OPUS_ATTR_CBR, CODEC_OPUS_ATTR_DATA, CODEC_OPUS_ATTR_DTX, CODEC_OPUS_ATTR_FEC, CODEC_OPUS_ATTR_MAX_AVERAGE_BITRATE, CODEC_OPUS_ATTR_MAX_PLAYBACK_RATE, CODEC_OPUS_ATTR_MAX_PTIME, CODEC_OPUS_ATTR_PTIME, CODEC_OPUS_ATTR_SPROP_MAX_CAPTURE_RATE, CODEC_OPUS_ATTR_SPROP_STEREO, CODEC_OPUS_ATTR_STEREO, opus_attr::data, opus_attr::dtx, opus_attr::fec, LOG_WARNING, opus_attr::maxbitrate, opus_attr::maxplayrate, opus_attr::maxptime, name, NULL, opus_attr::ptime, opus_attr::spropmaxcapturerate, opus_attr::spropstereo, and opus_attr::stereo.

◆ opus_getjoint()

static struct ast_format * opus_getjoint ( const struct ast_format format1,
const struct ast_format format2 
)
static

Definition at line 243 of file res_format_attr_opus.c.

244{
245 struct opus_attr *attr1 = ast_format_get_attribute_data(format1);
246 struct opus_attr *attr2 = ast_format_get_attribute_data(format2);
247 struct ast_format *jointformat;
248 struct opus_attr *attr_res;
249
250 if (!attr1) {
251 attr1 = &default_opus_attr;
252 }
253
254 if (!attr2) {
255 attr2 = &default_opus_attr;
256 }
257
258 jointformat = ast_format_clone(format1);
259 if (!jointformat) {
260 return NULL;
261 }
262
263 if (ast_format_get_channel_count(format1) == 2 || ast_format_get_channel_count(format2) == 2) {
264 ast_format_set_channel_count(jointformat, 2);
265 }
266 attr_res = ast_format_get_attribute_data(jointformat);
267
268 attr_res->dtx = attr1->dtx || attr2->dtx ? 1 : 0;
269
270 /* Only do FEC if both sides want it. If a peer specifically requests not
271 * to receive with FEC, it may be a waste of bandwidth. */
272 attr_res->fec = attr1->fec && attr2->fec ? 1 : 0;
273
274 attr_res->cbr = attr1->cbr || attr2->cbr ? 1 : 0;
275 attr_res->spropstereo = attr1->spropstereo || attr2->spropstereo ? 1 : 0;
276
277 /* Only do stereo if both sides want it. If a peer specifically requests not
278 * to receive stereo signals, it may be a waste of bandwidth. */
279 attr_res->stereo = attr1->stereo && attr2->stereo ? 1 : 0;
280
281 if (attr1->maxbitrate < 0) {
282 attr_res->maxbitrate = attr2->maxbitrate;
283 } else if (attr2->maxbitrate < 0) {
284 attr_res->maxbitrate = attr1->maxbitrate;
285 } else {
286 attr_res->maxbitrate = MIN(attr1->maxbitrate, attr2->maxbitrate);
287 }
288
290 attr_res->maxplayrate = MIN(attr1->maxplayrate, attr2->maxplayrate);
291
292 return jointformat;
293}
struct ast_format * ast_format_clone(const struct ast_format *format)
Clone an existing media format so it can be modified.
Definition: format.c:180
Definition of a media format.
Definition: format.c:43
#define MIN(a, b)
Definition: utils.h:231

References ast_format_clone(), ast_format_get_attribute_data(), ast_format_get_channel_count(), ast_format_set_channel_count(), opus_attr::cbr, default_opus_attr, opus_attr::dtx, opus_attr::fec, opus_attr::maxbitrate, opus_attr::maxplayrate, MIN, NULL, opus_attr::spropmaxcapturerate, opus_attr::spropstereo, and opus_attr::stereo.

◆ opus_parse_sdp_fmtp()

static struct ast_format * opus_parse_sdp_fmtp ( const struct ast_format format,
const char *  attributes 
)
static

Definition at line 139 of file res_format_attr_opus.c.

140{
141 char *attribs = ast_strdupa(attributes), *attrib;
142 struct ast_format *cloned;
143 struct opus_attr *attr;
144
145 cloned = ast_format_clone(format);
146 if (!cloned) {
147 return NULL;
148 }
149
150 attr = ast_format_get_attribute_data(cloned);
151
152 /* lower-case everything, so we are case-insensitive */
153 for (attrib = attribs; *attrib; ++attrib) {
154 *attrib = tolower(*attrib);
155 } /* based on channels/chan_sip.c:process_a_sdp_image() */
156
159 &attr->maxplayrate);
161 &attr->spropmaxcapturerate);
163 sdp_fmtp_get(attribs, CODEC_OPUS_ATTR_PTIME, &attr->ptime);
166 if (attr->stereo) {
168 }
170 sdp_fmtp_get(attribs, CODEC_OPUS_ATTR_CBR, &attr->cbr);
171 sdp_fmtp_get(attribs, CODEC_OPUS_ATTR_FEC, &attr->fec);
172 sdp_fmtp_get(attribs, CODEC_OPUS_ATTR_DTX, &attr->dtx);
173
174 return cloned;
175}
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:298
#define CODEC_OPUS_ATTR_MAX_CODED_AUDIO_BANDWIDTH
An alias for maxplaybackrate (used in older versions)
Definition: opus.h:31
static void sdp_fmtp_get(const char *attributes, const char *name, int *attr)

References ast_format_clone(), ast_format_get_attribute_data(), ast_format_set_channel_count(), ast_strdupa, opus_attr::cbr, CODEC_OPUS_ATTR_CBR, CODEC_OPUS_ATTR_DTX, CODEC_OPUS_ATTR_FEC, CODEC_OPUS_ATTR_MAX_AVERAGE_BITRATE, CODEC_OPUS_ATTR_MAX_CODED_AUDIO_BANDWIDTH, CODEC_OPUS_ATTR_MAX_PLAYBACK_RATE, CODEC_OPUS_ATTR_MAX_PTIME, CODEC_OPUS_ATTR_PTIME, CODEC_OPUS_ATTR_SPROP_MAX_CAPTURE_RATE, CODEC_OPUS_ATTR_SPROP_STEREO, CODEC_OPUS_ATTR_STEREO, opus_attr::dtx, opus_attr::fec, opus_attr::maxbitrate, opus_attr::maxplayrate, opus_attr::maxptime, NULL, opus_attr::ptime, sdp_fmtp_get(), opus_attr::spropmaxcapturerate, opus_attr::spropstereo, and opus_attr::stereo.

◆ opus_set()

static struct ast_format * opus_set ( const struct ast_format format,
const char *  name,
const char *  value 
)
static

Definition at line 295 of file res_format_attr_opus.c.

297{
298 struct ast_format *cloned;
299 struct opus_attr *attr;
300 int val;
301
302 if (!(cloned = ast_format_clone(format))) {
303 return NULL;
304 }
305
306 attr = ast_format_get_attribute_data(cloned);
307
308 if (!strcmp(name, CODEC_OPUS_ATTR_DATA)) {
309 ao2_cleanup(attr->data);
310 attr->data = ao2_bump((void*)value);
311 return cloned;
312 }
313
314 if (sscanf(value, "%30d", &val) != 1) {
315 ast_log(LOG_WARNING, "Unknown value '%s' for attribute type '%s'\n",
316 value, name);
317 ao2_ref(cloned, -1);
318 return NULL;
319 }
320
321 if (!strcasecmp(name, CODEC_OPUS_ATTR_MAX_PLAYBACK_RATE)) {
322 attr->maxplayrate = val;
323 } else if (!strcasecmp(name, CODEC_OPUS_ATTR_MAX_CODED_AUDIO_BANDWIDTH)) {
324 attr->maxplayrate = val;
325 } else if (!strcasecmp(name, CODEC_OPUS_ATTR_SPROP_MAX_CAPTURE_RATE)) {
326 attr->spropmaxcapturerate = val;
327 } else if (!strcasecmp(name, CODEC_OPUS_ATTR_MAX_PTIME)) {
328 attr->maxptime = val;
329 } else if (!strcasecmp(name, CODEC_OPUS_ATTR_PTIME)) {
330 attr->ptime = val;
331 } else if (!strcasecmp(name, CODEC_OPUS_ATTR_MAX_AVERAGE_BITRATE)) {
332 attr->maxbitrate = val;
333 } else if (!strcasecmp(name, CODEC_OPUS_ATTR_STEREO)) {
334 attr->stereo = val;
335 } else if (!strcasecmp(name, CODEC_OPUS_ATTR_SPROP_STEREO)) {
336 attr->spropstereo = val;
337 } else if (!strcasecmp(name, CODEC_OPUS_ATTR_CBR)) {
338 attr->cbr = val;
339 } else if (!strcasecmp(name, CODEC_OPUS_ATTR_FEC)) {
340 attr->fec = val;
341 } else if (!strcasecmp(name, CODEC_OPUS_ATTR_DTX)) {
342 attr->dtx = val;
343 } else {
344 ast_log(LOG_WARNING, "unknown attribute type %s\n", name);
345 }
346
347 return cloned;
348}
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
Definition: astobj2.h:459
int value
Definition: syslog.c:37

References ao2_bump, ao2_cleanup, ao2_ref, ast_format_clone(), ast_format_get_attribute_data(), ast_log, opus_attr::cbr, CODEC_OPUS_ATTR_CBR, CODEC_OPUS_ATTR_DATA, CODEC_OPUS_ATTR_DTX, CODEC_OPUS_ATTR_FEC, CODEC_OPUS_ATTR_MAX_AVERAGE_BITRATE, CODEC_OPUS_ATTR_MAX_CODED_AUDIO_BANDWIDTH, CODEC_OPUS_ATTR_MAX_PLAYBACK_RATE, CODEC_OPUS_ATTR_MAX_PTIME, CODEC_OPUS_ATTR_PTIME, CODEC_OPUS_ATTR_SPROP_MAX_CAPTURE_RATE, CODEC_OPUS_ATTR_SPROP_STEREO, CODEC_OPUS_ATTR_STEREO, opus_attr::data, opus_attr::dtx, opus_attr::fec, LOG_WARNING, opus_attr::maxbitrate, opus_attr::maxplayrate, opus_attr::maxptime, name, NULL, opus_attr::ptime, opus_attr::spropmaxcapturerate, opus_attr::spropstereo, opus_attr::stereo, and value.

◆ sdp_fmtp_get()

static void sdp_fmtp_get ( const char *  attributes,
const char *  name,
int *  attr 
)
static

Definition at line 105 of file res_format_attr_opus.c.

106{
107 const char *kvp = attributes;
108 int val;
109
110 if (ast_strlen_zero(attributes)) {
111 return;
112 }
113
114 /* This logic goes through each attribute in the fmtp line looking for the
115 * requested named attribute.
116 */
117 while (*kvp) {
118 /* Skip any preceeding blanks as some implementations separate attributes using spaces too */
119 kvp = ast_skip_blanks(kvp);
120
121 /* If we are at the requested attribute get its value and return */
122 if (!strncmp(kvp, name, strlen(name)) && kvp[strlen(name)] == '=') {
123 if (sscanf(kvp, "%*[^=]=%30d", &val) == 1) {
124 *attr = val;
125 break;
126 }
127 }
128
129 /* Move on to the next attribute if possible */
130 kvp = strchr(kvp, ';');
131 if (!kvp) {
132 break;
133 }
134
135 kvp++;
136 }
137}
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:65
char * ast_skip_blanks(const char *str)
Gets a pointer to the first non-whitespace character in a string.
Definition: strings.h:161

References ast_skip_blanks(), ast_strlen_zero(), and name.

Referenced by opus_parse_sdp_fmtp().

◆ unload_module()

static int unload_module ( void  )
static

Definition at line 407 of file res_format_attr_opus.c.

408{
409 return 0;
410}

Variable Documentation

◆ __mod_info

struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_LOAD_ORDER , .description = "Opus Format Attribute Module" , .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 = AST_BUILDOPT_SUM, .support_level = AST_MODULE_SUPPORT_CORE, .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_REALTIME_DRIVER }
static

Definition at line 417 of file res_format_attr_opus.c.

◆ ast_module_info

const struct ast_module_info* ast_module_info = &__mod_info
static

Definition at line 417 of file res_format_attr_opus.c.

◆ default_opus_attr

struct opus_attr default_opus_attr
static

Definition at line 62 of file res_format_attr_opus.c.

Referenced by opus_clone(), opus_generate_sdp_fmtp(), and opus_getjoint().

◆ opus_interface

struct ast_format_interface opus_interface
static

Definition at line 388 of file res_format_attr_opus.c.

Referenced by load_module().