summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlivier CrĂȘte <olivier.crete@collabora.com>2011-11-04 17:54:04 -0400
committerOlivier CrĂȘte <olivier.crete@collabora.com>2011-11-08 17:45:48 -0500
commitd937da4c0c5b0e0e12baa8fc2d60b54970bf1ff2 (patch)
treeaf5d6917c486811c2f5ce2a908586af619f9e6c7
parentd15d524fec908695765ad944a46d56679a438220 (diff)
dtmfsrc: Reject start/stop requests that come out of order
-rw-r--r--gst/dtmf/gstdtmfsrc.c22
-rw-r--r--gst/dtmf/gstdtmfsrc.h1
-rw-r--r--gst/dtmf/gstrtpdtmfsrc.c18
-rw-r--r--gst/dtmf/gstrtpdtmfsrc.h1
4 files changed, 32 insertions, 10 deletions
diff --git a/gst/dtmf/gstdtmfsrc.c b/gst/dtmf/gstdtmfsrc.c
index 1e76b4bab..6bc46429d 100644
--- a/gst/dtmf/gstdtmfsrc.c
+++ b/gst/dtmf/gstdtmfsrc.c
@@ -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 (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;
+ if (!correct_order)
+ goto failure;
+ if (start) {
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:
diff --git a/gst/dtmf/gstdtmfsrc.h b/gst/dtmf/gstdtmfsrc.h
index cda5840a5..ce69bf411 100644
--- a/gst/dtmf/gstdtmfsrc.h
+++ b/gst/dtmf/gstdtmfsrc.h
@@ -74,6 +74,7 @@ struct _GstDTMFSrc
GstBaseSrc parent;
GAsyncQueue *event_queue;
GstDTMFSrcEvent *last_event;
+ gboolean last_event_was_start;
guint16 interval;
GstClockTime timestamp;
diff --git a/gst/dtmf/gstrtpdtmfsrc.c b/gst/dtmf/gstrtpdtmfsrc.c
index cd6e12c9a..1689dc46a 100644
--- a/gst/dtmf/gstrtpdtmfsrc.c
+++ b/gst/dtmf/gstrtpdtmfsrc.c
@@ -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;
diff --git a/gst/dtmf/gstrtpdtmfsrc.h b/gst/dtmf/gstrtpdtmfsrc.h
index 9be9df69c..5bc0e3ea6 100644
--- a/gst/dtmf/gstrtpdtmfsrc.h
+++ b/gst/dtmf/gstrtpdtmfsrc.h
@@ -93,6 +93,7 @@ struct _GstRTPDTMFSrc
guint16 ptime;
guint16 packet_redundancy;
guint32 clock_rate;
+ gboolean last_event_was_start;
GstClockTime last_stop;