GNOME Bugzilla – Bug 728107
gl: No surface resizing logic on Android/iOS
Last modified: 2014-04-13 14:56:22 UTC
On Android and iOS when the surface is resized, glimagesink does not notice this and continues to render for the old surface size. Especially this means that the video is only rendered in the original size. Both platforms seem to provide nothing for getting notified about such changes, so in eglglessink we were polling for changes before rendering each frame. On Android (EGL) you can query the EGL_WIDTH and EGL_HEIGHT of the surface, on iOS you can get the CAEAGLLayer's frame.size.
Matthew, Julien, any ideas how to best integrate this into gst-plugins-gl? We could poll manually before each draw in the GstGLWindow subclasses, and if size changes call the resize callback... but is that enough? And it doesn't seem very elegant...
If nobody can tell us that the window size has changed i guess we have to check every draw. When all of the other implementations detect a resize (normally from the window system), they resize their window and call the resize callback. If the window resize is handled by the underlying window system, then the callback is all that is required to be called.
I'll take a look at implementing that then.
There are some options: 1: do like osxvideosink, i.e. manage an internal UIView and then set it as a subview (addSubView) of the one you get from gst_set_window_handle. Then in you internal UIView you could override "layoutSubviews" method. For the NSView it was the "reshape" method. (By the way I noticed osxvideosink implement navigation interface, shouldn't be hard to move that code in cocoa backend of gstgl) 2: do like in cocoa backend of gstgl, not sure if this is practical here as I decided to pass the NSWindow handle. But then it relies on the NSView too. "reshape" method here too. 3: add an observer to "bounds" property of the UIView you get from gst_set_window_handle. Not sure what would be the result but worth to try. 4: Override UIView::layoutSubviews in your application but then it would requires to add a new function to the GstVideoOverlay. gst_video_overlay_set_window_size. (or modify the description of gst_video_overlay_set_window_rectangle) waylandsink is in this 4th situation when using subsurface/st_window_handle, http://cgit.collabora.com/git/user/gkiagia/gst-wayland-gtk-demo.git/tree/main.c#n177 (gst_wayland_video_set_surface_size) . For me it would make sense to add gst_video_overlay_set_window_size for this purpose. With iOS/UIView I'm not sure in which situation you will fall but polling is not the right thing to do. So if possible do it the way Matthew described, if not your are in case 4.
commit 39c3ae5e5a717db507daad54dc6a7775a2fc09e3 Author: Sebastian Dröge <sebastian@centricular.com> Date: Sun Apr 13 16:53:58 2014 +0200 gl/eagl: Notify the window's resize callback about surface dimension changes https://bugzilla.gnome.org/show_bug.cgi?id=728107 commit 158cbc2cdf596ff5c21fea04501029e3bea5b0a3 Author: Sebastian Dröge <sebastian@centricular.com> Date: Sun Apr 13 16:46:11 2014 +0200 gl/eagl: Remove spurious private struct pointer commit e927d307203306a82ec67e096bc946a7bf9f7eec Author: Sebastian Dröge <sebastian@centricular.com> Date: Sun Apr 13 16:40:58 2014 +0200 gl/android: Notify the window's resize callback about surface dimension changes https://bugzilla.gnome.org/show_bug.cgi?id=728107