summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien Lespiau <damien.lespiau@intel.com>2012-02-28 15:34:16 +0000
committerDamien Lespiau <damien.lespiau@intel.com>2012-02-28 15:34:16 +0000
commit8197f6f974cf57709aded7218c72911f5e753fd7 (patch)
tree69a439164ea212eeb625541356438af7a8cd6261
parent52d1c17f0437ddf5b98e060522b151510be57018 (diff)
sink: Don't try to set the aspect ratio on a texture we don't have (yet)
set_caps() was unconditionally trying to access priv->texture, even if we did not have a texture yet (which happens when using gst-launch as the texture will be created lazily.
-rw-r--r--clutter-gst/clutter-gst-video-sink.c42
1 files changed, 29 insertions, 13 deletions
diff --git a/clutter-gst/clutter-gst-video-sink.c b/clutter-gst/clutter-gst-video-sink.c
index 0793b62..bb8317e 100644
--- a/clutter-gst/clutter-gst-video-sink.c
+++ b/clutter-gst/clutter-gst-video-sink.c
@@ -338,6 +338,28 @@ clutter_gst_find_renderer_by_format (ClutterGstVideoSink *sink,
return renderer;
}
+static void
+ensure_texture_pixel_aspect_ratio (ClutterGstVideoSink *sink)
+{
+ ClutterGstVideoSinkPrivate *priv = sink->priv;
+ GParamSpec *pspec;
+ GValue par = {0, };
+
+ if (priv->texture == NULL)
+ return;
+
+ pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (priv->texture),
+ "pixel-aspect-ratio");
+ if (pspec)
+ {
+ g_value_init (&par, GST_TYPE_FRACTION);
+ gst_value_set_fraction (&par, priv->par_n, priv->par_d);
+ g_object_set_property (G_OBJECT(priv->texture),
+ "pixel-aspect-ratio", &par);
+ g_value_unset (&par);
+ }
+}
+
static gboolean
clutter_gst_parse_caps (GstCaps *caps,
ClutterGstVideoSink *sink,
@@ -432,21 +454,13 @@ clutter_gst_parse_caps (GstCaps *caps,
if (par)
{
- GParamSpec *pspec;
-
- /* If we happen to use a ClutterGstVideoTexture, now is to good time to
- * instruct it about the pixel aspect ratio so we can have a correct
- * natural width/height */
- pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (priv->texture),
- "pixel-aspect-ratio");
- if (pspec)
- {
- g_object_set_property (G_OBJECT(priv->texture),
- "pixel-aspect-ratio", par);
- }
-
priv->par_n = gst_value_get_fraction_numerator (par);
priv->par_d = gst_value_get_fraction_denominator (par);
+
+ /* If we happen to use a ClutterGstVideoTexture, now is to good time
+ * to instruct it about the pixel aspect ratio so we can have a
+ * correct natural width/height */
+ ensure_texture_pixel_aspect_ratio (sink);
}
else
priv->par_n = priv->par_d = 1;
@@ -556,6 +570,8 @@ clutter_gst_source_dispatch (GSource *source,
priv->renderer->init (gst_source->sink);
gst_source->has_new_caps = FALSE;
+
+ ensure_texture_pixel_aspect_ratio (gst_source->sink);
}
buffer = gst_source->buffer;