summaryrefslogtreecommitdiff
path: root/gst-libs/gst
diff options
context:
space:
mode:
authorWind Yuan <feng.yuan@intel.com>2012-08-22 02:18:11 -0400
committerGwenole Beauchesne <gwenole.beauchesne@intel.com>2012-08-27 18:41:22 +0200
commitc899947e17b250a70d26332210314f31934823a3 (patch)
tree8f7fa58eb9465d9c8ea6320f8ae4a25f56a4c017 /gst-libs/gst
parenta192f40ed9dceba9434823877aa04ca33865ce3a (diff)
display: add support for rotation modes.
Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
Diffstat (limited to 'gst-libs/gst')
-rw-r--r--gst-libs/gst/vaapi/gstvaapidisplay.c51
-rw-r--r--gst-libs/gst/vaapi/gstvaapidisplay.h9
-rw-r--r--gst-libs/gst/vaapi/gstvaapitypes.h15
-rw-r--r--gst-libs/gst/vaapi/gstvaapiutils.c28
-rw-r--r--gst-libs/gst/vaapi/gstvaapiutils.h8
-rw-r--r--gst-libs/gst/vaapi/gstvaapivalue.c23
-rw-r--r--gst-libs/gst/vaapi/gstvaapivalue.h12
7 files changed, 146 insertions, 0 deletions
diff --git a/gst-libs/gst/vaapi/gstvaapidisplay.c b/gst-libs/gst/vaapi/gstvaapidisplay.c
index 8eed95d6..a212a106 100644
--- a/gst-libs/gst/vaapi/gstvaapidisplay.c
+++ b/gst-libs/gst/vaapi/gstvaapidisplay.c
@@ -1415,3 +1415,54 @@ gst_vaapi_display_set_render_mode(
return FALSE;
return TRUE;
}
+
+/**
+ * gst_vaapi_display_get_rotation:
+ * @display: a #GstVaapiDisplay
+ *
+ * Returns the current VA @display rotation angle. If the VA driver
+ * does not support "rotation" display attribute, then the display is
+ * assumed to be un-rotated.
+ *
+ * Return value: the current #GstVaapiRotation value
+ */
+GstVaapiRotation
+gst_vaapi_display_get_rotation(GstVaapiDisplay *display)
+{
+ gint value;
+
+ g_return_val_if_fail(GST_VAAPI_IS_DISPLAY(display), GST_VAAPI_ROTATION_0);
+
+ if (!get_attribute(display, VADisplayAttribRotation, &value))
+ value = VA_ROTATION_NONE;
+ return to_GstVaapiRotation(value);
+}
+
+/**
+ * gst_vaapi_display_set_rotation:
+ * @display: a #GstVaapiDisplay
+ * @rotation: the #GstVaapiRotation value to set
+ *
+ * Sets the VA @display rotation angle to the supplied @rotation
+ * value. This function returns %FALSE if the rotation angle could not
+ * be set, e.g. the VA driver does not allow to change the display
+ * rotation angle.
+ *
+ * Return value: %TRUE if VA @display rotation angle could be changed
+ * to the requested value
+ */
+gboolean
+gst_vaapi_display_set_rotation(
+ GstVaapiDisplay *display,
+ GstVaapiRotation rotation
+)
+{
+ guint value;
+
+ g_return_val_if_fail(GST_VAAPI_IS_DISPLAY(display), FALSE);
+
+ value = from_GstVaapiRotation(rotation);
+ if (!set_attribute(display, VADisplayAttribRotation, value))
+ return FALSE;
+ return TRUE;
+}
diff --git a/gst-libs/gst/vaapi/gstvaapidisplay.h b/gst-libs/gst/vaapi/gstvaapidisplay.h
index 6240e513..6dac4c5f 100644
--- a/gst-libs/gst/vaapi/gstvaapidisplay.h
+++ b/gst-libs/gst/vaapi/gstvaapidisplay.h
@@ -234,6 +234,15 @@ gst_vaapi_display_set_render_mode(
GstVaapiRenderMode mode
);
+GstVaapiRotation
+gst_vaapi_display_get_rotation(GstVaapiDisplay *display);
+
+gboolean
+gst_vaapi_display_set_rotation(
+ GstVaapiDisplay *display,
+ GstVaapiRotation rotation
+);
+
G_END_DECLS
#endif /* GST_VAAPI_DISPLAY_H */
diff --git a/gst-libs/gst/vaapi/gstvaapitypes.h b/gst-libs/gst/vaapi/gstvaapitypes.h
index 241051f8..ff5f9eb9 100644
--- a/gst-libs/gst/vaapi/gstvaapitypes.h
+++ b/gst-libs/gst/vaapi/gstvaapitypes.h
@@ -135,6 +135,21 @@ enum _GstVaapiRenderMode {
GST_VAAPI_RENDER_MODE_TEXTURE
};
+/**
+ * GstVaapiRotation:
+ * @GST_VAAPI_ROTATION_0: the VA display is not rotated.
+ * @GST_VAAPI_ROTATION_90: the VA display is rotated by 90°, clockwise.
+ * @GST_VAAPI_ROTATION_180: the VA display is rotated by 180°, clockwise.
+ * @GST_VAAPI_ROTATION_270: the VA display is rotated by 270°, clockwise.
+ */
+typedef enum _GstVaapiRotation GstVaapiRotation;
+enum _GstVaapiRotation {
+ GST_VAAPI_ROTATION_0 = 0,
+ GST_VAAPI_ROTATION_90 = 90,
+ GST_VAAPI_ROTATION_180 = 180,
+ GST_VAAPI_ROTATION_270 = 270,
+};
+
G_END_DECLS
#endif /* GST_VAAPI_TYPES_H */
diff --git a/gst-libs/gst/vaapi/gstvaapiutils.c b/gst-libs/gst/vaapi/gstvaapiutils.c
index 41682a98..996e328c 100644
--- a/gst-libs/gst/vaapi/gstvaapiutils.c
+++ b/gst-libs/gst/vaapi/gstvaapiutils.c
@@ -273,3 +273,31 @@ to_GstVaapiSurfaceStatus(guint va_flags)
#endif
return flags;
}
+
+/* Translate GstVaapiRotation value to VA-API rotation value */
+guint
+from_GstVaapiRotation(guint value)
+{
+ switch (value) {
+ case GST_VAAPI_ROTATION_0: return VA_ROTATION_NONE;
+ case GST_VAAPI_ROTATION_90: return VA_ROTATION_90;
+ case GST_VAAPI_ROTATION_180: return VA_ROTATION_180;
+ case GST_VAAPI_ROTATION_270: return VA_ROTATION_270;
+ }
+ GST_ERROR("unsupported GstVaapiRotation value %d", value);
+ return VA_ROTATION_NONE;
+}
+
+/* Translate VA-API rotation value to GstVaapiRotation value */
+guint
+to_GstVaapiRotation(guint value)
+{
+ switch (value) {
+ case VA_ROTATION_NONE: return GST_VAAPI_ROTATION_0;
+ case VA_ROTATION_90: return GST_VAAPI_ROTATION_90;
+ case VA_ROTATION_180: return GST_VAAPI_ROTATION_180;
+ case VA_ROTATION_270: return GST_VAAPI_ROTATION_270;
+ }
+ GST_ERROR("unsupported VA-API rotation value %d", value);
+ return GST_VAAPI_ROTATION_0;
+}
diff --git a/gst-libs/gst/vaapi/gstvaapiutils.h b/gst-libs/gst/vaapi/gstvaapiutils.h
index 644fd584..98d91e37 100644
--- a/gst-libs/gst/vaapi/gstvaapiutils.h
+++ b/gst-libs/gst/vaapi/gstvaapiutils.h
@@ -81,4 +81,12 @@ G_GNUC_INTERNAL
guint
to_GstVaapiSurfaceStatus(guint va_flags);
+G_GNUC_INTERNAL
+guint
+from_GstVaapiRotation(guint value);
+
+G_GNUC_INTERNAL
+guint
+to_GstVaapiRotation(guint value);
+
#endif /* GST_VAAPI_UTILS_H */
diff --git a/gst-libs/gst/vaapi/gstvaapivalue.c b/gst-libs/gst/vaapi/gstvaapivalue.c
index 703fca9c..8461c09e 100644
--- a/gst-libs/gst/vaapi/gstvaapivalue.c
+++ b/gst-libs/gst/vaapi/gstvaapivalue.c
@@ -185,3 +185,26 @@ gst_vaapi_render_mode_get_type(void)
}
return render_mode_type;
}
+
+/* --- GstVaapiRotation --- */
+
+GType
+gst_vaapi_rotation_get_type(void)
+{
+ static GType g_type = 0;
+
+ static const GEnumValue rotation_values[] = {
+ { GST_VAAPI_ROTATION_0,
+ "Unrotated mode", "0" },
+ { GST_VAAPI_ROTATION_90,
+ "Rotated by 90°, clockwise", "90" },
+ { GST_VAAPI_ROTATION_180,
+ "Rotated by 180°, clockwise", "180" },
+ { GST_VAAPI_ROTATION_270,
+ "Rotated by 270°, clockwise", "270" },
+ };
+
+ if (!g_type)
+ g_type = g_enum_register_static("GstVaapiRotation", rotation_values);
+ return g_type;
+}
diff --git a/gst-libs/gst/vaapi/gstvaapivalue.h b/gst-libs/gst/vaapi/gstvaapivalue.h
index 0c2c719e..ec99f8e5 100644
--- a/gst-libs/gst/vaapi/gstvaapivalue.h
+++ b/gst-libs/gst/vaapi/gstvaapivalue.h
@@ -54,6 +54,15 @@ G_BEGIN_DECLS
*/
#define GST_VAAPI_TYPE_RENDER_MODE gst_vaapi_render_mode_get_type()
+/**
+ * GST_VAAPI_TYPE_ROTATION:
+ *
+ * A type that represents the VA display rotation.
+ *
+ * Return value: the #GType of GstVaapiRotation
+ */
+#define GST_VAAPI_TYPE_ROTATION gst_vaapi_rotation_get_type()
+
GType
gst_vaapi_id_get_type(void) G_GNUC_CONST;
@@ -66,6 +75,9 @@ gst_vaapi_value_set_id(GValue *value, GstVaapiID id);
GType
gst_vaapi_render_mode_get_type(void) G_GNUC_CONST;
+GType
+gst_vaapi_rotation_get_type(void) G_GNUC_CONST;
+
G_END_DECLS
#endif /* GST_VAAPI_VALUE_H */