mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-26 19:51:11 +00:00
navigation: Improve interface to avoid exposing implementation details
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>
This commit is contained in:
parent
2a703678c0
commit
8648275601
10 changed files with 86 additions and 19 deletions
|
@ -12300,6 +12300,8 @@
|
||||||
"GstNavigationInterface.iface",
|
"GstNavigationInterface.iface",
|
||||||
"GstNavigationInterface.send_event",
|
"GstNavigationInterface.send_event",
|
||||||
"GstNavigationInterface::send_event",
|
"GstNavigationInterface::send_event",
|
||||||
|
"GstNavigationInterface.send_event_simple",
|
||||||
|
"GstNavigationInterface::send_event_simple",
|
||||||
"GstNavigationMessageType",
|
"GstNavigationMessageType",
|
||||||
"GstNavigationQueryType",
|
"GstNavigationQueryType",
|
||||||
"GstNavigationtest",
|
"GstNavigationtest",
|
||||||
|
|
|
@ -64,11 +64,26 @@
|
||||||
|
|
||||||
G_DEFINE_INTERFACE (GstNavigation, gst_navigation, 0);
|
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
|
static void
|
||||||
gst_navigation_default_init (GstNavigationInterface * iface)
|
gst_navigation_default_init (GstNavigationInterface * iface)
|
||||||
{
|
{
|
||||||
/* default virtual functions */
|
/* default virtual functions */
|
||||||
iface->send_event = NULL;
|
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
|
/* 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) {
|
if (iface->send_event) {
|
||||||
iface->send_event (navigation, structure);
|
iface->send_event (navigation, structure);
|
||||||
|
} else if (iface->send_event_simple) {
|
||||||
|
iface->send_event_simple (navigation, gst_event_new_navigation (structure));
|
||||||
} else {
|
} else {
|
||||||
gst_structure_free (structure);
|
gst_structure_free (structure);
|
||||||
}
|
}
|
||||||
|
@ -179,6 +196,32 @@ gst_navigation_send_command (GstNavigation * navigation,
|
||||||
"command", "command-code", G_TYPE_UINT, (guint) command, NULL));
|
"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 */
|
/* Navigation Queries */
|
||||||
|
|
||||||
#define GST_NAVIGATION_QUERY_HAS_TYPE(query,query_type) \
|
#define GST_NAVIGATION_QUERY_HAS_TYPE(query,query_type) \
|
||||||
|
|
|
@ -44,6 +44,7 @@ typedef struct _GstNavigationInterface GstNavigationInterface;
|
||||||
* GstNavigationInterface:
|
* GstNavigationInterface:
|
||||||
* @iface: the parent interface
|
* @iface: the parent interface
|
||||||
* @send_event: sending a navigation event
|
* @send_event: sending a navigation event
|
||||||
|
* @send_event_simple: sending a navigation event (Since: 1.22)
|
||||||
*
|
*
|
||||||
* Navigation interface.
|
* Navigation interface.
|
||||||
*/
|
*/
|
||||||
|
@ -51,7 +52,24 @@ struct _GstNavigationInterface {
|
||||||
GTypeInterface iface;
|
GTypeInterface iface;
|
||||||
|
|
||||||
/* virtual functions */
|
/* 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);
|
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
|
GST_VIDEO_API
|
||||||
|
@ -337,26 +355,30 @@ gboolean gst_navigation_event_parse_command (GstEvent *event,
|
||||||
|
|
||||||
/* interface virtual function wrappers */
|
/* interface virtual function wrappers */
|
||||||
|
|
||||||
GST_VIDEO_API
|
GST_VIDEO_DEPRECATED_FOR(gst_navigation_send_event_simple)
|
||||||
void gst_navigation_send_event (GstNavigation *navigation,
|
void gst_navigation_send_event (GstNavigation *navigation,
|
||||||
GstStructure *structure);
|
GstStructure *structure);
|
||||||
|
|
||||||
GST_VIDEO_API
|
GST_VIDEO_DEPRECATED_FOR(gst_navigation_send_event_simple)
|
||||||
void gst_navigation_send_key_event (GstNavigation *navigation,
|
void gst_navigation_send_key_event (GstNavigation *navigation,
|
||||||
const char *event, const char *key);
|
const char *event, const char *key);
|
||||||
|
|
||||||
GST_VIDEO_API
|
GST_VIDEO_DEPRECATED_FOR(gst_navigation_send_event_simple)
|
||||||
void gst_navigation_send_mouse_event (GstNavigation *navigation,
|
void gst_navigation_send_mouse_event (GstNavigation *navigation,
|
||||||
const char *event, int button, double x, double y);
|
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,
|
void gst_navigation_send_mouse_scroll_event (GstNavigation *navigation,
|
||||||
double x, double y, double delta_x, double delta_y);
|
double x, double y, double delta_x, double delta_y);
|
||||||
|
|
||||||
GST_VIDEO_API
|
GST_VIDEO_DEPRECATED_FOR(gst_navigation_send_event_simple)
|
||||||
void gst_navigation_send_command (GstNavigation *navigation,
|
void gst_navigation_send_command (GstNavigation *navigation,
|
||||||
GstNavigationCommand command);
|
GstNavigationCommand command);
|
||||||
|
|
||||||
|
GST_VIDEO_API
|
||||||
|
void gst_navigation_send_event_simple (GstNavigation *navigation,
|
||||||
|
GstEvent *event);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
#endif /* __GST_NAVIGATION_H__ */
|
#endif /* __GST_NAVIGATION_H__ */
|
||||||
|
|
|
@ -36,7 +36,7 @@ GstCheckABIStruct list[] = {
|
||||||
{"GstFFTF64Complex", sizeof (GstFFTF64Complex), 16},
|
{"GstFFTF64Complex", sizeof (GstFFTF64Complex), 16},
|
||||||
{"GstFFTS16Complex", sizeof (GstFFTS16Complex), 4},
|
{"GstFFTS16Complex", sizeof (GstFFTS16Complex), 4},
|
||||||
{"GstFFTS32Complex", sizeof (GstFFTS32Complex), 8},
|
{"GstFFTS32Complex", sizeof (GstFFTS32Complex), 8},
|
||||||
{"GstNavigationInterface", sizeof (GstNavigationInterface), 24},
|
{"GstNavigationInterface", sizeof (GstNavigationInterface), 32},
|
||||||
{"gst_riff_acid", sizeof (gst_riff_acid), 24},
|
{"gst_riff_acid", sizeof (gst_riff_acid), 24},
|
||||||
{"gst_riff_dmlh", sizeof (gst_riff_dmlh), 4},
|
{"gst_riff_dmlh", sizeof (gst_riff_dmlh), 4},
|
||||||
{"gst_riff_index_entry", sizeof (gst_riff_index_entry), 16},
|
{"gst_riff_index_entry", sizeof (gst_riff_index_entry), 16},
|
||||||
|
|
|
@ -36,7 +36,7 @@ GstCheckABIStruct list[] = {
|
||||||
{"GstFFTF64Complex", sizeof (GstFFTF64Complex), 16},
|
{"GstFFTF64Complex", sizeof (GstFFTF64Complex), 16},
|
||||||
{"GstFFTS16Complex", sizeof (GstFFTS16Complex), 4},
|
{"GstFFTS16Complex", sizeof (GstFFTS16Complex), 4},
|
||||||
{"GstFFTS32Complex", sizeof (GstFFTS32Complex), 8},
|
{"GstFFTS32Complex", sizeof (GstFFTS32Complex), 8},
|
||||||
{"GstNavigationInterface", sizeof (GstNavigationInterface), 28},
|
{"GstNavigationInterface", sizeof (GstNavigationInterface), 36},
|
||||||
{"gst_riff_acid", sizeof (gst_riff_acid), 24},
|
{"gst_riff_acid", sizeof (gst_riff_acid), 24},
|
||||||
{"gst_riff_dmlh", sizeof (gst_riff_dmlh), 4},
|
{"gst_riff_dmlh", sizeof (gst_riff_dmlh), 4},
|
||||||
{"gst_riff_index_entry", sizeof (gst_riff_index_entry), 16},
|
{"gst_riff_index_entry", sizeof (gst_riff_index_entry), 16},
|
||||||
|
|
|
@ -36,7 +36,7 @@ GstCheckABIStruct list[] = {
|
||||||
{"GstFFTF64Complex", sizeof (GstFFTF64Complex), 16},
|
{"GstFFTF64Complex", sizeof (GstFFTF64Complex), 16},
|
||||||
{"GstFFTS16Complex", sizeof (GstFFTS16Complex), 4},
|
{"GstFFTS16Complex", sizeof (GstFFTS16Complex), 4},
|
||||||
{"GstFFTS32Complex", sizeof (GstFFTS32Complex), 8},
|
{"GstFFTS32Complex", sizeof (GstFFTS32Complex), 8},
|
||||||
{"GstNavigationInterface", sizeof (GstNavigationInterface), 12},
|
{"GstNavigationInterface", sizeof (GstNavigationInterface), 16},
|
||||||
{"gst_riff_acid", sizeof (gst_riff_acid), 24},
|
{"gst_riff_acid", sizeof (gst_riff_acid), 24},
|
||||||
{"gst_riff_dmlh", sizeof (gst_riff_dmlh), 4},
|
{"gst_riff_dmlh", sizeof (gst_riff_dmlh), 4},
|
||||||
{"gst_riff_index_entry", sizeof (gst_riff_index_entry), 16},
|
{"gst_riff_index_entry", sizeof (gst_riff_index_entry), 16},
|
||||||
|
|
|
@ -36,7 +36,7 @@ GstCheckABIStruct list[] = {
|
||||||
{"GstFFTF64Complex", sizeof (GstFFTF64Complex), 16},
|
{"GstFFTF64Complex", sizeof (GstFFTF64Complex), 16},
|
||||||
{"GstFFTS16Complex", sizeof (GstFFTS16Complex), 4},
|
{"GstFFTS16Complex", sizeof (GstFFTS16Complex), 4},
|
||||||
{"GstFFTS32Complex", sizeof (GstFFTS32Complex), 8},
|
{"GstFFTS32Complex", sizeof (GstFFTS32Complex), 8},
|
||||||
{"GstNavigationInterface", sizeof (GstNavigationInterface), 28},
|
{"GstNavigationInterface", sizeof (GstNavigationInterface), 36},
|
||||||
{"gst_riff_acid", sizeof (gst_riff_acid), 24},
|
{"gst_riff_acid", sizeof (gst_riff_acid), 24},
|
||||||
{"gst_riff_dmlh", sizeof (gst_riff_dmlh), 4},
|
{"gst_riff_dmlh", sizeof (gst_riff_dmlh), 4},
|
||||||
{"gst_riff_index_entry", sizeof (gst_riff_index_entry), 16},
|
{"gst_riff_index_entry", sizeof (gst_riff_index_entry), 16},
|
||||||
|
|
|
@ -36,7 +36,7 @@ GstCheckABIStruct list[] = {
|
||||||
{"GstFFTF64Complex", sizeof (GstFFTF64Complex), 16},
|
{"GstFFTF64Complex", sizeof (GstFFTF64Complex), 16},
|
||||||
{"GstFFTS16Complex", sizeof (GstFFTS16Complex), 4},
|
{"GstFFTS16Complex", sizeof (GstFFTS16Complex), 4},
|
||||||
{"GstFFTS32Complex", sizeof (GstFFTS32Complex), 8},
|
{"GstFFTS32Complex", sizeof (GstFFTS32Complex), 8},
|
||||||
{"GstNavigationInterface", sizeof (GstNavigationInterface), 12},
|
{"GstNavigationInterface", sizeof (GstNavigationInterface), 16},
|
||||||
{"gst_riff_acid", sizeof (gst_riff_acid), 24},
|
{"gst_riff_acid", sizeof (gst_riff_acid), 24},
|
||||||
{"gst_riff_dmlh", sizeof (gst_riff_dmlh), 4},
|
{"gst_riff_dmlh", sizeof (gst_riff_dmlh), 4},
|
||||||
{"gst_riff_index_entry", sizeof (gst_riff_index_entry), 16},
|
{"gst_riff_index_entry", sizeof (gst_riff_index_entry), 16},
|
||||||
|
|
|
@ -36,7 +36,7 @@ GstCheckABIStruct list[] = {
|
||||||
{"GstFFTF64Complex", sizeof (GstFFTF64Complex), 16},
|
{"GstFFTF64Complex", sizeof (GstFFTF64Complex), 16},
|
||||||
{"GstFFTS16Complex", sizeof (GstFFTS16Complex), 4},
|
{"GstFFTS16Complex", sizeof (GstFFTS16Complex), 4},
|
||||||
{"GstFFTS32Complex", sizeof (GstFFTS32Complex), 8},
|
{"GstFFTS32Complex", sizeof (GstFFTS32Complex), 8},
|
||||||
{"GstNavigationInterface", sizeof (GstNavigationInterface), 24},
|
{"GstNavigationInterface", sizeof (GstNavigationInterface), 32},
|
||||||
{"gst_riff_acid", sizeof (gst_riff_acid), 24},
|
{"gst_riff_acid", sizeof (gst_riff_acid), 24},
|
||||||
{"gst_riff_dmlh", sizeof (gst_riff_dmlh), 4},
|
{"gst_riff_dmlh", sizeof (gst_riff_dmlh), 4},
|
||||||
{"gst_riff_index_entry", sizeof (gst_riff_index_entry), 16},
|
{"gst_riff_index_entry", sizeof (gst_riff_index_entry), 16},
|
||||||
|
|
|
@ -36,7 +36,7 @@ GstCheckABIStruct list[] = {
|
||||||
{"GstFFTF64Complex", sizeof (GstFFTF64Complex), 16},
|
{"GstFFTF64Complex", sizeof (GstFFTF64Complex), 16},
|
||||||
{"GstFFTS16Complex", sizeof (GstFFTS16Complex), 4},
|
{"GstFFTS16Complex", sizeof (GstFFTS16Complex), 4},
|
||||||
{"GstFFTS32Complex", sizeof (GstFFTS32Complex), 8},
|
{"GstFFTS32Complex", sizeof (GstFFTS32Complex), 8},
|
||||||
{"GstNavigationInterface", sizeof (GstNavigationInterface), 24},
|
{"GstNavigationInterface", sizeof (GstNavigationInterface), 32},
|
||||||
{"gst_riff_acid", sizeof (gst_riff_acid), 24},
|
{"gst_riff_acid", sizeof (gst_riff_acid), 24},
|
||||||
{"gst_riff_dmlh", sizeof (gst_riff_dmlh), 4},
|
{"gst_riff_dmlh", sizeof (gst_riff_dmlh), 4},
|
||||||
{"gst_riff_index_entry", sizeof (gst_riff_index_entry), 16},
|
{"gst_riff_index_entry", sizeof (gst_riff_index_entry), 16},
|
||||||
|
|
Loading…
Reference in a new issue