From 44420b2e567d81d529fa9a01b8646817bf927a89 Mon Sep 17 00:00:00 2001 From: Henry Wilkes Date: Wed, 16 Oct 2019 19:26:55 +0100 Subject: [PATCH] marker: add color meta Support optionally coloring markers by reserving GES_META_MARKER_COLOR for an ARGB guint. --- ges/ges-marker-list.c | 4 ++++ ges/ges-meta-container.h | 7 +++++++ tests/check/ges/markerlist.c | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 45 insertions(+) diff --git a/ges/ges-marker-list.c b/ges/ges-marker-list.c index 296f1e048e..89f9cbd5e0 100644 --- a/ges/ges-marker-list.c +++ b/ges/ges-marker-list.c @@ -24,6 +24,8 @@ * @short_description: implements a list of markers with metadata asociated to time positions * @see_also: #GESMarker * + * A #GESMarker can be colored by setting the #GES_META_MARKER_COLOR meta. + * * Since: 1.18 */ @@ -80,6 +82,8 @@ ges_marker_get_property (GObject * object, guint property_id, static void ges_marker_init (GESMarker * self) { + ges_meta_container_register_static_meta (GES_META_CONTAINER (self), + GES_META_READ_WRITE, GES_META_MARKER_COLOR, G_TYPE_UINT); } static void diff --git a/ges/ges-meta-container.h b/ges/ges-meta-container.h index 99063b8cf3..b7963a91de 100644 --- a/ges/ges-meta-container.h +++ b/ges/ges-meta-container.h @@ -109,6 +109,13 @@ G_BEGIN_DECLS */ #define GES_META_FORMAT_VERSION "format-version" +/** + * GES_META_MARKER_COLOR: + * + * The ARGB color of a #GESMarker (an AARRGGBB hex as a guint) + */ +#define GES_META_MARKER_COLOR "marker-color" + typedef struct _GESMetaContainer GESMetaContainer; typedef struct _GESMetaContainerInterface GESMetaContainerInterface; diff --git a/tests/check/ges/markerlist.c b/tests/check/ges/markerlist.c index b41b00f71c..d3e74004d1 100644 --- a/tests/check/ges/markerlist.c +++ b/tests/check/ges/markerlist.c @@ -343,6 +343,39 @@ GST_START_TEST (test_serialize_deserialize) GST_END_TEST; + +GST_START_TEST (test_marker_color) +{ + GESMarkerList *mlist; + GESMarker *marker; + const guint yellow_rgb = 16776960; + guint color; + + ges_init (); + + mlist = ges_marker_list_new (); + marker = ges_marker_list_add (mlist, 0); + /* getting the color should fail since no value should be set yet */ + fail_unless (ges_meta_container_get_meta (GES_META_CONTAINER (marker), + GES_META_MARKER_COLOR) == NULL); + /* trying to set the color field to something other than a uint should + * fail */ + fail_unless (ges_meta_container_set_float (GES_META_CONTAINER (marker), + GES_META_MARKER_COLOR, 0.0) == FALSE); + fail_unless (ges_meta_container_set_uint (GES_META_CONTAINER (marker), + GES_META_MARKER_COLOR, yellow_rgb)); + fail_unless (ges_meta_container_get_uint (GES_META_CONTAINER (marker), + GES_META_MARKER_COLOR, &color)); + fail_unless_equals_int (color, yellow_rgb); + + g_object_unref (mlist); + + ges_deinit (); +} + +GST_END_TEST; + + static Suite * ges_suite (void) { @@ -359,6 +392,7 @@ ges_suite (void) tcase_add_test (tc_chain, test_get_markers); tcase_add_test (tc_chain, test_move_marker); tcase_add_test (tc_chain, test_serialize_deserialize); + tcase_add_test (tc_chain, test_marker_color); return s; }