plugin: Add helper to get the actual width and height for a specific rotation

Signed-off-by: Eugenio Paolantonio (g7) <me@medesimo.eu>
This commit is contained in:
Eugenio Paolantonio (g7)
2023-03-26 16:14:22 +02:00
parent bf52197896
commit 7fc93fbebc
2 changed files with 24 additions and 0 deletions

View File

@@ -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;
}
}

View File

@@ -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