[asterisk-commits] file: branch group/vldtmf r39836 -
/team/group/vldtmf/rtp.c
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Tue Aug 15 10:57:44 MST 2006
Author: file
Date: Tue Aug 15 12:57:44 2006
New Revision: 39836
URL: http://svn.digium.com/view/asterisk?rev=39836&view=rev
Log:
Add latest round of fixes. This totally works (inbound/outbound/compensation) but is currently subject to change after lunch.
Modified:
team/group/vldtmf/rtp.c
Modified: team/group/vldtmf/rtp.c
URL: http://svn.digium.com/view/asterisk/team/group/vldtmf/rtp.c?rev=39836&r1=39835&r2=39836&view=diff
==============================================================================
--- team/group/vldtmf/rtp.c (original)
+++ team/group/vldtmf/rtp.c Tue Aug 15 12:57:44 2006
@@ -133,6 +133,7 @@
unsigned int lasteventendseqn;
int dtmfcount;
unsigned int dtmfduration;
+ int receive_compensate;
/* DTMF Transmission Variables */
unsigned int lastdigitts;
char send_digit;
@@ -168,6 +169,8 @@
static int ast_rtcp_write_sr(void *data);
static int ast_rtcp_write_rr(void *data);
static unsigned int ast_rtcp_calc_interval(struct ast_rtp *rtp);
+static int ast_rtp_senddigit_continuation(struct ast_rtp *rtp);
+int ast_rtp_senddigit_end(struct ast_rtp *rtp, char digit);
#define FLAG_3389_WARNING (1 << 0)
#define FLAG_NAT_ACTIVE (3 << 1)
@@ -663,14 +666,18 @@
resp = 'X';
}
- if ((!(rtp->resp) && (!(event_end & 0x80))) || (rtp->resp && rtp->resp != resp)) {
+ if (((!(rtp->resp) && (!(event_end & 0x80))) || (rtp->resp && rtp->resp != resp)) && !ast_test_flag(rtp, FLAG_DTMF_COMPENSATE)) {
rtp->resp = resp;
f = send_dtmf(rtp, AST_FRAME_DTMF_BEGIN);
- } else if ((event_end & 0x80) && rtp->resp && rtp->lasteventendseqn != seqno && !ast_test_flag(rtp, FLAG_DTMF_COMPENSATE)) {
- /* If we are compensating then our AST_FRAME_DTMF_END will come from elsewhere */
- rtp->lasteventendseqn = seqno;
- f = send_dtmf(rtp, AST_FRAME_DTMF_END);
- rtp->resp = 0;
+ } else if (event_end & 0x80) {
+ if (!rtp->resp && ast_test_flag(rtp, FLAG_DTMF_COMPENSATE)) {
+ rtp->resp = resp;
+ f = send_dtmf(rtp, AST_FRAME_DTMF_BEGIN);
+ } else if (rtp->resp && rtp->lasteventendseqn != seqno && !ast_test_flag(rtp, FLAG_DTMF_COMPENSATE)) {
+ rtp->lasteventendseqn = seqno;
+ f = send_dtmf(rtp, AST_FRAME_DTMF_END);
+ rtp->resp = 0;
+ }
}
rtp->dtmfcount = dtmftimeout;
@@ -954,6 +961,15 @@
struct rtpPayloadType rtpPT;
struct ast_frame *fr = NULL;
+ /* If time is up, kill it */
+ if (rtp->send_compensate >= 1) {
+ if (rtp->send_compensate == 7)
+ ast_rtp_senddigit_end(rtp, rtp->send_digit);
+ else
+ rtp->send_compensate++;
+ } else if (rtp->send_digit)
+ ast_rtp_senddigit_continuation(rtp);
+
len = sizeof(sin);
/* Cache where the header will go */
@@ -1119,11 +1135,15 @@
rtp->rxseqno = seqno;
/* If we are compensating for lack of VLDTMF, then check to see if we need to send an AST_FRAME_DTMF_END */
- if (rtp->resp && ast_test_flag(rtp, FLAG_DTMF_COMPENSATE) && (timestamp - rtp->lastrxts) >= rtp->dtmfduration) {
- fr = send_dtmf(rtp, AST_FRAME_DTMF_END);
- rtp->lastrxts = timestamp;
- rtp->resp = 0;
- return fr;
+ if (rtp->resp && ast_test_flag(rtp, FLAG_DTMF_COMPENSATE)) {
+ /* We wait for 6 regular frames to come in before queueing the AST_FRAME_DTMF_END */
+ if (rtp->receive_compensate >= 6) {
+ fr = send_dtmf(rtp, AST_FRAME_DTMF_END);
+ rtp->lastrxts = timestamp;
+ rtp->resp = 0;
+ return fr;
+ } else
+ rtp->receive_compensate++;
}
/* Record received timestamp as last received now */
@@ -1893,11 +1913,11 @@
if (digit_convert(digit))
return -1;
- payload = ast_rtp_lookup_code(rtp, 0, AST_RTP_DTMF);
-
/* If we have no peer, return immediately */
if (!rtp->them.sin_addr.s_addr)
return 0;
+
+ payload = ast_rtp_lookup_code(rtp, 0, AST_RTP_DTMF);
rtp->dtmfmute = ast_tvadd(ast_tvnow(), ast_tv(0, 500000));
@@ -2412,10 +2432,6 @@
ast_log(LOG_WARNING, "RTP can only send voice and video\n");
return -1;
}
-
- /* If a digit is currently active then send a continuation frame */
- if (rtp->send_digit)
- ast_rtp_senddigit_continuation(rtp);
subclass = _f->subclass;
if (_f->frametype == AST_FRAME_VIDEO)
More information about the asterisk-commits
mailing list