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 746818 - v4l2: Improve URI handler
v4l2: Improve URI handler
Status: RESOLVED OBSOLETE
Product: GStreamer
Classification: Platform
Component: gst-plugins-good
1.10.4
Other Linux
: Normal enhancement
: git master
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on: 779765
Blocks:
 
 
Reported: 2015-03-26 14:59 UTC by Marc Leeman
Modified: 2018-11-03 14:59 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
v4l2: add uri hander interface (11.08 KB, patch)
2015-03-26 14:59 UTC, Marc Leeman
none Details | Review
v4l2: add GstUri handler to v4l2 (7.63 KB, patch)
2017-03-10 12:56 UTC, Marc Leeman
none Details | Review
v4l2: add GstUri handler to v4l2 (7.59 KB, patch)
2018-10-30 07:50 UTC, Marc Leeman
needs-work Details | Review

Description Marc Leeman 2015-03-26 14:59:54 UTC
Created attachment 300359 [details] [review]
v4l2: add uri hander interface

patch against 1.4.5
GstUri backported from git in core
Comment 1 Marc Leeman 2015-04-16 10:20:31 UTC
ah yeah, the g_hash_table_destroy needs to be g_hash_table_unref
Comment 2 Nicolas Dufresne (ndufresne) 2015-06-10 02:22:49 UTC
Any intention updating the patch (to apply on git master and fix the destroy/unref error) ?
Comment 3 Marc Leeman 2017-03-10 12:56:34 UTC
Created attachment 347626 [details] [review]
v4l2: add GstUri handler to v4l2
Comment 4 Marc Leeman 2017-03-10 12:57:29 UTC
(In reply to Nicolas Dufresne (stormer) from comment #2)
> Any intention updating the patch (to apply on git master and fix the
> destroy/unref error) ?

I am submitting my patches accumulated over time; it has been too long :-(
Comment 5 Marc Leeman 2017-03-10 13:00:56 UTC
Depends on
https://bugzilla.gnome.org/show_bug.cgi?id=779765
Comment 6 Nicolas Dufresne (ndufresne) 2017-03-10 21:29:15 UTC
Review of attachment 347626 [details] [review]:

::: sys/v4l2/gstv4l2object.c
@@ +588,3 @@
+          gst_uri_unref (v4l2object->uri);
+
+        v4l2object->uri = gst_uri_from_string (g_value_get_string (value));

This may fail.

@@ +590,3 @@
+        v4l2object->uri = gst_uri_from_string (g_value_get_string (value));
+
+        gst_object_set_properties_from_uri_query_parameters (G_OBJECT (v4l2object->element), v4l2object->uri);

It's nice to have a generic interface here, though there is some stuff I really don't like. I'll bring that to the respective bug. In this specific case, we MUST filter certain properties (name, parent, device, device-fd, io-mode, are the one I would deliberatly prevent from accessing from the URI). We should also find a way to validate the values in a way that it won't assert.

@@ +591,3 @@
+
+        gst_object_set_properties_from_uri_query_parameters (G_OBJECT (v4l2object->element), v4l2object->uri);
+        path = gst_uri_get_path(v4l2object->uri);

Coding style, need space before (.

@@ +710,3 @@
+        gchar *string = gst_uri_to_string (v4l2object->uri);
+
+        g_value_set_string (value, string);

g_value_take_string() please, you can probably make it a one liner.

::: sys/v4l2/gstv4l2sink.c
@@ +102,3 @@
+        gst_v4l2sink_video_orientation_interface_init);
+    G_IMPLEMENT_INTERFACE (GST_TYPE_URI_HANDLER,
+        gst_v4l2sink_uri_handler_init));

This is a non-sense, URI handler are strictly for sources.
Comment 7 Nicolas Dufresne (ndufresne) 2017-03-11 15:08:17 UTC
btw, ignore the part about the sink, I learned later that it's usable to find and prepare sinks too using the gst-uri API. Sorry for the noise.
Comment 8 Marc Leeman 2017-03-14 09:04:59 UTC
 
> @@ +710,3 @@
> +        gchar *string = gst_uri_to_string (v4l2object->uri);
> +
> +        g_value_set_string (value, string);
> 
> g_value_take_string() please, you can probably make it a one liner.

What is the rationale of preferring the g_value_take_string over g_value_set_string; is it the extra copy where take string takes the ownership and set string not?
Comment 9 Olivier Crête 2017-03-17 21:30:07 UTC
(In reply to Marc Leeman from comment #8)
> What is the rationale of preferring the g_value_take_string over
> g_value_set_string; is it the extra copy where take string takes the
> ownership and set string not?

Yes, using g_value_take_string() saves an allocation and a copy.
Comment 10 Marc Leeman 2018-10-30 07:50:15 UTC
Created attachment 374101 [details] [review]
v4l2: add GstUri handler to v4l2
Comment 11 Nicolas Dufresne (ndufresne) 2018-10-31 14:59:43 UTC
Review of attachment 374101 [details] [review]:

::: sys/v4l2/gstv4l2object.c
@@ +542,3 @@
+    v4l2object->uri = gst_uri_from_string (DEFAULT_PROP_URI);
+  else
+    v4l2object->uri = DEFAULT_PROP_URI;

That is not great, DEFAULT_PROP_URI is both a string and a GstUri. You also add a runtime null check, where NULL is hard coded. If you think NULL is a the default, drop the default macro, it's not useful.

@@ +573,3 @@
+  if (v4l2object->uri) {
+    gst_uri_unref (v4l2object->uri);
+    v4l2object->uri = NULL;

No need, we g_free the v4l2object next.

@@ +628,3 @@
+        gst_object_set_properties_from_uri_query_parameters (G_OBJECT (v4l2object->element), v4l2object->uri);
+        path = gst_uri_get_path(v4l2object->uri);
+        if (0 != *(path))

Doc says the return of get_path is nullable, you are missing some checks here.

::: sys/v4l2/gstv4l2src.c
@@ +1047,1 @@
+  g_object_set (G_OBJECT (v4l2src->v4l2object->element), "uri", uri, NULL);

v4l2object->element should be v4l2src, why do you use this indirection ?
Comment 12 GStreamer system administrator 2018-11-03 14:59:22 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/issues/176.