mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-25 19:21:06 +00:00
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>
This commit is contained in:
parent
841f50f0d9
commit
99fc124f25
3 changed files with 34 additions and 37 deletions
|
@ -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:
|
||||
|
|
|
@ -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;
|
||||
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)) {
|
||||
|
||||
gst_navigation_event_set_coordinates (event, new_pointer_x,
|
||||
new_pointer_y);
|
||||
} else {
|
||||
GST_WARNING_OBJECT (video_box, "Failed to read navigation event");
|
||||
}
|
||||
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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue