Commit graph

878 commits

Author SHA1 Message Date
Matthew Waters 0806de5c75 glbufferpool: add the GstVideoGLTextureUploadMeta buffer pool option 2017-12-09 19:31:48 +00:00
Wang Xin-yu (王昕宇) 77682a51e6 glcolorconvert: support RGB16/BGR16 video format upload
https://bugzilla.gnome.org/show_bug.cgi?id=738842
2017-12-09 19:31:48 +00:00
Brion Vibber 02a0b92d9d gl/cocoa: Fix for building on Mac OS X 10.10
Using NSApp directly seems to confuse something, as the compiler
was expecting an id<NSFileManagerDelegate>. Switched to using
[NSApplication sharedApplication], and specified the delegate
protocol on the window class as well.

https://bugzilla.gnome.org/show_bug.cgi?id=738740
2017-12-09 19:31:48 +00:00
Matthew Waters 6663967994 glfilter: add uploaded_buffer field 2017-12-09 19:31:48 +00:00
Sebastian Dröge 6d273084eb gl/cocoa: Add support for HiDPI displays
Without this our GL surface would be upscaled after rendering
by Cocoa, which would reduce image quality.
2017-12-09 19:31:48 +00:00
Matthew Waters 3439402164 glcolorconvert: output why we cannot convert a buffer 2017-12-09 19:31:48 +00:00
Matthew Waters df6967c274 glcolorconvert: fix planar YUV download
- sample the u and v planes properly
- output the correctly scaled u and v planes for different chroma block sizes
2017-12-09 19:31:48 +00:00
Matthew Waters a771b40474 glcolorconvert: fix UYVY download green screen 2017-12-09 19:31:47 +00:00
Matthew Waters ea711807d8 glcolrconvert: fix YUY2 download
- The shader was outputing the wrong values compared with raw
  videotestsrc.
- deal with the texture edge properly.
- properly sample the 2x1 rectangle for the u and v values
- don't double sample the y value
2017-12-09 19:31:47 +00:00
Sebastian Dröge 435810b238 gl/cocoa: Always update our viewport if Cocoa tells us something has changed
The visible rect and bounds might be the same as before, but Cocoa
might've changed our viewport without us nothing. This happens if
you hide the view and show it again.
2017-12-09 19:31:47 +00:00
Sebastian Dröge b44798d549 gl/cocoa: Handle NSView::renewGState() properly
Don't update the screen until we redraw, this prevents flickering during
scrolling, clipping, resizing, etc
2017-12-09 19:31:47 +00:00
Matthew Waters e6bd70d580 glcolorconvert: convert xRGB into ARGB properly
The alpha channel might not be the last component so check which one
it is in and clobber that one instead.
2017-12-09 19:31:47 +00:00
Matthew Waters 5c7b5e0210 glmemory: unset the opposite corresponding transfer flags when mapped with write
fixes consistency with consecutive gst_memory_map()'s with
flags & GST_MAP_WRITE
2017-12-09 19:31:47 +00:00
Sebastian Dröge b1a5ae7c0d gl/cocoa: Update viewport according to the current clipping
We have to update the GL viewport if the NSView is only partially
visible. Otherwise the content of the frame will be visibly offset.
2017-12-09 19:31:47 +00:00
Sebastian Dröge 9ff86a3c54 gl/cocoa: Improve the NSApplication initialization
This is only for non-Cocoa apps but previously caused a 2 second
waiting during startup for Cocoa apps. This is unacceptable.

Instead we now check a bit more extensive if something actually
runs on the GLib default main context, and if not don't even
bother waiting for something to happen from there.
2017-12-09 19:31:47 +00:00
Sebastian Dröge 7cf214796a gl/cocoa: NSView::drawRect() should call into reshape too
We a) need to render again because part of the window was
obscured and b) might need to reshape because of clipping
changes.
2017-12-09 19:31:47 +00:00
Sebastian Dröge 32b23a340e gl/cocoa: Call UI related API from the application main thread 2017-12-09 19:31:47 +00:00
Sebastian Dröge 02b3e26854 gl/cocoa: Switch to a plain NSView subclass instead of NSOpenGLView
We don't and can't use NSOpenGLView as it's supposed to be used and
it gets into our way by being to clever in various situations.
2017-12-09 19:31:47 +00:00
Edward Hervey ef00d85f16 glcontext: Initialize variable
Avoids the following warning:

gstglcontext.c:647:58: error: 'prev' may be used uninitialized in
 this function [-Werror=maybe-uninitialized]
2017-12-09 19:31:47 +00:00
Matthew Waters ca476f03a8 glcontext: fixup error in sharegroup comment 2017-12-09 19:31:47 +00:00
Matthew Waters 817417c005 glcontext: detect the sharegroup case where the context are in different chains
In the end they will lead to the same root context in the tree so check that
for equality.
2017-12-09 19:31:47 +00:00
Matthew Waters 80be2d046b glfilter: silence a warning with empty input caps
discovered with the doublecube example

gst_caps_get_features: assertion 'index < GST_CAPS_LEN (caps)' failed
2017-12-09 19:31:47 +00:00
Sebastian Dröge ec0d04acec gl/cocoa: Switch from our custom main loop to a GMainLoop
Simplifies code a lot and makes it more similar to the other backends.
2017-12-09 19:31:46 +00:00
Sebastian Dröge 6c8f7f9dd5 gl/cocoa: Clear the current GL context when it should happen 2017-12-09 19:31:46 +00:00
Matthew Waters ae919f4475 gl: download whenever we have sysmem capsfeatures
Otherwise we could pass on a RGBA formatted buffer and downstream would
misinterpret that as some other video format.

Fixes pipelines of the form

    gleffects ! tee ! xvimagesink
2017-12-09 19:31:46 +00:00
Matthew Waters ccf8f014f0 glupload: fallback to upload if contexts cannot share GL resources
Fixes pipelines of the form

    gleffects ! tee ! glimagesink

as tee does not pass on the allocation query.
2017-12-09 19:31:46 +00:00
Matthew Waters 14630fac38 glcontext: add gst_gl_context_can_share
Which determines whether two GstGLContext's can share sharable
OpenGL resources.
2017-12-09 19:31:46 +00:00
Sebastian Dröge 9dd4f40ad6 gl: Let gst_gl_context_get_thread() return a new reference to the GThread
Otherwise it might go away in the meantime and the caller has some random pointer.
2017-12-09 19:31:46 +00:00
Anuj Jaiswal e9e84da30a gl: consecutive return, break statement
Signed-off-by: Anuj Jaiswal <anuj.jaiswal@samsung.com>

https://bugzilla.gnome.org/show_bug.cgi?id=736939
2017-12-09 19:31:46 +00:00
Matthew Waters 678e7b49b2 gl/debug: desktop GL does not have the KHR suffixes 2017-12-09 19:31:46 +00:00
Tim-Philipp Müller 9cccbb315c gl: add since markers for new API 2017-12-09 19:31:46 +00:00
Matthew Waters a793bda9b4 glmemory: add debug line for freeing textures 2017-12-09 19:31:46 +00:00
Matthew Waters 6491af9ffc glupload: provide the output buffer that is rendered into
Allows callers to properly reference count the buffers used for
rendering.

Fixes a redraw race in glimagesink where the previous buffer
(the one used for redraw operations) is freed as soon as the next
buffer is uploaded.

1. glimagesink uploads in _prepare() to texture n
1.1 glupload holds buffer n
2. glimagesink _render()s texture n
3. glimagesink uploads texture n+1
3.1 glupload free previous buffer which deletes texture n
3.2 glupload holds buffer n+1
4. glwindow resize/expose
5. glimagesink redraws with texture n

The race is that the buffer n (the one used for redrawing) is freed as soon as
the buffer n+1 arrives.  There could be any amount of time and number of
redraws between this event and when buffer n+1 is actually rendered and thus
replaces buffer n as the redraw source.

https://bugzilla.gnome.org/show_bug.cgi?id=736740
2017-12-09 19:31:46 +00:00
Matthew Waters 4e75ceba46 glcontext: add API to retreive the thread that context is active in 2017-12-09 19:31:46 +00:00
Ognyan Tonchev 7e21e35eac glfilter: do not leak pool in error cases
https://bugzilla.gnome.org/show_bug.cgi?id=736732
2017-12-09 19:31:46 +00:00
Vasilis Liaskovitis f803a9e746 GstGLWindow: Introduce navigation thread
This thread dispatches navigation events. It is needed to avoid deadlocks
between window backend threads that emit navigation events (e.g. X11/GMainLoop
thread) and consumers of navigation events such as glimagesink, see
https://bugzilla.gnome.org/show_bug.cgi?id=733661

GstGlWindow_x11 thread is changed to invoke the navigation thread for navigation
dispatching, instead of emiting the event itself. Othe backends beside X11 do
not dispatch navigation events yet, but should use this thread when dispatching
these events in the future.

The navigation thread is currently part of GstGLWindow and not implemented in
separate subclasses / backends. This will be needed in the future.

gst_gl_window_x11_get_surface_dimensions is also changed to use a cached value
of the window's width, height. These values are now retrieved in the X11
thread, function gst_gl_window_x11_handle_event. This change is needed because
otherwise the XGetWindowAttributes gets called from the navigation thread,
leading to xlib aborting due to multithreaded access (if XInitThreads is not
called before, as is the case for gst-launch)
2017-12-09 19:31:46 +00:00
Wang Xin-yu (王昕宇) 62bebdb4e6 gl: Add GSTGLAPI macro to the debug callback function
Fixes the Windows build.

https://bugzilla.gnome.org/show_bug.cgi?id=735565
2017-12-09 19:31:46 +00:00
Jan Schmidt 2d928bad1c egl: Wrap KHR_create_context flags in an ifdef
EGL_CONTEXT_FLAGS_KHR and EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR
don't exist in the Android NDK. Wrap their usage in an #ifdef
EGL_KHR_create_context to fix the build there.
2017-12-09 19:31:45 +00:00
Matthew Waters f6930bc0b4 egl: fallback to a non-debug context if a debug one fails
The text for EGL_KHR_create_context added the possiblity for ES
contexts to ask for a debug context however that has not been
fully realized by all implementations.  Fallback to a non-debug
context when the implementation errors.
2017-12-09 19:31:45 +00:00
Lubosz Sarnecki 30591d664c gstopengl: add introspection support
https://bugzilla.gnome.org/show_bug.cgi?id=734482
2017-12-09 19:31:45 +00:00
Lubosz Sarnecki 67b9f71619 glshader: expose opengl handle in getter
https://bugzilla.gnome.org/show_bug.cgi?id=734482
2017-12-09 19:31:45 +00:00
Wang Xin-yu (王昕宇) c8d1e4ad5f gl: check null before unref GstGLDisplay 2017-12-09 19:31:45 +00:00
Matthew Waters ac2fdb0aed gl: add prototype definition for KHR_debug 2017-12-09 19:31:45 +00:00
Matthew Waters 61b95b0300 glcontext: implement the debug callback
For both GL_KHR_debug and ARB_debug_output.  This allows us to
receive errors and other hints from the GL instead of querying after
every GL operation.
2017-12-09 19:31:45 +00:00
Matthew Waters d7a465f9da gl: add prototypes for KHR_debug/ARB_debug_output 2017-12-09 19:31:45 +00:00
Matthew Waters a76fe07919 gl: don't take an extra ref on the display on set_context
gst_context_get_gl_display() returns a ref.  Don't take another in
gst_object_replace().
2017-12-09 19:31:45 +00:00
Tim-Philipp Müller 15cd3d3d5c glbufferpool: fix allocator leak in some cases
Spotted by Sebastian Rasmussen.

https://bugzilla.gnome.org/show_bug.cgi?id=734523
2017-12-09 19:31:45 +00:00
Vasilis Liaskovitis 7b1a853888 GstGLWindow, GstGLImagesink, x11: Scale navigation events on resized windows
If window is resized, GstStructure pointer values have to be rescaled to
original geometry. A get_surface_dimensions GLWindow class method is added for
this purpose and used in the navigation send_event function.

https://bugzilla.gnome.org/show_bug.cgi?id=703486
2017-12-09 19:31:45 +00:00
Wang Xin-yu (王昕宇) f322a331c8 glupload: don't determine if frame needs upload by pointer compare
https://bugzilla.gnome.org/show_bug.cgi?id=734269
2017-12-09 19:31:45 +00:00
Matthew Waters fab6790c7f gl/docs: remove superflous 'the' 2017-12-09 19:31:45 +00:00
Matthew Waters d3804ee7aa gl: document GST_GL_* environment variables
https://bugzilla.gnome.org/show_bug.cgi?id=733245
2017-12-09 19:31:45 +00:00
Matthew Waters 4277d2742a glcontext: add a destroy function
that just calls the subclass
2017-12-09 19:31:45 +00:00
Matthew Waters d3077a890c gl/x11: silence runtime warning
g_main_loop_quit: assertion 'loop != NULL' failed
2017-12-09 19:31:45 +00:00
Matthew Waters 9426c0793e glmemory: use the plane offsets to compute the size of the data pointer
Certain elements expect that there be a certain number of lines
that they can write into.  e.g. for odd heights, I420, YV12, NV12,
NV21 (and others) Y lines are expected to have exactly twice the
number of U/UV lines.

https://bugzilla.gnome.org/show_bug.cgi?id=733717
2017-12-09 19:31:45 +00:00
Matthew Waters c216799b20 glmemory: use GstVideoInfo everywhere
Simplifies a lot of the calling code

https://bugzilla.gnome.org/show_bug.cgi?id=733717
2017-12-09 19:31:45 +00:00
Matthew Waters 2b82b78ef5 glmemory: reenable the texture_rg support for !eagl
The GST_GL_HAVE_PLATFORM_EAGL is always defined we need to compare
against the value instead.
2017-12-09 19:31:44 +00:00
Vasilis Liaskovitis b1e821f731 glwindow/11: Emit signals for mouse and key navigation events
https://bugzilla.gnome.org/show_bug.cgi?id=703486
2017-12-09 19:31:44 +00:00
Sebastian Dröge 307db954fd glwindow: Constify string parameters to the send_*_event() functions 2017-12-09 19:31:44 +00:00
Vasilis Liaskovitis 6b38d58427 GstGLWindow : Add mouse-event and key-event signals for navigation
https://bugzilla.gnome.org/show_bug.cgi?id=703486
2017-12-09 19:31:44 +00:00
Wang Xin-yu (王昕宇) 2ce11e4bac gl: fix multi gl object leaks
1. fix FBO leaks in decide_allocation
2. fix texture leaks in decide_allocation and reset
3. fix texture leaks in FBO incomplete error path
2017-12-09 19:31:44 +00:00
Sebastian Dröge b02a6a98b2 gl: Link to all required libraries but not more 2017-12-09 19:31:44 +00:00
Sebastian Dröge ab7a152cd4 gl: Move GstGLMixer to the plugin for now
It depends on GstAggregator and we don't want to install headers
for that yet.

https://bugzilla.gnome.org/show_bug.cgi?id=732207
2017-12-09 19:31:44 +00:00
Julien Isorce 62ac6db6a0 glcocoa: initalize NSApp asap when using gst-launch
See https://bugzilla.gnome.org/show_bug.cgi?id=732661
2017-12-09 19:31:44 +00:00
Sebastian Dröge f6ae4ab243 eagl: Disable usage of R and RG textures on iOS
They don't work currently and just render zeroes, while the
fallback code path with LUM and LUM_ALPHA textures still works.

https://bugzilla.gnome.org/show_bug.cgi?id=732390
2017-12-09 19:31:44 +00:00
Matthew Waters 216b5ec9a8 glcolorconvert: free pixel swizzling information 2017-12-09 19:31:44 +00:00
Matthew Waters 251c8a98ed glmixer: remove redundant/unused lock
Use the GstObject lock instead
2017-12-09 19:31:44 +00:00
Matthew Waters 21ea062cc8 glmixer: remove redundant creation and free of GPtrArrays
Also plugs a memory leak
2017-12-09 19:31:44 +00:00
Matthew Waters 4131456751 glmixer: plug a memory leak for the caps
gst_query_set_caps_result() takes a ref on the caps
2017-12-09 19:31:44 +00:00
Matthew Waters 6cea67b92a glmixer: intersect with the filtercaps if available 2017-12-09 19:31:44 +00:00
Matthew Waters 1e49da469d gl: update gles2 compatability header 2017-12-09 19:31:44 +00:00
Matthew Waters 730b88a677 glfilter: pass through the allocation query when in passthrough mode
Otherwise two GL elements on either side will fail to use the same
GL context.
2017-12-09 19:31:44 +00:00
Matthew Waters 3a20e70cbd glfilter: prefer passthrough for non-sysmem caps 2017-12-09 19:31:43 +00:00
Julien Isorce 7cdce1bdfc glfilter: handle NULL decide_query which means passthrough
See https://bugzilla.gnome.org/show_bug.cgi?id=732178
2017-12-09 19:31:43 +00:00
Julien Isorce e016324d31 glfilter: prepend intersection to src caps
Prefer to stay in the same memory space if possible.
Also it let a chance to do passthrough.

See https://bugzilla.gnome.org/show_bug.cgi?id=732178
2017-12-09 19:31:43 +00:00
Matthew Waters bcce615263 gl: add a scary note about initializing thread support for the winsys
We cannot do it as the winsys may crash if we initialize too late.

Example, GLX contexts with Intel drivers:
Intel requires the X Display to be the same in order to share GL
resources across GL contexts.  These GL contexts are generally
accessed from different threads.  Without winsys support it is
nearly impossible to guarentee that concurrent access will not
occur.  This concurrent access could result in crashes or abortion
by the winsys (xcb).

https://bugzilla.gnome.org/show_bug.cgi?id=731525
2017-12-09 19:31:43 +00:00
Matthew Waters 5fd0dc505e gluploadmeta: reenable GLMemory upload path 2017-12-09 19:31:43 +00:00
Matthew Waters 1f8c784131 gl: move gles2 compat header to glprototypes 2017-12-09 19:31:43 +00:00
Matthew Waters ec8f3e58de glbufferpool: provide a consistent API regardless of platform 2017-12-09 19:31:43 +00:00
Matthew Waters c399908c4b gl: mark library as API unstable 2017-12-09 19:31:43 +00:00
Thibault Saunier 30a9ef3768 gl: Port glmixer to the GstVideoAggregator baseclass
https://bugzilla.gnome.org/show_bug.cgi?id=731921
2017-12-09 19:31:43 +00:00
Matthew Waters b2eb1b305c glframebuffer: don't segfault needlessly with GLES2
gst_gl_framebuffer_use_v2 was using a function that is not available
with GLES2
2017-12-09 19:31:43 +00:00
Matthew Waters 58fbcfdf1f gldownload: plug a memory leak 2017-12-09 19:31:43 +00:00
Matthew Waters a656e76ac9 glmixer: allow the subclass to choose the sink pad type
Allows custom properties to be placed on the sink pads by subclasses
2017-12-09 19:31:43 +00:00
Matthew Waters 90eefa6e5a glmixer: send the stream-start event
and the caps event after.

https://bugzilla.gnome.org/show_bug.cgi?id=730944
2017-12-09 19:31:43 +00:00
Matthew Waters e523cdd21a glfilterapp: remove the reshape/draw properties
The reshape property was never used.
Replace the draw property with a signal.

Based on patch by Mathieu Duponchelle <mathieu.duponchelle@epitech.eu>

https://bugzilla.gnome.org/show_bug.cgi?id=704507
2017-12-09 19:31:42 +00:00
Matthew Waters 6a7ccd6f3e glmixer: lock the size of mix->frames to the number of pads
Fixes a segfault with decodebin ! glmixer where the request pads on
both sides were being requested after the state change to PAUSED.

Also fixes dynamically adding and removing pads while glmixer is
in a state >= PAUSED.
2017-12-09 19:31:42 +00:00
Matthew Waters 5433010ab5 gl/wayland: create a dummy display instead of an EGLDisplay
Currently, GstGLWindowWaylandEGL holds the wayland display connection
If we create the EGLDisplay at the GstDisplay creation time, then
libEGL will internally open another connection to the wayland server.
These two display connections are unable to communicate resulting in
no window output/display and hangs inside libEGL.

Eventually we will move the wl_display from GstGLWindow to GstGLDisplay.
2017-12-09 19:31:42 +00:00
Matthew Waters 57a54e9de4 glupload: always release the previous buffer
Fixes the case where _perform_with_buffer() is called without
intervening calls to _release_buffer() as is the case on start up
with glimagesink.

Also release the buffer when reseting the upload.

https://bugzilla.gnome.org/show_bug.cgi?id=731107
2017-12-09 19:31:42 +00:00
Sebastian Dröge 188ae1c3b0 glcontext: Handle (unlikely) NULL return of gl->GetString (GL_VERSION) more gracefully
CID 1219858
2017-12-09 19:31:42 +00:00
Matthew Waters ea8c49f106 glmemory: remove uneeded gl api ifdefs 2017-12-09 19:31:42 +00:00
Matthew Waters 384434b060 glwindow_x11: allow expose events to redraw our window
otherwise we will not update the window contents on low framerate
streams until the next buffer

https://bugzilla.gnome.org/show_bug.cgi?id=723529
2017-12-09 19:31:42 +00:00
Matthew Waters b534e7e7af glcontext: fix up assertion
error: 'return' with no value, in function returning non-void
2017-12-09 19:31:42 +00:00
Matthew Waters 4a8b31afd6 glfeature: remove GST_GL_API_GLES3
instead check the gl version using gst_gl_context_check_gl_version()
2017-12-09 19:31:42 +00:00
Matthew Waters bfd8550bff glcontext: check for GLES versions 2017-12-09 19:31:42 +00:00
Matthew Waters babef3069b gl/context: add check_gl_version 2017-12-09 19:31:42 +00:00
Edward Hervey 2ee94d606c glcontext: Try GLX support before EGL support
If available, glx has got a better chance of being the Gl platform
we want to use compared to EGL
2017-12-09 19:31:42 +00:00
Edward Hervey 14f844e1e9 glcontext: Try to open lib{EGL|GL|GLESv2}.so.1 before lib{EGL|GL|GLESv2}
Fixes issues with .so (without numbering) being installed for development
(such as from mesa-dev) but actual driver (with numbering) coming from
some other place (like nvidia drivers)
2017-12-09 19:31:42 +00:00
Sebastian Dröge 631278270f glupload: Fix assertion after API changes 2017-12-09 19:31:42 +00:00
Matthew Waters 5009338a50 gl/colorconvert: keep our private pointer
again, avoid to much trigger
2017-12-09 19:31:42 +00:00
Matthew Waters 04b2144ff1 gl/colorconvert: use GstObject's lock instead of our own 2017-12-09 19:31:42 +00:00