From 50433576b5a3474f26f17055aa2e073a5d0b6372 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Thu, 18 Jan 2018 19:08:10 +0200 Subject: [PATCH] padtemplate: Add gst_pad_template_new_with_gtype() For being able to create a pad template with GType without having a static pad template. --- gst/gstpadtemplate.c | 39 +++++++++++++++++++++++++++++++++++++++ gst/gstpadtemplate.h | 3 +++ 2 files changed, 42 insertions(+) diff --git a/gst/gstpadtemplate.c b/gst/gstpadtemplate.c index 77853fdc83..0e2a3dfd28 100644 --- a/gst/gstpadtemplate.c +++ b/gst/gstpadtemplate.c @@ -395,6 +395,45 @@ gst_pad_template_new (const gchar * name_template, return new; } +/** + * gst_pad_template_new_with_gtype: + * @name_template: the name template. + * @direction: the #GstPadDirection of the template. + * @presence: the #GstPadPresence of the pad. + * @caps: (transfer none): a #GstCaps set for the template. + * @pad_type: The #GType of the pad to create + * + * Creates a new pad template with a name according to the given template + * and with the given arguments. + * + * Returns: (transfer floating): a new #GstPadTemplate. + */ +GstPadTemplate * +gst_pad_template_new_with_gtype (const gchar * name_template, + GstPadDirection direction, GstPadPresence presence, GstCaps * caps, + GType pad_type) +{ + GstPadTemplate *new; + + g_return_val_if_fail (name_template != NULL, NULL); + g_return_val_if_fail (caps != NULL, NULL); + g_return_val_if_fail (direction == GST_PAD_SRC + || direction == GST_PAD_SINK, NULL); + g_return_val_if_fail (presence == GST_PAD_ALWAYS + || presence == GST_PAD_SOMETIMES || presence == GST_PAD_REQUEST, NULL); + + if (!name_is_valid (name_template, presence)) { + return NULL; + } + + new = g_object_new (gst_pad_template_get_type (), + "name", name_template, "name-template", name_template, + "direction", direction, "presence", presence, "caps", caps, + "gtype", pad_type, NULL); + + return new; +} + /** * gst_static_pad_template_get_caps: * @templ: a #GstStaticPadTemplate to get capabilities of. diff --git a/gst/gstpadtemplate.h b/gst/gstpadtemplate.h index 77dc8a1538..70ea72f570 100644 --- a/gst/gstpadtemplate.h +++ b/gst/gstpadtemplate.h @@ -201,6 +201,9 @@ GST_EXPORT GstPadTemplate* gst_pad_template_new (const gchar *name_template, GstPadDirection direction, GstPadPresence presence, GstCaps *caps) G_GNUC_MALLOC; +GstPadTemplate* gst_pad_template_new_with_gtype (const gchar *name_template, + GstPadDirection direction, GstPadPresence presence, + GstCaps *caps, GType pad_type) G_GNUC_MALLOC; GST_EXPORT GstPadTemplate * gst_static_pad_template_get (GstStaticPadTemplate *pad_template);