New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
wxMediaCtrl wayland support #2383
Conversation
Thanks for fixing this and sorry for the delay with the reply! I don't know anything about Wayland, but if this makes it work, let's merge it, of course. I'm a bit surprised because I thought that @varigigi did test it with Wayland, but maybe I misunderstood something. Anyhow, I'll merge this (maybe with some slight reformatting) soon if there are no comments from @paulcor. Thanks again! |
No worry about the delay, I wasn't sure about the process so I opened a trac ticket yesterday but I'll close it when this is merged :) I was also a bit surprised it didn't work, maybe it depends on the gstreamer version? I only tested with 1.0 (debian bullseye 1.18.4-2) |
@vadz, @martinetd, when I was testing wxwidgets on wayland, I was not able to fully test the mediactr: it was working fine with x11 and xwayland, but only partially with pure wayland with no x11 support. |
Thanks for the comment! that clears it up a bit. I could get mediaplayer to work without Xwayland on my laptop with the autovideosink, so there might be something to look at - can you paste what you get with GST_DEBUG=3 to get an idea of what it tries? |
This is what I'm getting: root@imx8mm-var-dart:/usr/share/wxwidgets/samples/mediaplayer# GST_DEBUG=3 ./mediaplayer It looks it does not even try the autovideosink that is actually present: root@imx8mm-var-dart:/usr/share/wxwidgets/samples/mediaplayer# gst-inspect-1.0 | grep -i sink | grep -i video |
oh an imx board.. I also couldn't get gstreamer to work well with one on a frankendebian and was blaming my hacked up install, will give it a shot with a slightly better setup on Monday -- I'll report if I find something. |
I've just realized that you patched the file src/unix/mediactrl_gstplayer.cpp |
Never mind, please just ignore my previous message.
but I've just derived it from the official gst-plugins-bad 1.16 code |
Thanks for keeping at it. I've got some more urgent work planned for this morning but hopefully will be done before the end of the day and come back to this PR ASAP, I need to see this work on imx anyway :) |
I think you are right, the gtk functions should not be present in this portion of the code, or at least they should be wrapped in a
Please let me know if you need me to perform specific tests. |
I just got started on my board (imx8mp by the way, but hopefully it's close enough).
Well, that's fine, but it won't work without an equivalent code path without gtk -- gstreamer on wayland needs to be given a pointer to the wayland display at some point or creates a new connection, which won't allow subsurfaces to be created. The problem seems to be setting either I'm not sure what we can do to please both worlds. But short term we've got the short handle of the stick, I'll try to look into why the auto sink didn't pick the "good" gstglimagesink on the imx board, but I'm afraid it might not be able to use it... |
Being wayland only supported via Linux+GTK3, I was actually suggesting to wrap all the changes, not just the internal handler calls. |
wayland is only supported via gtk3 right now but ultimately it could work with others right? e.g. there's no reason the qt backend wouldn't work with wayland, but I have no idea if it's compatible with mediactrl (I suppose gstreamer should work as long as we give it somewhere to draw on, but not sure how compatible the event loops would be...) I'm using whatever is in their lf-5.10.y-1.0.0 release right now -- it looks like gatesgarth. The plan will be to move to debian however (with quite some pain involved around the proprietary blobs..) so this is really just for testing. Anyway:
|
Ok so, progress!
Might need some light cleanup & comments added but I think we're good for gstplayer now -- @varigigi if you have time would you mind testing on the imx board again for wayland sink there? I'll probably get around to it in the next few days but I think you'll be faster Then there's the matter of the non-gstplayer variant, I honestly didn't look at it yet, but I assume it'd require similar patches. What do we want to do about it? |
Great job! the mediaplayer is fluently using the video accelerations from Gstreamer in Wayland:
Looking forward to see it in WxWidgets 3.1.6 |
@varigigi thanks for testing! I also confirmed just now. I know we're not testing the evk but hardware decoding is indeed impressive, I'm getting 20% cpu (+8% from weston) with 1080p@30fps bbb resized to almost full screen on a 4k display -- there's no way that'd work without acceleration :) @vadz I've rebased, added comments, and squashed the fixes so we're back to two logically separated commits (no code change from what @varigigi tested) the non-gstplayer variant of wxMediaCtrl would likely need similar fixes but I won't have time to look at it right now and this is probably worth getting as is already. |
d46fbc8
to
5042abc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks again!
I don't really know anything about the actual functions used by this code, but I'm quite ready to merge this without looking into this if it works for you and others. The only uncomfortable point is unsetting DISPLAY
globally, if we could at least do it locally/temporarily, it would alleviate 99% of my concerns. If not, I guess we'll just have to leave with my concerns and merge it nevertheless...
GstBus *bus = gst_pipeline_get_bus(GST_PIPELINE(gst_player_get_pipeline(m_player))); | ||
gst_bus_add_signal_watch(bus); | ||
gst_bus_set_sync_handler(bus, bus_sync_handler, this, NULL); | ||
gst_object_unref(bus); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, this is not really related to this PR and shouldn't be done in it, but I just wanted to mention that if anybody is interested in copying wxGtkObject
from include/wx/gtk/private/object.h
to some wxGstObject
and using it here, it would be welcome!
gstreamer creates a new connection to the wayland display by default, and gst_video_overlay_set_window_handle() only works if both the parent surface (part of the gtk window) and the gstreamer surface are on the same display, so we need to tell gstreamer about our wl_display when it asks
1d6cd3c
to
6e324b7
Compare
without this call gstreamer + gtk wayland would just draw the video over the whole window. There might be a better way to do that
gstreamer is known to crash on xvimagesink if the main window is wayland-native and DISPLAY is set: try to make it not load. Also do the same for ximagesink just in case.
the Move handler apparently misses some resize events, so move the gst_player_video_overlay_video_renderer_set_render_rectangle call to expose_event_callback. This is kept as a separate commit because it would be more efficient to keep it in Move once we can catch that initial size change, so this commit can get reverted then.
We're getting closer...! Now my last qualm is about positioning. I didn't notice it earlier with the code going through resize on every frame (expose_event_callback), but now I'm doing it in Move it's obvious there's a difference in behaviour with X11 if the window isn't resized.
Just to make sure I tried to make realize get the widget dimension through m_ctrl->m_wxwindow like I do in the Move handler and the dimension really changed at some point: if I log the size obtained that way in the expose event callback, I get the same x/y but the width/height change after two events:
I'm not sure how So:
in both cases figuring where that change comes from might help... That being said I guess we've got enough improvements for one iteration, can always look at improving further later. |
Thanks again for another update! I don't understand why did it still not run the GitHub CI builds for it even though I had already approved running them, but I've just done it again. If they pass (and I see no reason they shouldn't), I'm perfectly fine with merging this as is. If I understand you correctly (sorry, still didn't have time to actually test it myself), the positioning is indeed a bug, but as long as it's the same bug with X11 and Wayland, we could probably live with it -- even though, of course, it would be nice to fix it in a later PR. |
Ok, let's get this in and I'll take a look at positioning as time permits, it doesn't strike me as normal but we're indeed aligned with X11 and wayland now. |
Great, thanks again for your work on this, Dominique! |
👍 Thanks a lot for your work @martinetd. I had been trying for some time to get wxMediaCtrl working with Wayland, so I'm glad to see it happen! |
Great, if there are other users it's less likely to break when I'm not looking :D Thanks for the tests and review to you three. I need to fiddle with some other things for a while, but I'll come back for the resize issue definitely. |
wxMediaCtrl wayland support in #2257 seems to be incomplete.
In particular, the mediaplayer does not work under wxgtk3 with wayland (unset DISPLAY to make sure) - the most obvious thing that happens is the video stays black while sound plays, and the console gets filled with "Failed to flush Wayland connection" messages.
That problem is fixed in the first commit:
(see https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/issues/635 for details as I could reproduce this with a simpler client)
With that fixed the video was being drawn on the full window, the second commit sets where it is drawn only for gtk+wayland.
Tested on X11, weston and sway.
Please tell me if there are things you'd like fixed or concerns.
cc @varigigi (not sure if watching)