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 742875 - [API] new audiovisualizer base class
[API] new audiovisualizer base class
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-base
git master
Other All
: Normal enhancement
: 1.7.1
Assigned To: Luis de Bethencourt
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2015-01-13 17:40 UTC by Luis de Bethencourt
Modified: 2015-10-12 16:35 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
patch for plugins-base (96.11 KB, patch)
2015-01-22 18:24 UTC, Luis de Bethencourt
committed Details | Review
patch for plugins-bad (50.97 KB, patch)
2015-01-22 18:27 UTC, Luis de Bethencourt
committed Details | Review
port goom2k1 to using the new baseclass (21.26 KB, patch)
2015-01-29 17:59 UTC, Luis de Bethencourt
committed Details | Review
port goom to using the new baseclass (20.67 KB, patch)
2015-01-29 17:59 UTC, Luis de Bethencourt
committed Details | Review
make private all the variable the subclasses don't need (27.04 KB, patch)
2015-02-03 15:27 UTC, Luis de Bethencourt
committed Details | Review
goom/goom2k1: remove obsolete left over files (97.50 KB, patch)
2015-10-12 09:48 UTC, Julien Isorce
needs-work Details | Review
goom/goom2k1: fix undefined reference to gst_audio_visualizer_get_type (1.72 KB, patch)
2015-10-12 09:49 UTC, Julien Isorce
needs-work Details | Review

Description Luis de Bethencourt 2015-01-13 17:40:31 UTC
The audiovisualizer code is duplicated (and slightly off sync):
http://cgit.freedesktop.org/gstreamer/gst-plugins-base/tree/ext/libvisual/gstaudiovisualizer.c
http://cgit.freedesktop.org/gstreamer/gst-plugins-bad/tree/gst/audiovisualizers/gstaudiovisualizer.c

These need to be synced. All audiovisualization elements need to use this. Then it needs to be merged into a public base class.

I am currently working on this. This thread is to keep track of it and avoid any work duplication.
Comment 1 Luis de Bethencourt 2015-01-14 10:18:36 UTC
Stefan has adviced in IRC, "basically add another copy to goom and goom2k and if all 3 copies are the same, move the copy out as a public baseclass :)"
Comment 2 Julien Isorce 2015-01-14 22:57:11 UTC
There is also GL audio visualizer (which has not been ported to 1.x yet) which shares code with files you pointed. http://cgit.freedesktop.org/gstreamer/gst-plugins-bad/tree/ext/libvisual/visual-gl.c

Il will benefit from your work.
Comment 3 Luis de Bethencourt 2015-01-21 14:35:31 UTC
Thanks for pointing this out Julien! :)

Working on this now.
Comment 4 Luis de Bethencourt 2015-01-21 15:36:40 UTC
Files synced.

in -base:
684e5e0c8751dca5cb45a28ddd4f9aa6db01d925
945afe6cc4c4f0a7762d34ed38f15083d2124b81

in -bad:
6431de32860cc8b0e24f9973081e488fd50bdbff
1b2d74728ccdcddf8d774c0e66f12f72a6094dda

Now I can cleanly merge them.
Comment 5 Luis de Bethencourt 2015-01-22 18:24:53 UTC
Created attachment 295213 [details] [review]
patch for plugins-base
Comment 6 Luis de Bethencourt 2015-01-22 18:27:01 UTC
Created attachment 295214 [details] [review]
patch for plugins-bad

These are the two patches for the two modules so far.

They build cleanly and I have tested the audiovisualizers from -bad. spacescope, spectrascope, synaescope, and wavescope.

Any comments?
Comment 7 Stefan Sauer (gstreamer, gtkdoc dev) 2015-01-23 07:55:55 UTC
Luis, can you first try to port the goom visualizers using yet another copy to verify that the api is good?
Comment 8 Luis de Bethencourt 2015-01-23 10:47:48 UTC
Stefan,

So first having a third copy that goom uses and then merge them all into the above solution (patch)? I can do that! :)

Will start on it after lunch today.

Thanks for looking at this.
Comment 9 Matthew Waters (ystreet00) 2015-01-23 12:41:56 UTC
One other thing that should be mentioned is that the current baseaudiovisualizer already maps the output buffer readwrite before calling the subclass' render() function.  For GL, this essentially means downloading random data and then (possibly) uploading it again to draw to.

One fix common to all the other base classes is to make the subclass deal with mapping the buffer with it's (possible) special requirements.
Comment 10 Jan Schmidt 2015-01-28 05:27:26 UTC
Another thing we need to do is make sure GAP events negotiate the output format and get forwarded cleanly.

Bug 735666 - adding new trickmode modes - makes audio decoders output GAP events instead of audio buffers, which will make things not preroll with current goom (at least).
Comment 11 Luis de Bethencourt 2015-01-28 16:36:02 UTC
True. But let's merge code first, and then we can optimize/fix.

Working on it.
Comment 12 Stefan Sauer (gstreamer, gtkdoc dev) 2015-01-28 21:31:38 UTC
Jan, goom isn't using this baseclass yet. Can you try that with an element that does - e.g. synaescope.
Comment 13 Luis de Bethencourt 2015-01-29 17:59:07 UTC
Created attachment 295773 [details] [review]
port goom2k1 to using the new baseclass
Comment 14 Luis de Bethencourt 2015-01-29 17:59:29 UTC
Created attachment 295774 [details] [review]
port goom to using the new baseclass
Comment 15 Luis de Bethencourt 2015-01-29 18:02:43 UTC
With these two now patches, we have all related plugins using the new baseclass.

I know there is some cleanup to be done in goom and goom2k1, but wanted to submit this before traveling to FOSDEM. Will clean very soon and push upstream (unless anybody points out issues). With this we keep current behaviour but with everything ported to use common code.

Then, I can continue the work on audiovisualizers by doing the fixes people have mentioned here. One step at a time :)
Comment 16 Tim-Philipp Müller 2015-01-29 19:00:33 UTC
Please don't push this yet, I think we should review the APIs a bit more carefully before we make this all public.

The new public structs (instance+class) need padding.
Comment 17 Stefan Sauer (gstreamer, gtkdoc dev) 2015-01-30 08:17:46 UTC
Review of attachment 295773 [details] [review]:

This looks great!
Comment 18 Luis de Bethencourt 2015-01-30 10:12:49 UTC
Thanks Stefan! :)

Tim, no problem. I am happy to review the APIs.
Comment 19 Luis de Bethencourt 2015-02-03 15:27:59 UTC
Created attachment 296031 [details] [review]
make private all the variable the subclasses don't need

Cleaning the API
Comment 21 Stefan Sauer (gstreamer, gtkdoc dev) 2015-04-25 16:56:15 UTC
Can you push the patches that make the variables private? I think that makes sense in any case. It might be useful to have a local variable for "p = self->priv" in methods that do a lot "self->priv->abc".
Comment 22 Stefan Sauer (gstreamer, gtkdoc dev) 2015-04-25 16:58:10 UTC
Also for now, please just add yet another copy of the baseclass into goom and goom2k1. This way we don't loose your work.

FYI: I just pushed commits to update the license, this was always meant to be LGPL.
Comment 23 Luis de Bethencourt 2015-06-01 10:59:09 UTC
Review of attachment 296031 [details] [review]:

As Stefan suggested, pushing this now to not lose it since it doesn't change API.

commit a881085a75d20e7fd6d90bb818b14e17332be5d1
Comment 24 Luis de Bethencourt 2015-06-02 17:12:25 UTC
Stefan,

Following your advice I moved a copy of the baseclass into goom and goom2k1 to not have it bitrot. Once 1.6 opens I can unify them all into gst-libs/pbutils.

commit ffe75075125ffdc06406e360f631770a85508454
Author: Luis de Bethencourt <luis.bg@samsung.com>

    goom2k1: remove variables not needed anymore

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

commit 8756b6a9d42de500319822665449615342adc314
Author: Luis de Bethencourt <luis.bg@samsung.com>

    goom2k1: rebase to use the audiovisualizer class

    Rebase to have goom2k1 using the common GstAudioVisualizer class

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

commit 89903bf66ae0eec6f5613288123d263e1d80a5c9
Author: Luis de Bethencourt <luis.bg@samsung.com>

    goom: rebase to use the audiovisualizer class
Comment 25 Stefan Sauer (gstreamer, gtkdoc dev) 2015-06-06 15:33:40 UTC
Thanks for submitting, did you sync all versions?

find . -name "gstaudiovisualizer.c" -printf "%s %p\n" | grep -v "www"

42070 ./gst-plugins-bad/gst/audiovisualizers/gstaudiovisualizer.c
42247 ./gst-plugins-good/gst/goom2k1/gstaudiovisualizer.c
42237 ./gst-plugins-good/gst/goom/gstaudiovisualizer.c
40933 ./gst-plugins-base/ext/libvisual/gstaudiovisualizer.c
Comment 26 Stefan Sauer (gstreamer, gtkdoc dev) 2015-06-06 15:53:05 UTC
Thanks to the changes Luis made, the public api surface is much less. 

A few things we might want to discuss:
guint req_spf;                /* min samples per frame wanted by the subclass */

This could also be a property. Then the baseclass could wrap this with code to do some sanity checks. Although I don't have a good example yet for e.g. what would be out-of-bounds here.

The 3 vmethods are apparently sufficient for all our visualizers. Anything that should be changed there?

The shader feature might need more work for some videoformats, e.g.:
gst-launch-1.0 -v audiotestsrc ! goom shader=8 ! videoconvert ! autovideosink

Also for the goom and goo2k1 ports
gst-launch-1.0 -v audiotestsrc ! goom shader=0 ! videoconvert ! autovideosink
gst-launch-1.0 -v audiotestsrc ! goom2k1 shader=0 ! videoconvert ! autovideosink
causes a black screen.
Comment 27 Luis de Bethencourt 2015-06-07 18:30:28 UTC
Stefan,

I've updated and synced all instances of gstaudiovisualizer.c. They will still show different in your find command because each instance has a different static type name to avoid clashes.

Thanks for the review.

Will make req_spf a property. It is a good idea.

Will fix the shader property bug you mention.

Cool!
Comment 28 Luis de Bethencourt 2015-10-01 15:11:31 UTC
Review of attachment 295213 [details] [review]:

commit 8ae0fd3990ef922b6dc8bb531cb1caf91926fec2
Author: Luis de Bethencourt <luisbg@osg.samsung.com>
Date:   Thu Oct 1 11:55:59 2015 +0100

    visual: merge audiovisalizer base classes

    Move the audiovisualizer base class to pbutils, so it can be used by plugins
    from other modules

    https://bugzilla.gnome.org/show_bug.cgi?id=742875
Comment 29 Luis de Bethencourt 2015-10-01 15:11:58 UTC
Review of attachment 295214 [details] [review]:

commit 9e97267ca01e81f1ea0696e2cb4cfab0e05714dc
Author: Luis de Bethencourt <luisbg@osg.samsung.com>
Date:   Thu Oct 1 15:35:37 2015 +0100

    audiovisualizers: merge audiovisualizer base classes

    These plugins now use the audiovisualizer base class in pbutils

    https://bugzilla.gnome.org/show_bug.cgi?id=742875
Comment 30 Luis de Bethencourt 2015-10-01 15:20:33 UTC
Review of attachment 295774 [details] [review]:

commit 17c17fc369d17a0236eb92bb3d341da6bf15fbf0
Author: Luis de Bethencourt <luisbg@osg.samsung.com>
Date:   Thu Oct 1 16:16:08 2015 +0100

    goom: use the new audiovisualizer base class

    Rebase to have goom using the GstAudioVisualizer base class in
    gst-plugins-base/gst-libs/gst/pbutils

    https://bugzilla.gnome.org/show_bug.cgi?id=742875
Comment 31 Luis de Bethencourt 2015-10-01 15:26:12 UTC
Review of attachment 295773 [details] [review]:

commit 711b035137a34d946d01f623ef68af4787aea6ca
Author: Luis de Bethencourt <luisbg@osg.samsung.com>
Date:   Thu Oct 1 16:24:32 2015 +0100

    goom2k1: use the new audiovisualizer base class

    Rebase to have goom using the GstAudioVisualizer base class in
    gst-plugins-base/gst-libs/gst/pbutils

    https://bugzilla.gnome.org/show_bug.cgi?id=742875
Comment 32 Jan Schmidt 2015-10-01 15:41:04 UTC
Sorry to be late to the party. Is pbutils the best place for the base class?

I would have guessed libgstaudio.
Comment 33 Tim-Philipp Müller 2015-10-01 17:20:04 UTC
> Sorry to be late to the party. Is pbutils the best place for the base class?
> 
> I would have guessed libgstaudio.

It's not the best place, more like the least worst place.

Unless you think making libgstaudio depend on libgstvideo is a good idea, libgstaudio is out.
Comment 34 Tim-Philipp Müller 2015-10-01 17:57:19 UTC
Having said that, so far pbutils only has a 'hidden' dependency on libgstaudio/video through some trivial discoverer usage that could easily be done internally without a dependency, and with this we are adding an explicit dependency in the public headers.

So perhaps there's a case to be made for adding a new mini lib for this after all. Perhaps it could be the same lib into which we then move the camerabin wrapper src base class, for example.

But what to call it? ;)
Comment 35 Julien Isorce 2015-10-12 09:48:21 UTC
Created attachment 313109 [details] [review]
goom/goom2k1: remove obsolete left over files

Let me know if this is ok and then I can push it.
Comment 36 Julien Isorce 2015-10-12 09:49:07 UTC
Created attachment 313110 [details] [review]
goom/goom2k1: fix undefined reference to gst_audio_visualizer_get_type

Same
Comment 37 Sebastian Dröge (slomo) 2015-10-12 13:40:08 UTC
Review of attachment 313110 [details] [review]:

Can you squash both patches together?

::: gst/goom/Makefile.am
@@ +40,2 @@
 libgstgoom_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) $(GST_CFLAGS) $(GOOM_FILTER_CFLAGS) $(ARCH_CFLAGS) $(ORC_CFLAGS)
+libgstgoom_la_LIBADD = -lgstpbutils-$(GST_API_VERSION) $(GST_PLUGINS_BASE_LIBS) $(GST_BASE_LIBS) $(GST_LIBS) $(ORC_LIBS)

First $(GS_TPLUGINS_BASE_LIBS), then the lib

::: gst/goom2k1/Makefile.am
@@ +24,3 @@
 	-DzoomFilterNew=zoomFilterNew2k1
 
+libgstgoom2k1_la_LIBADD = $(GST_BASE_LIBS) $(GST_PLUGINS_BASE_LIBS) -lgstpbutils-$(GST_API_VERSION) $(GST_LIBS) $(LIBM)

First GST_PLUGINS_BASE, then GST_BASE, then GST
Comment 38 Tim-Philipp Müller 2015-10-12 13:51:17 UTC
And if you remove GST_BASE_LIBS please also remove GST_BASE_CFLAGS.
Comment 39 Julien Isorce 2015-10-12 16:35:49 UTC
commit c9df481e279982c67b3c9aace062d141375d77c9
Author: Julien Isorce <j.isorce@samsung.com>
Date:   Sun Oct 11 22:27:47 2015 +0100

    goom/goom2k1: remove obsolete left over files
    
    They now use the new GstAudioVisualizer base class
    from gst-plugins-base/gst-libs/gst/pbutils
    
    Also fixed undefined reference to gst_audio_visualizer_get_type
    Added GST_PLUGINS_BASE_LIBS to Makefile.am and re-order LIBADD.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=742875