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 786246 - qmlglsink: Add itemInitialized signal
qmlglsink: Add itemInitialized signal
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-bad
git master
Other Linux
: Normal enhancement
: 1.13.1
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2017-08-13 17:59 UTC by Carlos Rafael Giani
Modified: 2017-08-14 11:52 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
qmlglsink patch for new itemInitialized signal (1.37 KB, patch)
2017-08-13 18:00 UTC, Carlos Rafael Giani
committed Details | Review

Description Carlos Rafael Giani 2017-08-13 17:59:11 UTC
This is useful for autoplay for example. With autoplay, it is necessary to wait until the scene graph is fully set up. This signal is emitted once the QML item node is ready. So, inside a connected slot, the pipeline's state can be set to PLAYING to automatically start playback as soon as the QML script is loaded.

There is the sceneGraphInitialized signal, but it is not suitable for this, since the GLVideoItem still has to get and wrap the GL context before it is ready for playback. This is done in QtGLVideoItem::onSceneGraphInitialized().

Having a dedicated itemInitialized signal in the QML item not only makes autoplay easier to accomplish, it is also a more futureproof solution, since it would make refactoring of the item code easier. Suppose for example that the initialization process is heavily changed for some reason, and the item now becomes ready to play at some other moment compared to now. With the signal in place, all that needs to be done is to simply move the "emit itemInitialized();" line to wherever the initialization is finished.
Comment 1 Carlos Rafael Giani 2017-08-13 18:00:06 UTC
Created attachment 357521 [details] [review]
qmlglsink patch for new itemInitialized signal
Comment 2 Sebastian Dröge (slomo) 2017-08-14 07:24:05 UTC
Comment on attachment 357521 [details] [review]
qmlglsink patch for new itemInitialized signal

Is there no existing signal for this already that we could re-use? Seems like a common thing to want to get notified about.
Comment 3 Carlos Rafael Giani 2017-08-14 08:15:49 UTC
None that I've found. There is sceneGraphInitialized(), but it is emitted by the window, and suffers from the race condition I described. From what I've seen, it is *not* common for a QQuickItem to grab the context like qmlglsink does. The basic problem is that in Qt5, the scene graph and the QML tree are not always in sync, and other than this signal, I see no clean way of knowing when autoplay can be done. Also note what I wrote about it being futureproof. If you rely on other signals that were not designed for this purpose, you might risk regressions later on.
Comment 4 Matthew Waters (ystreet00) 2017-08-14 08:28:04 UTC
(In reply to Sebastian Dröge (slomo) from comment #2)
> Is there no existing signal for this already that we could re-use? Seems
> like a common thing to want to get notified about.

I don't think so.  Performing these acrobatics is not something every QQuickItem will need to do.

There is the windowChanged() signal that the item already uses internally to do this exact setup depending on if the scene graph is initialized.
https://cgit.freedesktop.org/gstreamer/gst-plugins-bad/tree/ext/qt/qtitem.cc#n351

Requiring every user to implement similar logic isn't that user-friendly so an extra signal is a good idea.
Comment 5 Sebastian Dröge (slomo) 2017-08-14 11:16:31 UTC
Ok, then let's go for this? Any things you'd like to have different, Matthew?
Comment 6 Sebastian Dröge (slomo) 2017-08-14 11:52:02 UTC
commit a13e8b3efa0e35d7dac7c57504339ac75aeae71e (HEAD -> master, origin/master, origin/HEAD)
Author: Carlos Rafael Giani <dv@pseudoterminal.org>
Date:   Sun May 21 16:01:14 2017 +0200

    qmlglsink: Add itemInitialized signal to QML item
    
    This is useful for autoplay for example. With autoplay, it is necessary to
    wait until the scene graph is fully set up. This signal is emitted once the
    QML item node is ready. So, inside a connected slot, the pipeline's state
    can be set to PLAYING to automatically start playback as soon as the QML
    script is loaded.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=786246