Save GSM in the proprietary Microsoft format. More...
#include "asterisk.h"
#include "asterisk/mod_format.h"
#include "asterisk/module.h"
#include "asterisk/endian.h"
#include "msgsm.h"
Go to the source code of this file.
Data Structures | |
struct | wavg_desc |
Defines | |
#define | GSM_FRAME_SIZE 33 |
#define | GSM_SAMPLES 160 |
#define | htoll(b) (b) |
#define | htols(b) (b) |
#define | ltohl(b) (b) |
#define | ltohs(b) (b) |
#define | MSGSM_DATA_OFFSET 60 |
#define | MSGSM_FRAME_SIZE 65 |
#define | MSGSM_SAMPLES (2*GSM_SAMPLES) |
Functions | |
AST_MODULE_INFO (ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER,"Microsoft WAV format (Proprietary GSM)",.load=load_module,.unload=unload_module,.load_pri=AST_MODPRI_APP_DEPEND) | |
static int | check_header (FILE *f) |
static int | load_module (void) |
static int | unload_module (void) |
static int | update_header (FILE *f) |
static int | wav_open (struct ast_filestream *s) |
static struct ast_frame * | wav_read (struct ast_filestream *s, int *whennext) |
static int | wav_rewrite (struct ast_filestream *s, const char *comment) |
static int | wav_seek (struct ast_filestream *fs, off_t sample_offset, int whence) |
static off_t | wav_tell (struct ast_filestream *fs) |
static int | wav_trunc (struct ast_filestream *fs) |
static int | wav_write (struct ast_filestream *s, struct ast_frame *f) |
static int | write_header (FILE *f) |
Variables | |
static char | msgsm_silence [] |
static struct ast_format | wav49_f |
Save GSM in the proprietary Microsoft format.
Microsoft WAV format (Proprietary GSM)
Definition in file format_wav_gsm.c.
#define GSM_FRAME_SIZE 33 |
Definition at line 48 of file format_wav_gsm.c.
#define GSM_SAMPLES 160 |
Definition at line 51 of file format_wav_gsm.c.
#define htoll | ( | b | ) | (b) |
Definition at line 70 of file format_wav_gsm.c.
#define htols | ( | b | ) | (b) |
Definition at line 71 of file format_wav_gsm.c.
#define ltohl | ( | b | ) | (b) |
Definition at line 72 of file format_wav_gsm.c.
#define ltohs | ( | b | ) | (b) |
Definition at line 73 of file format_wav_gsm.c.
#define MSGSM_DATA_OFFSET 60 |
Definition at line 50 of file format_wav_gsm.c.
Referenced by update_header(), wav_seek(), and wav_tell().
#define MSGSM_FRAME_SIZE 65 |
Definition at line 49 of file format_wav_gsm.c.
Referenced by update_header(), wav_read(), wav_seek(), wav_tell(), wav_write(), and write_header().
#define MSGSM_SAMPLES (2*GSM_SAMPLES) |
Definition at line 52 of file format_wav_gsm.c.
Referenced by update_header(), wav_seek(), wav_tell(), and write_header().
AST_MODULE_INFO | ( | ASTERISK_GPL_KEY | , | |
AST_MODFLAG_LOAD_ORDER | , | |||
"Microsoft WAV format (Proprietary GSM)" | , | |||
. | load = load_module , |
|||
. | unload = unload_module , |
|||
. | load_pri = AST_MODPRI_APP_DEPEND | |||
) |
static int check_header | ( | FILE * | f | ) | [static] |
Definition at line 92 of file format_wav_gsm.c.
References ast_log(), DEFAULT_SAMPLE_RATE, format, LOG_WARNING, ltohl, ltohs, and type.
Referenced by wav_open().
00093 { 00094 int type, size, formtype; 00095 int fmt, hsize, fact; 00096 short format, chans; 00097 int freq; 00098 int data; 00099 if (fread(&type, 1, 4, f) != 4) { 00100 ast_log(LOG_WARNING, "Read failed (type)\n"); 00101 return -1; 00102 } 00103 if (fread(&size, 1, 4, f) != 4) { 00104 ast_log(LOG_WARNING, "Read failed (size)\n"); 00105 return -1; 00106 } 00107 size = ltohl(size); 00108 if (fread(&formtype, 1, 4, f) != 4) { 00109 ast_log(LOG_WARNING, "Read failed (formtype)\n"); 00110 return -1; 00111 } 00112 if (memcmp(&type, "RIFF", 4)) { 00113 ast_log(LOG_WARNING, "Does not begin with RIFF\n"); 00114 return -1; 00115 } 00116 if (memcmp(&formtype, "WAVE", 4)) { 00117 ast_log(LOG_WARNING, "Does not contain WAVE\n"); 00118 return -1; 00119 } 00120 if (fread(&fmt, 1, 4, f) != 4) { 00121 ast_log(LOG_WARNING, "Read failed (fmt)\n"); 00122 return -1; 00123 } 00124 if (memcmp(&fmt, "fmt ", 4)) { 00125 ast_log(LOG_WARNING, "Does not say fmt\n"); 00126 return -1; 00127 } 00128 if (fread(&hsize, 1, 4, f) != 4) { 00129 ast_log(LOG_WARNING, "Read failed (formtype)\n"); 00130 return -1; 00131 } 00132 if (ltohl(hsize) != 20) { 00133 ast_log(LOG_WARNING, "Unexpected header size %d\n", ltohl(hsize)); 00134 return -1; 00135 } 00136 if (fread(&format, 1, 2, f) != 2) { 00137 ast_log(LOG_WARNING, "Read failed (format)\n"); 00138 return -1; 00139 } 00140 if (ltohs(format) != 49) { 00141 ast_log(LOG_WARNING, "Not a GSM file %d\n", ltohs(format)); 00142 return -1; 00143 } 00144 if (fread(&chans, 1, 2, f) != 2) { 00145 ast_log(LOG_WARNING, "Read failed (format)\n"); 00146 return -1; 00147 } 00148 if (ltohs(chans) != 1) { 00149 ast_log(LOG_WARNING, "Not in mono %d\n", ltohs(chans)); 00150 return -1; 00151 } 00152 if (fread(&freq, 1, 4, f) != 4) { 00153 ast_log(LOG_WARNING, "Read failed (freq)\n"); 00154 return -1; 00155 } 00156 if (ltohl(freq) != DEFAULT_SAMPLE_RATE) { 00157 ast_log(LOG_WARNING, "Unexpected frequency %d\n", ltohl(freq)); 00158 return -1; 00159 } 00160 /* Ignore the byte frequency */ 00161 if (fread(&freq, 1, 4, f) != 4) { 00162 ast_log(LOG_WARNING, "Read failed (X_1)\n"); 00163 return -1; 00164 } 00165 /* Ignore the two weird fields */ 00166 if (fread(&freq, 1, 4, f) != 4) { 00167 ast_log(LOG_WARNING, "Read failed (X_2/X_3)\n"); 00168 return -1; 00169 } 00170 /* Ignore the byte frequency */ 00171 if (fread(&freq, 1, 4, f) != 4) { 00172 ast_log(LOG_WARNING, "Read failed (Y_1)\n"); 00173 return -1; 00174 } 00175 /* Check for the word fact */ 00176 if (fread(&fact, 1, 4, f) != 4) { 00177 ast_log(LOG_WARNING, "Read failed (fact)\n"); 00178 return -1; 00179 } 00180 if (memcmp(&fact, "fact", 4)) { 00181 ast_log(LOG_WARNING, "Does not say fact\n"); 00182 return -1; 00183 } 00184 /* Ignore the "fact value" */ 00185 if (fread(&fact, 1, 4, f) != 4) { 00186 ast_log(LOG_WARNING, "Read failed (fact header)\n"); 00187 return -1; 00188 } 00189 if (fread(&fact, 1, 4, f) != 4) { 00190 ast_log(LOG_WARNING, "Read failed (fact value)\n"); 00191 return -1; 00192 } 00193 /* Check for the word data */ 00194 if (fread(&data, 1, 4, f) != 4) { 00195 ast_log(LOG_WARNING, "Read failed (data)\n"); 00196 return -1; 00197 } 00198 if (memcmp(&data, "data", 4)) { 00199 ast_log(LOG_WARNING, "Does not say data\n"); 00200 return -1; 00201 } 00202 /* Ignore the data length */ 00203 if (fread(&data, 1, 4, f) != 4) { 00204 ast_log(LOG_WARNING, "Read failed (data)\n"); 00205 return -1; 00206 } 00207 return 0; 00208 }
static int load_module | ( | void | ) | [static] |
Definition at line 568 of file format_wav_gsm.c.
References ast_format_register, AST_MODULE_LOAD_FAILURE, and AST_MODULE_LOAD_SUCCESS.
00569 { 00570 if (ast_format_register(&wav49_f)) 00571 return AST_MODULE_LOAD_FAILURE; 00572 return AST_MODULE_LOAD_SUCCESS; 00573 }
static int unload_module | ( | void | ) | [static] |
Definition at line 575 of file format_wav_gsm.c.
References ast_format_unregister(), and ast_format::name.
00576 { 00577 return ast_format_unregister(wav49_f.name); 00578 }
static int update_header | ( | FILE * | f | ) | [static] |
Definition at line 210 of file format_wav_gsm.c.
References ast_log(), htoll, LOG_WARNING, MSGSM_DATA_OFFSET, MSGSM_FRAME_SIZE, and MSGSM_SAMPLES.
Referenced by wav_trunc(), and wav_write().
00211 { 00212 off_t cur,end,bytes; 00213 int datalen, filelen, samples; 00214 00215 cur = ftello(f); 00216 fseek(f, 0, SEEK_END); 00217 end = ftello(f); 00218 /* in a gsm WAV, data starts 60 bytes in */ 00219 bytes = end - MSGSM_DATA_OFFSET; 00220 samples = htoll(bytes / MSGSM_FRAME_SIZE * MSGSM_SAMPLES); 00221 datalen = htoll(bytes); 00222 filelen = htoll(MSGSM_DATA_OFFSET - 8 + bytes); 00223 if (cur < 0) { 00224 ast_log(LOG_WARNING, "Unable to find our position\n"); 00225 return -1; 00226 } 00227 if (fseek(f, 4, SEEK_SET)) { 00228 ast_log(LOG_WARNING, "Unable to set our position\n"); 00229 return -1; 00230 } 00231 if (fwrite(&filelen, 1, 4, f) != 4) { 00232 ast_log(LOG_WARNING, "Unable to write file size\n"); 00233 return -1; 00234 } 00235 if (fseek(f, 48, SEEK_SET)) { 00236 ast_log(LOG_WARNING, "Unable to set our position\n"); 00237 return -1; 00238 } 00239 if (fwrite(&samples, 1, 4, f) != 4) { 00240 ast_log(LOG_WARNING, "Unable to write samples\n"); 00241 return -1; 00242 } 00243 if (fseek(f, 56, SEEK_SET)) { 00244 ast_log(LOG_WARNING, "Unable to set our position\n"); 00245 return -1; 00246 } 00247 if (fwrite(&datalen, 1, 4, f) != 4) { 00248 ast_log(LOG_WARNING, "Unable to write datalen\n"); 00249 return -1; 00250 } 00251 if (fseeko(f, cur, SEEK_SET)) { 00252 ast_log(LOG_WARNING, "Unable to return to position\n"); 00253 return -1; 00254 } 00255 return 0; 00256 }
static int wav_open | ( | struct ast_filestream * | s | ) | [static] |
Definition at line 372 of file format_wav_gsm.c.
References ast_filestream::_private, check_header(), ast_filestream::f, and wavg_desc::secondhalf.
00373 { 00374 /* We don't have any header to read or anything really, but 00375 if we did, it would go here. We also might want to check 00376 and be sure it's a valid file. */ 00377 struct wavg_desc *fs = (struct wavg_desc *)s->_private; 00378 00379 if (check_header(s->f)) 00380 return -1; 00381 fs->secondhalf = 0; /* not strictly necessary */ 00382 return 0; 00383 }
static struct ast_frame* wav_read | ( | struct ast_filestream * | s, | |
int * | whennext | |||
) | [static, read] |
Definition at line 396 of file format_wav_gsm.c.
References ast_filestream::_private, AST_FORMAT_GSM, AST_FRAME_SET_BUFFER, AST_FRAME_VOICE, AST_FRIENDLY_OFFSET, ast_log(), ast_filestream::buf, ast_frame_subclass::codec, conv65(), ast_frame::data, errno, ast_filestream::f, ast_filestream::fr, ast_frame::frametype, GSM_FRAME_SIZE, GSM_SAMPLES, LOG_WARNING, ast_frame::mallocd, MSGSM_FRAME_SIZE, ast_frame::offset, ast_frame::ptr, ast_frame::samples, wavg_desc::secondhalf, and ast_frame::subclass.
00397 { 00398 /* Send a frame from the file to the appropriate channel */ 00399 struct wavg_desc *fs = (struct wavg_desc *)s->_private; 00400 00401 s->fr.frametype = AST_FRAME_VOICE; 00402 s->fr.subclass.codec = AST_FORMAT_GSM; 00403 s->fr.offset = AST_FRIENDLY_OFFSET; 00404 s->fr.samples = GSM_SAMPLES; 00405 s->fr.mallocd = 0; 00406 AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, GSM_FRAME_SIZE); 00407 if (fs->secondhalf) { 00408 /* Just return a frame based on the second GSM frame */ 00409 s->fr.data.ptr = (char *)s->fr.data.ptr + GSM_FRAME_SIZE; 00410 s->fr.offset += GSM_FRAME_SIZE; 00411 } else { 00412 /* read and convert */ 00413 unsigned char msdata[MSGSM_FRAME_SIZE]; 00414 int res; 00415 00416 if ((res = fread(msdata, 1, MSGSM_FRAME_SIZE, s->f)) != MSGSM_FRAME_SIZE) { 00417 if (res && (res != 1)) 00418 ast_log(LOG_WARNING, "Short read (%d) (%s)!\n", res, strerror(errno)); 00419 return NULL; 00420 } 00421 /* Convert from MS format to two real GSM frames */ 00422 conv65(msdata, s->fr.data.ptr); 00423 } 00424 fs->secondhalf = !fs->secondhalf; 00425 *whennext = GSM_SAMPLES; 00426 return &s->fr; 00427 }
static int wav_rewrite | ( | struct ast_filestream * | s, | |
const char * | comment | |||
) | [static] |
Definition at line 385 of file format_wav_gsm.c.
References ast_filestream::f, and write_header().
00386 { 00387 /* We don't have any header to read or anything really, but 00388 if we did, it would go here. We also might want to check 00389 and be sure it's a valid file. */ 00390 00391 if (write_header(s->f)) 00392 return -1; 00393 return 0; 00394 }
static int wav_seek | ( | struct ast_filestream * | fs, | |
off_t | sample_offset, | |||
int | whence | |||
) | [static] |
Definition at line 476 of file format_wav_gsm.c.
References ast_filestream::_private, ast_log(), AST_LOG_WARNING, errno, ast_filestream::f, LOG_WARNING, MSGSM_DATA_OFFSET, MSGSM_FRAME_SIZE, MSGSM_SAMPLES, wavg_desc::secondhalf, and SEEK_FORCECUR.
00477 { 00478 off_t offset = 0, min = MSGSM_DATA_OFFSET, distance, max, cur; 00479 struct wavg_desc *s = (struct wavg_desc *)fs->_private; 00480 00481 if ((cur = ftello(fs->f)) < 0) { 00482 ast_log(AST_LOG_WARNING, "Unable to determine current position in WAV filestream %p: %s\n", fs, strerror(errno)); 00483 return -1; 00484 } 00485 00486 if (fseeko(fs->f, 0, SEEK_END) < 0) { 00487 ast_log(AST_LOG_WARNING, "Unable to seek to end of WAV filestream %p: %s\n", fs, strerror(errno)); 00488 return -1; 00489 } 00490 00491 /* XXX ideally, should round correctly */ 00492 if ((max = ftello(fs->f)) < 0) { 00493 ast_log(AST_LOG_WARNING, "Unable to determine max position in WAV filestream %p: %s\n", fs, strerror(errno)); 00494 return -1; 00495 } 00496 00497 /* Compute the distance in bytes, rounded to the block size */ 00498 distance = (sample_offset/MSGSM_SAMPLES) * MSGSM_FRAME_SIZE; 00499 if (whence == SEEK_SET) 00500 offset = distance + min; 00501 else if (whence == SEEK_CUR || whence == SEEK_FORCECUR) 00502 offset = distance + cur; 00503 else if (whence == SEEK_END) 00504 offset = max - distance; 00505 /* always protect against seeking past end of header */ 00506 if (offset < min) 00507 offset = min; 00508 if (whence != SEEK_FORCECUR) { 00509 if (offset > max) 00510 offset = max; 00511 } else if (offset > max) { 00512 int i; 00513 fseek(fs->f, 0, SEEK_END); 00514 for (i=0; i< (offset - max) / MSGSM_FRAME_SIZE; i++) { 00515 if (!fwrite(msgsm_silence, 1, MSGSM_FRAME_SIZE, fs->f)) { 00516 ast_log(LOG_WARNING, "fwrite() failed: %s\n", strerror(errno)); 00517 } 00518 } 00519 } 00520 s->secondhalf = 0; 00521 return fseeko(fs->f, offset, SEEK_SET); 00522 }
static off_t wav_tell | ( | struct ast_filestream * | fs | ) | [static] |
Definition at line 544 of file format_wav_gsm.c.
References ast_filestream::f, MSGSM_DATA_OFFSET, MSGSM_FRAME_SIZE, and MSGSM_SAMPLES.
00545 { 00546 off_t offset; 00547 offset = ftello(fs->f); 00548 /* since this will most likely be used later in play or record, lets stick 00549 * to that level of resolution, just even frames boundaries */ 00550 return (offset - MSGSM_DATA_OFFSET)/MSGSM_FRAME_SIZE*MSGSM_SAMPLES; 00551 }
static int wav_trunc | ( | struct ast_filestream * | fs | ) | [static] |
Definition at line 524 of file format_wav_gsm.c.
References ast_log(), AST_LOG_WARNING, errno, ast_filestream::f, and update_header().
00525 { 00526 int fd; 00527 off_t cur; 00528 00529 if ((fd = fileno(fs->f)) < 0) { 00530 ast_log(AST_LOG_WARNING, "Unable to determine file descriptor for WAV filestream %p: %s\n", fs, strerror(errno)); 00531 return -1; 00532 } 00533 if ((cur = ftello(fs->f)) < 0) { 00534 ast_log(AST_LOG_WARNING, "Unable to determine current position in WAV filestream %p: %s\n", fs, strerror(errno)); 00535 return -1; 00536 } 00537 /* Truncate file to current length */ 00538 if (ftruncate(fd, cur)) { 00539 return -1; 00540 } 00541 return update_header(fs->f); 00542 }
static int wav_write | ( | struct ast_filestream * | s, | |
struct ast_frame * | f | |||
) | [static] |
Definition at line 429 of file format_wav_gsm.c.
References ast_filestream::_private, AST_FORMAT_GSM, AST_FRAME_VOICE, ast_getformatname(), ast_log(), ast_filestream::buf, ast_frame_subclass::codec, conv66(), ast_frame::data, ast_frame::datalen, errno, ast_filestream::f, ast_frame::frametype, GSM_FRAME_SIZE, len(), LOG_WARNING, MSGSM_FRAME_SIZE, ast_frame::ptr, wavg_desc::secondhalf, ast_frame::subclass, and update_header().
00430 { 00431 int len; 00432 int size; 00433 struct wavg_desc *fs = (struct wavg_desc *)s->_private; 00434 00435 if (f->frametype != AST_FRAME_VOICE) { 00436 ast_log(LOG_WARNING, "Asked to write non-voice frame!\n"); 00437 return -1; 00438 } 00439 if (f->subclass.codec != AST_FORMAT_GSM) { 00440 ast_log(LOG_WARNING, "Asked to write non-GSM frame (%s)!\n", ast_getformatname(f->subclass.codec)); 00441 return -1; 00442 } 00443 /* XXX this might fail... if the input is a multiple of MSGSM_FRAME_SIZE 00444 * we assume it is already in the correct format. 00445 */ 00446 if (!(f->datalen % MSGSM_FRAME_SIZE)) { 00447 size = MSGSM_FRAME_SIZE; 00448 fs->secondhalf = 0; 00449 } else { 00450 size = GSM_FRAME_SIZE; 00451 } 00452 for (len = 0; len < f->datalen ; len += size) { 00453 int res; 00454 unsigned char *src, msdata[MSGSM_FRAME_SIZE]; 00455 if (fs->secondhalf) { /* second half of raw gsm to be converted */ 00456 memcpy(s->buf + GSM_FRAME_SIZE, f->data.ptr + len, GSM_FRAME_SIZE); 00457 conv66((unsigned char *) s->buf, msdata); 00458 src = msdata; 00459 fs->secondhalf = 0; 00460 } else if (size == GSM_FRAME_SIZE) { /* first half of raw gsm */ 00461 memcpy(s->buf, f->data.ptr + len, GSM_FRAME_SIZE); 00462 src = NULL; /* nothing to write */ 00463 fs->secondhalf = 1; 00464 } else { /* raw msgsm data */ 00465 src = f->data.ptr + len; 00466 } 00467 if (src && (res = fwrite(src, 1, MSGSM_FRAME_SIZE, s->f)) != MSGSM_FRAME_SIZE) { 00468 ast_log(LOG_WARNING, "Bad write (%d/65): %s\n", res, strerror(errno)); 00469 return -1; 00470 } 00471 update_header(s->f); /* XXX inefficient! */ 00472 } 00473 return 0; 00474 }
static int write_header | ( | FILE * | f | ) | [static] |
Definition at line 258 of file format_wav_gsm.c.
References ast_log(), htoll, htols, LOG_WARNING, MSGSM_FRAME_SIZE, and MSGSM_SAMPLES.
Referenced by wav_rewrite().
00259 { 00260 /* Samples per second (always 8000 for this format). */ 00261 unsigned int sample_rate = htoll(8000); 00262 /* Bytes per second (always 1625 for this format). */ 00263 unsigned int byte_sample_rate = htoll(1625); 00264 /* This is the size of the "fmt " subchunk */ 00265 unsigned int fmtsize = htoll(20); 00266 /* WAV #49 */ 00267 unsigned short fmt = htols(49); 00268 /* Mono = 1 channel */ 00269 unsigned short chans = htols(1); 00270 /* Each block of data is exactly 65 bytes in size. */ 00271 unsigned int block_align = htoll(MSGSM_FRAME_SIZE); 00272 /* Not actually 2, but rounded up to the nearest bit */ 00273 unsigned short bits_per_sample = htols(2); 00274 /* Needed for compressed formats */ 00275 unsigned short extra_format = htols(MSGSM_SAMPLES); 00276 /* This is the size of the "fact" subchunk */ 00277 unsigned int factsize = htoll(4); 00278 /* Number of samples in the data chunk */ 00279 unsigned int num_samples = htoll(0); 00280 /* Number of bytes in the data chunk */ 00281 unsigned int size = htoll(0); 00282 /* Write a GSM header, ignoring sizes which will be filled in later */ 00283 00284 /* 0: Chunk ID */ 00285 if (fwrite("RIFF", 1, 4, f) != 4) { 00286 ast_log(LOG_WARNING, "Unable to write header\n"); 00287 return -1; 00288 } 00289 /* 4: Chunk Size */ 00290 if (fwrite(&size, 1, 4, f) != 4) { 00291 ast_log(LOG_WARNING, "Unable to write header\n"); 00292 return -1; 00293 } 00294 /* 8: Chunk Format */ 00295 if (fwrite("WAVE", 1, 4, f) != 4) { 00296 ast_log(LOG_WARNING, "Unable to write header\n"); 00297 return -1; 00298 } 00299 /* 12: Subchunk 1: ID */ 00300 if (fwrite("fmt ", 1, 4, f) != 4) { 00301 ast_log(LOG_WARNING, "Unable to write header\n"); 00302 return -1; 00303 } 00304 /* 16: Subchunk 1: Size (minus 8) */ 00305 if (fwrite(&fmtsize, 1, 4, f) != 4) { 00306 ast_log(LOG_WARNING, "Unable to write header\n"); 00307 return -1; 00308 } 00309 /* 20: Subchunk 1: Audio format (49) */ 00310 if (fwrite(&fmt, 1, 2, f) != 2) { 00311 ast_log(LOG_WARNING, "Unable to write header\n"); 00312 return -1; 00313 } 00314 /* 22: Subchunk 1: Number of channels */ 00315 if (fwrite(&chans, 1, 2, f) != 2) { 00316 ast_log(LOG_WARNING, "Unable to write header\n"); 00317 return -1; 00318 } 00319 /* 24: Subchunk 1: Sample rate */ 00320 if (fwrite(&sample_rate, 1, 4, f) != 4) { 00321 ast_log(LOG_WARNING, "Unable to write header\n"); 00322 return -1; 00323 } 00324 /* 28: Subchunk 1: Byte rate */ 00325 if (fwrite(&byte_sample_rate, 1, 4, f) != 4) { 00326 ast_log(LOG_WARNING, "Unable to write header\n"); 00327 return -1; 00328 } 00329 /* 32: Subchunk 1: Block align */ 00330 if (fwrite(&block_align, 1, 4, f) != 4) { 00331 ast_log(LOG_WARNING, "Unable to write header\n"); 00332 return -1; 00333 } 00334 /* 36: Subchunk 1: Bits per sample */ 00335 if (fwrite(&bits_per_sample, 1, 2, f) != 2) { 00336 ast_log(LOG_WARNING, "Unable to write header\n"); 00337 return -1; 00338 } 00339 /* 38: Subchunk 1: Extra format bytes */ 00340 if (fwrite(&extra_format, 1, 2, f) != 2) { 00341 ast_log(LOG_WARNING, "Unable to write header\n"); 00342 return -1; 00343 } 00344 /* 40: Subchunk 2: ID */ 00345 if (fwrite("fact", 1, 4, f) != 4) { 00346 ast_log(LOG_WARNING, "Unable to write header\n"); 00347 return -1; 00348 } 00349 /* 44: Subchunk 2: Size (minus 8) */ 00350 if (fwrite(&factsize, 1, 4, f) != 4) { 00351 ast_log(LOG_WARNING, "Unable to write header\n"); 00352 return -1; 00353 } 00354 /* 48: Subchunk 2: Number of samples */ 00355 if (fwrite(&num_samples, 1, 4, f) != 4) { 00356 ast_log(LOG_WARNING, "Unable to write header\n"); 00357 return -1; 00358 } 00359 /* 52: Subchunk 3: ID */ 00360 if (fwrite("data", 1, 4, f) != 4) { 00361 ast_log(LOG_WARNING, "Unable to write header\n"); 00362 return -1; 00363 } 00364 /* 56: Subchunk 3: Size */ 00365 if (fwrite(&size, 1, 4, f) != 4) { 00366 ast_log(LOG_WARNING, "Unable to write header\n"); 00367 return -1; 00368 } 00369 return 0; 00370 }
char msgsm_silence[] [static] |
Definition at line 55 of file format_wav_gsm.c.
struct ast_format wav49_f [static] |
Definition at line 553 of file format_wav_gsm.c.