2003-09-27 03:16:28 +00:00
|
|
|
/* GStreamer Navigation
|
|
|
|
* Copyright (C) 2003 Ronald Bultje <rbultje@ronald.bitfreak.net>
|
2009-07-13 16:54:40 +00:00
|
|
|
* Copyright (C) 2007-2009 Jan Schmidt <thaytan@noraisin.net>
|
2003-09-27 03:16:28 +00:00
|
|
|
*
|
2009-07-13 16:54:40 +00:00
|
|
|
* navigation.c: navigation event virtual class function wrappers
|
2003-09-27 03:16:28 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
2012-11-03 23:05:09 +00:00
|
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
2003-09-27 03:16:28 +00:00
|
|
|
*/
|
|
|
|
|
2009-07-13 16:54:40 +00:00
|
|
|
/**
|
|
|
|
* SECTION:gstnavigation
|
2017-01-23 19:36:11 +00:00
|
|
|
* @title: GstNavigation
|
2009-07-13 16:54:40 +00:00
|
|
|
* @short_description: Interface for creating, sending and parsing navigation
|
2009-07-13 18:54:47 +00:00
|
|
|
* events.
|
2009-07-13 16:54:40 +00:00
|
|
|
*
|
|
|
|
* The Navigation interface is used for creating and injecting navigation related
|
|
|
|
* events such as mouse button presses, cursor motion and key presses. The associated
|
|
|
|
* library also provides methods for parsing received events, and for sending and
|
2009-07-13 18:54:47 +00:00
|
|
|
* receiving navigation related bus events. One main usecase is DVD menu navigation.
|
|
|
|
*
|
2009-07-13 16:54:40 +00:00
|
|
|
* The main parts of the API are:
|
2017-01-23 19:36:11 +00:00
|
|
|
*
|
|
|
|
* * The GstNavigation interface, implemented by elements which provide an application
|
|
|
|
* with the ability to create and inject navigation events into the pipeline.
|
|
|
|
* * GstNavigation event handling API. GstNavigation events are created in response to
|
|
|
|
* calls on a GstNavigation interface implementation, and sent in the pipeline. Upstream
|
|
|
|
* elements can use the navigation event API functions to parse the contents of received
|
|
|
|
* messages.
|
|
|
|
*
|
|
|
|
* * GstNavigation message handling API. GstNavigation messages may be sent on the message
|
|
|
|
* bus to inform applications of navigation related changes in the pipeline, such as the
|
|
|
|
* mouse moving over a clickable region, or the set of available angles changing.
|
|
|
|
*
|
2009-07-13 16:54:40 +00:00
|
|
|
* The GstNavigation message functions provide functions for creating and parsing
|
2011-09-13 19:10:43 +00:00
|
|
|
* custom bus messages for signaling GstNavigation changes.
|
2017-01-23 19:36:11 +00:00
|
|
|
*
|
2009-07-13 16:54:40 +00:00
|
|
|
*/
|
|
|
|
|
2003-09-27 03:16:28 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2012-04-13 09:01:03 +00:00
|
|
|
#include <gst/video/navigation.h>
|
|
|
|
#include <gst/video/video-enumtypes.h>
|
2003-09-27 03:16:28 +00:00
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
static void gst_navigation_class_init (GstNavigationInterface * iface);
|
2003-09-27 03:16:28 +00:00
|
|
|
|
2009-03-30 23:54:30 +00:00
|
|
|
#define GST_NAVIGATION_MESSAGE_NAME "GstNavigationMessage"
|
|
|
|
#define GST_NAVIGATION_QUERY_NAME "GstNavigationQuery"
|
|
|
|
#define GST_NAVIGATION_EVENT_NAME "application/x-gst-navigation"
|
|
|
|
|
2009-09-08 15:00:47 +00:00
|
|
|
#define WARN_IF_FAIL(exp,msg) if(G_UNLIKELY(!(exp))){g_warning("%s",(msg));}
|
|
|
|
|
2003-09-27 03:16:28 +00:00
|
|
|
GType
|
|
|
|
gst_navigation_get_type (void)
|
|
|
|
{
|
|
|
|
static GType gst_navigation_type = 0;
|
|
|
|
|
|
|
|
if (!gst_navigation_type) {
|
|
|
|
static const GTypeInfo gst_navigation_info = {
|
2003-10-30 01:43:45 +00:00
|
|
|
sizeof (GstNavigationInterface),
|
2003-09-27 03:16:28 +00:00
|
|
|
(GBaseInitFunc) gst_navigation_class_init,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
NULL,
|
|
|
|
};
|
|
|
|
|
|
|
|
gst_navigation_type = g_type_register_static (G_TYPE_INTERFACE,
|
2004-03-15 19:32:28 +00:00
|
|
|
"GstNavigation", &gst_navigation_info, 0);
|
2003-09-27 03:16:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return gst_navigation_type;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_navigation_class_init (GstNavigationInterface * iface)
|
2003-09-27 03:16:28 +00:00
|
|
|
{
|
|
|
|
/* default virtual functions */
|
2003-10-29 05:12:18 +00:00
|
|
|
iface->send_event = NULL;
|
2003-09-27 03:16:28 +00:00
|
|
|
}
|
|
|
|
|
2004-07-09 10:56:51 +00:00
|
|
|
/* The interface implementer should make sure that the object can handle
|
|
|
|
* the event. */
|
2003-09-27 03:16:28 +00:00
|
|
|
void
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_navigation_send_event (GstNavigation * navigation, GstStructure * structure)
|
2003-09-27 03:16:28 +00:00
|
|
|
{
|
2011-10-21 12:37:31 +00:00
|
|
|
GstNavigationInterface *iface = GST_NAVIGATION_GET_INTERFACE (navigation);
|
2003-09-27 03:16:28 +00:00
|
|
|
|
2003-10-29 05:12:18 +00:00
|
|
|
if (iface->send_event) {
|
2003-11-11 00:43:29 +00:00
|
|
|
iface->send_event (navigation, structure);
|
2015-05-04 15:58:38 +00:00
|
|
|
} else {
|
|
|
|
gst_structure_free (structure);
|
2003-09-27 03:16:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-03-30 23:54:30 +00:00
|
|
|
/**
|
2009-08-10 00:46:39 +00:00
|
|
|
* gst_navigation_send_key_event:
|
2009-03-30 23:54:30 +00:00
|
|
|
* @navigation: The navigation interface instance
|
|
|
|
* @event: The type of the key event. Recognised values are "key-press" and
|
|
|
|
* "key-release"
|
|
|
|
* @key: Character representation of the key. This is typically as produced
|
|
|
|
* by XKeysymToString.
|
|
|
|
*/
|
2003-09-27 03:16:28 +00:00
|
|
|
void
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_navigation_send_key_event (GstNavigation * navigation, const char *event,
|
|
|
|
const char *key)
|
2003-09-27 03:16:28 +00:00
|
|
|
{
|
2017-06-06 05:38:00 +00:00
|
|
|
g_return_if_fail (g_strcmp0 (event, "key-press") == 0 ||
|
|
|
|
g_strcmp0 (event, "key-release") == 0);
|
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_navigation_send_event (navigation,
|
2009-03-30 23:54:30 +00:00
|
|
|
gst_structure_new (GST_NAVIGATION_EVENT_NAME, "event", G_TYPE_STRING,
|
2004-03-15 19:32:28 +00:00
|
|
|
event, "key", G_TYPE_STRING, key, NULL));
|
2003-09-27 03:16:28 +00:00
|
|
|
}
|
|
|
|
|
2009-03-30 23:54:30 +00:00
|
|
|
/**
|
|
|
|
* gst_navigation_send_mouse_event:
|
|
|
|
* @navigation: The navigation interface instance
|
|
|
|
* @event: The type of mouse event, as a text string. Recognised values are
|
|
|
|
* "mouse-button-press", "mouse-button-release" and "mouse-move".
|
|
|
|
* @button: The button number of the button being pressed or released. Pass 0
|
|
|
|
* for mouse-move events.
|
|
|
|
* @x: The x coordinate of the mouse event.
|
|
|
|
* @y: The y coordinate of the mouse event.
|
|
|
|
*
|
|
|
|
* Sends a mouse event to the navigation interface. Mouse event coordinates
|
|
|
|
* are sent relative to the display space of the related output area. This is
|
|
|
|
* usually the size in pixels of the window associated with the element
|
|
|
|
* implementing the #GstNavigation interface.
|
|
|
|
*
|
|
|
|
*/
|
2003-09-27 03:16:28 +00:00
|
|
|
void
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_navigation_send_mouse_event (GstNavigation * navigation, const char *event,
|
|
|
|
int button, double x, double y)
|
2003-09-27 03:16:28 +00:00
|
|
|
{
|
2017-06-06 05:38:00 +00:00
|
|
|
g_return_if_fail (g_strcmp0 (event, "mouse-button-press") == 0 ||
|
|
|
|
g_strcmp0 (event, "mouse-button-release") == 0 ||
|
|
|
|
g_strcmp0 (event, "mouse-move") == 0);
|
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_navigation_send_event (navigation,
|
2009-03-30 23:54:30 +00:00
|
|
|
gst_structure_new (GST_NAVIGATION_EVENT_NAME, "event", G_TYPE_STRING,
|
2004-03-15 19:32:28 +00:00
|
|
|
event, "button", G_TYPE_INT, button, "pointer_x", G_TYPE_DOUBLE, x,
|
|
|
|
"pointer_y", G_TYPE_DOUBLE, y, NULL));
|
2003-09-27 03:16:28 +00:00
|
|
|
}
|
2009-03-30 23:54:30 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_navigation_send_command:
|
|
|
|
* @navigation: The navigation interface instance
|
|
|
|
* @command: The command to issue
|
|
|
|
*
|
|
|
|
* Sends the indicated command to the navigation interface.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gst_navigation_send_command (GstNavigation * navigation,
|
|
|
|
GstNavigationCommand command)
|
|
|
|
{
|
|
|
|
gst_navigation_send_event (navigation,
|
|
|
|
gst_structure_new (GST_NAVIGATION_EVENT_NAME, "event", G_TYPE_STRING,
|
|
|
|
"command", "command-code", G_TYPE_UINT, (guint) command, NULL));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Navigation Queries */
|
|
|
|
|
|
|
|
#define GST_NAVIGATION_QUERY_HAS_TYPE(query,query_type) \
|
|
|
|
(gst_navigation_query_get_type (query) == GST_NAVIGATION_QUERY_ ## query_type)
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_navigation_query_get_type:
|
|
|
|
* @query: The query to inspect
|
|
|
|
*
|
|
|
|
* Inspect a #GstQuery and return the #GstNavigationQueryType associated with
|
|
|
|
* it if it is a #GstNavigation query.
|
|
|
|
*
|
|
|
|
* Returns: The #GstNavigationQueryType of the query, or
|
|
|
|
* #GST_NAVIGATION_QUERY_INVALID
|
|
|
|
*/
|
|
|
|
GstNavigationQueryType
|
|
|
|
gst_navigation_query_get_type (GstQuery * query)
|
|
|
|
{
|
|
|
|
const GstStructure *s;
|
|
|
|
const gchar *q_type;
|
|
|
|
|
|
|
|
if (query == NULL || GST_QUERY_TYPE (query) != GST_QUERY_CUSTOM)
|
|
|
|
return GST_NAVIGATION_QUERY_INVALID;
|
|
|
|
|
|
|
|
s = gst_query_get_structure (query);
|
|
|
|
if (s == NULL || !gst_structure_has_name (s, GST_NAVIGATION_QUERY_NAME))
|
|
|
|
return GST_NAVIGATION_QUERY_INVALID;
|
|
|
|
|
|
|
|
q_type = gst_structure_get_string (s, "type");
|
|
|
|
if (q_type == NULL)
|
|
|
|
return GST_NAVIGATION_QUERY_INVALID;
|
|
|
|
|
|
|
|
if (g_str_equal (q_type, "commands"))
|
|
|
|
return GST_NAVIGATION_QUERY_COMMANDS;
|
|
|
|
else if (g_str_equal (q_type, "angles"))
|
|
|
|
return GST_NAVIGATION_QUERY_ANGLES;
|
|
|
|
|
|
|
|
return GST_NAVIGATION_QUERY_INVALID;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_navigation_query_new_commands:
|
|
|
|
*
|
|
|
|
* Create a new #GstNavigation commands query. When executed, it will
|
|
|
|
* query the pipeline for the set of currently available commands.
|
|
|
|
*
|
|
|
|
* Returns: The new query.
|
|
|
|
*/
|
|
|
|
GstQuery *
|
|
|
|
gst_navigation_query_new_commands (void)
|
|
|
|
{
|
|
|
|
GstQuery *query;
|
|
|
|
GstStructure *structure;
|
|
|
|
|
|
|
|
structure = gst_structure_new (GST_NAVIGATION_QUERY_NAME,
|
|
|
|
"type", G_TYPE_STRING, "commands", NULL);
|
2011-05-10 13:43:08 +00:00
|
|
|
query = gst_query_new_custom (GST_QUERY_CUSTOM, structure);
|
2009-03-30 23:54:30 +00:00
|
|
|
|
|
|
|
return query;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_query_list_add_command (GValue * list, GstNavigationCommand val)
|
|
|
|
{
|
|
|
|
GValue item = { 0, };
|
|
|
|
|
|
|
|
g_value_init (&item, GST_TYPE_NAVIGATION_COMMAND);
|
|
|
|
g_value_set_enum (&item, val);
|
|
|
|
gst_value_list_append_value (list, &item);
|
|
|
|
g_value_unset (&item);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_navigation_query_set_commands:
|
|
|
|
* @query: a #GstQuery
|
|
|
|
* @n_cmds: the number of commands to set.
|
|
|
|
* @...: A list of @GstNavigationCommand values, @n_cmds entries long.
|
|
|
|
*
|
|
|
|
* Set the #GstNavigation command query result fields in @query. The number
|
|
|
|
* of commands passed must be equal to @n_commands.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gst_navigation_query_set_commands (GstQuery * query, gint n_cmds, ...)
|
|
|
|
{
|
|
|
|
va_list ap;
|
|
|
|
GValue list = { 0, };
|
|
|
|
GstStructure *structure;
|
|
|
|
gint i;
|
|
|
|
|
|
|
|
g_return_if_fail (GST_NAVIGATION_QUERY_HAS_TYPE (query, COMMANDS));
|
|
|
|
|
|
|
|
g_value_init (&list, GST_TYPE_LIST);
|
|
|
|
|
|
|
|
va_start (ap, n_cmds);
|
|
|
|
for (i = 0; i < n_cmds; i++) {
|
|
|
|
GstNavigationCommand val = va_arg (ap, GstNavigationCommand);
|
|
|
|
gst_query_list_add_command (&list, val);
|
|
|
|
}
|
|
|
|
va_end (ap);
|
|
|
|
|
2011-05-10 13:43:08 +00:00
|
|
|
structure = gst_query_writable_structure (query);
|
2013-03-03 17:43:47 +00:00
|
|
|
gst_structure_take_value (structure, "commands", &list);
|
2009-03-30 23:54:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_navigation_query_set_commandsv:
|
|
|
|
* @query: a #GstQuery
|
|
|
|
* @n_cmds: the number of commands to set.
|
2017-06-01 20:01:03 +00:00
|
|
|
* @cmds: (array length=n_cmds): An array containing @n_cmds
|
|
|
|
* @GstNavigationCommand values.
|
2009-03-30 23:54:30 +00:00
|
|
|
*
|
|
|
|
* Set the #GstNavigation command query result fields in @query. The number
|
|
|
|
* of commands passed must be equal to @n_commands.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gst_navigation_query_set_commandsv (GstQuery * query, gint n_cmds,
|
|
|
|
GstNavigationCommand * cmds)
|
|
|
|
{
|
|
|
|
GValue list = { 0, };
|
|
|
|
GstStructure *structure;
|
|
|
|
gint i;
|
|
|
|
|
|
|
|
g_return_if_fail (GST_NAVIGATION_QUERY_HAS_TYPE (query, COMMANDS));
|
|
|
|
|
|
|
|
g_value_init (&list, GST_TYPE_LIST);
|
|
|
|
for (i = 0; i < n_cmds; i++) {
|
|
|
|
gst_query_list_add_command (&list, cmds[i]);
|
|
|
|
}
|
2011-05-10 13:43:08 +00:00
|
|
|
structure = gst_query_writable_structure (query);
|
2013-03-03 17:43:47 +00:00
|
|
|
gst_structure_take_value (structure, "commands", &list);
|
2009-03-30 23:54:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_navigation_query_parse_commands_length:
|
|
|
|
* @query: a #GstQuery
|
2017-06-01 20:01:03 +00:00
|
|
|
* @n_cmds: (out) (optional): the number of commands in this query.
|
2009-03-30 23:54:30 +00:00
|
|
|
*
|
|
|
|
* Parse the number of commands in the #GstNavigation commands @query.
|
|
|
|
*
|
|
|
|
* Returns: %TRUE if the query could be successfully parsed. %FALSE if not.
|
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
gst_navigation_query_parse_commands_length (GstQuery * query, guint * n_cmds)
|
|
|
|
{
|
2011-05-10 13:43:08 +00:00
|
|
|
const GstStructure *structure;
|
2009-03-30 23:54:30 +00:00
|
|
|
const GValue *list;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GST_NAVIGATION_QUERY_HAS_TYPE (query, COMMANDS), FALSE);
|
|
|
|
|
|
|
|
if (n_cmds == NULL)
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
structure = gst_query_get_structure (query);
|
|
|
|
list = gst_structure_get_value (structure, "commands");
|
|
|
|
if (list == NULL)
|
|
|
|
*n_cmds = 0;
|
|
|
|
else
|
|
|
|
*n_cmds = gst_value_list_get_size (list);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_navigation_query_parse_commands_nth:
|
|
|
|
* @query: a #GstQuery
|
|
|
|
* @nth: the nth command to retrieve.
|
2017-06-01 20:01:03 +00:00
|
|
|
* @cmd: (out) (optional): a pointer to store the nth command into.
|
2009-03-30 23:54:30 +00:00
|
|
|
*
|
|
|
|
* Parse the #GstNavigation command query and retrieve the @nth command from
|
|
|
|
* it into @cmd. If the list contains less elements than @nth, @cmd will be
|
|
|
|
* set to #GST_NAVIGATION_COMMAND_INVALID.
|
|
|
|
*
|
|
|
|
* Returns: %TRUE if the query could be successfully parsed. %FALSE if not.
|
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
gst_navigation_query_parse_commands_nth (GstQuery * query, guint nth,
|
|
|
|
GstNavigationCommand * cmd)
|
|
|
|
{
|
2011-05-10 13:43:08 +00:00
|
|
|
const GstStructure *structure;
|
2009-03-30 23:54:30 +00:00
|
|
|
const GValue *list;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GST_NAVIGATION_QUERY_HAS_TYPE (query, COMMANDS), FALSE);
|
|
|
|
|
|
|
|
if (cmd == NULL)
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
structure = gst_query_get_structure (query);
|
|
|
|
list = gst_structure_get_value (structure, "commands");
|
|
|
|
if (list == NULL) {
|
|
|
|
*cmd = GST_NAVIGATION_COMMAND_INVALID;
|
|
|
|
} else {
|
|
|
|
if (nth < gst_value_list_get_size (list)) {
|
|
|
|
*cmd = (GstNavigationCommand)
|
|
|
|
g_value_get_enum (gst_value_list_get_value (list, nth));
|
|
|
|
} else
|
|
|
|
*cmd = GST_NAVIGATION_COMMAND_INVALID;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_navigation_query_new_angles:
|
|
|
|
*
|
|
|
|
* Create a new #GstNavigation angles query. When executed, it will
|
|
|
|
* query the pipeline for the set of currently available angles, which may be
|
|
|
|
* greater than one in a multiangle video.
|
|
|
|
*
|
|
|
|
* Returns: The new query.
|
|
|
|
*/
|
|
|
|
GstQuery *
|
|
|
|
gst_navigation_query_new_angles (void)
|
|
|
|
{
|
|
|
|
GstQuery *query;
|
|
|
|
GstStructure *structure;
|
|
|
|
|
|
|
|
structure = gst_structure_new (GST_NAVIGATION_QUERY_NAME,
|
|
|
|
"type", G_TYPE_STRING, "angles", NULL);
|
2011-05-10 13:43:08 +00:00
|
|
|
query = gst_query_new_custom (GST_QUERY_CUSTOM, structure);
|
2009-03-30 23:54:30 +00:00
|
|
|
|
|
|
|
return query;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_navigation_query_set_angles:
|
|
|
|
* @query: a #GstQuery
|
|
|
|
* @cur_angle: the current viewing angle to set.
|
|
|
|
* @n_angles: the number of viewing angles to set.
|
|
|
|
*
|
|
|
|
* Set the #GstNavigation angles query result field in @query.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gst_navigation_query_set_angles (GstQuery * query, guint cur_angle,
|
|
|
|
guint n_angles)
|
|
|
|
{
|
|
|
|
GstStructure *structure;
|
|
|
|
|
|
|
|
g_return_if_fail (GST_NAVIGATION_QUERY_HAS_TYPE (query, ANGLES));
|
|
|
|
|
2011-05-10 13:43:08 +00:00
|
|
|
structure = gst_query_writable_structure (query);
|
2009-03-30 23:54:30 +00:00
|
|
|
gst_structure_set (structure,
|
|
|
|
"angle", G_TYPE_UINT, cur_angle, "angles", G_TYPE_UINT, n_angles, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_navigation_query_parse_angles:
|
|
|
|
* @query: a #GstQuery
|
2017-06-01 20:01:03 +00:00
|
|
|
* @cur_angle: (out) (optional): Pointer to a #guint into which to store the
|
|
|
|
* currently selected angle value from the query, or NULL
|
|
|
|
* @n_angles: (out) (optional): Pointer to a #guint into which to store the
|
|
|
|
* number of angles value from the query, or NULL
|
2009-03-30 23:54:30 +00:00
|
|
|
*
|
|
|
|
* Parse the current angle number in the #GstNavigation angles @query into the
|
|
|
|
* #guint pointed to by the @cur_angle variable, and the number of available
|
|
|
|
* angles into the #guint pointed to by the @n_angles variable.
|
|
|
|
*
|
|
|
|
* Returns: %TRUE if the query could be successfully parsed. %FALSE if not.
|
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
gst_navigation_query_parse_angles (GstQuery * query, guint * cur_angle,
|
|
|
|
guint * n_angles)
|
|
|
|
{
|
2011-05-10 13:43:08 +00:00
|
|
|
const GstStructure *structure;
|
2009-09-08 15:00:47 +00:00
|
|
|
gboolean ret = TRUE;
|
2009-03-30 23:54:30 +00:00
|
|
|
|
|
|
|
g_return_val_if_fail (GST_NAVIGATION_QUERY_HAS_TYPE (query, ANGLES), FALSE);
|
|
|
|
|
|
|
|
structure = gst_query_get_structure (query);
|
|
|
|
|
|
|
|
if (cur_angle)
|
2009-09-08 15:00:47 +00:00
|
|
|
ret &= gst_structure_get_uint (structure, "angle", cur_angle);
|
2009-03-30 23:54:30 +00:00
|
|
|
|
|
|
|
if (n_angles)
|
2009-09-08 15:00:47 +00:00
|
|
|
ret &= gst_structure_get_uint (structure, "angles", n_angles);
|
2009-03-30 23:54:30 +00:00
|
|
|
|
2009-09-08 15:00:47 +00:00
|
|
|
WARN_IF_FAIL (ret, "Couldn't extract details from angles query");
|
|
|
|
|
|
|
|
return ret;
|
2009-03-30 23:54:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Navigation Messages */
|
|
|
|
|
|
|
|
#define GST_NAVIGATION_MESSAGE_HAS_TYPE(msg,msg_type) \
|
|
|
|
(gst_navigation_message_get_type (msg) == GST_NAVIGATION_MESSAGE_ ## msg_type)
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_navigation_message_get_type:
|
|
|
|
* @message: A #GstMessage to inspect.
|
|
|
|
*
|
|
|
|
* Check a bus message to see if it is a #GstNavigation event, and return
|
|
|
|
* the #GstNavigationMessageType identifying the type of the message if so.
|
|
|
|
*
|
2011-08-20 17:16:42 +00:00
|
|
|
* Returns: The type of the #GstMessage, or
|
2009-03-30 23:54:30 +00:00
|
|
|
* #GST_NAVIGATION_MESSAGE_INVALID if the message is not a #GstNavigation
|
|
|
|
* notification.
|
|
|
|
*/
|
|
|
|
GstNavigationMessageType
|
|
|
|
gst_navigation_message_get_type (GstMessage * message)
|
|
|
|
{
|
|
|
|
const GstStructure *s;
|
|
|
|
const gchar *m_type;
|
|
|
|
|
|
|
|
if (message == NULL || GST_MESSAGE_TYPE (message) != GST_MESSAGE_ELEMENT)
|
|
|
|
return GST_NAVIGATION_MESSAGE_INVALID;
|
|
|
|
|
|
|
|
s = gst_message_get_structure (message);
|
|
|
|
if (s == NULL || !gst_structure_has_name (s, GST_NAVIGATION_MESSAGE_NAME))
|
|
|
|
return GST_NAVIGATION_MESSAGE_INVALID;
|
|
|
|
|
|
|
|
m_type = gst_structure_get_string (s, "type");
|
|
|
|
if (m_type == NULL)
|
|
|
|
return GST_NAVIGATION_MESSAGE_INVALID;
|
|
|
|
|
|
|
|
if (g_str_equal (m_type, "mouse-over"))
|
|
|
|
return GST_NAVIGATION_MESSAGE_MOUSE_OVER;
|
|
|
|
else if (g_str_equal (m_type, "commands-changed"))
|
|
|
|
return GST_NAVIGATION_MESSAGE_COMMANDS_CHANGED;
|
|
|
|
else if (g_str_equal (m_type, "angles-changed"))
|
|
|
|
return GST_NAVIGATION_MESSAGE_ANGLES_CHANGED;
|
2015-04-02 14:09:13 +00:00
|
|
|
else if (g_str_equal (m_type, "event"))
|
|
|
|
return GST_NAVIGATION_MESSAGE_EVENT;
|
2009-03-30 23:54:30 +00:00
|
|
|
|
|
|
|
return GST_NAVIGATION_MESSAGE_INVALID;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_navigation_message_new_mouse_over:
|
|
|
|
* @src: A #GstObject to set as source of the new message.
|
|
|
|
* @active: %TRUE if the mouse has entered a clickable area of the display.
|
|
|
|
* %FALSE if it over a non-clickable area.
|
|
|
|
*
|
|
|
|
* Creates a new #GstNavigation message with type
|
|
|
|
* #GST_NAVIGATION_MESSAGE_MOUSE_OVER.
|
|
|
|
*
|
|
|
|
* Returns: The new #GstMessage.
|
|
|
|
*/
|
|
|
|
GstMessage *
|
|
|
|
gst_navigation_message_new_mouse_over (GstObject * src, gboolean active)
|
|
|
|
{
|
|
|
|
GstStructure *s;
|
|
|
|
GstMessage *m;
|
|
|
|
|
|
|
|
s = gst_structure_new (GST_NAVIGATION_MESSAGE_NAME,
|
|
|
|
"type", G_TYPE_STRING, "mouse-over", "active", G_TYPE_BOOLEAN, active,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
m = gst_message_new_custom (GST_MESSAGE_ELEMENT, src, s);
|
|
|
|
|
|
|
|
return m;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_navigation_message_parse_mouse_over:
|
|
|
|
* @message: A #GstMessage to inspect.
|
2017-06-01 20:01:03 +00:00
|
|
|
* @active: (out) (optional): A pointer to a gboolean to receive the
|
|
|
|
* active/inactive state, or NULL.
|
2009-03-30 23:54:30 +00:00
|
|
|
*
|
|
|
|
* Parse a #GstNavigation message of type #GST_NAVIGATION_MESSAGE_MOUSE_OVER
|
|
|
|
* and extract the active/inactive flag. If the mouse over event is marked
|
|
|
|
* active, it indicates that the mouse is over a clickable area.
|
|
|
|
*
|
|
|
|
* Returns: %TRUE if the message could be successfully parsed. %FALSE if not.
|
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
gst_navigation_message_parse_mouse_over (GstMessage * message,
|
|
|
|
gboolean * active)
|
|
|
|
{
|
2009-04-04 14:28:14 +00:00
|
|
|
if (!GST_NAVIGATION_MESSAGE_HAS_TYPE (message, MOUSE_OVER))
|
|
|
|
return FALSE;
|
2009-03-30 23:54:30 +00:00
|
|
|
|
|
|
|
if (active) {
|
|
|
|
const GstStructure *s = gst_message_get_structure (message);
|
2014-11-28 13:28:06 +00:00
|
|
|
if (!gst_structure_get_boolean (s, "active", active))
|
2009-04-04 14:28:14 +00:00
|
|
|
return FALSE;
|
2009-03-30 23:54:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2015-04-02 14:09:13 +00:00
|
|
|
/**
|
|
|
|
* gst_navigation_message_new_event:
|
|
|
|
* @src: A #GstObject to set as source of the new message.
|
|
|
|
* @event: (transfer none): A navigation #GstEvent
|
|
|
|
*
|
|
|
|
* Creates a new #GstNavigation message with type
|
|
|
|
* #GST_NAVIGATION_MESSAGE_EVENT.
|
|
|
|
*
|
|
|
|
* Returns: The new #GstMessage.
|
2015-04-29 14:30:02 +00:00
|
|
|
*
|
|
|
|
* Since: 1.6
|
2015-04-02 14:09:13 +00:00
|
|
|
*/
|
|
|
|
GstMessage *
|
|
|
|
gst_navigation_message_new_event (GstObject * src, GstEvent * event)
|
|
|
|
{
|
|
|
|
GstStructure *s;
|
|
|
|
GstMessage *m;
|
|
|
|
|
|
|
|
s = gst_structure_new (GST_NAVIGATION_MESSAGE_NAME,
|
|
|
|
"type", G_TYPE_STRING, "event", "event", GST_TYPE_EVENT, event, NULL);
|
|
|
|
|
|
|
|
m = gst_message_new_custom (GST_MESSAGE_ELEMENT, src, s);
|
|
|
|
|
|
|
|
return m;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_navigation_message_parse_event:
|
|
|
|
* @message: A #GstMessage to inspect.
|
2017-06-01 20:01:03 +00:00
|
|
|
* @event: (out) (optional) (transfer full): a pointer to a #GstEvent to receive
|
|
|
|
* the contained navigation event.
|
2015-04-02 14:09:13 +00:00
|
|
|
*
|
|
|
|
* Parse a #GstNavigation message of type #GST_NAVIGATION_MESSAGE_EVENT
|
|
|
|
* and extract contained #GstEvent. The caller must unref the @event when done
|
|
|
|
* with it.
|
|
|
|
*
|
|
|
|
* Returns: %TRUE if the message could be successfully parsed. %FALSE if not.
|
2015-04-29 14:30:02 +00:00
|
|
|
*
|
|
|
|
* Since: 1.6
|
2015-04-02 14:09:13 +00:00
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
gst_navigation_message_parse_event (GstMessage * message, GstEvent ** event)
|
|
|
|
{
|
|
|
|
if (!GST_NAVIGATION_MESSAGE_HAS_TYPE (message, EVENT))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (event) {
|
|
|
|
const GstStructure *s = gst_message_get_structure (message);
|
|
|
|
if (!gst_structure_get (s, "event", GST_TYPE_EVENT, event, NULL))
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2009-03-30 23:54:30 +00:00
|
|
|
/**
|
|
|
|
* gst_navigation_message_new_commands_changed:
|
|
|
|
* @src: A #GstObject to set as source of the new message.
|
|
|
|
*
|
|
|
|
* Creates a new #GstNavigation message with type
|
|
|
|
* #GST_NAVIGATION_MESSAGE_COMMANDS_CHANGED
|
|
|
|
*
|
|
|
|
* Returns: The new #GstMessage.
|
|
|
|
*/
|
|
|
|
GstMessage *
|
|
|
|
gst_navigation_message_new_commands_changed (GstObject * src)
|
|
|
|
{
|
|
|
|
GstStructure *s;
|
|
|
|
GstMessage *m;
|
|
|
|
|
|
|
|
s = gst_structure_new (GST_NAVIGATION_MESSAGE_NAME,
|
|
|
|
"type", G_TYPE_STRING, "commands-changed", NULL);
|
|
|
|
|
|
|
|
m = gst_message_new_custom (GST_MESSAGE_ELEMENT, src, s);
|
|
|
|
|
|
|
|
return m;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_navigation_message_new_angles_changed:
|
|
|
|
* @src: A #GstObject to set as source of the new message.
|
|
|
|
* @cur_angle: The currently selected angle.
|
|
|
|
* @n_angles: The number of viewing angles now available.
|
|
|
|
*
|
|
|
|
* Creates a new #GstNavigation message with type
|
|
|
|
* #GST_NAVIGATION_MESSAGE_ANGLES_CHANGED for notifying an application
|
|
|
|
* that the current angle, or current number of angles available in a
|
|
|
|
* multiangle video has changed.
|
|
|
|
*
|
|
|
|
* Returns: The new #GstMessage.
|
|
|
|
*/
|
|
|
|
GstMessage *
|
|
|
|
gst_navigation_message_new_angles_changed (GstObject * src, guint cur_angle,
|
|
|
|
guint n_angles)
|
|
|
|
{
|
|
|
|
GstStructure *s;
|
|
|
|
GstMessage *m;
|
|
|
|
|
|
|
|
s = gst_structure_new (GST_NAVIGATION_MESSAGE_NAME,
|
|
|
|
"type", G_TYPE_STRING, "angles-changed",
|
|
|
|
"angle", G_TYPE_UINT, cur_angle, "angles", G_TYPE_UINT, n_angles, NULL);
|
|
|
|
|
|
|
|
m = gst_message_new_custom (GST_MESSAGE_ELEMENT, src, s);
|
|
|
|
|
|
|
|
return m;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_navigation_message_parse_angles_changed:
|
|
|
|
* @message: A #GstMessage to inspect.
|
2017-06-01 20:01:03 +00:00
|
|
|
* @cur_angle: (out) (optional): A pointer to a #guint to receive the new
|
|
|
|
* current angle number, or NULL
|
|
|
|
* @n_angles: (out) (optional): A pointer to a #guint to receive the new angle
|
|
|
|
* count, or NULL.
|
2009-03-30 23:54:30 +00:00
|
|
|
*
|
|
|
|
* Parse a #GstNavigation message of type GST_NAVIGATION_MESSAGE_ANGLES_CHANGED
|
|
|
|
* and extract the @cur_angle and @n_angles parameters.
|
|
|
|
*
|
|
|
|
* Returns: %TRUE if the message could be successfully parsed. %FALSE if not.
|
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
gst_navigation_message_parse_angles_changed (GstMessage * message,
|
|
|
|
guint * cur_angle, guint * n_angles)
|
|
|
|
{
|
|
|
|
const GstStructure *s;
|
2009-09-08 15:00:47 +00:00
|
|
|
gboolean ret = TRUE;
|
2009-03-30 23:54:30 +00:00
|
|
|
|
|
|
|
g_return_val_if_fail (GST_NAVIGATION_MESSAGE_HAS_TYPE (message,
|
|
|
|
ANGLES_CHANGED), FALSE);
|
|
|
|
|
|
|
|
s = gst_message_get_structure (message);
|
|
|
|
if (cur_angle)
|
2009-09-08 15:00:47 +00:00
|
|
|
ret &= gst_structure_get_uint (s, "angle", cur_angle);
|
2009-03-30 23:54:30 +00:00
|
|
|
|
|
|
|
if (n_angles)
|
2009-09-08 15:00:47 +00:00
|
|
|
ret &= gst_structure_get_uint (s, "angles", n_angles);
|
2009-03-30 23:54:30 +00:00
|
|
|
|
2009-09-08 15:00:47 +00:00
|
|
|
WARN_IF_FAIL (ret, "Couldn't extract details from angles-changed event");
|
|
|
|
|
|
|
|
return ret;
|
2009-03-30 23:54:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#define GST_NAVIGATION_EVENT_HAS_TYPE(event,event_type) \
|
|
|
|
(gst_navigation_event_get_type (event) == GST_NAVIGATION_EVENT_ ## event_type)
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_navigation_event_get_type:
|
|
|
|
* @event: A #GstEvent to inspect.
|
|
|
|
*
|
|
|
|
* Inspect a #GstEvent and return the #GstNavigationEventType of the event, or
|
|
|
|
* #GST_NAVIGATION_EVENT_INVALID if the event is not a #GstNavigation event.
|
|
|
|
*/
|
|
|
|
GstNavigationEventType
|
|
|
|
gst_navigation_event_get_type (GstEvent * event)
|
|
|
|
{
|
|
|
|
const GstStructure *s;
|
|
|
|
const gchar *e_type;
|
|
|
|
|
|
|
|
if (event == NULL || GST_EVENT_TYPE (event) != GST_EVENT_NAVIGATION)
|
|
|
|
return GST_NAVIGATION_EVENT_INVALID;
|
|
|
|
|
|
|
|
s = gst_event_get_structure (event);
|
|
|
|
if (s == NULL || !gst_structure_has_name (s, GST_NAVIGATION_EVENT_NAME))
|
|
|
|
return GST_NAVIGATION_EVENT_INVALID;
|
|
|
|
|
|
|
|
e_type = gst_structure_get_string (s, "event");
|
|
|
|
if (e_type == NULL)
|
|
|
|
return GST_NAVIGATION_EVENT_INVALID;
|
|
|
|
|
|
|
|
if (g_str_equal (e_type, "mouse-button-press"))
|
|
|
|
return GST_NAVIGATION_EVENT_MOUSE_BUTTON_PRESS;
|
|
|
|
else if (g_str_equal (e_type, "mouse-button-release"))
|
|
|
|
return GST_NAVIGATION_EVENT_MOUSE_BUTTON_RELEASE;
|
|
|
|
else if (g_str_equal (e_type, "mouse-move"))
|
|
|
|
return GST_NAVIGATION_EVENT_MOUSE_MOVE;
|
|
|
|
else if (g_str_equal (e_type, "key-press"))
|
|
|
|
return GST_NAVIGATION_EVENT_KEY_PRESS;
|
|
|
|
else if (g_str_equal (e_type, "key-release"))
|
|
|
|
return GST_NAVIGATION_EVENT_KEY_RELEASE;
|
|
|
|
else if (g_str_equal (e_type, "command"))
|
|
|
|
return GST_NAVIGATION_EVENT_COMMAND;
|
|
|
|
|
|
|
|
return GST_NAVIGATION_EVENT_INVALID;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_navigation_event_parse_key_event:
|
|
|
|
* @event: A #GstEvent to inspect.
|
2017-06-01 20:01:03 +00:00
|
|
|
* @key: (out) (optional) (transfer none): A pointer to a location to receive
|
|
|
|
* the string identifying the key press. The returned string is owned by the
|
|
|
|
* event, and valid only until the event is unreffed.
|
2009-03-30 23:54:30 +00:00
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
gst_navigation_event_parse_key_event (GstEvent * event, const gchar ** key)
|
|
|
|
{
|
|
|
|
GstNavigationEventType e_type;
|
|
|
|
const GstStructure *s;
|
|
|
|
|
|
|
|
e_type = gst_navigation_event_get_type (event);
|
|
|
|
g_return_val_if_fail (e_type == GST_NAVIGATION_EVENT_KEY_PRESS ||
|
|
|
|
e_type == GST_NAVIGATION_EVENT_KEY_RELEASE, FALSE);
|
|
|
|
|
|
|
|
if (key) {
|
|
|
|
s = gst_event_get_structure (event);
|
|
|
|
*key = gst_structure_get_string (s, "key");
|
|
|
|
if (*key == NULL)
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_navigation_event_parse_mouse_button_event:
|
|
|
|
* @event: A #GstEvent to inspect.
|
2017-06-01 20:01:03 +00:00
|
|
|
* @button: (out) (optional): Pointer to a gint that will receive the button
|
|
|
|
* number associated with the event.
|
|
|
|
* @x: (out) (optional): Pointer to a gdouble to receive the x coordinate of the
|
|
|
|
* mouse button event.
|
|
|
|
* @y: (out) (optional): Pointer to a gdouble to receive the y coordinate of the
|
|
|
|
* mouse button event.
|
2017-01-23 19:36:11 +00:00
|
|
|
*
|
2009-03-30 23:54:30 +00:00
|
|
|
* Retrieve the details of either a #GstNavigation mouse button press event or
|
|
|
|
* a mouse button release event. Determine which type the event is using
|
|
|
|
* gst_navigation_event_get_type() to retrieve the #GstNavigationEventType.
|
|
|
|
*
|
2010-03-15 13:32:58 +00:00
|
|
|
* Returns: TRUE if the button number and both coordinates could be extracted,
|
|
|
|
* otherwise FALSE.
|
2009-03-30 23:54:30 +00:00
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
gst_navigation_event_parse_mouse_button_event (GstEvent * event, gint * button,
|
|
|
|
gdouble * x, gdouble * y)
|
|
|
|
{
|
|
|
|
GstNavigationEventType e_type;
|
|
|
|
const GstStructure *s;
|
2009-09-08 15:00:47 +00:00
|
|
|
gboolean ret = TRUE;
|
2009-03-30 23:54:30 +00:00
|
|
|
|
|
|
|
e_type = gst_navigation_event_get_type (event);
|
|
|
|
g_return_val_if_fail (e_type == GST_NAVIGATION_EVENT_MOUSE_BUTTON_PRESS ||
|
|
|
|
e_type == GST_NAVIGATION_EVENT_MOUSE_BUTTON_RELEASE, FALSE);
|
|
|
|
|
|
|
|
s = gst_event_get_structure (event);
|
|
|
|
if (x)
|
2009-09-08 15:00:47 +00:00
|
|
|
ret &= gst_structure_get_double (s, "pointer_x", x);
|
2009-03-30 23:54:30 +00:00
|
|
|
if (y)
|
2009-09-08 15:00:47 +00:00
|
|
|
ret &= gst_structure_get_double (s, "pointer_y", y);
|
2009-03-30 23:54:30 +00:00
|
|
|
if (button)
|
2009-09-08 15:00:47 +00:00
|
|
|
ret &= gst_structure_get_int (s, "button", button);
|
2009-03-30 23:54:30 +00:00
|
|
|
|
2009-09-08 15:00:47 +00:00
|
|
|
WARN_IF_FAIL (ret, "Couldn't extract details from mouse button event");
|
|
|
|
|
|
|
|
return ret;
|
2009-03-30 23:54:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_navigation_event_parse_mouse_move_event:
|
|
|
|
* @event: A #GstEvent to inspect.
|
2017-06-01 20:01:03 +00:00
|
|
|
* @x: (out) (optional): Pointer to a gdouble to receive the x coordinate of the
|
|
|
|
* mouse movement.
|
|
|
|
* @y: (out) (optional): Pointer to a gdouble to receive the y coordinate of the
|
|
|
|
* mouse movement.
|
2009-03-30 23:54:30 +00:00
|
|
|
*
|
|
|
|
* Inspect a #GstNavigation mouse movement event and extract the coordinates
|
|
|
|
* of the event.
|
|
|
|
*
|
2010-03-15 13:32:58 +00:00
|
|
|
* Returns: TRUE if both coordinates could be extracted, otherwise FALSE.
|
2009-03-30 23:54:30 +00:00
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
gst_navigation_event_parse_mouse_move_event (GstEvent * event, gdouble * x,
|
|
|
|
gdouble * y)
|
|
|
|
{
|
|
|
|
const GstStructure *s;
|
2009-09-08 15:00:47 +00:00
|
|
|
gboolean ret = TRUE;
|
2009-03-30 23:54:30 +00:00
|
|
|
|
|
|
|
g_return_val_if_fail (GST_NAVIGATION_EVENT_HAS_TYPE (event, MOUSE_MOVE),
|
|
|
|
FALSE);
|
|
|
|
|
|
|
|
s = gst_event_get_structure (event);
|
|
|
|
if (x)
|
2009-09-08 15:00:47 +00:00
|
|
|
ret &= gst_structure_get_double (s, "pointer_x", x);
|
2009-03-30 23:54:30 +00:00
|
|
|
if (y)
|
2009-09-08 15:00:47 +00:00
|
|
|
ret &= gst_structure_get_double (s, "pointer_y", y);
|
2009-03-30 23:54:30 +00:00
|
|
|
|
2009-09-08 15:00:47 +00:00
|
|
|
WARN_IF_FAIL (ret, "Couldn't extract positions from mouse move event");
|
|
|
|
|
|
|
|
return ret;
|
2009-03-30 23:54:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_navigation_event_parse_command:
|
|
|
|
* @event: A #GstEvent to inspect.
|
2017-06-01 20:01:03 +00:00
|
|
|
* @command: (out) (optional): Pointer to GstNavigationCommand to receive the
|
|
|
|
* type of the navigation event.
|
2009-03-30 23:54:30 +00:00
|
|
|
*
|
|
|
|
* Inspect a #GstNavigation command event and retrieve the enum value of the
|
|
|
|
* associated command.
|
|
|
|
*
|
2010-03-15 13:32:58 +00:00
|
|
|
* Returns: TRUE if the navigation command could be extracted, otherwise FALSE.
|
2009-03-30 23:54:30 +00:00
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
gst_navigation_event_parse_command (GstEvent * event,
|
|
|
|
GstNavigationCommand * command)
|
|
|
|
{
|
|
|
|
const GstStructure *s;
|
2009-09-08 15:00:47 +00:00
|
|
|
gboolean ret = TRUE;
|
|
|
|
|
2009-03-30 23:54:30 +00:00
|
|
|
g_return_val_if_fail (GST_NAVIGATION_EVENT_HAS_TYPE (event, COMMAND), FALSE);
|
|
|
|
|
|
|
|
if (command) {
|
|
|
|
s = gst_event_get_structure (event);
|
2009-09-08 15:00:47 +00:00
|
|
|
ret = gst_structure_get_uint (s, "command-code", (guint *) command);
|
|
|
|
WARN_IF_FAIL (ret, "Couldn't extract command code from command event");
|
2009-03-30 23:54:30 +00:00
|
|
|
}
|
|
|
|
|
2009-09-08 15:00:47 +00:00
|
|
|
return ret;
|
2009-03-30 23:54:30 +00:00
|
|
|
}
|