[asterisk-commits] oej: branch oej/rana-dtmf-duration-1.8 r403286 - in /team/oej/rana-dtmf-durat...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Mon Dec 2 05:14:36 CST 2013
Author: oej
Date: Mon Dec 2 05:14:34 2013
New Revision: 403286
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=403286
Log:
Resolve stuff
Modified:
team/oej/rana-dtmf-duration-1.8/ (props changed)
team/oej/rana-dtmf-duration-1.8/main/translate.c
team/oej/rana-dtmf-duration-1.8/res/res_rtp_asterisk.c
Propchange: team/oej/rana-dtmf-duration-1.8/
------------------------------------------------------------------------------
automerge = Is-there-life-off-net?
Propchange: team/oej/rana-dtmf-duration-1.8/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Mon Dec 2 05:14:34 2013
@@ -1,1 +1,1 @@
-/branches/1.8:1-401610
+/branches/1.8:1-401659
Modified: team/oej/rana-dtmf-duration-1.8/main/translate.c
URL: http://svnview.digium.com/svn/asterisk/team/oej/rana-dtmf-duration-1.8/main/translate.c?view=diff&rev=403286&r1=403285&r2=403286
==============================================================================
--- team/oej/rana-dtmf-duration-1.8/main/translate.c (original)
+++ team/oej/rana-dtmf-duration-1.8/main/translate.c Mon Dec 2 05:14:34 2013
@@ -385,6 +385,10 @@
/* Predict next outgoing timestamp from samples in this
frame. */
path->nextout = ast_tvadd(path->nextout, ast_samp2tv(out->samples, ast_format_rate(out->subclass.codec)));
+ if (f->samples != out->samples && ast_test_flag(out, AST_FRFLAG_HAS_TIMING_INFO)) {
+ ast_debug(4, "Sample size different %u vs %u\n", f->samples, out->samples);
+ ast_clear_flag(out, AST_FRFLAG_HAS_TIMING_INFO);
+ }
} else {
out->delivery = ast_tv(0, 0);
ast_set2_flag(out, has_timing_info, AST_FRFLAG_HAS_TIMING_INFO);
Modified: team/oej/rana-dtmf-duration-1.8/res/res_rtp_asterisk.c
URL: http://svnview.digium.com/svn/asterisk/team/oej/rana-dtmf-duration-1.8/res/res_rtp_asterisk.c?view=diff&rev=403286&r1=403285&r2=403286
==============================================================================
--- team/oej/rana-dtmf-duration-1.8/res/res_rtp_asterisk.c (original)
+++ team/oej/rana-dtmf-duration-1.8/res/res_rtp_asterisk.c Mon Dec 2 05:14:34 2013
@@ -75,6 +75,7 @@
#define RTCP_PT_APP 204
#define RTP_MTU 1200
+#define DTMF_SAMPLE_RATE_MS 8 /*!< DTMF samples per millisecond */
#define DEFAULT_DTMF_TIMEOUT (150 * (8000 / 1000)) /*!< samples */
@@ -552,6 +553,35 @@
return probation;
}
+/*!
+ * \internal
+ * \brief Calculates the elapsed time from issue of the first tx packet in an
+ * rtp session and a specified time
+ *
+ * \param rtp pointer to the rtp struct with the transmitted rtp packet
+ * \param delivery time of delivery - if NULL or zero value, will be ast_tvnow()
+ *
+ * \return time elapsed in milliseconds
+ */
+static unsigned int calc_txstamp(struct ast_rtp *rtp, struct timeval *delivery)
+{
+ struct timeval t;
+ long ms;
+
+ if (ast_tvzero(rtp->txcore)) {
+ rtp->txcore = ast_tvnow();
+ rtp->txcore.tv_usec -= rtp->txcore.tv_usec % 20000;
+ }
+
+ t = (delivery && !ast_tvzero(*delivery)) ? *delivery : ast_tvnow();
+ if ((ms = ast_tvdiff_ms(t, rtp->txcore)) < 0) {
+ ms = 0;
+ }
+ rtp->txcore = t;
+
+ return (unsigned int) ms;
+}
+
static int ast_rtp_new(struct ast_rtp_instance *instance,
struct sched_context *sched, struct ast_sockaddr *addr,
void *data)
@@ -721,8 +751,9 @@
payload = ast_rtp_codecs_payload_code(ast_rtp_instance_get_codecs(instance), 0, AST_RTP_DTMF);
rtp->dtmfmute = ast_tvadd(ast_tvnow(), ast_tv(0, 500000));
- rtp->send_duration = 160;
+ rtp->send_duration = 160; /* XXX This assumes 20 ms packetization */
rtp->received_duration = 160;
+ rtp->lastts += calc_txstamp(rtp, NULL) * DTMF_SAMPLE_RATE_MS;
rtp->lastdigitts = rtp->lastts + rtp->send_duration;
/* Create the actual packet that we will be sending */
@@ -865,6 +896,7 @@
rtp->seqno++;
rtp->send_duration += 160; /* Again assuming 20 ms packetization and 8000 samples */
ast_debug(4, "---- Adding 160 samples after sending : Send duration %d Received duration %d\n", rtp->send_duration, rtp->received_duration);
+ rtp->lastts += calc_txstamp(rtp, NULL) * DTMF_SAMPLE_RATE_MS;
return 0;
}
@@ -949,7 +981,7 @@
res = 0;
/* Oh and we can't forget to turn off the stuff that says we are sending DTMF */
- rtp->lastts += rtp->send_duration;
+ rtp->lastts += calc_txstamp(rtp, NULL) * DTMF_SAMPLE_RATE_MS;
cleanup:
rtp->sending_dtmf = DTMF_NOT_SENDING;
@@ -998,25 +1030,6 @@
rtp->ssrc = ssrc;
return;
-}
-
-static unsigned int calc_txstamp(struct ast_rtp *rtp, struct timeval *delivery)
-{
- struct timeval t;
- long ms;
-
- if (ast_tvzero(rtp->txcore)) {
- rtp->txcore = ast_tvnow();
- rtp->txcore.tv_usec -= rtp->txcore.tv_usec % 20000;
- }
-
- t = (delivery && !ast_tvzero(*delivery)) ? *delivery : ast_tvnow();
- if ((ms = ast_tvdiff_ms(t, rtp->txcore)) < 0) {
- ms = 0;
- }
- rtp->txcore = t;
-
- return (unsigned int) ms;
}
static void timeval2ntp(struct timeval tv, unsigned int *msw, unsigned int *lsw)
More information about the asterisk-commits
mailing list