[totem] backend: Expose rotation through video widget



commit 195c68503513dbfaee6bf537de3932ec0be49b5f
Author: Bastien Nocera <hadess hadess net>
Date:   Wed Jun 27 20:21:00 2012 +0100

    backend: Expose rotation through video widget

 src/backend/bacon-video-widget-gst-0.10.c |   49 +++++++++++++++++++++++++++++
 src/backend/bacon-video-widget.h          |   21 ++++++++++++
 2 files changed, 70 insertions(+), 0 deletions(-)
---
diff --git a/src/backend/bacon-video-widget-gst-0.10.c b/src/backend/bacon-video-widget-gst-0.10.c
index 8fe73d8..61ef78b 100644
--- a/src/backend/bacon-video-widget-gst-0.10.c
+++ b/src/backend/bacon-video-widget-gst-0.10.c
@@ -226,6 +226,8 @@ struct BaconVideoWidgetPrivate
   gdouble                      volume;
   gboolean                     is_menu;
   gboolean                     has_angles;
+
+  BvwRotation                  rotation;
   
   gint                         video_width; /* Movie width */
   gint                         video_height; /* Movie height */
@@ -1142,6 +1144,7 @@ bacon_video_widget_init (BaconVideoWidget * bvw)
 
   g_type_class_ref (BVW_TYPE_METADATA_TYPE);
   g_type_class_ref (BVW_TYPE_DVD_EVENT);
+  g_type_class_ref (BVW_TYPE_ROTATION);
 
   bvw->priv = priv = G_TYPE_INSTANCE_GET_PRIVATE (bvw, BACON_TYPE_VIDEO_WIDGET, BaconVideoWidgetPrivate);
 
@@ -2567,6 +2570,7 @@ bacon_video_widget_finalize (GObject * object)
 
   g_type_class_unref (g_type_class_peek (BVW_TYPE_METADATA_TYPE));
   g_type_class_unref (g_type_class_peek (BVW_TYPE_DVD_EVENT));
+  g_type_class_unref (g_type_class_peek (BVW_TYPE_ROTATION));
 
   if (bvw->priv->bus) {
     /* make bus drop all messages to make sure none of our callbacks is ever
@@ -4830,6 +4834,51 @@ bacon_video_widget_get_zoom (BaconVideoWidget *bvw)
   return expand ? BVW_ZOOM_EXPAND : BVW_ZOOM_NONE;
 }
 
+/**
+ * bacon_video_widget_set_rotation:
+ * @bvw: a #BaconVideoWidget
+ * @rotation: the #BvwRotation of the video in degrees
+ *
+ * Sets the rotation to be applied to the video when it is displayed.
+ **/
+void
+bacon_video_widget_set_rotation (BaconVideoWidget *bvw,
+				 BvwRotation       rotation)
+{
+  gfloat angle;
+
+  g_return_if_fail (BACON_IS_VIDEO_WIDGET (bvw));
+
+  if (bvw->priv->frame == NULL)
+    return;
+
+  GST_DEBUG ("Rotating to %s (%f degrees) from %s",
+	     get_type_name (BVW_TYPE_ROTATION, rotation),
+	     rotation * 90.0,
+	     get_type_name (BVW_TYPE_ROTATION, bvw->priv->rotation));
+
+  bvw->priv->rotation = rotation;
+
+  angle = rotation * 90.0;
+  totem_aspect_frame_set_rotation (TOTEM_ASPECT_FRAME (bvw->priv->frame), angle);
+}
+
+/**
+ * bacon_video_widget_get_rotation:
+ * @bvw: a #BaconVideoWidget
+ *
+ * Returns the angle of rotation of the video, in degrees.
+ *
+ * Return value: a #BvwRotation.
+ **/
+BvwRotation
+bacon_video_widget_get_rotation (BaconVideoWidget *bvw)
+{
+  g_return_val_if_fail (BACON_IS_VIDEO_WIDGET (bvw), BVW_ROTATION_R_0);
+
+  return bvw->priv->rotation;
+}
+
 /* Search for the color balance channel corresponding to type and return it. */
 static GstColorBalanceChannel *
 bvw_get_color_balance_channel (GstColorBalance * color_balance,
diff --git a/src/backend/bacon-video-widget.h b/src/backend/bacon-video-widget.h
index c25654e..9c82a75 100644
--- a/src/backend/bacon-video-widget.h
+++ b/src/backend/bacon-video-widget.h
@@ -347,6 +347,23 @@ typedef enum {
 	BVW_ZOOM_EXPAND = 1
 } BvwZoomMode;
 
+/**
+ * BvwRotation:
+ * @BVW_ROTATION_0: No rotation
+ * @BVW_ROTATION_90R: Rotate 90 degrees to the right
+ * @BVW_ROTATION_180: Rotate 180 degrees
+ * @BVW_ROTATION_90L: Rotate 90 degrees to the left
+ *
+ * The rotation is used by the video widget, as set by
+ * bacon_video_widget_set_rotation().
+ **/
+typedef enum {
+	BVW_ROTATION_R_0 = 0,
+	BVW_ROTATION_R_90R = 1,
+	BVW_ROTATION_R_180 = 2,
+	BVW_ROTATION_R_90L = 3
+} BvwRotation;
+
 void bacon_video_widget_set_deinterlacing        (BaconVideoWidget *bvw,
 						  gboolean deinterlace);
 gboolean bacon_video_widget_get_deinterlacing    (BaconVideoWidget *bvw);
@@ -363,6 +380,10 @@ void bacon_video_widget_set_zoom		 (BaconVideoWidget *bvw,
 						  BvwZoomMode       mode);
 BvwZoomMode bacon_video_widget_get_zoom		 (BaconVideoWidget *bvw);
 
+void bacon_video_widget_set_rotation		 (BaconVideoWidget *bvw,
+						  BvwRotation       rotation);
+BvwRotation bacon_video_widget_get_rotation	 (BaconVideoWidget *bvw);
+
 int bacon_video_widget_get_video_property        (BaconVideoWidget *bvw,
 						  BvwVideoProperty type);
 void bacon_video_widget_set_video_property       (BaconVideoWidget *bvw,



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]