{
const GValue *fps;
gchar *fps_string;
-
- const GstCaps *caps = NULL;
+ GstCaps *caps = NULL;
GstStructure *structure;
/* get pad caps */
- caps = GST_PAD_CAPS (pad);
- if (caps == NULL) {
+ caps = gst_pad_get_current_caps (pad);
+ if (caps == NULL)
+ goto no_caps;
+
+ structure = gst_caps_get_structure (caps, 0);
+ if ((fps = gst_structure_get_value (structure, "framerate")) == NULL)
+ goto no_framerate;
+
+ if (!GST_VALUE_HOLDS_FRACTION (fps))
+ goto no_fraction;
+
+ fps_string = gst_value_serialize (fps);
+ GST_DEBUG ("Framerate request on pad %s:%s: %s",
+ GST_DEBUG_PAD_NAME (pad), fps_string);
+ g_free (fps_string);
+
+ gst_caps_unref (caps);
+
+ return fps;
+
+ /* ERRORS */
+no_caps:
+ {
g_warning ("gstvideo: failed to get caps of pad %s:%s",
GST_DEBUG_PAD_NAME (pad));
return NULL;
}
-
- structure = gst_caps_get_structure (caps, 0);
- if ((fps = gst_structure_get_value (structure, "framerate")) == NULL) {
+no_framerate:
+ {
g_warning ("gstvideo: failed to get framerate property of pad %s:%s",
GST_DEBUG_PAD_NAME (pad));
+ gst_caps_unref (caps);
return NULL;
}
- if (!GST_VALUE_HOLDS_FRACTION (fps)) {
+no_fraction:
+ {
g_warning
("gstvideo: framerate property of pad %s:%s is not of type Fraction",
GST_DEBUG_PAD_NAME (pad));
+ gst_caps_unref (caps);
return NULL;
}
-
- fps_string = gst_value_serialize (fps);
- GST_DEBUG ("Framerate request on pad %s:%s: %s",
- GST_DEBUG_PAD_NAME (pad), fps_string);
- g_free (fps_string);
-
- return fps;
}
/**
gboolean
gst_video_get_size (GstPad * pad, gint * width, gint * height)
{
- const GstCaps *caps = NULL;
+ GstCaps *caps = NULL;
GstStructure *structure;
gboolean ret;
g_return_val_if_fail (width != NULL, FALSE);
g_return_val_if_fail (height != NULL, FALSE);
- caps = GST_PAD_CAPS (pad);
-
- if (caps == NULL) {
- g_warning ("gstvideo: failed to get caps of pad %s:%s",
- GST_DEBUG_PAD_NAME (pad));
- return FALSE;
- }
+ caps = gst_pad_get_current_caps (pad);
+ if (caps == NULL)
+ goto no_caps;
structure = gst_caps_get_structure (caps, 0);
ret = gst_structure_get_int (structure, "width", width);
ret &= gst_structure_get_int (structure, "height", height);
+ gst_caps_unref (caps);
- if (!ret) {
- g_warning ("gstvideo: failed to get size properties on pad %s:%s",
- GST_DEBUG_PAD_NAME (pad));
- return FALSE;
- }
+ if (!ret)
+ goto no_size;
GST_DEBUG ("size request on pad %s:%s: %dx%d",
GST_DEBUG_PAD_NAME (pad), width ? *width : -1, height ? *height : -1);
return TRUE;
+
+ /* ERROR */
+no_caps:
+ {
+ g_warning ("gstvideo: failed to get caps of pad %s:%s",
+ GST_DEBUG_PAD_NAME (pad));
+ return FALSE;
+ }
+no_size:
+ {
+ g_warning ("gstvideo: failed to get size properties on pad %s:%s",
+ GST_DEBUG_PAD_NAME (pad));
+ return FALSE;
+ }
}
/**