format_wav_gsm.c 16 KB

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