[cogl/rig: 13/13] stash: cogl-gst: cogl_gst_video_sink_get_natural_size()
- From: Robert Bragg <rbragg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [cogl/rig: 13/13] stash: cogl-gst: cogl_gst_video_sink_get_natural_size()
- Date: Fri, 14 Mar 2014 03:12:34 +0000 (UTC)
commit d2dfbf87938f89cb4876bbb4f6f693c0ff76654f
Author: Robert Bragg <robert linux intel com>
Date: Thu Mar 13 01:20:52 2014 +0000
stash: cogl-gst: cogl_gst_video_sink_get_natural_size()
cogl-gst/cogl-gst-plugin.c | 5 ++-
cogl-gst/cogl-gst-video-sink.c | 47 ++++++++++++++++++++++++++++++
cogl-gst/cogl-gst-video-sink.h | 62 ++++++++++++++++++++++++++++++++++++++++
3 files changed, 113 insertions(+), 1 deletions(-)
---
diff --git a/cogl-gst/cogl-gst-plugin.c b/cogl-gst/cogl-gst-plugin.c
index 7edbe94..8b6a7ed 100644
--- a/cogl-gst/cogl-gst-plugin.c
+++ b/cogl-gst/cogl-gst-plugin.c
@@ -37,7 +37,10 @@
#define PACKAGE "CoglGst"
-static CoglBool
+CoglBool
+_plugin_init (GstPlugin *coglgstvideosink);
+
+CoglBool
_plugin_init (GstPlugin *coglgstvideosink)
{
return gst_element_register (coglgstvideosink,
diff --git a/cogl-gst/cogl-gst-video-sink.c b/cogl-gst/cogl-gst-video-sink.c
index 7118ca3..262dbd9 100644
--- a/cogl-gst/cogl-gst-video-sink.c
+++ b/cogl-gst/cogl-gst-video-sink.c
@@ -1655,6 +1655,53 @@ cogl_gst_video_sink_fit_size (CoglGstVideoSink *vt,
}
}
+void
+cogl_gst_video_sink_get_natural_size (CoglGstVideoSink *vt,
+ float *width,
+ float *height)
+{
+ GstVideoInfo *info;
+
+ g_return_val_if_fail (COGL_GST_IS_VIDEO_SINK (vt), 0.);
+
+ info = &vt->priv->info;
+
+ if (info->par_n < info->par_d)
+ {
+ /* In this case the encoded pixels are taller than they are wide
+ * so they will be stretched horizontally.
+ */
+
+ if (height)
+ *height = info->height;
+ if (width)
+ *width = cogl_gst_video_sink_get_width_for_height (vt, info->height);
+ }
+ else
+ {
+ if (width)
+ *width = info->width;
+ if (height)
+ *height = cogl_gst_video_sink_get_height_for_width (vt, info->width);
+ }
+}
+
+float
+cogl_gst_video_sink_get_natural_width (CoglGstVideoSink *vt)
+{
+ float width;
+ cogl_gst_video_sink_get_natural_size (vt, &width, NULL);
+ return width;
+}
+
+float
+cogl_gst_video_sink_get_natural_height (CoglGstVideoSink *vt)
+{
+ float height;
+ cogl_gst_video_sink_get_natural_size (vt, NULL, &height);
+ return height;
+}
+
CoglBool
cogl_gst_video_sink_is_ready (CoglGstVideoSink *sink)
{
diff --git a/cogl-gst/cogl-gst-video-sink.h b/cogl-gst/cogl-gst-video-sink.h
index 3c11be7..bfc17e7 100644
--- a/cogl-gst/cogl-gst-video-sink.h
+++ b/cogl-gst/cogl-gst-video-sink.h
@@ -413,6 +413,68 @@ cogl_gst_video_sink_get_height_for_width (CoglGstVideoSink *sink,
float width);
/**
+ * cogl_gst_video_sink_get_natural_size:
+ * @sink: A #CoglGstVideoSink
+ * @width: (out): return location for the video's natural width
+ * @height: (out): return location for the video's natural height
+ *
+ * Considering the real resolution of the video as well as the aspect
+ * ratio of pixel data that may need to be stretched when being displayed;
+ * this function calculates what the natural size of the underlying
+ * video source is.
+ *
+ * The natural size has the correct aspect ratio for displaying the
+ * video and is the minimum size where downscaling is not required.
+ *
+ * Since: 1.18
+ * Stability: unstable
+ */
+void
+cogl_gst_video_sink_get_natural_size (CoglGstVideoSink *sink,
+ float *width,
+ float *height);
+
+/**
+ * cogl_gst_video_sink_get_natural_width:
+ * @sink: A #CoglGstVideoSink
+ *
+ * Considering the real resolution of the video as well as the aspect
+ * ratio of pixel data that may need to be stretched when being displayed;
+ * this function calculates what the natural size of the underlying
+ * video source is, and returns its width.
+ *
+ * The natural size has the correct aspect ratio for displaying the
+ * video and is the minimum size where downscaling is not required.
+ *
+ * Return value: The video's natural width
+ *
+ * Since: 1.18
+ * Stability: unstable
+ */
+float
+cogl_gst_video_sink_get_natural_width (CoglGstVideoSink *sink);
+
+/**
+ * cogl_gst_video_sink_get_natural_height:
+ * @sink: A #CoglGstVideoSink
+ *
+ * Considering the real resolution of the video as well as the aspect
+ * ratio of pixel data that may need to be stretched when being displayed;
+ * this function calculates what the natural size of the underlying
+ * video source is, and returns its height.
+ *
+ * The natural size has the correct aspect ratio for displaying the
+ * video and is the minimum size where downscaling is not required.
+ *
+ * Return value: The video's natural height
+ *
+ * Since: 1.18
+ * Stability: unstable
+ */
+float
+cogl_gst_video_sink_get_natural_height (CoglGstVideoSink *sink);
+
+/**
* CoglGstRectangle:
* @x: The X coordinate of the top left of the rectangle
* @y: The Y coordinate of the top left of the rectangle
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]