From cf45b883495b4e1953af276c53b457483ecd9982 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Tue, 29 Apr 2008 11:23:51 +0000 Subject: [PATCH] Add method to conveniently check the name of a custom event with gst_event_has_name(). Original commit message from CVS: * docs/gst/gstreamer-sections.txt: * gst/gstevent.c: (gst_event_has_name): * gst/gstevent.h: * tests/check/gst/gstevent.c: (GST_START_TEST): Add method to conveniently check the name of a custom event with gst_event_has_name(). Reformat the event docs so that related methods are put together instead of the default alphabetical sort. Update unit test with new method. API: GstEvent::gst_event_has_name() --- ChangeLog | 13 +++++++++ docs/gst/gstreamer-sections.txt | 62 ++++++++++++++++++++++++++--------------- gst/gstevent.c | 23 +++++++++++++++ gst/gstevent.h | 2 ++ tests/check/gst/gstevent.c | 4 +++ 5 files changed, 81 insertions(+), 23 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0aa1c82..8e79bdd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2008-04-29 Wim Taymans + + * docs/gst/gstreamer-sections.txt: + * gst/gstevent.c: (gst_event_has_name): + * gst/gstevent.h: + * tests/check/gst/gstevent.c: (GST_START_TEST): + Add method to conveniently check the name of a custom event with + gst_event_has_name(). + Reformat the event docs so that related methods are put together instead + of the default alphabetical sort. + Update unit test with new method. + API: GstEvent::gst_event_has_name() + 2008-04-28 Michael Smith * libs/gst/check/Makefile.am: diff --git a/docs/gst/gstreamer-sections.txt b/docs/gst/gstreamer-sections.txt index 8d21b30..21296c5 100644 --- a/docs/gst/gstreamer-sections.txt +++ b/docs/gst/gstreamer-sections.txt @@ -636,49 +636,65 @@ gst_stream_error_quark gstevent GstEvent GstEvent + +GstEventTypeFlags +GST_EVENT_TYPE_BOTH +GST_EVENT_MAKE_TYPE + GstEventType + GST_EVENT_TRACE_NAME + GST_EVENT_TYPE GST_EVENT_TYPE_NAME -GST_EVENT_TYPE_BOTH GST_EVENT_TIMESTAMP GST_EVENT_SRC +GST_EVENT_IS_UPSTREAM GST_EVENT_IS_DOWNSTREAM GST_EVENT_IS_SERIALIZED -GST_EVENT_IS_UPSTREAM -GstSeekType -GstSeekFlags -GstEventTypeFlags -GST_EVENT_MAKE_TYPE +gst_event_type_get_flags +gst_event_type_get_name +gst_event_type_to_quark +gst_event_ref +gst_event_unref +gst_event_replace gst_event_copy -gst_event_get_structure -gst_event_new_buffer_size + + gst_event_new_custom -gst_event_new_eos +gst_event_get_structure +gst_event_has_name + gst_event_new_flush_start gst_event_new_flush_stop -gst_event_new_latency -gst_event_new_navigation + +gst_event_new_eos + gst_event_new_new_segment gst_event_new_new_segment_full -gst_event_new_qos -gst_event_new_seek -gst_event_new_tag -gst_event_parse_buffer_size -gst_event_parse_latency gst_event_parse_new_segment gst_event_parse_new_segment_full + +gst_event_new_tag +gst_event_parse_tag + +gst_event_new_buffer_size +gst_event_parse_buffer_size + +gst_event_new_qos gst_event_parse_qos + +GstSeekType +GstSeekFlags +gst_event_new_seek gst_event_parse_seek -gst_event_parse_tag -gst_event_ref -gst_event_unref -gst_event_replace -gst_event_type_get_flags -gst_event_type_get_name -gst_event_type_to_quark + +gst_event_new_navigation + +gst_event_new_latency +gst_event_parse_latency GstEventClass GST_EVENT diff --git a/gst/gstevent.c b/gst/gstevent.c index 8ba71b0..adf8835 100644 --- a/gst/gstevent.c +++ b/gst/gstevent.c @@ -355,6 +355,29 @@ gst_event_get_structure (GstEvent * event) } /** + * gst_event_has_name: + * @event: The #GstEvent. + * @name: name to check + * + * Checks if @event has the given @name. This function is usually used to + * check the name of a custom event. + * + * Returns: %TRUE if @name matches the name of the event structure. + * + * Since: 0.10.20 + */ +gboolean +gst_event_has_name (GstEvent * event, const gchar * name) +{ + g_return_val_if_fail (GST_IS_EVENT (event), FALSE); + + if (event->structure == NULL) + return FALSE; + + return gst_structure_has_name (event->structure, name); +} + +/** * gst_event_new_flush_start: * * Allocate a new flush start event. The flush start event can be sent diff --git a/gst/gstevent.h b/gst/gstevent.h index acbabac..00b711a 100644 --- a/gst/gstevent.h +++ b/gst/gstevent.h @@ -364,6 +364,8 @@ GstEvent* gst_event_new_custom (GstEventType type, GstStructure *structure); const GstStructure * gst_event_get_structure (GstEvent *event); +gboolean gst_event_has_name (GstEvent *event, const gchar *name); + /* flush events */ GstEvent * gst_event_new_flush_start (void); GstEvent * gst_event_new_flush_stop (void); diff --git a/tests/check/gst/gstevent.c b/tests/check/gst/gstevent.c index 82ed837..cc875a5 100644 --- a/tests/check/gst/gstevent.c +++ b/tests/check/gst/gstevent.c @@ -214,6 +214,7 @@ GST_START_TEST (create_events) fail_if (GST_EVENT_IS_DOWNSTREAM (event)); fail_if (GST_EVENT_IS_SERIALIZED (event)); fail_unless (gst_event_get_structure (event) == structure); + fail_unless (gst_event_has_name (event, "application/x-custom")); gst_event_unref (event); /* Decided not to test the other custom enum types, as they @@ -231,6 +232,7 @@ GST_START_TEST (create_events) event2 = gst_event_copy (event); fail_if (event2 == NULL); fail_unless (GST_EVENT_TYPE (event) == GST_EVENT_TYPE (event2)); + fail_unless (gst_event_has_name (event, "application/x-custom")); /* The structure should have been duplicated */ fail_if (gst_event_get_structure (event) == @@ -251,6 +253,7 @@ GST_START_TEST (create_events) /* this should fail if the structure isn't writable */ ASSERT_CRITICAL (gst_structure_remove_all_fields ((GstStructure *) gst_event_get_structure (event))); + fail_unless (gst_event_has_name (event, "application/x-custom")); /* now make writable */ event2 = @@ -259,6 +262,7 @@ GST_START_TEST (create_events) /* this fail if the structure isn't writable */ gst_structure_remove_all_fields ((GstStructure *) gst_event_get_structure (event2)); + fail_unless (gst_event_has_name (event2, "application/x-custom")); gst_event_unref (event); gst_event_unref (event); -- 2.7.4