#include <sys/types.h>#include <sys/time.h>Go to the source code of this file.
Data Structures | |
| struct | ast_codec_pref |
| 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 |
| #define | AST_MIN_OFFSET 32 |
| #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_FRAME_CNG 10 |
| #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_G726 (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_CONTROL_PROCEEDING 15 |
| #define | AST_SMOOTHER_FLAG_G729 (1 << 0) |
| #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 |
| #define | ast_frame_byteswap_le(fr) do { ; } while(0) |
| #define | ast_frame_byteswap_be(fr) do { struct ast_frame *__f = (fr); ast_memcpy_byteswap(__f->data, __f->data, __f->samples); } while(0) |
| #define | ast_smoother_feed(s, f) __ast_smoother_feed(s, f, 0) |
| #define | ast_smoother_feed_be(s, f) __ast_smoother_feed(s, f, 1) |
| #define | ast_smoother_feed_le(s, f) __ast_smoother_feed(s, f, 0) |
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. | |
| void | ast_memcpy_byteswap (void *dst, void *src, int samples) |
| char * | ast_getformatname (int format) |
| Get the name of a format. | |
| char * | ast_getformatname_multiple (char *buf, size_t size, int format) |
| Get the names of a set of formats. | |
| 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_format_list * | ast_get_format_list_index (int index) |
| ast_format_list * | ast_get_format_list (size_t *size) |
| ast_smoother * | ast_smoother_new (int bytes) |
| void | ast_smoother_set_flags (struct ast_smoother *smoother, int flags) |
| int | ast_smoother_get_flags (struct ast_smoother *smoother) |
| 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, int swap) |
| ast_frame * | ast_smoother_read (struct ast_smoother *s) |
| void | ast_frame_dump (char *name, struct ast_frame *f, char *prefix) |
| void | ast_codec_pref_init (struct ast_codec_pref *pref) |
| int | ast_codec_pref_index (struct ast_codec_pref *pref, int index) |
| void | ast_codec_pref_remove (struct ast_codec_pref *pref, int format) |
| int | ast_codec_pref_append (struct ast_codec_pref *pref, int format) |
| int | ast_codec_choose (struct ast_codec_pref *pref, int formats, int find_best) |
| void | ast_parse_allow_disallow (struct ast_codec_pref *pref, int *mask, char *list, int allowing) |
| int | ast_codec_pref_string (struct ast_codec_pref *pref, char *buf, size_t size) |
| void | ast_codec_pref_shift (struct ast_codec_pref *pref, char *buf, size_t size, int right) |
|
|
Remote end has answered Definition at line 202 of file frame.h. Referenced by __ast_request_and_dial(), ast_dsp_process(), ast_frame_dump(), ast_read(), ast_waitfordigit_full(), ast_waitstream(), ast_waitstream_fr(), and ast_waitstream_full(). |
|
|
Remote end is busy Definition at line 204 of file frame.h. Referenced by __ast_request_and_dial(), ast_dsp_process(), ast_frame_dump(), and ast_indicate(). |
|
|
Congestion (circuits busy) Definition at line 210 of file frame.h. Referenced by __ast_request_and_dial(), ast_dsp_process(), ast_frame_dump(), and ast_indicate(). |
|
|
Flash hook Definition at line 212 of file frame.h. Referenced by ast_frame_dump(). |
|
|
Other end has hungup Definition at line 196 of file frame.h. Referenced by __ast_request_and_dial(), ast_fr_fdhangup(), ast_fr_fdread(), ast_frame_dump(), ast_queue_frame(), ast_queue_hangup(), ast_read(), ast_recvchar(), ast_waitfordigit_full(), ast_waitstream(), ast_waitstream_fr(), and ast_waitstream_full(). |
|
|
Line is off hook Definition at line 208 of file frame.h. Referenced by ast_frame_dump(). |
|
|
Set a low-level option Definition at line 216 of file frame.h. Referenced by ast_frame_dump(). |
|
|
Indicate CALL PROCEEDING Definition at line 224 of file frame.h. Referenced by ast_indicate(). |
|
|
Indicate PROGRESS Definition at line 222 of file frame.h. Referenced by __ast_request_and_dial(), and ast_indicate(). |
|
|
Key Radio Definition at line 218 of file frame.h. Referenced by ast_frame_dump(). |
|
|
Un-Key Radio Definition at line 220 of file frame.h. Referenced by ast_frame_dump(). |
|
|
Local ring Definition at line 198 of file frame.h. Referenced by ast_frame_dump(). |
|
|
Remote end is ringing Definition at line 200 of file frame.h. Referenced by __ast_request_and_dial(), ast_dsp_process(), ast_frame_dump(), ast_indicate(), ast_waitfordigit_full(), ast_waitstream(), ast_waitstream_fr(), and ast_waitstream_full(). |
|
|
Make it go off hook Definition at line 206 of file frame.h. Referenced by ast_frame_dump(). |
|
|
Wink Definition at line 214 of file frame.h. Referenced by ast_frame_dump(). |
|
|
ADPCM (IMA) Definition at line 170 of file frame.h. Referenced by ast_best_codec(), ast_rtp_read(), and ast_rtp_write(). |
|
|
Raw A-law data (G.711) Definition at line 166 of file frame.h. Referenced by ast_best_codec(), ast_dsp_process(), ast_rtp_read(), and ast_rtp_write(). |
|
|
G.723.1 compression Definition at line 160 of file frame.h. Referenced by ast_best_codec(), ast_rtp_read(), and ast_rtp_write(). |
|
|
ADPCM (G.726, 32kbps) Definition at line 168 of file frame.h. Referenced by ast_best_codec(), ast_rtp_read(), and ast_rtp_write(). |
|
|
G.729A audio Definition at line 176 of file frame.h. Referenced by ast_best_codec(), ast_rtp_read(), and ast_rtp_write(). |
|
|
GSM compression Definition at line 162 of file frame.h. Referenced by ast_best_codec(), ast_rtp_read(), and ast_rtp_write(). |
|
|
H.261 Video Definition at line 188 of file frame.h. Referenced by ast_rtp_write(). |
|
|
H.263 Video Definition at line 190 of file frame.h. Referenced by ast_rtp_write(). |
|
|
iLBC Free Compression Definition at line 180 of file frame.h. Referenced by ast_best_codec(), ast_rtp_read(), and ast_rtp_write(). |
|
|
JPEG Images |
|
|
LPC10, 180 samples/frame Definition at line 174 of file frame.h. Referenced by ast_best_codec(), ast_rtp_read(), and ast_rtp_write(). |
|
|
Maximum audio format Definition at line 182 of file frame.h. Referenced by ast_closestream(), ast_playstream(), ast_rtp_read(), and ast_writestream(). |
|
|
Max one |
|
|
PNG Images |
|
|
Raw 16-bit Signed Linear (8000 Hz) PCM Definition at line 172 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_play_and_prepend(), ast_play_and_record(), ast_rtp_read(), and ast_rtp_write(). |
|
|
SpeeX Free Compression Definition at line 178 of file frame.h. Referenced by ast_best_codec(), ast_rtp_read(), and ast_rtp_write(). |
|
|
Raw mu-law data (G.711) Definition at line 164 of file frame.h. Referenced by ast_best_codec(), ast_dsp_process(), ast_rtp_read(), and ast_rtp_write(). |
|
|
Definition at line 338 of file frame.h. Referenced by ast_rtp_read(). |
|
|
|
|
|
Comfort Noise frame (subclass is level of CNG in -dBov), body may include zero or more 8-bit quantization coefficients Definition at line 136 of file frame.h. Referenced by ast_read(). |
|
|
A control frame, subclass is AST_CONTROL_* Definition at line 123 of file frame.h. Referenced by __ast_request_and_dial(), ast_channel_bridge(), ast_dsp_process(), ast_fr_fdhangup(), ast_fr_fdread(), ast_frame_dump(), ast_queue_control(), ast_queue_frame(), ast_queue_hangup(), ast_read(), ast_recvchar(), ast_waitfordigit_full(), ast_waitstream(), ast_waitstream_fr(), ast_waitstream_full(), and ast_write(). |
|
|
A DTMF digit, subclass is the digit Definition at line 117 of file frame.h. Referenced by ast_app_getvoice(), ast_channel_bridge(), ast_dsp_process(), ast_dtmf_stream(), ast_frame_dump(), ast_play_and_prepend(), ast_play_and_record(), 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 133 of file frame.h. Referenced by ast_channel_bridge(), ast_frame_dump(), and ast_write(). |
|
|
Inter Asterisk Exchange private frame type Definition at line 127 of file frame.h. Referenced by ast_frame_dump(). |
|
|
Image Frames Definition at line 131 of file frame.h. Referenced by ast_channel_bridge(), and ast_frame_dump(). |
|
|
An empty, useless frame Definition at line 125 of file frame.h. Referenced by ast_channel_masquerade(), ast_do_masquerade(), ast_dsp_process(), ast_frame_dump(), ast_read(), ast_rtcp_read(), ast_rtp_read(), and ast_softhangup_nolock(). |
|
|
Text messages Definition at line 129 of file frame.h. Referenced by ast_channel_bridge(), ast_frame_dump(), ast_recvchar(), and ast_write(). |
|
|
Video frame, maybe?? :) Definition at line 121 of file frame.h. Referenced by ast_channel_bridge(), ast_frame_dump(), ast_play_and_prepend(), ast_play_and_record(), ast_rtp_bridge(), ast_rtp_read(), ast_rtp_write(), ast_write(), and ast_writestream(). |
|
|
Voice data, subclass is AST_FORMAT_* Definition at line 119 of file frame.h. Referenced by __ast_smoother_feed(), ast_app_getvoice(), ast_channel_bridge(), ast_dsp_call_progress(), ast_dsp_digitdetect(), ast_dsp_process(), ast_dsp_silence(), ast_frame_dump(), ast_play_and_prepend(), ast_play_and_record(), ast_prod(), ast_queue_frame(), ast_read(), ast_rtp_bridge(), ast_rtp_read(), ast_rtp_write(), ast_smoother_read(), ast_waitfordigit_full(), ast_waitstream_full(), ast_write(), and ast_writestream(). |
|
|
Definition at line 103 of file frame.h. Referenced by ast_frisolate(), ast_prod(), ast_rtp_read(), and ast_smoother_read(). |
|
|
Beginning frame Definition at line 144 of file frame.h. Referenced by ast_frame_dump(). |
|
|
Data frame Definition at line 142 of file frame.h. Referenced by ast_frame_dump(). |
|
|
End frame Definition at line 146 of file frame.h. Referenced by ast_frame_dump(). |
|
|
Load is complete Definition at line 148 of file frame.h. Referenced by ast_frame_dump(). |
|
|
Reject link request Definition at line 156 of file frame.h. Referenced by ast_frame_dump(). |
|
|
Send URL, and track Definition at line 152 of file frame.h. Referenced by ast_frame_dump(). |
|
|
Peer is unable to support HTML Definition at line 150 of file frame.h. Referenced by ast_frame_dump(). |
|
|
No more HTML linkage Definition at line 154 of file frame.h. Referenced by ast_frame_dump(). |
|
|
Sending a URL Definition at line 140 of file frame.h. Referenced by ast_channel_sendurl(), and ast_frame_dump(). |
|
|
Need the data be free'd? Definition at line 111 of file frame.h. Referenced by ast_frfree(), and ast_frisolate(). |
|
|
Need the header be free'd? Definition at line 109 of file frame.h. Referenced by ast_frdup(), ast_frfree(), and ast_frisolate(). |
|
|
Need the source be free'd? (haha!) Definition at line 113 of file frame.h. Referenced by ast_frfree(), and ast_frisolate(). |
|
|
Definition at line 106 of file frame.h. Referenced by __ast_smoother_feed(). |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Definition at line 392 of file frame.h. Referenced by ast_rtp_write(). |
|
|
Definition at line 394 of file frame.h. Referenced by ast_rtp_write(). |
|
|
|
|
|
Definition at line 226 of file frame.h. Referenced by __ast_smoother_feed(), ast_rtp_write(), and ast_smoother_read(). |
|
||||||||||||||||
|
Definition at line 86 of file frame.c. References AST_FRAME_VOICE, ast_log(), ast_memcpy_byteswap(), AST_MIN_OFFSET, AST_SMOOTHER_FLAG_G729, ast_frame::data, ast_smoother::data, ast_frame::datalen, ast_smoother::delivery, ast_frame::delivery, ast_smoother::flags, ast_smoother::format, ast_frame::frametype, ast_smoother::len, LOG_NOTICE, LOG_WARNING, ast_frame::offset, ast_smoother::opt, ast_smoother::optimizablestream, ast_frame::samples, ast_smoother::samplesperbyte, ast_smoother::size, SMOOTHER_SIZE, and ast_frame::subclass. 00087 { 00088 if (f->frametype != AST_FRAME_VOICE) { 00089 ast_log(LOG_WARNING, "Huh? Can't smooth a non-voice frame!\n"); 00090 return -1; 00091 } 00092 if (!s->format) { 00093 s->format = f->subclass; 00094 s->samplesperbyte = (float)f->samples / (float)f->datalen; 00095 } else if (s->format != f->subclass) { 00096 ast_log(LOG_WARNING, "Smoother was working on %d format frames, now trying to feed %d?\n", s->format, f->subclass); 00097 return -1; 00098 } 00099 if (s->len + f->datalen > SMOOTHER_SIZE) { 00100 ast_log(LOG_WARNING, "Out of smoother space\n"); 00101 return -1; 00102 } 00103 if (((f->datalen == s->size) || ((f->datalen < 10) && (s->flags & AST_SMOOTHER_FLAG_G729))) 00104 && !s->opt && (f->offset >= AST_MIN_OFFSET)) { 00105 if (!s->len) { 00106 /* Optimize by sending the frame we just got 00107 on the next read, thus eliminating the douple 00108 copy */ 00109 s->opt = f; 00110 return 0; 00111 } else { 00112 s->optimizablestream++; 00113 if (s->optimizablestream > 10) { 00114 /* For the past 10 rounds, we have input and output 00115 frames of the correct size for this smoother, yet 00116 we were unable to optimize because there was still 00117 some cruft left over. Lets just drop the cruft so 00118 we can move to a fully optimized path */ 00119 s->len = 0; 00120 s->opt = f; 00121 return 0; 00122 } 00123 } 00124 } else 00125 s->optimizablestream = 0; 00126 if (s->flags & AST_SMOOTHER_FLAG_G729) { 00127 if (s->len % 10) { 00128 ast_log(LOG_NOTICE, "Dropping extra frame of G.729 since we already have a VAD frame at the end\n"); 00129 return 0; 00130 } 00131 } 00132 if (swap) 00133 ast_memcpy_byteswap(s->data+s->len, f->data, f->samples); 00134 else 00135 memcpy(s->data + s->len, f->data, f->datalen); 00136 /* If either side is empty, reset the delivery time */ 00137 if (!s->len || (!f->delivery.tv_sec && !f->delivery.tv_usec) || 00138 (!s->delivery.tv_sec && !s->delivery.tv_usec)) 00139 s->delivery = f->delivery; 00140 s->len += f->datalen; 00141 return 0; 00142 }
|
|
|
Pick the best codec.
Definition at line 233 of file channel.c. References AST_FORMAT_ADPCM, AST_FORMAT_ALAW, AST_FORMAT_G723_1, AST_FORMAT_G726, AST_FORMAT_G729A, AST_FORMAT_GSM, AST_FORMAT_ILBC, AST_FORMAT_LPC10, AST_FORMAT_SLINEAR, AST_FORMAT_SPEEX, AST_FORMAT_ULAW, ast_log(), and LOG_WARNING. Referenced by ast_codec_choose(). 00234 { 00235 /* This just our opinion, expressed in code. We are asked to choose 00236 the best codec to use, given no information */ 00237 int x; 00238 static int prefs[] = 00239 { 00240 /* Okay, ulaw is used by all telephony equipment, so start with it */ 00241 AST_FORMAT_ULAW, 00242 /* Unless of course, you're a silly European, so then prefer ALAW */ 00243 AST_FORMAT_ALAW, 00244 /* Okay, well, signed linear is easy to translate into other stuff */ 00245 AST_FORMAT_SLINEAR, 00246 /* G.726 is standard ADPCM */ 00247 AST_FORMAT_G726, 00248 /* ADPCM has great sound quality and is still pretty easy to translate */ 00249 AST_FORMAT_ADPCM, 00250 /* Okay, we're down to vocoders now, so pick GSM because it's small and easier to 00251 translate and sounds pretty good */ 00252 AST_FORMAT_GSM, 00253 /* iLBC is not too bad */ 00254 AST_FORMAT_ILBC, 00255 /* Speex is free, but computationally more expensive than GSM */ 00256 AST_FORMAT_SPEEX, 00257 /* Ick, LPC10 sounds terrible, but at least we have code for it, if you're tacky enough 00258 to use it */ 00259 AST_FORMAT_LPC10, 00260 /* G.729a is faster than 723 and slightly less expensive */ 00261 AST_FORMAT_G729A, 00262 /* Down to G.723.1 which is proprietary but at least designed for voice */ 00263 AST_FORMAT_G723_1, 00264 }; 00265 00266 00267 for (x=0;x<sizeof(prefs) / sizeof(prefs[0]); x++) 00268 if (fmts & prefs[x]) 00269 return prefs[x]; 00270 ast_log(LOG_WARNING, "Don't know any of 0x%x formats\n", fmts); 00271 return 0; 00272 }
|
|
|
Get a name from a format.
Definition at line 529 of file frame.c. 00529 { 00530 int x = 0; 00531 char *ret = "unknown"; 00532 for (x = 0 ; x < sizeof(AST_FORMAT_LIST) / sizeof(struct ast_format_list) ; x++) { 00533 if(AST_FORMAT_LIST[x].visible && AST_FORMAT_LIST[x].bits == codec) { 00534 ret = AST_FORMAT_LIST[x].desc; 00535 break; 00536 } 00537 } 00538 return ret; 00539 }
|
|
||||||||||||||||
|
Definition at line 952 of file frame.c. References ast_best_codec(), ast_format_list::bits, and ast_codec_pref::order. 00953 { 00954 size_t size = 0; 00955 int x = 0, ret = 0, slot = 0; 00956 00957 size = sizeof(AST_FORMAT_LIST) / sizeof(struct ast_format_list); 00958 for (x = 0; x < size; x++) { 00959 slot = pref->order[x]; 00960 00961 if(!slot) 00962 break; 00963 if ( formats & AST_FORMAT_LIST[slot-1].bits ) { 00964 ret = AST_FORMAT_LIST[slot-1].bits; 00965 break; 00966 } 00967 } 00968 if(ret) 00969 return ret; 00970 00971 return find_best ? ast_best_codec(formats) : 0; 00972 }
|
|
||||||||||||
|
Definition at line 923 of file frame.c. References ast_codec_pref_remove(), ast_format_list::bits, and ast_codec_pref::order. Referenced by ast_parse_allow_disallow(). 00924 { 00925 size_t size = 0; 00926 int x = 0, newindex = -1; 00927 00928 ast_codec_pref_remove(pref, format); 00929 size = sizeof(AST_FORMAT_LIST) / sizeof(struct ast_format_list); 00930 00931 for (x = 0; x < size; x++) { 00932 if(AST_FORMAT_LIST[x].bits == format) { 00933 newindex = x + 1; 00934 break; 00935 } 00936 } 00937 00938 if(newindex) { 00939 for (x = 0; x < size; x++) { 00940 if(!pref->order[x]) { 00941 pref->order[x] = newindex; 00942 break; 00943 } 00944 } 00945 } 00946 00947 return x; 00948 }
|
|
||||||||||||
|
Definition at line 884 of file frame.c. References ast_format_list::bits, and ast_codec_pref::order. Referenced by ast_codec_pref_string(). 00885 { 00886 int slot = 0; 00887 00888 00889 if((index >= 0) && (index < sizeof(pref->order))) { 00890 slot = pref->order[index]; 00891 } 00892 00893 return slot ? AST_FORMAT_LIST[slot-1].bits : 0; 00894 }
|
|
|
|
|
||||||||||||
|
Definition at line 897 of file frame.c. References ast_format_list::bits, and ast_codec_pref::order. Referenced by ast_codec_pref_append(), and ast_parse_allow_disallow(). 00898 { 00899 struct ast_codec_pref oldorder; 00900 int x=0, y=0; 00901 size_t size = 0; 00902 int slot = 0; 00903 00904 if(!pref->order[0]) 00905 return; 00906 00907 size = sizeof(AST_FORMAT_LIST) / sizeof(struct ast_format_list); 00908 00909 memcpy(&oldorder,pref,sizeof(struct ast_codec_pref)); 00910 memset(pref,0,sizeof(struct ast_codec_pref)); 00911 00912 for (x = 0; x < size; x++) { 00913 slot = oldorder.order[x]; 00914 if(! slot) 00915 break; 00916 if(AST_FORMAT_LIST[slot-1].bits != format) 00917 pref->order[y++] = slot; 00918 } 00919 00920 }
|
|
||||||||||||||||||||
|
Definition at line 826 of file frame.c. References ast_codec_pref::order. 00827 { 00828 int x = 0, differential = 65, mem = 0; 00829 char *from = NULL, *to = NULL; 00830 00831 if(right) { 00832 from = pref->order; 00833 to = buf; 00834 mem = size; 00835 } else { 00836 to = pref->order; 00837 from = buf; 00838 mem = 32; 00839 } 00840 00841 memset(to, 0, mem); 00842 for (x = 0; x < 32 ; x++) { 00843 if(!from[x]) 00844 break; 00845 to[x] = right ? (from[x] + differential) : (from[x] - differential); 00846 } 00847 }
|
|
||||||||||||||||
|
Definition at line 849 of file frame.c. References ast_codec_pref_index(), and ast_getformatname(). 00850 { 00851 int x = 0, codec = 0; 00852 size_t total_len = 0, slen = 0; 00853 char *formatname = 0; 00854 00855 memset(buf,0,size); 00856 total_len = size; 00857 buf[0] = '('; 00858 total_len--; 00859 for(x = 0; x < 32 ; x++) { 00860 if(total_len <= 0) 00861 break; 00862 if(!(codec = ast_codec_pref_index(pref,x))) 00863 break; 00864 if((formatname = ast_getformatname(codec))) { 00865 slen = strlen(formatname); 00866 if(slen > total_len) 00867 break; 00868 strncat(buf,formatname,total_len); 00869 total_len -= slen; 00870 } 00871 if(total_len && x < 31 && ast_codec_pref_index(pref , x + 1)) { 00872 strncat(buf,"|",total_len); 00873 total_len--; 00874 } 00875 } 00876 if(total_len) { 00877 strncat(buf,")",total_len); 00878 total_len--; 00879 } 00880 00881 return size - total_len; 00882 }
|
|
|
Sends a hangup to an fd.
Definition at line 396 of file frame.c. References AST_CONTROL_HANGUP, ast_fr_fdwrite(), and AST_FRAME_CONTROL. 00397 { 00398 struct ast_frame hangup = { 00399 AST_FRAME_CONTROL, 00400 AST_CONTROL_HANGUP 00401 }; 00402 return ast_fr_fdwrite(fd, &hangup); 00403 }
|
|
|
Reads a frame from an fd.
Definition at line 334 of file frame.c. References AST_CONTROL_HANGUP, AST_FRAME_CONTROL, ast_frisolate(), ast_log(), ast_frame::data, ast_frame::datalen, ast_frame::frametype, LOG_WARNING, ast_frame::mallocd, ast_frame::offset, ast_frame::src, and ast_frame::subclass. 00335 { 00336 char buf[65536]; 00337 int res; 00338 int ttl = sizeof(struct ast_frame); 00339 struct ast_frame *f = (struct ast_frame *)buf; 00340 /* Read a frame directly from there. They're always in the 00341 right format. */ 00342 00343 while(ttl) { 00344 res = read(fd, buf, ttl); 00345 if (res < 0) { 00346 ast_log(LOG_WARNING, "Bad read on %d: %s\n", fd, strerror(errno)); 00347 return NULL; 00348 } 00349 ttl -= res; 00350 } 00351 00352 /* read the frame header */ 00353 f->mallocd = 0; 00354 /* Re-write data position */ 00355 f->data = buf + sizeof(struct ast_frame); 00356 f->offset = 0; 00357 /* Forget about being mallocd */ 00358 f->mallocd = 0; 00359 /* Re-write the source */ 00360 f->src = (char *)__FUNCTION__; 00361 if (f->datalen > sizeof(buf) - sizeof(struct ast_frame)) { 00362 /* Really bad read */ 00363 ast_log(LOG_WARNING, "Strange read (%d bytes)\n", f->datalen); 00364 return NULL; 00365 } 00366 if (f->datalen) { 00367 if ((res = read(fd, f->data, f->datalen)) != f->datalen) { 00368 /* Bad read */ 00369 ast_log(LOG_WARNING, "How very strange, expected %d, got %d\n", f->datalen, res); 00370 return NULL; 00371 } 00372 } 00373 if ((f->frametype == AST_FRAME_CONTROL) && (f->subclass == AST_CONTROL_HANGUP)) { 00374 return NULL; 00375 } 00376 return ast_frisolate(f); 00377 }
|
|
||||||||||||
|
Writes a frame to an fd.
Definition at line 382 of file frame.c. References ast_log(), ast_frame::data, ast_frame::datalen, and LOG_WARNING. Referenced by ast_fr_fdhangup(). 00383 { 00384 /* Write the frame exactly */ 00385 if (write(fd, frame, sizeof(struct ast_frame)) != sizeof(struct ast_frame)) { 00386 ast_log(LOG_WARNING, "Write error: %s\n", strerror(errno)); 00387 return -1; 00388 } 00389 if (write(fd, frame->data, frame->datalen) != frame->datalen) { 00390 ast_log(LOG_WARNING, "Write error: %s\n", strerror(errno)); 00391 return -1; 00392 } 00393 return 0; 00394 }
|
|
||||||||||||||||
|
Definition at line 627 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(). 00628 { 00629 char *n = "unknown"; 00630 char ftype[40] = "Unknown Frametype"; 00631 char cft[80]; 00632 char subclass[40] = "Unknown Subclass"; 00633 char csub[80]; 00634 char moreinfo[40] = ""; 00635 char cn[60]; 00636 char cp[40]; 00637 char cmn[40]; 00638 if (name) 00639 n = name; 00640 if (!f) { 00641 ast_verbose("%s [ %s (NULL) ] [%s]\n", 00642 term_color(cp, prefix, COLOR_BRMAGENTA, COLOR_BLACK, sizeof(cp)), 00643 term_color(cft, "HANGUP", COLOR_BRRED, COLOR_BLACK, sizeof(cft)), 00644 term_color(cn, n, COLOR_YELLOW, COLOR_BLACK, sizeof(cn))); 00645 return; 00646 } 00647 /* XXX We should probably print one each of voice and video when the format changes XXX */ 00648 if (f->frametype == AST_FRAME_VOICE) 00649 return; 00650 if (f->frametype == AST_FRAME_VIDEO) 00651 return; 00652 switch(f->frametype) { 00653 case AST_FRAME_DTMF: 00654 strcpy(ftype, "DTMF"); 00655 subclass[0] = f->subclass; 00656 subclass[1] = '\0'; 00657 break; 00658 case AST_FRAME_CONTROL: 00659 strcpy(ftype, "Control"); 00660 switch(f->subclass) { 00661 case AST_CONTROL_HANGUP: 00662 strcpy(subclass, "Hangup"); 00663 break; 00664 case AST_CONTROL_RING: 00665 strcpy(subclass, "Ring"); 00666 break; 00667 case AST_CONTROL_RINGING: 00668 strcpy(subclass, "Ringing"); 00669 break; 00670 case AST_CONTROL_ANSWER: 00671 strcpy(subclass, "Answer"); 00672 break; 00673 case AST_CONTROL_BUSY: 00674 strcpy(subclass, "Busy"); 00675 break; 00676 case AST_CONTROL_TAKEOFFHOOK: 00677 strcpy(subclass, "Take Off Hook"); 00678 break; 00679 case AST_CONTROL_OFFHOOK: 00680 strcpy(subclass, "Line Off Hook"); 00681 break; 00682 case AST_CONTROL_CONGESTION: 00683 strcpy(subclass, "Congestion"); 00684 break; 00685 case AST_CONTROL_FLASH: 00686 strcpy(subclass, "Flash"); 00687 break; 00688 case AST_CONTROL_WINK: 00689 strcpy(subclass, "Wink"); 00690 break; 00691 case AST_CONTROL_OPTION: 00692 strcpy(subclass, "Option"); 00693 break; 00694 case AST_CONTROL_RADIO_KEY: 00695 strcpy(subclass, "Key Radio"); 00696 break; 00697 case AST_CONTROL_RADIO_UNKEY: 00698 strcpy(subclass, "Unkey Radio"); 00699 break; 00700 case -1: 00701 strcpy(subclass, "Stop generators"); 00702 break; 00703 default: 00704 snprintf(subclass, sizeof(subclass), "Unknown control '%d'", f->subclass); 00705 } 00706 break; 00707 case AST_FRAME_NULL: 00708 strcpy(ftype, "Null Frame"); 00709 strcpy(subclass, "N/A"); 00710 break; 00711 case AST_FRAME_IAX: 00712 /* Should never happen */ 00713 strcpy(ftype, "IAX Specific"); 00714 snprintf(subclass, sizeof(subclass), "IAX Frametype %d", f->subclass); 00715 break; 00716 case AST_FRAME_TEXT: 00717 strcpy(ftype, "Text"); 00718 strcpy(subclass, "N/A"); 00719 strncpy(moreinfo, f->data, sizeof(moreinfo) - 1); 00720 break; 00721 case AST_FRAME_IMAGE: 00722 strcpy(ftype, "Image"); 00723 snprintf(subclass, sizeof(subclass), "Image format %s\n", ast_getformatname(f->subclass)); 00724 break; 00725 case AST_FRAME_HTML: 00726 strcpy(ftype, "HTML"); 00727 switch(f->subclass) { 00728 case AST_HTML_URL: 00729 strcpy(subclass, "URL"); 00730 strncpy(moreinfo, f->data, sizeof(moreinfo) - 1); 00731 break; 00732 case AST_HTML_DATA: 00733 strcpy(subclass, "Data"); 00734 break; 00735 case AST_HTML_BEGIN: 00736 strcpy(subclass, "Begin"); 00737 break; 00738 case AST_HTML_END: 00739 strcpy(subclass, "End"); 00740 break; 00741 case AST_HTML_LDCOMPLETE: 00742 strcpy(subclass, "Load Complete"); 00743 break; 00744 case AST_HTML_NOSUPPORT: 00745 strcpy(subclass, "No Support"); 00746 break; 00747 case AST_HTML_LINKURL: 00748 strcpy(subclass, "Link URL"); 00749 strncpy(moreinfo, f->data, sizeof(moreinfo) - 1); 00750 break; 00751 case AST_HTML_UNLINK: 00752 strcpy(subclass, "Unlink"); 00753 break; 00754 case AST_HTML_LINKREJECT: 00755 strcpy(subclass, "Link Reject"); 00756 break; 00757 default: 00758 snprintf(subclass, sizeof(subclass), "Unknown HTML frame '%d'\n", f->subclass); 00759 break; 00760 } 00761 break; 00762 default: 00763 snprintf(ftype, sizeof(ftype), "Unknown Frametype '%d'", f->frametype); 00764 } 00765 if (!ast_strlen_zero(moreinfo)) 00766 ast_verbose("%s [ TYPE: %s (%d) SUBCLASS: %s (%d) '%s' ] [%s]\n", 00767 term_color(cp, prefix, COLOR_BRMAGENTA, COLOR_BLACK, sizeof(cp)), 00768 term_color(cft, ftype, COLOR_BRRED, COLOR_BLACK, sizeof(cft)), 00769 f->frametype, 00770 term_color(csub, subclass, COLOR_BRCYAN, COLOR_BLACK, sizeof(csub)), 00771 f->subclass, 00772 term_color(cmn, moreinfo, COLOR_BRGREEN, COLOR_BLACK, sizeof(cmn)), 00773 term_color(cn, n, COLOR_YELLOW, COLOR_BLACK, sizeof(cn))); 00774 else 00775 ast_verbose("%s [ TYPE: %s (%d) SUBCLASS: %s (%d) ] [%s]\n", 00776 term_color(cp, prefix, COLOR_BRMAGENTA, COLOR_BLACK, sizeof(cp)), 00777 term_color(cft, ftype, COLOR_BRRED, COLOR_BLACK, sizeof(cft)), 00778 f->frametype, 00779 term_color(csub, subclass, COLOR_BRCYAN, COLOR_BLACK, sizeof(csub)), 00780 f->subclass, 00781 term_color(cn, n, COLOR_YELLOW, COLOR_BLACK, sizeof(cn))); 00782 00783 }
|
|
|
Copies a frame.
Definition at line 296 of file frame.c. References AST_MALLOCD_HDR, ast_frame::data, ast_frame::datalen, ast_frame::delivery, ast_frame::frametype, malloc, ast_frame::mallocd, ast_frame::next, ast_frame::offset, ast_frame::prev, ast_frame::samples, ast_frame::src, and ast_frame::subclass. Referenced by ast_queue_frame(), and ast_rtp_write(). 00297 { 00298 struct ast_frame *out; 00299 int len, srclen = 0; 00300 void *buf; 00301 /* Start with standard stuff */ 00302 len = sizeof(struct ast_frame) + AST_FRIENDLY_OFFSET + f->datalen; 00303 /* If we have a source, add space for it */ 00304 if (f->src) 00305 srclen = strlen(f->src); 00306 if (srclen > 0) 00307 len += srclen + 1; 00308 buf = malloc(len); 00309 if (!buf) 00310 return NULL; 00311 out = buf; 00312 /* Set us as having malloc'd header only, so it will eventually 00313 get freed. */ 00314 out->frametype = f->frametype; 00315 out->subclass = f->subclass; 00316 out->datalen = f->datalen; 00317 out->samples = f->samples; 00318 out->delivery = f->delivery; 00319 out->mallocd = AST_MALLOCD_HDR; 00320 out->offset = AST_FRIENDLY_OFFSET; 00321 out->data = buf + sizeof(struct ast_frame) + AST_FRIENDLY_OFFSET; 00322 if (srclen > 0) { 00323 out->src = out->data + f->datalen; 00324 /* Must have space since we allocated for it */ 00325 strcpy(out->src, f->src); 00326 } else 00327 out->src = NULL; 00328 out->prev = NULL; 00329 out->next = NULL; 00330 memcpy(out->data, f->data, out->datalen); 00331 return out; 00332 }
|
|
|
|
Copies a frame.
Definition at line 255 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::offset, ast_frame::samples, ast_frame::src, strdup, and ast_frame::subclass. Referenced by ast_fr_fdread(). 00256 { 00257 struct ast_frame *out; 00258 if (!(fr->mallocd & AST_MALLOCD_HDR)) { 00259 /* Allocate a new header if needed */ 00260 out = ast_frame_header_new(); 00261 if (!out) { 00262 ast_log(LOG_WARNING, "Out of memory\n"); 00263 return NULL; 00264 } 00265 out->frametype = fr->frametype; 00266 out->subclass = fr->subclass; 00267 out->datalen = 0; 00268 out->samples = fr->samples; 00269 out->offset = 0; 00270 out->src = NULL; 00271 out->data = NULL; 00272 } else { 00273 out = fr; 00274 } 00275 if (!(fr->mallocd & AST_MALLOCD_SRC)) { 00276 if (fr->src) 00277 out->src = strdup(fr->src); 00278 } else 00279 out->src = fr->src; 00280 if (!(fr->mallocd & AST_MALLOCD_DATA)) { 00281 out->data = malloc(fr->datalen + AST_FRIENDLY_OFFSET); 00282 if (!out->data) { 00283 free(out); 00284 ast_log(LOG_WARNING, "Out of memory\n"); 00285 return NULL; 00286 } 00287 out->data += AST_FRIENDLY_OFFSET; 00288 out->offset = AST_FRIENDLY_OFFSET; 00289 out->datalen = fr->datalen; 00290 memcpy(out->data, fr->data, fr->datalen); 00291 } 00292 out->mallocd = AST_MALLOCD_HDR | AST_MALLOCD_SRC | AST_MALLOCD_DATA; 00293 return out; 00294 }
|
|
|
Definition at line 447 of file frame.c. 00447 { 00448 *size = (sizeof(AST_FORMAT_LIST) / sizeof(struct ast_format_list)); 00449 return AST_FORMAT_LIST; 00450 }
|
|
|
Definition at line 443 of file frame.c.
|
|
|
Definition at line 511 of file frame.c. Referenced by ast_parse_allow_disallow(). 00512 { 00513 int x = 0, all = 0, format = 0; 00514 00515 all = strcasecmp(name, "all") ? 0 : 1; 00516 for (x = 0 ; x < sizeof(AST_FORMAT_LIST) / sizeof(struct ast_format_list) ; x++) { 00517 if(AST_FORMAT_LIST[x].visible && (all || 00518 !strcasecmp(AST_FORMAT_LIST[x].name,name) || 00519 !strcasecmp(AST_FORMAT_LIST[x].name,ast_expand_codec_alias(name)))) { 00520 format |= AST_FORMAT_LIST[x].bits; 00521 if(!all) 00522 break; 00523 } 00524 } 00525 00526 return format; 00527 }
|
|
|
Get the name of a format.
Definition at line 452 of file frame.c. Referenced by ast_codec_pref_string(), ast_dsp_process(), ast_frame_dump(), ast_play_and_prepend(), ast_play_and_record(), 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(), ast_unregister_translator(), and ast_writestream(). 00453 { 00454 int x = 0; 00455 char *ret = "unknown"; 00456 for (x = 0 ; x < sizeof(AST_FORMAT_LIST) / sizeof(struct ast_format_list) ; x++) { 00457 if(AST_FORMAT_LIST[x].visible && AST_FORMAT_LIST[x].bits == format) { 00458 ret = AST_FORMAT_LIST[x].name; 00459 break; 00460 } 00461 } 00462 return ret; 00463 }
|
|
||||||||||||||||
|
Get the names of a set of formats.
Definition at line 465 of file frame.c. References ast_format_list::bits, ast_format_list::name, and ast_format_list::visible. 00465 { 00466 00467 int x = 0; 00468 unsigned len; 00469 char *end = buf; 00470 char *start = buf; 00471 if (!size) return buf; 00472 snprintf(end, size, "0x%x (", format); 00473 len = strlen(end); 00474 end += len; 00475 size -= len; 00476 start = end; 00477 for (x = 0 ; x < sizeof(AST_FORMAT_LIST) / sizeof(struct ast_format_list) ; x++) { 00478 if (AST_FORMAT_LIST[x].visible && (AST_FORMAT_LIST[x].bits & format)) { 00479 snprintf(end, size,"%s|",AST_FORMAT_LIST[x].name); 00480 len = strlen(end); 00481 end += len; 00482 size -= len; 00483 } 00484 } 00485 if (start == end) 00486 snprintf(start, size, "nothing)"); 00487 else if (size > 1) 00488 *(end -1) = ')'; 00489 return buf; 00490 }
|
|
||||||||||||||||
|
Definition at line 405 of file frame.c. Referenced by __ast_smoother_feed(). 00406 { 00407 int i; 00408 unsigned short *dst_s = dst; 00409 unsigned short *src_s = src; 00410 00411 for (i=0; i<samples; i++) 00412 dst_s[i] = (src_s[i]<<8)|(src_s[i]>>8); 00413 }
|
|
||||||||||||||||||||
|
Definition at line 974 of file frame.c. References ast_codec_pref_append(), ast_codec_pref_remove(), ast_getformatbyname(), ast_log(), and LOG_WARNING. 00975 { 00976 int format_i = 0; 00977 char *next_format = NULL, *last_format = NULL; 00978 00979 last_format = ast_strdupa(list); 00980 while(last_format) { 00981 if((next_format = strchr(last_format, ','))) { 00982 *next_format = '\0'; 00983 next_format++; 00984 } 00985 if ((format_i = ast_getformatbyname(last_format)) > 0) { 00986 if (mask) { 00987 if (allowing) 00988 (*mask) |= format_i; 00989 else 00990 (*mask) &= ~format_i; 00991 } 00992 /* can't consider 'all' a prefered codec*/ 00993 if(pref && strcasecmp(last_format, "all")) { 00994 if(allowing) 00995 ast_codec_pref_append(pref, format_i); 00996 else 00997 ast_codec_pref_remove(pref, format_i); 00998 } else if(!allowing) /* disallow all must clear your prefs or it makes no sense */ 00999 memset(pref, 0, sizeof(struct ast_codec_pref)); 01000 } else 01001 ast_log(LOG_WARNING, "Cannot %s unknown format '%s'\n", allowing ? "allow" : "disallow", last_format); 01002 01003 last_format = next_format; 01004 } 01005 }
|
|
|
Definition at line 198 of file frame.c. References free. Referenced by ast_rtp_destroy(), and ast_rtp_write(). 00199 { 00200 free(s); 00201 }
|
|
|
Definition at line 76 of file frame.c. References ast_smoother::flags. 00077 { 00078 return s->flags; 00079 }
|
|
|
Definition at line 65 of file frame.c. References ast_smoother_reset(), malloc, and s. Referenced by ast_rtp_write(). 00066 { 00067 struct ast_smoother *s; 00068 if (size < 1) 00069 return NULL; 00070 s = malloc(sizeof(struct ast_smoother)); 00071 if (s) 00072 ast_smoother_reset(s, size); 00073 return s; 00074 }
|
|
|
Definition at line 144 of file frame.c. References AST_FRAME_VOICE, AST_FRIENDLY_OFFSET, ast_log(), AST_SMOOTHER_FLAG_G729, ast_smoother::data, ast_frame::data, ast_frame::datalen, ast_smoother::delivery, ast_frame::delivery, ast_smoother::f, ast_smoother::flags, ast_smoother::format, ast_smoother::framedata, ast_frame::frametype, ast_smoother::len, LOG_WARNING, ast_frame::offset, ast_smoother::opt, ast_frame::samples, ast_smoother::samplesperbyte, ast_smoother::size, and ast_frame::subclass. Referenced by ast_rtp_write(). 00145 { 00146 struct ast_frame *opt; 00147 int len; 00148 /* IF we have an optimization frame, send it */ 00149 if (s->opt) { 00150 if (s->opt->offset < AST_FRIENDLY_OFFSET) 00151 ast_log(LOG_WARNING, "Returning a frame of inappropriate offset (%d).", 00152 s->opt->offset); 00153 opt = s->opt; 00154 s->opt = NULL; 00155 return opt; 00156 } 00157 00158 /* Make sure we have enough data */ 00159 if (s->len < s->size) { 00160 /* Or, if this is a G.729 frame with VAD on it, send it immediately anyway */ 00161 if (!((s->flags & AST_SMOOTHER_FLAG_G729) && (s->size % 10))) 00162 return NULL; 00163 } 00164 len = s->size; 00165 if (len > s->len) 00166 len = s->len; 00167 /* Make frame */ 00168 s->f.frametype = AST_FRAME_VOICE; 00169 s->f.subclass = s->format; 00170 s->f.data = s->framedata + AST_FRIENDLY_OFFSET; 00171 s->f.offset = AST_FRIENDLY_OFFSET; 00172 s->f.datalen = len; 00173 /* Samples will be improper given VAD, but with VAD the concept really doesn't even exist */ 00174 s->f.samples = len * s->samplesperbyte; 00175 s->f.delivery = s->delivery; 00176 /* Fill Data */ 00177 memcpy(s->f.data, s->data, len); 00178 s->len -= len; 00179 /* Move remaining data to the front if applicable */ 00180 if (s->len) { 00181 /* In principle this should all be fine because if we are sending 00182 G.729 VAD, the next timestamp will take over anyawy */ 00183 memmove(s->data, s->data + len, s->len); 00184 if (s->delivery.tv_sec || s->delivery.tv_usec) { 00185 /* If we have delivery time, increment it, otherwise, leave it at 0 */ 00186 s->delivery.tv_sec += (len * s->samplesperbyte) / 8000.0; 00187 s->delivery.tv_usec += (((int)(len * s->samplesperbyte)) % 8000) * 125; 00188 if (s->delivery.tv_usec > 1000000) { 00189 s->delivery.tv_usec -= 1000000; 00190 s->delivery.tv_sec += 1; 00191 } 00192 } 00193 } 00194 /* Return frame */ 00195 return &s->f; 00196 }
|
|
||||||||||||
|
Definition at line 59 of file frame.c. References ast_smoother::size. Referenced by ast_smoother_new(). 00060 { 00061 memset(s, 0, sizeof(struct ast_smoother)); 00062 s->size = size; 00063 }
|
|
||||||||||||
|
Definition at line 81 of file frame.c. References ast_smoother::flags. Referenced by ast_rtp_write(). 00082 { 00083 s->flags = flags; 00084 }
|
1.4.4