57 #define MAX_TIMESTAMP_SKEW 640
59 #define RTP_SEQ_MOD (1<<16)
60 #define RTCP_DEFAULT_INTERVALMS 5000
61 #define RTCP_MIN_INTERVALMS 500
62 #define RTCP_MAX_INTERVALMS 60000
64 #define DEFAULT_RTP_START 5000
65 #define DEFAULT_RTP_END 31000
67 #define MINIMUM_RTP_PORT 1024
68 #define MAXIMUM_RTP_PORT 65535
70 #define RTCP_PT_FUR 192
71 #define RTCP_PT_SR 200
72 #define RTCP_PT_RR 201
73 #define RTCP_PT_SDES 202
74 #define RTCP_PT_BYE 203
75 #define RTCP_PT_APP 204
78 #define DTMF_SAMPLE_RATE_MS 8
80 #define DEFAULT_DTMF_TIMEOUT (150 * (8000 / 1000))
82 #define ZFONE_PROFILE_ID 0x505a
84 #define DEFAULT_LEARNING_MIN_SEQUENTIAL 4
100 static int nochecksums;
111 #define FLAG_3389_WARNING (1 << 0)
112 #define FLAG_NAT_ACTIVE (3 << 1)
113 #define FLAG_NAT_INACTIVE (0 << 1)
114 #define FLAG_NAT_INACTIVE_NOWARN (1 << 1)
115 #define FLAG_NEED_MARKER_BIT (1 << 3)
116 #define FLAG_DTMF_COMPENSATE (1 << 4)
370 if ((*in & 0xC0) && res_srtp && srtp && res_srtp->
unprotect(srtp, buf, &len, rtcp) < 0) {
394 if (res_srtp && srtp && res_srtp->
protect(srtp, &temp, &len, rtcp) < 0) {
418 unsigned int interval;
426 static double normdev_compute(
double normdev,
double sample,
unsigned int sample_count)
428 normdev = normdev * sample_count + sample;
431 return normdev / sample_count;
434 static double stddev_compute(
double stddev,
double sample,
double normdev,
double normdev_curent,
unsigned int sample_count)
442 #define SQUARE(x) ((x) * (x))
444 stddev = sample_count * stddev;
448 ( sample_count *
SQUARE( (sample - normdev) / sample_count ) ) +
449 (
SQUARE(sample - normdev_curent) / sample_count );
456 int sock = socket(af, SOCK_DGRAM, 0);
464 long flags = fcntl(sock, F_GETFL);
465 fcntl(sock, F_SETFL, flags | O_NONBLOCK);
468 setsockopt(sock, SOL_SOCKET, SO_NO_CHECK, &nochecksums,
sizeof(nochecksums));
546 return (
unsigned int) ms;
574 ast_debug(1,
"Failed to create a new socket for RTP instance '%p'\n", instance);
588 ast_debug(1,
"Allocated port %d for RTP instance '%p'\n", x, instance);
595 x = (rtpstart + 1) & ~1;
599 if (x == startplace || (
errno != EADDRINUSE &&
errno != EACCES)) {
600 ast_log(
LOG_ERROR,
"Oh dear... we couldn't allocate a port for RTP instance '%p'\n", instance);
670 int hdrlen = 12, res = 0, i = 0, payload = 101;
672 unsigned int *rtpheader = (
unsigned int*)data;
682 if ((digit <=
'9') && (digit >=
'0')) {
684 }
else if (digit ==
'*') {
686 }
else if (digit ==
'#') {
688 }
else if ((digit >=
'A') && (digit <=
'D')) {
689 digit = digit -
'A' + 12;
690 }
else if ((digit >=
'a') && (digit <=
'd')) {
691 digit = digit -
'a' + 12;
706 rtpheader[0] = htonl((2 << 30) | (1 << 23) | (payload << 16) | (rtp->
seqno));
708 rtpheader[2] = htonl(rtp->
ssrc);
711 for (i = 0; i < 2; i++) {
712 rtpheader[3] = htonl((digit << 24) | (0xa << 16) | (rtp->
send_duration));
713 res =
rtp_sendto(instance, (
void *) rtpheader, hdrlen + 4, 0, &remote_address);
720 ast_verbose(
"Sent RTP DTMF packet to %s (type %-2.2d, seq %-6.6d, ts %-6.6u, len %-6.6d)\n",
726 rtpheader[0] = htonl((2 << 30) | (payload << 16) | (rtp->
seqno));
741 int hdrlen = 12, res = 0;
743 unsigned int *rtpheader = (
unsigned int*)data;
755 rtpheader[2] = htonl(rtp->
ssrc);
759 res =
rtp_sendto(instance, (
void *) rtpheader, hdrlen + 4, 0, &remote_address);
767 ast_verbose(
"Sent RTP DTMF packet to %s (type %-2.2d, seq %-6.6d, ts %-6.6u, len %-6.6d)\n",
784 int hdrlen = 12, res = -1, i = 0;
786 unsigned int *rtpheader = (
unsigned int*)data;
787 unsigned int measured_samples;
797 if ((digit <=
'9') && (digit >=
'0')) {
799 }
else if (digit ==
'*') {
801 }
else if (digit ==
'#') {
803 }
else if ((digit >=
'A') && (digit <=
'D')) {
804 digit = digit -
'A' + 12;
805 }
else if ((digit >=
'a') && (digit <=
'd')) {
806 digit = digit -
'a' + 12;
821 rtpheader[2] = htonl(rtp->
ssrc);
822 rtpheader[3] = htonl((digit << 24) | (0xa << 16) | (rtp->
send_duration));
823 rtpheader[3] |= htonl((1 << 23));
826 for (i = 0; i < 3; i++) {
830 res =
rtp_sendto(instance, (
void *) rtpheader, hdrlen + 4, 0, &remote_address);
837 ast_verbose(
"Sent RTP DTMF packet to %s (type %-2.2d, seq %-6.6d, ts %-6.6u, len %-6.6d)\n",
866 ast_debug(3,
"Setting the marker bit due to a source update\n");
878 ast_debug(3,
"Not changing SSRC since we haven't sent any RTP yet\n");
885 ast_debug(3,
"Changing ssrc from %u to %u due to a source change\n", rtp->
ssrc, ssrc);
888 ast_debug(3,
"Changing ssrc for SRTP from %u to %u\n", rtp->
ssrc, ssrc);
897 static void timeval2ntp(
struct timeval
tv,
unsigned int *msw,
unsigned int *lsw)
899 unsigned int sec, usec, frac;
900 sec = tv.tv_sec + 2208988800u;
902 frac = (usec << 12) + (usec << 8) - ((usec * 3650) >> 6);
914 unsigned int extended;
915 unsigned int expected;
916 unsigned int expected_interval;
917 unsigned int received_interval;
920 unsigned int *rtcpheader;
926 double rxlost_current;
928 if (!rtp || !rtp->
rtcp)
940 lost = expected - rtp->
rxcount;
945 lost_interval = expected_interval - received_interval;
947 if (lost_interval <= 0)
952 if (lost_interval < rtp->rtcp->minrxlost)
962 if (expected_interval == 0 || lost_interval <= 0)
965 fraction = (lost_interval << 8) / expected_interval;
966 gettimeofday(&now, NULL);
968 rtcpheader = (
unsigned int *)bdata;
969 rtcpheader[0] = htonl((2 << 30) | (1 << 24) | (
RTCP_PT_RR << 16) | ((len/4)-1));
970 rtcpheader[1] = htonl(rtp->
ssrc);
971 rtcpheader[2] = htonl(rtp->
themssrc);
972 rtcpheader[3] = htonl(((fraction & 0xff) << 24) | (lost & 0xffffff));
974 rtcpheader[5] = htonl((
unsigned int)(rtp->
rxjitter * rate));
976 rtcpheader[7] = htonl((((dlsr.tv_sec * 1000) + (dlsr.tv_usec / 1000)) * 65536) / 1000);
980 rtcpheader[len/4] = htonl((2 << 30) | (1 << 24) | (
RTCP_PT_SDES << 16) | 2);
981 rtcpheader[(len/4)+1] = htonl(rtp->
ssrc);
982 rtcpheader[(len/4)+2] = htonl(0x01 << 24);
995 " Our SSRC: %u\nTheir SSRC: %u\niFraction lost: %d\nCumulative loss: %u\n"
997 " Their last SR: %u\n"
998 " DLSR: %4.4f (sec)\n\n",
1003 (
double)(ntohl(rtcpheader[7])/65536.0));
1016 unsigned int now_lsw;
1017 unsigned int now_msw;
1018 unsigned int *rtcpheader;
1020 unsigned int extended;
1021 unsigned int expected;
1022 unsigned int expected_interval;
1023 unsigned int received_interval;
1026 struct timeval dlsr;
1030 if (!rtp || !rtp->
rtcp)
1040 gettimeofday(&now, NULL);
1042 rtcpheader = (
unsigned int *)bdata;
1043 rtcpheader[1] = htonl(rtp->
ssrc);
1044 rtcpheader[2] = htonl(now_msw);
1045 rtcpheader[3] = htonl(now_lsw);
1046 rtcpheader[4] = htonl(rtp->
lastts);
1047 rtcpheader[5] = htonl(rtp->
txcount);
1054 expected += rtp->
rxcount - expected;
1055 lost = expected - rtp->
rxcount;
1060 lost_interval = expected_interval - received_interval;
1061 if (expected_interval == 0 || lost_interval <= 0)
1064 fraction = (lost_interval << 8) / expected_interval;
1066 rtcpheader[7] = htonl(rtp->
themssrc);
1067 rtcpheader[8] = htonl(((fraction & 0xff) << 24) | (lost & 0xffffff));
1069 rtcpheader[10] = htonl((
unsigned int)(rtp->
rxjitter * rate));
1071 rtcpheader[12] = htonl((((dlsr.tv_sec * 1000) + (dlsr.tv_usec / 1000)) * 65536) / 1000);
1074 rtcpheader[0] = htonl((2 << 30) | (1 << 24) | (
RTCP_PT_SR << 16) | ((len/4)-1));
1078 rtcpheader[len/4] = htonl((2 << 30) | (1 << 24) | (
RTCP_PT_SDES << 16) | 2);
1079 rtcpheader[(len/4)+1] = htonl(rtp->
ssrc);
1080 rtcpheader[(len/4)+2] = htonl(0x01 << 24);
1100 ast_verbose(
" Sent(NTP): %u.%010u\n", (
unsigned int)now.tv_sec, (
unsigned int)now.tv_usec*4096);
1109 ast_verbose(
" DLSR: %4.4f (sec)\n\n", (
double)(ntohl(rtcpheader[12])/65536.0));
1113 "SentNTP: %u.%010u\r\n"
1115 "SentPackets: %u\r\n"
1116 "SentOctets: %u\r\n"
1118 "FractionLost: %d\r\n"
1119 "CumulativeLoss: %u\r\n"
1120 "IAJitter: %.4f\r\n"
1121 "TheirLastSR: %u\r\n"
1122 "DLSR: %4.4f (sec)\r\n",
1125 (
unsigned int)now.tv_sec, (
unsigned int)now.tv_usec*4096,
1133 (
double)(ntohl(rtcpheader[12])/65536.0));
1195 ast_debug(3,
"Difference is %d, ms is %u\n", abs(rtp->
lastts - pred), ms);
1206 if (abs(rtp->
lastts - pred) < 7200) {
1210 ast_debug(3,
"Difference is %d, ms is %u (%u), pred/ts/samples %u/%d/%d\n", abs(rtp->
lastts - pred), ms, ms * 90, rtp->
lastts, pred, frame->
samples);
1220 if (abs(rtp->
lastts - pred) < 7200) {
1224 ast_debug(3,
"Difference is %d, ms is %u, pred/ts/samples %u/%d/%d\n", abs(rtp->
lastts - pred), ms, rtp->
lastts, pred, frame->
samples);
1249 int hdrlen = 12, res;
1250 unsigned char *rtpheader = (
unsigned char *)(frame->
data.
ptr - hdrlen);
1256 if ((res =
rtp_sendto(instance, (
void *)rtpheader, frame->
datalen + hdrlen, 0, &remote_address)) < 0) {
1258 ast_debug(1,
"RTP Transmission error of packet %d to %s: %s\n",
1265 ast_debug(0,
"RTP NAT: Can't write RTP to private address %s, waiting for other end to send audio...\n",
1274 ast_debug(1,
"Starting RTCP transmission on RTP instance '%p'\n", instance);
1285 ast_verbose(
"Sent RTP packet to %s (type %-2.2d, seq %-6.6d, ts %-6.6u, len %-6.6d)\n",
1303 for (i = 1; i < red->
num_gen+1; i++)
1310 for (i = 0; i < red->
num_gen; i++)
1311 red->
len[i] = red->
len[i+1];
1317 len += data[i*4+3] = red->
len[i];
1343 ast_debug(1,
"No remote address on RTP instance '%p' so dropping frame\n", instance);
1349 ast_debug(1,
"Received frame with no data for RTP instance '%p' so dropping frame\n", instance);
1431 if (frame->
offset < hdrlen) {
1453 double current_time;
1459 double normdev_rxjitter_current;
1460 if ((!rtp->
rxcore.tv_sec && !rtp->
rxcore.tv_usec) || mark) {
1461 gettimeofday(&rtp->
rxcore, NULL);
1471 gettimeofday(&now,NULL);
1476 prog = (double)((timestamp-rtp->
seedrxts)/(float)(rate));
1477 dtv = (double)rtp->
drxcore + (
double)(prog);
1478 current_time = (double)now.tv_sec + (
double)now.tv_usec/1000000;
1479 transit = current_time - dtv;
1510 ast_debug(1,
"Ignore potential DTMF echo from '%s'\n",
1516 ast_debug(1,
"Creating %s DTMF Frame: %d (%c), at %s\n",
1520 if (rtp->
resp ==
'X') {
1540 unsigned int event, event_end, samples;
1547 event = ntohl(*((
unsigned int *)(data)));
1549 event_end = ntohl(*((
unsigned int *)(data)));
1552 samples = ntohl(*((
unsigned int *)(data)));
1556 ast_verbose(
"Got RTP RFC2833 from %s (type %-2.2d, seq %-6.6u, ts %-6.6u, len %-6.6d, mark %d, event %08x, end %d, duration %-5.5u) \n",
1558 payloadtype, seqno, timestamp, len, (mark?1:0), event, ((event_end & 0x80)?1:0), samples);
1563 ast_debug(0,
"- RTP 2833 Event: %08x (len = %d)\n", event, len);
1568 }
else if (event < 11) {
1570 }
else if (event < 12) {
1572 }
else if (event < 16) {
1573 resp =
'A' + (
event - 12);
1574 }
else if (event < 17) {
1578 ast_log(
LOG_DEBUG,
"Ignoring RTP 2833 Event: %08x. Not a DTMF Digit.\n", event);
1598 unsigned int last_duration = new_duration & 0xFFFF;
1600 if (last_duration > 64000 && samples < last_duration) {
1601 new_duration += 0xFFFF + 1;
1603 new_duration = (new_duration & ~0xFFFF) | samples;
1605 if (event_end & 0x80) {
1615 }
else if (rtpdebug) {
1616 ast_debug(1,
"Dropping re-transmitted, duplicate, or out of order DTMF END frame (seqno: %u, ts %u, digit %c)\n",
1617 seqno, timestamp, resp);
1627 || timestamp <= rtp->last_end_timestamp) {
1633 ast_debug(1,
"Dropping out of order DTMF frame (seqno %u, ts %u, digit %c)\n",
1634 seqno, timestamp, resp);
1639 if (rtp->
resp && rtp->
resp != resp) {
1673 unsigned int event,
flags, power;
1715 event = data[3] & 0x1f;
1718 ast_debug(0,
"Cisco DTMF Digit: %02x (len=%d, seq=%d, flags=%02x, power=%u, history count=%d)\n", event, len, seq, flags, power, (len - 4) / 2);
1721 }
else if (event < 11) {
1723 }
else if (event < 12) {
1725 }
else if (event < 16) {
1726 resp =
'A' + (
event - 12);
1727 }
else if (event < 17) {
1730 if ((!rtp->
resp && power) || (rtp->
resp && (rtp->
resp != resp))) {
1737 }
else if ((rtp->
resp == resp) && !power) {
1741 }
else if (rtp->
resp == resp)
1757 ast_debug(0,
"- RTP 3389 Comfort noise event: Level %" PRId64
" (len = %d)\n", rtp->
lastrxformat, len);
1764 ast_log(
LOG_NOTICE,
"Comfort noise support incomplete in Asterisk (RFC 3389). Please turn off on client if possible. Client address: %s\n",
1776 memcpy(rtp->
f.
data.
ptr, data + 1, len - 1);
1796 int res, packetwords, position = 0;
1804 if (
errno != EAGAIN) {
1811 packetwords = res / 4;
1818 ast_debug(0,
"RTCP NAT: Got RTCP from other end. Now sending to address %s\n",
1823 ast_debug(1,
"Got RTCP report of %d bytes\n", res);
1825 while (position < packetwords) {
1827 unsigned int length, dlsr, lsr, msw, lsw, comp;
1829 double rttsec, reported_jitter, reported_normdev_jitter_current, normdevrtt_current, reported_lost, reported_normdev_lost_current;
1833 length = ntohl(rtcpheader[i]);
1834 pt = (length & 0xff0000) >> 16;
1835 rc = (length & 0x1f000000) >> 24;
1838 if ((i + length) > packetwords) {
1847 ast_verbose(
"PT: %d(%s)\n", pt, (pt == 200) ?
"Sender Report" : (pt == 201) ?
"Receiver Report" : (pt == 192) ?
"H.261 FUR" :
"Unknown");
1849 ast_verbose(
"SSRC of sender: %u\n", rtcpheader[i + 1]);
1854 position += (length + 1);
1861 rtp->
rtcp->
spc = ntohl(rtcpheader[i+3]);
1862 rtp->
rtcp->
soc = ntohl(rtcpheader[i + 4]);
1863 rtp->
rtcp->
themrxlsr = ((ntohl(rtcpheader[i]) & 0x0000ffff) << 16) | ((ntohl(rtcpheader[i + 1]) & 0xffff0000) >> 16);
1866 ast_verbose(
"NTP timestamp: %lu.%010lu\n", (
unsigned long) ntohl(rtcpheader[i]), (
unsigned long) ntohl(rtcpheader[i + 1]) * 4096);
1867 ast_verbose(
"RTP timestamp: %lu\n", (
unsigned long) ntohl(rtcpheader[i + 2]));
1868 ast_verbose(
"SPC: %lu\tSOC: %lu\n", (
unsigned long) ntohl(rtcpheader[i + 3]), (
unsigned long) ntohl(rtcpheader[i + 4]));
1877 gettimeofday(&now, NULL);
1879 if (ntohl(rtcpheader[i + 4]) && ntohl(rtcpheader[i + 5])) {
1880 comp = ((msw & 0xffff) << 16) | ((lsw & 0xffff0000) >> 16);
1881 lsr = ntohl(rtcpheader[i + 4]);
1882 dlsr = ntohl(rtcpheader[i + 5]);
1883 rtt = comp - lsr - dlsr;
1888 rtt = (rtt * 1000000) >> 16;
1890 rtt = (rtt * 1000) >> 16;
1894 rttsec = rtt / 1000.;
1897 if (comp - dlsr >= lsr) {
1916 ast_verbose(
"Internal RTCP NTP clock skew detected: "
1917 "lsr=%u, now=%u, dlsr=%u (%u:%03ums), "
1919 lsr, comp, dlsr, dlsr / 65536,
1920 (dlsr % 65536) * 1000 / 65536,
1921 dlsr - (comp - lsr));
1931 if (reported_jitter < rtp->rtcp->reported_minjitter)
1951 if (reported_lost < rtp->rtcp->reported_minlost)
1965 ast_verbose(
" Fraction lost: %ld\n", (((
long) ntohl(rtcpheader[i + 1]) & 0xff000000) >> 24));
1967 ast_verbose(
" Highest sequence number: %ld\n", (
long) (ntohl(rtcpheader[i + 2]) & 0xffff));
1968 ast_verbose(
" Sequence number cycles: %ld\n", (
long) (ntohl(rtcpheader[i + 2])) >> 16);
1970 ast_verbose(
" Last SR(our NTP): %lu.%010lu\n",(
unsigned long) ntohl(rtcpheader[i + 4]) >> 16,((
unsigned long) ntohl(rtcpheader[i + 4]) << 16) * 4096);
1971 ast_verbose(
" DLSR: %4.4f (sec)\n",ntohl(rtcpheader[i + 5])/65536.0);
1973 ast_verbose(
" RTT: %lu(sec)\n", (
unsigned long) rtt);
1978 "ReceptionReports: %d\r\n"
1979 "SenderSSRC: %u\r\n"
1980 "FractionLost: %ld\r\n"
1981 "PacketsLost: %u\r\n"
1982 "HighestSequence: %ld\r\n"
1983 "SequenceNumberCycles: %ld\r\n"
1985 "LastSR: %lu.%010lu\r\n"
1986 "DLSR: %4.4f(sec)\r\n"
1987 "RTT: %llu(sec)\r\n",
1989 pt, (pt == 200) ?
"Sender Report" : (pt == 201) ?
"Receiver Report" : (pt == 192) ?
"H.261 FUR" :
"Unknown",
1992 (((
long) ntohl(rtcpheader[i + 1]) & 0xff000000) >> 24),
1994 (
long) (ntohl(rtcpheader[i + 2]) & 0xffff),
1995 (
long) (ntohl(rtcpheader[i + 2])) >> 16,
1997 (
unsigned long) ntohl(rtcpheader[i + 4]) >> 16, ((
unsigned long) ntohl(rtcpheader[i + 4]) << 16) * 4096,
1998 ntohl(rtcpheader[i + 5])/65536.0,
1999 (
unsigned long long)rtt);
2003 "ReceptionReports: %d\r\n"
2004 "SenderSSRC: %u\r\n"
2005 "FractionLost: %ld\r\n"
2006 "PacketsLost: %u\r\n"
2007 "HighestSequence: %ld\r\n"
2008 "SequenceNumberCycles: %ld\r\n"
2010 "LastSR: %lu.%010lu\r\n"
2011 "DLSR: %4.4f(sec)\r\n",
2013 pt, (pt == 200) ?
"Sender Report" : (pt == 201) ?
"Receiver Report" : (pt == 192) ?
"H.261 FUR" :
"Unknown",
2016 (((
long) ntohl(rtcpheader[i + 1]) & 0xff000000) >> 24),
2018 (
long) (ntohl(rtcpheader[i + 2]) & 0xffff),
2019 (
long) (ntohl(rtcpheader[i + 2])) >> 16,
2021 (
unsigned long) ntohl(rtcpheader[i + 4]) >> 16,
2022 ((
unsigned long) ntohl(rtcpheader[i + 4]) << 16) * 4096,
2023 ntohl(rtcpheader[i + 5])/65536.0);
2028 ast_verbose(
"Received an RTCP Fast Update Request\n");
2048 ast_debug(1,
"Unknown RTCP packet (pt=%d) received from %s\n",
2052 position += (length + 1);
2064 int res = 0, payload = 0, bridged_payload = 0, mark;
2070 payload = (reconstruct & 0x7f0000) >> 16;
2071 mark = (((reconstruct & 0x800000) >> 23) != 0);
2080 if (bridged_payload < 0) {
2096 reconstruct &= 0xFF80FFFF;
2097 reconstruct |= (bridged_payload << 16);
2098 reconstruct |= (mark << 23);
2099 rtpheader[0] = htonl(reconstruct);
2104 ast_debug(1,
"Remote address is null, most likely RTP has been stopped\n");
2109 res =
rtp_sendto(instance1, (
void *)rtpheader, len, 0, &remote_address);
2113 "RTP Transmission error of packet to %s: %s\n",
2119 "RTP NAT: Can't write RTP to private "
2120 "address %s, waiting for other end to "
2127 ast_verbose(
"Sent RTP P2P packet to %s (type %-2.2d, len %-6.6d)\n",
2129 bridged_payload, len - hdrlen);
2139 int res, hdrlen = 12,
version, payloadtype, padding, mark,
ext, cc, prev_seqno;
2163 if (
errno != EAGAIN) {
2177 seqno = ntohl(rtpheader[0]);
2181 if (!(
version = (seqno & 0xC0000000) >> 30)) {
2182 struct sockaddr_in addr_tmp;
2187 ast_debug(1,
"Using IPv6 mapped address %s for STUN\n",
2191 ast_debug(1,
"Cannot do STUN for non IPv4 address %s\n",
2211 ast_debug(1,
"%p -- Condition for learning hasn't exited, so reject the frame.\n", rtp);
2228 ast_debug(1,
"Received RTP packet from %s, dropping due to strict RTP protection. Expected it to be from %s\n",
2229 real_addr, expected_addr);
2248 ast_debug(0,
"RTP NAT: Got audio from other end. Now sending to address %s\n",
2264 payloadtype = (seqno & 0x7f0000) >> 16;
2265 padding = seqno & (1 << 29);
2266 mark = seqno & (1 << 23);
2267 ext = seqno & (1 << 28);
2268 cc = (seqno & 0xF000000) >> 24;
2270 timestamp = ntohl(rtpheader[1]);
2271 ssrc = ntohl(rtpheader[2]);
2283 ast_debug(1,
"Forcing Marker bit, because SSRC has changed\n");
2317 hdrlen += (ntohl(rtpheader[hdrlen/4]) & 0xffff) << 2;
2320 unsigned int profile;
2321 profile = (ntohl(rtpheader[3]) & 0xffff0000) >> 16;
2322 if (profile == 0x505a)
2323 ast_debug(1,
"Found Zfone extension in RTP stream - zrtp - not supported.\n");
2325 ast_debug(1,
"Found unknown RTP Extensions %x\n", profile);
2357 rtp->
themssrc = ntohl(rtpheader[2]);
2361 ast_verbose(
"Got RTP packet from %s (type %-2.2d, seq %-6.6u, ts %-6.6u, len %-6.6d)\n",
2363 payloadtype,
seqno, timestamp,res - hdrlen);
2439 unsigned char *header_end;
2440 int num_generations;
2443 int diff =(int)
seqno - (prev_seqno+1);
2447 header_end = memchr(data, ((*data) & 0x7f), rtp->
f.
datalen);
2448 if (header_end == NULL) {
2453 header_length = header_end -
data;
2454 num_generations = header_length / 4;
2455 len = header_length;
2458 for (x = 0; x < num_generations; x++)
2459 len += data[x * 4 + 3];
2466 }
else if (diff > num_generations && diff < 10) {
2476 for ( x = 0; x < num_generations - diff; x++)
2477 len += data[x * 4 + 3];
2530 ast_debug(1,
"Ignoring duplicate RTCP property on RTP instance '%p'\n", instance);
2548 AF_INET6 : -1)) < 0) {
2549 ast_debug(1,
"Failed to create a new socket for RTCP on instance '%p'\n", instance);
2557 ast_debug(1,
"Failed to setup RTCP on RTP instance '%p'\n", instance);
2558 close(rtp->
rtcp->
s);
2564 ast_debug(1,
"Setup RTCP on RTP instance '%p'\n", instance);
2576 ast_debug(1,
"Failed to tear down RTCP on RTP instance '%p'\n", instance);
2581 close(rtp->
rtcp->
s);
2596 return rtcp ? (rtp->
rtcp ? rtp->
rtcp->
s : -1) : rtp->
s;
2604 ast_debug(1,
"Setting RTCP address on RTP instance '%p'\n", instance);
2664 rtp->
red->
ti = buffer_time;
2669 for (x = 0; x < generations; x++) {
2670 rtp->
red->
pt[x] = payloads[x];
2671 rtp->
red->
pt[x] |= 1 << 7;
2772 struct sockaddr_in suggestion_tmp;
2816 unsigned int *rtpheader;
2818 int res, payload = 0;
2831 level = 127 - (level & 0x7f);
2836 rtpheader = (
unsigned int *)data;
2837 rtpheader[0] = htonl((2 << 30) | (payload << 16) | (rtp->
seqno));
2838 rtpheader[1] = htonl(rtp->
lastts);
2839 rtpheader[2] = htonl(rtp->
ssrc);
2842 res =
rtp_sendto(instance, (
void *) rtpheader, hdrlen + 1, 0, &remote_address);
2847 ast_verbose(
"Sent Comfort Noise RTP packet to %s (type %-2.2d, seq %-6.6d, ts %-6.6u, len %-6.6d)\n",
2860 char *debughost = NULL;
2861 char *debugport = NULL;
2864 ast_cli(a->
fd,
"Lookup failed for '%s'\n", arg);
2868 ast_cli(a->
fd,
"RTP Debugging Enabled for address: %s\n",
2877 char *debughost = NULL;
2878 char *debugport = NULL;
2881 ast_cli(a->
fd,
"Lookup failed for '%s'\n", arg);
2885 ast_cli(a->
fd,
"RTCP Debugging Enabled for address: %s\n",
2895 e->
command =
"rtp set debug {on|off|ip}";
2897 "Usage: rtp set debug {on|off|ip host[:port]}\n"
2898 " Enable/Disable dumping of all RTP packets. If 'ip' is\n"
2899 " specified, limit the dumped packets to those to and from\n"
2900 " the specified 'host' with optional port.\n";
2907 if (!strncasecmp(a->
argv[e->
args-1],
"on", 2)) {
2910 ast_cli(a->
fd,
"RTP Debugging Enabled\n");
2912 }
else if (!strncasecmp(a->
argv[e->
args-1],
"off", 3)) {
2914 ast_cli(a->
fd,
"RTP Debugging Disabled\n");
2917 }
else if (a->
argc == e->
args +1) {
2928 e->
command =
"rtcp set debug {on|off|ip}";
2930 "Usage: rtcp set debug {on|off|ip host[:port]}\n"
2931 " Enable/Disable dumping of all RTCP packets. If 'ip' is\n"
2932 " specified, limit the dumped packets to those to and from\n"
2933 " the specified 'host' with optional port.\n";
2940 if (!strncasecmp(a->
argv[e->
args-1],
"on", 2)) {
2943 ast_cli(a->
fd,
"RTCP Debugging Enabled\n");
2945 }
else if (!strncasecmp(a->
argv[e->
args-1],
"off", 3)) {
2947 ast_cli(a->
fd,
"RTCP Debugging Disabled\n");
2950 }
else if (a->
argc == e->
args +1) {
2961 e->
command =
"rtcp set stats {on|off}";
2963 "Usage: rtcp set stats {on|off}\n"
2964 " Enable/Disable dumping of RTCP stats.\n";
2973 if (!strncasecmp(a->
argv[e->
args-1],
"on", 2))
2975 else if (!strncasecmp(a->
argv[e->
args-1],
"off", 3))
2980 ast_cli(a->
fd,
"RTCP Stats %s\n", rtcpstats ?
"Enabled" :
"Disabled");
3022 rtcpinterval = atoi(s);
3023 if (rtcpinterval == 0)
3035 ast_log(
LOG_WARNING,
"Disabling RTP checksums is not supported on this operating system!\n");
3039 dtmftimeout = atoi(s);
3040 if ((dtmftimeout < 0) || (dtmftimeout > 64000)) {
3041 ast_log(
LOG_WARNING,
"DTMF timeout of '%d' outside range, using default of '%d' instead\n",
3050 if ((sscanf(s,
"%d", &learning_min_sequential) <= 0) || learning_min_sequential <= 0) {
3051 ast_log(
LOG_WARNING,
"Value for 'probation' could not be read, using default of '%d' instead\n",
3057 if (rtpstart >= rtpend) {
3062 ast_verb(2,
"RTP Allocating from port range %d -> %d\n", rtpstart, rtpend);
double local_normdevrxploss
union ast_frame_subclass subclass
unsigned char ts[AST_RED_MAX_GENERATION]
struct ast_smoother * ast_smoother_new(int bytes)
Main Channel structure associated with a channel.
double reported_stdev_jitter
#define AST_CLI_DEFINE(fn, txt,...)
int ast_sched_del(struct sched_context *con, int id) attribute_warn_unused_result
Deletes a scheduled event Remove this event from being run. A procedure should not remove its own eve...
void ast_smoother_free(struct ast_smoother *s)
ssize_t ast_sendto(int sockfd, const void *buf, size_t len, int flags, const struct ast_sockaddr *dest_addr)
Wrapper around sendto(2) that uses ast_sockaddr.
double reported_stdev_lost
Asterisk locking-related definitions:
#define FLAG_3389_WARNING
Asterisk main include file. File version handling, generic pbx functions.
#define AST_LIST_FIRST(head)
Returns the first entry contained in a list.
#define ast_rtp_engine_register(engine)
static int ast_rtp_dtmf_compatible(struct ast_channel *chan0, struct ast_rtp_instance *instance0, struct ast_channel *chan1, struct ast_rtp_instance *instance1)
const char * ast_variable_retrieve(const struct ast_config *config, const char *category, const char *variable)
Gets a variable.
enum strict_rtp_state strict_rtp_state
struct ast_frame ast_null_frame
unsigned int lastovidtimestamp
struct ast_rtp_payload_type ast_rtp_codecs_payload_lookup(struct ast_rtp_codecs *codecs, int payload)
Retrieve payload information by payload.
static int ast_rtp_dtmf_end_with_duration(struct ast_rtp_instance *instance, char digit, unsigned int duration)
unsigned int rxjitter_count
unsigned int lastotexttimestamp
static int rtp_sendto(struct ast_rtp_instance *instance, void *buf, size_t size, int flags, struct ast_sockaddr *sa)
int ast_sockaddr_parse(struct ast_sockaddr *addr, const char *str, int flags)
Parse an IPv4 or IPv6 address string.
struct sched_context * sched
double remote_normdevjitter
int ast_cli_unregister_multiple(struct ast_cli_entry *e, int len)
Unregister multiple commands.
struct ast_frame * ast_smoother_read(struct ast_smoother *s)
#define ast_test_flag(p, flag)
unsigned int lasteventseqn
#define DEFAULT_DTMF_TIMEOUT
static void ast_sockaddr_copy(struct ast_sockaddr *dst, const struct ast_sockaddr *src)
Copies the data from one ast_sockaddr to another.
static int ast_rtcp_write(const void *data)
Write and RTCP packet to the far end.
#define AST_FORMAT_G723_1
static int ast_rtp_fd(struct ast_rtp_instance *instance, int rtcp)
int ast_sched_add(struct sched_context *con, int when, ast_sched_cb callback, const void *data) attribute_warn_unused_result
Adds a scheduled event Schedule an event to take place at some point in the future. callback will be called with data as the argument, when milliseconds into the future (approximately) If callback returns 0, no further events will be re-scheduled.
int(*const send_digit_begin)(struct ast_channel *chan, char digit)
Start sending a literal DTMF digit.
void ast_smoother_set_flags(struct ast_smoother *smoother, int flags)
static int ast_rtp_dtmf_begin(struct ast_rtp_instance *instance, char digit)
#define ast_set_flag(p, flag)
unsigned int rxlost_count
struct ast_rtp_codecs * ast_rtp_instance_get_codecs(struct ast_rtp_instance *instance)
Get the codecs structure of an RTP instance.
descriptor for a cli entry.
double reported_minjitter
double remote_stdevjitter
void ast_verbose(const char *fmt,...)
int(* change_source)(struct ast_srtp *srtp, unsigned int from_ssrc, unsigned int to_ssrc)
int ast_sockaddr_ipv4_mapped(const struct ast_sockaddr *addr, struct ast_sockaddr *ast_mapped)
Convert an IPv4-mapped IPv6 address into an IPv4 address.
#define RTCP_MIN_INTERVALMS
static int __rtp_recvfrom(struct ast_rtp_instance *instance, void *buf, size_t size, int flags, struct ast_sockaddr *sa, int rtcp)
int ast_tvzero(const struct timeval t)
Returns true if the argument is 0,0.
#define AST_LIST_NEXT(elm, field)
Returns the next entry in the list after the given entry.
static void put_unaligned_uint32(void *p, unsigned int datum)
static void timeval2ntp(struct timeval tv, unsigned int *msw, unsigned int *lsw)
Configuration File Parser.
unsigned int reported_jitter
int(* protect)(struct ast_srtp *srtp, void **buf, int *size, int rtcp)
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
static force_inline int ast_format_rate(format_t format)
Get the sample rate for a given format.
static struct ast_frame * create_dtmf_frame(struct ast_rtp_instance *instance, enum ast_frame_type type, int compensate)
#define ast_frame_byteswap_be(fr)
#define AST_LIST_EMPTY(head)
Checks whether the specified list contains any entries.
#define AST_MODULE_INFO(keystr, flags_to_set, desc, fields...)
int64_t ast_tvdiff_ms(struct timeval end, struct timeval start)
Computes the difference (in milliseconds) between two struct timeval instances.
static char * rtcp_do_debug_ip(struct ast_cli_args *a)
struct ast_frame * ast_frisolate(struct ast_frame *fr)
Makes a frame independent of any static storage.
int ast_sockaddr_cmp(const struct ast_sockaddr *a, const struct ast_sockaddr *b)
Compares two ast_sockaddr structures.
void ast_cli(int fd, const char *fmt,...)
static int ast_rtp_qos_set(struct ast_rtp_instance *instance, int tos, int cos, const char *desc)
static void ast_rtp_update_source(struct ast_rtp_instance *instance)
int ast_stun_handle_packet(int s, struct sockaddr_in *src, unsigned char *data, size_t len, stun_cb_f *stun_cb, void *arg)
handle an incoming STUN message.
struct ast_srtp * ast_rtp_instance_get_srtp(struct ast_rtp_instance *instance)
Obtain the SRTP instance associated with an RTP instance.
static int ast_rtp_destroy(struct ast_rtp_instance *instance)
Socket address structure.
struct ast_config * ast_config_load2(const char *filename, const char *who_asked, struct ast_flags flags)
Load a config file.
int ast_bind(int sockfd, const struct ast_sockaddr *addr)
Wrapper around bind(2) that uses struct ast_sockaddr.
int(* unprotect)(struct ast_srtp *srtp, void *buf, int *size, int rtcp)
#define ast_verb(level,...)
int ast_sockaddr_cmp_addr(const struct ast_sockaddr *a, const struct ast_sockaddr *b)
Compares the addresses of two ast_sockaddr structures.
unsigned int expected_prior
void ast_config_destroy(struct ast_config *config)
Destroys a config.
static void ast_rtp_stun_request(struct ast_rtp_instance *instance, struct ast_sockaddr *suggestion, const char *username)
#define RTCP_MAX_INTERVALMS
static char * handle_cli_rtp_set_debug(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static int rtcp_recvfrom(struct ast_rtp_instance *instance, void *buf, size_t size, int flags, struct ast_sockaddr *sa)
static void ast_sockaddr_setnull(struct ast_sockaddr *addr)
Sets address addr to null.
struct sched_context * sched
int args
This gets set in ast_cli_register()
static int ast_rtp_dtmf_mode_set(struct ast_rtp_instance *instance, enum ast_rtp_dtmf_mode dtmf_mode)
static int rtp_red_buffer(struct ast_rtp_instance *instance, struct ast_frame *frame)
#define AST_RED_MAX_GENERATION
#define CONFIG_STATUS_FILEMISSING
static int ast_sockaddr_isnull(const struct ast_sockaddr *addr)
Checks if the ast_sockaddr is null. "null" in this sense essentially means uninitialized, or having a 0 length.
#define ast_sockaddr_port(addr)
Get the port number of a socket address.
unsigned char rawdata[8192+AST_FRIENDLY_OFFSET]
struct ast_format_list ast_codec_pref_getsize(struct ast_codec_pref *pref, format_t format)
Get packet size for codec.
static int ast_rtp_raw_write(struct ast_rtp_instance *instance, struct ast_frame *frame, int codec)
static int rtp_debug_test_addr(struct ast_sockaddr *addr)
#define ast_debug(level,...)
Log a DEBUG message.
Handle unaligned data access.
static int ast_rtcp_write_rr(struct ast_rtp_instance *instance)
Send RTCP recipient's report.
unsigned int rxoctetcount
int ast_sockaddr_split_hostport(char *str, char **host, char **port, int flags)
Splits a string into its host and port components.
#define AST_SMOOTHER_FLAG_BE
#define FLAG_NAT_INACTIVE_NOWARN
General Asterisk PBX channel definitions.
#define AST_FRIENDLY_OFFSET
Offset into a frame's data buffer.
#define AST_SCHED_DEL(sched, id)
a loop construct to ensure that the scheduled task get deleted. The idea is that if we loop attemptin...
double accumulated_transit
#define ast_sockaddr_from_sin(addr, sin)
Converts a struct sockaddr_in to a struct ast_sockaddr.
int ast_rtp_engine_unregister(struct ast_rtp_engine *engine)
Unregister an RTP engine.
void ast_rtp_instance_set_data(struct ast_rtp_instance *instance, void *data)
Set the data portion of an RTP instance.
#define AST_FORMAT_T140RED
double reported_normdev_lost
int ast_stun_request(int s, struct sockaddr_in *dst, const char *username, struct sockaddr_in *answer)
Generic STUN request.
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Access Control of various sorts.
Asterisk internal frame definitions.
static struct ast_sockaddr rtpdebugaddr
static char * handle_cli_rtcp_set_stats(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static int unload_module(void)
Global IO variables are now in a struct in order to be made threadsafe.
static int ast_rtp_write(struct ast_rtp_instance *instance, struct ast_frame *frame)
struct ast_sockaddr alt_rtp_address
#define ao2_ref(o, delta)
static struct ast_sockaddr rtcpdebugaddr
long int ast_random(void)
struct timeval ast_samp2tv(unsigned int _nsamp, unsigned int _rate)
Returns a timeval corresponding to the duration of n samples at rate r. Useful to convert samples to ...
int ast_rtp_instance_set_remote_address(struct ast_rtp_instance *instance, const struct ast_sockaddr *address)
Set the address of the remote endpoint that we are sending RTP to.
double local_stdevrxploss
static void process_dtmf_rfc2833(struct ast_rtp_instance *instance, unsigned char *data, int len, unsigned int seqno, unsigned int timestamp, struct ast_sockaddr *addr, int payloadtype, int mark, struct frame_list *frames)
static int ast_rtp_dtmf_continuation(struct ast_rtp_instance *instance)
#define FLAG_NEED_MARKER_BIT
static struct ast_frame * process_cn_rfc3389(struct ast_rtp_instance *instance, unsigned char *data, int len, unsigned int seqno, unsigned int timestamp, struct ast_sockaddr *addr, int payloadtype, int mark)
static void ast_rtp_stop(struct ast_rtp_instance *instance)
#define AST_FORMAT_SLINEAR16
Core PBX routines and definitions.
static void ast_rtp_alt_remote_address_set(struct ast_rtp_instance *instance, struct ast_sockaddr *addr)
double remote_normdevrxploss
int ast_rtp_instance_set_local_address(struct ast_rtp_instance *instance, const struct ast_sockaddr *address)
Set the address that we are expecting to receive RTP on.
#define DEFAULT_LEARNING_MIN_SEQUENTIAL
static double stddev_compute(double stddev, double sample, double normdev, double normdev_curent, unsigned int sample_count)
The AMI - Asterisk Manager Interface - is a TCP protocol created to manage Asterisk with third-party ...
#define AST_LIST_HEAD_NOLOCK(name, type)
Defines a structure to be used to hold a list of specified type (with no lock).
#define ast_strdupa(s)
duplicate a string in memory from the stack
static int rtp_recvfrom(struct ast_rtp_instance *instance, void *buf, size_t size, int flags, struct ast_sockaddr *sa)
static void ast_rtp_remote_address_set(struct ast_rtp_instance *instance, struct ast_sockaddr *addr)
static int rtcp_debug_test_addr(struct ast_sockaddr *addr)
void timersub(struct timeval *tvend, struct timeval *tvstart, struct timeval *tvdiff)
char * ast_getformatname(format_t format)
Get the name of a format.
int ast_tvcmp(struct timeval _a, struct timeval _b)
Compres two struct timeval instances returning -1, 0, 1 if the first arg is smaller, equal or greater to the second.
#define AST_LIST_INSERT_TAIL(head, elm, field)
Appends a list entry to the tail of a list.
#define AST_FORMAT_SIREN7
static double normdev_compute(double normdev, double sample, unsigned int sample_count)
Calculate normal deviation.
int attribute_pure ast_true(const char *val)
Make sure something is true. Determine if a string containing a boolean value is "true". This function checks to see whether a string passed to it is an indication of an "true" value. It checks to see if the string is "yes", "true", "y", "t", "on" or "1".
#define DEFAULT_RTP_START
unsigned int reported_lost
static int rtp_reload(int reload)
unsigned int received_prior
#define ast_sockaddr_set_port(addr, port)
Sets the port number of a socket address.
static struct ast_frame * ast_rtp_read(struct ast_rtp_instance *instance, int rtcp)
int ast_set_qos(int sockfd, int tos, int cos, const char *desc)
Set type of service.
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
static struct ast_frame * ast_rtcp_read(struct ast_rtp_instance *instance)
unsigned int dtmf_timeout
struct timeval ast_tvadd(struct timeval a, struct timeval b)
Returns the sum of two timevals a + b.
static enum ast_rtp_dtmf_mode ast_rtp_dtmf_mode_get(struct ast_rtp_instance *instance)
static char * ast_sockaddr_stringify(const struct ast_sockaddr *addr)
Wrapper around ast_sockaddr_stringify_fmt() with default format.
ssize_t ast_recvfrom(int sockfd, void *buf, size_t len, int flags, struct ast_sockaddr *src_addr)
Wrapper around recvfrom(2) that uses struct ast_sockaddr.
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
static unsigned int calc_txstamp(struct ast_rtp *rtp, struct timeval *delivery)
static int ast_rtp_get_stat(struct ast_rtp_instance *instance, struct ast_rtp_instance_stats *stats, enum ast_rtp_instance_stat stat)
#define AST_FORMAT_VIDEO_MASK
static int ast_rtp_sendcng(struct ast_rtp_instance *instance, int level)
generate comfort noice (CNG)
#define AST_RTP_CISCO_DTMF
double reported_maxjitter
unsigned char t140red_data[64000]
Structure defining an RTCP session.
#define RTCP_DEFAULT_INTERVALMS
void * ast_rtp_instance_get_data(struct ast_rtp_instance *instance)
Get the data portion of an RTP instance.
static int __rtp_sendto(struct ast_rtp_instance *instance, void *buf, size_t size, int flags, struct ast_sockaddr *sa, int rtcp)
struct ast_srtp_res * res_srtp
#define AST_FORMAT_AUDIO_MASK
void ast_rtp_instance_get_remote_address(struct ast_rtp_instance *instance, struct ast_sockaddr *address)
Get the address of the remote endpoint that we are sending RTP to.
struct ast_sockaddr strict_rtp_address
unsigned char pt[AST_RED_MAX_GENERATION]
#define AST_FORMAT_SIREN14
static void calc_rxstamp(struct timeval *tv, struct ast_rtp *rtp, unsigned int timestamp, int mark)
int ast_smoother_test_flag(struct ast_smoother *s, int flag)
#define DTMF_SAMPLE_RATE_MS
static char * rtp_do_debug_ip(struct ast_cli_args *a)
if(yyss+yystacksize-1<=yyssp)
static int rtp_learning_rtp_seq_update(struct ast_rtp *rtp, uint16_t seq)
static void * cleanup(void *unused)
void ast_rtp_instance_get_local_address(struct ast_rtp_instance *instance, struct ast_sockaddr *address)
Get the local address that we are expecting RTP on.
Structure used to handle boolean flags.
unsigned int dtmf_duration
static int rtp_get_rate(format_t subclass)
#define ast_clear_flag(p, flag)
ast_frame_type
Frame types.
unsigned int lastsrtxcount
static void ast_rtp_change_source(struct ast_rtp_instance *instance)
static int load_module(void)
struct ast_smoother * smoother
#define EVENT_FLAG_REPORTING
static struct ast_cli_entry cli_rtp[]
unsigned int lastividtimestamp
static volatile unsigned int seq
unsigned int txoctetcount
#define AST_LIST_HEAD_INIT_NOLOCK(head)
Initializes a list head structure.
unsigned char buf_data[64000]
static int rtp_red_init(struct ast_rtp_instance *instance, int buffer_time, int *payloads, int generations)
static struct ast_rtp_engine asterisk_rtp_engine
unsigned char len[AST_RED_MAX_GENERATION]
static int reconstruct(int sign, int dqln, int y)
#define AST_FORMAT_SLINEAR
Standard Command Line Interface.
static int ast_rtp_new(struct ast_rtp_instance *instance, struct sched_context *sched, struct ast_sockaddr *addr, void *data)
struct timeval ast_tv(ast_time_t sec, ast_suseconds_t usec)
Returns a timeval from sec, usec.
#define AST_RTP_STAT_SET(current_stat, combined, placement, value)
int ast_codec_get_samples(struct ast_frame *f)
Returns the number of samples contained in the frame.
int attribute_pure ast_false(const char *val)
Make sure something is false. Determine if a string containing a boolean value is "false"...
int ast_cli_register_multiple(struct ast_cli_entry *e, int len)
Register multiple commands.
struct ast_rtp_instance * ast_rtp_instance_get_bridged(struct ast_rtp_instance *instance)
Get the other RTP instance that an instance is bridged to.
static int ast_rtcp_write_sr(struct ast_rtp_instance *instance)
Send RTCP sender's report.
int ast_rtp_instance_get_prop(struct ast_rtp_instance *instance, enum ast_rtp_property property)
Get the value of an RTP instance property.
static unsigned int ast_rtcp_calc_interval(struct ast_rtp *rtp)
static int learning_min_sequential
static char * handle_cli_rtcp_set_debug(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
#define AST_RTP_STAT_TERMINATOR(combined)
int ast_sockaddr_is_ipv4(const struct ast_sockaddr *addr)
Determine if the address is an IPv4 address.
static void ast_rtp_prop_set(struct ast_rtp_instance *instance, enum ast_rtp_property property, int value)
Data structure associated with a single frame of data.
static int bridge_p2p_rtp_write(struct ast_rtp_instance *instance, unsigned int *rtpheader, int len, int hdrlen)
double remote_stdevrxploss
static struct ast_frame * process_dtmf_cisco(struct ast_rtp_instance *instance, unsigned char *data, int len, unsigned int seqno, unsigned int timestamp, struct ast_sockaddr *addr, int payloadtype, int mark)
static int create_new_socket(const char *type, int af)
struct timeval ast_tvsub(struct timeval a, struct timeval b)
Returns the difference of two timevals a - b.
static int red_write(const void *data)
Write t140 redundacy frame.
#define ast_sockaddr_to_sin(addr, sin)
Converts a struct ast_sockaddr to a struct sockaddr_in.
unsigned int reported_jitter_count
static int reload_module(void)
enum ast_frame_type frametype
static void rtp_learning_seq_init(struct ast_rtp *rtp, uint16_t seq)
uint16_t learning_max_seq
static struct ast_frame * red_t140_to_red(struct rtp_red *red)
enum ast_rtp_dtmf_mode dtmfmode
#define CONFIG_STATUS_FILEINVALID
double local_normdevjitter
unsigned char buf[8192+AST_FRIENDLY_OFFSET]
static int rtcp_sendto(struct ast_rtp_instance *instance, void *buf, size_t size, int flags, struct ast_sockaddr *sa)
static int ast_rtp_dtmf_end(struct ast_rtp_instance *instance, char digit)
#define MAX_TIMESTAMP_SKEW
#define ASTERISK_GPL_KEY
The text the key() function should return.
#define manager_event(category, event, contents,...)
External routines may send asterisk manager events this way.
Pluggable RTP Architecture.
Asterisk module definitions.
union ast_frame::@172 data
struct ast_channel_tech * tech
unsigned int lastitexttimestamp
int ast_rtp_codecs_payload_code(struct ast_rtp_codecs *codecs, const int asterisk_format, const format_t code)
Retrieve a payload based on whether it is an Asterisk format and the code.
struct ast_rtp_instance * rtp
unsigned short seedrxseqno
#define FLAG_NAT_INACTIVE
#define ast_smoother_feed_be(s, f)
int ast_sockaddr_is_ipv6(const struct ast_sockaddr *addr)
Determine if this is an IPv6 address.
unsigned int last_end_timestamp
struct ast_frame * ast_frdup(const struct ast_frame *fr)
Copies a frame.
#define ASTERISK_FILE_VERSION(file, version)
Register/unregister a source code file with the core.
#define CONFIG_STATUS_FILEUNCHANGED
#define ast_smoother_feed(s, f)
static int ast_rtp_local_bridge(struct ast_rtp_instance *instance0, struct ast_rtp_instance *instance1)
#define AST_FORMAT_SPEEX16
double reported_normdev_jitter