From: Vivienne Watermeier Date: Mon, 31 Jan 2022 12:01:10 +0000 (+0100) Subject: navigation: add more constructors for navigation events X-Git-Tag: 1.22.0~2449 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c38afa2070b4784304ec96e696bf778ec16b109b;p=platform%2Fupstream%2Fgstreamer.git navigation: add more constructors for navigation events Part-of: --- diff --git a/subprojects/gst-plugins-base/gst-libs/gst/video/navigation.c b/subprojects/gst-plugins-base/gst-libs/gst/video/navigation.c index 9548168..c2300a4 100644 --- a/subprojects/gst-plugins-base/gst-libs/gst/video/navigation.c +++ b/subprojects/gst-plugins-base/gst-libs/gst/video/navigation.c @@ -746,6 +746,146 @@ gst_navigation_event_get_type (GstEvent * event) } /** + * gst_navigation_event_new_key_press: + * @key: A string identifying the key press. + * + * Create a new navigation event for the given key press. + * + * Returns: (transfer full): a new #GstEvent + * + * Since: 1.22 + */ +GstEvent * +gst_navigation_event_new_key_press (const gchar * key) +{ + return gst_event_new_navigation (gst_structure_new (GST_NAVIGATION_EVENT_NAME, + "event", G_TYPE_STRING, "key-press", "key", G_TYPE_STRING, key, + NULL)); +} + +/** + * gst_navigation_event_new_key_release: + * @key: A string identifying the released key. + * + * Create a new navigation event for the given key release. + * + * Returns: (transfer full): a new #GstEvent + * + * Since: 1.22 + */ +GstEvent * +gst_navigation_event_new_key_release (const gchar * key) +{ + return gst_event_new_navigation (gst_structure_new (GST_NAVIGATION_EVENT_NAME, + "event", G_TYPE_STRING, "key-release", "key", G_TYPE_STRING, key, + NULL)); +} + +/** + * gst_navigation_event_new_mouse_button_press: + * @button: The number of the pressed mouse button. + * @x: The x coordinate of the mouse cursor. + * @y: The y coordinate of the mouse cursor. + * + * Create a new navigation event for the given key mouse button press. + * + * Returns: (transfer full): a new #GstEvent + * + * Since: 1.22 + */ +GstEvent * +gst_navigation_event_new_mouse_button_press (gint button, gdouble x, gdouble y) +{ + return gst_event_new_navigation (gst_structure_new (GST_NAVIGATION_EVENT_NAME, + "event", G_TYPE_STRING, "mouse-button-press", + "button", G_TYPE_INT, button, "pointer_x", G_TYPE_DOUBLE, x, + "pointer_y", G_TYPE_DOUBLE, y, NULL)); +} + +/** + * gst_navigation_event_new_mouse_button_release: + * @button: The number of the released mouse button. + * @x: The x coordinate of the mouse cursor. + * @y: The y coordinate of the mouse cursor. + * + * Create a new navigation event for the given key mouse button release. + * + * Returns: (transfer full): a new #GstEvent + * + * Since: 1.22 + */ +GstEvent * +gst_navigation_event_new_mouse_button_release (gint button, gdouble x, + gdouble y) +{ + return gst_event_new_navigation (gst_structure_new (GST_NAVIGATION_EVENT_NAME, + "event", G_TYPE_STRING, "mouse-button-release", + "button", G_TYPE_INT, button, "pointer_x", G_TYPE_DOUBLE, x, + "pointer_y", G_TYPE_DOUBLE, y, NULL)); +} + +/** + * gst_navigation_event_new_mouse_move: + * @x: The x coordinate of the mouse cursor. + * @y: The y coordinate of the mouse cursor. + * + * Create a new navigation event for the new mouse location. + * + * Returns: (transfer full): a new #GstEvent + * + * Since: 1.22 + */ +GstEvent * +gst_navigation_event_new_mouse_move (gdouble x, gdouble y) +{ + return gst_event_new_navigation (gst_structure_new (GST_NAVIGATION_EVENT_NAME, + "event", G_TYPE_STRING, "mouse-move", + "pointer_x", G_TYPE_DOUBLE, x, "pointer_y", G_TYPE_DOUBLE, y, NULL)); +} + +/** + * gst_navigation_event_new_mouse_scroll: + * @x: The x coordinate of the mouse cursor. + * @y: The y coordinate of the mouse cursor. + * @delta_x: The x component of the scroll movement. + * @delta_y: The y component of the scroll movement. + * + * Create a new navigation event for the mouse scroll. + * + * Returns: (transfer full): a new #GstEvent + * + * Since: 1.22 + */ +GstEvent * +gst_navigation_event_new_mouse_scroll (gdouble x, gdouble y, gdouble delta_x, + gdouble delta_y) +{ + return gst_event_new_navigation (gst_structure_new (GST_NAVIGATION_EVENT_NAME, + "event", G_TYPE_STRING, "mouse-scroll", + "pointer_x", G_TYPE_DOUBLE, x, "pointer_y", G_TYPE_DOUBLE, y, + "delta_pointer_x", G_TYPE_DOUBLE, delta_x, + "delta_pointer_y", G_TYPE_DOUBLE, delta_y, NULL)); +} + +/** + * gst_navigation_event_new_command: + * @command: The navigation command to use. + * + * Create a new navigation event given navigation command.. + * + * Returns: (transfer full): a new #GstEvent + * + * Since: 1.22 + */ +GstEvent * +gst_navigation_event_new_command (GstNavigationCommand command) +{ + return gst_event_new_navigation (gst_structure_new (GST_NAVIGATION_EVENT_NAME, + "event", G_TYPE_STRING, "command", + "command-code", G_TYPE_UINT, (guint) command, NULL)); +} + +/** * gst_navigation_event_parse_key_event: * @event: A #GstEvent to inspect. * @key: (out) (optional) (transfer none): A pointer to a location to receive diff --git a/subprojects/gst-plugins-base/gst-libs/gst/video/navigation.h b/subprojects/gst-plugins-base/gst-libs/gst/video/navigation.h index 6bd61a5..79d3ea6 100644 --- a/subprojects/gst-plugins-base/gst-libs/gst/video/navigation.h +++ b/subprojects/gst-plugins-base/gst-libs/gst/video/navigation.h @@ -291,6 +291,30 @@ GST_VIDEO_API GstNavigationEventType gst_navigation_event_get_type (GstEvent *event); GST_VIDEO_API +GstEvent* gst_navigation_event_new_key_press (const gchar * key) G_GNUC_MALLOC; + +GST_VIDEO_API +GstEvent* gst_navigation_event_new_key_release (const gchar * key) G_GNUC_MALLOC; + +GST_VIDEO_API +GstEvent* gst_navigation_event_new_mouse_button_press (gint button, gdouble x, + gdouble y) G_GNUC_MALLOC; + +GST_VIDEO_API +GstEvent* gst_navigation_event_new_mouse_button_release (gint button, gdouble x, + gdouble y) G_GNUC_MALLOC; + +GST_VIDEO_API +GstEvent* gst_navigation_event_new_mouse_move (gdouble x, gdouble y) G_GNUC_MALLOC; + +GST_VIDEO_API +GstEvent* gst_navigation_event_new_mouse_scroll (gdouble x, gdouble y, + gdouble delta_x, gdouble delta_y) G_GNUC_MALLOC; + +GST_VIDEO_API +GstEvent* gst_navigation_event_new_command (GstNavigationCommand command) G_GNUC_MALLOC; + +GST_VIDEO_API gboolean gst_navigation_event_parse_key_event (GstEvent *event, const gchar **key); diff --git a/subprojects/gstreamer/gst/gstevent.c b/subprojects/gstreamer/gst/gstevent.c index 225ed3b..c5bf474 100644 --- a/subprojects/gstreamer/gst/gstevent.c +++ b/subprojects/gstreamer/gst/gstevent.c @@ -1492,7 +1492,8 @@ gst_event_parse_seek_trickmode_interval (GstEvent * event, /** * gst_event_new_navigation: * @structure: (transfer full): description of the event. The event will take - * ownership of the structure. + * ownership of the structure. See #GstNavigation for more specific + * constructors. * * Create a new navigation event from the given description. *