41 unsigned char g729_filler[] = {
42 114, 170, 250, 103, 54, 211, 203, 194, 94, 64,
43 229, 127, 79, 96, 207, 82, 216, 110, 245, 81,
44 114, 170, 250, 103, 54, 211, 203, 194, 94, 64,
45 229, 127, 79, 96, 207, 82, 216, 110, 245, 81,
46 114, 170, 250, 103, 54, 211, 203, 194, 94, 64,
47 229, 127, 79, 96, 207, 82, 216, 110, 245, 81,
48 114, 170, 250, 103, 54, 211, 203, 194, 94, 64,
49 229, 127, 79, 96, 207, 82, 216, 110, 245, 81,
50 114, 170, 250, 103, 54, 211, 203, 194, 94, 64,
51 229, 127, 79, 96, 207, 82, 216, 110, 245, 81,
52 114, 170, 250, 103, 54, 211, 203, 194, 94, 64,
53 229, 127, 79, 96, 207, 82, 216, 110, 245, 81,
54 114, 170, 250, 103, 54, 211, 203, 194, 94, 64,
55 229, 127, 79, 96, 207, 82, 216, 110, 245, 81
59 if (read_impl->ianacode == 18 ||
switch_stristr(
"g729", read_impl->iananame)) {
60 memcpy(data, g729_filler, len);
72 int need_codec, perfect, do_bugs = 0, do_resample = 0, is_cng = 0, tap_only = 0;
74 unsigned int flag = 0;
91 if (!(session->read_codec && session->read_codec->implementation &&
switch_core_codec_ready(session->read_codec))) {
126 for(i = 0; i < 2; i++) {
127 if (session->dmachine[i]) {
142 need_codec = perfect = 0;
146 if (session->read_codec && !session->track_id && session->track_duration) {
147 if (session->read_frame_count == 0) {
151 session->read_frame_count = (session->read_impl.samples_per_second / session->read_impl.samples_per_packet) * session->track_duration;
161 session->read_frame_count--;
167 switch_yield(session->read_impl.microseconds_per_packet);
172 if (session->endpoint_interface->io_routines->read_frame) {
175 if ((status = session->endpoint_interface->io_routines->read_frame(session, frame, flags, stream_id)) ==
SWITCH_STATUS_SUCCESS) {
176 for (ptr = session->event_hooks.
read_frame; ptr; ptr = ptr->
next) {
230 if (!(session->read_codec && (*frame)->codec && (*frame)->codec->implementation) &&
switch_core_codec_ready((*frame)->codec)) {
242 for (bp = session->bugs; bp; bp = bp->
next) {
259 if ((*frame)->codec && (*frame)->codec->implementation &&
260 (*frame)->codec->implementation->encoded_bytes_per_packet &&
261 (*frame)->datalen != (*frame)->codec->implementation->encoded_bytes_per_packet) {
285 codec_impl = *(*frame)->codec->implementation;
287 if (session->read_codec->implementation->impl_id != codec_impl.
impl_id) {
303 for (bp = session->bugs; bp; bp = bp->
next) {
318 if (bp->
ready && (*frame)->codec && (*frame)->codec->implementation && (*frame)->codec->implementation->encoded_bytes_per_packet) {
325 tmp_frame.
codec = (*frame)->codec;
326 tmp_frame.
datalen = (*frame)->codec->implementation->encoded_bytes_per_packet;
327 tmp_frame.
samples = (*frame)->codec->implementation->samples_per_packet;
328 tmp_frame.
channels = (*frame)->codec->implementation->number_of_channels;
329 tmp_frame.
data = data;
356 }
else if (session->bugs && !need_codec) {
362 if (!session->bugs && !session->plc) {
364 unsigned int other_session_bugs = 0;
369 other_session_bugs = 1;
375 if (!other_session_bugs) {
420 if (read_frame->
codec || is_cng) {
421 session->raw_read_frame.datalen = session->raw_read_frame.buflen;
432 session->raw_read_frame.timestamp = 0;
434 session->raw_read_frame.samples = session->raw_read_frame.datalen /
sizeof(int16_t) / session->read_impl.number_of_channels;
436 read_frame = &session->raw_read_frame;
442 if (!session->bugs) {
458 use_codec = &session->bug_codec;
463 if (!session->bugs) {
467 if (!do_bugs)
goto done;
473 session->plc = plc_init(NULL);
478 session->raw_read_frame.samples = session->raw_read_frame.datalen /
sizeof(int16_t) / session->read_impl.number_of_channels;
479 session->raw_read_frame.channels = session->read_impl.number_of_channels;
480 memset(session->raw_read_frame.data, 255, session->raw_read_frame.datalen);
488 codec = read_frame->
codec;
497 session->read_codec->cur_frame = read_frame;
502 session->read_impl.actual_samples_per_second,
503 session->raw_read_frame.data, &session->raw_read_frame.datalen, &session->raw_read_frame.rate,
511 session->raw_read_frame.samples = session->raw_read_frame.datalen / 2;
514 session->read_codec->cur_frame = NULL;
522 plc_fillin(session->plc, session->raw_read_frame.data, session->raw_read_frame.datalen / 2);
525 plc_rx(session->plc, session->raw_read_frame.data, session->raw_read_frame.datalen / 2);
538 if (session->raw_read_frame.channels != session->read_impl.number_of_channels) {
539 uint32_t rlen = session->raw_read_frame.datalen / 2 / session->raw_read_frame.channels;
540 switch_mux_channels((int16_t *) session->raw_read_frame.data, rlen, session->raw_read_frame.channels, session->read_impl.number_of_channels);
541 session->raw_read_frame.datalen = rlen * 2 * session->read_impl.number_of_channels;
542 session->raw_read_frame.samples = session->raw_read_frame.datalen / 2;
543 session->raw_read_frame.channels = session->read_impl.number_of_channels;
549 if (!session->read_resampler) {
554 session->read_impl.actual_samples_per_second,
556 session->read_impl.number_of_channels);
574 session->raw_read_frame.samples = session->raw_read_frame.datalen /
sizeof(int16_t) / session->read_impl.number_of_channels;
575 session->raw_read_frame.channels = session->read_impl.number_of_channels;
576 session->raw_read_frame.rate = read_frame->
rate;
578 session->raw_read_frame.timestamp = 0;
580 session->raw_read_frame.timestamp = read_frame->
timestamp;
582 session->raw_read_frame.ssrc = read_frame->
ssrc;
583 session->raw_read_frame.seq = read_frame->
seq;
584 session->raw_read_frame.m = read_frame->
m;
585 session->raw_read_frame.payload = read_frame->
payload;
586 session->raw_read_frame.flags = 0;
588 session->raw_read_frame.flags |=
SFF_PLC;
590 read_frame = &session->raw_read_frame;
593 if (session->read_resampler) {
613 session->raw_read_frame.samples = session->raw_read_frame.datalen /
sizeof(int16_t) / session->read_impl.number_of_channels;
614 session->raw_read_frame.channels = session->read_impl.number_of_channels;
615 session->raw_read_frame.timestamp = read_frame->
timestamp;
616 session->raw_read_frame.rate = read_frame->
rate;
617 session->raw_read_frame.ssrc = read_frame->
ssrc;
618 session->raw_read_frame.seq = read_frame->
seq;
619 session->raw_read_frame.m = read_frame->
m;
620 session->raw_read_frame.payload = read_frame->
payload;
621 session->raw_read_frame.flags = 0;
623 session->raw_read_frame.flags |=
SFF_PLC;
626 read_frame = &session->raw_read_frame;
634 session->read_codec->codec_interface->interface_name, status);
636 if (++session->decoder_errors < 10) {
643 session->decoder_errors = 0;
652 for (bp = session->bugs; bp; bp = bp->
next) {
703 for (bp = session->bugs; bp; bp = bp->
next) {
727 int bytes = read_frame->
datalen;
728 uint32_t datalen = 0;
731 memcpy(data, read_frame->
data, read_frame->
datalen);
758 if (do_bugs || tap_only) {
762 if (session->read_codec) {
763 if (session->read_resampler) {
764 short *data = read_frame->
data;
767 memcpy(data, session->read_resampler->to, session->read_resampler->to_len * 2 * session->read_resampler->channels);
768 read_frame->
samples = session->read_resampler->to_len;
769 read_frame->
channels = session->read_resampler->channels;
770 read_frame->
datalen = session->read_resampler->to_len * 2 * session->read_resampler->channels;
771 read_frame->
rate = session->read_resampler->to_rate;
775 if (read_frame->
datalen == session->read_impl.decoded_bytes_per_packet) {
778 if (!session->raw_read_buffer) {
779 switch_size_t bytes = session->read_impl.decoded_bytes_per_packet;
781 (uint32_t) bytes, (uint32_t) (*frame)->datalen);
791 if (perfect ||
switch_buffer_inuse(session->raw_read_buffer) >= session->read_impl.decoded_bytes_per_packet) {
793 enc_frame = read_frame;
794 session->raw_read_frame.
rate = read_frame->
rate;
796 session->raw_read_frame.datalen = (uint32_t)
switch_buffer_read(session->raw_read_buffer,
797 session->raw_read_frame.data,
798 session->read_impl.decoded_bytes_per_packet);
800 session->raw_read_frame.rate = session->read_impl.actual_samples_per_second;
801 enc_frame = &session->raw_read_frame;
803 session->enc_read_frame.
datalen = session->enc_read_frame.buflen;
808 session->read_codec->cur_frame = enc_frame;
816 session->read_impl.actual_samples_per_second,
817 session->enc_read_frame.data, &session->enc_read_frame.datalen, &session->enc_read_frame.rate, &flag);
820 session->read_codec->cur_frame = NULL;
826 session->enc_read_frame.samples = session->read_impl.decoded_bytes_per_packet /
sizeof(int16_t) / session->read_impl.number_of_channels;
827 session->enc_read_frame.channels = session->read_impl.number_of_channels;
830 session->enc_read_frame.timestamp = 0;
832 session->enc_read_frame.timestamp = read_frame->
timestamp;
834 session->enc_read_frame.rate = read_frame->
rate;
835 session->enc_read_frame.ssrc = read_frame->
ssrc;
836 session->enc_read_frame.seq = read_frame->
seq;
837 session->enc_read_frame.m = read_frame->
m;
838 session->enc_read_frame.payload = session->read_impl.ianacode;
840 *frame = &session->enc_read_frame;
845 session->raw_read_frame.timestamp = read_frame->
timestamp;
847 session->raw_read_frame.m = read_frame->
m;
848 session->raw_read_frame.ssrc = read_frame->
ssrc;
849 session->raw_read_frame.seq = read_frame->
seq;
860 session->read_codec->codec_interface->interface_name);
883 for (bp = session->bugs; bp; bp = bp->
next) {
961 for (bp = session->
bugs; bp; bp = bp->
next) {
1018 unsigned int flag = 0, need_codec = 0, perfect = 0, do_bugs = 0, do_write = 0, do_resample = 0, ptime_mismatch = 0, pass_cng = 0, resample = 0;
1019 int did_write_resample = 0;
1066 if (!(frame->codec && frame->codec->implementation)) {
1088 if ((session->write_codec && frame->codec && session->write_codec->implementation != frame->codec->implementation)) {
1089 if (session->write_impl.codec_id == frame->codec->implementation->codec_id ||
1090 session->write_impl.microseconds_per_packet != frame->codec->implementation->microseconds_per_packet) {
1091 ptime_mismatch =
TRUE;
1101 if (session->write_codec && !frame->codec) {
1110 if (frame->codec->implementation->actual_samples_per_second != session->write_impl.actual_samples_per_second) {
1144 write_frame = frame;
1157 session->raw_write_frame.datalen = session->raw_write_frame.buflen;
1158 frame->codec->cur_frame = frame;
1159 session->write_codec->cur_frame = frame;
1161 session->write_codec,
1164 session->write_impl.actual_samples_per_second,
1165 session->raw_write_frame.data, &session->raw_write_frame.datalen, &session->raw_write_frame.rate, &frame->flags);
1166 frame->codec->cur_frame = NULL;
1167 session->write_codec->cur_frame = NULL;
1173 if (session->write_impl.number_of_channels != frame->codec->implementation->number_of_channels) {
1174 uint32_t rlen = session->raw_write_frame.datalen / 2 / frame->codec->implementation->number_of_channels;
1176 frame->codec->implementation->number_of_channels, session->write_impl.number_of_channels);
1177 session->raw_write_frame.datalen = rlen * 2 * session->write_impl.number_of_channels;
1183 write_frame = &session->raw_write_frame;
1184 write_frame->rate = frame->codec->implementation->actual_samples_per_second;
1185 if (!session->write_resampler) {
1188 frame->codec->implementation->actual_samples_per_second,
1189 session->write_impl.actual_samples_per_second,
1190 session->write_impl.decoded_bytes_per_packet,
SWITCH_RESAMPLE_QUALITY, session->write_impl.number_of_channels);
1207 session->raw_write_frame.samples = session->raw_write_frame.datalen /
sizeof(int16_t) / session->write_impl.number_of_channels;
1208 session->raw_write_frame.channels = session->write_impl.number_of_channels;
1209 session->raw_write_frame.timestamp = frame->timestamp;
1210 session->raw_write_frame.rate = frame->rate;
1211 session->raw_write_frame.m = frame->m;
1212 session->raw_write_frame.ssrc = frame->ssrc;
1213 session->raw_write_frame.seq = frame->seq;
1214 session->raw_write_frame.payload = frame->payload;
1215 session->raw_write_frame.flags = 0;
1217 session->raw_write_frame.flags |=
SFF_PLC;
1220 write_frame = &session->raw_write_frame;
1226 if (session->write_resampler) {
1240 write_frame = frame;
1256 frame->codec->codec_interface->interface_name);
1263 if (session->write_resampler) {
1264 short *data = write_frame->data;
1267 if (session->write_resampler) {
1280 switch_resample_process(session->write_resampler, data, write_frame->datalen / 2 / session->write_resampler->channels);
1282 memcpy(data, session->write_resampler->to, session->write_resampler->to_len * 2 * session->write_resampler->channels);
1284 write_frame->samples = session->write_resampler->to_len;
1285 write_frame->channels = session->write_resampler->channels;
1286 write_frame->datalen = write_frame->samples * 2 * session->write_resampler->channels;
1288 write_frame->rate = session->write_resampler->to_rate;
1290 did_write_resample = 1;
1297 if (session->bugs) {
1302 for (bp = session->bugs; bp; bp = bp->
next) {
1361 write_frame = frame;
1365 if (session->write_codec) {
1366 if (!ptime_mismatch && write_frame->codec && write_frame->codec->implementation &&
1367 write_frame->codec->implementation->decoded_bytes_per_packet == session->write_impl.decoded_bytes_per_packet) {
1375 if (write_frame->datalen < session->write_impl.decoded_bytes_per_packet) {
1376 memset(write_frame->data, 255, session->write_impl.decoded_bytes_per_packet - write_frame->datalen);
1377 write_frame->datalen = session->write_impl.decoded_bytes_per_packet;
1380 enc_frame = write_frame;
1381 session->enc_write_frame.
datalen = session->enc_write_frame.buflen;
1382 session->write_codec->cur_frame = frame;
1383 frame->codec->cur_frame = frame;
1390 session->write_impl.actual_samples_per_second,
1391 session->enc_write_frame.data, &session->enc_write_frame.datalen, &session->enc_write_frame.rate, &flag);
1395 session->write_codec->cur_frame = NULL;
1396 frame->codec->cur_frame = NULL;
1402 session->enc_write_frame.codec = session->write_codec;
1403 session->enc_write_frame.samples = enc_frame->
datalen /
sizeof(int16_t) / session->write_impl.number_of_channels;
1404 session->enc_write_frame.channels = session->write_impl.number_of_channels;
1405 if (frame->codec->implementation->samples_per_packet != session->write_impl.samples_per_packet) {
1406 session->enc_write_frame.timestamp = 0;
1408 session->enc_write_frame.timestamp = frame->timestamp;
1410 session->enc_write_frame.payload = session->write_impl.ianacode;
1411 session->enc_write_frame.m = frame->m;
1412 session->enc_write_frame.ssrc = frame->ssrc;
1413 session->enc_write_frame.seq = frame->seq;
1414 session->enc_write_frame.flags = 0;
1415 write_frame = &session->enc_write_frame;
1418 enc_frame->
codec = session->write_codec;
1419 enc_frame->
samples = enc_frame->
datalen /
sizeof(int16_t) / session->write_impl.number_of_channels;
1420 enc_frame->
channels = session->write_impl.number_of_channels;
1421 enc_frame->
timestamp = frame->timestamp;
1422 enc_frame->
m = frame->m;
1423 enc_frame->
seq = frame->seq;
1424 enc_frame->
ssrc = frame->ssrc;
1426 write_frame = enc_frame;
1435 session->read_codec->codec_interface->interface_name);
1443 status =
perform_write(session, write_frame, flags, stream_id);
1446 if (!session->raw_write_buffer) {
1447 switch_size_t bytes_per_packet = session->write_impl.decoded_bytes_per_packet;
1449 "Engaging Write Buffer at %u bytes to accommodate %u->%u\n",
1450 (uint32_t) bytes_per_packet, write_frame->datalen, session->write_impl.decoded_bytes_per_packet);
1462 if (!(
switch_buffer_write(session->raw_write_buffer, write_frame->data, write_frame->datalen))) {
1470 while (
switch_buffer_inuse(session->raw_write_buffer) >= session->write_impl.decoded_bytes_per_packet) {
1476 if ((session->raw_write_frame.datalen = (uint32_t)
1477 switch_buffer_read(session->raw_write_buffer, session->raw_write_frame.data, session->write_impl.decoded_bytes_per_packet)) == 0) {
1481 enc_frame = &session->raw_write_frame;
1482 session->raw_write_frame.
rate = session->write_impl.actual_samples_per_second;
1483 session->enc_write_frame.datalen = session->enc_write_frame.buflen;
1484 session->enc_write_frame.timestamp = 0;
1488 rate = frame->codec->implementation->actual_samples_per_second;
1490 rate = session->write_impl.actual_samples_per_second;
1493 session->write_codec->cur_frame = frame;
1494 frame->codec->cur_frame = frame;
1502 session->enc_write_frame.data, &session->enc_write_frame.datalen, &session->enc_write_frame.rate, &flag);
1506 session->write_codec->cur_frame = NULL;
1507 frame->codec->cur_frame = NULL;
1511 session->enc_write_frame.codec = session->write_codec;
1512 session->enc_write_frame.samples = enc_frame->
datalen /
sizeof(int16_t) / session->write_impl.number_of_channels;
1513 session->enc_write_frame.channels = session->write_impl.number_of_channels;
1514 session->enc_write_frame.m = frame->m;
1515 session->enc_write_frame.ssrc = frame->ssrc;
1516 session->enc_write_frame.payload = session->write_impl.ianacode;
1517 write_frame = &session->enc_write_frame;
1518 if (!session->write_resampler) {
1520 if (!session->write_resampler) {
1522 frame->codec->implementation->actual_samples_per_second,
1523 session->write_impl.actual_samples_per_second,
1525 session->write_impl.number_of_channels);
1545 session->enc_write_frame.codec = session->write_codec;
1546 session->enc_write_frame.samples = enc_frame->
datalen /
sizeof(int16_t) / session->write_impl.number_of_channels;
1547 session->enc_write_frame.channels = session->write_impl.number_of_channels;
1548 session->enc_write_frame.m = frame->m;
1549 session->enc_write_frame.ssrc = frame->ssrc;
1550 session->enc_write_frame.payload = session->write_impl.ianacode;
1551 session->enc_write_frame.flags = 0;
1552 write_frame = &session->enc_write_frame;
1555 if (session->write_resampler) {
1560 if (session->write_resampler) {
1574 enc_frame->
codec = session->write_codec;
1575 enc_frame->
samples = enc_frame->
datalen /
sizeof(int16_t) / session->read_impl.number_of_channels;
1576 enc_frame->
channels = session->read_impl.number_of_channels;
1577 enc_frame->
m = frame->m;
1578 enc_frame->
ssrc = frame->ssrc;
1580 write_frame = enc_frame;
1589 session->read_codec->codec_interface->interface_name, status);
1594 if (!did_write_resample && session->read_resampler) {
1595 short *data = write_frame->data;
1597 if (session->read_resampler) {
1598 switch_resample_process(session->read_resampler, data, write_frame->datalen / 2 / session->read_resampler->channels);
1599 memcpy(data, session->read_resampler->to, session->read_resampler->to_len * 2 * session->read_resampler->channels);
1600 write_frame->samples = session->read_resampler->to_len;
1601 write_frame->channels = session->read_resampler->channels;
1602 write_frame->datalen = session->read_resampler->to_len * 2 * session->read_resampler->channels;
1603 write_frame->rate = session->read_resampler->to_rate;
1613 if (ptime_mismatch || resample) {
1614 write_frame->timestamp = 0;
1633 if (ptime_mismatch || resample) {
1634 write_frame->timestamp = 0;
1638 status =
perform_write(session, write_frame, flags, stream_id);
1667 if (session->endpoint_interface->io_routines->kill_channel) {
1668 if ((status = session->endpoint_interface->io_routines->kill_channel(session, sig)) ==
SWITCH_STATUS_SUCCESS) {
1711 if (session->dmachine[0]) {
1712 char str[2] = { dtmf->digit,
'\0' };
1717 for (ptr = session->event_hooks.
recv_dtmf; ptr; ptr = ptr->
next) {
1754 for(p = digits; p && *p; p++) {
1770 if (new_dtmf.
digit !=
'w' && new_dtmf.
digit !=
'W') {
1787 for (ptr = session->event_hooks.
send_dtmf; ptr; ptr = ptr->
next) {
1792 if (session->dmachine[1]) {
1793 char str[2] = { new_dtmf.
digit,
'\0' };
1800 if (session->endpoint_interface->io_routines->send_dtmf) {
1807 if (dtmf->digit ==
'w') {
1809 }
else if (dtmf->digit ==
'W') {
1817 status = session->endpoint_interface->io_routines->send_dtmf(session, &new_dtmf);
1835 if (
zstr(dtmf_string)) {
1839 if (*dtmf_string ==
'~') {
1849 if (strlen(dtmf_string) > 99) {
1861 for (i = 0; i < argc; i++) {
1864 if ((p = strchr(argv[i],
'@'))) {
1872 for (p = argv[i]; p && *p; p++) {
1876 if (dtmf.
digit !=
'w' && dtmf.
digit !=
'W') {
switch_channel_state_t switch_channel_get_state(switch_channel_t *channel)
Get the current state of a channel in the state engine.
#define switch_event_fire(event)
Fire an event filling in most of the arguements with obvious values.
#define switch_channel_hangup(channel, hangup_cause)
Hangup a channel flagging it's state machine to end.
switch_status_t switch_thread_rwlock_unlock(switch_thread_rwlock_t *rwlock)
switch_frame_t dummy_cng_frame
#define SWITCH_BUFFER_START_FRAMES
#define SWITCH_CHANNEL_SESSION_LOG(x)
switch_thread_rwlock_t * bug_rwlock
#define switch_set_flag(obj, flag)
Set a flag on an arbitrary object.
switch_send_dtmf_hook_t send_dtmf
switch_core_session_message_types_t message_id
switch_size_t switch_buffer_read(_In_ switch_buffer_t *buffer, _In_ void *data, _In_ switch_size_t datalen)
Read data from a switch_buffer_t up to the ammount of datalen if it is available. Remove read data fr...
switch_status_t switch_mutex_trylock(switch_mutex_t *lock)
const char * switch_channel_get_partner_uuid(switch_channel_t *channel)
switch_status_t switch_buffer_create_dynamic(_Out_ switch_buffer_t **buffer, _In_ switch_size_t blocksize, _In_ switch_size_t start_len, _In_ switch_size_t max_len)
Allocate a new dynamic switch_buffer.
uint32_t switch_io_flag_t
switch_read_frame_hook_t read_frame
#define SWITCH_RECOMMENDED_BUFFER_SIZE
void switch_channel_event_set_data(_In_ switch_channel_t *channel, _In_ switch_event_t *event)
Add information about a given channel to an event object.
struct switch_io_event_hook_send_dtmf * next
switch_status_t switch_core_codec_encode(switch_codec_t *codec, switch_codec_t *other_codec, void *decoded_data, uint32_t decoded_data_len, uint32_t decoded_rate, void *encoded_data, uint32_t *encoded_data_len, uint32_t *encoded_rate, unsigned int *flag)
Encode data using a codec handle.
switch_status_t switch_ivr_broadcast(const char *uuid, const char *path, switch_media_flag_t flags)
Signal the session to broadcast audio.
switch_kill_channel_hook_t kill_channel
switch_status_t switch_core_media_bug_flush_all(_In_ switch_core_session_t *session)
Flush the read/write buffers for all media bugs on the session.
uint32_t decoded_bytes_per_packet
Representation of an event.
#define switch_channel_ready(_channel)
switch_frame_t * cur_frame
switch_io_routines_t * io_routines
#define switch_channel_media_ready(_channel)
switch_status_t switch_core_codec_decode(switch_codec_t *codec, switch_codec_t *other_codec, void *encoded_data, uint32_t encoded_data_len, uint32_t encoded_rate, void *decoded_data, uint32_t *decoded_data_len, uint32_t *decoded_rate, unsigned int *flag)
Decode data using a codec handle.
#define SWITCH_RESAMPLE_QUALITY
const char * switch_channel_get_variable_dup(switch_channel_t *channel, const char *varname, switch_bool_t dup, int idx)
Retrieve a variable from a given channel.
struct switch_io_event_hook_read_frame * next
#define switch_core_session_get_name(_s)
#define switch_resample_calc_buffer_size(_to, _from, _srclen)
void switch_resample_destroy(switch_audio_resampler_t **resampler)
Destroy an existing resampler handle.
int switch_snprintf(_Out_z_cap_(len) char *buf, _In_ switch_size_t len, _In_z_ _Printf_format_string_ const char *format,...)
switch_size_t switch_buffer_write(_In_ switch_buffer_t *buffer, _In_bytecount_(datalen) const void *data, _In_ switch_size_t datalen)
Write data into a switch_buffer_t up to the length of datalen.
struct switch_runtime runtime
uint32_t switch_channel_test_flag(switch_channel_t *channel, switch_channel_flag_t flag)
Test for presence of given flag on a given channel.
A message object designed to allow unlike technologies to exchange data.
Node in which to store custom write_frame channel callback hooks.
uint32_t switch_core_max_dtmf_duration(uint32_t duration)
uint32_t switch_unmerge_sln(int16_t *data, uint32_t samples, int16_t *other_data, uint32_t other_samples, int channels)
#define is_dtmf(key)
determine if a character is a valid DTMF key
switch_status_t switch_core_codec_reset(switch_codec_t *codec)
switch_io_event_hooks_t event_hooks
switch_status_t switch_mutex_unlock(switch_mutex_t *lock)
switch_status_t switch_thread_rwlock_rdlock(switch_thread_rwlock_t *rwlock)
_Ret_ switch_channel_t * switch_core_session_get_channel(_In_ switch_core_session_t *session)
Retrieve a pointer to the channel object associated with a given session.
#define switch_clear_flag(obj, flag)
Clear a flag on an arbitrary object while locked.
uint32_t switch_core_min_dtmf_duration(uint32_t duration)
switch_status_t switch_thread_rwlock_wrlock(switch_thread_rwlock_t *rwlock)
const switch_codec_implementation_t * implementation
if((uint32_t)(unpack->cur-unpack->buf) > unpack->buflen)
void switch_os_yield(void)
#define switch_yield(ms)
Wait a desired number of microseconds and yield the CPU.
uint32_t switch_core_media_bug_prune(switch_core_session_t *session)
unsigned int switch_separate_string(_In_ char *buf, char delim, _Post_count_(return) char **array, unsigned int arraylen)
Separate a string into an array based on a character delimiter.
switch_channel_t * channel
switch_write_frame_hook_t write_frame
switch_frame_flag_t flags
switch_recv_dtmf_hook_t recv_dtmf
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
uint32_t actual_samples_per_second
void switch_core_gen_encoded_silence(unsigned char *data, const switch_codec_implementation_t *read_impl, switch_size_t len)
switch_status_t switch_core_codec_copy(switch_codec_t *codec, switch_codec_t *new_codec, const switch_codec_settings_t *codec_settings, switch_memory_pool_t *pool)
static char * SIG_NAMES[]
switch_media_bug_t * bugs
An abstraction of a data frame.
struct switch_io_event_hook_kill_channel * next
void switch_cond_next(void)
#define switch_core_session_get_partner(_session, _partner)
switch_status_t switch_core_session_write_frame(switch_core_session_t *session, switch_frame_t *frame, switch_io_flag_t flags, int stream_id)
Node in which to store custom read frame channel callback hooks.
#define switch_core_session_receive_message(_session, _message)
void switch_core_session_rwunlock(_In_ switch_core_session_t *session)
Unlock a read or write lock on as given session.
switch_status_t switch_channel_dtmf_lock(switch_channel_t *channel)
char * switch_core_session_get_uuid(_In_ switch_core_session_t *session)
Retrieve the unique identifier from a session.
uint32_t switch_channel_test_cap(switch_channel_t *channel, switch_channel_cap_t cap)
void switch_mux_channels(int16_t *data, switch_size_t samples, uint32_t orig_channels, uint32_t channels)
switch_status_t switch_core_session_perform_kill_channel(switch_core_session_t *session, const char *file, const char *func, int line, switch_signal_t sig)
uint32_t switch_core_default_dtmf_duration(uint32_t duration)
switch_io_write_frame_t write_frame
uint32_t samples_per_packet
#define switch_channel_down(_channel)
#define switch_channel_set_callstate(channel, state)
uint8_t number_of_channels
static switch_status_t perform_write(switch_core_session_t *session, switch_frame_t *frame, switch_io_flag_t flags, int stream_id)
switch_status_t
Common return values.
Node in which to store custom send dtmf channel callback hooks.
switch_status_t switch_core_session_read_frame(switch_core_session_t *session, switch_frame_t **frame, switch_io_flag_t flags, int stream_id)
switch_payload_t ianacode
#define switch_core_session_locate(uuid_str)
Locate a session based on it's uuid.
#define switch_event_create(event, id)
Create a new event assuming it will not be custom event and therefore hiding the unused parameters...
#define switch_channel_set_flag(_c, _f)
switch_status_t switch_core_session_send_dtmf_string(switch_core_session_t *session, const char *dtmf_string)
Send DTMF to a session.
switch_signal_t
Signals to send to channels.
struct switch_io_event_hook_recv_dtmf * next
Node in which to store custom kill channel callback hooks.
struct switch_io_event_hook_write_frame * next
time_t switch_epoch_time_now(time_t *t)
Get the current epoch time.
#define switch_test_flag(obj, flag)
Test for the existance of a flag on an arbitary object.
static switch_bool_t switch_core_codec_ready(switch_codec_t *codec)
void switch_log_printf(_In_ switch_text_channel_t channel, _In_z_ const char *file, _In_z_ const char *func, _In_ int line, _In_opt_z_ const char *userdata, _In_ switch_log_level_t level, _In_z_ _Printf_format_string_ const char *fmt,...) PRINTF_FUNCTION(7
Write log data to the logging engine.
const char * switch_stristr(const char *instr, const char *str)
A table of settings and callbacks that define a paticular implementation of a codec.
switch_channel_callstate_t switch_channel_get_callstate(switch_channel_t *channel)
switch_endpoint_interface_t * endpoint_interface
uint32_t switch_core_media_bug_test_flag(_In_ switch_media_bug_t *bug, _In_ uint32_t flag)
Test for the existance of a flag on an media bug.
#define switch_core_session_strdup(_session, _todup)
Copy a string using memory allocation from a session's pool.
switch_status_t switch_core_session_send_dtmf(switch_core_session_t *session, const switch_dtmf_t *dtmf)
void switch_channel_clear_flag(switch_channel_t *channel, switch_channel_flag_t flag)
Clear given flag(s) from a channel.
#define switch_channel_set_variable(_channel, _var, _val)
#define switch_channel_pre_answer(channel)
Indicate progress on a channel to attempt early media.
Node in which to store custom recv dtmf channel callback hooks.
#define SWITCH_BUFFER_BLOCK_FRAMES
switch_size_t switch_buffer_inuse(_In_ switch_buffer_t *buffer)
Get the in use amount of a switch_buffer_t.
char * switch_channel_get_name(switch_channel_t *channel)
Retrieve the name of a given channel.
switch_status_t switch_core_session_recv_dtmf(switch_core_session_t *session, const switch_dtmf_t *dtmf)
#define SWITCH_READ_ACCEPTABLE(status)
#define switch_resample_create(_n, _fr, _tr, _ts, _q, _c)
uint32_t switch_resample_process(switch_audio_resampler_t *resampler, int16_t *src, uint32_t srclen)
Resample one float buffer into another using specifications of a given handle.
switch_status_t switch_channel_dtmf_unlock(switch_channel_t *channel)