marker: add color meta
authorHenry Wilkes <hwilkes@igalia.com>
Wed, 16 Oct 2019 18:26:55 +0000 (19:26 +0100)
committerThibault Saunier <tsaunier@gnome.org>
Thu, 24 Oct 2019 09:45:19 +0000 (09:45 +0000)
Support optionally coloring markers by reserving GES_META_MARKER_COLOR
for an ARGB guint.

ges/ges-marker-list.c
ges/ges-meta-container.h
tests/check/ges/markerlist.c

index 296f1e048ebbf51a2f579d4d12bb331767130c59..89f9cbd5e098894800fa9a3e1df06208f4fe17c2 100644 (file)
@@ -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
index 99063b8cf37e7bdafca34adbe5e79411c34b2ce3..b7963a91de5127703af6662ba0cdcc238904b2b1 100644 (file)
@@ -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;
 
index b41b00f71c1dbec046f32583f25bb2945ffb6d58..d3e74004d1f022d5b7ee1a017d98fd6ff81d1a28 100644 (file)
@@ -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;
 }