mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-24 17:20:36 +00:00
dtmfsrc: Reject start/stop requests that come out of order
This commit is contained in:
parent
d15d524fec
commit
d937da4c0c
4 changed files with 32 additions and 10 deletions
|
@ -330,6 +330,9 @@ gst_dtmf_src_handle_dtmf_event (GstDTMFSrc * dtmfsrc,
|
|||
gboolean start;
|
||||
gint method;
|
||||
GstClockTime last_stop;
|
||||
gint event_number;
|
||||
gint event_volume;
|
||||
gboolean correct_order;
|
||||
|
||||
if (!gst_structure_get_int (event_structure, "type", &event_type) ||
|
||||
!gst_structure_get_boolean (event_structure, "start", &start) ||
|
||||
|
@ -342,22 +345,25 @@ gst_dtmf_src_handle_dtmf_event (GstDTMFSrc * dtmfsrc,
|
|||
}
|
||||
}
|
||||
|
||||
if (start)
|
||||
if (!gst_structure_get_int (event_structure, "number", &event_number) ||
|
||||
!gst_structure_get_int (event_structure, "volume", &event_volume))
|
||||
goto failure;
|
||||
|
||||
|
||||
GST_OBJECT_LOCK (dtmfsrc);
|
||||
if (gst_structure_get_clock_time (event_structure, "last-stop", &last_stop))
|
||||
dtmfsrc->last_stop = last_stop;
|
||||
else
|
||||
dtmfsrc->last_stop = GST_CLOCK_TIME_NONE;
|
||||
correct_order = (start != dtmfsrc->last_event_was_start);
|
||||
dtmfsrc->last_event_was_start = start;
|
||||
GST_OBJECT_UNLOCK (dtmfsrc);
|
||||
|
||||
if (!correct_order)
|
||||
goto failure;
|
||||
|
||||
if (start) {
|
||||
gint event_number;
|
||||
gint event_volume;
|
||||
|
||||
if (!gst_structure_get_int (event_structure, "number", &event_number) ||
|
||||
!gst_structure_get_int (event_structure, "volume", &event_volume))
|
||||
goto failure;
|
||||
|
||||
GST_DEBUG_OBJECT (dtmfsrc, "Received start event %d with volume %d",
|
||||
event_number, event_volume);
|
||||
gst_dtmf_src_add_start_event (dtmfsrc, event_number, event_volume);
|
||||
|
@ -896,6 +902,7 @@ gst_dtmf_src_change_state (GstElement * element, GstStateChange transition)
|
|||
g_slice_free (GstDTMFSrcEvent, event);
|
||||
event = g_async_queue_try_pop (dtmfsrc->event_queue);
|
||||
}
|
||||
dtmfsrc->last_event_was_start = FALSE;
|
||||
dtmfsrc->timestamp = 0;
|
||||
no_preroll = TRUE;
|
||||
break;
|
||||
|
@ -922,6 +929,7 @@ gst_dtmf_src_change_state (GstElement * element, GstStateChange transition)
|
|||
g_slice_free (GstDTMFSrcEvent, event);
|
||||
event = g_async_queue_try_pop (dtmfsrc->event_queue);
|
||||
}
|
||||
dtmfsrc->last_event_was_start = FALSE;
|
||||
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -74,6 +74,7 @@ struct _GstDTMFSrc
|
|||
GstBaseSrc parent;
|
||||
GAsyncQueue *event_queue;
|
||||
GstDTMFSrcEvent *last_event;
|
||||
gboolean last_event_was_start;
|
||||
|
||||
guint16 interval;
|
||||
GstClockTime timestamp;
|
||||
|
|
|
@ -341,6 +341,9 @@ gst_rtp_dtmf_src_handle_dtmf_event (GstRTPDTMFSrc * dtmfsrc,
|
|||
gboolean start;
|
||||
gint method;
|
||||
GstClockTime last_stop;
|
||||
gint event_number;
|
||||
gint event_volume;
|
||||
gboolean correct_order;
|
||||
|
||||
if (!gst_structure_get_int (event_structure, "type", &event_type) ||
|
||||
!gst_structure_get_boolean (event_structure, "start", &start) ||
|
||||
|
@ -353,17 +356,24 @@ gst_rtp_dtmf_src_handle_dtmf_event (GstRTPDTMFSrc * dtmfsrc,
|
|||
}
|
||||
}
|
||||
|
||||
if (start)
|
||||
if (!gst_structure_get_int (event_structure, "number", &event_number) ||
|
||||
!gst_structure_get_int (event_structure, "volume", &event_volume))
|
||||
goto failure;
|
||||
|
||||
GST_OBJECT_LOCK (dtmfsrc);
|
||||
if (gst_structure_get_clock_time (event_structure, "last-stop", &last_stop))
|
||||
dtmfsrc->last_stop = last_stop;
|
||||
else
|
||||
dtmfsrc->last_stop = GST_CLOCK_TIME_NONE;
|
||||
correct_order = (start != dtmfsrc->last_event_was_start);
|
||||
dtmfsrc->last_event_was_start = start;
|
||||
GST_OBJECT_UNLOCK (dtmfsrc);
|
||||
|
||||
if (start) {
|
||||
gint event_number;
|
||||
gint event_volume;
|
||||
if (!correct_order)
|
||||
goto failure;
|
||||
|
||||
if (start) {
|
||||
if (!gst_structure_get_int (event_structure, "number", &event_number) ||
|
||||
!gst_structure_get_int (event_structure, "volume", &event_volume))
|
||||
goto failure;
|
||||
|
@ -1048,6 +1058,7 @@ gst_rtp_dtmf_src_change_state (GstElement * element, GstStateChange transition)
|
|||
gst_dtmf_src_post_message (dtmfsrc, "dtmf-event-dropped", event);
|
||||
gst_rtp_dtmf_src_event_free (event);
|
||||
}
|
||||
dtmfsrc->last_event_was_start = FALSE;
|
||||
|
||||
no_preroll = TRUE;
|
||||
break;
|
||||
|
@ -1071,6 +1082,7 @@ gst_rtp_dtmf_src_change_state (GstElement * element, GstStateChange transition)
|
|||
gst_dtmf_src_post_message (dtmfsrc, "dtmf-event-dropped", event);
|
||||
gst_rtp_dtmf_src_event_free (event);
|
||||
}
|
||||
dtmfsrc->last_event_was_start = FALSE;
|
||||
|
||||
/* Indicate that we don't do PRE_ROLL */
|
||||
break;
|
||||
|
|
|
@ -93,6 +93,7 @@ struct _GstRTPDTMFSrc
|
|||
guint16 ptime;
|
||||
guint16 packet_redundancy;
|
||||
guint32 clock_rate;
|
||||
gboolean last_event_was_start;
|
||||
|
||||
GstClockTime last_stop;
|
||||
|
||||
|
|
Loading…
Reference in a new issue