Wed Jan 8 2020 09:49:47

Asterisk developer's documentation


format_wav_gsm.c
Go to the documentation of this file.
1 /*
2  * Asterisk -- An open source telephony toolkit.
3  *
4  * Copyright (C) 1999 - 2005, Digium, Inc.
5  *
6  * Mark Spencer <markster@digium.com>
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 /*! \file
20  *
21  * \brief Save GSM in the proprietary Microsoft format.
22  *
23  * Microsoft WAV format (Proprietary GSM)
24  * \arg File name extension: WAV,wav49 (Upper case WAV, lower case is another format)
25  * This format can be played on Windows systems, used for
26  * e-mail attachments mainly.
27  * \ingroup formats
28  */
29 
30 /*** MODULEINFO
31  <support_level>core</support_level>
32  ***/
33 
34 #include "asterisk.h"
35 
36 ASTERISK_FILE_VERSION(__FILE__, "$Revision: 364578 $")
37 
38 #include "asterisk/mod_format.h"
39 #include "asterisk/module.h"
40 #include "asterisk/endian.h"
41 
42 #include "msgsm.h"
43 
44 /* Some Ideas for this code came from makewave.c by Jeffrey Chilton */
45 
46 /* Portions of the conversion code are by guido@sienanet.it */
47 
48 #define GSM_FRAME_SIZE 33
49 #define MSGSM_FRAME_SIZE 65
50 #define MSGSM_DATA_OFFSET 60 /* offset of data bytes */
51 #define GSM_SAMPLES 160 /* samples in a GSM block */
52 #define MSGSM_SAMPLES (2*GSM_SAMPLES) /* samples in an MSGSM block */
53 
54 /* begin binary data: */
55 static char msgsm_silence[] = /* 65 */
56 {0x48,0x17,0xD6,0x84,0x02,0x80,0x24,0x49,0x92,0x24,0x89,0x02,0x80,0x24,0x49
57 ,0x92,0x24,0x89,0x02,0x80,0x24,0x49,0x92,0x24,0x89,0x02,0x80,0x24,0x49,0x92
58 ,0x24,0x09,0x82,0x74,0x61,0x4D,0x28,0x00,0x48,0x92,0x24,0x49,0x92,0x28,0x00
59 ,0x48,0x92,0x24,0x49,0x92,0x28,0x00,0x48,0x92,0x24,0x49,0x92,0x28,0x00,0x48
60 ,0x92,0x24,0x49,0x92,0x00};
61 /* end binary data. size = 65 bytes */
62 
63 struct wavg_desc {
64  /* Believe it or not, we must decode/recode to account for the
65  weird MS format */
66  int secondhalf; /* Are we on the second half */
67 };
68 
69 #if __BYTE_ORDER == __LITTLE_ENDIAN
70 #define htoll(b) (b)
71 #define htols(b) (b)
72 #define ltohl(b) (b)
73 #define ltohs(b) (b)
74 #else
75 #if __BYTE_ORDER == __BIG_ENDIAN
76 #define htoll(b) \
77  (((((b) ) & 0xFF) << 24) | \
78  ((((b) >> 8) & 0xFF) << 16) | \
79  ((((b) >> 16) & 0xFF) << 8) | \
80  ((((b) >> 24) & 0xFF) ))
81 #define htols(b) \
82  (((((b) ) & 0xFF) << 8) | \
83  ((((b) >> 8) & 0xFF) ))
84 #define ltohl(b) htoll(b)
85 #define ltohs(b) htols(b)
86 #else
87 #error "Endianess not defined"
88 #endif
89 #endif
90 
91 
92 static int check_header(FILE *f)
93 {
94  int type, size, formtype;
95  int fmt, hsize, fact;
96  short format, chans;
97  int freq;
98  int data;
99  if (fread(&type, 1, 4, f) != 4) {
100  ast_log(LOG_WARNING, "Read failed (type)\n");
101  return -1;
102  }
103  if (fread(&size, 1, 4, f) != 4) {
104  ast_log(LOG_WARNING, "Read failed (size)\n");
105  return -1;
106  }
107  size = ltohl(size);
108  if (fread(&formtype, 1, 4, f) != 4) {
109  ast_log(LOG_WARNING, "Read failed (formtype)\n");
110  return -1;
111  }
112  if (memcmp(&type, "RIFF", 4)) {
113  ast_log(LOG_WARNING, "Does not begin with RIFF\n");
114  return -1;
115  }
116  if (memcmp(&formtype, "WAVE", 4)) {
117  ast_log(LOG_WARNING, "Does not contain WAVE\n");
118  return -1;
119  }
120  if (fread(&fmt, 1, 4, f) != 4) {
121  ast_log(LOG_WARNING, "Read failed (fmt)\n");
122  return -1;
123  }
124  if (memcmp(&fmt, "fmt ", 4)) {
125  ast_log(LOG_WARNING, "Does not say fmt\n");
126  return -1;
127  }
128  if (fread(&hsize, 1, 4, f) != 4) {
129  ast_log(LOG_WARNING, "Read failed (formtype)\n");
130  return -1;
131  }
132  if (ltohl(hsize) != 20) {
133  ast_log(LOG_WARNING, "Unexpected header size %d\n", ltohl(hsize));
134  return -1;
135  }
136  if (fread(&format, 1, 2, f) != 2) {
137  ast_log(LOG_WARNING, "Read failed (format)\n");
138  return -1;
139  }
140  if (ltohs(format) != 49) {
141  ast_log(LOG_WARNING, "Not a GSM file %d\n", ltohs(format));
142  return -1;
143  }
144  if (fread(&chans, 1, 2, f) != 2) {
145  ast_log(LOG_WARNING, "Read failed (format)\n");
146  return -1;
147  }
148  if (ltohs(chans) != 1) {
149  ast_log(LOG_WARNING, "Not in mono %d\n", ltohs(chans));
150  return -1;
151  }
152  if (fread(&freq, 1, 4, f) != 4) {
153  ast_log(LOG_WARNING, "Read failed (freq)\n");
154  return -1;
155  }
156  if (ltohl(freq) != DEFAULT_SAMPLE_RATE) {
157  ast_log(LOG_WARNING, "Unexpected frequency %d\n", ltohl(freq));
158  return -1;
159  }
160  /* Ignore the byte frequency */
161  if (fread(&freq, 1, 4, f) != 4) {
162  ast_log(LOG_WARNING, "Read failed (X_1)\n");
163  return -1;
164  }
165  /* Ignore the two weird fields */
166  if (fread(&freq, 1, 4, f) != 4) {
167  ast_log(LOG_WARNING, "Read failed (X_2/X_3)\n");
168  return -1;
169  }
170  /* Ignore the byte frequency */
171  if (fread(&freq, 1, 4, f) != 4) {
172  ast_log(LOG_WARNING, "Read failed (Y_1)\n");
173  return -1;
174  }
175  /* Check for the word fact */
176  if (fread(&fact, 1, 4, f) != 4) {
177  ast_log(LOG_WARNING, "Read failed (fact)\n");
178  return -1;
179  }
180  if (memcmp(&fact, "fact", 4)) {
181  ast_log(LOG_WARNING, "Does not say fact\n");
182  return -1;
183  }
184  /* Ignore the "fact value" */
185  if (fread(&fact, 1, 4, f) != 4) {
186  ast_log(LOG_WARNING, "Read failed (fact header)\n");
187  return -1;
188  }
189  if (fread(&fact, 1, 4, f) != 4) {
190  ast_log(LOG_WARNING, "Read failed (fact value)\n");
191  return -1;
192  }
193  /* Check for the word data */
194  if (fread(&data, 1, 4, f) != 4) {
195  ast_log(LOG_WARNING, "Read failed (data)\n");
196  return -1;
197  }
198  if (memcmp(&data, "data", 4)) {
199  ast_log(LOG_WARNING, "Does not say data\n");
200  return -1;
201  }
202  /* Ignore the data length */
203  if (fread(&data, 1, 4, f) != 4) {
204  ast_log(LOG_WARNING, "Read failed (data)\n");
205  return -1;
206  }
207  return 0;
208 }
209 
210 static int update_header(FILE *f)
211 {
212  off_t cur,end,bytes;
213  int datalen, filelen, samples;
214 
215  cur = ftello(f);
216  fseek(f, 0, SEEK_END);
217  end = ftello(f);
218  /* in a gsm WAV, data starts 60 bytes in */
219  bytes = end - MSGSM_DATA_OFFSET;
220  samples = htoll(bytes / MSGSM_FRAME_SIZE * MSGSM_SAMPLES);
221  datalen = htoll(bytes);
222  filelen = htoll(MSGSM_DATA_OFFSET - 8 + bytes);
223  if (cur < 0) {
224  ast_log(LOG_WARNING, "Unable to find our position\n");
225  return -1;
226  }
227  if (fseek(f, 4, SEEK_SET)) {
228  ast_log(LOG_WARNING, "Unable to set our position\n");
229  return -1;
230  }
231  if (fwrite(&filelen, 1, 4, f) != 4) {
232  ast_log(LOG_WARNING, "Unable to write file size\n");
233  return -1;
234  }
235  if (fseek(f, 48, SEEK_SET)) {
236  ast_log(LOG_WARNING, "Unable to set our position\n");
237  return -1;
238  }
239  if (fwrite(&samples, 1, 4, f) != 4) {
240  ast_log(LOG_WARNING, "Unable to write samples\n");
241  return -1;
242  }
243  if (fseek(f, 56, SEEK_SET)) {
244  ast_log(LOG_WARNING, "Unable to set our position\n");
245  return -1;
246  }
247  if (fwrite(&datalen, 1, 4, f) != 4) {
248  ast_log(LOG_WARNING, "Unable to write datalen\n");
249  return -1;
250  }
251  if (fseeko(f, cur, SEEK_SET)) {
252  ast_log(LOG_WARNING, "Unable to return to position\n");
253  return -1;
254  }
255  return 0;
256 }
257 
258 static int write_header(FILE *f)
259 {
260  /* Samples per second (always 8000 for this format). */
261  unsigned int sample_rate = htoll(8000);
262  /* Bytes per second (always 1625 for this format). */
263  unsigned int byte_sample_rate = htoll(1625);
264  /* This is the size of the "fmt " subchunk */
265  unsigned int fmtsize = htoll(20);
266  /* WAV #49 */
267  unsigned short fmt = htols(49);
268  /* Mono = 1 channel */
269  unsigned short chans = htols(1);
270  /* Each block of data is exactly 65 bytes in size. */
271  unsigned int block_align = htoll(MSGSM_FRAME_SIZE);
272  /* Not actually 2, but rounded up to the nearest bit */
273  unsigned short bits_per_sample = htols(2);
274  /* Needed for compressed formats */
275  unsigned short extra_format = htols(MSGSM_SAMPLES);
276  /* This is the size of the "fact" subchunk */
277  unsigned int factsize = htoll(4);
278  /* Number of samples in the data chunk */
279  unsigned int num_samples = htoll(0);
280  /* Number of bytes in the data chunk */
281  unsigned int size = htoll(0);
282  /* Write a GSM header, ignoring sizes which will be filled in later */
283 
284  /* 0: Chunk ID */
285  if (fwrite("RIFF", 1, 4, f) != 4) {
286  ast_log(LOG_WARNING, "Unable to write header\n");
287  return -1;
288  }
289  /* 4: Chunk Size */
290  if (fwrite(&size, 1, 4, f) != 4) {
291  ast_log(LOG_WARNING, "Unable to write header\n");
292  return -1;
293  }
294  /* 8: Chunk Format */
295  if (fwrite("WAVE", 1, 4, f) != 4) {
296  ast_log(LOG_WARNING, "Unable to write header\n");
297  return -1;
298  }
299  /* 12: Subchunk 1: ID */
300  if (fwrite("fmt ", 1, 4, f) != 4) {
301  ast_log(LOG_WARNING, "Unable to write header\n");
302  return -1;
303  }
304  /* 16: Subchunk 1: Size (minus 8) */
305  if (fwrite(&fmtsize, 1, 4, f) != 4) {
306  ast_log(LOG_WARNING, "Unable to write header\n");
307  return -1;
308  }
309  /* 20: Subchunk 1: Audio format (49) */
310  if (fwrite(&fmt, 1, 2, f) != 2) {
311  ast_log(LOG_WARNING, "Unable to write header\n");
312  return -1;
313  }
314  /* 22: Subchunk 1: Number of channels */
315  if (fwrite(&chans, 1, 2, f) != 2) {
316  ast_log(LOG_WARNING, "Unable to write header\n");
317  return -1;
318  }
319  /* 24: Subchunk 1: Sample rate */
320  if (fwrite(&sample_rate, 1, 4, f) != 4) {
321  ast_log(LOG_WARNING, "Unable to write header\n");
322  return -1;
323  }
324  /* 28: Subchunk 1: Byte rate */
325  if (fwrite(&byte_sample_rate, 1, 4, f) != 4) {
326  ast_log(LOG_WARNING, "Unable to write header\n");
327  return -1;
328  }
329  /* 32: Subchunk 1: Block align */
330  if (fwrite(&block_align, 1, 4, f) != 4) {
331  ast_log(LOG_WARNING, "Unable to write header\n");
332  return -1;
333  }
334  /* 36: Subchunk 1: Bits per sample */
335  if (fwrite(&bits_per_sample, 1, 2, f) != 2) {
336  ast_log(LOG_WARNING, "Unable to write header\n");
337  return -1;
338  }
339  /* 38: Subchunk 1: Extra format bytes */
340  if (fwrite(&extra_format, 1, 2, f) != 2) {
341  ast_log(LOG_WARNING, "Unable to write header\n");
342  return -1;
343  }
344  /* 40: Subchunk 2: ID */
345  if (fwrite("fact", 1, 4, f) != 4) {
346  ast_log(LOG_WARNING, "Unable to write header\n");
347  return -1;
348  }
349  /* 44: Subchunk 2: Size (minus 8) */
350  if (fwrite(&factsize, 1, 4, f) != 4) {
351  ast_log(LOG_WARNING, "Unable to write header\n");
352  return -1;
353  }
354  /* 48: Subchunk 2: Number of samples */
355  if (fwrite(&num_samples, 1, 4, f) != 4) {
356  ast_log(LOG_WARNING, "Unable to write header\n");
357  return -1;
358  }
359  /* 52: Subchunk 3: ID */
360  if (fwrite("data", 1, 4, f) != 4) {
361  ast_log(LOG_WARNING, "Unable to write header\n");
362  return -1;
363  }
364  /* 56: Subchunk 3: Size */
365  if (fwrite(&size, 1, 4, f) != 4) {
366  ast_log(LOG_WARNING, "Unable to write header\n");
367  return -1;
368  }
369  return 0;
370 }
371 
372 static int wav_open(struct ast_filestream *s)
373 {
374  /* We don't have any header to read or anything really, but
375  if we did, it would go here. We also might want to check
376  and be sure it's a valid file. */
377  struct wavg_desc *fs = (struct wavg_desc *)s->_private;
378 
379  if (check_header(s->f))
380  return -1;
381  fs->secondhalf = 0; /* not strictly necessary */
382  return 0;
383 }
384 
385 static int wav_rewrite(struct ast_filestream *s, const char *comment)
386 {
387  /* We don't have any header to read or anything really, but
388  if we did, it would go here. We also might want to check
389  and be sure it's a valid file. */
390 
391  if (write_header(s->f))
392  return -1;
393  return 0;
394 }
395 
396 static struct ast_frame *wav_read(struct ast_filestream *s, int *whennext)
397 {
398  /* Send a frame from the file to the appropriate channel */
399  struct wavg_desc *fs = (struct wavg_desc *)s->_private;
400 
404  s->fr.samples = GSM_SAMPLES;
405  s->fr.mallocd = 0;
407  if (fs->secondhalf) {
408  /* Just return a frame based on the second GSM frame */
409  s->fr.data.ptr = (char *)s->fr.data.ptr + GSM_FRAME_SIZE;
410  s->fr.offset += GSM_FRAME_SIZE;
411  } else {
412  /* read and convert */
413  unsigned char msdata[MSGSM_FRAME_SIZE];
414  int res;
415 
416  if ((res = fread(msdata, 1, MSGSM_FRAME_SIZE, s->f)) != MSGSM_FRAME_SIZE) {
417  if (res && (res != 1))
418  ast_log(LOG_WARNING, "Short read (%d) (%s)!\n", res, strerror(errno));
419  return NULL;
420  }
421  /* Convert from MS format to two real GSM frames */
422  conv65(msdata, s->fr.data.ptr);
423  }
424  fs->secondhalf = !fs->secondhalf;
425  *whennext = GSM_SAMPLES;
426  return &s->fr;
427 }
428 
429 static int wav_write(struct ast_filestream *s, struct ast_frame *f)
430 {
431  int len;
432  int size;
433  struct wavg_desc *fs = (struct wavg_desc *)s->_private;
434 
435  if (f->frametype != AST_FRAME_VOICE) {
436  ast_log(LOG_WARNING, "Asked to write non-voice frame!\n");
437  return -1;
438  }
439  if (f->subclass.codec != AST_FORMAT_GSM) {
440  ast_log(LOG_WARNING, "Asked to write non-GSM frame (%s)!\n", ast_getformatname(f->subclass.codec));
441  return -1;
442  }
443  /* XXX this might fail... if the input is a multiple of MSGSM_FRAME_SIZE
444  * we assume it is already in the correct format.
445  */
446  if (!(f->datalen % MSGSM_FRAME_SIZE)) {
447  size = MSGSM_FRAME_SIZE;
448  fs->secondhalf = 0;
449  } else {
450  size = GSM_FRAME_SIZE;
451  }
452  for (len = 0; len < f->datalen ; len += size) {
453  int res;
454  unsigned char *src, msdata[MSGSM_FRAME_SIZE];
455  if (fs->secondhalf) { /* second half of raw gsm to be converted */
456  memcpy(s->buf + GSM_FRAME_SIZE, f->data.ptr + len, GSM_FRAME_SIZE);
457  conv66((unsigned char *) s->buf, msdata);
458  src = msdata;
459  fs->secondhalf = 0;
460  } else if (size == GSM_FRAME_SIZE) { /* first half of raw gsm */
461  memcpy(s->buf, f->data.ptr + len, GSM_FRAME_SIZE);
462  src = NULL; /* nothing to write */
463  fs->secondhalf = 1;
464  } else { /* raw msgsm data */
465  src = f->data.ptr + len;
466  }
467  if (src && (res = fwrite(src, 1, MSGSM_FRAME_SIZE, s->f)) != MSGSM_FRAME_SIZE) {
468  ast_log(LOG_WARNING, "Bad write (%d/65): %s\n", res, strerror(errno));
469  return -1;
470  }
471  update_header(s->f); /* XXX inefficient! */
472  }
473  return 0;
474 }
475 
476 static int wav_seek(struct ast_filestream *fs, off_t sample_offset, int whence)
477 {
478  off_t offset = 0, min = MSGSM_DATA_OFFSET, distance, max, cur;
479  struct wavg_desc *s = (struct wavg_desc *)fs->_private;
480 
481  if ((cur = ftello(fs->f)) < 0) {
482  ast_log(AST_LOG_WARNING, "Unable to determine current position in WAV filestream %p: %s\n", fs, strerror(errno));
483  return -1;
484  }
485 
486  if (fseeko(fs->f, 0, SEEK_END) < 0) {
487  ast_log(AST_LOG_WARNING, "Unable to seek to end of WAV filestream %p: %s\n", fs, strerror(errno));
488  return -1;
489  }
490 
491  /* XXX ideally, should round correctly */
492  if ((max = ftello(fs->f)) < 0) {
493  ast_log(AST_LOG_WARNING, "Unable to determine max position in WAV filestream %p: %s\n", fs, strerror(errno));
494  return -1;
495  }
496 
497  /* Compute the distance in bytes, rounded to the block size */
498  distance = (sample_offset/MSGSM_SAMPLES) * MSGSM_FRAME_SIZE;
499  if (whence == SEEK_SET)
500  offset = distance + min;
501  else if (whence == SEEK_CUR || whence == SEEK_FORCECUR)
502  offset = distance + cur;
503  else if (whence == SEEK_END)
504  offset = max - distance;
505  /* always protect against seeking past end of header */
506  if (offset < min)
507  offset = min;
508  if (whence != SEEK_FORCECUR) {
509  if (offset > max)
510  offset = max;
511  } else if (offset > max) {
512  int i;
513  fseek(fs->f, 0, SEEK_END);
514  for (i=0; i< (offset - max) / MSGSM_FRAME_SIZE; i++) {
515  if (!fwrite(msgsm_silence, 1, MSGSM_FRAME_SIZE, fs->f)) {
516  ast_log(LOG_WARNING, "fwrite() failed: %s\n", strerror(errno));
517  }
518  }
519  }
520  s->secondhalf = 0;
521  return fseeko(fs->f, offset, SEEK_SET);
522 }
523 
524 static int wav_trunc(struct ast_filestream *fs)
525 {
526  int fd;
527  off_t cur;
528 
529  if ((fd = fileno(fs->f)) < 0) {
530  ast_log(AST_LOG_WARNING, "Unable to determine file descriptor for WAV filestream %p: %s\n", fs, strerror(errno));
531  return -1;
532  }
533  if ((cur = ftello(fs->f)) < 0) {
534  ast_log(AST_LOG_WARNING, "Unable to determine current position in WAV filestream %p: %s\n", fs, strerror(errno));
535  return -1;
536  }
537  /* Truncate file to current length */
538  if (ftruncate(fd, cur)) {
539  return -1;
540  }
541  return update_header(fs->f);
542 }
543 
544 static off_t wav_tell(struct ast_filestream *fs)
545 {
546  off_t offset;
547  offset = ftello(fs->f);
548  /* since this will most likely be used later in play or record, lets stick
549  * to that level of resolution, just even frames boundaries */
551 }
552 
553 static const struct ast_format wav49_f = {
554  .name = "wav49",
555  .exts = "WAV|wav49",
556  .format = AST_FORMAT_GSM,
557  .open = wav_open,
558  .rewrite = wav_rewrite,
559  .write = wav_write,
560  .seek = wav_seek,
561  .trunc = wav_trunc,
562  .tell = wav_tell,
563  .read = wav_read,
564  .buf_size = 2*GSM_FRAME_SIZE + AST_FRIENDLY_OFFSET,
565  .desc_size = sizeof(struct wavg_desc),
566 };
567 
568 static int load_module(void)
569 {
570  if (ast_format_register(&wav49_f))
573 }
574 
575 static int unload_module(void)
576 {
577  return ast_format_unregister(wav49_f.name);
578 }
579 
580 AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "Microsoft WAV format (Proprietary GSM)",
581  .load = load_module,
582  .unload = unload_module,
583  .load_pri = AST_MODPRI_APP_DEPEND
584 );
union ast_frame_subclass subclass
Definition: frame.h:146
static int update_header(FILE *f)
static int load_module(void)
Asterisk main include file. File version handling, generic pbx functions.
#define ast_format_register(f)
Definition: mod_format.h:131
int offset
Definition: frame.h:156
#define DEFAULT_SAMPLE_RATE
Definition: asterisk.h:41
static int wav_rewrite(struct ast_filestream *s, const char *comment)
void * ptr
Definition: frame.h:160
static off_t wav_tell(struct ast_filestream *fs)
#define LOG_WARNING
Definition: logger.h:144
#define AST_LOG_WARNING
Definition: logger.h:149
#define MSGSM_SAMPLES
Each supported file format is described by the following structure.
Definition: mod_format.h:43
static struct ast_frame * wav_read(struct ast_filestream *s, int *whennext)
#define MSGSM_DATA_OFFSET
#define AST_MODULE_INFO(keystr, flags_to_set, desc, fields...)
Definition: module.h:374
format_t codec
Definition: frame.h:137
static int wav_open(struct ast_filestream *s)
#define GSM_FRAME_SIZE
#define AST_FRAME_SET_BUFFER(fr, _base, _ofs, _datalen)
Definition: frame.h:183
static int check_header(FILE *f)
static int wav_seek(struct ast_filestream *fs, off_t sample_offset, int whence)
#define AST_FRIENDLY_OFFSET
Offset into a frame&#39;s data buffer.
Definition: frame.h:204
Asterisk architecture endianess compatibility definitions.
int datalen
Definition: frame.h:148
struct ast_frame fr
Definition: mod_format.h:117
static void conv65(wav_byte *c, gsm_byte *d)
Definition: msgsm.h:455
void * _private
Definition: mod_format.h:119
int ast_format_unregister(const char *name)
Unregisters a file format.
Definition: file.c:104
#define MSGSM_FRAME_SIZE
char * ast_getformatname(format_t format)
Get the name of a format.
Definition: frame.c:578
char name[80]
Definition: mod_format.h:44
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
#define comment
Definition: ael_lex.c:961
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
static int wav_write(struct ast_filestream *s, struct ast_frame *f)
int errno
#define SEEK_FORCECUR
Definition: file.h:50
static int wav_trunc(struct ast_filestream *fs)
static void conv66(gsm_byte *d, wav_byte *c)
Definition: msgsm.h:114
static struct ast_format f[]
Definition: format_g726.c:181
static struct ast_format wav49_f
static char msgsm_silence[]
if(yyss+yystacksize-1<=yyssp)
Definition: ast_expr2.c:1874
static const char type[]
Definition: chan_nbs.c:57
#define GSM_SAMPLES
int mallocd
Definition: frame.h:152
This structure is allocated by file.c in one chunk, together with buf_size and desc_size bytes of mem...
Definition: mod_format.h:100
static int unload_module(void)
Data structure associated with a single frame of data.
Definition: frame.h:142
enum ast_frame_type frametype
Definition: frame.h:144
#define ASTERISK_GPL_KEY
The text the key() function should return.
Definition: module.h:38
Asterisk module definitions.
static snd_pcm_format_t format
Definition: chan_alsa.c:93
union ast_frame::@172 data
#define AST_FORMAT_GSM
Definition: frame.h:244
#define ASTERISK_FILE_VERSION(file, version)
Register/unregister a source code file with the core.
Definition: asterisk.h:180
int samples
Definition: frame.h:150
static int write_header(FILE *f)