Commit Graph

1330 Commits

Author SHA1 Message Date
Benjamin Otte
0a6c4711bc gstreamer: Fix small memleak 2024-11-04 21:50:26 +01:00
Benjamin Otte
7085a58f01 gstreamer: Identify GL memory by looking at the memory
Instead of looking at availability of a GL context, check the
memory's type.

That's what we do everywhere else and GL is not special.
2024-11-04 21:50:26 +01:00
Benjamin Otte
8b1dff5b94 gstsink: Do not advertise dmabufs with no formats
We return an empty format list when dmabufs aren't supported, not NULL.

And the sink was treating the empty format list by setting no fourccs
on the caps, which GStreamer conveniently interpreted as "any",
not as "none".
2024-11-04 21:50:26 +01:00
Simon McVittie
9d9e665f34 printing: Treat any G_DBUS_ERROR contacting Avahi as non-problematic
If we get an error from the message bus (dbus-daemon or dbus-broker),
for example ServiceUnknown if Avahi is not installed or perhaps
SpawnFailed if the service is disabled, it is mapped to a GLib GError.
The errors typically emitted by the message bus belong to the GDBusError
domain, but if nobody has registered the G_DBUS_ERROR domain yet,
then they might be mapped to G_IO_ERROR_DBUS_ERROR instead.

Previously, this code ignored G_IO_ERROR_DBUS_ERROR, but emitted a
warning if the error happens to have been mapped to G_DBUS_ERROR.
This resulted in action-at-a-distance: an unrelated component
triggering registration of the G_DBUS_ERROR domain would make printing
dialogs log the warning. This seems undesirable, and in particular it
can cause test failures, because GLib's test framework makes warnings
fatal by default.

Signed-off-by: Simon McVittie <smcv@debian.org>
2024-10-15 15:44:33 +01:00
Simon McVittie
7dc72303aa printing: If we cannot contact Avahi, debug-log the error message
If we get a G_IO_ERROR_DBUS_ERROR here, we shouldn't make too much noise
about it by default, but it's still a useful data point for debugging
and diagnosis.

Signed-off-by: Simon McVittie <smcv@debian.org>
2024-10-15 15:44:33 +01:00
Matthias Clasen
ea6bcdbd3d gstreamer: Fix gl context creation
We may not have a surface (since realizing media streams is optional),
so use the display when creating a gl context.
2024-10-04 11:18:48 -04:00
Matthias Clasen
bef38bd9c4 gstreamer: Tweak gl context handling
Just create the context when it is needed.
2024-10-04 08:21:58 -04:00
Matthias Clasen
79bb805a02 gstreamer: Simplify
Add a uses-gl property to our sink implementation, and use
it in the paintable code. This avoids juggling a second gl
context, with the risk of leaking it.
2024-10-04 07:49:07 -04:00
Matthias Clasen
d70c005021 gstreamer: Improve caps handling
Separate out the caps for dmabuf, gl and memory and add them
when appropriate.
2024-10-04 07:44:20 -04:00
Matthias Clasen
9fc7d8e947 Restructure gtk_gst_paintable_video_renderer_create_video_sink
This code had too many early exits and was leaking GL contexts
and Gstreamer elements. Simplify.
2024-10-04 07:44:20 -04:00
Matthias Clasen
b06ac9826c gstreamer: Use the default display if needed
Calling gtk_media_stream_realize is not mandatory, but we can
still try to make dmabufs happen. Tested by removing the realize
call from GtkVideo and using GDK_DISABLE=gl.
2024-10-04 07:44:20 -04:00
Matthias Clasen
94cacd79f9 gstreamer: Restructure gtk_gst_sink_propose_allocation
Split this clearly into two cases: dmabuf or gl memory.
2024-10-04 07:44:20 -04:00
Matthias Clasen
17d3631605 gstreamer: Make dmabufs work without GL
We only need a display to negotiate dmabuf formats. Pass that
directly, instead of getting the display of the GL context as
we did so far.

With this,

GSK_RENDERER=vulkan GL_DISABLE=gl gtk4-demo --run video_player

still uses dmabufs.

Related: #7048
2024-10-04 07:44:20 -04:00
Matthias Clasen
b7fba6298f gst: Don't leak texture builders
Found by code inspection. The leak was introduced in 4707784755.

Might help for #4184
2024-10-01 07:18:32 -04:00
nee
0c97c86573 gstmediafile: improve error message when there is an input stream.
Previously it was unclear why passing an input stream would crash a video,
unless you went into the source and read it.

This adds a clarifying message that only file based media files are supported.
2024-09-29 13:41:17 +02:00
Thomas Devoogdt
9f855eecb1
modules/printbackends/gtkprintbackendfile.c: add CAIRO_HAS checks
This is similar to the checks in tools/gtk-rendernode-tool-render.c.

resolves #5072

Signed-off-by: Thomas Devoogdt <thomas@devoogdt.com>
2024-09-17 10:55:40 +02:00
Benjamin Otte
2096a29b06 build: Remove an old workaround
The workaround only triggered in GStreamer < 1.19.1 but we require 1.23
now.
2024-08-08 19:03:31 +00:00
Benjamin Otte
ce352b5538 build: Move GStreamer dependency checks
Put them where all the other checks go so that it's easy for people
reading build files to see what GTK depends on.

Also reindent properly.
2024-08-08 19:03:31 +00:00
Benjamin Otte
4bcd2c75cc gstreamer: Require the same version for all GStreamer deps
We don't want people to have different GStramer library versions.

GStreamer now is developed in a monorepo, so the versions are in sync.
2024-08-08 19:03:31 +00:00
Benjamin Otte
3c3bf0192d gstreamer: Always build dmabuf support
I just spent an hour trying to figure out why things don't work. And it
was an optional dependency hidden 3 layers deep in some meson file.

This really has to stop.

And because just like in GTK, GStreamer's dmabuf APIs are always
available (they will just fail on Windows etc), there's no need to have
any conditions.

The only difference is that the GStreamer media backend now requires
GStreamer 1.24.
2024-08-08 19:03:31 +00:00
Matthias Clasen
17524f2794 gst: Fix a wrong unref function
Use gdk_color_state_unref on a color state.
2024-07-28 19:09:05 -04:00
Benjamin Otte
cbe09373a5 gstreamer: Specify values for unspecified values
When the cicp values coming out of GStreamer are unspecified, replace
them with the default cicp values for YUV video: 1/13/6.

We still may end up with unspecified values inside the params, because
GStreamer returns unspecified for primaries/tfs/matrices that aren't
supported by cicp.

See also https://github.com/AOMediaCodec/libavif/wiki/CICP#unspecified
fora similar discussion.
2024-07-26 15:16:05 +02:00
Benjamin Otte
103296d948 gstsink: Make it usable again
The later CICP changes made the cicp params we were setting unustable.

Set ones that work in the current state of git main. They are still
imperfect, but they reflect the current code.
2024-07-25 18:53:55 +02:00
Benjamin Otte
b1962de51a gtksink: Add colorstate handling
The part for matrix coefficients and range is commented out so far.

It requires fixes so the dmabuf handling code can properly deal with it.
2024-07-24 16:45:21 -06:00
Benjamin Otte
25268c2086 gstsink: Don't use g_autoptr 2024-07-19 21:37:48 +02:00
Benjamin Otte
823b529f89 gstsink: Remove unused member variable 2024-07-18 04:33:14 +02:00
Benjamin Otte
4707784755 gstsink: Use GdkMemoryTextureBuilder 2024-07-18 04:33:14 +02:00
Chun-wei Fan
1dfc6d65df GStreamer media backend: Fix building and running on Windows
Visual Studio (and possibly other non-GCC compilers) do not like
uses of #-preprocessor directives in macro usage (warning C5101: use of
preprocessor directive in function-like macro argument list is undefined
behavior is also shown), so fix the build by defining another macro
accordingly.
2024-04-24 16:15:32 +08:00
Matthias Clasen
ade1aaa8be printing: Add context to some strings
The job priority strings need context to disambiguate them from
similar short strings elsewhere.
2024-04-04 16:56:50 +02:00
Marek Kasik
fb3d8b8523 printing: Avoid accessing freed printers
Print backend can be disposed together with all its printers
as a reaction to user stopping enumeration of printers.
Adding a weak pointer help us to detect that the backend
was disposed and hence the backend and its printers should not
be used anymore.

Fixes #6265
2024-03-13 11:17:42 +01:00
Robert Mader
465446430e gstreamer: Use G_APPROX_VALUE to compare floats
Mainly to silence compiler warnings.
2024-03-03 14:35:27 +01:00
Alessandro Bono
b6767d2eef meson: Decouple linux/dma-buf.h and libdrm checks
Currently dmabuf_dep is found when the following conditions are met:
 - linux/dma-buf.h is present;
 - libdrm is found.

This is because Linux dmabuf support requires drm_fourcc.h which is part
of libdrm.

However, dmabuf_dep is used for two purposes:
 - define HAVE_DMABUF to state dmabuf support;
 - ensure the presence of drm_fourcc.h for gdk and for the
   media-gstreamer module.

Decouple this, unconditionally check for libdrm and require it on
Linux. Then, use libdrm_dep only to state the drm_fourcc.h presence.

Given that now we unconditionally require libdrm on Linux, HAVE_DMABUF
depends only on the linux/dma-buf.h presence.
2024-02-16 14:01:44 +01:00
Alessandro Bono
4e680cae48 gtkgstsink: Include gdkdmabuffourccprivate.h
It includes a fallback list of fourccs. Otherwise we might miss some
DRM_FORMAT definition.
2024-02-13 14:15:32 +01:00
Robert Mader
8f293f3153 gstreamer: Bump required version for offloading
This version is guaranteed to have all features in place.
2024-02-11 21:50:50 -05:00
Matthias Clasen
d91d0f1c0a gstreamer: Pass viewport along
Obtain the viewport from gstreamer, and pass it to the paintable
implemenation, which adds a clip node around the texture to enforce
the viewport.
2024-02-11 21:44:47 -05:00
Matthias Clasen
da227386ad Drop ffmpeg support
The experimental ffmpeg media backend  hasn't been building for a
year, and nobody showed up with a patch to make it build again.

Fixes: #5581
2024-02-09 22:32:58 -05:00
Matthias Clasen
b885d288cc Revert "gstreamer: Add more debug spew"
This reverts commit 67e50a6cfd.
2024-02-07 15:26:08 -05:00
Matthias Clasen
67e50a6cfd gstreamer: Add more debug spew 2024-02-07 14:43:01 +00:00
Matthias Clasen
9e05ce18d9 gstreamer: Simplify dmabuf code
We don't need a property here, we can just get the formats from
the display.
2024-02-07 14:41:28 +00:00
Robert Mader
d2097d0449 gstsink: Add support for DMABuf import and graphics offload
By implementing support for `GdkDmabufTextureBuilder` and
`GstVideoInfoDmaDrm`. This allows zero-copy video playback on Wayland
when paired with hardware video decoding.

Can be tested with `gtk4-demo --run=video_player`
2024-01-28 19:09:41 +01:00
Matthias Clasen
ae5ea8e495 printing: Convert headers to #pragma once
That is our current coding style.
2023-12-20 09:44:29 -05:00
Matthias Clasen
bbabb1973c media: Convert headers to #pragma once
This is our current coding style.
2023-12-20 09:43:54 -05:00
Andrey Kutejko
540a83327f Fix issues spotted by PVS-Studio 2023-11-14 08:56:40 +01:00
Benjamin Otte
310ab7b531 Remove G_ENABLE_DEBUG around debug checks
It started out as busywork, but it does many separate things. If I could
start over, I'd take them apart into multiple commits:

1. Remove G_ENABLE_DEBUG around GDK_DEBUG_*() calls
   This is not needed at all, the calls themselves take care of it.

2. Remove G_ENABLE_DEBUG around profiling code
   This now enables profiling support in release builds.

3. Stop poking _gdk_debug_flags and use GDK_DEBUG_CHECK()
   This was old code that was never updated.

4. Make !G_ENABLE_DEBUG turn off GDK_DEBUG_CHECK()
   The code used to
     #define GDK_DEBUG_CHECK(...) false
     #define GDK_DEBUG(...)
   which would compile away all the code inside those macros. This
   means a lot of variable definitions and debug utility functions
   would suddenly no longer be used and cause compiler errors.
2023-11-05 11:16:23 +01:00
Benjamin Otte
dd530b45e2 gstmediafile: Handle premultiplied alpha
1. Check GStreamer caps for premultiplied alpha and select
   GdkMemoryFormat accordingly

2. Set a GdkMemoryFormat for GL textures

Fixes the video in widget-factory being treated as premultiplied when it
isn't.
2023-11-01 08:01:27 +01:00
Jeremy Bícha
08d08678e8 print: Update printerprivate header location for cpdb backend
This fixes the print-cpdb build option
2023-08-08 17:55:54 -04:00
Chun-wei Fan
4e9bd13892 Visual Studio: Remove workarounds for <= glib-2.74.x
We now need glib-2.76.0 or later, which removes our needs for the workarounds
that we need to build the media backends against GLib-2.74.x or earlier, so
clean up things a bit.
2023-06-21 12:29:38 +08:00
Matthias Clasen
30ff352960 print: Maintain compatibility
gtkunixprint.h is a public header, that needs
to keep being installed in the same location.
2023-06-07 07:16:26 -04:00
Matthias Clasen
d1aae4bffa print: Move all the remaining sources
Move the unix- and Windows-specific print
sources to the gtk/print subdirectory.
2023-06-07 00:06:33 -04:00
Matthias Clasen
19362522e0 print: Rename private headers
Rename private print-related headers to follow our
naming conventions:
gtkprintutils.h -> gtkprintutilsprivate.h
gtkprinteroption.h -> gtkprinteroptionprivate.h
gtkprinteroptionset.h => gtkprinteroptionsetprivate.h
gtkprinteroptionwidget.h -> gtkprinteroptionwidgetprivate.h
2023-06-06 22:32:18 -04:00