default:
GST_DEBUG_OBJECT (dfbvideosink, "key press event %c !",
event.input.key_symbol);
- gst_navigation_send_key_event (GST_NAVIGATION (dfbvideosink),
- "key-press", "prout");
+ gst_dfbvideosink_navigation_send_event
+ (gst_navigation_event_new_key_press ("prout"));
}
} else if (event.input.type == DIET_BUTTONPRESS) {
gint x, y;
GST_DEBUG_OBJECT (dfbvideosink, "button %d pressed at %dx%d",
event.input.button, x, y);
- gst_navigation_send_mouse_event (GST_NAVIGATION (dfbvideosink),
- "mouse-button-press", event.input.button, x, y);
+ gst_dfbvideosink_navigation_send_event
+ (gst_navigation_event_new_mouse_button_press (event.input.button,
+ x, y));
} else if (event.input.type == DIET_BUTTONRELEASE) {
gint x, y;
GST_DEBUG_OBJECT (dfbvideosink, "button %d released at %dx%d",
event.input.button, x, y);
- gst_navigation_send_mouse_event (GST_NAVIGATION (dfbvideosink),
- "mouse-button-release", event.input.button, x, y);
+ gst_dfbvideosink_navigation_send_event
+ (gst_navigation_event_new_mouse_button_release
+ (event.input.button, x, y));
} else if (event.input.type == DIET_AXISMOTION) {
gint x, y;
dfbvideosink->layer->GetCursorPosition (dfbvideosink->layer, &x, &y);
- gst_navigation_send_mouse_event (GST_NAVIGATION (dfbvideosink),
- "mouse-move", 0, x, y);
+ gst_dfbvideosink_navigation_send_event
+ (gst_navigation_event_new_mouse_move (x, y));
} else {
GST_WARNING_OBJECT (dfbvideosink, "unhandled event type %d",
event.input.type);
static void
gst_dfbvideosink_navigation_send_event (GstNavigation * navigation,
- GstStructure * structure)
+ GstEvent * event)
{
GstDfbVideoSink *dfbvideosink = GST_DFBVIDEOSINK (navigation);
- GstEvent *event;
GstVideoRectangle dst = { 0, };
GstVideoRectangle src = { 0, };
GstVideoRectangle result;
dst.h = dfbvideosink->out_height;
gst_video_sink_center_rect (src, dst, &result, dfbvideosink->hw_scaling);
- event = gst_event_new_navigation (structure);
+ event = gst_event_make_writable (event);
/* Our coordinates can be wrong here if we centered the video */
/* Converting pointer coordinates to the non scaled geometry */
- if (gst_structure_get_double (structure, "pointer_x", &old_x)) {
+ if gst_navigation_event_get_coordinates
+ (event, &old_x, &old_y) {
x = old_x;
+ y = old_y;
if (x >= result.x && x <= (result.x + result.w)) {
x -= result.x;
} else {
x = 0;
}
- GST_DEBUG_OBJECT (dfbvideosink, "translated navigation event x "
- "coordinate from %f to %f", old_x, x);
- gst_structure_set (structure, "pointer_x", G_TYPE_DOUBLE, x, NULL);
- }
- if (gst_structure_get_double (structure, "pointer_y", &old_y)) {
- y = old_y;
-
if (y >= result.y && y <= (result.y + result.h)) {
y -= result.y;
y *= dfbvideosink->video_height;
} else {
y = 0;
}
+
+ GST_DEBUG_OBJECT (dfbvideosink, "translated navigation event x "
+ "coordinate from %f to %f", old_x, x);
GST_DEBUG_OBJECT (dfbvideosink, "translated navigation event y "
"coordinate from %fd to %fd", old_y, y);
- gst_structure_set (structure, "pointer_y", G_TYPE_DOUBLE, y, NULL);
- }
+ gst_navigation_event_set_coordinates (event, x, y);
+ }
pad = gst_pad_get_peer (GST_VIDEO_SINK_PAD (dfbvideosink));
- if (GST_IS_PAD (pad) && GST_IS_EVENT (event)) {
+ if (GST_IS_PAD (pad)) {
if (!gst_pad_send_event (pad, gst_event_ref (event))) {
/* If upstream didn't handle the event we'll post a message with it
* for the application in case it wants to do something with it */
static void
gst_dfbvideosink_navigation_init (GstNavigationInterface * iface)
{
- iface->send_event = gst_dfbvideosink_navigation_send_event;
+ iface->send_event_simple = gst_dfbvideosink_navigation_send_event;
}
static void
static void gst_handdetect_navigation_interface_init (GstNavigationInterface *
iface);
static void gst_handdetect_navigation_send_event (GstNavigation * navigation,
- GstStructure * structure);
+ GstEvent * event);
G_DEFINE_TYPE_WITH_CODE (GstHanddetect, gst_handdetect,
GST_TYPE_OPENCV_VIDEO_FILTER,
static void
gst_handdetect_navigation_interface_init (GstNavigationInterface * iface)
{
- iface->send_event = gst_handdetect_navigation_send_event;
+ iface->send_event_simple = gst_handdetect_navigation_send_event;
}
/* FIXME: this function used to parse the region of interests coordinates
*/
static void
gst_handdetect_navigation_send_event (GstNavigation * navigation,
- GstStructure * structure)
+ GstEvent * event)
{
GstHanddetect *filter = GST_HANDDETECT (navigation);
GstPad *peer;
if ((peer = gst_pad_get_peer (GST_BASE_TRANSFORM_CAST (filter)->sinkpad))) {
- GstEvent *event;
- event = gst_event_new_navigation (structure);
gst_pad_send_event (peer, event);
gst_object_unref (peer);
}
* !!! this will CHANGE in the future !!!
* !!! by adding gst_navigation_send_hand_detect_event() in navigation.c !!!
*/
- gst_navigation_send_mouse_event (GST_NAVIGATION (filter),
- "mouse-move",
- 0,
- (double) (filter->best_r->x + filter->best_r->width * 0.5),
- (double) (filter->best_r->y + filter->best_r->height * 0.5));
+ gst_handdetect_navigation_send_event (GST_NAVIGATION (filter),
+ gst_navigation_event_new_mouse_move (
+ (double) (filter->best_r->x + filter->best_r->width * 0.5),
+ (double) (filter->best_r->y + filter->best_r->height * 0.5)));
#endif
}
* !!! this will CHANGE in the future !!!
* !!! by adding gst_navigation_send_hand_detect_event() in navigation.c !!!
*/
- gst_navigation_send_mouse_event (GST_NAVIGATION (filter),
- "mouse-move",
- 0,
- (double) (filter->best_r->x + filter->best_r->width * 0.5),
- (double) (filter->best_r->y + filter->best_r->height * 0.5));
+ gst_handdetect_navigation_send_event (GST_NAVIGATION (filter),
+ gst_navigation_event_new_mouse_move (
+ (double) (filter->best_r->x + filter->best_r->width * 0.5),
+ (double) (filter->best_r->y + filter->best_r->height * 0.5)));
/* or use another way to send upstream navigation event for debug
*
static void
gst_vulkan_sink_navigation_send_event (GstNavigation * navigation,
- GstStructure * structure)
+ GstEvent * event)
{
GstVulkanSink *vk_sink = GST_VULKAN_SINK (navigation);
GstVideoRectangle display_rect;
- GstEvent *event = NULL;
+ gboolean handled;
gdouble x, y;
if (!vk_sink->swapper || !vk_sink->swapper->window) {
- gst_structure_free (structure);
+ gst_event_unref (event);
return;
}
+ event = gst_event_make_writable (event);
+
gst_vulkan_swapper_get_surface_rectangles (vk_sink->swapper, NULL, NULL,
&display_rect);
/* Converting pointer coordinates to the non scaled geometry */
if (display_rect.w != 0 && display_rect.h != 0
- && gst_structure_get_double (structure, "pointer_x", &x)
- && gst_structure_get_double (structure, "pointer_y", &y)) {
+ && gst_navigation_event_get_coordinates (event, &x, &y)) {
gdouble stream_x, stream_y;
_display_size_to_stream_size (vk_sink, &display_rect, x, y, &stream_x,
&stream_y);
-
- gst_structure_set (structure, "pointer_x", G_TYPE_DOUBLE,
- stream_x, "pointer_y", G_TYPE_DOUBLE, stream_y, NULL);
+ gst_navigation_event_set_coordinates (event, stream_x, stream_y);
}
- event = gst_event_new_navigation (structure);
- if (event) {
- gboolean handled;
-
- gst_event_ref (event);
- handled = gst_pad_push_event (GST_VIDEO_SINK_PAD (vk_sink), event);
+ gst_event_ref (event);
+ handled = gst_pad_push_event (GST_VIDEO_SINK_PAD (vk_sink), event);
- if (!handled)
- gst_element_post_message ((GstElement *) vk_sink,
- gst_navigation_message_new_event ((GstObject *) vk_sink, event));
+ if (!handled)
+ gst_element_post_message ((GstElement *) vk_sink,
+ gst_navigation_message_new_event ((GstObject *) vk_sink, event));
- gst_event_unref (event);
- }
+ gst_event_unref (event);
}
static void
gst_vulkan_sink_navigation_interface_init (GstNavigationInterface * iface)
{
- iface->send_event = gst_vulkan_sink_navigation_send_event;
+ iface->send_event_simple = gst_vulkan_sink_navigation_send_event;
}
static void
gst_vulkan_sink_key_event_cb (GstVulkanWindow * window, char *event_name, char
*key_string, GstVulkanSink * vk_sink)
{
+ GstEvent *event = NULL;
+
GST_DEBUG_OBJECT (vk_sink, "event %s key %s pressed", event_name, key_string);
- gst_navigation_send_key_event (GST_NAVIGATION (vk_sink),
- event_name, key_string);
+ if (0 == g_strcmp0 ("key-press", event_name))
+ event = gst_navigation_event_new_key_press (key_string);
+ else if (0 == g_strcmp0 ("key-release", event_name))
+ event = gst_navigation_event_new_key_release (key_string);
+
+ if (event)
+ gst_navigation_send_event_simple (GST_NAVIGATION (vk_sink), event);
}
static void
gst_vulkan_sink_mouse_event_cb (GstVulkanWindow * window, char *event_name,
int button, double posx, double posy, GstVulkanSink * vk_sink)
{
+ GstEvent *event = NULL;
+
GST_DEBUG_OBJECT (vk_sink, "event %s at %g, %g", event_name, posx, posy);
- gst_navigation_send_mouse_event (GST_NAVIGATION (vk_sink),
- event_name, button, posx, posy);
+ if (0 == g_strcmp0 ("mouse-button-press", event_name))
+ event = gst_navigation_event_new_mouse_button_press (button, posx, posy);
+ else if (0 == g_strcmp0 ("mouse-button-release", event_name))
+ event = gst_navigation_event_new_mouse_button_release (button, posx, posy);
+ else if (0 == g_strcmp0 ("mouse-move", event_name))
+ event = gst_navigation_event_new_mouse_move (posx, posy);
+
+ if (event)
+ gst_navigation_send_event_simple (GST_NAVIGATION (vk_sink), event);
}
GstRfbSrc *src = GST_RFB_SRC (bsrc);
gdouble x, y;
gint button;
- const GstStructure *structure;
- const gchar *event_type;
- gboolean key_event, key_press;
-
- key_event = FALSE;
+ GstNavigationEventType event_type;
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_NAVIGATION:
if (src->view_only)
break;
- structure = gst_event_get_structure (event);
- event_type = gst_structure_get_string (structure, "event");
-
- if (strcmp (event_type, "key-press") == 0) {
- key_event = key_press = TRUE;
- } else if (strcmp (event_type, "key-release") == 0) {
- key_event = TRUE;
- key_press = FALSE;
- }
-
- if (key_event) {
+ event_type = gst_navigation_event_get_type (event);
+ switch (event_type) {
#ifdef HAVE_X11
- const gchar *key;
- KeySym key_sym;
-
- key = gst_structure_get_string (structure, "key");
- key_sym = XStringToKeysym (key);
-
- if (key_sym != NoSymbol)
- rfb_decoder_send_key_event (src->decoder, key_sym, key_press);
+ case GST_NAVIGATION_EVENT_KEY_PRESS:
+ case GST_NAVIGATION_EVENT_KEY_RELEASE:{
+ const gchar *key;
+ KeySym key_sym;
+
+ gst_navigation_event_parse_key_event (event, &key);
+ key_sym = XStringToKeysym (key);
+
+ if (key_sym != NoSymbol)
+ rfb_decoder_send_key_event (src->decoder, key_sym,
+ event_type == GST_NAVIGATION_EVENT_KEY_PRESS);
+ break;
+ }
#endif
- break;
- }
-
- gst_structure_get_double (structure, "pointer_x", &x);
- gst_structure_get_double (structure, "pointer_y", &y);
- gst_structure_get_int (structure, "button", &button);
-
- /* we need to take care of the offset's */
- x += src->decoder->offset_x;
- y += src->decoder->offset_y;
-
- if (strcmp (event_type, "mouse-move") == 0) {
- GST_LOG_OBJECT (src, "sending mouse-move event "
- "button_mask=%d, x=%d, y=%d", src->button_mask, (gint) x, (gint) y);
- rfb_decoder_send_pointer_event (src->decoder, src->button_mask,
- (gint) x, (gint) y);
- } else if (strcmp (event_type, "mouse-button-release") == 0) {
- src->button_mask &= ~(1 << (button - 1));
- GST_LOG_OBJECT (src, "sending mouse-button-release event "
- "button_mask=%d, x=%d, y=%d", src->button_mask, (gint) x, (gint) y);
- rfb_decoder_send_pointer_event (src->decoder, src->button_mask,
- (gint) x, (gint) y);
- } else if (strcmp (event_type, "mouse-button-press") == 0) {
- src->button_mask |= (1 << (button - 1));
- GST_LOG_OBJECT (src, "sending mouse-button-press event "
- "button_mask=%d, x=%d, y=%d", src->button_mask, (gint) x, (gint) y);
- rfb_decoder_send_pointer_event (src->decoder, src->button_mask,
- (gint) x, (gint) y);
+ case GST_NAVIGATION_EVENT_MOUSE_BUTTON_PRESS:{
+ gst_navigation_event_parse_mouse_button_event (event,
+ &button, &x, &y);
+ x += src->decoder->offset_x;
+ y += src->decoder->offset_y;
+ src->button_mask |= (1 << (button - 1));
+ GST_LOG_OBJECT (src, "sending mouse-button-press event "
+ "button_mask=%d, x=%d, y=%d",
+ src->button_mask, (gint) x, (gint) y);
+ rfb_decoder_send_pointer_event (src->decoder, src->button_mask,
+ (gint) x, (gint) y);
+ break;
+ }
+ case GST_NAVIGATION_EVENT_MOUSE_BUTTON_RELEASE:{
+ gst_navigation_event_parse_mouse_button_event (event,
+ &button, &x, &y);
+ x += src->decoder->offset_x;
+ y += src->decoder->offset_y;
+ src->button_mask &= ~(1 << (button - 1));
+ GST_LOG_OBJECT (src, "sending mouse-button-release event "
+ "button_mask=%d, x=%d, y=%d",
+ src->button_mask, (gint) x, (gint) y);
+ rfb_decoder_send_pointer_event (src->decoder, src->button_mask,
+ (gint) x, (gint) y);
+ break;
+ }
+ case GST_NAVIGATION_EVENT_MOUSE_MOVE:{
+ gst_navigation_event_parse_mouse_move_event (event, &x, &y);
+ x += src->decoder->offset_x;
+ y += src->decoder->offset_y;
+ GST_LOG_OBJECT (src, "sending mouse-move event "
+ "button_mask=%d, x=%d, y=%d",
+ src->button_mask, (gint) x, (gint) y);
+ rfb_decoder_send_pointer_event (src->decoder, src->button_mask,
+ (gint) x, (gint) y);
+ break;
+ }
+ default:
+ break;
}
break;
default:
gst_d3d11_video_sink_key_event (GstD3D11Window * window, const gchar * event,
const gchar * key, GstD3D11VideoSink * self)
{
+ GstEvent *key_event = NULL;
+
if (self->enable_navigation_events) {
GST_LOG_OBJECT (self, "send key event %s, key %s", event, key);
- gst_navigation_send_key_event (GST_NAVIGATION (self), event, key);
+ if (0 == g_strcmp0 ("key-press", event))
+ key_event = gst_navigation_event_new_key_press (key);
+ else if (0 == g_strcmp0 ("key-release", event))
+ key_event = gst_navigation_event_new_key_release (key);
+
+ if (event)
+ gst_navigation_send_event_simple (GST_NAVIGATION (self), key_event);
}
}
gst_d3d11_video_mouse_key_event (GstD3D11Window * window, const gchar * event,
gint button, gdouble x, gdouble y, GstD3D11VideoSink * self)
{
+ GstEvent *mouse_event = NULL;
+
if (self->enable_navigation_events) {
GST_LOG_OBJECT (self,
"send mouse event %s, button %d (%.1f, %.1f)", event, button, x, y);
- gst_navigation_send_mouse_event (GST_NAVIGATION (self), event, button, x,
- y);
+ if (0 == g_strcmp0 ("mouse-button-press", event))
+ mouse_event = gst_navigation_event_new_mouse_button_press (button, x, y);
+ else if (0 == g_strcmp0 ("mouse-button-release", event))
+ mouse_event = gst_navigation_event_new_mouse_button_release (button, x, y);
+ else if (0 == g_strcmp0 ("mouse-move", event))
+ mouse_event = gst_navigation_event_new_mouse_move (x, y);
+
+ if (event)
+ gst_navigation_send_event_simple (GST_NAVIGATION (self), mouse_event);
}
}
/* Navigation interface */
static void
gst_d3d11_video_sink_navigation_send_event (GstNavigation * navigation,
- GstStructure * structure)
+ GstEvent * event)
{
GstD3D11VideoSink *self = GST_D3D11_VIDEO_SINK (navigation);
- GstEvent *event = gst_event_new_navigation (structure);
/* TODO: add support for translating native coordinate and video coordinate
* when force-aspect-ratio is set */
static void
gst_d3d11_video_sink_navigation_init (GstNavigationInterface * iface)
{
- iface->send_event = gst_d3d11_video_sink_navigation_send_event;
+ iface->send_event_simple = gst_d3d11_video_sink_navigation_send_event;
}
static gboolean
gchar *utfrep = g_utf16_to_utf8 (wcrep, 128, NULL, NULL, NULL);
if (utfrep) {
if (message == WM_KEYDOWN)
- gst_navigation_send_key_event (GST_NAVIGATION (sink), "key-press",
- utfrep);
+ gst_navigation_send_event_simple (GST_NAVIGATION (sink),
+ gst_navigation_event_new_key_press (utfrep));
else if (message == WM_KEYUP)
- gst_navigation_send_key_event (GST_NAVIGATION (sink),
- "key-release", utfrep);
+ gst_navigation_send_event_simple (GST_NAVIGATION (sink),
+ gst_navigation_event_new_key_release (utfrep));
g_free (utfrep);
}
}
if (sink->enable_navigation_events
&& d3d_get_render_coordinates (sink, LOWORD (lParam), HIWORD (lParam),
&x, &y)) {
- gint button;
- const gchar *action = NULL;
switch (message) {
case WM_MOUSEMOVE:
- button = 0;
- action = "mouse-move";
+ gst_navigation_send_event_simple (GST_NAVIGATION (sink),
+ gst_navigation_event_new_mouse_move (x, y));
break;
case WM_LBUTTONDOWN:
- button = 1;
- action = "mouse-button-press";
+ gst_navigation_send_event_simple (GST_NAVIGATION (sink),
+ gst_navigation_event_new_mouse_button_press (1, x, y));
break;
case WM_LBUTTONUP:
- button = 1;
- action = "mouse-button-release";
+ gst_navigation_send_event_simple (GST_NAVIGATION (sink),
+ gst_navigation_event_new_mouse_button_release (1, x, y));
break;
case WM_RBUTTONDOWN:
- button = 2;
- action = "mouse-button-press";
+ gst_navigation_send_event_simple (GST_NAVIGATION (sink),
+ gst_navigation_event_new_mouse_button_press (2, x, y));
break;
case WM_RBUTTONUP:
- button = 2;
- action = "mouse-button-release";
+ gst_navigation_send_event_simple (GST_NAVIGATION (sink),
+ gst_navigation_event_new_mouse_button_release (2, x, y));
break;
case WM_MBUTTONDOWN:
- button = 3;
- action = "mouse-button-press";
+ gst_navigation_send_event_simple (GST_NAVIGATION (sink),
+ gst_navigation_event_new_mouse_button_press (3, x, y));
break;
case WM_MBUTTONUP:
- button = 3;
- action = "mouse-button-release";
+ gst_navigation_send_event_simple (GST_NAVIGATION (sink),
+ gst_navigation_event_new_mouse_button_release (3, x, y));
break;
default:
break;
}
- if (action) {
- /* GST_DEBUG_OBJECT(sink, "%s: %lfx%lf", action, x, y); */
- gst_navigation_send_mouse_event (GST_NAVIGATION (sink), action,
- button, x, y);
- }
}
break;
}
static void gst_d3dvideosink_navigation_interface_init (GstNavigationInterface *
iface);
static void gst_d3dvideosink_navigation_send_event (GstNavigation * navigation,
- GstStructure * structure);
+ GstEvent * event);
/* GObject */
static void gst_d3dvideosink_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec);
static void
gst_d3dvideosink_navigation_interface_init (GstNavigationInterface * iface)
{
- iface->send_event = gst_d3dvideosink_navigation_send_event;
+ iface->send_event_simple = gst_d3dvideosink_navigation_send_event;
}
/* Video Render Code */
static void
gst_d3dvideosink_navigation_send_event (GstNavigation * navigation,
- GstStructure * structure)
+ GstEvent * event)
{
GstD3DVideoSink *sink = GST_D3DVIDEOSINK (navigation);
- GstEvent *e;
-
- if ((e = gst_event_new_navigation (structure))) {
- GstPad *pad;
- if ((pad = gst_pad_get_peer (GST_VIDEO_SINK_PAD (sink)))) {
- if (!gst_pad_send_event (pad, gst_event_ref (e))) {
- /* If upstream didn't handle the event we'll post a message with it
- * for the application in case it wants to do something with it */
- gst_element_post_message (GST_ELEMENT_CAST (sink),
- gst_navigation_message_new_event (GST_OBJECT_CAST (sink), e));
- }
- gst_event_unref (e);
- gst_object_unref (pad);
+
+ GstPad *pad;
+ if ((pad = gst_pad_get_peer (GST_VIDEO_SINK_PAD (sink)))) {
+ if (!gst_pad_send_event (pad, gst_event_ref (event))) {
+ /* If upstream didn't handle the event we'll post a message with it
+ * for the application in case it wants to do something with it */
+ gst_element_post_message (GST_ELEMENT_CAST (sink),
+ gst_navigation_message_new_event (GST_OBJECT_CAST (sink), event));
}
+ gst_object_unref (pad);
}
}
static void
gst_dshowvideosink_navigation_send_event (GstNavigation * navigation,
- GstStructure * structure)
+ GstEvent * event)
{
GstDshowVideoSink *sink = GST_DSHOWVIDEOSINK (navigation);
- GstEvent *event = NULL;
GstPad *pad = NULL;
- event = gst_event_new_navigation (structure);
-
/* FXIME: handle aspect ratio. */
pad = gst_pad_get_peer (GST_VIDEO_SINK_PAD (sink));
gst_dshowvideosink_navigation_interface_init (GstNavigationInterface * iface)
{
/* FIXME: navigation interface partially implemented.
- * Need to call gst_navigation_send_mouse_event and
- * gst_navigation_send_key_event like in directdrawsink.
+ * Need to call gst_navigation_send_event_simple and like in directdrawsink.
*/
- iface->send_event = gst_dshowvideosink_navigation_send_event;
+ iface->send_event_simple = gst_dshowvideosink_navigation_send_event;
}
static void
{
GstVaVpp *self = GST_VA_VPP (trans);
GstVaBaseTransform *btrans = GST_VA_BASE_TRANSFORM (trans);
- GstStructure *structure;
const GstVideoInfo *in_info = &btrans->in_info, *out_info = &btrans->out_info;
gdouble new_x = 0, new_y = 0, x = 0, y = 0, w_factor = 1, h_factor = 1;
gboolean ret;
|| gst_va_filter_get_orientation (btrans->filter) !=
GST_VIDEO_ORIENTATION_IDENTITY) {
- event =
- GST_EVENT (gst_mini_object_make_writable (GST_MINI_OBJECT (event)));
+ event = gst_event_make_writable (event);
- structure = (GstStructure *) gst_event_get_structure (event);
- if (!gst_structure_get_double (structure, "pointer_x", &x)
- || !gst_structure_get_double (structure, "pointer_y", &y))
+ if (!gst_navigation_event_get_coordinates (event, &x, &y))
break;
/* video-direction compensation */
/* crop compensation is done by videocrop */
GST_TRACE_OBJECT (self, "from %fx%f to %fx%f", x, y, new_x, new_y);
- gst_structure_set (structure, "pointer_x", G_TYPE_DOUBLE, new_x,
- "pointer_y", G_TYPE_DOUBLE, new_y, NULL);
+ gst_navigation_event_set_coordinates (event, new_x, new_y);
}
break;
default:
#include <sys/types.h>
#include <sys/socket.h>
#include <gst/check/gstcheck.h>
+#include <gst/video/navigation.h>
#include <string.h>
#ifndef HAVE_PIPE2
{
test_data *td = user_data;
navigation_master_data *d = td->md;
- const GstStructure *s;
- const gchar *string, *key;
+ GstEvent *e;
+ const gchar *key;
double x, y;
if (GST_IS_EVENT (info->data)) {
if (GST_EVENT_TYPE (info->data) == GST_EVENT_NAVIGATION) {
- s = gst_event_get_structure (info->data);
- FAIL_UNLESS (s);
+ e = GST_EVENT (info->data);
- /* mouse-move */
- string = gst_structure_get_string (s, "event");
- if (string && !strcmp (string, "mouse-move")) {
- if (gst_structure_get_double (s, "pointer_x", &x) && x == 4.7) {
- if (gst_structure_get_double (s, "pointer_y", &y) && y == 0.1) {
+ switch (gst_navigation_event_get_type (e)) {
+ case GST_NAVIGATION_EVENT_MOUSE_MOVE:
+ gst_navigation_event_parse_mouse_move_event (e, &x, &y);
+ if (x == 4.7 && y == 0.1)
d->navigation_received[TEST_NAV_MOUSE_MOVE] = TRUE;
- }
- }
- }
+ break;
- /* key-press */
- string = gst_structure_get_string (s, "event");
- if (string && !strcmp (string, "key-press")) {
- key = gst_structure_get_string (s, "key");
- if (key && !strcmp (key, "Left")) {
- d->navigation_received[TEST_NAV_KEY_PRESS] = TRUE;
- }
+ case GST_NAVIGATION_EVENT_KEY_PRESS:
+ gst_navigation_event_parse_key_event (e, &key);
+ if (!strcmp (key, "Left"))
+ d->navigation_received[TEST_NAV_KEY_PRESS] = TRUE;
+ break;
+
+ default:
+ break;
}
/* drop at this point to imply successful handling; the upstream filesrc
navigation_slave_data *d = td->sd;
GstElement *sink;
GstPad *pad, *peer;
- GstStructure *s;
GstEvent *e = NULL;
sink = g_value_get_object (v);
switch (d->step) {
case TEST_NAV_MOUSE_MOVE:
- s = gst_structure_new ("application/x-gst-navigation", "event",
- G_TYPE_STRING, "mouse-move", "button", G_TYPE_INT, 0, "pointer_x",
- G_TYPE_DOUBLE, 4.7, "pointer_y", G_TYPE_DOUBLE, 0.1, NULL);
- e = gst_event_new_navigation (s);
+ e = gst_navigation_event_new_mouse_move (4.7, 0.1);
break;
case TEST_NAV_KEY_PRESS:
- s = gst_structure_new ("application/x-gst-navigation", "event",
- G_TYPE_STRING, "key-press", "key", G_TYPE_STRING, "Left", NULL);
- e = gst_event_new_navigation (s);
+ e = gst_navigation_event_new_key_press ("Left");
break;
}
}
static void
-gst_glimage_sink_navigation_send_event (GstNavigation * navigation, GstStructure
- * structure)
+gst_glimage_sink_navigation_send_event (GstNavigation * navigation,
+ GstEvent * event)
{
GstGLImageSink *sink = GST_GLIMAGE_SINK (navigation);
gboolean handled = FALSE;
- GstEvent *event = NULL;
GstGLWindow *window;
guint width, height;
gdouble x, y;
if (!sink->context) {
- gst_structure_free (structure);
+ gst_event_unref (event);
return;
}
+ event = gst_event_make_writable (event);
+
window = gst_gl_context_get_window (sink->context);
g_return_if_fail (GST_IS_GL_WINDOW (window));
gst_gl_window_get_surface_dimensions (window, &width, &height);
/* Converting pointer coordinates to the non scaled geometry */
- if (width != 0 && gst_structure_get_double (structure, "pointer_x", &x)
- && height != 0 && gst_structure_get_double (structure, "pointer_y", &y)) {
+ if (width != 0 && height != 0 &&
+ gst_navigation_event_get_coordinates (event, &x, &y)) {
gdouble stream_x, stream_y;
_display_size_to_stream_size (sink, x, y, &stream_x, &stream_y);
- gst_structure_set (structure, "pointer_x", G_TYPE_DOUBLE,
- stream_x, "pointer_y", G_TYPE_DOUBLE, stream_y, NULL);
+ gst_navigation_event_set_coordinates (event, stream_x, stream_y);
}
/* Converting pointer scroll coordinates to the non scaled geometry */
- if (width != 0 && gst_structure_get_double (structure, "delta_pointer_x", &x)
- && height != 0
- && gst_structure_get_double (structure, "delta_pointer_y", &y)) {
- gdouble stream_x, stream_y;
+ if (width != 0 && height != 0 && gst_navigation_event_get_type (event)
+ == GST_NAVIGATION_EVENT_MOUSE_SCROLL) {
+ gdouble dx, dy, stream_dx, stream_dy;
- _display_scroll_value_to_stream_scroll_value (sink, x, y, &stream_x,
- &stream_y);
+ gst_navigation_event_parse_mouse_scroll_event (event, &x, &y, &dx, &dy);
+ _display_scroll_value_to_stream_scroll_value (sink, dx, dy, &stream_dx,
+ &stream_dy);
- gst_structure_set (structure, "delta_pointer_x", G_TYPE_DOUBLE,
- stream_x, "delta_pointer_y", G_TYPE_DOUBLE, stream_y, NULL);
+ gst_event_replace (&event,
+ gst_navigation_event_new_mouse_scroll (x, y, stream_dx, stream_dy));
}
- event = gst_event_new_navigation (structure);
- if (event) {
- gst_event_ref (event);
- handled = gst_pad_push_event (GST_VIDEO_SINK_PAD (sink), event);
+ gst_event_ref (event);
+ handled = gst_pad_push_event (GST_VIDEO_SINK_PAD (sink), event);
- if (!handled)
- gst_element_post_message ((GstElement *) sink,
- gst_navigation_message_new_event ((GstObject *) sink, event));
+ if (!handled)
+ gst_element_post_message ((GstElement *) sink,
+ gst_navigation_message_new_event ((GstObject *) sink, event));
- gst_event_unref (event);
- }
+ gst_event_unref (event);
gst_object_unref (window);
}
static void
gst_glimage_sink_navigation_interface_init (GstNavigationInterface * iface)
{
- iface->send_event = gst_glimage_sink_navigation_send_event;
+ iface->send_event_simple = gst_glimage_sink_navigation_send_event;
}
#define gst_glimage_sink_parent_class parent_class
gst_glimage_sink_key_event_cb (GstGLWindow * window, char *event_name, char
*key_string, GstGLImageSink * gl_sink)
{
+ GstEvent *event = NULL;
+
GST_DEBUG_OBJECT (gl_sink, "event %s key %s pressed", event_name, key_string);
- gst_navigation_send_key_event (GST_NAVIGATION (gl_sink),
- event_name, key_string);
+ if (0 == g_strcmp0 ("key-press", event_name))
+ event = gst_navigation_event_new_key_press (key_string);
+ else if (0 == g_strcmp0 ("key-release", event_name))
+ event = gst_navigation_event_new_key_release (key_string);
+
+ if (event)
+ gst_navigation_send_event_simple (GST_NAVIGATION (gl_sink), event);
}
static void
gst_glimage_sink_mouse_event_cb (GstGLWindow * window, char *event_name,
int button, double posx, double posy, GstGLImageSink * gl_sink)
{
+ GstEvent *event = NULL;
+
GST_DEBUG_OBJECT (gl_sink, "event %s at %g, %g", event_name, posx, posy);
- gst_navigation_send_mouse_event (GST_NAVIGATION (gl_sink),
- event_name, button, posx, posy);
+ if (0 == g_strcmp0 ("mouse-button-press", event_name))
+ event = gst_navigation_event_new_mouse_button_press (button, posx, posy);
+ else if (0 == g_strcmp0 ("mouse-button-release", event_name))
+ event = gst_navigation_event_new_mouse_button_release (button, posx, posy);
+ else if (0 == g_strcmp0 ("mouse-move", event_name))
+ event = gst_navigation_event_new_mouse_move (posx, posy);
+
+ if (event)
+ gst_navigation_send_event_simple (GST_NAVIGATION (gl_sink), event);
}
GstGLImageSink * gl_sink)
{
GST_DEBUG_OBJECT (gl_sink, "event scroll at %g, %g", posx, posy);
- gst_navigation_send_mouse_scroll_event (GST_NAVIGATION (gl_sink),
- posx, posy, delta_x, delta_y);
+ gst_navigation_send_event_simple (GST_NAVIGATION (gl_sink),
+ gst_navigation_event_new_mouse_scroll (posx, posy, delta_x, delta_y));
}
static void
}
static void
-gst_gl_sink_bin_navigation_send_event (GstNavigation * navigation, GstStructure
- * structure)
+gst_gl_sink_bin_navigation_send_event (GstNavigation * navigation,
+ GstEvent * event)
{
GstGLSinkBin *self = GST_GL_SINK_BIN (navigation);
GstElement *nav =
gst_bin_get_by_interface (GST_BIN (self), GST_TYPE_NAVIGATION);
if (nav) {
- gst_navigation_send_event (GST_NAVIGATION (nav), structure);
- structure = NULL;
+ gst_navigation_send_event_simple (GST_NAVIGATION (nav), event);
gst_object_unref (nav);
} else {
- GstEvent *event = gst_event_new_navigation (structure);
- structure = NULL;
gst_element_send_event (GST_ELEMENT (self), event);
}
}
gpointer g_iface_data)
{
GstNavigationInterface *iface = (GstNavigationInterface *) g_iface;
- iface->send_event = gst_gl_sink_bin_navigation_send_event;
+ iface->send_event_simple = gst_gl_sink_bin_navigation_send_event;
}
static void
gst_gl_transformation_src_event (GstBaseTransform * trans, GstEvent * event)
{
GstGLTransformation *transformation = GST_GL_TRANSFORMATION (trans);
- GstStructure *structure;
gboolean ret;
GST_DEBUG_OBJECT (trans, "handling %s event", GST_EVENT_TYPE_NAME (event));
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_NAVIGATION:{
gdouble x, y;
- event =
- GST_EVENT (gst_mini_object_make_writable (GST_MINI_OBJECT (event)));
+ event = gst_event_make_writable (event);
- structure = (GstStructure *) gst_event_get_structure (event);
- if (gst_structure_get_double (structure, "pointer_x", &x) &&
- gst_structure_get_double (structure, "pointer_y", &y)) {
+ if (gst_navigation_event_get_coordinates (event, &x, &y)) {
gdouble new_x, new_y;
if (!_screen_coord_to_model_coord (transformation, x, y, &new_x,
return TRUE;
}
- gst_structure_set (structure, "pointer_x", G_TYPE_DOUBLE, new_x,
- "pointer_y", G_TYPE_DOUBLE, new_y, NULL);
+ gst_navigation_event_set_coordinates (event, x, y);
}
break;
}
static void
gst_play_bin_navigation_send_event (GstNavigation * navigation,
- GstStructure * structure)
+ GstEvent * event)
{
GstPlayBin *playbin = GST_PLAY_BIN (navigation);
- gst_navigation_send_event (GST_NAVIGATION (playbin->playsink), structure);
+ gst_navigation_send_event_simple (GST_NAVIGATION (playbin->playsink), event);
}
static void
{
GstNavigationInterface *iface = (GstNavigationInterface *) g_iface;
- iface->send_event = gst_play_bin_navigation_send_event;
+ iface->send_event_simple = gst_play_bin_navigation_send_event;
}
static const GList *
static void
gst_play_bin3_navigation_send_event (GstNavigation * navigation,
- GstStructure * structure)
+ GstEvent * event)
{
GstPlayBin3 *playbin = GST_PLAY_BIN3 (navigation);
- gst_navigation_send_event (GST_NAVIGATION (playbin->playsink), structure);
+ gst_navigation_send_event_simple (GST_NAVIGATION (playbin->playsink), event);
}
static void
{
GstNavigationInterface *iface = (GstNavigationInterface *) g_iface;
- iface->send_event = gst_play_bin3_navigation_send_event;
+ iface->send_event_simple = gst_play_bin3_navigation_send_event;
}
static const GList *
static void
gst_play_sink_navigation_send_event (GstNavigation * navigation,
- GstStructure * structure)
+ GstEvent * event)
{
GstPlaySink *playsink = GST_PLAY_SINK (navigation);
GstBin *bin = NULL;
GstElement *nav = gst_bin_get_by_interface (bin, GST_TYPE_NAVIGATION);
if (nav) {
- gst_navigation_send_event (GST_NAVIGATION (nav), structure);
- structure = NULL;
+ gst_navigation_send_event_simple (GST_NAVIGATION (nav), event);
gst_object_unref (nav);
} else {
- GstEvent *event = gst_event_new_navigation (structure);
- structure = NULL;
gst_element_send_event (GST_ELEMENT (bin), event);
}
gst_object_unref (bin);
}
-
- if (structure)
- gst_structure_free (structure);
}
static void
{
GstNavigationInterface *iface = (GstNavigationInterface *) g_iface;
- iface->send_event = gst_play_sink_navigation_send_event;
+ iface->send_event_simple = gst_play_sink_navigation_send_event;
}
static const GList *
GstVideoScale *videoscale = GST_VIDEO_SCALE_CAST (trans);
GstVideoFilter *filter = GST_VIDEO_FILTER_CAST (trans);
gboolean ret;
- gdouble a;
- GstStructure *structure;
+ gdouble x, y;
GST_DEBUG_OBJECT (videoscale, "handling %s event",
GST_EVENT_TYPE_NAME (event));
case GST_EVENT_NAVIGATION:
if (filter->in_info.width != filter->out_info.width ||
filter->in_info.height != filter->out_info.height) {
- event =
- GST_EVENT (gst_mini_object_make_writable (GST_MINI_OBJECT (event)));
+ event = gst_event_make_writable (event);
- structure = (GstStructure *) gst_event_get_structure (event);
- if (gst_structure_get_double (structure, "pointer_x", &a)) {
- gst_structure_set (structure, "pointer_x", G_TYPE_DOUBLE,
- a * filter->in_info.width / filter->out_info.width, NULL);
- }
- if (gst_structure_get_double (structure, "pointer_y", &a)) {
- gst_structure_set (structure, "pointer_y", G_TYPE_DOUBLE,
- a * filter->in_info.height / filter->out_info.height, NULL);
+ if (gst_navigation_event_get_coordinates (event, &x, &y)) {
+ gst_navigation_event_set_coordinates (event,
+ x * filter->in_info.width / filter->out_info.width,
+ y * filter->in_info.height / filter->out_info.height);
}
}
break;
GST_DEBUG ("ximagesink pointer moved over window at %d,%d",
pointer_x, pointer_y);
- gst_navigation_send_mouse_event (GST_NAVIGATION (ximagesink),
- "mouse-move", 0, pointer_x, pointer_y);
+ gst_navigation_send_event_simple (GST_NAVIGATION (ximagesink),
+ gst_navigation_event_new_mouse_move (pointer_x, pointer_y));
g_mutex_lock (&ximagesink->flow_lock);
g_mutex_lock (&ximagesink->x_lock);
events for interactivity/navigation */
GST_DEBUG ("ximagesink button %d pressed over window at %d,%d",
e.xbutton.button, e.xbutton.x, e.xbutton.x);
- gst_navigation_send_mouse_event (GST_NAVIGATION (ximagesink),
- "mouse-button-press", e.xbutton.button, e.xbutton.x, e.xbutton.y);
+ gst_navigation_send_event_simple (GST_NAVIGATION (ximagesink),
+ gst_navigation_event_new_mouse_button_press (e.xbutton.button,
+ e.xbutton.x, e.xbutton.y));
break;
case ButtonRelease:
GST_DEBUG ("ximagesink button %d release over window at %d,%d",
e.xbutton.button, e.xbutton.x, e.xbutton.x);
- gst_navigation_send_mouse_event (GST_NAVIGATION (ximagesink),
- "mouse-button-release", e.xbutton.button, e.xbutton.x, e.xbutton.y);
+ gst_navigation_send_event_simple (GST_NAVIGATION (ximagesink),
+ gst_navigation_event_new_mouse_button_release (e.xbutton.button,
+ e.xbutton.x, e.xbutton.y));
break;
case KeyPress:
case KeyRelease:
GST_DEBUG_OBJECT (ximagesink,
"key %d pressed over window at %d,%d (%s)",
e.xkey.keycode, e.xkey.x, e.xkey.y, key_str);
- gst_navigation_send_key_event (GST_NAVIGATION (ximagesink),
- e.type == KeyPress ? "key-press" : "key-release", key_str);
+ gst_navigation_send_event_simple (GST_NAVIGATION (ximagesink),
+ (e.type == KeyPress) ?
+ gst_navigation_event_new_key_press (key_str) :
+ gst_navigation_event_new_key_release (key_str));
break;
default:
GST_DEBUG_OBJECT (ximagesink, "ximagesink unhandled X event (%d)",
/* Interfaces stuff */
static void
gst_x_image_sink_navigation_send_event (GstNavigation * navigation,
- GstStructure * structure)
+ GstEvent * event)
{
GstXImageSink *ximagesink = GST_X_IMAGE_SINK (navigation);
- GstEvent *event = NULL;
gint x_offset, y_offset;
gdouble x, y;
gboolean handled = FALSE;
if (!ximagesink->xwindow) {
g_mutex_unlock (&ximagesink->flow_lock);
- gst_structure_free (structure);
+ gst_event_unref (event);
return;
}
+ event = gst_event_make_writable (event);
+
x_offset = ximagesink->xwindow->width - GST_VIDEO_SINK_WIDTH (ximagesink);
y_offset = ximagesink->xwindow->height - GST_VIDEO_SINK_HEIGHT (ximagesink);
g_mutex_unlock (&ximagesink->flow_lock);
- if (x_offset > 0 && gst_structure_get_double (structure, "pointer_x", &x)) {
+ if (gst_navigation_event_get_coordinates (event, &x, &y)) {
x -= x_offset / 2;
- gst_structure_set (structure, "pointer_x", G_TYPE_DOUBLE, x, NULL);
- }
- if (y_offset > 0 && gst_structure_get_double (structure, "pointer_y", &y)) {
y -= y_offset / 2;
- gst_structure_set (structure, "pointer_y", G_TYPE_DOUBLE, y, NULL);
+ gst_navigation_event_set_coordinates (event, x, y);
}
- event = gst_event_new_navigation (structure);
- if (event) {
- gst_event_ref (event);
- handled = gst_pad_push_event (GST_VIDEO_SINK_PAD (ximagesink), event);
+ gst_event_ref (event);
+ handled = gst_pad_push_event (GST_VIDEO_SINK_PAD (ximagesink), event);
- if (!handled)
- gst_element_post_message (GST_ELEMENT_CAST (ximagesink),
- gst_navigation_message_new_event (GST_OBJECT_CAST (ximagesink),
- event));
+ if (!handled)
+ gst_element_post_message (GST_ELEMENT_CAST (ximagesink),
+ gst_navigation_message_new_event (GST_OBJECT_CAST (ximagesink), event));
- gst_event_unref (event);
- }
+ gst_event_unref (event);
}
static void
gst_x_image_sink_navigation_init (GstNavigationInterface * iface)
{
- iface->send_event = gst_x_image_sink_navigation_send_event;
+ iface->send_event_simple = gst_x_image_sink_navigation_send_event;
}
static void
GST_DEBUG ("xvimagesink pointer moved over window at %d,%d",
pointer_x, pointer_y);
- gst_navigation_send_mouse_event (GST_NAVIGATION (xvimagesink),
- "mouse-move", 0, e.xbutton.x, e.xbutton.y);
+ gst_navigation_send_event_simple (GST_NAVIGATION (xvimagesink),
+ gst_navigation_event_new_mouse_move (e.xbutton.x, e.xbutton.y));
g_mutex_lock (&xvimagesink->flow_lock);
g_mutex_lock (&xvimagesink->context->lock);
events for interactivity/navigation */
GST_DEBUG ("xvimagesink button %d pressed over window at %d,%d",
e.xbutton.button, e.xbutton.x, e.xbutton.y);
- gst_navigation_send_mouse_event (GST_NAVIGATION (xvimagesink),
- "mouse-button-press", e.xbutton.button, e.xbutton.x, e.xbutton.y);
+ gst_navigation_send_event_simple (GST_NAVIGATION (xvimagesink),
+ gst_navigation_event_new_mouse_button_press (e.xbutton.button,
+ e.xbutton.x, e.xbutton.y));
break;
case ButtonRelease:
/* Mouse button released over our window. We send upstream
events for interactivity/navigation */
GST_DEBUG ("xvimagesink button %d released over window at %d,%d",
e.xbutton.button, e.xbutton.x, e.xbutton.y);
- gst_navigation_send_mouse_event (GST_NAVIGATION (xvimagesink),
- "mouse-button-release", e.xbutton.button, e.xbutton.x, e.xbutton.y);
+ gst_navigation_send_event_simple (GST_NAVIGATION (xvimagesink),
+ gst_navigation_event_new_mouse_button_release (e.xbutton.button,
+ e.xbutton.x, e.xbutton.y));
break;
case KeyPress:
case KeyRelease:
GST_DEBUG_OBJECT (xvimagesink,
"key %d pressed over window at %d,%d (%s)",
e.xkey.keycode, e.xkey.x, e.xkey.y, key_str);
- gst_navigation_send_key_event (GST_NAVIGATION (xvimagesink),
- e.type == KeyPress ? "key-press" : "key-release", key_str);
+ gst_navigation_send_event_simple (GST_NAVIGATION (xvimagesink),
+ (e.type == KeyPress) ?
+ gst_navigation_event_new_key_press (key_str) :
+ gst_navigation_event_new_key_release (key_str));
break;
default:
GST_DEBUG_OBJECT (xvimagesink, "xvimagesink unhandled X event (%d)",
/* Interfaces stuff */
static void
gst_xv_image_sink_navigation_send_event (GstNavigation * navigation,
- GstStructure * structure)
+ GstEvent * event)
{
GstXvImageSink *xvimagesink = GST_XV_IMAGE_SINK (navigation);
gboolean handled = FALSE;
- GstEvent *event = NULL;
GstVideoRectangle src = { 0, };
GstVideoRectangle dst = { 0, };
if (!(xwindow = xvimagesink->xwindow)) {
g_mutex_unlock (&xvimagesink->flow_lock);
- gst_structure_free (structure);
+ gst_event_unref (event);
return;
}
xscale = (gdouble) xvimagesink->video_width / result.w;
yscale = (gdouble) xvimagesink->video_height / result.h;
+ event = gst_event_make_writable (event);
+
/* Converting pointer coordinates to the non scaled geometry */
- if (gst_structure_get_double (structure, "pointer_x", &x)) {
+ if (gst_navigation_event_get_coordinates (event, &x, &y)) {
x = MIN (x, result.x + result.w);
x = MAX (x - result.x, 0);
- gst_structure_set (structure, "pointer_x", G_TYPE_DOUBLE,
- (gdouble) x * xscale, NULL);
- }
- if (gst_structure_get_double (structure, "pointer_y", &y)) {
y = MIN (y, result.y + result.h);
y = MAX (y - result.y, 0);
- gst_structure_set (structure, "pointer_y", G_TYPE_DOUBLE,
- (gdouble) y * yscale, NULL);
+ gst_navigation_event_set_coordinates (event, x * xscale, y * yscale);
}
- event = gst_event_new_navigation (structure);
- if (event) {
- gst_event_ref (event);
- handled = gst_pad_push_event (GST_VIDEO_SINK_PAD (xvimagesink), event);
+ gst_event_ref (event);
+ handled = gst_pad_push_event (GST_VIDEO_SINK_PAD (xvimagesink), event);
- if (!handled)
- gst_element_post_message ((GstElement *) xvimagesink,
- gst_navigation_message_new_event ((GstObject *) xvimagesink, event));
+ if (!handled)
+ gst_element_post_message ((GstElement *) xvimagesink,
+ gst_navigation_message_new_event ((GstObject *) xvimagesink, event));
- gst_event_unref (event);
- }
+ gst_event_unref (event);
}
static void
gst_xv_image_sink_navigation_init (GstNavigationInterface * iface)
{
- iface->send_event = gst_xv_image_sink_navigation_send_event;
+ iface->send_event_simple = gst_xv_image_sink_navigation_send_event;
}
static void
GType test_element_get_type (void);
static void init_interface (GType type);
-static void nav_send_event (GstNavigation * navigation,
- GstStructure * structure);
+static void nav_send_event (GstNavigation * navigation, GstEvent * event);
G_DEFINE_TYPE_WITH_CODE (TestElement, test_element, GST_TYPE_ELEMENT,
init_interface (g_define_type_id));
static void
test_element_navigation_interface_init (GstNavigationInterface * iface)
{
- iface->send_event = nav_send_event;
+ iface->send_event_simple = nav_send_event;
}
static void
}
static void
-nav_send_event (GstNavigation * navigation, GstStructure * structure)
+nav_send_event (GstNavigation * navigation, GstEvent * event)
{
- GstEvent *event = gst_event_new_navigation (structure);
GstNavigationEventType etype = gst_navigation_event_get_type (event);
TestElement *self = (TestElement *) (navigation);
test_element->sent_key = "1";
gst_navigation_send_key_event (GST_NAVIGATION (test_element), "key-press",
"1");
+ gst_navigation_send_event_simple (GST_NAVIGATION (test_element),
+ gst_navigation_event_new_key_press ("1"));
test_element->sent_type = GST_NAVIGATION_EVENT_KEY_RELEASE;
test_element->sent_key = "2";
gst_navigation_send_key_event (GST_NAVIGATION (test_element), "key-release",
"2");
+ gst_navigation_send_event_simple (GST_NAVIGATION (test_element),
+ gst_navigation_event_new_key_release ("2"));
test_element->sent_type = GST_NAVIGATION_EVENT_MOUSE_MOVE;
test_element->sent_x = 50;
test_element->sent_y = 100;
gst_navigation_send_mouse_event (GST_NAVIGATION (test_element), "mouse-move",
0, 50, 100);
+ gst_navigation_send_event_simple (GST_NAVIGATION (test_element),
+ gst_navigation_event_new_mouse_move (50, 100));
test_element->sent_type = GST_NAVIGATION_EVENT_MOUSE_SCROLL;
test_element->sent_x = 60;
test_element->sent_delta_y = 3;
gst_navigation_send_mouse_scroll_event (GST_NAVIGATION (test_element),
60, 120, 2, 3);
+ gst_navigation_send_event_simple (GST_NAVIGATION (test_element),
+ gst_navigation_event_new_mouse_scroll (60, 120, 2, 3));
test_element->sent_type = GST_NAVIGATION_EVENT_MOUSE_BUTTON_PRESS;
test_element->sent_x = 10;
test_element->sent_button = 1;
gst_navigation_send_mouse_event (GST_NAVIGATION (test_element),
"mouse-button-press", 1, 10, 20);
+ gst_navigation_send_event_simple (GST_NAVIGATION (test_element),
+ gst_navigation_event_new_mouse_button_press (1, 10, 20));
for (i = 0; i < G_N_ELEMENTS (cmds); i++) {
test_element->sent_type = GST_NAVIGATION_EVENT_COMMAND;
test_element->sent_command = cmds[i];
gst_navigation_send_command (GST_NAVIGATION (test_element), cmds[i]);
+ gst_navigation_send_event_simple (GST_NAVIGATION (test_element),
+ gst_navigation_event_new_command (cmds[i]));
}
gst_object_unref (test_element);
}
if (cmd != GST_NAVIGATION_COMMAND_INVALID)
- gst_navigation_send_command (GST_NAVIGATION (app->navigation_element), cmd);
+ gst_navigation_send_event_simple (GST_NAVIGATION (app->navigation_element),
+ gst_navigation_event_new_command (cmd));
}
#if defined (GDK_WINDOWING_X11) || defined (GDK_WINDOWING_WIN32) || defined (GDK_WINDOWING_QUARTZ)
gtk_widget_grab_focus (widget);
if (app->navigation_element)
- gst_navigation_send_mouse_event (GST_NAVIGATION (app->navigation_element),
- "mouse-button-press", event->button, event->x, event->y);
+ gst_navigation_send_event_simple (GST_NAVIGATION (app->navigation_element),
+ gst_navigation_event_new_mouse_button_press (event->button, event->x,
+ event->y));
return FALSE;
}
PlaybackApp * app)
{
if (app->navigation_element)
- gst_navigation_send_mouse_event (GST_NAVIGATION (app->navigation_element),
- "mouse-button-release", event->button, event->x, event->y);
+ gst_navigation_send_event_simple (GST_NAVIGATION (app->navigation_element),
+ gst_navigation_event_new_mouse_button_release (event->button, event->x,
+ event->y));
return FALSE;
}
key_press_cb (GtkWidget * widget, GdkEventKey * event, PlaybackApp * app)
{
if (app->navigation_element)
- gst_navigation_send_key_event (GST_NAVIGATION (app->navigation_element),
- "key-press", gdk_keyval_name (event->keyval));
+ gst_navigation_send_event_simple (GST_NAVIGATION (app->navigation_element),
+ gst_navigation_event_new_key_press (gdk_keyval_name (event->keyval)));
return FALSE;
}
key_release_cb (GtkWidget * widget, GdkEventKey * event, PlaybackApp * app)
{
if (app->navigation_element)
- gst_navigation_send_key_event (GST_NAVIGATION (app->navigation_element),
- "key-release", gdk_keyval_name (event->keyval));
+ gst_navigation_send_event_simple (GST_NAVIGATION (app->navigation_element),
+ gst_navigation_event_new_key_release (gdk_keyval_name (event->keyval)));
return FALSE;
}
motion_notify_cb (GtkWidget * widget, GdkEventMotion * event, PlaybackApp * app)
{
if (app->navigation_element)
- gst_navigation_send_mouse_event (GST_NAVIGATION (app->navigation_element),
- "mouse-move", 0, event->x, event->y);
+ gst_navigation_send_event_simple (GST_NAVIGATION (app->navigation_element),
+ gst_navigation_event_new_mouse_move (event->x, event->y));
return FALSE;
}
static void
gst_gtk_base_sink_navigation_send_event (GstNavigation * navigation,
- GstStructure * structure)
+ GstEvent * event)
{
GstGtkBaseSink *sink = GST_GTK_BASE_SINK (navigation);
- GstEvent *event;
GstPad *pad;
gdouble x, y;
- if (gst_structure_get_double (structure, "pointer_x", &x) &&
- gst_structure_get_double (structure, "pointer_y", &y)) {
+ event = gst_event_make_writable (event);
+
+ if (gst_navigation_event_get_coordinates (event, &x, &y)) {
GtkGstBaseWidget *widget = gst_gtk_base_sink_get_widget (sink);
gdouble stream_x, stream_y;
gtk_gst_base_widget_display_size_to_stream_size (widget,
x, y, &stream_x, &stream_y);
- gst_structure_set (structure,
- "pointer_x", G_TYPE_DOUBLE, (gdouble) stream_x,
- "pointer_y", G_TYPE_DOUBLE, (gdouble) stream_y, NULL);
+ gst_navigation_event_set_coordinates (event, stream_x, stream_y);
}
- event = gst_event_new_navigation (structure);
pad = gst_pad_get_peer (GST_VIDEO_SINK_PAD (sink));
- GST_TRACE_OBJECT (sink, "navigation event %" GST_PTR_FORMAT, structure);
+ GST_TRACE_OBJECT (sink, "navigation event %" GST_PTR_FORMAT,
+ gst_event_get_structure (event));
if (GST_IS_PAD (pad) && GST_IS_EVENT (event)) {
if (!gst_pad_send_event (pad, gst_event_ref (event))) {
static void
gst_gtk_base_sink_navigation_interface_init (GstNavigationInterface * iface)
{
- iface->send_event = gst_gtk_base_sink_navigation_send_event;
+ iface->send_event_simple = gst_gtk_base_sink_navigation_send_event;
}
static gboolean
if ((element = g_weak_ref_get (&base_widget->element))) {
if (GST_IS_NAVIGATION (element)) {
const gchar *str = _gdk_key_to_navigation_string (event->keyval);
- const gchar *key_type =
- event->type == GDK_KEY_PRESS ? "key-press" : "key-release";
if (!str)
str = event->string;
- gst_navigation_send_key_event (GST_NAVIGATION (element), key_type, str);
+ gst_navigation_send_event_simple (GST_NAVIGATION (element),
+ (event->type == GDK_KEY_PRESS) ?
+ gst_navigation_event_new_key_press (str) :
+ gst_navigation_event_new_key_release (str));
}
g_object_unref (element);
}
if ((element = g_weak_ref_get (&base_widget->element))) {
if (GST_IS_NAVIGATION (element)) {
- const gchar *key_type =
- event->type ==
- GDK_BUTTON_PRESS ? "mouse-button-press" : "mouse-button-release";
- gst_navigation_send_mouse_event (GST_NAVIGATION (element), key_type,
- event->button, event->x, event->y);
+ gst_navigation_send_event_simple (GST_NAVIGATION (element),
+ (event->type == GDK_BUTTON_PRESS) ?
+ gst_navigation_event_new_mouse_button_press (event->button,
+ event->x, event->y) :
+ gst_navigation_event_new_mouse_button_release (event->button,
+ event->x, event->y));
}
g_object_unref (element);
}
if ((element = g_weak_ref_get (&base_widget->element))) {
if (GST_IS_NAVIGATION (element)) {
- gst_navigation_send_mouse_event (GST_NAVIGATION (element), "mouse-move",
- 0, event->x, event->y);
+ gst_navigation_send_event_simple (GST_NAVIGATION (element),
+ gst_navigation_event_new_mouse_move (event->x, event->y));
}
g_object_unref (element);
}
break;
}
}
- gst_navigation_send_mouse_scroll_event (GST_NAVIGATION (element),
- x, y, delta_x, delta_y);
+ gst_navigation_send_event_simple (GST_NAVIGATION (element),
+ gst_navigation_event_new_mouse_scroll (x, y, delta_x, delta_y));
}
g_object_unref (element);
}
static void
gst_qt_sink_navigation_send_event (GstNavigation * navigation,
- GstStructure * structure)
+ GstEvent * event)
{
GstQtSink *qt_sink = GST_QT_SINK (navigation);
- GstEvent *event;
GstPad *pad;
- event = gst_event_new_navigation (structure);
pad = gst_pad_get_peer (GST_VIDEO_SINK_PAD (qt_sink));
- GST_TRACE_OBJECT (qt_sink, "navigation event %" GST_PTR_FORMAT, structure);
+ GST_TRACE_OBJECT (qt_sink, "navigation event %" GST_PTR_FORMAT,
+ gst_event_get_structure(event));
if (GST_IS_PAD (pad) && GST_IS_EVENT (event)) {
if (!gst_pad_send_event (pad, gst_event_ref (event))) {
static void gst_qt_sink_navigation_interface_init (GstNavigationInterface * iface)
{
- iface->send_event = gst_qt_sink_navigation_send_event;
+ iface->send_event_simple = gst_qt_sink_navigation_send_event;
}
#else
auto position = *event;
#endif
- gst_navigation_send_mouse_scroll_event (GST_NAVIGATION (element),
- position.x(), position.y(), delta.x(), delta.y());
+ gst_navigation_send_event_simple (GST_NAVIGATION (element),
+ gst_navigation_event_new_mouse_scroll (position.x(), position.y(),
+ delta.x(), delta.y()));
g_object_unref (element);
}
g_mutex_unlock (&this->priv->lock);
if (!mouseHovering)
return;
- quint32 button = !!mousePressedButton;
-
g_mutex_lock (&this->priv->lock);
/* can't do anything when we don't have input format */
GstElement *element = GST_ELEMENT_CAST (g_weak_ref_get (&this->priv->sink));
if (element != NULL) {
- gst_navigation_send_mouse_event (GST_NAVIGATION (element), "mouse-move",
- button, pos.x(), pos.y());
+ gst_navigation_send_event_simple (GST_NAVIGATION (element),
+ gst_navigation_event_new_mouse_move (pos.x(), pos.y()));
g_object_unref (element);
}
}
}
void
-QtGLVideoItem::sendMouseEvent(QMouseEvent * event, const gchar * type)
+QtGLVideoItem::sendMouseEvent(QMouseEvent * event, gboolean is_press)
{
quint32 button = 0;
}
QPointF pos = mapPointToStreamSize(event->pos());
- gchar* event_type = g_strconcat ("mouse-button-", type, NULL);
GstElement *element = GST_ELEMENT_CAST (g_weak_ref_get (&this->priv->sink));
if (element != NULL) {
- gst_navigation_send_mouse_event (GST_NAVIGATION (element), event_type,
- button, pos.x(), pos.y());
+ gst_navigation_send_event_simple (GST_NAVIGATION (element),
+ (is_press) ? gst_navigation_event_new_mouse_button_press (button,
+ pos.x(), pos.y()) :
+ gst_navigation_event_new_mouse_button_release (button, pos.x(),
+ pos.y()));
g_object_unref (element);
}
- g_free (event_type);
g_mutex_unlock (&this->priv->lock);
}
QtGLVideoItem::mousePressEvent(QMouseEvent * event)
{
forceActiveFocus();
- sendMouseEvent(event, "press");
+ sendMouseEvent(event, TRUE);
}
void
QtGLVideoItem::mouseReleaseEvent(QMouseEvent * event)
{
- sendMouseEvent(event, "release");
+ sendMouseEvent(event, FALSE);
}
void
void fitStreamToAllocatedSize(GstVideoRectangle * result);
QPointF mapPointToStreamSize(QPointF);
- void sendMouseEvent(QMouseEvent * event, const gchar * type);
+ void sendMouseEvent(QMouseEvent * event, gboolean is_press);
quint32 mousePressedButton;
bool mouseHovering;
{
GstVideoInfo *info;
GstNavigationtest *navtest;
- const gchar *type;
+ GstNavigationEventType type;
navtest = GST_NAVIGATIONTEST (trans);
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_NAVIGATION:
{
- const GstStructure *s = gst_event_get_structure (event);
gint fps_n, fps_d;
fps_n = GST_VIDEO_INFO_FPS_N (info);
fps_d = GST_VIDEO_INFO_FPS_D (info);
- type = gst_structure_get_string (s, "event");
- if (g_str_equal (type, "mouse-move")) {
- gst_structure_get_double (s, "pointer_x", &navtest->x);
- gst_structure_get_double (s, "pointer_y", &navtest->y);
- } else if (g_str_equal (type, "mouse-button-press")) {
- ButtonClick *click = g_new (ButtonClick, 1);
-
- gst_structure_get_double (s, "pointer_x", &click->x);
- gst_structure_get_double (s, "pointer_y", &click->y);
- click->images_left = (fps_n + fps_d - 1) / fps_d;
- /* green */
- click->cy = 150;
- click->cu = 46;
- click->cv = 21;
- navtest->clicks = g_slist_prepend (navtest->clicks, click);
- } else if (g_str_equal (type, "mouse-button-release")) {
- ButtonClick *click = g_new (ButtonClick, 1);
-
- gst_structure_get_double (s, "pointer_x", &click->x);
- gst_structure_get_double (s, "pointer_y", &click->y);
- click->images_left = (fps_n + fps_d - 1) / fps_d;
- /* red */
- click->cy = 76;
- click->cu = 85;
- click->cv = 255;
- navtest->clicks = g_slist_prepend (navtest->clicks, click);
+ type = gst_navigation_event_get_type (event);
+ switch (type) {
+ case GST_NAVIGATION_EVENT_MOUSE_MOVE:{
+ gst_navigation_event_get_coordinates (event, &navtest->x,
+ &navtest->y);
+ break;
+ }
+ case GST_NAVIGATION_EVENT_MOUSE_BUTTON_PRESS:{
+ ButtonClick *click = g_new (ButtonClick, 1);
+
+ gst_navigation_event_get_coordinates (event, &click->x, &click->y);
+ click->images_left = (fps_n + fps_d - 1) / fps_d;
+ /* green */
+ click->cy = 150;
+ click->cu = 46;
+ click->cv = 21;
+ navtest->clicks = g_slist_prepend (navtest->clicks, click);
+ break;
+ }
+ case GST_NAVIGATION_EVENT_MOUSE_BUTTON_RELEASE:{
+ ButtonClick *click = g_new (ButtonClick, 1);
+
+ gst_navigation_event_get_coordinates (event, &click->x, &click->y);
+ click->images_left = (fps_n + fps_d - 1) / fps_d;
+ /* red */
+ click->cy = 76;
+ click->cu = 85;
+ click->cv = 255;
+ navtest->clicks = g_slist_prepend (navtest->clicks, click);
+ break;
+ }
+ default:
+ break;
}
break;
}
#include "gstdebugutilselements.h"
#include "gstnavseek.h"
+#include <gst/video/navigation.h>
#include <string.h>
#include <math.h>
case GST_EVENT_NAVIGATION:
{
/* Check for a keyup and convert left/right to a seek event */
- const GstStructure *structure;
- const gchar *event_type;
-
- structure = gst_event_get_structure (event);
- g_return_val_if_fail (structure != NULL, FALSE);
-
- event_type = gst_structure_get_string (structure, "event");
- g_return_val_if_fail (event_type != NULL, FALSE);
-
- if (strcmp (event_type, "key-press") == 0) {
+ if (gst_navigation_event_get_type (event)
+ == GST_NAVIGATION_EVENT_KEY_PRESS) {
const gchar *key;
- key = gst_structure_get_string (structure, "key");
+ gst_navigation_event_parse_key_event (event, &key);
g_return_val_if_fail (key != NULL, FALSE);
if (strcmp (key, "Left") == 0) {
gst_video_box_src_event (GstBaseTransform * trans, GstEvent * event)
{
GstVideoBox *video_box = GST_VIDEO_BOX (trans);
- GstStructure *new_structure;
- const GstStructure *structure;
- const gchar *event_name;
+ GstNavigationEventType type;
gdouble pointer_x;
gdouble pointer_y;
GST_OBJECT_LOCK (video_box);
+ type = gst_navigation_event_get_type (event);
if (GST_EVENT_TYPE (event) == GST_EVENT_NAVIGATION &&
- (video_box->box_left != 0 || video_box->box_top != 0)) {
- structure = gst_event_get_structure (event);
- event_name = gst_structure_get_string (structure, "event");
-
- if (event_name &&
- (strcmp (event_name, "mouse-move") == 0 ||
- strcmp (event_name, "mouse-button-press") == 0 ||
- strcmp (event_name, "mouse-button-release") == 0)) {
- if (gst_structure_get_double (structure, "pointer_x", &pointer_x) &&
- gst_structure_get_double (structure, "pointer_y", &pointer_y)) {
- gdouble new_pointer_x, new_pointer_y;
- GstEvent *new_event;
-
- new_pointer_x = pointer_x + video_box->box_left;
- new_pointer_y = pointer_y + video_box->box_top;
-
- new_structure = gst_structure_copy (structure);
- gst_structure_set (new_structure,
- "pointer_x", G_TYPE_DOUBLE, (gdouble) (new_pointer_x),
- "pointer_y", G_TYPE_DOUBLE, (gdouble) (new_pointer_y), NULL);
-
- new_event = gst_event_new_navigation (new_structure);
- gst_event_unref (event);
- event = new_event;
- } else {
- GST_WARNING_OBJECT (video_box, "Failed to read navigation event");
- }
+ (video_box->box_left != 0 || video_box->box_top != 0) &&
+ (type == GST_NAVIGATION_EVENT_MOUSE_MOVE
+ || type == GST_NAVIGATION_EVENT_MOUSE_BUTTON_PRESS
+ || type == GST_NAVIGATION_EVENT_MOUSE_BUTTON_RELEASE)) {
+ if (gst_navigation_event_get_coordinates (event, &pointer_x, &pointer_y)) {
+ gdouble new_pointer_x, new_pointer_y;
+
+ event = gst_event_make_writable (event);
+ new_pointer_x = pointer_x + video_box->box_left;
+ new_pointer_y = pointer_y + video_box->box_top;
+
+ gst_navigation_event_set_coordinates (event, new_pointer_x,
+ new_pointer_y);
+ } else {
+ GST_WARNING_OBJECT (video_box, "Failed to read navigation event");
}
}
GST_OBJECT_UNLOCK (video_box);
static gboolean
gst_video_crop_src_event (GstBaseTransform * trans, GstEvent * event)
{
- GstEvent *new_event;
- GstStructure *new_structure;
- const GstStructure *structure;
- const gchar *event_name;
+ GstNavigationEventType type;
double pointer_x;
double pointer_y;
GstVideoCrop *vcrop = GST_VIDEO_CROP (trans);
- new_event = NULL;
-
GST_OBJECT_LOCK (vcrop);
+
+ type = gst_navigation_event_get_type (event);
if (GST_EVENT_TYPE (event) == GST_EVENT_NAVIGATION &&
- (vcrop->crop_left != 0 || vcrop->crop_top != 0)) {
- structure = gst_event_get_structure (event);
- event_name = gst_structure_get_string (structure, "event");
-
- if (event_name &&
- (strcmp (event_name, "mouse-move") == 0 ||
- strcmp (event_name, "mouse-button-press") == 0 ||
- strcmp (event_name, "mouse-button-release") == 0)) {
-
- if (gst_structure_get_double (structure, "pointer_x", &pointer_x) &&
- gst_structure_get_double (structure, "pointer_y", &pointer_y)) {
-
- new_structure = gst_structure_copy (structure);
- gst_structure_set (new_structure,
- "pointer_x", G_TYPE_DOUBLE, (double) (pointer_x + vcrop->crop_left),
- "pointer_y", G_TYPE_DOUBLE, (double) (pointer_y + vcrop->crop_top),
- NULL);
-
- new_event = gst_event_new_navigation (new_structure);
- gst_event_unref (event);
- } else {
- GST_WARNING_OBJECT (vcrop, "Failed to read navigation event");
- }
+ (vcrop->crop_left != 0 || vcrop->crop_top != 0) &&
+ (type == GST_NAVIGATION_EVENT_MOUSE_MOVE
+ || type == GST_NAVIGATION_EVENT_MOUSE_BUTTON_PRESS
+ || type == GST_NAVIGATION_EVENT_MOUSE_BUTTON_RELEASE)) {
+ if (gst_navigation_event_get_coordinates (event, &pointer_x, &pointer_y)) {
+ event = gst_event_make_writable (event);
+ gst_navigation_event_set_coordinates (event, pointer_x + vcrop->crop_left,
+ pointer_y + vcrop->crop_top);
+ } else {
+ GST_WARNING_OBJECT (vcrop, "Failed to read navigation event");
}
}
GST_OBJECT_UNLOCK (vcrop);
- return GST_BASE_TRANSFORM_CLASS (parent_class)->src_event (trans,
- (new_event ? new_event : event));
+ return GST_BASE_TRANSFORM_CLASS (parent_class)->src_event (trans, event);
}
static void
{
GstVideoFlip *vf = GST_VIDEO_FLIP (trans);
gdouble new_x, new_y, x, y;
- GstStructure *structure;
gboolean ret;
GstVideoInfo *out_info = &GST_VIDEO_FILTER (trans)->out_info;
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_NAVIGATION:
- event =
- GST_EVENT (gst_mini_object_make_writable (GST_MINI_OBJECT (event)));
+ event = gst_event_make_writable (event);
- structure = (GstStructure *) gst_event_get_structure (event);
- if (gst_structure_get_double (structure, "pointer_x", &x) &&
- gst_structure_get_double (structure, "pointer_y", &y)) {
+ if (gst_navigation_event_get_coordinates (event, &x, &y)) {
GST_DEBUG_OBJECT (vf, "converting %fx%f", x, y);
GST_OBJECT_LOCK (vf);
switch (vf->active_method) {
}
GST_OBJECT_UNLOCK (vf);
GST_DEBUG_OBJECT (vf, "to %fx%f", new_x, new_y);
- gst_structure_set (structure, "pointer_x", G_TYPE_DOUBLE, new_x,
- "pointer_y", G_TYPE_DOUBLE, new_y, NULL);
+ gst_navigation_event_set_coordinates (event, new_x, new_y);
}
break;
default:
{
GstVaapiPostproc *const postproc = GST_VAAPIPOSTPROC (trans);
gdouble new_x = 0, new_y = 0, x = 0, y = 0, w_factor = 1, h_factor = 1;
- GstStructure *structure;
gboolean ret;
GST_TRACE_OBJECT (postproc, "handling %s event", GST_EVENT_TYPE_NAME (event));
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_NAVIGATION:
- event =
- GST_EVENT (gst_mini_object_make_writable (GST_MINI_OBJECT (event)));
+ event = gst_event_make_writable (event);
- structure = (GstStructure *) gst_event_get_structure (event);
- if (postproc->has_vpp
- && gst_structure_get_double (structure, "pointer_x", &x)
- && gst_structure_get_double (structure, "pointer_y", &y)) {
+ if (postproc->has_vpp &&
+ gst_navigation_event_get_coordinates (event, &x, &y)) {
GST_DEBUG_OBJECT (postproc, "converting %fx%f", x, y);
/* video-direction compensation */
new_y += postproc->crop_top;
GST_DEBUG_OBJECT (postproc, "to %fx%f", new_x, new_y);
- gst_structure_set (structure, "pointer_x", G_TYPE_DOUBLE, new_x,
- "pointer_y", G_TYPE_DOUBLE, new_y, NULL);
+ gst_navigation_event_set_coordinates (event, new_x, new_y);
}
break;
default:
static void
gst_vaapisink_navigation_send_event (GstNavigation * navigation,
- GstStructure * structure)
+ GstEvent * event)
{
GstVaapiSink *const sink = GST_VAAPISINK (navigation);
GstPad *peer;
if (!sink->window) {
- gst_structure_free (structure);
+ gst_event_unref (event);
return;
}
if ((peer = gst_pad_get_peer (GST_VAAPI_PLUGIN_BASE_SINK_PAD (sink)))) {
- GstEvent *event;
GstVaapiRectangle *disp_rect = &sink->display_rect;
gdouble x, y, xscale = 1.0, yscale = 1.0;
- event = gst_event_new_navigation (structure);
-
/* We calculate scaling using the original video frames geometry to include
pixel aspect ratio scaling. */
xscale = (gdouble) sink->video_width / disp_rect->width;
yscale = (gdouble) sink->video_height / disp_rect->height;
+ event = gst_event_make_writable (event);
+
/* Converting pointer coordinates to the non scaled geometry */
- if (gst_structure_get_double (structure, "pointer_x", &x)) {
+ if (gst_navigation_event_get_coordinates (event, &x, &y)) {
x = MIN (x, disp_rect->x + disp_rect->width);
x = MAX (x - disp_rect->x, 0);
- gst_structure_set (structure, "pointer_x", G_TYPE_DOUBLE,
- (gdouble) x * xscale, NULL);
- }
- if (gst_structure_get_double (structure, "pointer_y", &y)) {
y = MIN (y, disp_rect->y + disp_rect->height);
y = MAX (y - disp_rect->y, 0);
- gst_structure_set (structure, "pointer_y", G_TYPE_DOUBLE,
- (gdouble) y * yscale, NULL);
+ gst_navigation_event_set_coordinates (event, x * xscale, y * yscale);
}
if (!gst_pad_send_event (peer, gst_event_ref (event))) {
static void
gst_vaapisink_navigation_iface_init (GstNavigationInterface * iface)
{
- iface->send_event = gst_vaapisink_navigation_send_event;
+ iface->send_event_simple = gst_vaapisink_navigation_send_event;
}
/* ------------------------------------------------------------------------ */
vpp_test_mouse_events (VppTestContext * ctx,
const VppTestCoordinateParams * const params, const size_t nparams)
{
- GstStructure *structure;
- GstEvent *event;
+ GstEvent *event = NULL;
VppTestCoordinate probed = { 0, };
guint i, j;
for (j = 0; j < G_N_ELEMENTS (mouse_events); ++j) {
probed.x = probed.y = -1;
+ switch (j) {
+ case 0:
+ event = gst_navigation_event_new_mouse_move (params[i].send.x,
+ params[i].send.y);
+ break;
+ case 1:
+ event = gst_navigation_event_new_mouse_button_press (0,
+ params[i].send.x, params[i].send.y);
+ break;
+ case 2:
+ event = gst_navigation_event_new_mouse_button_release (0,
+ params[i].send.x, params[i].send.y);
+ break;
+ }
+
GST_LOG ("sending %s event %fx%f", mouse_events[j], params[i].send.x,
params[i].send.y);
- structure = gst_structure_new ("application/x-gst-navigation", "event",
- G_TYPE_STRING, mouse_events[j],
- "pointer_x", G_TYPE_DOUBLE, params[i].send.x,
- "pointer_y", G_TYPE_DOUBLE, params[i].send.y, NULL);
- event = gst_event_new_navigation (structure);
gst_element_send_event (ctx->pipeline, event);
GST_LOG ("probed %s event %fx%f", mouse_events[j], probed.x, probed.y);