From 7fc93fbebc9320a48c439d34721075270181f824 Mon Sep 17 00:00:00 2001 From: "Eugenio Paolantonio (g7)" Date: Sun, 26 Mar 2023 16:14:22 +0200 Subject: [PATCH] plugin: Add helper to get the actual width and height for a specific rotation Signed-off-by: Eugenio Paolantonio (g7) --- lib/gst/plugin/gstgtkutils.c | 20 ++++++++++++++++++++ lib/gst/plugin/gstgtkutils.h | 4 ++++ 2 files changed, 24 insertions(+) diff --git a/lib/gst/plugin/gstgtkutils.c b/lib/gst/plugin/gstgtkutils.c index 19cf233b..4570726f 100644 --- a/lib/gst/plugin/gstgtkutils.c +++ b/lib/gst/plugin/gstgtkutils.c @@ -140,3 +140,23 @@ gst_video_frame_into_gdk_texture (GstVideoFrame *frame) return texture; } + +void +gst_gtk_get_width_height_for_rotation (gint width, gint height, + gint *out_width, gint *out_height, + GstVideoOrientationMethod rotation) +{ + switch (rotation) { + case GST_VIDEO_ORIENTATION_90R: + case GST_VIDEO_ORIENTATION_90L: + case GST_VIDEO_ORIENTATION_UL_LR: + case GST_VIDEO_ORIENTATION_UR_LL: + *out_width = height; + *out_height = width; + break; + default: + *out_width = width; + *out_height = height; + break; + } +} diff --git a/lib/gst/plugin/gstgtkutils.h b/lib/gst/plugin/gstgtkutils.h index 3e8fa5dc..972eccba 100644 --- a/lib/gst/plugin/gstgtkutils.h +++ b/lib/gst/plugin/gstgtkutils.h @@ -32,4 +32,8 @@ gpointer gst_gtk_invoke_on_main (GThreadFunc func, gpointe GdkTexture * gst_video_frame_into_gdk_texture (GstVideoFrame *frame); +void gst_gtk_get_width_height_for_rotation (gint width, gint height, + gint *out_width, gint *out_height, + GstVideoOrientationMethod rotation); + G_END_DECLS