38 #include "asterisk/mod_format.h"
48 #define GSM_FRAME_SIZE 33
49 #define MSGSM_FRAME_SIZE 65
50 #define MSGSM_DATA_OFFSET 60
51 #define GSM_SAMPLES 160
52 #define MSGSM_SAMPLES (2*GSM_SAMPLES)
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};
69 #if __BYTE_ORDER == __LITTLE_ENDIAN
75 #if __BYTE_ORDER == __BIG_ENDIAN
77 (((((b) ) & 0xFF) << 24) | \
78 ((((b) >> 8) & 0xFF) << 16) | \
79 ((((b) >> 16) & 0xFF) << 8) | \
80 ((((b) >> 24) & 0xFF) ))
82 (((((b) ) & 0xFF) << 8) | \
83 ((((b) >> 8) & 0xFF) ))
84 #define ltohl(b) htoll(b)
85 #define ltohs(b) htols(b)
87 #error "Endianess not defined"
94 int type, size, formtype;
99 if (fread(&type, 1, 4, f) != 4) {
103 if (fread(&size, 1, 4, f) != 4) {
108 if (fread(&formtype, 1, 4, f) != 4) {
112 if (memcmp(&type,
"RIFF", 4)) {
116 if (memcmp(&formtype,
"WAVE", 4)) {
120 if (fread(&fmt, 1, 4, f) != 4) {
124 if (memcmp(&fmt,
"fmt ", 4)) {
128 if (fread(&hsize, 1, 4, f) != 4) {
132 if (ltohl(hsize) != 20) {
136 if (fread(&format, 1, 2, f) != 2) {
140 if (ltohs(format) != 49) {
144 if (fread(&chans, 1, 2, f) != 2) {
148 if (ltohs(chans) != 1) {
152 if (fread(&freq, 1, 4, f) != 4) {
161 if (fread(&freq, 1, 4, f) != 4) {
166 if (fread(&freq, 1, 4, f) != 4) {
171 if (fread(&freq, 1, 4, f) != 4) {
176 if (fread(&fact, 1, 4, f) != 4) {
180 if (memcmp(&fact,
"fact", 4)) {
185 if (fread(&fact, 1, 4, f) != 4) {
189 if (fread(&fact, 1, 4, f) != 4) {
194 if (fread(&data, 1, 4, f) != 4) {
198 if (memcmp(&data,
"data", 4)) {
203 if (fread(&data, 1, 4, f) != 4) {
213 int datalen, filelen, samples;
216 fseek(f, 0, SEEK_END);
221 datalen = htoll(bytes);
222 filelen = htoll(MSGSM_DATA_OFFSET - 8 + bytes);
227 if (fseek(f, 4, SEEK_SET)) {
231 if (fwrite(&filelen, 1, 4, f) != 4) {
235 if (fseek(f, 48, SEEK_SET)) {
239 if (fwrite(&samples, 1, 4, f) != 4) {
243 if (fseek(f, 56, SEEK_SET)) {
247 if (fwrite(&datalen, 1, 4, f) != 4) {
251 if (fseeko(f, cur, SEEK_SET)) {
261 unsigned int sample_rate = htoll(8000);
263 unsigned int byte_sample_rate = htoll(1625);
265 unsigned int fmtsize = htoll(20);
267 unsigned short fmt = htols(49);
269 unsigned short chans = htols(1);
273 unsigned short bits_per_sample = htols(2);
277 unsigned int factsize = htoll(4);
279 unsigned int num_samples = htoll(0);
281 unsigned int size = htoll(0);
285 if (fwrite(
"RIFF", 1, 4, f) != 4) {
290 if (fwrite(&size, 1, 4, f) != 4) {
295 if (fwrite(
"WAVE", 1, 4, f) != 4) {
300 if (fwrite(
"fmt ", 1, 4, f) != 4) {
305 if (fwrite(&fmtsize, 1, 4, f) != 4) {
310 if (fwrite(&fmt, 1, 2, f) != 2) {
315 if (fwrite(&chans, 1, 2, f) != 2) {
320 if (fwrite(&sample_rate, 1, 4, f) != 4) {
325 if (fwrite(&byte_sample_rate, 1, 4, f) != 4) {
330 if (fwrite(&block_align, 1, 4, f) != 4) {
335 if (fwrite(&bits_per_sample, 1, 2, f) != 2) {
340 if (fwrite(&extra_format, 1, 2, f) != 2) {
345 if (fwrite(
"fact", 1, 4, f) != 4) {
350 if (fwrite(&factsize, 1, 4, f) != 4) {
355 if (fwrite(&num_samples, 1, 4, f) != 4) {
360 if (fwrite(
"data", 1, 4, f) != 4) {
365 if (fwrite(&size, 1, 4, f) != 4) {
417 if (res && (res != 1))
452 for (len = 0; len < f->
datalen ; len += size) {
457 conv66((
unsigned char *) s->
buf, msdata);
481 if ((cur = ftello(fs->
f)) < 0) {
486 if (fseeko(fs->
f, 0, SEEK_END) < 0) {
492 if ((max = ftello(fs->
f)) < 0) {
499 if (whence == SEEK_SET)
500 offset = distance + min;
502 offset = distance + cur;
503 else if (whence == SEEK_END)
504 offset = max - distance;
511 }
else if (offset > max) {
513 fseek(fs->
f, 0, SEEK_END);
521 return fseeko(fs->
f, offset, SEEK_SET);
529 if ((fd = fileno(fs->
f)) < 0) {
533 if ((cur = ftello(fs->
f)) < 0) {
538 if (ftruncate(fd, cur)) {
547 offset = ftello(fs->
f);
union ast_frame_subclass subclass
Asterisk main include file. File version handling, generic pbx functions.
#define DEFAULT_SAMPLE_RATE
#define AST_MODULE_INFO(keystr, flags_to_set, desc, fields...)
#define AST_FRAME_SET_BUFFER(fr, _base, _ofs, _datalen)
#define AST_FRIENDLY_OFFSET
Offset into a frame's data buffer.
Asterisk architecture endianess compatibility definitions.
static void conv65(wav_byte *c, gsm_byte *d)
char * ast_getformatname(format_t format)
Get the name of a format.
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
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...
static void conv66(gsm_byte *d, wav_byte *c)
if(yyss+yystacksize-1<=yyssp)
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.
enum ast_frame_type frametype
#define ASTERISK_GPL_KEY
The text the key() function should return.
Asterisk module definitions.
static snd_pcm_format_t format
union ast_frame::@172 data
#define ASTERISK_FILE_VERSION(file, version)
Register/unregister a source code file with the core.