vdpau: remove GstVdpOutputSrcPad "template-caps" property

instead we do as GstVdpVideoSrcPad and use the "templ" property of GstPad,
which enable us to change the signature of gst_vdp_output_src_pad_new to match
gst_pad_new_from_template
This commit is contained in:
Carl-Anton Ingmarsson 2010-07-28 21:39:12 +02:00
parent 5626857ac4
commit 093fcacc20
4 changed files with 21 additions and 50 deletions

View file

@ -29,8 +29,7 @@ GST_DEBUG_CATEGORY_STATIC (gst_vdp_output_src_pad_debug);
enum enum
{ {
PROP_0, PROP_0,
PROP_DEVICE, PROP_DEVICE
PROP_TEMPL_CAPS
}; };
typedef enum _GstVdpOutputSrcPadFormat GstVdpOutputSrcPadFormat; typedef enum _GstVdpOutputSrcPadFormat GstVdpOutputSrcPadFormat;
@ -54,7 +53,6 @@ struct _GstVdpOutputSrcPad
/* properties */ /* properties */
GstVdpDevice *device; GstVdpDevice *device;
GstCaps *templ_caps;
}; };
struct _GstVdpOutputSrcPadClass struct _GstVdpOutputSrcPadClass
@ -318,10 +316,15 @@ gst_vdp_output_src_pad_getcaps (GstPad * pad)
{ {
GstVdpOutputSrcPad *vdp_pad = (GstVdpOutputSrcPad *) pad; GstVdpOutputSrcPad *vdp_pad = (GstVdpOutputSrcPad *) pad;
const GstCaps *templ_caps;
if (vdp_pad->caps) if (vdp_pad->caps)
return gst_caps_ref (vdp_pad->caps); return gst_caps_ref (vdp_pad->caps);
return gst_caps_ref (vdp_pad->templ_caps); else if ((templ_caps = gst_pad_get_pad_template_caps (pad)))
return gst_caps_copy (templ_caps);
return NULL;
} }
static gboolean static gboolean
@ -343,29 +346,28 @@ gst_vdp_output_src_pad_activate_push (GstPad * pad, gboolean active)
} }
GstVdpOutputSrcPad * GstVdpOutputSrcPad *
gst_vdp_output_src_pad_new (GstCaps * templ_caps) gst_vdp_output_src_pad_new (GstPadTemplate * templ, const gchar * name)
{ {
return g_object_new (GST_TYPE_VDP_OUTPUT_SRC_PAD, "template-caps", templ_caps, return g_object_new (GST_TYPE_VDP_OUTPUT_SRC_PAD, "name", name,
"direction", GST_PAD_SRC, NULL); "template", templ, "direction", GST_PAD_SRC, NULL);
} }
static void static void
gst_vdp_output_src_pad_update_caps (GstVdpOutputSrcPad * vdp_pad) gst_vdp_output_src_pad_update_caps (GstVdpOutputSrcPad * vdp_pad)
{ {
GstCaps *allowed_caps; GstCaps *caps;
const GstCaps *templ_caps;
allowed_caps = gst_vdp_output_buffer_get_allowed_caps (vdp_pad->device);
if (vdp_pad->caps) if (vdp_pad->caps)
gst_caps_unref (vdp_pad->caps); gst_caps_unref (vdp_pad->caps);
if (vdp_pad->templ_caps) { caps = gst_vdp_output_buffer_get_allowed_caps (vdp_pad->device);
vdp_pad->caps = gst_caps_intersect (allowed_caps, vdp_pad->templ_caps);
gst_caps_unref (allowed_caps);
} else
vdp_pad->caps = allowed_caps;
GST_DEBUG_OBJECT (vdp_pad, "allowed caps: %" GST_PTR_FORMAT, vdp_pad->caps); if ((templ_caps = gst_pad_get_pad_template_caps (GST_PAD (vdp_pad)))) {
vdp_pad->caps = gst_caps_intersect (caps, templ_caps);
gst_caps_unref (caps);
} else
vdp_pad->caps = caps;
} }
static void static void
@ -379,10 +381,6 @@ gst_vdp_output_src_pad_get_property (GObject * object, guint prop_id,
g_value_set_object (value, vdp_pad->device); g_value_set_object (value, vdp_pad->device);
break; break;
case PROP_TEMPL_CAPS:
gst_value_set_caps (value, vdp_pad->templ_caps);
break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break; break;
@ -403,29 +401,12 @@ gst_vdp_output_src_pad_set_property (GObject * object, guint prop_id,
gst_vdp_output_src_pad_update_caps (vdp_pad); gst_vdp_output_src_pad_update_caps (vdp_pad);
break; break;
case PROP_TEMPL_CAPS:
if (vdp_pad->templ_caps)
gst_caps_unref (vdp_pad->templ_caps);
vdp_pad->templ_caps = gst_caps_copy (gst_value_get_caps (value));
break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break; break;
} }
} }
static void
gst_vdp_output_src_pad_finalize (GObject * object)
{
GstVdpOutputSrcPad *vdp_pad = (GstVdpOutputSrcPad *) object;
if (vdp_pad->templ_caps)
gst_caps_unref (vdp_pad->templ_caps);
G_OBJECT_CLASS (gst_vdp_output_src_pad_parent_class)->finalize (object);
}
static void static void
gst_vdp_output_src_pad_init (GstVdpOutputSrcPad * vdp_pad) gst_vdp_output_src_pad_init (GstVdpOutputSrcPad * vdp_pad)
{ {
@ -434,7 +415,6 @@ gst_vdp_output_src_pad_init (GstVdpOutputSrcPad * vdp_pad)
vdp_pad->caps = NULL; vdp_pad->caps = NULL;
vdp_pad->device = NULL; vdp_pad->device = NULL;
vdp_pad->templ_caps = NULL;
gst_pad_set_getcaps_function (pad, gst_pad_set_getcaps_function (pad,
GST_DEBUG_FUNCPTR (gst_vdp_output_src_pad_getcaps)); GST_DEBUG_FUNCPTR (gst_vdp_output_src_pad_getcaps));
@ -449,7 +429,6 @@ gst_vdp_output_src_pad_class_init (GstVdpOutputSrcPadClass * klass)
object_class->get_property = gst_vdp_output_src_pad_get_property; object_class->get_property = gst_vdp_output_src_pad_get_property;
object_class->set_property = gst_vdp_output_src_pad_set_property; object_class->set_property = gst_vdp_output_src_pad_set_property;
object_class->finalize = gst_vdp_output_src_pad_finalize;
/** /**
* GstVdpVideoSrcPad:device: * GstVdpVideoSrcPad:device:
@ -463,10 +442,4 @@ gst_vdp_output_src_pad_class_init (GstVdpOutputSrcPadClass * klass)
"Device", "Device",
"The GstVdpDevice the pad should use", "The GstVdpDevice the pad should use",
GST_TYPE_VDP_DEVICE, G_PARAM_READWRITE)); GST_TYPE_VDP_DEVICE, G_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_TEMPL_CAPS,
g_param_spec_boxed ("template-caps", "Template caps",
"Template caps", GST_TYPE_CAPS,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
} }

View file

@ -45,7 +45,7 @@ GstFlowReturn gst_vdp_output_src_pad_get_device (GstVdpOutputSrcPad *vdp_pad, Gs
gboolean gst_vdp_output_src_pad_negotiate_output (GstVdpOutputSrcPad *vdp_pad, GstCaps *video_caps); gboolean gst_vdp_output_src_pad_negotiate_output (GstVdpOutputSrcPad *vdp_pad, GstCaps *video_caps);
GstVdpOutputSrcPad *gst_vdp_output_src_pad_new (GstCaps * templ_caps); GstVdpOutputSrcPad *gst_vdp_output_src_pad_new (GstPadTemplate *templ, const gchar *name);
GType gst_vdp_output_src_pad_get_type (void); GType gst_vdp_output_src_pad_get_type (void);
G_END_DECLS G_END_DECLS

View file

@ -238,7 +238,7 @@ gst_vdp_video_src_pad_getcaps (GstPad * pad)
const GstCaps *templ_caps; const GstCaps *templ_caps;
if (vdp_pad->caps) if (vdp_pad->caps)
return gst_caps_copy (vdp_pad->caps); return gst_caps_ref (vdp_pad->caps);
else if ((templ_caps = gst_pad_get_pad_template_caps (pad))) else if ((templ_caps = gst_pad_get_pad_template_caps (pad)))
return gst_caps_copy (templ_caps); return gst_caps_copy (templ_caps);

View file

@ -1273,9 +1273,7 @@ gst_vdp_vpp_init (GstVdpVideoPostProcess * vpp,
src_template = src_template =
gst_element_class_get_pad_template (GST_ELEMENT_CLASS (gclass), "src"); gst_element_class_get_pad_template (GST_ELEMENT_CLASS (gclass), "src");
vpp->srcpad = vpp->srcpad = GST_PAD (gst_vdp_output_src_pad_new (src_template, "src"));
GST_PAD (gst_vdp_output_src_pad_new (gst_pad_template_get_caps
(src_template)));
gst_element_add_pad (GST_ELEMENT (vpp), vpp->srcpad); gst_element_add_pad (GST_ELEMENT (vpp), vpp->srcpad);
gst_pad_set_event_function (vpp->srcpad, gst_pad_set_event_function (vpp->srcpad,