Commit Graph

46 Commits

Author SHA1 Message Date
Matthias Clasen
00763e5af3 media: Don't include gsk/gl/gskglrenderer.h 2021-08-22 12:29:40 -04:00
Matthias Clasen
3227aa2c45 mediastream: Rename apis one more time
Before we end up with names that we are unhappy with,
rename things one more time, and update all callers.
2021-07-03 09:05:33 -04:00
Timm Bäder
106417ada7 gtkffmediafile: Fix deprecated API usage 2021-07-02 18:41:55 +02:00
Matthias Clasen
96fc5dc3a7 mediastream: Some more api renaming
Also rename gtk_media_stream_ended to
gtk_media_stream_set_ended, to avoid naming
collision with GtkMediaStream:ended.

The existing entry points still exist, deprecated
and marked as non-introspectable.

Update all internal uses.

Fixes: #4023
2021-06-15 18:33:23 -04:00
Matthias Clasen
86b5dba43b mediastream: Rename an api to avoid name collisions
Some bindings can't handle the coexistence of
GtkMediaStream:prepared and gtk_media_stream_prepared.
Help them out by renaming the function to
gtk_media_stream_set_prepared, and rename
gtk_media_stream_unprepared as well, to match.

The existing entry points still exist, deprecated.

Update all internal uses.

Fixes: #4023
2021-06-14 07:50:12 -04:00
Chun-wei Fan
16f307b305 media-gstreamer: Provide fallback mode for playback
Make the "gl-context" property of the GstGLSink readable as well so that
we can query whether the GstGLContext sharing really succeeded.  If it
did, then we proceed to playback our video using the glimagesink as we
did before.  If it didn't, throw out the GtkGstSink we were creating, and
re-create the GtkGstSink without the "gl-context" property, meaning that
we won't be using the glimagesink in this case.
2021-05-24 19:04:37 +08:00
Chun-wei Fan
ccdec5da77 gtkgstsink.c: Support EGL on Windows as well
Add support to look for and use the EGL context in Windows if it was activated
instead of desktop OpenGL.

GstGL may have been built with or without EGL/libANGLE support, so if it were,
check in GstGL whether we have gst_gl_display_new_with_type() to create a
GstGLDisplay that is of the GST_GL_WINDOW_WIN32 type when we are using
Desktop OpenGL (WGL), otherwise we show messages indicating that envvars
need to be set to initialize GstGL properly.

Due to a bug in GstGL, the GstGLContext can only be set up successfully
if one of the following is true:

*  An OpenGL 3.x or later emulator, such as Mesa is used (for WGL)
*  The latest GstGL master is being used, at the time of writing (for
   WGL)
*  GTK, libepoxy and GstGL are all built only with WGL support (for WGL)
*  EGL is being used in GTK at runtime

Special thanks to Matthew Waters for the help during the process.
2021-05-24 19:04:14 +08:00
Chun-wei Fan
52d1c0c271 media/gstreamer: Support using GL for video for Windows
Add support to share the WGL context in GDK with the WGL context in GStreamer,
so that we can also use OpenGL in the gstreamer media backend to playback
videos.  For now OpenGL/ES is not supported for this under Windows.

The process of setting this up in Windows is a little bit more involved, as:

*  The OpenGL support in GstGL requires a GL 4.1 Core context, but we may just
   get the GL version from wglCreateContextAttribsARB() that we pass into the
   attributes, which is 3.2 by default.  So, try to ask for a 4.1 Core context
   first if we are asking for anything less.

*  There is only one GstDisplay available for Windows, so we just use
   gst_gl_display_new().

*  We must explicitly tell libepoxy that we are using wglMakeCurrent() outside
   of libepoxy that is being used in GdkGL, otherwise we would end up crashing
   as the GL/WGL function pointers would become invalid.

*  We must also deactivate temporarily the underlying WGL context that was made
   current by gdk_gl_context_make_current() so that when
   gst_gl_display_create_context() calls wglShareLists(), we won't get bitten
   by error 0xaa (resource busy), as some drivers don't handle this well when
   the GL context is current in another thread.

For the last two points we make use of macros defined by the platforms that the
build is done for to help us carry out the necessary tasks as needed.

Thanks to Matthew Waters for the info on integrating GstGL and windowing
toolkits on Windows.
2021-05-24 16:36:40 +08:00
Ivan Molodetskikh
12a9a0faf7 gtkgstmediafile: Remove media-info-updated callback
Instead, rely on position-updated which is also called always, and also
a little later than media-info-updated, giving GstPlayer time to figure
out more of the video info. Tested on local and remote mount videos,
images, sound files.

Works around / fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/3913,
https://gitlab.gnome.org/GNOME/gtk/-/issues/3914.
2021-05-19 18:55:37 +03:00
Rafał Dzięgiel
bbd4ee2986
meson: Do not enforce GStreamer EGL lib
GStreamer EGL headers are handled by GstGL lib.
No need to additionally import them.
2021-05-15 14:03:23 +02:00
Rafał Dzięgiel
c51eb7665e
gtkgstsink: Support EGL under x11
Add support for EGL under x11 windowing system to GStreamer sink
2021-05-14 19:29:00 +02:00
Ivan Molodetskikh
03ca7081df gtkgstmediafile: Fix callback argument type 2021-05-01 18:17:40 +03:00
Matthias Clasen
187072c3fa media: Fix a memory leak
This was introduced in e7dc82fa32.
2021-04-10 09:02:59 -04:00
Benjamin Otte
e7dc82fa32 gstmedia: Properly detect stream metadata when preparing
We can look at the GstPlayerMediaInfo to get all the info we care about.
2021-03-30 22:26:26 +02:00
Benjamin Otte
6569a877d8 Merge branch 'wip/otte/for-master' into 'master'
Wip/otte/for master

Closes #3810

See merge request GNOME/gtk!3366
2021-03-29 15:41:55 +00:00
Benjamin Otte
06be1f8b52 gstmedia: Ensure we prepare files without duration
In particular this fixes playback of images.

Fixes #3810
2021-03-29 17:08:34 +02:00
Matthias Clasen
60ccae000b media: Always use GL with gstreamer
As long as we can create a GL context, pass one to
gstreamer. This at least gets us GL textures with
the ngl renderer, the previous code was arbitrarily
refusing that.
2021-03-17 16:28:12 -04:00
David Lechner
b509809f34 meson: use correct module file extension on macOS
GModule requires the .so file extension on macOS for historic reasons.
However Meson defaults to .dylib for modules, so we need to override
it to get the correct extension.

Fixes #3645.
2021-02-05 16:54:28 -06:00
Jan Alexander Steffens (heftig)
4644dab081
gtkgstsink: Sync texture before handing it to GDK
We need to synchronize when moving the texture between contexts, or we
get glitches with VA-API decoding.
2021-01-29 18:58:17 +01:00
Jan Alexander Steffens (heftig)
00fd60aaa8
gtkgstsink: Use video_frame_free also for the GL path
The video frame needs to stay mapped while the texture is in use.

Avoid using g_memdup because the structure is not supposed to be moved.
2021-01-26 20:30:47 +01:00
Jan Alexander Steffens (heftig)
c7a7d0582a
gtkgstsink: Report allocation size even if no pool requested
We can do that so we should.
2021-01-26 20:30:47 +01:00
Chun-wei Fan
2b8ad6c4b5 gtkffmediafile.c: Use g_snprintf()
Visual Studio 2013 is just shy of being sufficiently C99-compliant to
build GTK master, as it did not support snprintf() in its CRT
implementation.

Use g_snprintf() to cover for this.
2021-01-08 22:24:42 -05:00
Matthias Clasen
0eab4deab0 Merge branch 'media-caps' into 'master'
media: Be more specific in our caps

See merge request GNOME/gtk!3037
2021-01-05 21:34:27 +00:00
Matthias Clasen
532b8c71a8 media: Be more specific in our caps
We can only handle 2D textures, so tell gstreamer
about that.
2021-01-05 09:28:04 -05:00
Chun-wei Fan
397a71ca8b gstreamer media backend: Disable OpenGL on Windows
...for at least WGL, since we are not allowed to use wglMakeCurrent(),
which is eventually called by gdk_gl_context_make_current() to share WGL
contexts across different threads, which will cause a crash.

This means, we cannot enable WGL in the gstreamer media backend on
Windows.
2021-01-05 14:34:06 +08:00
Matthias Clasen
536a67ec96 media: Only force GL if we're using a GL renderer
When we are not using a GL renderer, getting GL textures
is no advantage to us, so don't make gstreamer send its
frames as GL memory in this case.
2021-01-04 15:01:19 -05:00
Matthias Clasen
53fe751371 media: Convince gstreamer to deliver GL memory
Use a glsinkbin to make gstreamer deliver GL memory.
2021-01-04 15:00:36 -05:00
Benjamin Otte
7901ab857b media: Add support for OpenGL to GtkGstMediaFile 2021-01-04 15:00:36 -05:00
Sebastian Dröge
18ea60e235 gtkmediafile: Consider pixel-aspect-ratio for rendering video with the correct aspect ratio
Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/3516
2020-12-27 19:33:55 +02:00
Sebastian Dröge
6e108d310a gtkmediafile: Only unmap the GstVideoFrame in the GBytes destroy notify
The memory pointed to by GstVideoFrame::plane_data becomes invalid after
unmapping causing the GBytes to point at some random memory if the
unmapping is not deferred until its destroy notify.

When the GStreamer buffer is backed by normal system memory this is not
a problem but if it is backed by e.g. an OpenGL texture, dmabuf or some
other hardware-specific memory this will otherwise cause interesting
problems.
2020-12-26 14:26:23 +02:00
Emmanuele Bassi
99e0929d6c build: Use a consistent style for Meson files 2020-12-15 12:46:59 +00:00
Benjamin Otte
8e6701c9a6 gtkmediafile: Use cubic volume function
Gstreamer suggests doing that.

https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/issues/1439

Fixes #3295
2020-10-27 16:32:53 +01:00
Xavier Claessens
a4aa6d79ad meson: Use feature options for media and print backends
This gracefully disable ffmpeg, gstreamer, cups and cloudprint optional
dependencies when they are not available, while still giving full
control to distributors using -Dauto_features=enabled.
2020-10-17 09:54:47 -04:00
Chun-wei Fan
acd9c12667 modules: Fix build on Visual Studio
Visual Studio does not allow decorating functions with '__declspec (dllexport)'
if a prototype exists and is not decorated with '__declspec (dllexport)' as
well, so we cannot just decorate g_io_module_[load|unload|query] in the various
module sources with G_MODULE_EXPORT because the prototypes of these functions
have been marked with _GLIB_EXTERN, which equates to 'extern' unless overridden

Fix this by overriding _GLIB_EXTERN with the appropriate visibility flag, as we
have used to define _GDK_EXTERN.  Unfortunately, we can't just use _GDK_EXTERN
G_MODULE_EXPORT as they may have not been defined yet for our use

Do this across the board for all modules, even if they are not buildable on
Visual Studio nor Windows, for consistency's sake.
2020-06-05 11:16:45 +08:00
Benjamin Otte
0b8cebd6ef ffmediafile: Add fixes for recent cflags changes
Related: #2771
2020-06-03 16:23:49 +02:00
Qiu Wenbo
340a8e11b0 Build media backends with common_cflags and export the symbol
Fixes: #2771
2020-05-22 17:00:06 +08:00
Chun-wei Fan
8d987be673 Merge branch 'wip/fanc999/meson.msvc' into 'master'
GTK+ 4: Improve Windows/Visual Studio build experience

See merge request GNOME/gtk!185
2019-02-23 02:13:35 +00:00
Benjamin Otte
1423265610 gstmedia: Implement error handling.
I wonder who forgot that.
Whoops.
2018-12-18 02:04:54 +01:00
Chun-wei Fan
5383d11bb4 modules/media/meson.build: Export needed symbols on MSVC
We need to override _GLIB_EXTERN to export the required symbols for the
GIO module on Visual Studio, so that the media modules can be
successfully loaded.
2018-12-06 17:07:33 +08:00
Benjamin Otte
3439862634 gtkmediafile: Don't leak all the images
We were leaking the GBytes for the image memory, which is a
noticeable memleak to anyone who's casually running a memory monitor.

Go KDE users!

Closes #1200
2018-07-04 15:05:02 +02:00
Benjamin Otte
e665667bff mediafile: Check if media files are open when trying to play
If no file is open, refuse to play.
2018-07-04 06:15:33 +02:00
Benjamin Otte
12063fe53e ffmpeg: Fix compile warnings for newest version 2018-04-10 15:13:38 +02:00
Benjamin Otte
c74854fe49 paintable: Introduce gdk_paintable_new_empty()
Also, use it where appropriate.
2018-04-05 14:56:39 +02:00
Benjamin Otte
2362e4d41e gtk: Add a GStreamer implementation of GtkMediaFile 2018-03-18 21:01:23 +01:00
Benjamin Otte
800bcb5cb4 gtk: Add ffmpeg implementation of GtkMediaFile
This adds a module using ffmpeg to implement the GtkMediaFile interface.
2018-03-18 21:01:23 +01:00
Matthias Clasen
e4338c4d42 mediafile: Turn into an extension point
This way, we can support external libraries providing implementations of
GtkMediaFile.

We also add a media backend called 'nomedia' that can be enabled to not
compile any support for GtkMediaFile. This is useful when people want to
statically compile GTK into an application that does not use media.
For now, this option is the default.

We also support a new environment variable GTK_MEDIA that allows
selecting the implementation to use.
GTK_MEDIA=help can be used to get info about the available
implementations.
2018-03-18 21:01:23 +01:00