mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-09 10:59:39 +00:00
[MOVED FROM GST-P-FARSIGHT] Better handling of packets, we send the same duration for all packets to avoid huge packets when min duration defines are modified.
20070827172339-4f0f6-cc93304437ea376fff6458c74c46c19f6920d329.gz
This commit is contained in:
parent
d5110d76e9
commit
bb4f9fa477
1 changed files with 15 additions and 24 deletions
|
@ -689,39 +689,30 @@ static GstBuffer *
|
||||||
gst_dtmf_src_create_next_tone_packet (GstDTMFSrc *dtmfsrc, GstDTMFSrcEvent *event)
|
gst_dtmf_src_create_next_tone_packet (GstDTMFSrc *dtmfsrc, GstDTMFSrcEvent *event)
|
||||||
{
|
{
|
||||||
GstBuffer *buf = NULL;
|
GstBuffer *buf = NULL;
|
||||||
guint32 duration;
|
gboolean send_silence = FALSE;
|
||||||
|
|
||||||
|
GST_DEBUG_OBJECT (dtmfsrc, "Creating buffer for tone %s", DTMF_KEYS[event->event_number].event_name);
|
||||||
GST_DEBUG_OBJECT (dtmfsrc,
|
|
||||||
"Creating buffer for tone");
|
|
||||||
|
|
||||||
/* create buffer to hold the tone */
|
/* create buffer to hold the tone */
|
||||||
buf = gst_buffer_new ();
|
buf = gst_buffer_new ();
|
||||||
|
|
||||||
/* The first packet must be inter digit silence, then the second and third must be the
|
if (event->packet_count * dtmfsrc->interval < MIN_INTER_DIGIT_INTERVAL) {
|
||||||
* minimal pulse duration divided into two packets to make it small
|
send_silence = TRUE;
|
||||||
*/
|
}
|
||||||
switch(event->packet_count) {
|
|
||||||
case 0:
|
if (send_silence) {
|
||||||
duration = MIN_INTER_DIGIT_INTERVAL;
|
GST_DEBUG_OBJECT (dtmfsrc, "Generating silence");
|
||||||
gst_dtmf_src_generate_silence (buf, duration);
|
gst_dtmf_src_generate_silence (buf, dtmfsrc->interval);
|
||||||
break;
|
} else {
|
||||||
case 1:
|
GST_DEBUG_OBJECT (dtmfsrc, "Generating tone");
|
||||||
case 2:
|
gst_dtmf_src_generate_tone(event, DTMF_KEYS[event->event_number],
|
||||||
/* Generate the tone */
|
dtmfsrc->interval, buf);
|
||||||
duration = MIN_PULSE_DURATION / 2;
|
|
||||||
gst_dtmf_src_generate_tone(event, DTMF_KEYS[event->event_number], duration, buf);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
duration = dtmfsrc->interval;
|
|
||||||
gst_dtmf_src_generate_tone(event, DTMF_KEYS[event->event_number], duration, buf);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
event->packet_count++;
|
event->packet_count++;
|
||||||
|
|
||||||
|
|
||||||
/* timestamp and duration of GstBuffer */
|
/* timestamp and duration of GstBuffer */
|
||||||
GST_BUFFER_DURATION (buf) = duration * GST_MSECOND;
|
GST_BUFFER_DURATION (buf) = dtmfsrc->interval * GST_MSECOND;
|
||||||
GST_BUFFER_TIMESTAMP (buf) = dtmfsrc->timestamp;
|
GST_BUFFER_TIMESTAMP (buf) = dtmfsrc->timestamp;
|
||||||
dtmfsrc->timestamp += GST_BUFFER_DURATION (buf);
|
dtmfsrc->timestamp += GST_BUFFER_DURATION (buf);
|
||||||
|
|
||||||
|
@ -757,7 +748,7 @@ gst_dtmf_src_push_next_tone_packet (GstDTMFSrc *dtmfsrc)
|
||||||
event->packet_count = 0;
|
event->packet_count = 0;
|
||||||
dtmfsrc->last_event = event;
|
dtmfsrc->last_event = event;
|
||||||
}
|
}
|
||||||
} else if (dtmfsrc->last_event->packet_count >= 3) {
|
} else if (dtmfsrc->last_event->packet_count * dtmfsrc->interval >= MIN_DUTY_CYCLE) {
|
||||||
event = g_async_queue_try_pop (dtmfsrc->event_queue);
|
event = g_async_queue_try_pop (dtmfsrc->event_queue);
|
||||||
|
|
||||||
if (event != NULL) {
|
if (event != NULL) {
|
||||||
|
|
Loading…
Reference in a new issue