mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-28 11:10:37 +00:00
all: Use new navigation interface and API
Use and implement the new navigation interface in all relevant sink elements, and use API functions everywhere instead of directy accessing the event structure. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1633>
This commit is contained in:
parent
f402b2e180
commit
6c2f6c3bd4
34 changed files with 477 additions and 519 deletions
|
@ -605,8 +605,8 @@ gst_dfbvideosink_event_thread (GstDfbVideoSink * dfbvideosink)
|
||||||
default:
|
default:
|
||||||
GST_DEBUG_OBJECT (dfbvideosink, "key press event %c !",
|
GST_DEBUG_OBJECT (dfbvideosink, "key press event %c !",
|
||||||
event.input.key_symbol);
|
event.input.key_symbol);
|
||||||
gst_navigation_send_key_event (GST_NAVIGATION (dfbvideosink),
|
gst_dfbvideosink_navigation_send_event
|
||||||
"key-press", "prout");
|
(gst_navigation_event_new_key_press ("prout"));
|
||||||
}
|
}
|
||||||
} else if (event.input.type == DIET_BUTTONPRESS) {
|
} else if (event.input.type == DIET_BUTTONPRESS) {
|
||||||
gint x, y;
|
gint x, y;
|
||||||
|
@ -616,8 +616,9 @@ gst_dfbvideosink_event_thread (GstDfbVideoSink * dfbvideosink)
|
||||||
GST_DEBUG_OBJECT (dfbvideosink, "button %d pressed at %dx%d",
|
GST_DEBUG_OBJECT (dfbvideosink, "button %d pressed at %dx%d",
|
||||||
event.input.button, x, y);
|
event.input.button, x, y);
|
||||||
|
|
||||||
gst_navigation_send_mouse_event (GST_NAVIGATION (dfbvideosink),
|
gst_dfbvideosink_navigation_send_event
|
||||||
"mouse-button-press", event.input.button, x, y);
|
(gst_navigation_event_new_mouse_button_press (event.input.button,
|
||||||
|
x, y));
|
||||||
} else if (event.input.type == DIET_BUTTONRELEASE) {
|
} else if (event.input.type == DIET_BUTTONRELEASE) {
|
||||||
gint x, y;
|
gint x, y;
|
||||||
|
|
||||||
|
@ -626,14 +627,15 @@ gst_dfbvideosink_event_thread (GstDfbVideoSink * dfbvideosink)
|
||||||
GST_DEBUG_OBJECT (dfbvideosink, "button %d released at %dx%d",
|
GST_DEBUG_OBJECT (dfbvideosink, "button %d released at %dx%d",
|
||||||
event.input.button, x, y);
|
event.input.button, x, y);
|
||||||
|
|
||||||
gst_navigation_send_mouse_event (GST_NAVIGATION (dfbvideosink),
|
gst_dfbvideosink_navigation_send_event
|
||||||
"mouse-button-release", event.input.button, x, y);
|
(gst_navigation_event_new_mouse_button_release
|
||||||
|
(event.input.button, x, y));
|
||||||
} else if (event.input.type == DIET_AXISMOTION) {
|
} else if (event.input.type == DIET_AXISMOTION) {
|
||||||
gint x, y;
|
gint x, y;
|
||||||
|
|
||||||
dfbvideosink->layer->GetCursorPosition (dfbvideosink->layer, &x, &y);
|
dfbvideosink->layer->GetCursorPosition (dfbvideosink->layer, &x, &y);
|
||||||
gst_navigation_send_mouse_event (GST_NAVIGATION (dfbvideosink),
|
gst_dfbvideosink_navigation_send_event
|
||||||
"mouse-move", 0, x, y);
|
(gst_navigation_event_new_mouse_move (x, y));
|
||||||
} else {
|
} else {
|
||||||
GST_WARNING_OBJECT (dfbvideosink, "unhandled event type %d",
|
GST_WARNING_OBJECT (dfbvideosink, "unhandled event type %d",
|
||||||
event.input.type);
|
event.input.type);
|
||||||
|
@ -1983,10 +1985,9 @@ beach:
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_dfbvideosink_navigation_send_event (GstNavigation * navigation,
|
gst_dfbvideosink_navigation_send_event (GstNavigation * navigation,
|
||||||
GstStructure * structure)
|
GstEvent * event)
|
||||||
{
|
{
|
||||||
GstDfbVideoSink *dfbvideosink = GST_DFBVIDEOSINK (navigation);
|
GstDfbVideoSink *dfbvideosink = GST_DFBVIDEOSINK (navigation);
|
||||||
GstEvent *event;
|
|
||||||
GstVideoRectangle dst = { 0, };
|
GstVideoRectangle dst = { 0, };
|
||||||
GstVideoRectangle src = { 0, };
|
GstVideoRectangle src = { 0, };
|
||||||
GstVideoRectangle result;
|
GstVideoRectangle result;
|
||||||
|
@ -1999,13 +2000,15 @@ gst_dfbvideosink_navigation_send_event (GstNavigation * navigation,
|
||||||
dst.h = dfbvideosink->out_height;
|
dst.h = dfbvideosink->out_height;
|
||||||
gst_video_sink_center_rect (src, dst, &result, dfbvideosink->hw_scaling);
|
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 */
|
/* Our coordinates can be wrong here if we centered the video */
|
||||||
|
|
||||||
/* Converting pointer coordinates to the non scaled geometry */
|
/* 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;
|
x = old_x;
|
||||||
|
y = old_y;
|
||||||
|
|
||||||
if (x >= result.x && x <= (result.x + result.w)) {
|
if (x >= result.x && x <= (result.x + result.w)) {
|
||||||
x -= result.x;
|
x -= result.x;
|
||||||
|
@ -2014,13 +2017,6 @@ gst_dfbvideosink_navigation_send_event (GstNavigation * navigation,
|
||||||
} else {
|
} else {
|
||||||
x = 0;
|
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)) {
|
if (y >= result.y && y <= (result.y + result.h)) {
|
||||||
y -= result.y;
|
y -= result.y;
|
||||||
y *= dfbvideosink->video_height;
|
y *= dfbvideosink->video_height;
|
||||||
|
@ -2028,14 +2024,17 @@ gst_dfbvideosink_navigation_send_event (GstNavigation * navigation,
|
||||||
} else {
|
} else {
|
||||||
y = 0;
|
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 "
|
GST_DEBUG_OBJECT (dfbvideosink, "translated navigation event y "
|
||||||
"coordinate from %fd to %fd", old_y, 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));
|
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 (!gst_pad_send_event (pad, gst_event_ref (event))) {
|
||||||
/* If upstream didn't handle the event we'll post a message with it
|
/* 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 */
|
* for the application in case it wants to do something with it */
|
||||||
|
@ -2051,7 +2050,7 @@ gst_dfbvideosink_navigation_send_event (GstNavigation * navigation,
|
||||||
static void
|
static void
|
||||||
gst_dfbvideosink_navigation_init (GstNavigationInterface * iface)
|
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
|
||||||
|
|
|
@ -122,7 +122,7 @@ static CascadeClassifier *gst_handdetect_load_profile (GstHanddetect * filter,
|
||||||
static void gst_handdetect_navigation_interface_init (GstNavigationInterface *
|
static void gst_handdetect_navigation_interface_init (GstNavigationInterface *
|
||||||
iface);
|
iface);
|
||||||
static void gst_handdetect_navigation_send_event (GstNavigation * navigation,
|
static void gst_handdetect_navigation_send_event (GstNavigation * navigation,
|
||||||
GstStructure * structure);
|
GstEvent * event);
|
||||||
|
|
||||||
G_DEFINE_TYPE_WITH_CODE (GstHanddetect, gst_handdetect,
|
G_DEFINE_TYPE_WITH_CODE (GstHanddetect, gst_handdetect,
|
||||||
GST_TYPE_OPENCV_VIDEO_FILTER,
|
GST_TYPE_OPENCV_VIDEO_FILTER,
|
||||||
|
@ -136,7 +136,7 @@ GST_ELEMENT_REGISTER_DEFINE (handdetect, "handdetect", GST_RANK_NONE,
|
||||||
static void
|
static void
|
||||||
gst_handdetect_navigation_interface_init (GstNavigationInterface * iface)
|
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
|
/* FIXME: this function used to parse the region of interests coordinates
|
||||||
|
@ -146,14 +146,12 @@ gst_handdetect_navigation_interface_init (GstNavigationInterface * iface)
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
gst_handdetect_navigation_send_event (GstNavigation * navigation,
|
gst_handdetect_navigation_send_event (GstNavigation * navigation,
|
||||||
GstStructure * structure)
|
GstEvent * event)
|
||||||
{
|
{
|
||||||
GstHanddetect *filter = GST_HANDDETECT (navigation);
|
GstHanddetect *filter = GST_HANDDETECT (navigation);
|
||||||
GstPad *peer;
|
GstPad *peer;
|
||||||
|
|
||||||
if ((peer = gst_pad_get_peer (GST_BASE_TRANSFORM_CAST (filter)->sinkpad))) {
|
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_pad_send_event (peer, event);
|
||||||
gst_object_unref (peer);
|
gst_object_unref (peer);
|
||||||
}
|
}
|
||||||
|
@ -481,11 +479,10 @@ gst_handdetect_transform_ip (GstOpencvVideoFilter * transform,
|
||||||
* !!! this will CHANGE in the future !!!
|
* !!! this will CHANGE in the future !!!
|
||||||
* !!! by adding gst_navigation_send_hand_detect_event() in navigation.c !!!
|
* !!! by adding gst_navigation_send_hand_detect_event() in navigation.c !!!
|
||||||
*/
|
*/
|
||||||
gst_navigation_send_mouse_event (GST_NAVIGATION (filter),
|
gst_handdetect_navigation_send_event (GST_NAVIGATION (filter),
|
||||||
"mouse-move",
|
gst_navigation_event_new_mouse_move (
|
||||||
0,
|
(double) (filter->best_r->x + filter->best_r->width * 0.5),
|
||||||
(double) (filter->best_r->x + filter->best_r->width * 0.5),
|
(double) (filter->best_r->y + filter->best_r->height * 0.5)));
|
||||||
(double) (filter->best_r->y + filter->best_r->height * 0.5));
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -571,11 +568,10 @@ gst_handdetect_transform_ip (GstOpencvVideoFilter * transform,
|
||||||
* !!! this will CHANGE in the future !!!
|
* !!! this will CHANGE in the future !!!
|
||||||
* !!! by adding gst_navigation_send_hand_detect_event() in navigation.c !!!
|
* !!! by adding gst_navigation_send_hand_detect_event() in navigation.c !!!
|
||||||
*/
|
*/
|
||||||
gst_navigation_send_mouse_event (GST_NAVIGATION (filter),
|
gst_handdetect_navigation_send_event (GST_NAVIGATION (filter),
|
||||||
"mouse-move",
|
gst_navigation_event_new_mouse_move (
|
||||||
0,
|
(double) (filter->best_r->x + filter->best_r->width * 0.5),
|
||||||
(double) (filter->best_r->x + filter->best_r->width * 0.5),
|
(double) (filter->best_r->y + filter->best_r->height * 0.5)));
|
||||||
(double) (filter->best_r->y + filter->best_r->height * 0.5));
|
|
||||||
|
|
||||||
/* or use another way to send upstream navigation event for debug
|
/* or use another way to send upstream navigation event for debug
|
||||||
*
|
*
|
||||||
|
|
|
@ -632,69 +632,79 @@ _display_size_to_stream_size (GstVulkanSink * vk_sink,
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_vulkan_sink_navigation_send_event (GstNavigation * navigation,
|
gst_vulkan_sink_navigation_send_event (GstNavigation * navigation,
|
||||||
GstStructure * structure)
|
GstEvent * event)
|
||||||
{
|
{
|
||||||
GstVulkanSink *vk_sink = GST_VULKAN_SINK (navigation);
|
GstVulkanSink *vk_sink = GST_VULKAN_SINK (navigation);
|
||||||
GstVideoRectangle display_rect;
|
GstVideoRectangle display_rect;
|
||||||
GstEvent *event = NULL;
|
gboolean handled;
|
||||||
gdouble x, y;
|
gdouble x, y;
|
||||||
|
|
||||||
if (!vk_sink->swapper || !vk_sink->swapper->window) {
|
if (!vk_sink->swapper || !vk_sink->swapper->window) {
|
||||||
gst_structure_free (structure);
|
gst_event_unref (event);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
event = gst_event_make_writable (event);
|
||||||
|
|
||||||
gst_vulkan_swapper_get_surface_rectangles (vk_sink->swapper, NULL, NULL,
|
gst_vulkan_swapper_get_surface_rectangles (vk_sink->swapper, NULL, NULL,
|
||||||
&display_rect);
|
&display_rect);
|
||||||
|
|
||||||
/* Converting pointer coordinates to the non scaled geometry */
|
/* Converting pointer coordinates to the non scaled geometry */
|
||||||
if (display_rect.w != 0 && display_rect.h != 0
|
if (display_rect.w != 0 && display_rect.h != 0
|
||||||
&& gst_structure_get_double (structure, "pointer_x", &x)
|
&& gst_navigation_event_get_coordinates (event, &x, &y)) {
|
||||||
&& gst_structure_get_double (structure, "pointer_y", &y)) {
|
|
||||||
gdouble stream_x, stream_y;
|
gdouble stream_x, stream_y;
|
||||||
|
|
||||||
_display_size_to_stream_size (vk_sink, &display_rect, x, y, &stream_x,
|
_display_size_to_stream_size (vk_sink, &display_rect, x, y, &stream_x,
|
||||||
&stream_y);
|
&stream_y);
|
||||||
|
gst_navigation_event_set_coordinates (event, stream_x, stream_y);
|
||||||
gst_structure_set (structure, "pointer_x", G_TYPE_DOUBLE,
|
|
||||||
stream_x, "pointer_y", G_TYPE_DOUBLE, stream_y, NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
event = gst_event_new_navigation (structure);
|
gst_event_ref (event);
|
||||||
if (event) {
|
handled = gst_pad_push_event (GST_VIDEO_SINK_PAD (vk_sink), event);
|
||||||
gboolean handled;
|
|
||||||
|
|
||||||
gst_event_ref (event);
|
if (!handled)
|
||||||
handled = gst_pad_push_event (GST_VIDEO_SINK_PAD (vk_sink), event);
|
gst_element_post_message ((GstElement *) vk_sink,
|
||||||
|
gst_navigation_message_new_event ((GstObject *) vk_sink, event));
|
||||||
|
|
||||||
if (!handled)
|
gst_event_unref (event);
|
||||||
gst_element_post_message ((GstElement *) vk_sink,
|
|
||||||
gst_navigation_message_new_event ((GstObject *) vk_sink, event));
|
|
||||||
|
|
||||||
gst_event_unref (event);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_vulkan_sink_navigation_interface_init (GstNavigationInterface * iface)
|
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
|
static void
|
||||||
gst_vulkan_sink_key_event_cb (GstVulkanWindow * window, char *event_name, char
|
gst_vulkan_sink_key_event_cb (GstVulkanWindow * window, char *event_name, char
|
||||||
*key_string, GstVulkanSink * vk_sink)
|
*key_string, GstVulkanSink * vk_sink)
|
||||||
{
|
{
|
||||||
|
GstEvent *event = NULL;
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (vk_sink, "event %s key %s pressed", event_name, key_string);
|
GST_DEBUG_OBJECT (vk_sink, "event %s key %s pressed", event_name, key_string);
|
||||||
gst_navigation_send_key_event (GST_NAVIGATION (vk_sink),
|
if (0 == g_strcmp0 ("key-press", event_name))
|
||||||
event_name, key_string);
|
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
|
static void
|
||||||
gst_vulkan_sink_mouse_event_cb (GstVulkanWindow * window, char *event_name,
|
gst_vulkan_sink_mouse_event_cb (GstVulkanWindow * window, char *event_name,
|
||||||
int button, double posx, double posy, GstVulkanSink * vk_sink)
|
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_DEBUG_OBJECT (vk_sink, "event %s at %g, %g", event_name, posx, posy);
|
||||||
gst_navigation_send_mouse_event (GST_NAVIGATION (vk_sink),
|
if (0 == g_strcmp0 ("mouse-button-press", event_name))
|
||||||
event_name, button, posx, posy);
|
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);
|
||||||
}
|
}
|
||||||
|
|
|
@ -551,11 +551,7 @@ gst_rfb_src_event (GstBaseSrc * bsrc, GstEvent * event)
|
||||||
GstRfbSrc *src = GST_RFB_SRC (bsrc);
|
GstRfbSrc *src = GST_RFB_SRC (bsrc);
|
||||||
gdouble x, y;
|
gdouble x, y;
|
||||||
gint button;
|
gint button;
|
||||||
const GstStructure *structure;
|
GstNavigationEventType event_type;
|
||||||
const gchar *event_type;
|
|
||||||
gboolean key_event, key_press;
|
|
||||||
|
|
||||||
key_event = FALSE;
|
|
||||||
|
|
||||||
switch (GST_EVENT_TYPE (event)) {
|
switch (GST_EVENT_TYPE (event)) {
|
||||||
case GST_EVENT_NAVIGATION:
|
case GST_EVENT_NAVIGATION:
|
||||||
|
@ -564,55 +560,62 @@ gst_rfb_src_event (GstBaseSrc * bsrc, GstEvent * event)
|
||||||
if (src->view_only)
|
if (src->view_only)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
structure = gst_event_get_structure (event);
|
event_type = gst_navigation_event_get_type (event);
|
||||||
event_type = gst_structure_get_string (structure, "event");
|
switch (event_type) {
|
||||||
|
|
||||||
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) {
|
|
||||||
#ifdef HAVE_X11
|
#ifdef HAVE_X11
|
||||||
const gchar *key;
|
case GST_NAVIGATION_EVENT_KEY_PRESS:
|
||||||
KeySym key_sym;
|
case GST_NAVIGATION_EVENT_KEY_RELEASE:{
|
||||||
|
const gchar *key;
|
||||||
|
KeySym key_sym;
|
||||||
|
|
||||||
key = gst_structure_get_string (structure, "key");
|
gst_navigation_event_parse_key_event (event, &key);
|
||||||
key_sym = XStringToKeysym (key);
|
key_sym = XStringToKeysym (key);
|
||||||
|
|
||||||
if (key_sym != NoSymbol)
|
if (key_sym != NoSymbol)
|
||||||
rfb_decoder_send_key_event (src->decoder, key_sym, key_press);
|
rfb_decoder_send_key_event (src->decoder, key_sym,
|
||||||
|
event_type == GST_NAVIGATION_EVENT_KEY_PRESS);
|
||||||
|
break;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
break;
|
case GST_NAVIGATION_EVENT_MOUSE_BUTTON_PRESS:{
|
||||||
}
|
gst_navigation_event_parse_mouse_button_event (event,
|
||||||
|
&button, &x, &y);
|
||||||
gst_structure_get_double (structure, "pointer_x", &x);
|
x += src->decoder->offset_x;
|
||||||
gst_structure_get_double (structure, "pointer_y", &y);
|
y += src->decoder->offset_y;
|
||||||
gst_structure_get_int (structure, "button", &button);
|
src->button_mask |= (1 << (button - 1));
|
||||||
|
GST_LOG_OBJECT (src, "sending mouse-button-press event "
|
||||||
/* we need to take care of the offset's */
|
"button_mask=%d, x=%d, y=%d",
|
||||||
x += src->decoder->offset_x;
|
src->button_mask, (gint) x, (gint) y);
|
||||||
y += src->decoder->offset_y;
|
rfb_decoder_send_pointer_event (src->decoder, src->button_mask,
|
||||||
|
(gint) x, (gint) y);
|
||||||
if (strcmp (event_type, "mouse-move") == 0) {
|
break;
|
||||||
GST_LOG_OBJECT (src, "sending mouse-move event "
|
}
|
||||||
"button_mask=%d, x=%d, y=%d", src->button_mask, (gint) x, (gint) y);
|
case GST_NAVIGATION_EVENT_MOUSE_BUTTON_RELEASE:{
|
||||||
rfb_decoder_send_pointer_event (src->decoder, src->button_mask,
|
gst_navigation_event_parse_mouse_button_event (event,
|
||||||
(gint) x, (gint) y);
|
&button, &x, &y);
|
||||||
} else if (strcmp (event_type, "mouse-button-release") == 0) {
|
x += src->decoder->offset_x;
|
||||||
src->button_mask &= ~(1 << (button - 1));
|
y += src->decoder->offset_y;
|
||||||
GST_LOG_OBJECT (src, "sending mouse-button-release event "
|
src->button_mask &= ~(1 << (button - 1));
|
||||||
"button_mask=%d, x=%d, y=%d", src->button_mask, (gint) x, (gint) y);
|
GST_LOG_OBJECT (src, "sending mouse-button-release event "
|
||||||
rfb_decoder_send_pointer_event (src->decoder, src->button_mask,
|
"button_mask=%d, x=%d, y=%d",
|
||||||
(gint) x, (gint) y);
|
src->button_mask, (gint) x, (gint) y);
|
||||||
} else if (strcmp (event_type, "mouse-button-press") == 0) {
|
rfb_decoder_send_pointer_event (src->decoder, src->button_mask,
|
||||||
src->button_mask |= (1 << (button - 1));
|
(gint) x, (gint) y);
|
||||||
GST_LOG_OBJECT (src, "sending mouse-button-press event "
|
break;
|
||||||
"button_mask=%d, x=%d, y=%d", src->button_mask, (gint) x, (gint) y);
|
}
|
||||||
rfb_decoder_send_pointer_event (src->decoder, src->button_mask,
|
case GST_NAVIGATION_EVENT_MOUSE_MOVE:{
|
||||||
(gint) x, (gint) y);
|
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;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -687,9 +687,17 @@ static void
|
||||||
gst_d3d11_video_sink_key_event (GstD3D11Window * window, const gchar * event,
|
gst_d3d11_video_sink_key_event (GstD3D11Window * window, const gchar * event,
|
||||||
const gchar * key, GstD3D11VideoSink * self)
|
const gchar * key, GstD3D11VideoSink * self)
|
||||||
{
|
{
|
||||||
|
GstEvent *key_event = NULL;
|
||||||
|
|
||||||
if (self->enable_navigation_events) {
|
if (self->enable_navigation_events) {
|
||||||
GST_LOG_OBJECT (self, "send key event %s, key %s", event, key);
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -697,11 +705,20 @@ static void
|
||||||
gst_d3d11_video_mouse_key_event (GstD3D11Window * window, const gchar * event,
|
gst_d3d11_video_mouse_key_event (GstD3D11Window * window, const gchar * event,
|
||||||
gint button, gdouble x, gdouble y, GstD3D11VideoSink * self)
|
gint button, gdouble x, gdouble y, GstD3D11VideoSink * self)
|
||||||
{
|
{
|
||||||
|
GstEvent *mouse_event = NULL;
|
||||||
|
|
||||||
if (self->enable_navigation_events) {
|
if (self->enable_navigation_events) {
|
||||||
GST_LOG_OBJECT (self,
|
GST_LOG_OBJECT (self,
|
||||||
"send mouse event %s, button %d (%.1f, %.1f)", event, button, x, y);
|
"send mouse event %s, button %d (%.1f, %.1f)", event, button, x, y);
|
||||||
gst_navigation_send_mouse_event (GST_NAVIGATION (self), event, button, x,
|
if (0 == g_strcmp0 ("mouse-button-press", event))
|
||||||
y);
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1330,10 +1347,9 @@ gst_d3d11_video_sink_video_overlay_init (GstVideoOverlayInterface * iface)
|
||||||
/* Navigation interface */
|
/* Navigation interface */
|
||||||
static void
|
static void
|
||||||
gst_d3d11_video_sink_navigation_send_event (GstNavigation * navigation,
|
gst_d3d11_video_sink_navigation_send_event (GstNavigation * navigation,
|
||||||
GstStructure * structure)
|
GstEvent * event)
|
||||||
{
|
{
|
||||||
GstD3D11VideoSink *self = GST_D3D11_VIDEO_SINK (navigation);
|
GstD3D11VideoSink *self = GST_D3D11_VIDEO_SINK (navigation);
|
||||||
GstEvent *event = gst_event_new_navigation (structure);
|
|
||||||
|
|
||||||
/* TODO: add support for translating native coordinate and video coordinate
|
/* TODO: add support for translating native coordinate and video coordinate
|
||||||
* when force-aspect-ratio is set */
|
* when force-aspect-ratio is set */
|
||||||
|
@ -1354,7 +1370,7 @@ gst_d3d11_video_sink_navigation_send_event (GstNavigation * navigation,
|
||||||
static void
|
static void
|
||||||
gst_d3d11_video_sink_navigation_init (GstNavigationInterface * iface)
|
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
|
static gboolean
|
||||||
|
|
|
@ -2140,11 +2140,11 @@ d3d_wnd_proc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
gchar *utfrep = g_utf16_to_utf8 (wcrep, 128, NULL, NULL, NULL);
|
gchar *utfrep = g_utf16_to_utf8 (wcrep, 128, NULL, NULL, NULL);
|
||||||
if (utfrep) {
|
if (utfrep) {
|
||||||
if (message == WM_KEYDOWN)
|
if (message == WM_KEYDOWN)
|
||||||
gst_navigation_send_key_event (GST_NAVIGATION (sink), "key-press",
|
gst_navigation_send_event_simple (GST_NAVIGATION (sink),
|
||||||
utfrep);
|
gst_navigation_event_new_key_press (utfrep));
|
||||||
else if (message == WM_KEYUP)
|
else if (message == WM_KEYUP)
|
||||||
gst_navigation_send_key_event (GST_NAVIGATION (sink),
|
gst_navigation_send_event_simple (GST_NAVIGATION (sink),
|
||||||
"key-release", utfrep);
|
gst_navigation_event_new_key_release (utfrep));
|
||||||
g_free (utfrep);
|
g_free (utfrep);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2161,45 +2161,38 @@ d3d_wnd_proc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
if (sink->enable_navigation_events
|
if (sink->enable_navigation_events
|
||||||
&& d3d_get_render_coordinates (sink, LOWORD (lParam), HIWORD (lParam),
|
&& d3d_get_render_coordinates (sink, LOWORD (lParam), HIWORD (lParam),
|
||||||
&x, &y)) {
|
&x, &y)) {
|
||||||
gint button;
|
|
||||||
const gchar *action = NULL;
|
|
||||||
switch (message) {
|
switch (message) {
|
||||||
case WM_MOUSEMOVE:
|
case WM_MOUSEMOVE:
|
||||||
button = 0;
|
gst_navigation_send_event_simple (GST_NAVIGATION (sink),
|
||||||
action = "mouse-move";
|
gst_navigation_event_new_mouse_move (x, y));
|
||||||
break;
|
break;
|
||||||
case WM_LBUTTONDOWN:
|
case WM_LBUTTONDOWN:
|
||||||
button = 1;
|
gst_navigation_send_event_simple (GST_NAVIGATION (sink),
|
||||||
action = "mouse-button-press";
|
gst_navigation_event_new_mouse_button_press (1, x, y));
|
||||||
break;
|
break;
|
||||||
case WM_LBUTTONUP:
|
case WM_LBUTTONUP:
|
||||||
button = 1;
|
gst_navigation_send_event_simple (GST_NAVIGATION (sink),
|
||||||
action = "mouse-button-release";
|
gst_navigation_event_new_mouse_button_release (1, x, y));
|
||||||
break;
|
break;
|
||||||
case WM_RBUTTONDOWN:
|
case WM_RBUTTONDOWN:
|
||||||
button = 2;
|
gst_navigation_send_event_simple (GST_NAVIGATION (sink),
|
||||||
action = "mouse-button-press";
|
gst_navigation_event_new_mouse_button_press (2, x, y));
|
||||||
break;
|
break;
|
||||||
case WM_RBUTTONUP:
|
case WM_RBUTTONUP:
|
||||||
button = 2;
|
gst_navigation_send_event_simple (GST_NAVIGATION (sink),
|
||||||
action = "mouse-button-release";
|
gst_navigation_event_new_mouse_button_release (2, x, y));
|
||||||
break;
|
break;
|
||||||
case WM_MBUTTONDOWN:
|
case WM_MBUTTONDOWN:
|
||||||
button = 3;
|
gst_navigation_send_event_simple (GST_NAVIGATION (sink),
|
||||||
action = "mouse-button-press";
|
gst_navigation_event_new_mouse_button_press (3, x, y));
|
||||||
break;
|
break;
|
||||||
case WM_MBUTTONUP:
|
case WM_MBUTTONUP:
|
||||||
button = 3;
|
gst_navigation_send_event_simple (GST_NAVIGATION (sink),
|
||||||
action = "mouse-button-release";
|
gst_navigation_event_new_mouse_button_release (3, x, y));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,7 +70,7 @@ static void gst_d3dvideosink_expose (GstVideoOverlay * overlay);
|
||||||
static void gst_d3dvideosink_navigation_interface_init (GstNavigationInterface *
|
static void gst_d3dvideosink_navigation_interface_init (GstNavigationInterface *
|
||||||
iface);
|
iface);
|
||||||
static void gst_d3dvideosink_navigation_send_event (GstNavigation * navigation,
|
static void gst_d3dvideosink_navigation_send_event (GstNavigation * navigation,
|
||||||
GstStructure * structure);
|
GstEvent * event);
|
||||||
/* GObject */
|
/* GObject */
|
||||||
static void gst_d3dvideosink_set_property (GObject * object, guint prop_id,
|
static void gst_d3dvideosink_set_property (GObject * object, guint prop_id,
|
||||||
const GValue * value, GParamSpec * pspec);
|
const GValue * value, GParamSpec * pspec);
|
||||||
|
@ -580,7 +580,7 @@ gst_d3dvideosink_video_overlay_interface_init (GstVideoOverlayInterface * iface)
|
||||||
static void
|
static void
|
||||||
gst_d3dvideosink_navigation_interface_init (GstNavigationInterface * iface)
|
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 */
|
/* Video Render Code */
|
||||||
|
@ -622,23 +622,19 @@ gst_d3dvideosink_show_frame (GstVideoSink * vsink, GstBuffer * buffer)
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_d3dvideosink_navigation_send_event (GstNavigation * navigation,
|
gst_d3dvideosink_navigation_send_event (GstNavigation * navigation,
|
||||||
GstStructure * structure)
|
GstEvent * event)
|
||||||
{
|
{
|
||||||
GstD3DVideoSink *sink = GST_D3DVIDEOSINK (navigation);
|
GstD3DVideoSink *sink = GST_D3DVIDEOSINK (navigation);
|
||||||
GstEvent *e;
|
|
||||||
|
|
||||||
if ((e = gst_event_new_navigation (structure))) {
|
GstPad *pad;
|
||||||
GstPad *pad;
|
if ((pad = gst_pad_get_peer (GST_VIDEO_SINK_PAD (sink)))) {
|
||||||
if ((pad = gst_pad_get_peer (GST_VIDEO_SINK_PAD (sink)))) {
|
if (!gst_pad_send_event (pad, gst_event_ref (event))) {
|
||||||
if (!gst_pad_send_event (pad, gst_event_ref (e))) {
|
/* If upstream didn't handle the event we'll post a message with it
|
||||||
/* 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 */
|
||||||
* for the application in case it wants to do something with it */
|
gst_element_post_message (GST_ELEMENT_CAST (sink),
|
||||||
gst_element_post_message (GST_ELEMENT_CAST (sink),
|
gst_navigation_message_new_event (GST_OBJECT_CAST (sink), event));
|
||||||
gst_navigation_message_new_event (GST_OBJECT_CAST (sink), e));
|
|
||||||
}
|
|
||||||
gst_event_unref (e);
|
|
||||||
gst_object_unref (pad);
|
|
||||||
}
|
}
|
||||||
|
gst_object_unref (pad);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -155,14 +155,11 @@ gst_dshowvideosink_videooverlay_init (GstVideoOverlayInterface * iface)
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_dshowvideosink_navigation_send_event (GstNavigation * navigation,
|
gst_dshowvideosink_navigation_send_event (GstNavigation * navigation,
|
||||||
GstStructure * structure)
|
GstEvent * event)
|
||||||
{
|
{
|
||||||
GstDshowVideoSink *sink = GST_DSHOWVIDEOSINK (navigation);
|
GstDshowVideoSink *sink = GST_DSHOWVIDEOSINK (navigation);
|
||||||
GstEvent *event = NULL;
|
|
||||||
GstPad *pad = NULL;
|
GstPad *pad = NULL;
|
||||||
|
|
||||||
event = gst_event_new_navigation (structure);
|
|
||||||
|
|
||||||
/* FXIME: handle aspect ratio. */
|
/* FXIME: handle aspect ratio. */
|
||||||
|
|
||||||
pad = gst_pad_get_peer (GST_VIDEO_SINK_PAD (sink));
|
pad = gst_pad_get_peer (GST_VIDEO_SINK_PAD (sink));
|
||||||
|
@ -178,10 +175,9 @@ static void
|
||||||
gst_dshowvideosink_navigation_interface_init (GstNavigationInterface * iface)
|
gst_dshowvideosink_navigation_interface_init (GstNavigationInterface * iface)
|
||||||
{
|
{
|
||||||
/* FIXME: navigation interface partially implemented.
|
/* FIXME: navigation interface partially implemented.
|
||||||
* Need to call gst_navigation_send_mouse_event and
|
* Need to call gst_navigation_send_event_simple and like in directdrawsink.
|
||||||
* gst_navigation_send_key_event like in directdrawsink.
|
|
||||||
*/
|
*/
|
||||||
iface->send_event = gst_dshowvideosink_navigation_send_event;
|
iface->send_event_simple = gst_dshowvideosink_navigation_send_event;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -1885,7 +1885,6 @@ gst_va_vpp_src_event (GstBaseTransform * trans, GstEvent * event)
|
||||||
{
|
{
|
||||||
GstVaVpp *self = GST_VA_VPP (trans);
|
GstVaVpp *self = GST_VA_VPP (trans);
|
||||||
GstVaBaseTransform *btrans = GST_VA_BASE_TRANSFORM (trans);
|
GstVaBaseTransform *btrans = GST_VA_BASE_TRANSFORM (trans);
|
||||||
GstStructure *structure;
|
|
||||||
const GstVideoInfo *in_info = &btrans->in_info, *out_info = &btrans->out_info;
|
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;
|
gdouble new_x = 0, new_y = 0, x = 0, y = 0, w_factor = 1, h_factor = 1;
|
||||||
gboolean ret;
|
gboolean ret;
|
||||||
|
@ -1899,12 +1898,9 @@ gst_va_vpp_src_event (GstBaseTransform * trans, GstEvent * event)
|
||||||
|| gst_va_filter_get_orientation (btrans->filter) !=
|
|| gst_va_filter_get_orientation (btrans->filter) !=
|
||||||
GST_VIDEO_ORIENTATION_IDENTITY) {
|
GST_VIDEO_ORIENTATION_IDENTITY) {
|
||||||
|
|
||||||
event =
|
event = gst_event_make_writable (event);
|
||||||
GST_EVENT (gst_mini_object_make_writable (GST_MINI_OBJECT (event)));
|
|
||||||
|
|
||||||
structure = (GstStructure *) gst_event_get_structure (event);
|
if (!gst_navigation_event_get_coordinates (event, &x, &y))
|
||||||
if (!gst_structure_get_double (structure, "pointer_x", &x)
|
|
||||||
|| !gst_structure_get_double (structure, "pointer_y", &y))
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* video-direction compensation */
|
/* video-direction compensation */
|
||||||
|
@ -1952,8 +1948,7 @@ gst_va_vpp_src_event (GstBaseTransform * trans, GstEvent * event)
|
||||||
/* crop compensation is done by videocrop */
|
/* crop compensation is done by videocrop */
|
||||||
|
|
||||||
GST_TRACE_OBJECT (self, "from %fx%f to %fx%f", x, y, new_x, new_y);
|
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,
|
gst_navigation_event_set_coordinates (event, new_x, new_y);
|
||||||
"pointer_y", G_TYPE_DOUBLE, new_y, NULL);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <gst/check/gstcheck.h>
|
#include <gst/check/gstcheck.h>
|
||||||
|
#include <gst/video/navigation.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#ifndef HAVE_PIPE2
|
#ifndef HAVE_PIPE2
|
||||||
|
@ -2988,32 +2989,29 @@ navigation_probe_source (GstPad * pad, GstPadProbeInfo * info,
|
||||||
{
|
{
|
||||||
test_data *td = user_data;
|
test_data *td = user_data;
|
||||||
navigation_master_data *d = td->md;
|
navigation_master_data *d = td->md;
|
||||||
const GstStructure *s;
|
GstEvent *e;
|
||||||
const gchar *string, *key;
|
const gchar *key;
|
||||||
double x, y;
|
double x, y;
|
||||||
|
|
||||||
if (GST_IS_EVENT (info->data)) {
|
if (GST_IS_EVENT (info->data)) {
|
||||||
if (GST_EVENT_TYPE (info->data) == GST_EVENT_NAVIGATION) {
|
if (GST_EVENT_TYPE (info->data) == GST_EVENT_NAVIGATION) {
|
||||||
s = gst_event_get_structure (info->data);
|
e = GST_EVENT (info->data);
|
||||||
FAIL_UNLESS (s);
|
|
||||||
|
|
||||||
/* mouse-move */
|
switch (gst_navigation_event_get_type (e)) {
|
||||||
string = gst_structure_get_string (s, "event");
|
case GST_NAVIGATION_EVENT_MOUSE_MOVE:
|
||||||
if (string && !strcmp (string, "mouse-move")) {
|
gst_navigation_event_parse_mouse_move_event (e, &x, &y);
|
||||||
if (gst_structure_get_double (s, "pointer_x", &x) && x == 4.7) {
|
if (x == 4.7 && y == 0.1)
|
||||||
if (gst_structure_get_double (s, "pointer_y", &y) && y == 0.1) {
|
|
||||||
d->navigation_received[TEST_NAV_MOUSE_MOVE] = TRUE;
|
d->navigation_received[TEST_NAV_MOUSE_MOVE] = TRUE;
|
||||||
}
|
break;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* key-press */
|
case GST_NAVIGATION_EVENT_KEY_PRESS:
|
||||||
string = gst_structure_get_string (s, "event");
|
gst_navigation_event_parse_key_event (e, &key);
|
||||||
if (string && !strcmp (string, "key-press")) {
|
if (!strcmp (key, "Left"))
|
||||||
key = gst_structure_get_string (s, "key");
|
d->navigation_received[TEST_NAV_KEY_PRESS] = TRUE;
|
||||||
if (key && !strcmp (key, "Left")) {
|
break;
|
||||||
d->navigation_received[TEST_NAV_KEY_PRESS] = TRUE;
|
|
||||||
}
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* drop at this point to imply successful handling; the upstream filesrc
|
/* drop at this point to imply successful handling; the upstream filesrc
|
||||||
|
@ -3067,7 +3065,6 @@ send_navigation_event (const GValue * v, gpointer user_data)
|
||||||
navigation_slave_data *d = td->sd;
|
navigation_slave_data *d = td->sd;
|
||||||
GstElement *sink;
|
GstElement *sink;
|
||||||
GstPad *pad, *peer;
|
GstPad *pad, *peer;
|
||||||
GstStructure *s;
|
|
||||||
GstEvent *e = NULL;
|
GstEvent *e = NULL;
|
||||||
|
|
||||||
sink = g_value_get_object (v);
|
sink = g_value_get_object (v);
|
||||||
|
@ -3080,15 +3077,10 @@ send_navigation_event (const GValue * v, gpointer user_data)
|
||||||
|
|
||||||
switch (d->step) {
|
switch (d->step) {
|
||||||
case TEST_NAV_MOUSE_MOVE:
|
case TEST_NAV_MOUSE_MOVE:
|
||||||
s = gst_structure_new ("application/x-gst-navigation", "event",
|
e = gst_navigation_event_new_mouse_move (4.7, 0.1);
|
||||||
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);
|
|
||||||
break;
|
break;
|
||||||
case TEST_NAV_KEY_PRESS:
|
case TEST_NAV_KEY_PRESS:
|
||||||
s = gst_structure_new ("application/x-gst-navigation", "event",
|
e = gst_navigation_event_new_key_press ("Left");
|
||||||
G_TYPE_STRING, "key-press", "key", G_TYPE_STRING, "Left", NULL);
|
|
||||||
e = gst_event_new_navigation (s);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -595,21 +595,22 @@ gst_glimage_sink_set_rotate_method (GstGLImageSink * gl_sink,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_glimage_sink_navigation_send_event (GstNavigation * navigation, GstStructure
|
gst_glimage_sink_navigation_send_event (GstNavigation * navigation,
|
||||||
* structure)
|
GstEvent * event)
|
||||||
{
|
{
|
||||||
GstGLImageSink *sink = GST_GLIMAGE_SINK (navigation);
|
GstGLImageSink *sink = GST_GLIMAGE_SINK (navigation);
|
||||||
gboolean handled = FALSE;
|
gboolean handled = FALSE;
|
||||||
GstEvent *event = NULL;
|
|
||||||
GstGLWindow *window;
|
GstGLWindow *window;
|
||||||
guint width, height;
|
guint width, height;
|
||||||
gdouble x, y;
|
gdouble x, y;
|
||||||
|
|
||||||
if (!sink->context) {
|
if (!sink->context) {
|
||||||
gst_structure_free (structure);
|
gst_event_unref (event);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
event = gst_event_make_writable (event);
|
||||||
|
|
||||||
window = gst_gl_context_get_window (sink->context);
|
window = gst_gl_context_get_window (sink->context);
|
||||||
g_return_if_fail (GST_IS_GL_WINDOW (window));
|
g_return_if_fail (GST_IS_GL_WINDOW (window));
|
||||||
|
|
||||||
|
@ -618,47 +619,43 @@ gst_glimage_sink_navigation_send_event (GstNavigation * navigation, GstStructure
|
||||||
gst_gl_window_get_surface_dimensions (window, &width, &height);
|
gst_gl_window_get_surface_dimensions (window, &width, &height);
|
||||||
|
|
||||||
/* Converting pointer coordinates to the non scaled geometry */
|
/* Converting pointer coordinates to the non scaled geometry */
|
||||||
if (width != 0 && gst_structure_get_double (structure, "pointer_x", &x)
|
if (width != 0 && height != 0 &&
|
||||||
&& height != 0 && gst_structure_get_double (structure, "pointer_y", &y)) {
|
gst_navigation_event_get_coordinates (event, &x, &y)) {
|
||||||
gdouble stream_x, stream_y;
|
gdouble stream_x, stream_y;
|
||||||
|
|
||||||
_display_size_to_stream_size (sink, x, y, &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,
|
gst_navigation_event_set_coordinates (event, stream_x, stream_y);
|
||||||
stream_x, "pointer_y", G_TYPE_DOUBLE, stream_y, NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Converting pointer scroll coordinates to the non scaled geometry */
|
/* Converting pointer scroll coordinates to the non scaled geometry */
|
||||||
if (width != 0 && gst_structure_get_double (structure, "delta_pointer_x", &x)
|
if (width != 0 && height != 0 && gst_navigation_event_get_type (event)
|
||||||
&& height != 0
|
== GST_NAVIGATION_EVENT_MOUSE_SCROLL) {
|
||||||
&& gst_structure_get_double (structure, "delta_pointer_y", &y)) {
|
gdouble dx, dy, stream_dx, stream_dy;
|
||||||
gdouble stream_x, stream_y;
|
|
||||||
|
|
||||||
_display_scroll_value_to_stream_scroll_value (sink, x, y, &stream_x,
|
gst_navigation_event_parse_mouse_scroll_event (event, &x, &y, &dx, &dy);
|
||||||
&stream_y);
|
_display_scroll_value_to_stream_scroll_value (sink, dx, dy, &stream_dx,
|
||||||
|
&stream_dy);
|
||||||
|
|
||||||
gst_structure_set (structure, "delta_pointer_x", G_TYPE_DOUBLE,
|
gst_event_replace (&event,
|
||||||
stream_x, "delta_pointer_y", G_TYPE_DOUBLE, stream_y, NULL);
|
gst_navigation_event_new_mouse_scroll (x, y, stream_dx, stream_dy));
|
||||||
}
|
}
|
||||||
|
|
||||||
event = gst_event_new_navigation (structure);
|
gst_event_ref (event);
|
||||||
if (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)
|
if (!handled)
|
||||||
gst_element_post_message ((GstElement *) sink,
|
gst_element_post_message ((GstElement *) sink,
|
||||||
gst_navigation_message_new_event ((GstObject *) sink, event));
|
gst_navigation_message_new_event ((GstObject *) sink, event));
|
||||||
|
|
||||||
gst_event_unref (event);
|
gst_event_unref (event);
|
||||||
}
|
|
||||||
gst_object_unref (window);
|
gst_object_unref (window);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_glimage_sink_navigation_interface_init (GstNavigationInterface * iface)
|
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
|
#define gst_glimage_sink_parent_class parent_class
|
||||||
|
@ -946,18 +943,34 @@ static void
|
||||||
gst_glimage_sink_key_event_cb (GstGLWindow * window, char *event_name, char
|
gst_glimage_sink_key_event_cb (GstGLWindow * window, char *event_name, char
|
||||||
*key_string, GstGLImageSink * gl_sink)
|
*key_string, GstGLImageSink * gl_sink)
|
||||||
{
|
{
|
||||||
|
GstEvent *event = NULL;
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (gl_sink, "event %s key %s pressed", event_name, key_string);
|
GST_DEBUG_OBJECT (gl_sink, "event %s key %s pressed", event_name, key_string);
|
||||||
gst_navigation_send_key_event (GST_NAVIGATION (gl_sink),
|
if (0 == g_strcmp0 ("key-press", event_name))
|
||||||
event_name, key_string);
|
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
|
static void
|
||||||
gst_glimage_sink_mouse_event_cb (GstGLWindow * window, char *event_name,
|
gst_glimage_sink_mouse_event_cb (GstGLWindow * window, char *event_name,
|
||||||
int button, double posx, double posy, GstGLImageSink * gl_sink)
|
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_DEBUG_OBJECT (gl_sink, "event %s at %g, %g", event_name, posx, posy);
|
||||||
gst_navigation_send_mouse_event (GST_NAVIGATION (gl_sink),
|
if (0 == g_strcmp0 ("mouse-button-press", event_name))
|
||||||
event_name, button, posx, posy);
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -967,8 +980,8 @@ gst_glimage_sink_mouse_scroll_event_cb (GstGLWindow * window,
|
||||||
GstGLImageSink * gl_sink)
|
GstGLImageSink * gl_sink)
|
||||||
{
|
{
|
||||||
GST_DEBUG_OBJECT (gl_sink, "event scroll at %g, %g", posx, posy);
|
GST_DEBUG_OBJECT (gl_sink, "event scroll at %g, %g", posx, posy);
|
||||||
gst_navigation_send_mouse_scroll_event (GST_NAVIGATION (gl_sink),
|
gst_navigation_send_event_simple (GST_NAVIGATION (gl_sink),
|
||||||
posx, posy, delta_x, delta_y);
|
gst_navigation_event_new_mouse_scroll (posx, posy, delta_x, delta_y));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -447,20 +447,17 @@ gst_gl_sink_bin_change_state (GstElement * element, GstStateChange transition)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_gl_sink_bin_navigation_send_event (GstNavigation * navigation, GstStructure
|
gst_gl_sink_bin_navigation_send_event (GstNavigation * navigation,
|
||||||
* structure)
|
GstEvent * event)
|
||||||
{
|
{
|
||||||
GstGLSinkBin *self = GST_GL_SINK_BIN (navigation);
|
GstGLSinkBin *self = GST_GL_SINK_BIN (navigation);
|
||||||
GstElement *nav =
|
GstElement *nav =
|
||||||
gst_bin_get_by_interface (GST_BIN (self), GST_TYPE_NAVIGATION);
|
gst_bin_get_by_interface (GST_BIN (self), GST_TYPE_NAVIGATION);
|
||||||
|
|
||||||
if (nav) {
|
if (nav) {
|
||||||
gst_navigation_send_event (GST_NAVIGATION (nav), structure);
|
gst_navigation_send_event_simple (GST_NAVIGATION (nav), event);
|
||||||
structure = NULL;
|
|
||||||
gst_object_unref (nav);
|
gst_object_unref (nav);
|
||||||
} else {
|
} else {
|
||||||
GstEvent *event = gst_event_new_navigation (structure);
|
|
||||||
structure = NULL;
|
|
||||||
gst_element_send_event (GST_ELEMENT (self), event);
|
gst_element_send_event (GST_ELEMENT (self), event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -470,7 +467,7 @@ gst_gl_sink_bin_navigation_interface_init (gpointer g_iface,
|
||||||
gpointer g_iface_data)
|
gpointer g_iface_data)
|
||||||
{
|
{
|
||||||
GstNavigationInterface *iface = (GstNavigationInterface *) g_iface;
|
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
|
static void
|
||||||
|
|
|
@ -658,7 +658,6 @@ static gboolean
|
||||||
gst_gl_transformation_src_event (GstBaseTransform * trans, GstEvent * event)
|
gst_gl_transformation_src_event (GstBaseTransform * trans, GstEvent * event)
|
||||||
{
|
{
|
||||||
GstGLTransformation *transformation = GST_GL_TRANSFORMATION (trans);
|
GstGLTransformation *transformation = GST_GL_TRANSFORMATION (trans);
|
||||||
GstStructure *structure;
|
|
||||||
gboolean ret;
|
gboolean ret;
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (trans, "handling %s event", GST_EVENT_TYPE_NAME (event));
|
GST_DEBUG_OBJECT (trans, "handling %s event", GST_EVENT_TYPE_NAME (event));
|
||||||
|
@ -666,12 +665,9 @@ gst_gl_transformation_src_event (GstBaseTransform * trans, GstEvent * event)
|
||||||
switch (GST_EVENT_TYPE (event)) {
|
switch (GST_EVENT_TYPE (event)) {
|
||||||
case GST_EVENT_NAVIGATION:{
|
case GST_EVENT_NAVIGATION:{
|
||||||
gdouble x, y;
|
gdouble x, y;
|
||||||
event =
|
event = gst_event_make_writable (event);
|
||||||
GST_EVENT (gst_mini_object_make_writable (GST_MINI_OBJECT (event)));
|
|
||||||
|
|
||||||
structure = (GstStructure *) gst_event_get_structure (event);
|
if (gst_navigation_event_get_coordinates (event, &x, &y)) {
|
||||||
if (gst_structure_get_double (structure, "pointer_x", &x) &&
|
|
||||||
gst_structure_get_double (structure, "pointer_y", &y)) {
|
|
||||||
gdouble new_x, new_y;
|
gdouble new_x, new_y;
|
||||||
|
|
||||||
if (!_screen_coord_to_model_coord (transformation, x, y, &new_x,
|
if (!_screen_coord_to_model_coord (transformation, x, y, &new_x,
|
||||||
|
@ -680,8 +676,7 @@ gst_gl_transformation_src_event (GstBaseTransform * trans, GstEvent * event)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
gst_structure_set (structure, "pointer_x", G_TYPE_DOUBLE, new_x,
|
gst_navigation_event_set_coordinates (event, x, y);
|
||||||
"pointer_y", G_TYPE_DOUBLE, new_y, NULL);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6041,11 +6041,11 @@ gst_play_bin_overlay_init (gpointer g_iface, gpointer g_iface_data)
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_play_bin_navigation_send_event (GstNavigation * navigation,
|
gst_play_bin_navigation_send_event (GstNavigation * navigation,
|
||||||
GstStructure * structure)
|
GstEvent * event)
|
||||||
{
|
{
|
||||||
GstPlayBin *playbin = GST_PLAY_BIN (navigation);
|
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
|
static void
|
||||||
|
@ -6053,7 +6053,7 @@ gst_play_bin_navigation_init (gpointer g_iface, gpointer g_iface_data)
|
||||||
{
|
{
|
||||||
GstNavigationInterface *iface = (GstNavigationInterface *) g_iface;
|
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 const GList *
|
||||||
|
|
|
@ -5149,11 +5149,11 @@ gst_play_bin3_overlay_init (gpointer g_iface, gpointer g_iface_data)
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_play_bin3_navigation_send_event (GstNavigation * navigation,
|
gst_play_bin3_navigation_send_event (GstNavigation * navigation,
|
||||||
GstStructure * structure)
|
GstEvent * event)
|
||||||
{
|
{
|
||||||
GstPlayBin3 *playbin = GST_PLAY_BIN3 (navigation);
|
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
|
static void
|
||||||
|
@ -5161,7 +5161,7 @@ gst_play_bin3_navigation_init (gpointer g_iface, gpointer g_iface_data)
|
||||||
{
|
{
|
||||||
GstNavigationInterface *iface = (GstNavigationInterface *) g_iface;
|
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 const GList *
|
||||||
|
|
|
@ -5437,7 +5437,7 @@ gst_play_sink_overlay_init (gpointer g_iface, gpointer g_iface_data)
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_play_sink_navigation_send_event (GstNavigation * navigation,
|
gst_play_sink_navigation_send_event (GstNavigation * navigation,
|
||||||
GstStructure * structure)
|
GstEvent * event)
|
||||||
{
|
{
|
||||||
GstPlaySink *playsink = GST_PLAY_SINK (navigation);
|
GstPlaySink *playsink = GST_PLAY_SINK (navigation);
|
||||||
GstBin *bin = NULL;
|
GstBin *bin = NULL;
|
||||||
|
@ -5451,20 +5451,14 @@ gst_play_sink_navigation_send_event (GstNavigation * navigation,
|
||||||
GstElement *nav = gst_bin_get_by_interface (bin, GST_TYPE_NAVIGATION);
|
GstElement *nav = gst_bin_get_by_interface (bin, GST_TYPE_NAVIGATION);
|
||||||
|
|
||||||
if (nav) {
|
if (nav) {
|
||||||
gst_navigation_send_event (GST_NAVIGATION (nav), structure);
|
gst_navigation_send_event_simple (GST_NAVIGATION (nav), event);
|
||||||
structure = NULL;
|
|
||||||
gst_object_unref (nav);
|
gst_object_unref (nav);
|
||||||
} else {
|
} else {
|
||||||
GstEvent *event = gst_event_new_navigation (structure);
|
|
||||||
structure = NULL;
|
|
||||||
gst_element_send_event (GST_ELEMENT (bin), event);
|
gst_element_send_event (GST_ELEMENT (bin), event);
|
||||||
}
|
}
|
||||||
|
|
||||||
gst_object_unref (bin);
|
gst_object_unref (bin);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (structure)
|
|
||||||
gst_structure_free (structure);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -5472,7 +5466,7 @@ gst_play_sink_navigation_init (gpointer g_iface, gpointer g_iface_data)
|
||||||
{
|
{
|
||||||
GstNavigationInterface *iface = (GstNavigationInterface *) g_iface;
|
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 *
|
static const GList *
|
||||||
|
|
|
@ -1193,8 +1193,7 @@ gst_video_scale_src_event (GstBaseTransform * trans, GstEvent * event)
|
||||||
GstVideoScale *videoscale = GST_VIDEO_SCALE_CAST (trans);
|
GstVideoScale *videoscale = GST_VIDEO_SCALE_CAST (trans);
|
||||||
GstVideoFilter *filter = GST_VIDEO_FILTER_CAST (trans);
|
GstVideoFilter *filter = GST_VIDEO_FILTER_CAST (trans);
|
||||||
gboolean ret;
|
gboolean ret;
|
||||||
gdouble a;
|
gdouble x, y;
|
||||||
GstStructure *structure;
|
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (videoscale, "handling %s event",
|
GST_DEBUG_OBJECT (videoscale, "handling %s event",
|
||||||
GST_EVENT_TYPE_NAME (event));
|
GST_EVENT_TYPE_NAME (event));
|
||||||
|
@ -1203,17 +1202,12 @@ gst_video_scale_src_event (GstBaseTransform * trans, GstEvent * event)
|
||||||
case GST_EVENT_NAVIGATION:
|
case GST_EVENT_NAVIGATION:
|
||||||
if (filter->in_info.width != filter->out_info.width ||
|
if (filter->in_info.width != filter->out_info.width ||
|
||||||
filter->in_info.height != filter->out_info.height) {
|
filter->in_info.height != filter->out_info.height) {
|
||||||
event =
|
event = gst_event_make_writable (event);
|
||||||
GST_EVENT (gst_mini_object_make_writable (GST_MINI_OBJECT (event)));
|
|
||||||
|
|
||||||
structure = (GstStructure *) gst_event_get_structure (event);
|
if (gst_navigation_event_get_coordinates (event, &x, &y)) {
|
||||||
if (gst_structure_get_double (structure, "pointer_x", &a)) {
|
gst_navigation_event_set_coordinates (event,
|
||||||
gst_structure_set (structure, "pointer_x", G_TYPE_DOUBLE,
|
x * filter->in_info.width / filter->out_info.width,
|
||||||
a * filter->in_info.width / filter->out_info.width, NULL);
|
y * filter->in_info.height / filter->out_info.height);
|
||||||
}
|
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -610,8 +610,8 @@ gst_x_image_sink_handle_xevents (GstXImageSink * ximagesink)
|
||||||
|
|
||||||
GST_DEBUG ("ximagesink pointer moved over window at %d,%d",
|
GST_DEBUG ("ximagesink pointer moved over window at %d,%d",
|
||||||
pointer_x, pointer_y);
|
pointer_x, pointer_y);
|
||||||
gst_navigation_send_mouse_event (GST_NAVIGATION (ximagesink),
|
gst_navigation_send_event_simple (GST_NAVIGATION (ximagesink),
|
||||||
"mouse-move", 0, pointer_x, pointer_y);
|
gst_navigation_event_new_mouse_move (pointer_x, pointer_y));
|
||||||
|
|
||||||
g_mutex_lock (&ximagesink->flow_lock);
|
g_mutex_lock (&ximagesink->flow_lock);
|
||||||
g_mutex_lock (&ximagesink->x_lock);
|
g_mutex_lock (&ximagesink->x_lock);
|
||||||
|
@ -635,14 +635,16 @@ gst_x_image_sink_handle_xevents (GstXImageSink * ximagesink)
|
||||||
events for interactivity/navigation */
|
events for interactivity/navigation */
|
||||||
GST_DEBUG ("ximagesink button %d pressed over window at %d,%d",
|
GST_DEBUG ("ximagesink button %d pressed over window at %d,%d",
|
||||||
e.xbutton.button, e.xbutton.x, e.xbutton.x);
|
e.xbutton.button, e.xbutton.x, e.xbutton.x);
|
||||||
gst_navigation_send_mouse_event (GST_NAVIGATION (ximagesink),
|
gst_navigation_send_event_simple (GST_NAVIGATION (ximagesink),
|
||||||
"mouse-button-press", e.xbutton.button, e.xbutton.x, e.xbutton.y);
|
gst_navigation_event_new_mouse_button_press (e.xbutton.button,
|
||||||
|
e.xbutton.x, e.xbutton.y));
|
||||||
break;
|
break;
|
||||||
case ButtonRelease:
|
case ButtonRelease:
|
||||||
GST_DEBUG ("ximagesink button %d release over window at %d,%d",
|
GST_DEBUG ("ximagesink button %d release over window at %d,%d",
|
||||||
e.xbutton.button, e.xbutton.x, e.xbutton.x);
|
e.xbutton.button, e.xbutton.x, e.xbutton.x);
|
||||||
gst_navigation_send_mouse_event (GST_NAVIGATION (ximagesink),
|
gst_navigation_send_event_simple (GST_NAVIGATION (ximagesink),
|
||||||
"mouse-button-release", e.xbutton.button, e.xbutton.x, e.xbutton.y);
|
gst_navigation_event_new_mouse_button_release (e.xbutton.button,
|
||||||
|
e.xbutton.x, e.xbutton.y));
|
||||||
break;
|
break;
|
||||||
case KeyPress:
|
case KeyPress:
|
||||||
case KeyRelease:
|
case KeyRelease:
|
||||||
|
@ -665,8 +667,10 @@ gst_x_image_sink_handle_xevents (GstXImageSink * ximagesink)
|
||||||
GST_DEBUG_OBJECT (ximagesink,
|
GST_DEBUG_OBJECT (ximagesink,
|
||||||
"key %d pressed over window at %d,%d (%s)",
|
"key %d pressed over window at %d,%d (%s)",
|
||||||
e.xkey.keycode, e.xkey.x, e.xkey.y, key_str);
|
e.xkey.keycode, e.xkey.x, e.xkey.y, key_str);
|
||||||
gst_navigation_send_key_event (GST_NAVIGATION (ximagesink),
|
gst_navigation_send_event_simple (GST_NAVIGATION (ximagesink),
|
||||||
e.type == KeyPress ? "key-press" : "key-release", key_str);
|
(e.type == KeyPress) ?
|
||||||
|
gst_navigation_event_new_key_press (key_str) :
|
||||||
|
gst_navigation_event_new_key_release (key_str));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
GST_DEBUG_OBJECT (ximagesink, "ximagesink unhandled X event (%d)",
|
GST_DEBUG_OBJECT (ximagesink, "ximagesink unhandled X event (%d)",
|
||||||
|
@ -1550,10 +1554,9 @@ no_pool:
|
||||||
/* Interfaces stuff */
|
/* Interfaces stuff */
|
||||||
static void
|
static void
|
||||||
gst_x_image_sink_navigation_send_event (GstNavigation * navigation,
|
gst_x_image_sink_navigation_send_event (GstNavigation * navigation,
|
||||||
GstStructure * structure)
|
GstEvent * event)
|
||||||
{
|
{
|
||||||
GstXImageSink *ximagesink = GST_X_IMAGE_SINK (navigation);
|
GstXImageSink *ximagesink = GST_X_IMAGE_SINK (navigation);
|
||||||
GstEvent *event = NULL;
|
|
||||||
gint x_offset, y_offset;
|
gint x_offset, y_offset;
|
||||||
gdouble x, y;
|
gdouble x, y;
|
||||||
gboolean handled = FALSE;
|
gboolean handled = FALSE;
|
||||||
|
@ -1569,42 +1572,37 @@ gst_x_image_sink_navigation_send_event (GstNavigation * navigation,
|
||||||
|
|
||||||
if (!ximagesink->xwindow) {
|
if (!ximagesink->xwindow) {
|
||||||
g_mutex_unlock (&ximagesink->flow_lock);
|
g_mutex_unlock (&ximagesink->flow_lock);
|
||||||
gst_structure_free (structure);
|
gst_event_unref (event);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
event = gst_event_make_writable (event);
|
||||||
|
|
||||||
x_offset = ximagesink->xwindow->width - GST_VIDEO_SINK_WIDTH (ximagesink);
|
x_offset = ximagesink->xwindow->width - GST_VIDEO_SINK_WIDTH (ximagesink);
|
||||||
y_offset = ximagesink->xwindow->height - GST_VIDEO_SINK_HEIGHT (ximagesink);
|
y_offset = ximagesink->xwindow->height - GST_VIDEO_SINK_HEIGHT (ximagesink);
|
||||||
|
|
||||||
g_mutex_unlock (&ximagesink->flow_lock);
|
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;
|
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;
|
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);
|
gst_event_ref (event);
|
||||||
if (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)
|
if (!handled)
|
||||||
gst_element_post_message (GST_ELEMENT_CAST (ximagesink),
|
gst_element_post_message (GST_ELEMENT_CAST (ximagesink),
|
||||||
gst_navigation_message_new_event (GST_OBJECT_CAST (ximagesink),
|
gst_navigation_message_new_event (GST_OBJECT_CAST (ximagesink), event));
|
||||||
event));
|
|
||||||
|
|
||||||
gst_event_unref (event);
|
gst_event_unref (event);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_x_image_sink_navigation_init (GstNavigationInterface * iface)
|
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
|
static void
|
||||||
|
|
|
@ -453,8 +453,8 @@ gst_xv_image_sink_handle_xevents (GstXvImageSink * xvimagesink)
|
||||||
|
|
||||||
GST_DEBUG ("xvimagesink pointer moved over window at %d,%d",
|
GST_DEBUG ("xvimagesink pointer moved over window at %d,%d",
|
||||||
pointer_x, pointer_y);
|
pointer_x, pointer_y);
|
||||||
gst_navigation_send_mouse_event (GST_NAVIGATION (xvimagesink),
|
gst_navigation_send_event_simple (GST_NAVIGATION (xvimagesink),
|
||||||
"mouse-move", 0, e.xbutton.x, e.xbutton.y);
|
gst_navigation_event_new_mouse_move (e.xbutton.x, e.xbutton.y));
|
||||||
|
|
||||||
g_mutex_lock (&xvimagesink->flow_lock);
|
g_mutex_lock (&xvimagesink->flow_lock);
|
||||||
g_mutex_lock (&xvimagesink->context->lock);
|
g_mutex_lock (&xvimagesink->context->lock);
|
||||||
|
@ -478,16 +478,18 @@ gst_xv_image_sink_handle_xevents (GstXvImageSink * xvimagesink)
|
||||||
events for interactivity/navigation */
|
events for interactivity/navigation */
|
||||||
GST_DEBUG ("xvimagesink button %d pressed over window at %d,%d",
|
GST_DEBUG ("xvimagesink button %d pressed over window at %d,%d",
|
||||||
e.xbutton.button, e.xbutton.x, e.xbutton.y);
|
e.xbutton.button, e.xbutton.x, e.xbutton.y);
|
||||||
gst_navigation_send_mouse_event (GST_NAVIGATION (xvimagesink),
|
gst_navigation_send_event_simple (GST_NAVIGATION (xvimagesink),
|
||||||
"mouse-button-press", e.xbutton.button, e.xbutton.x, e.xbutton.y);
|
gst_navigation_event_new_mouse_button_press (e.xbutton.button,
|
||||||
|
e.xbutton.x, e.xbutton.y));
|
||||||
break;
|
break;
|
||||||
case ButtonRelease:
|
case ButtonRelease:
|
||||||
/* Mouse button released over our window. We send upstream
|
/* Mouse button released over our window. We send upstream
|
||||||
events for interactivity/navigation */
|
events for interactivity/navigation */
|
||||||
GST_DEBUG ("xvimagesink button %d released over window at %d,%d",
|
GST_DEBUG ("xvimagesink button %d released over window at %d,%d",
|
||||||
e.xbutton.button, e.xbutton.x, e.xbutton.y);
|
e.xbutton.button, e.xbutton.x, e.xbutton.y);
|
||||||
gst_navigation_send_mouse_event (GST_NAVIGATION (xvimagesink),
|
gst_navigation_send_event_simple (GST_NAVIGATION (xvimagesink),
|
||||||
"mouse-button-release", e.xbutton.button, e.xbutton.x, e.xbutton.y);
|
gst_navigation_event_new_mouse_button_release (e.xbutton.button,
|
||||||
|
e.xbutton.x, e.xbutton.y));
|
||||||
break;
|
break;
|
||||||
case KeyPress:
|
case KeyPress:
|
||||||
case KeyRelease:
|
case KeyRelease:
|
||||||
|
@ -510,8 +512,10 @@ gst_xv_image_sink_handle_xevents (GstXvImageSink * xvimagesink)
|
||||||
GST_DEBUG_OBJECT (xvimagesink,
|
GST_DEBUG_OBJECT (xvimagesink,
|
||||||
"key %d pressed over window at %d,%d (%s)",
|
"key %d pressed over window at %d,%d (%s)",
|
||||||
e.xkey.keycode, e.xkey.x, e.xkey.y, key_str);
|
e.xkey.keycode, e.xkey.x, e.xkey.y, key_str);
|
||||||
gst_navigation_send_key_event (GST_NAVIGATION (xvimagesink),
|
gst_navigation_send_event_simple (GST_NAVIGATION (xvimagesink),
|
||||||
e.type == KeyPress ? "key-press" : "key-release", key_str);
|
(e.type == KeyPress) ?
|
||||||
|
gst_navigation_event_new_key_press (key_str) :
|
||||||
|
gst_navigation_event_new_key_release (key_str));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
GST_DEBUG_OBJECT (xvimagesink, "xvimagesink unhandled X event (%d)",
|
GST_DEBUG_OBJECT (xvimagesink, "xvimagesink unhandled X event (%d)",
|
||||||
|
@ -1147,11 +1151,10 @@ no_pool:
|
||||||
/* Interfaces stuff */
|
/* Interfaces stuff */
|
||||||
static void
|
static void
|
||||||
gst_xv_image_sink_navigation_send_event (GstNavigation * navigation,
|
gst_xv_image_sink_navigation_send_event (GstNavigation * navigation,
|
||||||
GstStructure * structure)
|
GstEvent * event)
|
||||||
{
|
{
|
||||||
GstXvImageSink *xvimagesink = GST_XV_IMAGE_SINK (navigation);
|
GstXvImageSink *xvimagesink = GST_XV_IMAGE_SINK (navigation);
|
||||||
gboolean handled = FALSE;
|
gboolean handled = FALSE;
|
||||||
GstEvent *event = NULL;
|
|
||||||
|
|
||||||
GstVideoRectangle src = { 0, };
|
GstVideoRectangle src = { 0, };
|
||||||
GstVideoRectangle dst = { 0, };
|
GstVideoRectangle dst = { 0, };
|
||||||
|
@ -1164,7 +1167,7 @@ gst_xv_image_sink_navigation_send_event (GstNavigation * navigation,
|
||||||
|
|
||||||
if (!(xwindow = xvimagesink->xwindow)) {
|
if (!(xwindow = xvimagesink->xwindow)) {
|
||||||
g_mutex_unlock (&xvimagesink->flow_lock);
|
g_mutex_unlock (&xvimagesink->flow_lock);
|
||||||
gst_structure_free (structure);
|
gst_event_unref (event);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1190,37 +1193,31 @@ gst_xv_image_sink_navigation_send_event (GstNavigation * navigation,
|
||||||
xscale = (gdouble) xvimagesink->video_width / result.w;
|
xscale = (gdouble) xvimagesink->video_width / result.w;
|
||||||
yscale = (gdouble) xvimagesink->video_height / result.h;
|
yscale = (gdouble) xvimagesink->video_height / result.h;
|
||||||
|
|
||||||
|
event = gst_event_make_writable (event);
|
||||||
|
|
||||||
/* Converting pointer coordinates to the non scaled geometry */
|
/* 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 = MIN (x, result.x + result.w);
|
||||||
x = MAX (x - result.x, 0);
|
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 = MIN (y, result.y + result.h);
|
||||||
y = MAX (y - result.y, 0);
|
y = MAX (y - result.y, 0);
|
||||||
gst_structure_set (structure, "pointer_y", G_TYPE_DOUBLE,
|
gst_navigation_event_set_coordinates (event, x * xscale, y * yscale);
|
||||||
(gdouble) y * yscale, NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
event = gst_event_new_navigation (structure);
|
gst_event_ref (event);
|
||||||
if (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)
|
if (!handled)
|
||||||
gst_element_post_message ((GstElement *) xvimagesink,
|
gst_element_post_message ((GstElement *) xvimagesink,
|
||||||
gst_navigation_message_new_event ((GstObject *) xvimagesink, event));
|
gst_navigation_message_new_event ((GstObject *) xvimagesink, event));
|
||||||
|
|
||||||
gst_event_unref (event);
|
gst_event_unref (event);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_xv_image_sink_navigation_init (GstNavigationInterface * iface)
|
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
|
static void
|
||||||
|
|
|
@ -55,8 +55,7 @@ struct TestElementClass
|
||||||
GType test_element_get_type (void);
|
GType test_element_get_type (void);
|
||||||
|
|
||||||
static void init_interface (GType type);
|
static void init_interface (GType type);
|
||||||
static void nav_send_event (GstNavigation * navigation,
|
static void nav_send_event (GstNavigation * navigation, GstEvent * event);
|
||||||
GstStructure * structure);
|
|
||||||
|
|
||||||
G_DEFINE_TYPE_WITH_CODE (TestElement, test_element, GST_TYPE_ELEMENT,
|
G_DEFINE_TYPE_WITH_CODE (TestElement, test_element, GST_TYPE_ELEMENT,
|
||||||
init_interface (g_define_type_id));
|
init_interface (g_define_type_id));
|
||||||
|
@ -64,7 +63,7 @@ G_DEFINE_TYPE_WITH_CODE (TestElement, test_element, GST_TYPE_ELEMENT,
|
||||||
static void
|
static void
|
||||||
test_element_navigation_interface_init (GstNavigationInterface * iface)
|
test_element_navigation_interface_init (GstNavigationInterface * iface)
|
||||||
{
|
{
|
||||||
iface->send_event = nav_send_event;
|
iface->send_event_simple = nav_send_event;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -91,9 +90,8 @@ test_element_init (TestElement * this)
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
GstNavigationEventType etype = gst_navigation_event_get_type (event);
|
||||||
TestElement *self = (TestElement *) (navigation);
|
TestElement *self = (TestElement *) (navigation);
|
||||||
|
|
||||||
|
@ -171,17 +169,23 @@ GST_START_TEST (test_events)
|
||||||
test_element->sent_key = "1";
|
test_element->sent_key = "1";
|
||||||
gst_navigation_send_key_event (GST_NAVIGATION (test_element), "key-press",
|
gst_navigation_send_key_event (GST_NAVIGATION (test_element), "key-press",
|
||||||
"1");
|
"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_type = GST_NAVIGATION_EVENT_KEY_RELEASE;
|
||||||
test_element->sent_key = "2";
|
test_element->sent_key = "2";
|
||||||
gst_navigation_send_key_event (GST_NAVIGATION (test_element), "key-release",
|
gst_navigation_send_key_event (GST_NAVIGATION (test_element), "key-release",
|
||||||
"2");
|
"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_type = GST_NAVIGATION_EVENT_MOUSE_MOVE;
|
||||||
test_element->sent_x = 50;
|
test_element->sent_x = 50;
|
||||||
test_element->sent_y = 100;
|
test_element->sent_y = 100;
|
||||||
gst_navigation_send_mouse_event (GST_NAVIGATION (test_element), "mouse-move",
|
gst_navigation_send_mouse_event (GST_NAVIGATION (test_element), "mouse-move",
|
||||||
0, 50, 100);
|
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_type = GST_NAVIGATION_EVENT_MOUSE_SCROLL;
|
||||||
test_element->sent_x = 60;
|
test_element->sent_x = 60;
|
||||||
|
@ -190,6 +194,8 @@ GST_START_TEST (test_events)
|
||||||
test_element->sent_delta_y = 3;
|
test_element->sent_delta_y = 3;
|
||||||
gst_navigation_send_mouse_scroll_event (GST_NAVIGATION (test_element),
|
gst_navigation_send_mouse_scroll_event (GST_NAVIGATION (test_element),
|
||||||
60, 120, 2, 3);
|
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_type = GST_NAVIGATION_EVENT_MOUSE_BUTTON_PRESS;
|
||||||
test_element->sent_x = 10;
|
test_element->sent_x = 10;
|
||||||
|
@ -197,11 +203,15 @@ GST_START_TEST (test_events)
|
||||||
test_element->sent_button = 1;
|
test_element->sent_button = 1;
|
||||||
gst_navigation_send_mouse_event (GST_NAVIGATION (test_element),
|
gst_navigation_send_mouse_event (GST_NAVIGATION (test_element),
|
||||||
"mouse-button-press", 1, 10, 20);
|
"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++) {
|
for (i = 0; i < G_N_ELEMENTS (cmds); i++) {
|
||||||
test_element->sent_type = GST_NAVIGATION_EVENT_COMMAND;
|
test_element->sent_type = GST_NAVIGATION_EVENT_COMMAND;
|
||||||
test_element->sent_command = cmds[i];
|
test_element->sent_command = cmds[i];
|
||||||
gst_navigation_send_command (GST_NAVIGATION (test_element), 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);
|
gst_object_unref (test_element);
|
||||||
|
|
|
@ -2175,7 +2175,8 @@ navigation_cmd_cb (GtkButton * button, PlaybackApp * app)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cmd != GST_NAVIGATION_COMMAND_INVALID)
|
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)
|
#if defined (GDK_WINDOWING_X11) || defined (GDK_WINDOWING_WIN32) || defined (GDK_WINDOWING_QUARTZ)
|
||||||
|
@ -2271,8 +2272,9 @@ button_press_cb (GtkWidget * widget, GdkEventButton * event, PlaybackApp * app)
|
||||||
gtk_widget_grab_focus (widget);
|
gtk_widget_grab_focus (widget);
|
||||||
|
|
||||||
if (app->navigation_element)
|
if (app->navigation_element)
|
||||||
gst_navigation_send_mouse_event (GST_NAVIGATION (app->navigation_element),
|
gst_navigation_send_event_simple (GST_NAVIGATION (app->navigation_element),
|
||||||
"mouse-button-press", event->button, event->x, event->y);
|
gst_navigation_event_new_mouse_button_press (event->button, event->x,
|
||||||
|
event->y));
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -2282,8 +2284,9 @@ button_release_cb (GtkWidget * widget, GdkEventButton * event,
|
||||||
PlaybackApp * app)
|
PlaybackApp * app)
|
||||||
{
|
{
|
||||||
if (app->navigation_element)
|
if (app->navigation_element)
|
||||||
gst_navigation_send_mouse_event (GST_NAVIGATION (app->navigation_element),
|
gst_navigation_send_event_simple (GST_NAVIGATION (app->navigation_element),
|
||||||
"mouse-button-release", event->button, event->x, event->y);
|
gst_navigation_event_new_mouse_button_release (event->button, event->x,
|
||||||
|
event->y));
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -2292,8 +2295,8 @@ static gboolean
|
||||||
key_press_cb (GtkWidget * widget, GdkEventKey * event, PlaybackApp * app)
|
key_press_cb (GtkWidget * widget, GdkEventKey * event, PlaybackApp * app)
|
||||||
{
|
{
|
||||||
if (app->navigation_element)
|
if (app->navigation_element)
|
||||||
gst_navigation_send_key_event (GST_NAVIGATION (app->navigation_element),
|
gst_navigation_send_event_simple (GST_NAVIGATION (app->navigation_element),
|
||||||
"key-press", gdk_keyval_name (event->keyval));
|
gst_navigation_event_new_key_press (gdk_keyval_name (event->keyval)));
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -2302,8 +2305,8 @@ static gboolean
|
||||||
key_release_cb (GtkWidget * widget, GdkEventKey * event, PlaybackApp * app)
|
key_release_cb (GtkWidget * widget, GdkEventKey * event, PlaybackApp * app)
|
||||||
{
|
{
|
||||||
if (app->navigation_element)
|
if (app->navigation_element)
|
||||||
gst_navigation_send_key_event (GST_NAVIGATION (app->navigation_element),
|
gst_navigation_send_event_simple (GST_NAVIGATION (app->navigation_element),
|
||||||
"key-release", gdk_keyval_name (event->keyval));
|
gst_navigation_event_new_key_release (gdk_keyval_name (event->keyval)));
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -2312,8 +2315,8 @@ static gboolean
|
||||||
motion_notify_cb (GtkWidget * widget, GdkEventMotion * event, PlaybackApp * app)
|
motion_notify_cb (GtkWidget * widget, GdkEventMotion * event, PlaybackApp * app)
|
||||||
{
|
{
|
||||||
if (app->navigation_element)
|
if (app->navigation_element)
|
||||||
gst_navigation_send_mouse_event (GST_NAVIGATION (app->navigation_element),
|
gst_navigation_send_event_simple (GST_NAVIGATION (app->navigation_element),
|
||||||
"mouse-move", 0, event->x, event->y);
|
gst_navigation_event_new_mouse_move (event->x, event->y));
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -319,15 +319,15 @@ gst_gtk_base_sink_set_property (GObject * object, guint prop_id,
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_gtk_base_sink_navigation_send_event (GstNavigation * navigation,
|
gst_gtk_base_sink_navigation_send_event (GstNavigation * navigation,
|
||||||
GstStructure * structure)
|
GstEvent * event)
|
||||||
{
|
{
|
||||||
GstGtkBaseSink *sink = GST_GTK_BASE_SINK (navigation);
|
GstGtkBaseSink *sink = GST_GTK_BASE_SINK (navigation);
|
||||||
GstEvent *event;
|
|
||||||
GstPad *pad;
|
GstPad *pad;
|
||||||
gdouble x, y;
|
gdouble x, y;
|
||||||
|
|
||||||
if (gst_structure_get_double (structure, "pointer_x", &x) &&
|
event = gst_event_make_writable (event);
|
||||||
gst_structure_get_double (structure, "pointer_y", &y)) {
|
|
||||||
|
if (gst_navigation_event_get_coordinates (event, &x, &y)) {
|
||||||
GtkGstBaseWidget *widget = gst_gtk_base_sink_get_widget (sink);
|
GtkGstBaseWidget *widget = gst_gtk_base_sink_get_widget (sink);
|
||||||
gdouble stream_x, stream_y;
|
gdouble stream_x, stream_y;
|
||||||
|
|
||||||
|
@ -338,15 +338,13 @@ gst_gtk_base_sink_navigation_send_event (GstNavigation * navigation,
|
||||||
|
|
||||||
gtk_gst_base_widget_display_size_to_stream_size (widget,
|
gtk_gst_base_widget_display_size_to_stream_size (widget,
|
||||||
x, y, &stream_x, &stream_y);
|
x, y, &stream_x, &stream_y);
|
||||||
gst_structure_set (structure,
|
gst_navigation_event_set_coordinates (event, stream_x, stream_y);
|
||||||
"pointer_x", G_TYPE_DOUBLE, (gdouble) stream_x,
|
|
||||||
"pointer_y", G_TYPE_DOUBLE, (gdouble) stream_y, NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
event = gst_event_new_navigation (structure);
|
|
||||||
pad = gst_pad_get_peer (GST_VIDEO_SINK_PAD (sink));
|
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_IS_PAD (pad) && GST_IS_EVENT (event)) {
|
||||||
if (!gst_pad_send_event (pad, gst_event_ref (event))) {
|
if (!gst_pad_send_event (pad, gst_event_ref (event))) {
|
||||||
|
@ -363,7 +361,7 @@ gst_gtk_base_sink_navigation_send_event (GstNavigation * navigation,
|
||||||
static void
|
static void
|
||||||
gst_gtk_base_sink_navigation_interface_init (GstNavigationInterface * iface)
|
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
|
static gboolean
|
||||||
|
|
|
@ -290,13 +290,14 @@ gtk_gst_base_widget_key_event (GtkWidget * widget, GdkEventKey * event)
|
||||||
if ((element = g_weak_ref_get (&base_widget->element))) {
|
if ((element = g_weak_ref_get (&base_widget->element))) {
|
||||||
if (GST_IS_NAVIGATION (element)) {
|
if (GST_IS_NAVIGATION (element)) {
|
||||||
const gchar *str = _gdk_key_to_navigation_string (event->keyval);
|
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)
|
if (!str)
|
||||||
str = event->string;
|
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);
|
g_object_unref (element);
|
||||||
}
|
}
|
||||||
|
@ -378,11 +379,12 @@ gtk_gst_base_widget_button_event (GtkWidget * widget, GdkEventButton * event)
|
||||||
|
|
||||||
if ((element = g_weak_ref_get (&base_widget->element))) {
|
if ((element = g_weak_ref_get (&base_widget->element))) {
|
||||||
if (GST_IS_NAVIGATION (element)) {
|
if (GST_IS_NAVIGATION (element)) {
|
||||||
const gchar *key_type =
|
gst_navigation_send_event_simple (GST_NAVIGATION (element),
|
||||||
event->type ==
|
(event->type == GDK_BUTTON_PRESS) ?
|
||||||
GDK_BUTTON_PRESS ? "mouse-button-press" : "mouse-button-release";
|
gst_navigation_event_new_mouse_button_press (event->button,
|
||||||
gst_navigation_send_mouse_event (GST_NAVIGATION (element), key_type,
|
event->x, event->y) :
|
||||||
event->button, event->x, event->y);
|
gst_navigation_event_new_mouse_button_release (event->button,
|
||||||
|
event->x, event->y));
|
||||||
}
|
}
|
||||||
g_object_unref (element);
|
g_object_unref (element);
|
||||||
}
|
}
|
||||||
|
@ -398,8 +400,8 @@ gtk_gst_base_widget_motion_event (GtkWidget * widget, GdkEventMotion * event)
|
||||||
|
|
||||||
if ((element = g_weak_ref_get (&base_widget->element))) {
|
if ((element = g_weak_ref_get (&base_widget->element))) {
|
||||||
if (GST_IS_NAVIGATION (element)) {
|
if (GST_IS_NAVIGATION (element)) {
|
||||||
gst_navigation_send_mouse_event (GST_NAVIGATION (element), "mouse-move",
|
gst_navigation_send_event_simple (GST_NAVIGATION (element),
|
||||||
0, event->x, event->y);
|
gst_navigation_event_new_mouse_move (event->x, event->y));
|
||||||
}
|
}
|
||||||
g_object_unref (element);
|
g_object_unref (element);
|
||||||
}
|
}
|
||||||
|
@ -443,8 +445,8 @@ gtk_gst_base_widget_scroll_event (GtkWidget * widget, GdkEventScroll * event)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
gst_navigation_send_mouse_scroll_event (GST_NAVIGATION (element),
|
gst_navigation_send_event_simple (GST_NAVIGATION (element),
|
||||||
x, y, delta_x, delta_y);
|
gst_navigation_event_new_mouse_scroll (x, y, delta_x, delta_y));
|
||||||
}
|
}
|
||||||
g_object_unref (element);
|
g_object_unref (element);
|
||||||
}
|
}
|
||||||
|
|
|
@ -558,16 +558,15 @@ config_failed:
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_qt_sink_navigation_send_event (GstNavigation * navigation,
|
gst_qt_sink_navigation_send_event (GstNavigation * navigation,
|
||||||
GstStructure * structure)
|
GstEvent * event)
|
||||||
{
|
{
|
||||||
GstQtSink *qt_sink = GST_QT_SINK (navigation);
|
GstQtSink *qt_sink = GST_QT_SINK (navigation);
|
||||||
GstEvent *event;
|
|
||||||
GstPad *pad;
|
GstPad *pad;
|
||||||
|
|
||||||
event = gst_event_new_navigation (structure);
|
|
||||||
pad = gst_pad_get_peer (GST_VIDEO_SINK_PAD (qt_sink));
|
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_IS_PAD (pad) && GST_IS_EVENT (event)) {
|
||||||
if (!gst_pad_send_event (pad, gst_event_ref (event))) {
|
if (!gst_pad_send_event (pad, gst_event_ref (event))) {
|
||||||
|
@ -583,5 +582,5 @@ gst_qt_sink_navigation_send_event (GstNavigation * navigation,
|
||||||
|
|
||||||
static void gst_qt_sink_navigation_interface_init (GstNavigationInterface * iface)
|
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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -437,8 +437,9 @@ QtGLVideoItem::wheelEvent(QWheelEvent * event)
|
||||||
#else
|
#else
|
||||||
auto position = *event;
|
auto position = *event;
|
||||||
#endif
|
#endif
|
||||||
gst_navigation_send_mouse_scroll_event (GST_NAVIGATION (element),
|
gst_navigation_send_event_simple (GST_NAVIGATION (element),
|
||||||
position.x(), position.y(), delta.x(), delta.y());
|
gst_navigation_event_new_mouse_scroll (position.x(), position.y(),
|
||||||
|
delta.x(), delta.y()));
|
||||||
g_object_unref (element);
|
g_object_unref (element);
|
||||||
}
|
}
|
||||||
g_mutex_unlock (&this->priv->lock);
|
g_mutex_unlock (&this->priv->lock);
|
||||||
|
@ -462,8 +463,6 @@ QtGLVideoItem::hoverMoveEvent(QHoverEvent * event)
|
||||||
if (!mouseHovering)
|
if (!mouseHovering)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
quint32 button = !!mousePressedButton;
|
|
||||||
|
|
||||||
g_mutex_lock (&this->priv->lock);
|
g_mutex_lock (&this->priv->lock);
|
||||||
|
|
||||||
/* can't do anything when we don't have input format */
|
/* can't do anything when we don't have input format */
|
||||||
|
@ -477,8 +476,8 @@ QtGLVideoItem::hoverMoveEvent(QHoverEvent * event)
|
||||||
GstElement *element = GST_ELEMENT_CAST (g_weak_ref_get (&this->priv->sink));
|
GstElement *element = GST_ELEMENT_CAST (g_weak_ref_get (&this->priv->sink));
|
||||||
|
|
||||||
if (element != NULL) {
|
if (element != NULL) {
|
||||||
gst_navigation_send_mouse_event (GST_NAVIGATION (element), "mouse-move",
|
gst_navigation_send_event_simple (GST_NAVIGATION (element),
|
||||||
button, pos.x(), pos.y());
|
gst_navigation_event_new_mouse_move (pos.x(), pos.y()));
|
||||||
g_object_unref (element);
|
g_object_unref (element);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -486,7 +485,7 @@ QtGLVideoItem::hoverMoveEvent(QHoverEvent * event)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
QtGLVideoItem::sendMouseEvent(QMouseEvent * event, const gchar * type)
|
QtGLVideoItem::sendMouseEvent(QMouseEvent * event, gboolean is_press)
|
||||||
{
|
{
|
||||||
quint32 button = 0;
|
quint32 button = 0;
|
||||||
|
|
||||||
|
@ -512,16 +511,17 @@ QtGLVideoItem::sendMouseEvent(QMouseEvent * event, const gchar * type)
|
||||||
}
|
}
|
||||||
|
|
||||||
QPointF pos = mapPointToStreamSize(event->pos());
|
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));
|
GstElement *element = GST_ELEMENT_CAST (g_weak_ref_get (&this->priv->sink));
|
||||||
|
|
||||||
if (element != NULL) {
|
if (element != NULL) {
|
||||||
gst_navigation_send_mouse_event (GST_NAVIGATION (element), event_type,
|
gst_navigation_send_event_simple (GST_NAVIGATION (element),
|
||||||
button, pos.x(), pos.y());
|
(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_object_unref (element);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_free (event_type);
|
|
||||||
g_mutex_unlock (&this->priv->lock);
|
g_mutex_unlock (&this->priv->lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -529,13 +529,13 @@ void
|
||||||
QtGLVideoItem::mousePressEvent(QMouseEvent * event)
|
QtGLVideoItem::mousePressEvent(QMouseEvent * event)
|
||||||
{
|
{
|
||||||
forceActiveFocus();
|
forceActiveFocus();
|
||||||
sendMouseEvent(event, "press");
|
sendMouseEvent(event, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
QtGLVideoItem::mouseReleaseEvent(QMouseEvent * event)
|
QtGLVideoItem::mouseReleaseEvent(QMouseEvent * event)
|
||||||
{
|
{
|
||||||
sendMouseEvent(event, "release");
|
sendMouseEvent(event, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -112,7 +112,7 @@ private:
|
||||||
void fitStreamToAllocatedSize(GstVideoRectangle * result);
|
void fitStreamToAllocatedSize(GstVideoRectangle * result);
|
||||||
QPointF mapPointToStreamSize(QPointF);
|
QPointF mapPointToStreamSize(QPointF);
|
||||||
|
|
||||||
void sendMouseEvent(QMouseEvent * event, const gchar * type);
|
void sendMouseEvent(QMouseEvent * event, gboolean is_press);
|
||||||
|
|
||||||
quint32 mousePressedButton;
|
quint32 mousePressedButton;
|
||||||
bool mouseHovering;
|
bool mouseHovering;
|
||||||
|
|
|
@ -59,7 +59,7 @@ gst_navigationtest_src_event (GstBaseTransform * trans, GstEvent * event)
|
||||||
{
|
{
|
||||||
GstVideoInfo *info;
|
GstVideoInfo *info;
|
||||||
GstNavigationtest *navtest;
|
GstNavigationtest *navtest;
|
||||||
const gchar *type;
|
GstNavigationEventType type;
|
||||||
|
|
||||||
navtest = GST_NAVIGATIONTEST (trans);
|
navtest = GST_NAVIGATIONTEST (trans);
|
||||||
|
|
||||||
|
@ -68,38 +68,44 @@ gst_navigationtest_src_event (GstBaseTransform * trans, GstEvent * event)
|
||||||
switch (GST_EVENT_TYPE (event)) {
|
switch (GST_EVENT_TYPE (event)) {
|
||||||
case GST_EVENT_NAVIGATION:
|
case GST_EVENT_NAVIGATION:
|
||||||
{
|
{
|
||||||
const GstStructure *s = gst_event_get_structure (event);
|
|
||||||
gint fps_n, fps_d;
|
gint fps_n, fps_d;
|
||||||
|
|
||||||
fps_n = GST_VIDEO_INFO_FPS_N (info);
|
fps_n = GST_VIDEO_INFO_FPS_N (info);
|
||||||
fps_d = GST_VIDEO_INFO_FPS_D (info);
|
fps_d = GST_VIDEO_INFO_FPS_D (info);
|
||||||
|
|
||||||
type = gst_structure_get_string (s, "event");
|
type = gst_navigation_event_get_type (event);
|
||||||
if (g_str_equal (type, "mouse-move")) {
|
switch (type) {
|
||||||
gst_structure_get_double (s, "pointer_x", &navtest->x);
|
case GST_NAVIGATION_EVENT_MOUSE_MOVE:{
|
||||||
gst_structure_get_double (s, "pointer_y", &navtest->y);
|
gst_navigation_event_get_coordinates (event, &navtest->x,
|
||||||
} else if (g_str_equal (type, "mouse-button-press")) {
|
&navtest->y);
|
||||||
ButtonClick *click = g_new (ButtonClick, 1);
|
break;
|
||||||
|
}
|
||||||
|
case GST_NAVIGATION_EVENT_MOUSE_BUTTON_PRESS:{
|
||||||
|
ButtonClick *click = g_new (ButtonClick, 1);
|
||||||
|
|
||||||
gst_structure_get_double (s, "pointer_x", &click->x);
|
gst_navigation_event_get_coordinates (event, &click->x, &click->y);
|
||||||
gst_structure_get_double (s, "pointer_y", &click->y);
|
click->images_left = (fps_n + fps_d - 1) / fps_d;
|
||||||
click->images_left = (fps_n + fps_d - 1) / fps_d;
|
/* green */
|
||||||
/* green */
|
click->cy = 150;
|
||||||
click->cy = 150;
|
click->cu = 46;
|
||||||
click->cu = 46;
|
click->cv = 21;
|
||||||
click->cv = 21;
|
navtest->clicks = g_slist_prepend (navtest->clicks, click);
|
||||||
navtest->clicks = g_slist_prepend (navtest->clicks, click);
|
break;
|
||||||
} else if (g_str_equal (type, "mouse-button-release")) {
|
}
|
||||||
ButtonClick *click = g_new (ButtonClick, 1);
|
case GST_NAVIGATION_EVENT_MOUSE_BUTTON_RELEASE:{
|
||||||
|
ButtonClick *click = g_new (ButtonClick, 1);
|
||||||
|
|
||||||
gst_structure_get_double (s, "pointer_x", &click->x);
|
gst_navigation_event_get_coordinates (event, &click->x, &click->y);
|
||||||
gst_structure_get_double (s, "pointer_y", &click->y);
|
click->images_left = (fps_n + fps_d - 1) / fps_d;
|
||||||
click->images_left = (fps_n + fps_d - 1) / fps_d;
|
/* red */
|
||||||
/* red */
|
click->cy = 76;
|
||||||
click->cy = 76;
|
click->cu = 85;
|
||||||
click->cu = 85;
|
click->cv = 255;
|
||||||
click->cv = 255;
|
navtest->clicks = g_slist_prepend (navtest->clicks, click);
|
||||||
navtest->clicks = g_slist_prepend (navtest->clicks, click);
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
|
|
||||||
#include "gstdebugutilselements.h"
|
#include "gstdebugutilselements.h"
|
||||||
#include "gstnavseek.h"
|
#include "gstnavseek.h"
|
||||||
|
#include <gst/video/navigation.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
|
@ -252,19 +253,11 @@ gst_navseek_src_event (GstBaseTransform * trans, GstEvent * event)
|
||||||
case GST_EVENT_NAVIGATION:
|
case GST_EVENT_NAVIGATION:
|
||||||
{
|
{
|
||||||
/* Check for a keyup and convert left/right to a seek event */
|
/* Check for a keyup and convert left/right to a seek event */
|
||||||
const GstStructure *structure;
|
if (gst_navigation_event_get_type (event)
|
||||||
const gchar *event_type;
|
== GST_NAVIGATION_EVENT_KEY_PRESS) {
|
||||||
|
|
||||||
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) {
|
|
||||||
const gchar *key;
|
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);
|
g_return_val_if_fail (key != NULL, FALSE);
|
||||||
|
|
||||||
if (strcmp (key, "Left") == 0) {
|
if (strcmp (key, "Left") == 0) {
|
||||||
|
|
|
@ -3187,41 +3187,28 @@ static gboolean
|
||||||
gst_video_box_src_event (GstBaseTransform * trans, GstEvent * event)
|
gst_video_box_src_event (GstBaseTransform * trans, GstEvent * event)
|
||||||
{
|
{
|
||||||
GstVideoBox *video_box = GST_VIDEO_BOX (trans);
|
GstVideoBox *video_box = GST_VIDEO_BOX (trans);
|
||||||
GstStructure *new_structure;
|
GstNavigationEventType type;
|
||||||
const GstStructure *structure;
|
|
||||||
const gchar *event_name;
|
|
||||||
gdouble pointer_x;
|
gdouble pointer_x;
|
||||||
gdouble pointer_y;
|
gdouble pointer_y;
|
||||||
|
|
||||||
GST_OBJECT_LOCK (video_box);
|
GST_OBJECT_LOCK (video_box);
|
||||||
|
type = gst_navigation_event_get_type (event);
|
||||||
if (GST_EVENT_TYPE (event) == GST_EVENT_NAVIGATION &&
|
if (GST_EVENT_TYPE (event) == GST_EVENT_NAVIGATION &&
|
||||||
(video_box->box_left != 0 || video_box->box_top != 0)) {
|
(video_box->box_left != 0 || video_box->box_top != 0) &&
|
||||||
structure = gst_event_get_structure (event);
|
(type == GST_NAVIGATION_EVENT_MOUSE_MOVE
|
||||||
event_name = gst_structure_get_string (structure, "event");
|
|| 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;
|
||||||
|
|
||||||
if (event_name &&
|
event = gst_event_make_writable (event);
|
||||||
(strcmp (event_name, "mouse-move") == 0 ||
|
new_pointer_x = pointer_x + video_box->box_left;
|
||||||
strcmp (event_name, "mouse-button-press") == 0 ||
|
new_pointer_y = pointer_y + video_box->box_top;
|
||||||
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;
|
gst_navigation_event_set_coordinates (event, new_pointer_x,
|
||||||
new_pointer_y = pointer_y + video_box->box_top;
|
new_pointer_y);
|
||||||
|
} else {
|
||||||
new_structure = gst_structure_copy (structure);
|
GST_WARNING_OBJECT (video_box, "Failed to read navigation event");
|
||||||
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");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
GST_OBJECT_UNLOCK (video_box);
|
GST_OBJECT_UNLOCK (video_box);
|
||||||
|
|
|
@ -123,48 +123,31 @@ static GstFlowReturn gst_video_crop_transform_ip (GstBaseTransform * trans,
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_video_crop_src_event (GstBaseTransform * trans, GstEvent * event)
|
gst_video_crop_src_event (GstBaseTransform * trans, GstEvent * event)
|
||||||
{
|
{
|
||||||
GstEvent *new_event;
|
GstNavigationEventType type;
|
||||||
GstStructure *new_structure;
|
|
||||||
const GstStructure *structure;
|
|
||||||
const gchar *event_name;
|
|
||||||
double pointer_x;
|
double pointer_x;
|
||||||
double pointer_y;
|
double pointer_y;
|
||||||
|
|
||||||
GstVideoCrop *vcrop = GST_VIDEO_CROP (trans);
|
GstVideoCrop *vcrop = GST_VIDEO_CROP (trans);
|
||||||
new_event = NULL;
|
|
||||||
|
|
||||||
GST_OBJECT_LOCK (vcrop);
|
GST_OBJECT_LOCK (vcrop);
|
||||||
|
|
||||||
|
type = gst_navigation_event_get_type (event);
|
||||||
if (GST_EVENT_TYPE (event) == GST_EVENT_NAVIGATION &&
|
if (GST_EVENT_TYPE (event) == GST_EVENT_NAVIGATION &&
|
||||||
(vcrop->crop_left != 0 || vcrop->crop_top != 0)) {
|
(vcrop->crop_left != 0 || vcrop->crop_top != 0) &&
|
||||||
structure = gst_event_get_structure (event);
|
(type == GST_NAVIGATION_EVENT_MOUSE_MOVE
|
||||||
event_name = gst_structure_get_string (structure, "event");
|
|| type == GST_NAVIGATION_EVENT_MOUSE_BUTTON_PRESS
|
||||||
|
|| type == GST_NAVIGATION_EVENT_MOUSE_BUTTON_RELEASE)) {
|
||||||
if (event_name &&
|
if (gst_navigation_event_get_coordinates (event, &pointer_x, &pointer_y)) {
|
||||||
(strcmp (event_name, "mouse-move") == 0 ||
|
event = gst_event_make_writable (event);
|
||||||
strcmp (event_name, "mouse-button-press") == 0 ||
|
gst_navigation_event_set_coordinates (event, pointer_x + vcrop->crop_left,
|
||||||
strcmp (event_name, "mouse-button-release") == 0)) {
|
pointer_y + vcrop->crop_top);
|
||||||
|
} else {
|
||||||
if (gst_structure_get_double (structure, "pointer_x", &pointer_x) &&
|
GST_WARNING_OBJECT (vcrop, "Failed to read navigation event");
|
||||||
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");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GST_OBJECT_UNLOCK (vcrop);
|
GST_OBJECT_UNLOCK (vcrop);
|
||||||
|
|
||||||
return GST_BASE_TRANSFORM_CLASS (parent_class)->src_event (trans,
|
return GST_BASE_TRANSFORM_CLASS (parent_class)->src_event (trans, event);
|
||||||
(new_event ? new_event : event));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -1223,7 +1223,6 @@ gst_video_flip_src_event (GstBaseTransform * trans, GstEvent * event)
|
||||||
{
|
{
|
||||||
GstVideoFlip *vf = GST_VIDEO_FLIP (trans);
|
GstVideoFlip *vf = GST_VIDEO_FLIP (trans);
|
||||||
gdouble new_x, new_y, x, y;
|
gdouble new_x, new_y, x, y;
|
||||||
GstStructure *structure;
|
|
||||||
gboolean ret;
|
gboolean ret;
|
||||||
GstVideoInfo *out_info = &GST_VIDEO_FILTER (trans)->out_info;
|
GstVideoInfo *out_info = &GST_VIDEO_FILTER (trans)->out_info;
|
||||||
|
|
||||||
|
@ -1231,12 +1230,9 @@ gst_video_flip_src_event (GstBaseTransform * trans, GstEvent * event)
|
||||||
|
|
||||||
switch (GST_EVENT_TYPE (event)) {
|
switch (GST_EVENT_TYPE (event)) {
|
||||||
case GST_EVENT_NAVIGATION:
|
case GST_EVENT_NAVIGATION:
|
||||||
event =
|
event = gst_event_make_writable (event);
|
||||||
GST_EVENT (gst_mini_object_make_writable (GST_MINI_OBJECT (event)));
|
|
||||||
|
|
||||||
structure = (GstStructure *) gst_event_get_structure (event);
|
if (gst_navigation_event_get_coordinates (event, &x, &y)) {
|
||||||
if (gst_structure_get_double (structure, "pointer_x", &x) &&
|
|
||||||
gst_structure_get_double (structure, "pointer_y", &y)) {
|
|
||||||
GST_DEBUG_OBJECT (vf, "converting %fx%f", x, y);
|
GST_DEBUG_OBJECT (vf, "converting %fx%f", x, y);
|
||||||
GST_OBJECT_LOCK (vf);
|
GST_OBJECT_LOCK (vf);
|
||||||
switch (vf->active_method) {
|
switch (vf->active_method) {
|
||||||
|
@ -1275,8 +1271,7 @@ gst_video_flip_src_event (GstBaseTransform * trans, GstEvent * event)
|
||||||
}
|
}
|
||||||
GST_OBJECT_UNLOCK (vf);
|
GST_OBJECT_UNLOCK (vf);
|
||||||
GST_DEBUG_OBJECT (vf, "to %fx%f", new_x, new_y);
|
GST_DEBUG_OBJECT (vf, "to %fx%f", new_x, new_y);
|
||||||
gst_structure_set (structure, "pointer_x", G_TYPE_DOUBLE, new_x,
|
gst_navigation_event_set_coordinates (event, new_x, new_y);
|
||||||
"pointer_y", G_TYPE_DOUBLE, new_y, NULL);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -1899,20 +1899,16 @@ gst_vaapipostproc_src_event (GstBaseTransform * trans, GstEvent * event)
|
||||||
{
|
{
|
||||||
GstVaapiPostproc *const postproc = GST_VAAPIPOSTPROC (trans);
|
GstVaapiPostproc *const postproc = GST_VAAPIPOSTPROC (trans);
|
||||||
gdouble new_x = 0, new_y = 0, x = 0, y = 0, w_factor = 1, h_factor = 1;
|
gdouble new_x = 0, new_y = 0, x = 0, y = 0, w_factor = 1, h_factor = 1;
|
||||||
GstStructure *structure;
|
|
||||||
gboolean ret;
|
gboolean ret;
|
||||||
|
|
||||||
GST_TRACE_OBJECT (postproc, "handling %s event", GST_EVENT_TYPE_NAME (event));
|
GST_TRACE_OBJECT (postproc, "handling %s event", GST_EVENT_TYPE_NAME (event));
|
||||||
|
|
||||||
switch (GST_EVENT_TYPE (event)) {
|
switch (GST_EVENT_TYPE (event)) {
|
||||||
case GST_EVENT_NAVIGATION:
|
case GST_EVENT_NAVIGATION:
|
||||||
event =
|
event = gst_event_make_writable (event);
|
||||||
GST_EVENT (gst_mini_object_make_writable (GST_MINI_OBJECT (event)));
|
|
||||||
|
|
||||||
structure = (GstStructure *) gst_event_get_structure (event);
|
if (postproc->has_vpp &&
|
||||||
if (postproc->has_vpp
|
gst_navigation_event_get_coordinates (event, &x, &y)) {
|
||||||
&& gst_structure_get_double (structure, "pointer_x", &x)
|
|
||||||
&& gst_structure_get_double (structure, "pointer_y", &y)) {
|
|
||||||
GST_DEBUG_OBJECT (postproc, "converting %fx%f", x, y);
|
GST_DEBUG_OBJECT (postproc, "converting %fx%f", x, y);
|
||||||
|
|
||||||
/* video-direction compensation */
|
/* video-direction compensation */
|
||||||
|
@ -1961,8 +1957,7 @@ gst_vaapipostproc_src_event (GstBaseTransform * trans, GstEvent * event)
|
||||||
new_y += postproc->crop_top;
|
new_y += postproc->crop_top;
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (postproc, "to %fx%f", new_x, new_y);
|
GST_DEBUG_OBJECT (postproc, "to %fx%f", new_x, new_y);
|
||||||
gst_structure_set (structure, "pointer_x", G_TYPE_DOUBLE, new_x,
|
gst_navigation_event_set_coordinates (event, new_x, new_y);
|
||||||
"pointer_y", G_TYPE_DOUBLE, new_y, NULL);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -896,40 +896,34 @@ gst_vaapisink_color_balance_iface_init (GstColorBalanceInterface * iface)
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_vaapisink_navigation_send_event (GstNavigation * navigation,
|
gst_vaapisink_navigation_send_event (GstNavigation * navigation,
|
||||||
GstStructure * structure)
|
GstEvent * event)
|
||||||
{
|
{
|
||||||
GstVaapiSink *const sink = GST_VAAPISINK (navigation);
|
GstVaapiSink *const sink = GST_VAAPISINK (navigation);
|
||||||
GstPad *peer;
|
GstPad *peer;
|
||||||
|
|
||||||
if (!sink->window) {
|
if (!sink->window) {
|
||||||
gst_structure_free (structure);
|
gst_event_unref (event);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((peer = gst_pad_get_peer (GST_VAAPI_PLUGIN_BASE_SINK_PAD (sink)))) {
|
if ((peer = gst_pad_get_peer (GST_VAAPI_PLUGIN_BASE_SINK_PAD (sink)))) {
|
||||||
GstEvent *event;
|
|
||||||
GstVaapiRectangle *disp_rect = &sink->display_rect;
|
GstVaapiRectangle *disp_rect = &sink->display_rect;
|
||||||
gdouble x, y, xscale = 1.0, yscale = 1.0;
|
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
|
/* We calculate scaling using the original video frames geometry to include
|
||||||
pixel aspect ratio scaling. */
|
pixel aspect ratio scaling. */
|
||||||
xscale = (gdouble) sink->video_width / disp_rect->width;
|
xscale = (gdouble) sink->video_width / disp_rect->width;
|
||||||
yscale = (gdouble) sink->video_height / disp_rect->height;
|
yscale = (gdouble) sink->video_height / disp_rect->height;
|
||||||
|
|
||||||
|
event = gst_event_make_writable (event);
|
||||||
|
|
||||||
/* Converting pointer coordinates to the non scaled geometry */
|
/* 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 = MIN (x, disp_rect->x + disp_rect->width);
|
||||||
x = MAX (x - disp_rect->x, 0);
|
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 = MIN (y, disp_rect->y + disp_rect->height);
|
||||||
y = MAX (y - disp_rect->y, 0);
|
y = MAX (y - disp_rect->y, 0);
|
||||||
gst_structure_set (structure, "pointer_y", G_TYPE_DOUBLE,
|
gst_navigation_event_set_coordinates (event, x * xscale, y * yscale);
|
||||||
(gdouble) y * yscale, NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!gst_pad_send_event (peer, gst_event_ref (event))) {
|
if (!gst_pad_send_event (peer, gst_event_ref (event))) {
|
||||||
|
@ -946,7 +940,7 @@ gst_vaapisink_navigation_send_event (GstNavigation * navigation,
|
||||||
static void
|
static void
|
||||||
gst_vaapisink_navigation_iface_init (GstNavigationInterface * iface)
|
gst_vaapisink_navigation_iface_init (GstNavigationInterface * iface)
|
||||||
{
|
{
|
||||||
iface->send_event = gst_vaapisink_navigation_send_event;
|
iface->send_event_simple = gst_vaapisink_navigation_send_event;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------ */
|
/* ------------------------------------------------------------------------ */
|
||||||
|
|
|
@ -155,8 +155,7 @@ static void
|
||||||
vpp_test_mouse_events (VppTestContext * ctx,
|
vpp_test_mouse_events (VppTestContext * ctx,
|
||||||
const VppTestCoordinateParams * const params, const size_t nparams)
|
const VppTestCoordinateParams * const params, const size_t nparams)
|
||||||
{
|
{
|
||||||
GstStructure *structure;
|
GstEvent *event = NULL;
|
||||||
GstEvent *event;
|
|
||||||
VppTestCoordinate probed = { 0, };
|
VppTestCoordinate probed = { 0, };
|
||||||
guint i, j;
|
guint i, j;
|
||||||
|
|
||||||
|
@ -180,13 +179,23 @@ vpp_test_mouse_events (VppTestContext * ctx,
|
||||||
for (j = 0; j < G_N_ELEMENTS (mouse_events); ++j) {
|
for (j = 0; j < G_N_ELEMENTS (mouse_events); ++j) {
|
||||||
probed.x = probed.y = -1;
|
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,
|
GST_LOG ("sending %s event %fx%f", mouse_events[j], params[i].send.x,
|
||||||
params[i].send.y);
|
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_element_send_event (ctx->pipeline, event);
|
||||||
|
|
||||||
GST_LOG ("probed %s event %fx%f", mouse_events[j], probed.x, probed.y);
|
GST_LOG ("probed %s event %fx%f", mouse_events[j], probed.x, probed.y);
|
||||||
|
|
Loading…
Reference in a new issue