38 #define SAMPLES_TO_BYTES(x) ((typeof(x)) x / ((float) 640 / 120))
39 #define BYTES_TO_SAMPLES(x) ((typeof(x)) x * ((float) 640 / 120))
49 ast_log(LOG_WARNING,
"Short read of %s data (expected %d bytes, read %zu): %s\n",
55 *whennext = s->
fr.
samples = BYTES_TO_SAMPLES(res);
64 ast_log(LOG_WARNING,
"Bad write (%d/%d): %s\n", res, f->
datalen, strerror(errno));
70 static int siren14seek(
struct ast_filestream *fs, off_t sample_offset,
int whence)
72 off_t
offset = 0, min = 0, cur, max;
74 sample_offset = SAMPLES_TO_BYTES(sample_offset);
76 if ((cur = ftello(fs->f)) < 0) {
77 ast_log(AST_LOG_WARNING,
"Unable to determine current position in siren14 filestream %p: %s\n", fs, strerror(errno));
81 if (fseeko(fs->f, 0, SEEK_END) < 0) {
82 ast_log(AST_LOG_WARNING,
"Unable to seek to end of siren14 filestream %p: %s\n", fs, strerror(errno));
86 if ((max = ftello(fs->f)) < 0) {
87 ast_log(AST_LOG_WARNING,
"Unable to determine max position in siren14 filestream %p: %s\n", fs, strerror(errno));
91 if (whence == SEEK_SET)
92 offset = sample_offset;
93 else if (whence == SEEK_CUR || whence == SEEK_FORCECUR)
94 offset = sample_offset + cur;
95 else if (whence == SEEK_END)
96 offset = max - sample_offset;
98 if (whence != SEEK_FORCECUR)
99 offset = (offset > max) ? max : offset;
102 offset = (offset < min) ? min : offset;
104 return fseeko(fs->f, offset, SEEK_SET);
112 if ((fd = fileno(fs->f)) < 0) {
113 ast_log(AST_LOG_WARNING,
"Unable to determine file descriptor for siren14 filestream %p: %s\n", fs, strerror(errno));
116 if ((cur = ftello(fs->f)) < 0) {
117 ast_log(AST_LOG_WARNING,
"Unable to determine current position in siren14 filestream %p: %s\n", fs, strerror(errno));
121 return ftruncate(fd, cur);
126 return BYTES_TO_SAMPLES(ftello(fs->f));
132 .write = siren14write,
134 .trunc = siren14trunc,
140 static int load_module(
void)
143 if (ast_format_def_register(&siren14_f))
149 static int unload_module(
void)
154 AST_MODULE_INFO(
ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER,
"ITU G.722.1 Annex C (Siren14, licensed from Polycom)",
155 .support_level = AST_MODULE_SUPPORT_CORE,
157 .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.