Asterisk - The Open Source Telephony Project  18.5.0
res_format_attr_g729.c
Go to the documentation of this file.
1 /*
2  * Asterisk -- An open source telephony toolkit.
3  *
4  * Copyright (C) 2016, Digium, Inc.
5  *
6  * Jason Parker <[email protected]>
7  *
8  * See http://www.asterisk.org for more information about
9  * the Asterisk project. Please do not directly contact
10  * any of the maintainers of this project for assistance;
11  * the project provides a web site, mailing lists and IRC
12  * channels for your use.
13  *
14  * This program is free software, distributed under the terms of
15  * the GNU General Public License Version 2. See the LICENSE file
16  * at the top of the source tree.
17  */
18 
19 /*** MODULEINFO
20  <support_level>core</support_level>
21  ***/
22 
23 #include "asterisk.h"
24 
25 #include "asterisk/module.h"
26 #include "asterisk/format.h"
27 
28 /* Destroy is a required callback and must exist */
29 static void g729_destroy(struct ast_format *format)
30 {
31 }
32 
33 /* Clone is a required callback and must exist */
34 static int g729_clone(const struct ast_format *src, struct ast_format *dst)
35 {
36  return 0;
37 }
38 
39 static void g729_generate_sdp_fmtp(const struct ast_format *format, unsigned int payload, struct ast_str **str)
40 {
41  /*
42  * According to the rfc the joint annexb format parameter should be set to 'yes'
43  * or 'no' based on the answerer (rfc7261 - 3.3). However, Asterisk being a B2BUA
44  * makes things tricky. So for now Asterisk will set annexb=no.
45  */
46  ast_str_append(str, 0, "a=fmtp:%u annexb=no\r\n", payload);
47 }
48 
51  .format_clone = g729_clone,
52  .format_generate_sdp_fmtp = g729_generate_sdp_fmtp,
53 };
54 
55 static int load_module(void)
56 {
57  if (ast_format_interface_register("g729", &g729_interface)) {
59  }
60 
62 }
63 
64 static int unload_module(void)
65 {
66  return 0;
67 }
68 
69 AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "G.729 Format Attribute Module",
70  .support_level = AST_MODULE_SUPPORT_CORE,
71  .load = load_module,
72  .unload = unload_module,
73  .load_pri = AST_MODPRI_CHANNEL_DEPEND,
74 );
Asterisk main include file. File version handling, generic pbx functions.
Optional format interface to extend format operations.
Definition: format.h:44
static int unload_module(void)
static void g729_generate_sdp_fmtp(const struct ast_format *format, unsigned int payload, struct ast_str **str)
Definition of a media format.
Definition: format.c:43
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
const char * str
Definition: app_jack.c:147
static int g729_clone(const struct ast_format *src, struct ast_format *dst)
Media Format API.
void(*const format_destroy)(struct ast_format *format)
Callback for when the format is destroyed, used to release attribute resources.
Definition: format.h:50
The descriptor of a dynamic string XXX storage will be optimized later if needed We use the ts field ...
Definition: strings.h:584
#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
AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS|AST_MODFLAG_LOAD_ORDER, "HTTP Phone Provisioning",.support_level=AST_MODULE_SUPPORT_EXTENDED,.load=load_module,.unload=unload_module,.reload=reload,.load_pri=AST_MODPRI_CHANNEL_DEPEND,.requires="http",)
static void g729_destroy(struct ast_format *format)
static struct ast_format_interface g729_interface
static int load_module(void)
#define ASTERISK_GPL_KEY
The text the key() function should return.
Definition: module.h:46
Asterisk module definitions.
static snd_pcm_format_t format
Definition: chan_alsa.c:102