#include "asterisk/file.h"
#include "asterisk/frame.h"


Go to the source code of this file.
Data Structures | |
| struct | ast_filestream |
| This structure is allocated by file.c in one chunk, together with buf_size and desc_size bytes of memory to be used for private purposes (e.g. buffers etc.). More... | |
| struct | ast_format_def |
| Each supported file format is described by the following structure. More... | |
Defines | |
| #define | ast_format_def_register(f) __ast_format_def_register(f, ast_module_info->self) |
Functions | |
| int | __ast_format_def_register (const struct ast_format_def *f, struct ast_module *mod) |
| Register a new file format capability. Adds a format to Asterisk's format abilities. | |
| int | ast_format_def_unregister (const char *name) |
| Unregisters a file format. | |
Definition in file mod_format.h.
| #define ast_format_def_register | ( | f | ) | __ast_format_def_register(f, ast_module_info->self) |
| int __ast_format_def_register | ( | const struct ast_format_def * | f, | |
| struct ast_module * | mod | |||
| ) |
Register a new file format capability. Adds a format to Asterisk's format abilities.
| 0 | on success | |
| -1 | on failure |
Definition at line 65 of file file.c.
References ast_calloc, ast_log(), AST_RWLIST_INSERT_HEAD, AST_RWLIST_TRAVERSE, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, ast_verb, ast_format_def::buf_size, ast_format_def::exts, ast_format_def::list, LOG_WARNING, ast_format_def::module, and ast_format_def::name.
00066 { 00067 struct ast_format_def *tmp; 00068 00069 AST_RWLIST_WRLOCK(&formats); 00070 AST_RWLIST_TRAVERSE(&formats, tmp, list) { 00071 if (!strcasecmp(f->name, tmp->name)) { 00072 AST_RWLIST_UNLOCK(&formats); 00073 ast_log(LOG_WARNING, "Tried to register '%s' format, already registered\n", f->name); 00074 return -1; 00075 } 00076 } 00077 if (!(tmp = ast_calloc(1, sizeof(*tmp)))) { 00078 AST_RWLIST_UNLOCK(&formats); 00079 return -1; 00080 } 00081 *tmp = *f; 00082 tmp->module = mod; 00083 if (tmp->buf_size) { 00084 /* 00085 * Align buf_size properly, rounding up to the machine-specific 00086 * alignment for pointers. 00087 */ 00088 struct _test_align { void *a, *b; } p; 00089 int align = (char *)&p.b - (char *)&p.a; 00090 tmp->buf_size = ((f->buf_size + align - 1) / align) * align; 00091 } 00092 00093 memset(&tmp->list, 0, sizeof(tmp->list)); 00094 00095 AST_RWLIST_INSERT_HEAD(&formats, tmp, list); 00096 AST_RWLIST_UNLOCK(&formats); 00097 ast_verb(2, "Registered file format %s, extension(s) %s\n", f->name, f->exts); 00098 00099 return 0; 00100 }
| int ast_format_def_unregister | ( | const char * | name | ) |
Unregisters a file format.
| name | the name of the format you wish to unregister Unregisters a format based on the name of the format. |
| 0 | on success | |
| -1 | on failure to unregister |
Definition at line 102 of file file.c.
References ast_free, ast_log(), AST_RWLIST_REMOVE_CURRENT, AST_RWLIST_TRAVERSE_SAFE_BEGIN, AST_RWLIST_TRAVERSE_SAFE_END, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, ast_verb, ast_format_def::list, LOG_WARNING, and ast_format_def::name.
Referenced by unload_module().
00103 { 00104 struct ast_format_def *tmp; 00105 int res = -1; 00106 00107 AST_RWLIST_WRLOCK(&formats); 00108 AST_RWLIST_TRAVERSE_SAFE_BEGIN(&formats, tmp, list) { 00109 if (!strcasecmp(name, tmp->name)) { 00110 AST_RWLIST_REMOVE_CURRENT(list); 00111 ast_free(tmp); 00112 res = 0; 00113 } 00114 } 00115 AST_RWLIST_TRAVERSE_SAFE_END; 00116 AST_RWLIST_UNLOCK(&formats); 00117 00118 if (!res) 00119 ast_verb(2, "Unregistered format %s\n", name); 00120 else 00121 ast_log(LOG_WARNING, "Tried to unregister format %s, already unregistered\n", name); 00122 00123 return res; 00124 }
1.5.6