43 #define ILBC_BUF_SIZE 50
44 #define ILBC_SAMPLES 240
54 ast_log(LOG_WARNING,
"Short read of %s data (expected %d bytes, read %zu): %s\n",
68 ast_log(LOG_WARNING,
"Invalid data length, %d, should be multiple of 50\n", f->
datalen);
72 ast_log(LOG_WARNING,
"Bad write (%d/50): %s\n", res, strerror(errno));
78 static int ilbc_seek(
struct ast_filestream *fs, off_t sample_offset,
int whence)
81 off_t min,cur,max,
offset=0;
84 fseeko(fs->f, 0, SEEK_END);
87 bytes = ILBC_BUF_SIZE * (sample_offset / ILBC_SAMPLES);
88 if (whence == SEEK_SET)
90 else if (whence == SEEK_CUR || whence == SEEK_FORCECUR)
92 else if (whence == SEEK_END)
94 if (whence != SEEK_FORCECUR) {
95 offset = (offset > max)?max:offset;
98 offset = (offset < min)?min:offset;
99 if (fseeko(fs->f, offset, SEEK_SET) < 0)
109 if ((fd = fileno(fs->f)) < 0) {
110 ast_log(AST_LOG_WARNING,
"Unable to determine file descriptor for iLBC filestream %p: %s\n", fs, strerror(errno));
113 if ((cur = ftello(fs->f)) < 0) {
114 ast_log(AST_LOG_WARNING,
"Unable to determine current position in iLBC filestream %p: %s\n", fs, strerror(errno));
118 return ftruncate(fd, cur);
123 off_t offset = ftello(fs->f);
124 return (offset/ILBC_BUF_SIZE)*ILBC_SAMPLES;
138 static int load_module(
void)
141 if (ast_format_def_register(&ilbc_f))
146 static int unload_module(
void)
152 .support_level = AST_MODULE_SUPPORT_CORE,
154 .unload = unload_module,
Asterisk main include file. File version handling, generic pbx functions.
struct ast_frame_subclass subclass
#define AST_FRIENDLY_OFFSET
Offset into a frame's data buffer.
Asterisk architecture endianess compatibility definitions.
struct ast_frame fr
frame produced by read, typically
#define AST_FRAME_SET_BUFFER(fr, _base, _ofs, _datalen)
union ast_frame::@224 data
Module has failed to load, may be in an inconsistent state.
This structure is allocated by file.c in one chunk, together with buf_size and desc_size bytes of mem...
Data structure associated with a single frame of data.
struct ast_format * format
#define ASTERISK_GPL_KEY
The text the key() function should return.
Asterisk module definitions.