From 074189363e4def66041756597462b788773762cd Mon Sep 17 00:00:00 2001 From: Olivier Crete Date: Thu, 12 Jul 2007 19:55:28 +0000 Subject: [MOVED FROM GST-P-FARSIGHT] Put non-zero duration in first packet and put a minimum duration of 50ms 20070712195528-3e2dc-d46edeaab84fb55e74842bdcf4f8792dfcdb0457.gz --- gst/rtpdtmf/gstrtpdtmfsrc.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/gst/rtpdtmf/gstrtpdtmfsrc.c b/gst/rtpdtmf/gstrtpdtmfsrc.c index a31957f9..b20254ea 100644 --- a/gst/rtpdtmf/gstrtpdtmfsrc.c +++ b/gst/rtpdtmf/gstrtpdtmfsrc.c @@ -144,6 +144,7 @@ #define MAX_EVENT_STRING "16" #define MIN_VOLUME 0 #define MAX_VOLUME 36 +#define MIN_EVENT_DURATION 50 #define DEFAULT_PACKET_REDUNDANCY 1 #define MIN_PACKET_REDUNDANCY 1 @@ -659,6 +660,10 @@ gst_rtp_dtmf_prepare_buffer_data (GstRTPDTMFSrc *dtmfsrc, GstBuffer *buf) gst_rtp_dtmf_prepare_rtp_headers (dtmfsrc, buf); + /* duration of DTMF payload */ + dtmfsrc->payload->duration += + dtmfsrc->interval * dtmfsrc->clock_rate / 1000; + /* timestamp and duration of GstBuffer */ GST_BUFFER_DURATION (buf) = dtmfsrc->interval * GST_MSECOND; GST_BUFFER_TIMESTAMP (buf) = dtmfsrc->timestamp; @@ -668,12 +673,14 @@ gst_rtp_dtmf_prepare_buffer_data (GstRTPDTMFSrc *dtmfsrc, GstBuffer *buf) /* copy payload and convert to network-byte order */ g_memmove (payload, dtmfsrc->payload, sizeof (GstRTPDTMFPayload)); - payload->duration = g_htons (payload->duration); - - /* duration of DTMF payload */ - dtmfsrc->payload->duration += - dtmfsrc->interval * dtmfsrc->clock_rate / 1000; + /* Force the packet duration to a certain minumum + * if its the end of the event + */ + if (payload->e && + payload->duration < MIN_EVENT_DURATION * dtmfsrc->clock_rate / 1000) + payload->duration = MIN_EVENT_DURATION * dtmfsrc->clock_rate / 1000; + payload->duration = g_htons (payload->duration); } static GstBuffer * -- cgit v1.2.1