47 #define GSM_FRAME_SIZE 33 48 #define MSGSM_FRAME_SIZE 65 49 #define MSGSM_DATA_OFFSET 60 50 #define GSM_SAMPLES 160 51 #define MSGSM_SAMPLES (2*GSM_SAMPLES) 55 {0x48,0x17,0xD6,0x84,0x02,0x80,0x24,0x49,0x92,0x24,0x89,0x02,0x80,0x24,0x49
56 ,0x92,0x24,0x89,0x02,0x80,0x24,0x49,0x92,0x24,0x89,0x02,0x80,0x24,0x49,0x92
57 ,0x24,0x09,0x82,0x74,0x61,0x4D,0x28,0x00,0x48,0x92,0x24,0x49,0x92,0x28,0x00
58 ,0x48,0x92,0x24,0x49,0x92,0x28,0x00,0x48,0x92,0x24,0x49,0x92,0x28,0x00,0x48
59 ,0x92,0x24,0x49,0x92,0x00};
68 #if __BYTE_ORDER == __LITTLE_ENDIAN 74 #if __BYTE_ORDER == __BIG_ENDIAN 76 (((((b) ) & 0xFF) << 24) | \ 77 ((( (b) >> 8) & 0xFF) << 16) | \ 78 ((( (b) >> 16) & 0xFF) << 8) | \ 79 ((( (b) >> 24) & 0xFF) )) 81 (((((b) ) & 0xFF) << 8) | \ 82 ((( (b) >> 8) & 0xFF) )) 83 #define ltohl(b) htoll(b) 84 #define ltohs(b) htols(b) 86 #error "Endianess not defined" 93 int type, size, formtype;
98 if (fread(&type, 1, 4, f) != 4) {
102 if (fread(&size, 1, 4, f) != 4) {
106 #if __BYTE_ORDER == __BIG_ENDIAN 109 if (fread(&formtype, 1, 4, f) != 4) {
113 if (memcmp(&type,
"RIFF", 4)) {
117 if (memcmp(&formtype,
"WAVE", 4)) {
121 if (fread(&fmt, 1, 4, f) != 4) {
125 if (memcmp(&fmt,
"fmt ", 4)) {
129 if (fread(&hsize, 1, 4, f) != 4) {
133 if (ltohl(hsize) != 20) {
137 if (fread(&format, 1, 2, f) != 2) {
141 if (ltohs(format) != 49) {
145 if (fread(&chans, 1, 2, f) != 2) {
149 if (ltohs(chans) != 1) {
153 if (fread(&freq, 1, 4, f) != 4) {
162 if (fread(&freq, 1, 4, f) != 4) {
167 if (fread(&freq, 1, 4, f) != 4) {
172 if (fread(&freq, 1, 4, f) != 4) {
177 if (fread(&fact, 1, 4, f) != 4) {
181 if (memcmp(&fact,
"fact", 4)) {
186 if (fread(&fact, 1, 4, f) != 4) {
190 if (fread(&fact, 1, 4, f) != 4) {
195 if (fread(&data, 1, 4, f) != 4) {
199 if (memcmp(&data,
"data", 4)) {
204 if (fread(&data, 1, 4, f) != 4) {
214 int datalen, filelen, samples;
217 fseek(f, 0, SEEK_END);
222 datalen = htoll(bytes);
223 filelen = htoll(MSGSM_DATA_OFFSET - 8 + bytes);
228 if (fseek(f, 4, SEEK_SET)) {
232 if (fwrite(&filelen, 1, 4, f) != 4) {
236 if (fseek(f, 48, SEEK_SET)) {
240 if (fwrite(&samples, 1, 4, f) != 4) {
244 if (fseek(f, 56, SEEK_SET)) {
248 if (fwrite(&datalen, 1, 4, f) != 4) {
252 if (fseeko(f, cur, SEEK_SET)) {
262 unsigned int sample_rate = htoll(8000);
264 unsigned int byte_sample_rate = htoll(1625);
266 unsigned int fmtsize = htoll(20);
268 unsigned short fmt = htols(49);
270 unsigned short chans = htols(1);
274 unsigned short bits_per_sample = htols(2);
278 unsigned int factsize = htoll(4);
280 unsigned int num_samples = htoll(0);
282 unsigned int size = htoll(0);
286 if (fwrite(
"RIFF", 1, 4, f) != 4) {
291 if (fwrite(&size, 1, 4, f) != 4) {
296 if (fwrite(
"WAVE", 1, 4, f) != 4) {
301 if (fwrite(
"fmt ", 1, 4, f) != 4) {
306 if (fwrite(&fmtsize, 1, 4, f) != 4) {
311 if (fwrite(&fmt, 1, 2, f) != 2) {
316 if (fwrite(&chans, 1, 2, f) != 2) {
321 if (fwrite(&sample_rate, 1, 4, f) != 4) {
326 if (fwrite(&byte_sample_rate, 1, 4, f) != 4) {
331 if (fwrite(&block_align, 1, 4, f) != 4) {
336 if (fwrite(&bits_per_sample, 1, 2, f) != 2) {
341 if (fwrite(&extra_format, 1, 2, f) != 2) {
346 if (fwrite(
"fact", 1, 4, f) != 4) {
351 if (fwrite(&factsize, 1, 4, f) != 4) {
356 if (fwrite(&num_samples, 1, 4, f) != 4) {
361 if (fwrite(
"data", 1, 4, f) != 4) {
366 if (fwrite(&size, 1, 4, f) != 4) {
399 if (s->
mode == O_RDONLY) {
425 if (res && res != 1) {
455 for (len = 0; len < f->
datalen ; len += size) {
460 conv66((
unsigned char *) s->
buf, msdata);
483 if ((cur = ftello(fs->
f)) < 0) {
488 if (fseeko(fs->
f, 0, SEEK_END) < 0) {
494 if ((max = ftello(fs->
f)) < 0) {
501 if (whence == SEEK_SET)
502 offset = distance +
min;
504 offset = distance + cur;
505 else if (whence == SEEK_END)
506 offset = max - distance;
513 }
else if (offset > max) {
515 fseek(fs->
f, 0, SEEK_END);
523 return fseeko(fs->
f, offset, SEEK_SET);
531 if ((fd = fileno(fs->
f)) < 0) {
535 if ((cur = ftello(fs->
f)) < 0) {
540 if (ftruncate(fd, cur)) {
549 offset = ftello(fs->
f);
Asterisk main include file. File version handling, generic pbx functions.
#define DEFAULT_SAMPLE_RATE
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
static void conv65(wav_byte *c, gsm_byte *d)
#define AST_FRAME_SET_BUFFER(fr, _base, _ofs, _datalen)
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
static void conv66(gsm_byte *d, wav_byte *c)
Module has failed to load, may be in an inconsistent state.
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",)
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.
union ast_frame::@263 data
struct ast_format * format
#define ASTERISK_GPL_KEY
The text the key() function should return.
Asterisk module definitions.
static snd_pcm_format_t format
static struct chans chans