rtpdtmfsrc: Put the inter digit interval at the end, not at the start

The reason is to let rtpdtmfmux drop buffers during the inter digit interval,
this way, there will be more silence around the DTMF tones so IVFs will have
a better chance recognizing them.
This commit is contained in:
Olivier Crête 2011-07-11 20:46:20 -04:00
parent 7837cc25fb
commit e6c431a533

View file

@ -514,8 +514,7 @@ gst_rtp_dtmf_prepare_timestamps (GstRTPDTMFSrc * dtmfsrc)
if (clock == NULL) if (clock == NULL)
return FALSE; return FALSE;
dtmfsrc->timestamp = gst_clock_get_time (clock) dtmfsrc->start_timestamp = gst_clock_get_time (clock)
+ (MIN_INTER_DIGIT_INTERVAL * GST_MSECOND)
- gst_element_get_base_time (GST_ELEMENT (dtmfsrc)); - gst_element_get_base_time (GST_ELEMENT (dtmfsrc));
dtmfsrc->start_timestamp = dtmfsrc->timestamp; dtmfsrc->start_timestamp = dtmfsrc->timestamp;
gst_object_unref (clock); gst_object_unref (clock);
@ -591,7 +590,6 @@ gst_rtp_dtmf_prepare_buffer_data (GstRTPDTMFSrc * dtmfsrc, GstBuffer * buf)
GST_BUFFER_DURATION (buf) = dtmfsrc->ptime * GST_MSECOND; GST_BUFFER_DURATION (buf) = dtmfsrc->ptime * GST_MSECOND;
GST_BUFFER_TIMESTAMP (buf) = dtmfsrc->timestamp; GST_BUFFER_TIMESTAMP (buf) = dtmfsrc->timestamp;
dtmfsrc->timestamp += GST_BUFFER_DURATION (buf);
payload = (GstRTPDTMFPayload *) gst_rtp_buffer_get_payload (buf); payload = (GstRTPDTMFPayload *) gst_rtp_buffer_get_payload (buf);
@ -606,6 +604,18 @@ gst_rtp_dtmf_prepare_buffer_data (GstRTPDTMFSrc * dtmfsrc, GstBuffer * buf)
if (dtmfsrc->redundancy_count == 0) if (dtmfsrc->redundancy_count == 0)
dtmfsrc->payload->duration += dtmfsrc->ptime * dtmfsrc->clock_rate / 1000; dtmfsrc->payload->duration += dtmfsrc->ptime * dtmfsrc->clock_rate / 1000;
if (dtmfsrc->redundancy_count == 0 && dtmfsrc->last_packet) {
GstClockTime inter_digit_interval = MIN_INTER_DIGIT_INTERVAL;
if (inter_digit_interval % dtmfsrc->ptime != 0)
inter_digit_interval += dtmfsrc->ptime -
(MIN_INTER_DIGIT_INTERVAL % dtmfsrc->ptime);
GST_BUFFER_DURATION (buf) += inter_digit_interval * GST_MSECOND;
}
if (GST_CLOCK_TIME_IS_VALID (dtmfsrc->timestamp))
dtmfsrc->timestamp += GST_BUFFER_DURATION (buf);
} }
static GstBuffer * static GstBuffer *