video: Add a new "event" navigation message type

This will be useful for elements that wish to post unhandled navigation
events on the bus to give the application a chance to do something with
it

https://bugzilla.gnome.org/show_bug.cgi?id=747245
This commit is contained in:
Edward Hervey 2015-04-02 16:09:13 +02:00 committed by Edward Hervey
parent b3db5883e1
commit 01e2a2152d
2 changed files with 61 additions and 1 deletions

View file

@ -495,6 +495,8 @@ gst_navigation_message_get_type (GstMessage * message)
return GST_NAVIGATION_MESSAGE_COMMANDS_CHANGED; return GST_NAVIGATION_MESSAGE_COMMANDS_CHANGED;
else if (g_str_equal (m_type, "angles-changed")) else if (g_str_equal (m_type, "angles-changed"))
return GST_NAVIGATION_MESSAGE_ANGLES_CHANGED; return GST_NAVIGATION_MESSAGE_ANGLES_CHANGED;
else if (g_str_equal (m_type, "event"))
return GST_NAVIGATION_MESSAGE_EVENT;
return GST_NAVIGATION_MESSAGE_INVALID; return GST_NAVIGATION_MESSAGE_INVALID;
} }
@ -553,6 +555,57 @@ gst_navigation_message_parse_mouse_over (GstMessage * message,
return TRUE; return TRUE;
} }
/**
* 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.
*/
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.
* @event: (transfer full): a pointer to a #GstEvent to receive the contained
* navigation event.
*
* 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.
*/
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;
}
/** /**
* gst_navigation_message_new_commands_changed: * gst_navigation_message_new_commands_changed:
* @src: A #GstObject to set as source of the new message. * @src: A #GstObject to set as source of the new message.

View file

@ -178,6 +178,8 @@ gboolean gst_navigation_query_parse_angles (GstQuery *query, guint
* @GST_NAVIGATION_MESSAGE_ANGLES_CHANGED: Sent when display angles in a multi-angle * @GST_NAVIGATION_MESSAGE_ANGLES_CHANGED: Sent when display angles in a multi-angle
* feature (such as a multiangle DVD) change - either angles have appeared or * feature (such as a multiangle DVD) change - either angles have appeared or
* disappeared. * disappeared.
* @GST_NAVIGATION_MESSAGE_EVENT: Sent when a navigation event was not handled
* by any element in the pipeline.
* *
* A set of notifications that may be received on the bus when navigation * A set of notifications that may be received on the bus when navigation
* related status changes. * related status changes.
@ -186,7 +188,8 @@ typedef enum {
GST_NAVIGATION_MESSAGE_INVALID, GST_NAVIGATION_MESSAGE_INVALID,
GST_NAVIGATION_MESSAGE_MOUSE_OVER, GST_NAVIGATION_MESSAGE_MOUSE_OVER,
GST_NAVIGATION_MESSAGE_COMMANDS_CHANGED, GST_NAVIGATION_MESSAGE_COMMANDS_CHANGED,
GST_NAVIGATION_MESSAGE_ANGLES_CHANGED GST_NAVIGATION_MESSAGE_ANGLES_CHANGED,
GST_NAVIGATION_MESSAGE_EVENT
} GstNavigationMessageType; } GstNavigationMessageType;
GstNavigationMessageType gst_navigation_message_get_type (GstMessage *message); GstNavigationMessageType gst_navigation_message_get_type (GstMessage *message);
@ -205,6 +208,10 @@ gboolean gst_navigation_message_parse_angles_changed (GstMessage *message
guint *cur_angle, guint *cur_angle,
guint *n_angles); guint *n_angles);
GstMessage * gst_navigation_message_new_event (GstObject *src,
GstEvent *event);
gboolean gst_navigation_message_parse_event (GstMessage *message,
GstEvent ** event);
/* event parsing functions */ /* event parsing functions */
/** /**
* GstNavigationEventType: * GstNavigationEventType: