navigation: Improve interface to avoid exposing implementation details
authorVivienne Watermeier <vwatermeier@igalia.com>
Mon, 14 Feb 2022 13:06:12 +0000 (14:06 +0100)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Wed, 23 Mar 2022 13:14:51 +0000 (13:14 +0000)
This deprecates the current send_event interface, and the wrapper
functions based on it, replacing it with a send_event_simple interface and
wrapper function. Together with the new event constructors, this avoids
implementations having to directly access the underlying structure.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1633>

subprojects/gst-docs/symbols/symbol_index.json
subprojects/gst-plugins-base/gst-libs/gst/video/navigation.c
subprojects/gst-plugins-base/gst-libs/gst/video/navigation.h
subprojects/gst-plugins-base/tests/check/libs/struct_aarch64.h
subprojects/gst-plugins-base/tests/check/libs/struct_arm.h
subprojects/gst-plugins-base/tests/check/libs/struct_i386.h
subprojects/gst-plugins-base/tests/check/libs/struct_i386_osx.h
subprojects/gst-plugins-base/tests/check/libs/struct_ppc32.h
subprojects/gst-plugins-base/tests/check/libs/struct_ppc64.h
subprojects/gst-plugins-base/tests/check/libs/struct_x86_64.h

index 7741aaec807855a8388e925c6d63dbdded07dd05..9230d00de22691124266342ef92a74a3b9242dfa 100644 (file)
   "GstNavigationInterface.iface",
   "GstNavigationInterface.send_event",
   "GstNavigationInterface::send_event",
+  "GstNavigationInterface.send_event_simple",
+  "GstNavigationInterface::send_event_simple",
   "GstNavigationMessageType",
   "GstNavigationQueryType",
   "GstNavigationtest",
index c2300a4ba968bde10841d907eacd60d5ba979d73..4cad1de393d4b25bb9ad819aa28d3cc94b382395 100644 (file)
 
 G_DEFINE_INTERFACE (GstNavigation, gst_navigation, 0);
 
+static void
+gst_navigation_default_send_event_simple (GstNavigation * navigation,
+    GstEvent * event)
+{
+  GstNavigationInterface *iface = GST_NAVIGATION_GET_INTERFACE (navigation);
+
+  if (iface->send_event) {
+    iface->send_event (navigation,
+        gst_structure_copy (gst_event_get_structure (event)));
+  } else {
+    gst_event_unref (event);
+  }
+}
+
 static void
 gst_navigation_default_init (GstNavigationInterface * iface)
 {
   /* default virtual functions */
   iface->send_event = NULL;
+  iface->send_event_simple = gst_navigation_default_send_event_simple;
 }
 
 /* The interface implementer should make sure that the object can handle
@@ -80,6 +95,8 @@ gst_navigation_send_event (GstNavigation * navigation, GstStructure * structure)
 
   if (iface->send_event) {
     iface->send_event (navigation, structure);
+  } else if (iface->send_event_simple) {
+    iface->send_event_simple (navigation, gst_event_new_navigation (structure));
   } else {
     gst_structure_free (structure);
   }
@@ -179,6 +196,32 @@ gst_navigation_send_command (GstNavigation * navigation,
           "command", "command-code", G_TYPE_UINT, (guint) command, NULL));
 }
 
+/**
+ * gst_navigation_send_event_simple:
+ * @navigation: The navigation interface instance
+ * @event: The event to send
+ *
+ * Sends an event to the navigation interface.
+ * Since: 1.22
+ */
+void
+gst_navigation_send_event_simple (GstNavigation * navigation, GstEvent * event)
+{
+  GstNavigationInterface *iface = GST_NAVIGATION_GET_INTERFACE (navigation);
+
+  g_return_if_fail (GST_EVENT_TYPE (event) == GST_EVENT_NAVIGATION);
+
+  if (iface->send_event_simple) {
+    iface->send_event_simple (navigation, event);
+  } else if (iface->send_event) {
+    iface->send_event (navigation,
+        gst_structure_copy (gst_event_get_structure (event)));
+    gst_event_unref (event);
+  } else {
+    gst_event_unref (event);
+  }
+}
+
 /* Navigation Queries */
 
 #define GST_NAVIGATION_QUERY_HAS_TYPE(query,query_type) \
index 79d3ea6e692b9053036698e44b402c9dee8ea8ad..a7dd93ed0b516b377f8a665fa7d493249e213052 100644 (file)
@@ -44,6 +44,7 @@ typedef struct _GstNavigationInterface GstNavigationInterface;
  * GstNavigationInterface:
  * @iface: the parent interface
  * @send_event: sending a navigation event
+ * @send_event_simple: sending a navigation event (Since: 1.22)
  *
  * Navigation interface.
  */
@@ -51,7 +52,24 @@ struct _GstNavigationInterface {
   GTypeInterface iface;
 
   /* virtual functions */
+
+  /**
+   * GstNavigationInterface::send_event:
+   *
+   * sending a navigation event.
+   *
+   * Deprecated: 1.22: Use #GstNavigationInterface.send_event_simple() instead.
+   */
   void (*send_event) (GstNavigation *navigation, GstStructure *structure);
+
+  /**
+   * GstNavigationInterface::send_event_simple:
+   *
+   * sending a navigation event.
+   *
+   * Since: 1.22
+   */
+  void (*send_event_simple) (GstNavigation *navigation, GstEvent *event);
 };
 
 GST_VIDEO_API
@@ -337,25 +355,29 @@ gboolean        gst_navigation_event_parse_command            (GstEvent *event,
 
 /* interface virtual function wrappers */
 
-GST_VIDEO_API
-void    gst_navigation_send_event       (GstNavigation *navigation,
-                                         GstStructure *structure);
+GST_VIDEO_DEPRECATED_FOR(gst_navigation_send_event_simple)
+void    gst_navigation_send_event        (GstNavigation *navigation,
+                                          GstStructure *structure);
 
-GST_VIDEO_API
-void    gst_navigation_send_key_event   (GstNavigation *navigation,
-                                         const char *event, const char *key);
+GST_VIDEO_DEPRECATED_FOR(gst_navigation_send_event_simple)
+void    gst_navigation_send_key_event    (GstNavigation *navigation,
+                                          const char *event, const char *key);
 
-GST_VIDEO_API
-void    gst_navigation_send_mouse_event (GstNavigation *navigation,
-                                         const char *event, int button, double x, double y);
+GST_VIDEO_DEPRECATED_FOR(gst_navigation_send_event_simple)
+void    gst_navigation_send_mouse_event  (GstNavigation *navigation,
+                                          const char *event, int button, double x, double y);
 
-GST_VIDEO_API
+GST_VIDEO_DEPRECATED_FOR(gst_navigation_send_event_simple)
 void    gst_navigation_send_mouse_scroll_event (GstNavigation *navigation,
                                                 double x, double y, double delta_x, double delta_y);
 
+GST_VIDEO_DEPRECATED_FOR(gst_navigation_send_event_simple)
+void    gst_navigation_send_command      (GstNavigation *navigation,
+                                          GstNavigationCommand command);
+
 GST_VIDEO_API
-void    gst_navigation_send_command     (GstNavigation *navigation,
-                                         GstNavigationCommand command);
+void    gst_navigation_send_event_simple (GstNavigation *navigation,
+                                          GstEvent *event);
 
 G_END_DECLS
 
index 81828f6da9200756c20229ba50def2643fa1c3b6..f35e9878c4d57daa28d97458603610e8d53dc1d9 100644 (file)
@@ -36,7 +36,7 @@ GstCheckABIStruct list[] = {
   {"GstFFTF64Complex", sizeof (GstFFTF64Complex), 16},
   {"GstFFTS16Complex", sizeof (GstFFTS16Complex), 4},
   {"GstFFTS32Complex", sizeof (GstFFTS32Complex), 8},
-  {"GstNavigationInterface", sizeof (GstNavigationInterface), 24},
+  {"GstNavigationInterface", sizeof (GstNavigationInterface), 32},
   {"gst_riff_acid", sizeof (gst_riff_acid), 24},
   {"gst_riff_dmlh", sizeof (gst_riff_dmlh), 4},
   {"gst_riff_index_entry", sizeof (gst_riff_index_entry), 16},
index 107137eeecc5ef13bf3d840f28eda60b07ff648d..61b502dd3b0b9bc7a3ba389c702f75b8b3ea7b4e 100644 (file)
@@ -36,7 +36,7 @@ GstCheckABIStruct list[] = {
   {"GstFFTF64Complex", sizeof (GstFFTF64Complex), 16},
   {"GstFFTS16Complex", sizeof (GstFFTS16Complex), 4},
   {"GstFFTS32Complex", sizeof (GstFFTS32Complex), 8},
-  {"GstNavigationInterface", sizeof (GstNavigationInterface), 28},
+  {"GstNavigationInterface", sizeof (GstNavigationInterface), 36},
   {"gst_riff_acid", sizeof (gst_riff_acid), 24},
   {"gst_riff_dmlh", sizeof (gst_riff_dmlh), 4},
   {"gst_riff_index_entry", sizeof (gst_riff_index_entry), 16},
index 7a9f7c533384156f04a5f9910d40f09897616b11..f0bdf7821927fc7d23fdc3ef550bc8e66f938c50 100644 (file)
@@ -36,7 +36,7 @@ GstCheckABIStruct list[] = {
   {"GstFFTF64Complex", sizeof (GstFFTF64Complex), 16},
   {"GstFFTS16Complex", sizeof (GstFFTS16Complex), 4},
   {"GstFFTS32Complex", sizeof (GstFFTS32Complex), 8},
-  {"GstNavigationInterface", sizeof (GstNavigationInterface), 12},
+  {"GstNavigationInterface", sizeof (GstNavigationInterface), 16},
   {"gst_riff_acid", sizeof (gst_riff_acid), 24},
   {"gst_riff_dmlh", sizeof (gst_riff_dmlh), 4},
   {"gst_riff_index_entry", sizeof (gst_riff_index_entry), 16},
index 83fcac9786fd40283b1c4f7ab9766e3d3e47c5ee..c81df23c9f2ae577120e795e9c200d4443d54261 100644 (file)
@@ -36,7 +36,7 @@ GstCheckABIStruct list[] = {
   {"GstFFTF64Complex", sizeof (GstFFTF64Complex), 16},
   {"GstFFTS16Complex", sizeof (GstFFTS16Complex), 4},
   {"GstFFTS32Complex", sizeof (GstFFTS32Complex), 8},
-  {"GstNavigationInterface", sizeof (GstNavigationInterface), 28},
+  {"GstNavigationInterface", sizeof (GstNavigationInterface), 36},
   {"gst_riff_acid", sizeof (gst_riff_acid), 24},
   {"gst_riff_dmlh", sizeof (gst_riff_dmlh), 4},
   {"gst_riff_index_entry", sizeof (gst_riff_index_entry), 16},
index 0e4228249a52a073c14b47fc9eec08ab6678f298..567d64e70d20a23da360538291cddb88d020c8fc 100644 (file)
@@ -36,7 +36,7 @@ GstCheckABIStruct list[] = {
   {"GstFFTF64Complex", sizeof (GstFFTF64Complex), 16},
   {"GstFFTS16Complex", sizeof (GstFFTS16Complex), 4},
   {"GstFFTS32Complex", sizeof (GstFFTS32Complex), 8},
-  {"GstNavigationInterface", sizeof (GstNavigationInterface), 12},
+  {"GstNavigationInterface", sizeof (GstNavigationInterface), 16},
   {"gst_riff_acid", sizeof (gst_riff_acid), 24},
   {"gst_riff_dmlh", sizeof (gst_riff_dmlh), 4},
   {"gst_riff_index_entry", sizeof (gst_riff_index_entry), 16},
index 773226656616e82db6477bcc94552e151693edf1..3c6c09bb1b5a65a36edf225c8d67970377be6d2c 100644 (file)
@@ -36,7 +36,7 @@ GstCheckABIStruct list[] = {
   {"GstFFTF64Complex", sizeof (GstFFTF64Complex), 16},
   {"GstFFTS16Complex", sizeof (GstFFTS16Complex), 4},
   {"GstFFTS32Complex", sizeof (GstFFTS32Complex), 8},
-  {"GstNavigationInterface", sizeof (GstNavigationInterface), 24},
+  {"GstNavigationInterface", sizeof (GstNavigationInterface), 32},
   {"gst_riff_acid", sizeof (gst_riff_acid), 24},
   {"gst_riff_dmlh", sizeof (gst_riff_dmlh), 4},
   {"gst_riff_index_entry", sizeof (gst_riff_index_entry), 16},
index 81828f6da9200756c20229ba50def2643fa1c3b6..f35e9878c4d57daa28d97458603610e8d53dc1d9 100644 (file)
@@ -36,7 +36,7 @@ GstCheckABIStruct list[] = {
   {"GstFFTF64Complex", sizeof (GstFFTF64Complex), 16},
   {"GstFFTS16Complex", sizeof (GstFFTS16Complex), 4},
   {"GstFFTS32Complex", sizeof (GstFFTS32Complex), 8},
-  {"GstNavigationInterface", sizeof (GstNavigationInterface), 24},
+  {"GstNavigationInterface", sizeof (GstNavigationInterface), 32},
   {"gst_riff_acid", sizeof (gst_riff_acid), 24},
   {"gst_riff_dmlh", sizeof (gst_riff_dmlh), 4},
   {"gst_riff_index_entry", sizeof (gst_riff_index_entry), 16},