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 722343 - waylandsink: fix surface width/height when caps have changed
waylandsink: fix surface width/height when caps have changed
Status: RESOLVED OBSOLETE
Product: GStreamer
Classification: Platform
Component: gst-plugins-bad
1.x
Other Linux
: Normal enhancement
: git master
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2014-01-16 14:37 UTC by Benjamin Gaignard
Modified: 2018-11-03 13:19 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
waylandsink: fix surface width/height when caps have changed (6.36 KB, patch)
2014-01-16 14:37 UTC, Benjamin Gaignard
reviewed Details | Review
waylandsink: allow window resizing (14.38 KB, patch)
2014-01-28 16:36 UTC, Benjamin Gaignard
needs-work Details | Review
waylandsink: allow window resizing (14.36 KB, patch)
2014-02-04 12:35 UTC, Benjamin Gaignard
needs-work Details | Review
waylandsink: allow window resizing (14.25 KB, patch)
2014-02-04 13:02 UTC, Benjamin Gaignard
none Details | Review
waylandsink: allow window resizing (7.55 KB, patch)
2014-10-07 08:45 UTC, Benjamin Gaignard
none Details | Review
waylandsink: manage server window resizing (3.49 KB, patch)
2016-09-22 14:36 UTC, Fabien Dessenne
none Details | Review

Description Benjamin Gaignard 2014-01-16 14:37:04 UTC
Created attachment 266474 [details] [review]
waylandsink: fix surface width/height when caps have changed

If a player (like gst-play) only change the state between two files
waylandsink need to be able to resize the surface output according
to the new width/height values.

I have tested this patch with a command line similar to this one:
gst-play --audiosink fakesink --videosink waylandsink FILE1 FILE2
Comment 1 Sebastian Dröge (slomo) 2014-01-16 14:53:07 UTC
Comment on attachment 266474 [details] [review]
waylandsink: fix surface width/height when caps have changed

I might be missing somethnig but where does this recreate the window after caps changes?
What other sinks are doing is to keep the window size btw... and only adapt video rendering (adding block borders if necessary, scaling, etc.). Let's keep the behaviour between the different sinks the same.

Apart from that this code is broken for non-1/1 pixel-aspect-ratio. Already before your changes though :)
Comment 2 Benjamin Gaignard 2014-01-16 15:55:01 UTC
Window isn't recreated only dst.w and dst.h change and window dimension change when the surface is commited.

While user can't change the size of the window I done the assumption that video size == window size.

Do you have an example of how use pixel-aspect-ratio ?
Comment 3 Benjamin Gaignard 2014-01-17 10:23:16 UTC
Wayland have a client-side decoration model.
My assumption is that waylandsink doesn't have to provide this decoration, the drawback is that it doesn't provide edges where user interact to re-size the window.

If my assumption is correct window size should always be equal to video size.
If not, does waylandsink have to provide the decorations ?
Comment 4 Benjamin Gaignard 2014-01-28 16:36:14 UTC
Created attachment 267416 [details] [review]
waylandsink: allow window resizing

Weston allow to resize the window by keeping pressed CTRL + middle button.
waylandsink then receive configure event with new width and height so before display a new buffer send a reconfigure event to try to negotiate new caps with upstream element.

Wayland assume that the buffer size is equal to the surface to fill so we need to renegotiate new caps and we can't do resize inside the server like XVimagesink can do.

I have make shm_pool creation/destruction depend of wayland life instead of mixing it with sink life.

I have also some clean up around in sink width/height field.

gst-play with files with different resolution is also working now.
Comment 5 Sebastian Dröge (slomo) 2014-02-04 12:12:48 UTC
Review of attachment 267416 [details] [review]:

Generally looks good. But it's not clear to me what happens if upstream just ignores the reconfigure event and the new size will not be configured. What will happen?

::: ext/wayland/gstwaylandsink.c
@@ +308,3 @@
+    caps = gst_caps_make_writable (caps);
+
+    /* There can only be a single structure because the xcontext

xcontext?

@@ +320,3 @@
+     * fixed width/height caps again if not possible
+     * upstream */
+    if (filter) {

Put the filter bit outside the "if (sink->window)" block at the very end and just always do that

::: ext/wayland/gstwaylandsink.h
@@ +79,3 @@
   struct wl_callback *callback;
   guint redraw_pending :1;
+  gboolean reconfig_needed;

If you already use bitfields here, use them in a way that actually makes sense ;)
Comment 6 Benjamin Gaignard 2014-02-04 12:35:50 UTC
Created attachment 268064 [details] [review]
waylandsink: allow window resizing

This patch fix the comments.
"xcontext" comes from the copy/paste I have done from ximagesink to manage reconfigure.
Comment 7 Sebastian Dröge (slomo) 2014-02-04 12:39:02 UTC
Review of attachment 268064 [details] [review]:

Ok, so what happens if the reconfiguration does not happen and the old size is continued to be used? Is the frame just cropped or black borders added?

::: ext/wayland/gstwaylandsink.c
@@ +296,3 @@
     gst_caps_unref (caps);
     caps = intersection;
   }

You filter here too already, remove that part of the code... not useful to filter twice.
Comment 8 Benjamin Gaignard 2014-02-04 13:02:06 UTC
Created attachment 268068 [details] [review]
waylandsink: allow window resizing

If reconfigure failed, wayland window size remain the same without black borders or cropping.
Comment 9 Benjamin Gaignard 2014-04-18 12:11:09 UTC
Any additional comments on this patch ?
Comment 10 Julien Isorce 2014-04-19 09:28:57 UTC
Hi, not blocking but just to know how hard would it be to merge with https://bugzilla.gnome.org/show_bug.cgi?id=726193 ?
Comment 11 Benjamin Gaignard 2014-04-22 08:12:41 UTC
Hi,

It seems that George is doing a very large rework of waylandsink, when do you schedule to merge it ? If it is after 1.4 release, I think you can push my patch to improve a little wayland support.
Comment 12 George Kiagiadakis 2014-06-17 12:57:46 UTC
Hi,

I merged my branch today. My code takes into consideration the caps changes and the gst-play example in the description now works, but there are still some problems if the video is embedded with GstVideoOverlay. I am going to open a new bug for that, though, as the problem is different.

However, I'm not sure if this bug should be closed yet, because I have not implemented the same functionality as in attachment 268068 [details] [review] (the part that handles the configure event from the compositor and resizes the video). I will have a look at it as soon as I can.
Comment 13 Benjamin Gaignard 2014-10-07 08:45:09 UTC
Created attachment 287932 [details] [review]
waylandsink: allow window resizing

I have rework my patch to match with your latest development.
We have tested it on our board and it works fine now.
Comment 14 Nicolas Dufresne (ndufresne) 2016-09-21 19:48:04 UTC
Review of attachment 287932 [details] [review]:

Sounds like something we want. Quick question, why do you delay sending the reconfigure event upstream ?
Comment 15 Fabien Dessenne 2016-09-22 14:36:44 UTC
Created attachment 336086 [details] [review]
waylandsink: manage server window resizing

I have attached another patch that probably (since I did not have time to read the history of this bugzilla) deals with the same feature.
In this version no configure event is triggered through the pipeline. We just make use of the wayland viewport protocol
Comment 16 Nicolas Dufresne (ndufresne) 2016-09-22 22:07:59 UTC
I started to play with that a bit today. Unless I'm doing something wrong, the implementation of wl_shell_surface does not work in Weston. This greatly limits my ability to test. Both weston and gnome-wayland leaves the edges to 0. I ended up with a completly different implementation. I'll try and clarify what behaviour is to be expected.
Comment 17 Nicolas Dufresne (ndufresne) 2016-09-22 23:19:19 UTC
I've sent a very partial implementation. I think the old method previously proposed was not suitable with the use of viewporter. In that version, I simply update the render rectangle to be the size of the new request window. Which will by side effect resize the window. If you have the viewporter, it will scale the video keeping aspect ratio, if you don't, the video is kept centered unscaled. This of course is only for the special case where GStreamer create the top level window. Note, it's not perfect for the non-viewporter case, as we don't crop the output like ximagesink would do. It's require some work, as you need to destroy and create new wl_buffer for that. Probably not worth it, to be useful, this element really depends on viewporter.

commit f6b270d8eb0583940b59af35ea8552876234d335
Author: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Date:   Thu Sep 22 18:55:23 2016 -0400

    waylandsink: Update our window size on configure event
    
    This is specific to when the waylandsink is not being embedded. In
    this patch we pass the render lock to the window so it can safely
    call gst_wl_window_set_render_rectangle() with the new size.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=722343

Next step will be to push a reconfigure event upstream, and to teach get caps to prepend an "ideal" resolution. I haven't read yet, but I suppose this is most likely what Benjamin patch do.
Comment 18 Nicolas Dufresne (ndufresne) 2018-01-24 16:33:10 UTC
I've just created this bug, to make the top level window create by the element inline with what an application embedding the window would be.

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

Overall, the main issue if you compare X11 Window and WL Surface, it's that the WL Surface does not have a width/height you can request. Hacking around assuming windows width/height is the render rectangle width/height is quite a hack. I'm tempted to propose a new method to GstVideoOverlay. Something like set_window_size(). With that information, we could crop the output for the non-viewporter case, hence stop leaking out of the allocation. And then for all cases, when 792874 is fixed, we'll have a more consistent result when comparing with xvimagesink/ximagesink and other embeddable sinks out there.
Comment 19 GStreamer system administrator 2018-11-03 13:19:53 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-bad/issues/125.