diff options
author | Colin Kinloch <colin.kinloch@collabora.com> | 2022-10-10 21:58:12 +0300 |
---|---|---|
committer | GStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org> | 2022-11-11 09:45:49 +0300 |
commit | 99fc124f25d706f03ae7529b4405529459c71d4a (patch) | |
tree | 2cb0f87d1585d8743052c76b5a9dcd54c9158a4d | |
parent | 841f50f0d91c246df1eb28a261731168f582d029 (diff) |
videocrop, videobox: Simplify navigation event handling and support touch events
Signed-off-by: Colin Kinloch <colin.kinloch@collabora.com>
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3053>
-rw-r--r-- | subprojects/gst-plugins-bad/sys/va/gstvavpp.c | 4 | ||||
-rw-r--r-- | subprojects/gst-plugins-good/gst/videobox/gstvideobox.c | 38 | ||||
-rw-r--r-- | subprojects/gst-plugins-good/gst/videocrop/gstvideocrop.c | 33 |
3 files changed, 36 insertions, 39 deletions
diff --git a/subprojects/gst-plugins-bad/sys/va/gstvavpp.c b/subprojects/gst-plugins-bad/sys/va/gstvavpp.c index 730bea3781..6355216ad3 100644 --- a/subprojects/gst-plugins-bad/sys/va/gstvavpp.c +++ b/subprojects/gst-plugins-bad/sys/va/gstvavpp.c @@ -1939,11 +1939,11 @@ gst_va_vpp_src_event (GstBaseTransform * trans, GstEvent * event) || gst_va_filter_get_orientation (btrans->filter) != GST_VIDEO_ORIENTATION_IDENTITY) { - event = gst_event_make_writable (event); - if (!gst_navigation_event_get_coordinates (event, &x, &y)) break; + event = gst_event_make_writable (event); + /* video-direction compensation */ switch (gst_va_filter_get_orientation (btrans->filter)) { case GST_VIDEO_ORIENTATION_90R: diff --git a/subprojects/gst-plugins-good/gst/videobox/gstvideobox.c b/subprojects/gst-plugins-good/gst/videobox/gstvideobox.c index 302e714260..5267c9180c 100644 --- a/subprojects/gst-plugins-good/gst/videobox/gstvideobox.c +++ b/subprojects/gst-plugins-good/gst/videobox/gstvideobox.c @@ -3189,29 +3189,25 @@ static gboolean gst_video_box_src_event (GstBaseTransform * trans, GstEvent * event) { GstVideoBox *video_box = GST_VIDEO_BOX (trans); - GstNavigationEventType type; - gdouble pointer_x; - gdouble pointer_y; + gdouble x, y, new_x, new_y; GST_OBJECT_LOCK (video_box); - type = gst_navigation_event_get_type (event); - if (GST_EVENT_TYPE (event) == GST_EVENT_NAVIGATION && - (video_box->box_left != 0 || video_box->box_top != 0) && - (type == GST_NAVIGATION_EVENT_MOUSE_MOVE - || type == GST_NAVIGATION_EVENT_MOUSE_BUTTON_PRESS - || type == GST_NAVIGATION_EVENT_MOUSE_BUTTON_RELEASE)) { - if (gst_navigation_event_get_coordinates (event, &pointer_x, &pointer_y)) { - gdouble new_pointer_x, new_pointer_y; - - event = gst_event_make_writable (event); - new_pointer_x = pointer_x + video_box->box_left; - new_pointer_y = pointer_y + video_box->box_top; - - gst_navigation_event_set_coordinates (event, new_pointer_x, - new_pointer_y); - } else { - GST_WARNING_OBJECT (video_box, "Failed to read navigation event"); - } + + switch (GST_EVENT_TYPE (event)) { + case GST_EVENT_NAVIGATION: + if ((video_box->box_left != 0 || video_box->box_top != 0) + && gst_navigation_event_get_coordinates (event, &x, &y)) { + + event = gst_event_make_writable (event); + new_x = x + video_box->box_left; + new_y = y + video_box->box_top; + + GST_TRACE_OBJECT (video_box, "from %fx%f to %fx%f", x, y, new_x, new_y); + gst_navigation_event_set_coordinates (event, new_x, new_y); + } + break; + default: + break; } GST_OBJECT_UNLOCK (video_box); diff --git a/subprojects/gst-plugins-good/gst/videocrop/gstvideocrop.c b/subprojects/gst-plugins-good/gst/videocrop/gstvideocrop.c index 9ef4d1e55d..b87ee96198 100644 --- a/subprojects/gst-plugins-good/gst/videocrop/gstvideocrop.c +++ b/subprojects/gst-plugins-good/gst/videocrop/gstvideocrop.c @@ -123,26 +123,27 @@ static GstFlowReturn gst_video_crop_transform_ip (GstBaseTransform * trans, static gboolean gst_video_crop_src_event (GstBaseTransform * trans, GstEvent * event) { - GstNavigationEventType type; - double pointer_x; - double pointer_y; + double x, y, new_x, new_y; GstVideoCrop *vcrop = GST_VIDEO_CROP (trans); GST_OBJECT_LOCK (vcrop); - type = gst_navigation_event_get_type (event); - if (GST_EVENT_TYPE (event) == GST_EVENT_NAVIGATION && - (vcrop->crop_left != 0 || vcrop->crop_top != 0) && - (type == GST_NAVIGATION_EVENT_MOUSE_MOVE - || type == GST_NAVIGATION_EVENT_MOUSE_BUTTON_PRESS - || type == GST_NAVIGATION_EVENT_MOUSE_BUTTON_RELEASE)) { - if (gst_navigation_event_get_coordinates (event, &pointer_x, &pointer_y)) { - event = gst_event_make_writable (event); - gst_navigation_event_set_coordinates (event, pointer_x + vcrop->crop_left, - pointer_y + vcrop->crop_top); - } else { - GST_WARNING_OBJECT (vcrop, "Failed to read navigation event"); - } + switch (GST_EVENT_TYPE (event)) { + case GST_EVENT_NAVIGATION: + if ((vcrop->crop_left != 0 || vcrop->crop_top != 0) + && gst_navigation_event_get_coordinates (event, &x, &y)) { + + new_x = x + vcrop->crop_left; + new_y = y + vcrop->crop_top; + + event = gst_event_make_writable (event); + + GST_TRACE_OBJECT (vcrop, "from %fx%f to %fx%f", x, y, new_x, new_y); + gst_navigation_event_set_coordinates (event, new_x, new_y); + } + break; + default: + break; } GST_OBJECT_UNLOCK (vcrop); |