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

Siren7 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 dependency graph for res_format_attr_siren7.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 load_module (void)
 
static int siren7_clone (const struct ast_format *src, struct ast_format *dst)
 
static void siren7_destroy (struct ast_format *format)
 
static void siren7_generate_sdp_fmtp (const struct ast_format *format, unsigned int payload, struct ast_str **str)
 
static struct ast_formatsiren7_parse_sdp_fmtp (const struct ast_format *format, const char *attributes)
 
static int unload_module (void)
 

Variables

static struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Siren7 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 = "30ef0c93b36035ec78c9cfd712d36d9b" , .support_level = AST_MODULE_SUPPORT_CORE, .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_CHANNEL_DEPEND, }
 
static const struct ast_module_infoast_module_info = &__mod_info
 
static struct ast_format_interface siren7_interface
 

Detailed Description

Siren7 format attribute interface.

Author
Joshua Colp jcolp.nosp@m.@dig.nosp@m.ium.c.nosp@m.om

Definition in file res_format_attr_siren7.c.

Function Documentation

◆ __reg_module()

static void __reg_module ( void  )
static

Definition at line 103 of file res_format_attr_siren7.c.

◆ __unreg_module()

static void __unreg_module ( void  )
static

Definition at line 103 of file res_format_attr_siren7.c.

◆ AST_MODULE_SELF_SYM()

struct ast_module* AST_MODULE_SELF_SYM ( void  )

Definition at line 103 of file res_format_attr_siren7.c.

◆ load_module()

static int load_module ( void  )
static

Definition at line 84 of file res_format_attr_siren7.c.

References ast_format_interface_register, AST_MODULE_LOAD_DECLINE, and AST_MODULE_LOAD_SUCCESS.

Referenced by unload_module().

85 {
88  }
89 
91 }
#define ast_format_interface_register(codec, interface)
Register a format interface for use with the provided codec.
Definition: format.h:273
Module has failed to load, may be in an inconsistent state.
Definition: module.h:78
static struct ast_format_interface siren7_interface

◆ siren7_clone()

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

Definition at line 46 of file res_format_attr_siren7.c.

47 {
48  return 0;
49 }

◆ siren7_destroy()

static void siren7_destroy ( struct ast_format format)
static

Definition at line 41 of file res_format_attr_siren7.c.

42 {
43 }

◆ siren7_generate_sdp_fmtp()

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

Definition at line 72 of file res_format_attr_siren7.c.

References ast_str_append().

73 {
74  ast_str_append(str, 0, "a=fmtp:%u bitrate=32000\r\n", payload);
75 }
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:1091

◆ siren7_parse_sdp_fmtp()

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

Definition at line 51 of file res_format_attr_siren7.c.

References ao2_bump, ast_log, ast_strdupa, LOG_WARNING, and NULL.

52 {
53  char *attribs = ast_strdupa(attributes), *attrib;
54  unsigned int val;
55 
56  /* lower-case everything, so we are case-insensitive */
57  for (attrib = attribs; *attrib; ++attrib) {
58  *attrib = tolower(*attrib);
59  } /* based on channels/chan_sip.c:process_a_sdp_image() */
60 
61  if (sscanf(attribs, "bitrate=%30u", &val) == 1) {
62  if (val != 32000) {
63  ast_log(LOG_WARNING, "Got Siren7 offer at %u bps, but only 32000 bps supported; ignoring.\n", val);
64  return NULL;
65  }
66  }
67 
68  /* We aren't modifying the format and once passed back it won't be touched, so use what we were given */
69  return ao2_bump((struct ast_format *)format);
70 }
Definition: ast_expr2.c:325
#define LOG_WARNING
Definition: logger.h:274
Definition of a media format.
Definition: format.c:43
#define NULL
Definition: resample.c:96
#define ao2_bump(obj)
Definition: astobj2.h:491
#define ast_log
Definition: astobj2.c:42
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:300

◆ unload_module()

static int unload_module ( void  )
static

Variable Documentation

◆ __mod_info

struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Siren7 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 = "30ef0c93b36035ec78c9cfd712d36d9b" , .support_level = AST_MODULE_SUPPORT_CORE, .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_CHANNEL_DEPEND, }
static

Definition at line 103 of file res_format_attr_siren7.c.

◆ ast_module_info

const struct ast_module_info* ast_module_info = &__mod_info
static

Definition at line 103 of file res_format_attr_siren7.c.

◆ siren7_interface

struct ast_format_interface siren7_interface
static

Definition at line 77 of file res_format_attr_siren7.c.