#include <sys/types.h>
Go to the source code of this file.
Data Structures | |
struct | ast_frame |
Data structure associated with a single frame of data. More... | |
struct | ast_frame_chain |
struct | ast_option_header |
Defines | |
#define | AST_FRIENDLY_OFFSET 64 /*! It's polite for a a new frame to |
#define | AST_MALLOCD_HDR (1 << 0) |
#define | AST_MALLOCD_DATA (1 << 1) |
#define | AST_MALLOCD_SRC (1 << 2) |
#define | AST_FRAME_DTMF 1 |
#define | AST_FRAME_VOICE 2 |
#define | AST_FRAME_VIDEO 3 |
#define | AST_FRAME_CONTROL 4 |
#define | AST_FRAME_NULL 5 |
#define | AST_FRAME_IAX 6 |
#define | AST_FRAME_TEXT 7 |
#define | AST_FRAME_IMAGE 8 |
#define | AST_FRAME_HTML 9 |
#define | AST_HTML_URL 1 |
#define | AST_HTML_DATA 2 |
#define | AST_HTML_BEGIN 4 |
#define | AST_HTML_END 8 |
#define | AST_HTML_LDCOMPLETE 16 |
#define | AST_HTML_NOSUPPORT 17 |
#define | AST_HTML_LINKURL 18 |
#define | AST_HTML_UNLINK 19 |
#define | AST_HTML_LINKREJECT 20 |
#define | AST_FORMAT_G723_1 (1 << 0) |
#define | AST_FORMAT_GSM (1 << 1) |
#define | AST_FORMAT_ULAW (1 << 2) |
#define | AST_FORMAT_ALAW (1 << 3) |
#define | AST_FORMAT_MP3 (1 << 4) |
#define | AST_FORMAT_ADPCM (1 << 5) |
#define | AST_FORMAT_SLINEAR (1 << 6) |
#define | AST_FORMAT_LPC10 (1 << 7) |
#define | AST_FORMAT_G729A (1 << 8) |
#define | AST_FORMAT_SPEEX (1 << 9) |
#define | AST_FORMAT_ILBC (1 << 10) |
#define | AST_FORMAT_MAX_AUDIO (1 << 15) |
#define | AST_FORMAT_JPEG (1 << 16) |
#define | AST_FORMAT_PNG (1 << 17) |
#define | AST_FORMAT_H261 (1 << 18) |
#define | AST_FORMAT_H263 (1 << 19) |
#define | AST_FORMAT_MAX_VIDEO (1 << 24) |
#define | AST_CONTROL_HANGUP 1 |
#define | AST_CONTROL_RING 2 |
#define | AST_CONTROL_RINGING 3 |
#define | AST_CONTROL_ANSWER 4 |
#define | AST_CONTROL_BUSY 5 |
#define | AST_CONTROL_TAKEOFFHOOK 6 |
#define | AST_CONTROL_OFFHOOK 7 |
#define | AST_CONTROL_CONGESTION 8 |
#define | AST_CONTROL_FLASH 9 |
#define | AST_CONTROL_WINK 10 |
#define | AST_CONTROL_OPTION 11 |
#define | AST_CONTROL_RADIO_KEY 12 |
#define | AST_CONTROL_RADIO_UNKEY 13 |
#define | AST_CONTROL_PROGRESS 14 |
#define | AST_OPTION_FLAG_REQUEST 0 |
#define | AST_OPTION_FLAG_ACCEPT 1 |
#define | AST_OPTION_FLAG_REJECT 2 |
#define | AST_OPTION_FLAG_QUERY 4 |
#define | AST_OPTION_FLAG_ANSWER 5 |
#define | AST_OPTION_FLAG_WTF 6 |
#define | AST_OPTION_TONE_VERIFY 1 |
#define | AST_OPTION_TDD 2 |
#define | AST_OPTION_RELAXDTMF 3 |
#define | AST_OPTION_AUDIO_MODE 4 |
Functions | |
void | ast_frfree (struct ast_frame *fr) |
Frees a frame. | |
ast_frame * | ast_frisolate (struct ast_frame *fr) |
Copies a frame. | |
ast_frame * | ast_frdup (struct ast_frame *fr) |
Copies a frame. | |
ast_frame * | ast_fr_fdread (int fd) |
Reads a frame from an fd. | |
int | ast_fr_fdwrite (int fd, struct ast_frame *frame) |
Writes a frame to an fd. | |
int | ast_fr_fdhangup (int fd) |
Sends a hangup to an fd. | |
char * | ast_getformatname (int format) |
Get the name of a format. | |
int | ast_getformatbyname (char *name) |
char * | ast_codec2str (int codec) |
Get a name from a format. | |
int | ast_best_codec (int fmts) |
Pick the best codec. | |
ast_smoother * | ast_smoother_new (int bytes) |
void | ast_smoother_free (struct ast_smoother *s) |
void | ast_smoother_reset (struct ast_smoother *s, int bytes) |
int | ast_smoother_feed (struct ast_smoother *s, struct ast_frame *f) |
ast_frame * | ast_smoother_read (struct ast_smoother *s) |
void | ast_frame_dump (char *name, struct ast_frame *f, char *prefix) |
|
Remote end has answered Definition at line 188 of file frame.h. Referenced by ast_dsp_process(), ast_frame_dump(), ast_read(), ast_request_and_dial(), ast_waitstream(), ast_waitstream_fr(), and ast_waitstream_full(). |
|
Remote end is busy Definition at line 190 of file frame.h. Referenced by ast_dsp_process(), ast_frame_dump(), ast_indicate(), and ast_request_and_dial(). |
|
Congestion (circuits busy) Definition at line 196 of file frame.h. Referenced by ast_dsp_process(), ast_frame_dump(), ast_indicate(), and ast_request_and_dial(). |
|
Flash hook Definition at line 198 of file frame.h. Referenced by ast_frame_dump(). |
|
Other end has hungup Definition at line 182 of file frame.h. Referenced by ast_fr_fdhangup(), ast_fr_fdread(), ast_frame_dump(), ast_queue_hangup(), ast_read(), ast_recvchar(), ast_request_and_dial(), ast_waitstream(), ast_waitstream_fr(), and ast_waitstream_full(). |
|
Line is off hook Definition at line 194 of file frame.h. Referenced by ast_frame_dump(). |
|
Set a low-level option Definition at line 202 of file frame.h. Referenced by ast_frame_dump(). |
|
Indicate CALL_PROCEEDING or PROGRESS Definition at line 208 of file frame.h. Referenced by ast_indicate(). |
|
Key Radio Definition at line 204 of file frame.h. Referenced by ast_frame_dump(). |
|
Un-Key Radio Definition at line 206 of file frame.h. Referenced by ast_frame_dump(). |
|
Local ring Definition at line 184 of file frame.h. Referenced by ast_frame_dump(). |
|
Remote end is ringing Definition at line 186 of file frame.h. Referenced by ast_dsp_process(), ast_frame_dump(), ast_indicate(), ast_request_and_dial(), ast_waitstream(), ast_waitstream_fr(), and ast_waitstream_full(). |
|
Make it go off hook Definition at line 192 of file frame.h. Referenced by ast_frame_dump(). |
|
Wink Definition at line 200 of file frame.h. Referenced by ast_frame_dump(). |
|
ADPCM (whose?) Definition at line 156 of file frame.h. Referenced by ast_best_codec(), ast_getformatbyname(), ast_getformatname(), and ast_rtp_read(). |
|
Raw A-law data (G.711) Definition at line 152 of file frame.h. Referenced by ast_best_codec(), ast_dsp_process(), ast_getformatbyname(), ast_getformatname(), ast_rtp_read(), and ast_rtp_write(). |
|
G.723.1 compression Definition at line 146 of file frame.h. Referenced by ast_best_codec(), ast_getformatbyname(), ast_getformatname(), ast_rtp_read(), and ast_rtp_write(). |
|
G.729A audio Definition at line 162 of file frame.h. Referenced by ast_best_codec(), ast_getformatbyname(), ast_getformatname(), ast_rtp_read(), and ast_rtp_write(). |
|
GSM compression Definition at line 148 of file frame.h. Referenced by ast_best_codec(), ast_getformatbyname(), ast_getformatname(), ast_rtp_read(), and ast_rtp_write(). |
|
H.261 Video Definition at line 174 of file frame.h. Referenced by ast_getformatbyname(), ast_getformatname(), and ast_rtp_write(). |
|
H.263 Video Definition at line 176 of file frame.h. Referenced by ast_getformatbyname(), ast_getformatname(), and ast_rtp_write(). |
|
iLBC Free Compression Definition at line 166 of file frame.h. Referenced by ast_best_codec(), ast_getformatbyname(), ast_getformatname(), ast_rtp_read(), and ast_rtp_write(). |
|
JPEG Images Definition at line 170 of file frame.h. Referenced by ast_getformatname(). |
|
LPC10, 180 samples/frame Definition at line 160 of file frame.h. Referenced by ast_best_codec(), ast_getformatbyname(), and ast_getformatname(). |
|
Maximum audio format Definition at line 168 of file frame.h. Referenced by ast_closestream(), ast_playstream(), ast_rtp_read(), and ast_writestream(). |
|
Max one |
|
MPEG-2 layer 3 Definition at line 154 of file frame.h. Referenced by ast_best_codec(), ast_getformatbyname(), and ast_getformatname(). |
|
PNG Images Definition at line 172 of file frame.h. Referenced by ast_getformatname(). |
|
Raw 16-bit Signed Linear (8000 Hz) PCM Definition at line 158 of file frame.h. Referenced by ast_app_getvoice(), ast_best_codec(), ast_dsp_call_progress(), ast_dsp_digitdetect(), ast_dsp_process(), ast_dsp_silence(), ast_getformatbyname(), ast_getformatname(), and ast_rtp_read(). |
|
SpeeX Free Compression Definition at line 164 of file frame.h. Referenced by ast_best_codec(), ast_getformatbyname(), ast_getformatname(), ast_rtp_read(), and ast_rtp_write(). |
|
Raw mu-law data (G.711) Definition at line 150 of file frame.h. Referenced by ast_best_codec(), ast_dsp_process(), ast_getformatbyname(), ast_getformatname(), ast_rtp_read(), and ast_rtp_write(). |
|
A control frame, subclass is AST_CONTROL_* Definition at line 112 of file frame.h. Referenced by ast_channel_bridge(), ast_dsp_process(), ast_fr_fdhangup(), ast_fr_fdread(), ast_frame_dump(), ast_queue_control(), ast_queue_hangup(), ast_read(), ast_recvchar(), ast_request_and_dial(), ast_waitstream(), ast_waitstream_fr(), ast_waitstream_full(), and ast_write(). |
|
A DTMF digit, subclass is the digit Definition at line 106 of file frame.h. Referenced by ast_app_getvoice(), ast_channel_bridge(), ast_dsp_process(), ast_frame_dump(), ast_read(), ast_rtp_bridge(), ast_waitfordigit(), ast_waitfordigit_full(), ast_waitstream(), ast_waitstream_fr(), ast_waitstream_full(), and ast_write(). |
|
HTML Frame Definition at line 122 of file frame.h. Referenced by ast_frame_dump(). |
|
Inter Aterisk Exchange private frame type Definition at line 116 of file frame.h. Referenced by ast_frame_dump(). |
|
Image Frames Definition at line 120 of file frame.h. Referenced by ast_channel_bridge(), and ast_frame_dump(). |
|
An empty, useless frame Definition at line 114 of file frame.h. Referenced by ast_channel_masquerade(), ast_dsp_process(), ast_frame_dump(), ast_read(), ast_rtcp_read(), ast_rtp_read(), and ast_softhangup_nolock(). |
|
Text messages Definition at line 118 of file frame.h. Referenced by ast_channel_bridge(), ast_frame_dump(), ast_recvchar(), and ast_write(). |
|
Video frame, maybe?? :) Definition at line 110 of file frame.h. Referenced by ast_channel_bridge(), ast_frame_dump(), ast_rtp_bridge(), ast_rtp_read(), ast_rtp_write(), ast_write(), and ast_writestream(). |
|
Voice data, subclass is AST_FORMAT_* Definition at line 108 of file frame.h. Referenced by ast_app_getvoice(), ast_channel_bridge(), ast_dsp_call_progress(), ast_dsp_digitdetect(), ast_dsp_process(), ast_dsp_silence(), ast_frame_dump(), ast_prod(), ast_queue_frame(), ast_read(), ast_rtp_bridge(), ast_rtp_read(), ast_rtp_write(), ast_smoother_feed(), ast_smoother_read(), ast_waitstream_full(), ast_write(), and ast_writestream(). |
|
Definition at line 92 of file frame.h. Referenced by ast_frdup(), ast_frisolate(), ast_prod(), ast_rtp_read(), and ast_smoother_read(). |
|
Beginning frame Definition at line 130 of file frame.h. Referenced by ast_frame_dump(). |
|
Data frame Definition at line 128 of file frame.h. Referenced by ast_frame_dump(). |
|
End frame Definition at line 132 of file frame.h. Referenced by ast_frame_dump(). |
|
Load is complete Definition at line 134 of file frame.h. Referenced by ast_frame_dump(). |
|
Reject link request Definition at line 142 of file frame.h. Referenced by ast_frame_dump(). |
|
Send URL, and track Definition at line 138 of file frame.h. Referenced by ast_frame_dump(). |
|
Peer is unable to support HTML Definition at line 136 of file frame.h. Referenced by ast_frame_dump(). |
|
No more HTML linkage Definition at line 140 of file frame.h. Referenced by ast_frame_dump(). |
|
Sending a URL Definition at line 126 of file frame.h. Referenced by ast_channel_sendurl(), and ast_frame_dump(). |
|
Need the data be free'd? Definition at line 100 of file frame.h. Referenced by ast_frfree(), and ast_frisolate(). |
|
Need the header be free'd? Definition at line 98 of file frame.h. Referenced by ast_frdup(), ast_frfree(), and ast_frisolate(). |
|
Need the source be free'd? (haha!) Definition at line 102 of file frame.h. Referenced by ast_frfree(), and ast_frisolate(). |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Pick the best codec.
Definition at line 222 of file channel.c. References AST_FORMAT_ADPCM, AST_FORMAT_ALAW, AST_FORMAT_G723_1, AST_FORMAT_G729A, AST_FORMAT_GSM, AST_FORMAT_ILBC, AST_FORMAT_LPC10, AST_FORMAT_MP3, AST_FORMAT_SLINEAR, AST_FORMAT_SPEEX, AST_FORMAT_ULAW, ast_log(), and LOG_WARNING.
00223 { 00224 /* This just our opinion, expressed in code. We are asked to choose 00225 the best codec to use, given no information */ 00226 int x; 00227 static int prefs[] = 00228 { 00229 /* Okay, ulaw is used by all telephony equipment, so start with it */ 00230 AST_FORMAT_ULAW, 00231 /* Unless of course, you're a silly European, so then prefer ALAW */ 00232 AST_FORMAT_ALAW, 00233 /* Okay, well, signed linear is easy to translate into other stuff */ 00234 AST_FORMAT_SLINEAR, 00235 /* ADPCM has great sound quality and is still pretty easy to translate */ 00236 AST_FORMAT_ADPCM, 00237 /* Okay, we're down to vocoders now, so pick GSM because it's small and easier to 00238 translate and sounds pretty good */ 00239 AST_FORMAT_GSM, 00240 /* iLBC is not too bad */ 00241 AST_FORMAT_ILBC, 00242 /* Speex is free, but computationally more expensive than GSM */ 00243 AST_FORMAT_SPEEX, 00244 /* Ick, LPC10 sounds terrible, but at least we have code for it, if you're tacky enough 00245 to use it */ 00246 AST_FORMAT_LPC10, 00247 /* G.729a is faster than 723 and slightly less expensive */ 00248 AST_FORMAT_G729A, 00249 /* Down to G.723.1 which is proprietary but at least designed for voice */ 00250 AST_FORMAT_G723_1, 00251 /* Last and least, MP3 which was of course never designed for real-time voice */ 00252 AST_FORMAT_MP3, 00253 }; 00254 00255 00256 for (x=0;x<sizeof(prefs) / sizeof(prefs[0]); x++) 00257 if (fmts & prefs[x]) 00258 return prefs[x]; 00259 ast_log(LOG_WARNING, "Don't know any of 0x%x formats\n", fmts); 00260 return 0; 00261 } |
|
Get a name from a format.
Definition at line 414 of file frame.c.
00414 { 00415 static char codecs[25][30] = { 00416 /* Audio formats */ 00417 "G.723.1", /* 0 */ 00418 "GSM", /* 1 */ 00419 "G.711 u-law", /* 2 */ 00420 "G.711 A-law", /* 3 */ 00421 "MPEG-2 layer 3", /* 4 */ 00422 "ADPCM", /* 5 */ 00423 "16 bit Signed Linear PCM", /* 6 */ 00424 "LPC10", /* 7 */ 00425 "G.729A audio", /* 8 */ 00426 "SpeeX", /* 9 */ 00427 "iLBC", /* 10 */ 00428 "undefined", /* 11 */ 00429 "undefined", /* 12 */ 00430 "undefined", /* 13 */ 00431 "undefined", /* 14 */ 00432 "Maximum audio format", /* 15 */ 00433 /* Image formats */ 00434 "JPEG image", /* 16 */ 00435 "PNG image", /* 17 */ 00436 "H.261 Video", /* 18 */ 00437 "H.263 Video", /* 19 */ 00438 "undefined", /* 20 */ 00439 "undefined", /* 21 */ 00440 "undefined", /* 22 */ 00441 "undefined", /* 23 */ 00442 "Maximum video format", /* 24 */ 00443 }; 00444 return codecs[codec]; 00445 } |
|
Sends a hangup to an fd.
Definition at line 337 of file frame.c. References AST_CONTROL_HANGUP, ast_fr_fdwrite(), and AST_FRAME_CONTROL.
00338 { 00339 struct ast_frame hangup = { 00340 AST_FRAME_CONTROL, 00341 AST_CONTROL_HANGUP 00342 }; 00343 return ast_fr_fdwrite(fd, &hangup); 00344 } |
|
Reads a frame from an fd.
Definition at line 275 of file frame.c. References AST_CONTROL_HANGUP, AST_FRAME_CONTROL, ast_frisolate(), ast_log(), and LOG_WARNING.
00276 { 00277 char buf[65536]; 00278 int res; 00279 int ttl = sizeof(struct ast_frame); 00280 struct ast_frame *f = (struct ast_frame *)buf; 00281 /* Read a frame directly from there. They're always in the 00282 right format. */ 00283 00284 while(ttl) { 00285 res = read(fd, buf, ttl); 00286 if (res < 0) { 00287 ast_log(LOG_WARNING, "Bad read on %d: %s\n", fd, strerror(errno)); 00288 return NULL; 00289 } 00290 ttl -= res; 00291 } 00292 00293 /* read the frame header */ 00294 f->mallocd = 0; 00295 /* Re-write data position */ 00296 f->data = buf + sizeof(struct ast_frame); 00297 f->offset = 0; 00298 /* Forget about being mallocd */ 00299 f->mallocd = 0; 00300 /* Re-write the source */ 00301 f->src = __FUNCTION__; 00302 if (f->datalen > sizeof(buf) - sizeof(struct ast_frame)) { 00303 /* Really bad read */ 00304 ast_log(LOG_WARNING, "Strange read (%d bytes)\n", f->datalen); 00305 return NULL; 00306 } 00307 if (f->datalen) { 00308 if ((res = read(fd, f->data, f->datalen)) != f->datalen) { 00309 /* Bad read */ 00310 ast_log(LOG_WARNING, "How very strange, expected %d, got %d\n", f->datalen, res); 00311 return NULL; 00312 } 00313 } 00314 if ((f->frametype == AST_FRAME_CONTROL) && (f->subclass == AST_CONTROL_HANGUP)) { 00315 return NULL; 00316 } 00317 return ast_frisolate(f); 00318 } |
|
Writes a frame to an fd.
Definition at line 323 of file frame.c. References ast_log(), ast_frame::data, ast_frame::datalen, and LOG_WARNING. Referenced by ast_fr_fdhangup().
00324 { 00325 /* Write the frame exactly */ 00326 if (write(fd, frame, sizeof(struct ast_frame)) != sizeof(struct ast_frame)) { 00327 ast_log(LOG_WARNING, "Write error: %s\n", strerror(errno)); 00328 return -1; 00329 } 00330 if (write(fd, frame->data, frame->datalen) != frame->datalen) { 00331 ast_log(LOG_WARNING, "Write error: %s\n", strerror(errno)); 00332 return -1; 00333 } 00334 return 0; 00335 } |
|
Definition at line 520 of file frame.c. References AST_CONTROL_ANSWER, AST_CONTROL_BUSY, AST_CONTROL_CONGESTION, AST_CONTROL_FLASH, AST_CONTROL_HANGUP, AST_CONTROL_OFFHOOK, AST_CONTROL_OPTION, AST_CONTROL_RADIO_KEY, AST_CONTROL_RADIO_UNKEY, AST_CONTROL_RING, AST_CONTROL_RINGING, AST_CONTROL_TAKEOFFHOOK, AST_CONTROL_WINK, AST_FRAME_CONTROL, AST_FRAME_DTMF, AST_FRAME_HTML, AST_FRAME_IAX, AST_FRAME_IMAGE, AST_FRAME_NULL, AST_FRAME_TEXT, AST_FRAME_VIDEO, AST_FRAME_VOICE, ast_getformatname(), AST_HTML_BEGIN, AST_HTML_DATA, AST_HTML_END, AST_HTML_LDCOMPLETE, AST_HTML_LINKREJECT, AST_HTML_LINKURL, AST_HTML_NOSUPPORT, AST_HTML_UNLINK, AST_HTML_URL, ast_verbose(), COLOR_BLACK, COLOR_BRCYAN, COLOR_BRGREEN, COLOR_BRMAGENTA, COLOR_BRRED, COLOR_YELLOW, ast_frame::data, ast_frame::frametype, ast_frame::subclass, and term_color(). Referenced by ast_read(), and ast_write().
00521 { 00522 char *n = "unknown"; 00523 char ftype[40] = "Unknown Frametype"; 00524 char cft[80]; 00525 char subclass[40] = "Unknown Subclass"; 00526 char csub[80]; 00527 char moreinfo[40] = ""; 00528 char cn[40]; 00529 char cp[40]; 00530 char cmn[40]; 00531 if (name) 00532 n = name; 00533 if (!f) { 00534 ast_verbose("%s [ %s (NULL) ] [%s]\n", 00535 term_color(cp, prefix, COLOR_BRMAGENTA, COLOR_BLACK, sizeof(cp)), 00536 term_color(cft, "HANGUP", COLOR_BRRED, COLOR_BLACK, sizeof(cft)), 00537 term_color(cn, n, COLOR_YELLOW, COLOR_BLACK, sizeof(cn))); 00538 return; 00539 } 00540 /* XXX We should probably print one each of voice and video when the format changes XXX */ 00541 if (f->frametype == AST_FRAME_VOICE) 00542 return; 00543 if (f->frametype == AST_FRAME_VIDEO) 00544 return; 00545 switch(f->frametype) { 00546 case AST_FRAME_DTMF: 00547 strcpy(ftype, "DTMF"); 00548 subclass[0] = f->subclass; 00549 subclass[1] = '\0'; 00550 break; 00551 case AST_FRAME_CONTROL: 00552 strcpy(ftype, "Control"); 00553 switch(f->subclass) { 00554 case AST_CONTROL_HANGUP: 00555 strcpy(subclass, "Hangup"); 00556 break; 00557 case AST_CONTROL_RING: 00558 strcpy(subclass, "Ring"); 00559 break; 00560 case AST_CONTROL_RINGING: 00561 strcpy(subclass, "Ringing"); 00562 break; 00563 case AST_CONTROL_ANSWER: 00564 strcpy(subclass, "Answer"); 00565 break; 00566 case AST_CONTROL_BUSY: 00567 strcpy(subclass, "Busy"); 00568 break; 00569 case AST_CONTROL_TAKEOFFHOOK: 00570 strcpy(subclass, "Take Off Hook"); 00571 break; 00572 case AST_CONTROL_OFFHOOK: 00573 strcpy(subclass, "Line Off Hook"); 00574 break; 00575 case AST_CONTROL_CONGESTION: 00576 strcpy(subclass, "Congestion"); 00577 break; 00578 case AST_CONTROL_FLASH: 00579 strcpy(subclass, "Flash"); 00580 break; 00581 case AST_CONTROL_WINK: 00582 strcpy(subclass, "Wink"); 00583 break; 00584 case AST_CONTROL_OPTION: 00585 strcpy(subclass, "Option"); 00586 break; 00587 case AST_CONTROL_RADIO_KEY: 00588 strcpy(subclass, "Key Radio"); 00589 break; 00590 case AST_CONTROL_RADIO_UNKEY: 00591 strcpy(subclass, "Unkey Radio"); 00592 break; 00593 default: 00594 snprintf(subclass, sizeof(subclass), "Unknown control '%d'", f->subclass); 00595 } 00596 case AST_FRAME_NULL: 00597 strcpy(ftype, "Null Frame"); 00598 strcpy(subclass, "N/A"); 00599 break; 00600 case AST_FRAME_IAX: 00601 /* Should never happen */ 00602 strcpy(ftype, "IAX Specific"); 00603 snprintf(subclass, sizeof(subclass), "IAX Frametype %d", f->subclass); 00604 break; 00605 case AST_FRAME_TEXT: 00606 strcpy(ftype, "Text"); 00607 strcpy(subclass, "N/A"); 00608 strncpy(moreinfo, f->data, sizeof(moreinfo) - 1); 00609 break; 00610 case AST_FRAME_IMAGE: 00611 strcpy(ftype, "Image"); 00612 snprintf(subclass, sizeof(subclass), "Image format %s\n", ast_getformatname(f->subclass)); 00613 break; 00614 case AST_FRAME_HTML: 00615 strcpy(ftype, "HTML"); 00616 switch(f->subclass) { 00617 case AST_HTML_URL: 00618 strcpy(subclass, "URL"); 00619 strncpy(moreinfo, f->data, sizeof(moreinfo) - 1); 00620 break; 00621 case AST_HTML_DATA: 00622 strcpy(subclass, "Data"); 00623 break; 00624 case AST_HTML_BEGIN: 00625 strcpy(subclass, "Begin"); 00626 break; 00627 case AST_HTML_END: 00628 strcpy(subclass, "End"); 00629 break; 00630 case AST_HTML_LDCOMPLETE: 00631 strcpy(subclass, "Load Complete"); 00632 break; 00633 case AST_HTML_NOSUPPORT: 00634 strcpy(subclass, "No Support"); 00635 break; 00636 case AST_HTML_LINKURL: 00637 strcpy(subclass, "Link URL"); 00638 strncpy(moreinfo, f->data, sizeof(moreinfo) - 1); 00639 break; 00640 case AST_HTML_UNLINK: 00641 strcpy(subclass, "Unlink"); 00642 break; 00643 case AST_HTML_LINKREJECT: 00644 strcpy(subclass, "Link Reject"); 00645 break; 00646 default: 00647 snprintf(subclass, sizeof(subclass), "Unknown HTML frame '%d'\n", f->subclass); 00648 break; 00649 } 00650 break; 00651 default: 00652 snprintf(ftype, sizeof(ftype), "Unknown Frametype '%d'", f->frametype); 00653 } 00654 if (strlen(moreinfo)) 00655 ast_verbose("%s [ TYPE: %s (%d) SUBCLASS: %s (%d) '%s' ] [%s]\n", 00656 term_color(cp, prefix, COLOR_BRMAGENTA, COLOR_BLACK, sizeof(cp)), 00657 term_color(cft, ftype, COLOR_BRRED, COLOR_BLACK, sizeof(cft)), 00658 f->frametype, 00659 term_color(csub, subclass, COLOR_BRCYAN, COLOR_BLACK, sizeof(csub)), 00660 f->subclass, 00661 term_color(cmn, moreinfo, COLOR_BRGREEN, COLOR_BLACK, sizeof(cmn)), 00662 term_color(cn, n, COLOR_YELLOW, COLOR_BLACK, sizeof(cn))); 00663 else 00664 ast_verbose("%s [ TYPE: %s (%d) SUBCLASS: %s (%d) ] [%s]\n", 00665 term_color(cp, prefix, COLOR_BRMAGENTA, COLOR_BLACK, sizeof(cp)), 00666 term_color(cft, ftype, COLOR_BRRED, COLOR_BLACK, sizeof(cft)), 00667 f->frametype, 00668 term_color(csub, subclass, COLOR_BRCYAN, COLOR_BLACK, sizeof(csub)), 00669 f->subclass, 00670 term_color(cn, n, COLOR_YELLOW, COLOR_BLACK, sizeof(cn))); 00671 00672 } |
|
Copies a frame.
Definition at line 240 of file frame.c. References AST_FRIENDLY_OFFSET, AST_MALLOCD_HDR, ast_frame::data, ast_frame::datalen, ast_frame::frametype, malloc, ast_frame::samples, ast_frame::src, and ast_frame::subclass. Referenced by ast_queue_frame(), and ast_rtp_write().
00241 { 00242 struct ast_frame *out; 00243 int len; 00244 void *buf; 00245 /* Start with standard stuff */ 00246 len = sizeof(struct ast_frame) + AST_FRIENDLY_OFFSET + f->datalen; 00247 /* If we have a source, add space for it */ 00248 if (f->src && strlen(f->src)) 00249 len += strlen(f->src) + 1; 00250 buf = malloc(len); 00251 if (!buf) 00252 return NULL; 00253 out = buf; 00254 /* Set us as having malloc'd header only, so it will eventually 00255 get freed. */ 00256 out->frametype = f->frametype; 00257 out->subclass = f->subclass; 00258 out->datalen = f->datalen; 00259 out->samples = f->samples; 00260 out->mallocd = AST_MALLOCD_HDR; 00261 out->offset = AST_FRIENDLY_OFFSET; 00262 out->data = buf + sizeof(struct ast_frame) + AST_FRIENDLY_OFFSET; 00263 if (f->src && strlen(f->src)) { 00264 out->src = out->data + f->datalen; 00265 /* Must have space since we allocated for it */ 00266 strcpy(out->src, f->src); 00267 } else 00268 out->src = NULL; 00269 out->prev = NULL; 00270 out->next = NULL; 00271 memcpy(out->data, f->data, out->datalen); 00272 return out; 00273 } |
|
|
Copies a frame.
Definition at line 199 of file frame.c. References AST_FRIENDLY_OFFSET, ast_log(), AST_MALLOCD_DATA, AST_MALLOCD_HDR, AST_MALLOCD_SRC, ast_frame::data, ast_frame::datalen, ast_frame::frametype, free, LOG_WARNING, malloc, ast_frame::mallocd, ast_frame::samples, ast_frame::src, strdup, and ast_frame::subclass. Referenced by ast_fr_fdread().
00200 { 00201 struct ast_frame *out; 00202 if (!(fr->mallocd & AST_MALLOCD_HDR)) { 00203 /* Allocate a new header if needed */ 00204 out = ast_frame_header_new(); 00205 if (!out) { 00206 ast_log(LOG_WARNING, "Out of memory\n"); 00207 return NULL; 00208 } 00209 out->frametype = fr->frametype; 00210 out->subclass = fr->subclass; 00211 out->datalen = 0; 00212 out->samples = fr->samples; 00213 out->offset = 0; 00214 out->src = NULL; 00215 out->data = NULL; 00216 } else { 00217 out = fr; 00218 } 00219 if (!(fr->mallocd & AST_MALLOCD_SRC)) { 00220 if (fr->src) 00221 out->src = strdup(fr->src); 00222 } else 00223 out->src = fr->src; 00224 if (!(fr->mallocd & AST_MALLOCD_DATA)) { 00225 out->data = malloc(fr->datalen + AST_FRIENDLY_OFFSET); 00226 if (!out->data) { 00227 free(out); 00228 ast_log(LOG_WARNING, "Out of memory\n"); 00229 return NULL; 00230 } 00231 out->data += AST_FRIENDLY_OFFSET; 00232 out->offset = AST_FRIENDLY_OFFSET; 00233 out->datalen = fr->datalen; 00234 memcpy(out->data, fr->data, fr->datalen); 00235 } 00236 out->mallocd = AST_MALLOCD_HDR | AST_MALLOCD_SRC | AST_MALLOCD_DATA; 00237 return out; 00238 } |
|
Definition at line 381 of file frame.c. References AST_FORMAT_ADPCM, AST_FORMAT_ALAW, AST_FORMAT_G723_1, AST_FORMAT_G729A, AST_FORMAT_GSM, AST_FORMAT_H261, AST_FORMAT_H263, AST_FORMAT_ILBC, AST_FORMAT_LPC10, AST_FORMAT_MP3, AST_FORMAT_SLINEAR, AST_FORMAT_SPEEX, and AST_FORMAT_ULAW.
00382 { 00383 if (!strcasecmp(name, "g723.1")) 00384 return AST_FORMAT_G723_1; 00385 else if (!strcasecmp(name, "gsm")) 00386 return AST_FORMAT_GSM; 00387 else if (!strcasecmp(name, "ulaw")) 00388 return AST_FORMAT_ULAW; 00389 else if (!strcasecmp(name, "alaw")) 00390 return AST_FORMAT_ALAW; 00391 else if (!strcasecmp(name, "mp3")) 00392 return AST_FORMAT_MP3; 00393 else if (!strcasecmp(name, "slinear")) 00394 return AST_FORMAT_SLINEAR; 00395 else if (!strcasecmp(name, "lpc10")) 00396 return AST_FORMAT_LPC10; 00397 else if (!strcasecmp(name, "adpcm")) 00398 return AST_FORMAT_ADPCM; 00399 else if (!strcasecmp(name, "g729")) 00400 return AST_FORMAT_G729A; 00401 else if (!strcasecmp(name, "speex")) 00402 return AST_FORMAT_SPEEX; 00403 else if (!strcasecmp(name, "ilbc")) 00404 return AST_FORMAT_ILBC; 00405 else if (!strcasecmp(name, "h261")) 00406 return AST_FORMAT_H261; 00407 else if (!strcasecmp(name, "h263")) 00408 return AST_FORMAT_H263; 00409 else if (!strcasecmp(name, "all")) 00410 return 0x7FFFFFFF; 00411 return 0; 00412 } |
|
Get the name of a format.
Definition at line 346 of file frame.c. References AST_FORMAT_ADPCM, AST_FORMAT_ALAW, AST_FORMAT_G723_1, AST_FORMAT_G729A, AST_FORMAT_GSM, AST_FORMAT_H261, AST_FORMAT_H263, AST_FORMAT_ILBC, AST_FORMAT_JPEG, AST_FORMAT_LPC10, AST_FORMAT_MP3, AST_FORMAT_PNG, AST_FORMAT_SLINEAR, AST_FORMAT_SPEEX, and AST_FORMAT_ULAW. Referenced by ast_frame_dump(), ast_read(), ast_register_translator(), ast_rtp_read(), ast_rtp_write(), ast_set_read_format(), ast_set_write_format(), ast_streamfile(), ast_translator_build_path(), and ast_writestream().
00347 { 00348 if (format == AST_FORMAT_G723_1) 00349 return "G723"; 00350 else if (format == AST_FORMAT_GSM) 00351 return "GSM"; 00352 else if (format == AST_FORMAT_ULAW) 00353 return "ULAW"; 00354 else if (format == AST_FORMAT_ALAW) 00355 return "ALAW"; 00356 else if (format == AST_FORMAT_MP3) 00357 return "MP3"; 00358 else if (format == AST_FORMAT_SLINEAR) 00359 return "SLINR"; 00360 else if (format == AST_FORMAT_LPC10) 00361 return "LPC10"; 00362 else if (format == AST_FORMAT_ADPCM) 00363 return "ADPCM"; 00364 else if (format == AST_FORMAT_G729A) 00365 return "G729A"; 00366 else if (format == AST_FORMAT_SPEEX) 00367 return "SPEEX"; 00368 else if (format == AST_FORMAT_ILBC) 00369 return "ILBC"; 00370 else if (format == AST_FORMAT_JPEG) 00371 return "JPEG"; 00372 else if (format == AST_FORMAT_PNG) 00373 return "PNG"; 00374 else if (format == AST_FORMAT_H261) 00375 return "H261"; 00376 else if (format == AST_FORMAT_H263) 00377 return "H263"; 00378 return "UNKN"; 00379 } |
|
Definition at line 66 of file frame.c. References AST_FRAME_VOICE, ast_log(), ast_frame::data, ast_smoother::data, ast_frame::datalen, ast_smoother::format, ast_frame::frametype, ast_smoother::len, LOG_WARNING, ast_smoother::opt, ast_smoother::optimizablestream, ast_frame::samples, ast_smoother::samplesperbyte, ast_smoother::size, SMOOTHER_SIZE, and ast_frame::subclass. Referenced by ast_rtp_write().
00067 { 00068 if (f->frametype != AST_FRAME_VOICE) { 00069 ast_log(LOG_WARNING, "Huh? Can't smooth a non-voice frame!\n"); 00070 return -1; 00071 } 00072 if (!s->format) { 00073 s->format = f->subclass; 00074 s->samplesperbyte = (float)f->samples / (float)f->datalen; 00075 } else if (s->format != f->subclass) { 00076 ast_log(LOG_WARNING, "Smoother was working on %d format frames, now trying to feed %d?\n", s->format, f->subclass); 00077 return -1; 00078 } 00079 if (s->len + f->datalen > SMOOTHER_SIZE) { 00080 ast_log(LOG_WARNING, "Out of smoother space\n"); 00081 return -1; 00082 } 00083 if ((f->datalen == s->size) && !s->opt) { 00084 if (!s->len) { 00085 /* Optimize by sending the frame we just got 00086 on the next read, thus eliminating the douple 00087 copy */ 00088 s->opt = f; 00089 return 0; 00090 } else { 00091 s->optimizablestream++; 00092 if (s->optimizablestream > 10) { 00093 /* For the past 10 rounds, we have input and output 00094 frames of the correct size for this smoother, yet 00095 we were unable to optimize because there was still 00096 some cruft left over. Lets just drop the cruft so 00097 we can move to a fully optimized path */ 00098 s->len = 0; 00099 s->opt = f; 00100 return 0; 00101 } 00102 } 00103 } else 00104 s->optimizablestream = 0; 00105 memcpy(s->data + s->len, f->data, f->datalen); 00106 s->len += f->datalen; 00107 return 0; 00108 } |
|
Definition at line 142 of file frame.c. References free. Referenced by ast_rtp_destroy(), and ast_rtp_write().
00143 { 00144 free(s); 00145 } |
|
Definition at line 55 of file frame.c. References ast_smoother_reset(), and malloc. Referenced by ast_rtp_write().
00056 { 00057 struct ast_smoother *s; 00058 if (size < 1) 00059 return NULL; 00060 s = malloc(sizeof(struct ast_smoother)); 00061 if (s) 00062 ast_smoother_reset(s, size); 00063 return s; 00064 } |
|
Definition at line 110 of file frame.c. References AST_FRAME_VOICE, AST_FRIENDLY_OFFSET, ast_smoother::data, ast_frame::data, ast_frame::datalen, ast_smoother::f, ast_smoother::format, ast_smoother::framedata, ast_frame::frametype, ast_smoother::len, ast_frame::offset, ast_smoother::opt, ast_frame::samples, ast_smoother::samplesperbyte, ast_smoother::size, and ast_frame::subclass. Referenced by ast_rtp_write().
00111 { 00112 struct ast_frame *opt; 00113 00114 /* IF we have an optimization frame, send it */ 00115 if (s->opt) { 00116 opt = s->opt; 00117 s->opt = NULL; 00118 return opt; 00119 } 00120 00121 /* Make sure we have enough data */ 00122 if (s->len < s->size) { 00123 return NULL; 00124 } 00125 /* Make frame */ 00126 s->f.frametype = AST_FRAME_VOICE; 00127 s->f.subclass = s->format; 00128 s->f.data = s->framedata + AST_FRIENDLY_OFFSET; 00129 s->f.offset = AST_FRIENDLY_OFFSET; 00130 s->f.datalen = s->size; 00131 s->f.samples = s->size * s->samplesperbyte; 00132 /* Fill Data */ 00133 memcpy(s->f.data, s->data, s->size); 00134 s->len -= s->size; 00135 /* Move remaining data to the front if applicable */ 00136 if (s->len) 00137 memmove(s->data, s->data + s->size, s->len); 00138 /* Return frame */ 00139 return &s->f; 00140 } |
|
Definition at line 49 of file frame.c. References ast_smoother::size. Referenced by ast_smoother_new().
00050 { 00051 memset(s, 0, sizeof(struct ast_smoother)); 00052 s->size = size; 00053 } |