After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 789986 - pad templates: Allow specifying GType
pad templates: Allow specifying GType
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gstreamer (core)
unspecified
Other All
: Normal enhancement
: 1.13.1
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks: 731301
 
 
Reported: 2017-11-06 20:17 UTC by Mathieu Duponchelle
Modified: 2017-11-22 16:06 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
pad templates: Allow specifying GType (6.61 KB, patch)
2017-11-06 20:17 UTC, Mathieu Duponchelle
none Details | Review
aggregator: Remove klass->sinkpads_type (13.92 KB, patch)
2017-11-06 20:19 UTC, Mathieu Duponchelle
none Details | Review
pad templates: Allow specifying GType (8.18 KB, patch)
2017-11-22 15:21 UTC, Mathieu Duponchelle
none Details | Review
aggregator: Remove klass->sinkpads_type (13.84 KB, patch)
2017-11-22 15:25 UTC, Mathieu Duponchelle
none Details | Review
pad templates: Allow specifying GType (8.24 KB, patch)
2017-11-22 15:36 UTC, Mathieu Duponchelle
committed Details | Review
aggregator: Remove klass->sinkpads_type (13.85 KB, patch)
2017-11-22 15:39 UTC, Mathieu Duponchelle
none Details | Review
aggregator: Remove klass->sinkpads_type (14.04 KB, patch)
2017-11-22 15:52 UTC, Mathieu Duponchelle
committed Details | Review

Description Mathieu Duponchelle 2017-11-06 20:17:09 UTC
See https://bugzilla.gnome.org/show_bug.cgi?id=731301
Comment 1 Mathieu Duponchelle 2017-11-06 20:17:13 UTC
Created attachment 363082 [details] [review]
pad templates: Allow specifying GType
Comment 2 Mathieu Duponchelle 2017-11-06 20:19:34 UTC
Created attachment 363084 [details] [review]
aggregator: Remove klass->sinkpads_type

This posed problems for the python bindings (and possibly others).

Instead, subclasses now use add_pad_template_with_type.
Comment 3 Thibault Saunier 2017-11-06 20:33:39 UTC
Review of attachment 363082 [details] [review]:

Makes sense, I would have put the GType into `GstStaticPadTemplate` but it seems not to be possible as the structure doesn't have padding.

`gst_element_class_add_static_pad_template_with_type` is a looong name but well :-)
Comment 4 Thibault Saunier 2017-11-06 20:35:10 UTC
(In reply to Mathieu Duponchelle from comment #2)
> Created attachment 363084 [details] [review] [review]
> aggregator: Remove klass->sinkpads_type
> 
> This posed problems for the python bindings (and possibly others).
> 
> Instead, subclasses now use add_pad_template_with_type.

Actually this also poses a problem with the python bindings, adding pad templates is already overriden in gst-python so we should just extend it there to be able to also specify a GType.
Comment 5 Mathieu Duponchelle 2017-11-06 20:43:03 UTC
afaics, the way to do it in python is:

__gsttemplates__ = (Gst.PadTemplate.new("src",
                                           Gst.PadDirection.SRC,
                                           Gst.PadPresence.ALWAYS,
                                           Gst.Caps.new_any())

So there won't be any need for an override if you can do:

__gsttemplates__ = (Gst.PadTemplate.new_with_type("src",
                                           Gst.PadDirection.SRC,
                                           Gst.PadPresence.ALWAYS,
                                           Gst.Caps.new_any(),
                                           your_gtype)

?
Comment 6 Thibault Saunier 2017-11-06 20:44:36 UTC
That should work indeed :)
Comment 7 Nicolas Dufresne (ndufresne) 2017-11-06 21:59:23 UTC
I had in my todo something similar, but to be able to print the pad properties. My conclusion was that I needed the GType, for sometimes and request pads, gst-inspect only have access to StaticTemplate, but indeed, there is no padding, that's unfortunate.
Comment 8 Thibault Saunier 2017-11-06 22:13:50 UTC
This also allows us to introspect pad types, Mathieu said he will add it to gst-inspect :-)
Comment 9 Nicolas Dufresne (ndufresne) 2017-11-07 00:31:25 UTC
Ok, looking further, we can get the ElementClass from the element, and then iterate over the GstPadTemplates instead of the StaticPadTemplates (which is the only thing available from the registry). That would be great addition indeed.
Comment 10 Mathieu Duponchelle 2017-11-21 13:53:16 UTC
Good, should we push that then? :)
Comment 11 Sebastian Dröge (slomo) 2017-11-21 14:02:49 UTC
I guess once the gst-inspect part is done for completeness :)
Comment 12 Tim-Philipp Müller 2017-11-21 14:04:09 UTC
+1

The only question for me is whether it shouldn't be _with_gtype() and "gtype" property.

What do other libs do? There must be a precedence somewhere.
Comment 13 Tim-Philipp Müller 2017-11-22 12:08:57 UTC
Comment on attachment 363082 [details] [review]
pad templates: Allow specifying GType

>@@ -127,7 +137,12 @@ struct _GstPadTemplate {
>   GstCaps	  *caps;
> 
>   /*< private >*/
>-  gpointer _gst_reserved[GST_PADDING];
>+  union {
>+    gpointer _gst_reserved[GST_PADDING];
>+    struct {
>+      GType type;
>+    } abi;
>+  } ABI;
> };

For what it's worth, I think we can rely on GType always being pointer-sized, so the ABI union struct compat dance is probably not necessary here, but doesn't hurt either of course.
Comment 14 Mathieu Duponchelle 2017-11-22 15:21:13 UTC
Created attachment 364206 [details] [review]
pad templates: Allow specifying GType

See https://bugzilla.gnome.org/show_bug.cgi?id=731301
Comment 15 Mathieu Duponchelle 2017-11-22 15:25:14 UTC
Created attachment 364207 [details] [review]
aggregator: Remove klass->sinkpads_type

This posed problems for the python bindings (and possibly others).

Instead, subclasses now use add_pad_template_with_gtype.
Comment 16 Thibault Saunier 2017-11-22 15:32:58 UTC
Review of attachment 364206 [details] [review]:

::: docs/gst/gstreamer-sections.txt
@@ +2200,2 @@
 GST_PAD_TEMPLATE_CAPS
 GST_PAD_TEMPLATE_IS_FIXED

Missing the ` GST_PAD_TEMPLATE_TYPE` macro?

::: gst/gstpadtemplate.h
@@ -97,0 +97,9 @@
+/**
+ * GST_PAD_TEMPLATE_TYPE:
+ * @templ: the template to query
... 6 more ...

_GTYPE then? :)
Comment 17 Mathieu Duponchelle 2017-11-22 15:36:13 UTC
Created attachment 364208 [details] [review]
pad templates: Allow specifying GType

See https://bugzilla.gnome.org/show_bug.cgi?id=731301
Comment 18 Mathieu Duponchelle 2017-11-22 15:36:55 UTC
(In reply to Thibault Saunier from comment #16)
> Review of attachment 364206 [details] [review] [review]:
> 
> ::: docs/gst/gstreamer-sections.txt
> @@ +2200,2 @@
>  GST_PAD_TEMPLATE_CAPS
>  GST_PAD_TEMPLATE_IS_FIXED
> 
> Missing the ` GST_PAD_TEMPLATE_TYPE` macro?

Yes, good catch

> 
> ::: gst/gstpadtemplate.h
> @@ -97,0 +97,9 @@
> +/**
> + * GST_PAD_TEMPLATE_TYPE:
> + * @templ: the template to query
> ... 6 more ...
> 
> _GTYPE then? :)

Yes, fixed
Comment 19 Thibault Saunier 2017-11-22 15:38:35 UTC
Review of attachment 364208 [details] [review]:

lgtm
Comment 20 Mathieu Duponchelle 2017-11-22 15:39:42 UTC
Created attachment 364209 [details] [review]
aggregator: Remove klass->sinkpads_type

This posed problems for the python bindings (and possibly others).

Instead, subclasses now use add_pad_template_with_gtype.
Comment 21 Thibault Saunier 2017-11-22 15:45:32 UTC
Review of attachment 364209 [details] [review]:

::: gst/mxf/mxfmux.c
@@ -170,3 @@
   gstaggregator_class->stop = GST_DEBUG_FUNCPTR (gst_mxf_mux_stop);
   gstaggregator_class->aggregate = GST_DEBUG_FUNCPTR (gst_mxf_mux_aggregate);
-  gstaggregator_class->sinkpads_type = GST_TYPE_MXF_MUX_PAD;

Isn't it going to use `TYPE_AGGREGATOR_PAD` now?
Comment 22 Mathieu Duponchelle 2017-11-22 15:46:45 UTC
Review of attachment 364208 [details] [review]:

Commited
Comment 23 Mathieu Duponchelle 2017-11-22 15:52:01 UTC
Created attachment 364210 [details] [review]
aggregator: Remove klass->sinkpads_type

This posed problems for the python bindings (and possibly others).

Instead, subclasses now use add_pad_template_with_gtype.
Comment 24 Thibault Saunier 2017-11-22 15:53:16 UTC
Review of attachment 364210 [details] [review]:

lgtm
Comment 25 Mathieu Duponchelle 2017-11-22 15:53:54 UTC
Attachment 364210 [details] pushed as 56fc5be - aggregator: Remove klass->sinkpads_type