From: Andy Wingo Date: Mon, 21 Nov 2005 11:06:42 +0000 (+0000) Subject: gst/gstevent.h (GstEventTypeFlags): New data type, the flags of the event type (upstr... X-Git-Tag: RELEASE-0_9_6~64 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=33d5749b88c59ec9ca38919009640c01644c5743;p=platform%2Fupstream%2Fgstreamer.git gst/gstevent.h (GstEventTypeFlags): New data type, the flags of the event type (upstream, downstream, serialized). Re... Original commit message from CVS: 2005-11-21 Andy Wingo * gst/gstevent.h (GstEventTypeFlags): New data type, the flags of the event type (upstream, downstream, serialized). Renamed GST_EVDIR_* and GST_EVSER to GST_EVENT_TYPE_*. (GstEventType): Use GstEventTypeFlags. Rename CUSTOM_UP to CUSTOM_UPSTREAM, CUSTOM_DS to CUSTOM_DOWNSTREAM, etc. * gst/gstevent.c: Update for new CUSTOM event names. * check/gst/gstevent.c: Update check for new CUSTOM event names. * gst/gstevent.h: * gst/gstevent.c (gst_event_type_get_flags): New function. Fixes bug #319392. --- diff --git a/ChangeLog b/ChangeLog index bbc1af8..428b1dd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,19 @@ +2005-11-21 Andy Wingo + + * gst/gstevent.h (GstEventTypeFlags): New data type, the flags of + the event type (upstream, downstream, serialized). Renamed + GST_EVDIR_* and GST_EVSER to GST_EVENT_TYPE_*. + (GstEventType): Use GstEventTypeFlags. Rename CUSTOM_UP to + CUSTOM_UPSTREAM, CUSTOM_DS to CUSTOM_DOWNSTREAM, etc. + + * gst/gstevent.c: Update for new CUSTOM event names. + + * check/gst/gstevent.c: Update check for new CUSTOM event names. + + * gst/gstevent.h: + * gst/gstevent.c (gst_event_type_get_flags): New function. Fixes + bug #319392. + 2005-11-21 Tim-Philipp Müller * docs/gst/gstreamer-sections.txt: diff --git a/check/gst/gstevent.c b/check/gst/gstevent.c index 17e6afd..018faab 100644 --- a/check/gst/gstevent.c +++ b/check/gst/gstevent.c @@ -155,9 +155,9 @@ GST_START_TEST (create_custom_events) { structure = gst_structure_empty_new ("application/x-custom"); fail_if (structure == NULL); - event = gst_event_new_custom (GST_EVENT_CUSTOM_UP, structure); + event = gst_event_new_custom (GST_EVENT_CUSTOM_UPSTREAM, structure); fail_if (event == NULL); - fail_unless (GST_EVENT_TYPE (event) == GST_EVENT_CUSTOM_UP); + fail_unless (GST_EVENT_TYPE (event) == GST_EVENT_CUSTOM_UPSTREAM); fail_unless (GST_EVENT_IS_UPSTREAM (event)); fail_if (GST_EVENT_IS_DOWNSTREAM (event)); fail_if (GST_EVENT_IS_SERIALIZED (event)); @@ -203,7 +203,7 @@ event_probe (GstPad * pad, GstMiniObject ** data, gpointer user_data) if (before_q) { switch (GST_EVENT_TYPE (GST_EVENT (data))) { - case GST_EVENT_CUSTOM_UP: + case GST_EVENT_CUSTOM_UPSTREAM: case GST_EVENT_CUSTOM_BOTH: case GST_EVENT_CUSTOM_BOTH_OOB: if (got_event_before_q != NULL) @@ -217,8 +217,8 @@ event_probe (GstPad * pad, GstMiniObject ** data, gpointer user_data) } } else { switch (GST_EVENT_TYPE (GST_EVENT (data))) { - case GST_EVENT_CUSTOM_DS: - case GST_EVENT_CUSTOM_DS_OOB: + case GST_EVENT_CUSTOM_DOWNSTREAM: + case GST_EVENT_CUSTOM_DOWNSTREAM_OOB: case GST_EVENT_CUSTOM_BOTH: case GST_EVENT_CUSTOM_BOTH_OOB: if (got_event_after_q != NULL) @@ -328,7 +328,7 @@ GST_START_TEST (send_custom_events) GINT_TO_POINTER (FALSE)); /* Upstream events */ - test_event (pipeline, GST_EVENT_CUSTOM_UP, sinkpad, TRUE); + test_event (pipeline, GST_EVENT_CUSTOM_UPSTREAM, sinkpad, TRUE); fail_unless (timediff (&got_event_time, &sent_event_time) < G_USEC_PER_SEC / 2, "GST_EVENT_CUSTOM_UP took to long to reach source: %" @@ -347,7 +347,7 @@ GST_START_TEST (send_custom_events) G_GINT64_FORMAT " us", timediff (&got_event_time, &sent_event_time)); /* Out of band downstream events */ - test_event (pipeline, GST_EVENT_CUSTOM_DS_OOB, srcpad, FALSE); + test_event (pipeline, GST_EVENT_CUSTOM_DOWNSTREAM_OOB, srcpad, FALSE); fail_unless (timediff (&got_event_time, &sent_event_time) < G_USEC_PER_SEC / 2, "GST_EVENT_CUSTOM_DS_OOB took to long to reach source: %" @@ -361,7 +361,7 @@ GST_START_TEST (send_custom_events) /* In-band downstream events are expected to take at least 1 second * to traverse the the queue */ - test_event (pipeline, GST_EVENT_CUSTOM_DS, srcpad, FALSE); + test_event (pipeline, GST_EVENT_CUSTOM_DOWNSTREAM, srcpad, FALSE); fail_unless (timediff (&got_event_time, &sent_event_time) >= G_USEC_PER_SEC / 2, "GST_EVENT_CUSTOM_DS arrived too quickly for an in-band event: %" diff --git a/gst/gstevent.c b/gst/gstevent.c index 2088ca5..17f9a91 100644 --- a/gst/gstevent.c +++ b/gst/gstevent.c @@ -107,9 +107,9 @@ static GstEventQuarks event_quarks[] = { {GST_EVENT_QOS, "qos", 0}, {GST_EVENT_SEEK, "seek", 0}, {GST_EVENT_NAVIGATION, "navigation", 0}, - {GST_EVENT_CUSTOM_UP, "custom-up", 0}, - {GST_EVENT_CUSTOM_DS, "custom-ds", 0}, - {GST_EVENT_CUSTOM_DS_OOB, "custom-ds-oob", 0}, + {GST_EVENT_CUSTOM_UPSTREAM, "custom-upstream", 0}, + {GST_EVENT_CUSTOM_DOWNSTREAM, "custom-downstream", 0}, + {GST_EVENT_CUSTOM_DOWNSTREAM_OOB, "custom-downstream-oob", 0}, {GST_EVENT_CUSTOM_BOTH, "custom-both", 0}, {GST_EVENT_CUSTOM_BOTH_OOB, "custom-both-oob", 0}, @@ -156,6 +156,24 @@ gst_event_type_to_quark (GstEventType type) return 0; } +/** + * gst_event_type_get_flags: + * @type: a #GstEventType + * + * Gets the #GstEventTypeFlags associated with @type. + * + * Returns: a #GstEventTypeFlags. + */ +GstEventTypeFlags +gst_event_type_get_flags (GstEventType type) +{ + GstEventTypeFlags ret; + + ret = type & ((1 << GST_EVENT_TYPE_SHIFT) - 1); + + return ret; +} + GType gst_event_get_type (void) { diff --git a/gst/gstevent.h b/gst/gstevent.h index 6b9a68d..368e273 100644 --- a/gst/gstevent.h +++ b/gst/gstevent.h @@ -35,35 +35,31 @@ G_BEGIN_DECLS /** - * GST_EVDIR_US: + * GstEventTypeFlags: + * @GST_EVENT_TYPE_UPSTREAM: Set if the event can travel upstream. + * @GST_EVENT_TYPE_DOWNSTREAM: Set if the event can travel downstream. + * @GST_EVENT_TYPE_SERIALIZED: Set if the event should be serialized with data + * flow. * - * bitmask defining the event can travel upstream + * #GstEventTypeFlags indicate the aspects of the different #GstEventType + * values. You can get the type flags of a #GstEventType with the + * gst_event_type_get_flags() function. */ -#define GST_EVDIR_US (1 << 0) -/** - * GST_EVDIR_DS: - * - * bitmask defining the event can travel downstream - */ -#define GST_EVDIR_DS (1 << 1) -/** - * GST_EVDIR_BOTH: - * - * bitmask defining the event can travel both up and downstream - */ -#define GST_EVDIR_BOTH GST_EVDIR_US | GST_EVDIR_DS -/** - * GST_EVSER: - * - * mask defining if the event is serialized with the data stream - */ -#define GST_EVSER (1 << 2) +typedef enum { + GST_EVENT_TYPE_UPSTREAM = 1 << 0, + GST_EVENT_TYPE_DOWNSTREAM = 1 << 1, + GST_EVENT_TYPE_SERIALIZED = 1 << 2, +} GstEventTypeFlags; + /** - * GST_EVSHIFT: + * GST_EVENT_TYPE_BOTH: * - * shift for the bits in the serialize mask. + * The same thing as #GST_EVENT_TYPE_UPSTREAM | #GST_EVENT_TYPE_DOWNSTREAM. */ -#define GST_EVSHIFT 4 +#define GST_EVENT_TYPE_BOTH \ + (GST_EVENT_TYPE_UPSTREAM | GST_EVENT_TYPE_DOWNSTREAM) + +#define GST_EVENT_TYPE_SHIFT 4 /** * GST_EVENT_MAKE_TYPE: @@ -73,7 +69,10 @@ G_BEGIN_DECLS * when making custom event types, use this macro with the num and * the given flags */ -#define GST_EVENT_MAKE_TYPE(num,flags) (((num) << GST_EVSHIFT) | (flags)) +#define GST_EVENT_MAKE_TYPE(num,flags) \ + (((num) << GST_EVENT_TYPE_SHIFT) | (flags)) + +#define FLAG(name) GST_EVENT_TYPE_##name /** * GstEventType: @@ -93,9 +92,10 @@ G_BEGIN_DECLS * @GST_EVENT_NAVIGATION: Navigation events are usually used for communicating user requests, such as mouse or keyboard movements, * to upstream elements. - * @GST_EVENT_CUSTOM_UP: Upstream custom event - * @GST_EVENT_CUSTOM_DS: Downstream custom event that travels in the data flow. - * @GST_EVENT_CUSTOM_DS_OOB: Custom out-of-band downstream event. + * @GST_EVENT_CUSTOM_UPSTREAM: Upstream custom event + * @GST_EVENT_CUSTOM_DOWNSTREAM: Downstream custom event that travels in the + * data flow. + * @GST_EVENT_CUSTOM_DOWNSTREAM_OOB: Custom out-of-band downstream event. * @GST_EVENT_CUSTOM_BOTH: Custom upstream or downstream event. * In-band when travelling downstream. * @GST_EVENT_CUSTOM_BOTH_OOB: Custom upstream or downstream out-of-band event. @@ -112,26 +112,27 @@ G_BEGIN_DECLS typedef enum { GST_EVENT_UNKNOWN = GST_EVENT_MAKE_TYPE (0, 0), /* bidirectional events */ - GST_EVENT_FLUSH_START = GST_EVENT_MAKE_TYPE (1, GST_EVDIR_BOTH), - GST_EVENT_FLUSH_STOP = GST_EVENT_MAKE_TYPE (2, GST_EVDIR_BOTH), + GST_EVENT_FLUSH_START = GST_EVENT_MAKE_TYPE (1, FLAG(BOTH)), + GST_EVENT_FLUSH_STOP = GST_EVENT_MAKE_TYPE (2, FLAG(BOTH)), /* downstream serialized events */ - GST_EVENT_EOS = GST_EVENT_MAKE_TYPE (5, GST_EVDIR_DS | GST_EVSER), - GST_EVENT_NEWSEGMENT = GST_EVENT_MAKE_TYPE (6, GST_EVDIR_DS | GST_EVSER), - GST_EVENT_TAG = GST_EVENT_MAKE_TYPE (7, GST_EVDIR_DS | GST_EVSER), - GST_EVENT_FILLER = GST_EVENT_MAKE_TYPE (8, GST_EVDIR_DS | GST_EVSER), - GST_EVENT_BUFFERSIZE = GST_EVENT_MAKE_TYPE (9, GST_EVDIR_DS | GST_EVSER), + GST_EVENT_EOS = GST_EVENT_MAKE_TYPE (5, FLAG(DOWNSTREAM) | FLAG(SERIALIZED)), + GST_EVENT_NEWSEGMENT = GST_EVENT_MAKE_TYPE (6, FLAG(DOWNSTREAM) | FLAG(SERIALIZED)), + GST_EVENT_TAG = GST_EVENT_MAKE_TYPE (7, FLAG(DOWNSTREAM) | FLAG(SERIALIZED)), + GST_EVENT_FILLER = GST_EVENT_MAKE_TYPE (8, FLAG(DOWNSTREAM) | FLAG(SERIALIZED)), + GST_EVENT_BUFFERSIZE = GST_EVENT_MAKE_TYPE (9, FLAG(DOWNSTREAM) | FLAG(SERIALIZED)), /* upstream events */ - GST_EVENT_QOS = GST_EVENT_MAKE_TYPE (15, GST_EVDIR_US), - GST_EVENT_SEEK = GST_EVENT_MAKE_TYPE (16, GST_EVDIR_US), - GST_EVENT_NAVIGATION = GST_EVENT_MAKE_TYPE (17, GST_EVDIR_US), + GST_EVENT_QOS = GST_EVENT_MAKE_TYPE (15, FLAG(UPSTREAM)), + GST_EVENT_SEEK = GST_EVENT_MAKE_TYPE (16, FLAG(UPSTREAM)), + GST_EVENT_NAVIGATION = GST_EVENT_MAKE_TYPE (17, FLAG(UPSTREAM)), /* custom events start here */ - GST_EVENT_CUSTOM_UP = GST_EVENT_MAKE_TYPE (32, GST_EVDIR_US), - GST_EVENT_CUSTOM_DS = GST_EVENT_MAKE_TYPE (32, GST_EVDIR_DS | GST_EVSER), - GST_EVENT_CUSTOM_DS_OOB = GST_EVENT_MAKE_TYPE (32, GST_EVDIR_DS), - GST_EVENT_CUSTOM_BOTH = GST_EVENT_MAKE_TYPE (32, GST_EVDIR_BOTH | GST_EVSER), - GST_EVENT_CUSTOM_BOTH_OOB = GST_EVENT_MAKE_TYPE (32, GST_EVDIR_BOTH) + GST_EVENT_CUSTOM_UPSTREAM = GST_EVENT_MAKE_TYPE (32, FLAG(UPSTREAM)), + GST_EVENT_CUSTOM_DOWNSTREAM = GST_EVENT_MAKE_TYPE (32, FLAG(DOWNSTREAM) | FLAG(SERIALIZED)), + GST_EVENT_CUSTOM_DOWNSTREAM_OOB = GST_EVENT_MAKE_TYPE (32, FLAG(DOWNSTREAM)), + GST_EVENT_CUSTOM_BOTH = GST_EVENT_MAKE_TYPE (32, FLAG(BOTH) | FLAG(SERIALIZED)), + GST_EVENT_CUSTOM_BOTH_OOB = GST_EVENT_MAKE_TYPE (32, FLAG(BOTH)) } GstEventType; +#undef FLAG /** * GST_EVENT_TRACE_NAME: @@ -190,21 +191,21 @@ typedef struct _GstEventClass GstEventClass; * * Check if an event can travel upstream. */ -#define GST_EVENT_IS_UPSTREAM(ev) !!(GST_EVENT_TYPE (ev) & GST_EVDIR_US) +#define GST_EVENT_IS_UPSTREAM(ev) !!(GST_EVENT_TYPE (ev) & GST_EVENT_TYPE_UPSTREAM) /** * GST_EVENT_IS_DOWNSTREAM: * @ev: the event to query * * Check if an event can travel downstream. */ -#define GST_EVENT_IS_DOWNSTREAM(ev) !!(GST_EVENT_TYPE (ev) & GST_EVDIR_DS) +#define GST_EVENT_IS_DOWNSTREAM(ev) !!(GST_EVENT_TYPE (ev) & GST_EVENT_TYPE_DOWNSTREAM) /** * GST_EVENT_IS_SERIALIZED: * @ev: the event to query * * Check if an event is serialized with the data stream. */ -#define GST_EVENT_IS_SERIALIZED(ev) !!(GST_EVENT_TYPE (ev) & GST_EVSER) +#define GST_EVENT_IS_SERIALIZED(ev) !!(GST_EVENT_TYPE (ev) & GST_EVENT_TYPE_SERIALIZED) /** * GstSeekType: @@ -295,6 +296,8 @@ void _gst_event_initialize (void); const gchar* gst_event_type_get_name (GstEventType type); GQuark gst_event_type_to_quark (GstEventType type); +GstEventTypeFlags + gst_event_type_get_flags (GstEventType type); GType gst_event_get_type (void); diff --git a/tests/check/gst/gstevent.c b/tests/check/gst/gstevent.c index 17e6afd..018faab 100644 --- a/tests/check/gst/gstevent.c +++ b/tests/check/gst/gstevent.c @@ -155,9 +155,9 @@ GST_START_TEST (create_custom_events) { structure = gst_structure_empty_new ("application/x-custom"); fail_if (structure == NULL); - event = gst_event_new_custom (GST_EVENT_CUSTOM_UP, structure); + event = gst_event_new_custom (GST_EVENT_CUSTOM_UPSTREAM, structure); fail_if (event == NULL); - fail_unless (GST_EVENT_TYPE (event) == GST_EVENT_CUSTOM_UP); + fail_unless (GST_EVENT_TYPE (event) == GST_EVENT_CUSTOM_UPSTREAM); fail_unless (GST_EVENT_IS_UPSTREAM (event)); fail_if (GST_EVENT_IS_DOWNSTREAM (event)); fail_if (GST_EVENT_IS_SERIALIZED (event)); @@ -203,7 +203,7 @@ event_probe (GstPad * pad, GstMiniObject ** data, gpointer user_data) if (before_q) { switch (GST_EVENT_TYPE (GST_EVENT (data))) { - case GST_EVENT_CUSTOM_UP: + case GST_EVENT_CUSTOM_UPSTREAM: case GST_EVENT_CUSTOM_BOTH: case GST_EVENT_CUSTOM_BOTH_OOB: if (got_event_before_q != NULL) @@ -217,8 +217,8 @@ event_probe (GstPad * pad, GstMiniObject ** data, gpointer user_data) } } else { switch (GST_EVENT_TYPE (GST_EVENT (data))) { - case GST_EVENT_CUSTOM_DS: - case GST_EVENT_CUSTOM_DS_OOB: + case GST_EVENT_CUSTOM_DOWNSTREAM: + case GST_EVENT_CUSTOM_DOWNSTREAM_OOB: case GST_EVENT_CUSTOM_BOTH: case GST_EVENT_CUSTOM_BOTH_OOB: if (got_event_after_q != NULL) @@ -328,7 +328,7 @@ GST_START_TEST (send_custom_events) GINT_TO_POINTER (FALSE)); /* Upstream events */ - test_event (pipeline, GST_EVENT_CUSTOM_UP, sinkpad, TRUE); + test_event (pipeline, GST_EVENT_CUSTOM_UPSTREAM, sinkpad, TRUE); fail_unless (timediff (&got_event_time, &sent_event_time) < G_USEC_PER_SEC / 2, "GST_EVENT_CUSTOM_UP took to long to reach source: %" @@ -347,7 +347,7 @@ GST_START_TEST (send_custom_events) G_GINT64_FORMAT " us", timediff (&got_event_time, &sent_event_time)); /* Out of band downstream events */ - test_event (pipeline, GST_EVENT_CUSTOM_DS_OOB, srcpad, FALSE); + test_event (pipeline, GST_EVENT_CUSTOM_DOWNSTREAM_OOB, srcpad, FALSE); fail_unless (timediff (&got_event_time, &sent_event_time) < G_USEC_PER_SEC / 2, "GST_EVENT_CUSTOM_DS_OOB took to long to reach source: %" @@ -361,7 +361,7 @@ GST_START_TEST (send_custom_events) /* In-band downstream events are expected to take at least 1 second * to traverse the the queue */ - test_event (pipeline, GST_EVENT_CUSTOM_DS, srcpad, FALSE); + test_event (pipeline, GST_EVENT_CUSTOM_DOWNSTREAM, srcpad, FALSE); fail_unless (timediff (&got_event_time, &sent_event_time) >= G_USEC_PER_SEC / 2, "GST_EVENT_CUSTOM_DS arrived too quickly for an in-band event: %"