diff options
author | Mathieu Duponchelle <mathieu@centricular.com> | 2018-02-28 19:51:44 +0100 |
---|---|---|
committer | Mathieu Duponchelle <mathieu@centricular.com> | 2018-03-01 00:39:08 +0100 |
commit | 7847e69ef8bab985739b60460094c17b471786db (patch) | |
tree | 43d13aec28ebdb34516f84e315415eb82c89d04f | |
parent | 91798e16cc09420163684d13779f13f374164ea2 (diff) |
pad, ghostpad: use the template gtype if specified
Also make sure the GType passed to the with_gtype versions
of the template constructors is_a GstPad
https://bugzilla.gnome.org/show_bug.cgi?id=793933
-rw-r--r-- | gst/gstghostpad.c | 7 | ||||
-rw-r--r-- | gst/gstpad.c | 5 | ||||
-rw-r--r-- | gst/gstpadtemplate.c | 3 |
3 files changed, 12 insertions, 3 deletions
diff --git a/gst/gstghostpad.c b/gst/gstghostpad.c index 1598084d2..dd53122d5 100644 --- a/gst/gstghostpad.c +++ b/gst/gstghostpad.c @@ -627,12 +627,15 @@ gst_ghost_pad_new_full (const gchar * name, GstPadDirection dir, GstPadTemplate * templ) { GstGhostPad *ret; - g_return_val_if_fail (dir != GST_PAD_UNKNOWN, NULL); /* OBJECT CREATION */ if (templ) { - ret = g_object_new (GST_TYPE_GHOST_PAD, "name", name, + GType pad_type = + GST_PAD_TEMPLATE_GTYPE (templ) == + G_TYPE_NONE ? GST_TYPE_GHOST_PAD : GST_PAD_TEMPLATE_GTYPE (templ); + + ret = g_object_new (pad_type, "name", name, "direction", dir, "template", templ, NULL); } else { ret = g_object_new (GST_TYPE_GHOST_PAD, "name", name, diff --git a/gst/gstpad.c b/gst/gstpad.c index ffecee9e3..229f3dd0c 100644 --- a/gst/gstpad.c +++ b/gst/gstpad.c @@ -864,8 +864,11 @@ GstPad * gst_pad_new_from_template (GstPadTemplate * templ, const gchar * name) { g_return_val_if_fail (GST_IS_PAD_TEMPLATE (templ), NULL); + GType pad_type = + GST_PAD_TEMPLATE_GTYPE (templ) == + G_TYPE_NONE ? GST_TYPE_PAD : GST_PAD_TEMPLATE_GTYPE (templ); - return g_object_new (GST_TYPE_PAD, + return g_object_new (pad_type, "name", name, "direction", templ->direction, "template", templ, NULL); } diff --git a/gst/gstpadtemplate.c b/gst/gstpadtemplate.c index 1df8e07f8..02a9132b8 100644 --- a/gst/gstpadtemplate.c +++ b/gst/gstpadtemplate.c @@ -342,6 +342,8 @@ gst_pad_template_new_from_static_pad_template_with_gtype (GstStaticPadTemplate * GstPadTemplate *new; GstCaps *caps; + g_return_val_if_fail (g_type_is_a (pad_type, GST_TYPE_PAD), NULL); + if (!name_is_valid (pad_template->name_template, pad_template->presence)) return NULL; @@ -423,6 +425,7 @@ gst_pad_template_new_with_gtype (const gchar * name_template, || direction == GST_PAD_SINK, NULL); g_return_val_if_fail (presence == GST_PAD_ALWAYS || presence == GST_PAD_SOMETIMES || presence == GST_PAD_REQUEST, NULL); + g_return_val_if_fail (g_type_is_a (pad_type, GST_TYPE_PAD), NULL); if (!name_is_valid (name_template, presence)) { return NULL; |