rtpdtmfsrc: Post the messages after the clock wait

This way, the messages will be closer in time to when the packets are sent out
This commit is contained in:
Olivier Crête 2013-01-25 20:39:33 -05:00
parent b69f09e26f
commit a2384408f0

View file

@ -642,12 +642,11 @@ gst_rtp_dtmf_src_create_next_rtp_packet (GstRTPDTMFSrc * dtmfsrc)
return buf; return buf;
} }
static GstMessage *
static void gst_dtmf_src_prepare_message (GstRTPDTMFSrc * dtmfsrc,
gst_dtmf_src_post_message (GstRTPDTMFSrc * dtmfsrc, const gchar * message_name, const gchar * message_name, GstRTPDTMFSrcEvent * event)
GstRTPDTMFSrcEvent * event)
{ {
GstStructure *s = NULL; GstStructure *s;
switch (event->event_type) { switch (event->event_type) {
case RTP_DTMF_EVENT_TYPE_START: case RTP_DTMF_EVENT_TYPE_START:
@ -664,12 +663,21 @@ gst_dtmf_src_post_message (GstRTPDTMFSrc * dtmfsrc, const gchar * message_name,
"start", G_TYPE_BOOLEAN, FALSE, NULL); "start", G_TYPE_BOOLEAN, FALSE, NULL);
break; break;
case RTP_DTMF_EVENT_TYPE_PAUSE_TASK: case RTP_DTMF_EVENT_TYPE_PAUSE_TASK:
return; return NULL;
} }
if (s) return gst_message_new_element (GST_OBJECT (dtmfsrc), s);
gst_element_post_message (GST_ELEMENT (dtmfsrc), }
gst_message_new_element (GST_OBJECT (dtmfsrc), s));
static void
gst_dtmf_src_post_message (GstRTPDTMFSrc * dtmfsrc, const gchar * message_name,
GstRTPDTMFSrcEvent * event)
{
GstMessage *m = gst_dtmf_src_prepare_message (dtmfsrc, message_name, event);
if (m)
gst_element_post_message (GST_ELEMENT (dtmfsrc), m);
} }
@ -682,6 +690,8 @@ gst_rtp_dtmf_src_create (GstBaseSrc * basesrc, guint64 offset,
GstClock *clock; GstClock *clock;
GstClockID *clockid; GstClockID *clockid;
GstClockReturn clockret; GstClockReturn clockret;
GstMessage *message;
GQueue messages = G_QUEUE_INIT;
dtmfsrc = GST_RTP_DTMF_SRC (basesrc); dtmfsrc = GST_RTP_DTMF_SRC (basesrc);
@ -708,7 +718,9 @@ gst_rtp_dtmf_src_create (GstBaseSrc * basesrc, guint64 offset,
if (!gst_rtp_dtmf_prepare_timestamps (dtmfsrc)) if (!gst_rtp_dtmf_prepare_timestamps (dtmfsrc))
goto no_clock; goto no_clock;
gst_dtmf_src_post_message (dtmfsrc, "dtmf-event-processed", event); g_queue_push_tail (&messages,
gst_dtmf_src_prepare_message (dtmfsrc, "dtmf-event-processed",
event));
dtmfsrc->payload = event->payload; dtmfsrc->payload = event->payload;
dtmfsrc->payload->duration = dtmfsrc->payload->duration =
dtmfsrc->ptime * dtmfsrc->clock_rate / 1000; dtmfsrc->ptime * dtmfsrc->clock_rate / 1000;
@ -752,7 +764,9 @@ gst_rtp_dtmf_src_create (GstBaseSrc * basesrc, guint64 offset,
dtmfsrc->last_packet = TRUE; dtmfsrc->last_packet = TRUE;
/* Set the redundancy on the last packet */ /* Set the redundancy on the last packet */
dtmfsrc->redundancy_count = dtmfsrc->packet_redundancy; dtmfsrc->redundancy_count = dtmfsrc->packet_redundancy;
gst_dtmf_src_post_message (dtmfsrc, "dtmf-event-processed", event); g_queue_push_tail (&messages,
gst_dtmf_src_prepare_message (dtmfsrc, "dtmf-event-processed",
event));
break; break;
case RTP_DTMF_EVENT_TYPE_PAUSE_TASK: case RTP_DTMF_EVENT_TYPE_PAUSE_TASK:
@ -801,6 +815,9 @@ gst_rtp_dtmf_src_create (GstBaseSrc * basesrc, guint64 offset,
dtmfsrc->clockid = NULL; dtmfsrc->clockid = NULL;
GST_OBJECT_UNLOCK (dtmfsrc); GST_OBJECT_UNLOCK (dtmfsrc);
while ((message = g_queue_pop_head (&messages)) != NULL)
gst_element_post_message (GST_ELEMENT (dtmfsrc), message);
if (clockret == GST_CLOCK_UNSCHEDULED) { if (clockret == GST_CLOCK_UNSCHEDULED) {
goto paused; goto paused;
} }