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 742918 - v4l2: Add decoder and converter element with RW device property
v4l2: Add decoder and converter element with RW device property
Status: RESOLVED OBSOLETE
Product: GStreamer
Classification: Platform
Component: gst-plugins-good
unspecified
Other Linux
: Normal enhancement
: git master
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2015-01-14 13:51 UTC by Enrico Jorns
Modified: 2017-07-14 17:40 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
generic converter patch (7.35 KB, patch)
2015-01-14 13:51 UTC, Enrico Jorns
needs-work Details | Review
generic decoder patch (4.80 KB, patch)
2015-01-14 14:04 UTC, Enrico Jorns
needs-work Details | Review
v4l2: Add gst_v4l2_object_install_device_property_helper (3.05 KB, patch)
2015-03-10 16:15 UTC, Philipp Zabel
none Details | Review
v4l2: Add generic v4l2convert element (6.12 KB, patch)
2015-03-10 16:16 UTC, Philipp Zabel
none Details | Review
v4l2: Add generic v4l2videodec element (5.01 KB, patch)
2015-03-10 16:17 UTC, Philipp Zabel
none Details | Review
v4l2: Add gst_v4l2_object_install_device_property_helper (3.06 KB, patch)
2017-01-05 11:18 UTC, Michael Tretter
none Details | Review
v4l2: Add generic v4l2convert element (6.14 KB, patch)
2017-01-05 11:19 UTC, Michael Tretter
none Details | Review
v4l2: Add generic v4l2videodec element (5.02 KB, patch)
2017-01-05 11:20 UTC, Michael Tretter
none Details | Review
v4l2videoenc: verify outcaps with peer before setting the format (1.24 KB, patch)
2017-06-06 09:15 UTC, Michael Tretter
rejected Details | Review
v4l2: Add generic v4l2videoenc element (6.57 KB, patch)
2017-06-06 09:16 UTC, Michael Tretter
rejected Details | Review

Description Enrico Jorns 2015-01-14 13:51:46 UTC
Created attachment 294529 [details] [review]
generic converter patch

Instead of only creating device-specific convert elements as subclasses
of GstV4l2Transform, allow instantiating former abstract base class
GstV4l2Transform directly as a generic convert element.
The specific device can be passed using the 'device' property.

For this purpose the base classes 'device' property was given the read/write
flag and device-specific subclasses overwrite this property with a
read-only 'device' property set to the respecitve device path.

This eases constructing pipelines in scripts and allows to use
fixed '/dev/video/by-name/..' device paths.

Example usage:
gst-launch [..] ! v4l2convert device=/dev/video1 ! [..]
Comment 1 Enrico Jorns 2015-01-14 14:04:51 UTC
Created attachment 294530 [details] [review]
generic decoder patch

This patch creates a generic decoder element based on and similar to the generic convert element

Example usage:

gst-launch [..] ! v4l2decoder device=/dev/video5 ! [..]
Comment 2 Nicolas Dufresne (ndufresne) 2015-01-14 14:38:25 UTC
(In reply to comment #1)
> Created an attachment (id=294530) [details] [review]
> generic decoder patch
> 
> This patch creates a generic decoder element based on and similar to the
> generic convert element
> 
> Example usage:
> 
> gst-launch [..] ! v4l2decoder device=/dev/video5 ! [..]

v4l2videodecoder, or v4l2videodec would be the right name for this element. There is a lot of video specific code in there.
Comment 3 Nicolas Dufresne (ndufresne) 2015-01-14 14:39:46 UTC
I think if we go this way (as opposed to having fixed name through udev), it will be required to also implement the GstDeviceMonitor part.
Comment 4 Nicolas Dufresne (ndufresne) 2015-02-18 13:47:48 UTC
Any update / interest ?
Comment 5 Nicolas Dufresne (ndufresne) 2015-02-25 19:44:21 UTC
ping ?
Comment 6 Frédéric Sureau 2015-03-05 10:16:52 UTC
I can make the generic v4l2convert element work using this patch. (Not tested the decoder patch)

However, this element accepts all formats in its src and sink caps.
Caps should be redefined more precisely once the device property is set, so that GStreamer can negotiate the right format with other elements instead of just pick one and try.
Comment 7 Nicolas Dufresne (ndufresne) 2015-03-05 13:28:45 UTC
The caps should be updated when the element is set to ready state. At least this is how it should work, and how v4l2src works.
Comment 8 Nicolas Dufresne (ndufresne) 2015-03-05 13:53:47 UTC
Review of attachment 294529 [details] [review]:

Except for the code duplication, this look ok. I'll give it a try to make sure nothing breaks. Can you add bug reference to your commit message when re-submitting.

::: sys/v4l2/gstv4l2object.c
@@ +414,3 @@
+  g_object_class_install_property (gobject_class, PROP_DEVICE,
+      g_param_spec_string ("device", "Device", "Device location",
+          NULL, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));

I don't like copy paste here, specially that we clearly need to improve the description, which will have to be done twice.

Maybe add an argument to previous call or something ? Or just find a better way ?
Comment 9 Nicolas Dufresne (ndufresne) 2015-03-05 13:56:22 UTC
Review of attachment 294530 [details] [review]:

Please add bug reference to your commit message while resubmitting. Also, it says 5/5, where are the 3 other patches ?
Comment 10 Nicolas Dufresne (ndufresne) 2015-03-08 21:28:36 UTC
ping ?
Comment 11 Philipp Zabel 2015-03-10 16:15:20 UTC
Created attachment 299019 [details] [review]
v4l2: Add gst_v4l2_object_install_device_property_helper

v4l2: Add gst_v4l2_object_install_device_property_helper

To avoid duplication of the device property definition,
move it out into its own function and have it called
from gst_v4l2_object_install_properties_helper and
gst_v4l2_object_install_m2m_properties_helper.
Comment 12 Philipp Zabel 2015-03-10 16:16:31 UTC
Created attachment 299020 [details] [review]
v4l2: Add generic v4l2convert element

v4l2: Add generic v4l2convert element

Instead of only creating device-specific convert elements as subclasses
of GstV4l2Transform, allow instantiating former abstract base class
GstV4l2Transform directly as a generic convert element.
The specific device can be passed using the 'device' property.

For this purpose the base classes 'device' property was given the read/write
flag and device-specific subclasses overwrite this property with a
read-only 'device' property set to the respecitve device path.

This eases constructing pipelines in scripts and allows to use
fixed '/dev/video/by-name/..' device paths.

Example usage:
gst-launch [..] ! v4l2convert device=/dev/video1 ! [..]
Comment 13 Philipp Zabel 2015-03-10 16:17:19 UTC
Created attachment 299021 [details] [review]
v4l2: Add generic v4l2videodec element

v4l2: Add generic v4l2videodec element

This patch creates a generic decoder element based on and similar to the generic
convert element

Example usage:

gst-launch [..] ! v4l2videodec device=/dev/video5 ! [..]
Comment 14 Philipp Zabel 2015-03-10 16:19:26 UTC
(In reply to Nicolas Dufresne (stormer) from comment #10)
> ping ?

Unfortunately Enrico is temporarily out of order.

Just so this doesn't get forgotten, would splitting out the device property installation like this be preferred?
Comment 15 Enrico Jorns 2015-04-27 10:21:35 UTC
Any comments on this and what is still missing?
Is the device monitor part still mandatory?
Comment 16 Nicolas Dufresne (ndufresne) 2015-04-27 13:01:14 UTC
(In reply to Enrico Jorns from comment #15)
> Any comments on this and what is still missing?

I was on holiday, that's the reason I didn't yet look at this. It adds quite some "API", so I hope you wont be offended if I wait for the next development cycle to commit to that.

> Is the device monitor part still mandatory?

I think it is something one would like to make this usable in a more generic way. But I'd agree that this can be handled separately.

In general though, adding such API instead of implementing proper auto-plugging looks like the lazy approach. The overall benefit is small, making this patch-set a bit of a low priority for me. Meanwhile, feel free to use them though, the code seems correct.

The general goal with these decoders and transform element is tat they should just work, using decodebin and other dynamic elements.
Comment 17 Michael Tretter 2017-01-05 11:18:33 UTC
Created attachment 342939 [details] [review]
v4l2: Add gst_v4l2_object_install_device_property_helper
Comment 18 Michael Tretter 2017-01-05 11:19:40 UTC
Created attachment 342941 [details] [review]
v4l2: Add generic v4l2convert element
Comment 19 Michael Tretter 2017-01-05 11:20:11 UTC
Created attachment 342942 [details] [review]
v4l2: Add generic v4l2videodec element
Comment 20 Michael Tretter 2017-01-05 11:42:39 UTC
I rebased the patches on current master.

The point of this patch series is to make gst-launch pipelines more readable. For example, the following pipeline uses the added property to find the v4l2 by name:

gst-launch [...] ! v4l2videodec device=/dev/v4l/by-name/coda-decoder ! [...]

With the existing mechanism, the same pipeline would look as follows, which I consider less readable.

gst-launch [...] ! v4l2video9dec ! [...]

Of course, auto-detection is still preferred. However, decodebin, playbin, etc. will continue to use the v4l2videoCdec elements. Therefore, I do not see, why this mechanism should use the device monitor to be more generic unless you would want to remove the sub-classing mechanism.
Comment 21 Michael Tretter 2017-01-24 08:42:47 UTC
Any comments?
Comment 22 Nicolas Dufresne (ndufresne) 2017-01-24 15:28:54 UTC
Nothing special on my end, was just trying to find some time to properly review. Quick question, "/dev/v4l/by-name/" does not exist on my kernel here, I have by-id and by-path. Where is that from ?
Comment 23 Michael Tretter 2017-01-25 09:51:40 UTC
(In reply to Nicolas Dufresne (stormer) from comment #22)
> Nothing special on my end, was just trying to find some time to properly
> review. 

Thanks :)

> Quick question, "/dev/v4l/by-name/" does not exist on my kernel
> here, I have by-id and by-path. Where is that from ?

I have a udev rule that creates these symlinks using the name attribute.
Comment 24 Michael Tretter 2017-05-10 07:03:46 UTC
Could you have another look on these patches?
Comment 25 Michael Tretter 2017-06-06 09:15:41 UTC
Created attachment 353246 [details] [review]
v4l2videoenc: verify outcaps with peer before setting the format

If the subclass specifies multiple supported codecs or if the
v4l2videoenc element is directly instantiated, the outcaps are not
fixated and can contain codecs that are not supported by the downstream
element.

Ask the peer for the available caps and fixate them before setting the
format.

This patch is especially required for the generic encoder element.
Comment 26 Michael Tretter 2017-06-06 09:16:54 UTC
Created attachment 353247 [details] [review]
v4l2: Add generic v4l2videoenc element

This patch creates a generic encoder element based on and similar to the
generic convert element.

Example usage:

        gst-launch [..] ! v4l2videoenc device=/dev/video2 ! [..]

If this element is combined with udev rules to create named device nodes
for the v4l2 devices, you can define stable pipelines with speaking
names for the encoder elements, e.g.

        gst-launch [..] ! v4l2videoenc device=/dev/v4l/coda-encoder ! [..]
Comment 27 Nicolas Dufresne (ndufresne) 2017-06-06 12:12:58 UTC
Review of attachment 353246 [details] [review]:

::: sys/v4l2/gstv4l2videoenc.c
@@ +326,3 @@
   outcaps = gst_caps_make_writable (outcaps);
+  outcaps = gst_pad_peer_query_caps (encoder->srcpad, outcaps);
+  outcaps = gst_caps_fixate (outcaps);

This is obscure change. Each subclass of GstV4l2VideoEnc should have been created with a single template. So for the H264 subclass the template caps should simply be "video/x-h264,stream-format=byte-stream". The downstream query is also redundant, because this will be done few lines later, when we call gst_video_encoder_negotiated() (see negotiate() virtual method). The actual set format will happen at the start of decide_allocation().
Comment 28 Nicolas Dufresne (ndufresne) 2017-06-06 12:14:07 UTC
Review of attachment 353247 [details] [review]:

This is no longer valid. In the design, a generic encoder is not acceptable. You will need a generic H264, MPEG4, and so on encoder, a subclass the appropriate encoder.
Comment 29 Nicolas Dufresne (ndufresne) 2017-06-11 16:29:30 UTC
Comment on attachment 353246 [details] [review]
v4l2videoenc: verify outcaps with peer before setting the format

As discussed over IRC, encoders have fixed name, no need for this patch anymore. We will likely drop all the other by implementing similar naming method (first found have a fixed named, then others are numbered using the node name).
Comment 30 Nicolas Dufresne (ndufresne) 2017-07-14 17:40:05 UTC
This is obsoleted by the new approach, which is to give the first driver found, implementing a specific feature a fixed name. On most SoC only on such element will be found. As a result we'll have:

  v4l2h264dec
  v4l2h264enc
  etc.

For encoder and decoders this is all implemented now, only transform element are missing. There is a proposed patch, which I should have a look and make a decision soon (kernel lacks some information).

https://bugzilla.gnome.org/show_bug.cgi?id=784958