386 Commits

Author SHA1 Message Date
Doug Nazar
75cf21d834 gstreamer: A few small memory cleanups
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/9044>
2025-05-27 10:44:37 +00:00
Thibault Saunier
78a44afc22 gst: Add a gst_structure_is_writable method
There are cases (in the gst-python bindings for example) where
it is interesting to know that the structure is not writable

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/9027>
2025-05-25 15:16:37 +02:00
Sebastian Dröge
60d9ad038c meta: Add g_return_val_if_fail() for NULL valid_tags in gst_meta_api_type_tags_contain_only()
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/9054>
2025-05-25 06:45:27 +00:00
Jordan Petridis
98e8d3a127 gsttracerutils: Fix leak in gst_tracer_utils_create_tracer()
Co-authored-by: Alicia Boya García <aboya@igalia.com>
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/9028>
2025-05-23 12:37:15 +00:00
Thibault Saunier
c796abbf0a gst: info: Add a GstLogContext API
Add a new API to control logging behavior, particularly for implementing
"log once" functionality and periodic logging. This helps avoid spamming
logs with repetitive messages.

The API provides:
- Static and dynamic context creation
- Configurable message identity calculation
- Periodic reset capability
- Context-aware logging macros
- Element message variants with context support

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6855>
2025-05-22 09:53:35 +00:00
Guillaume Desmottes
328b6bc55d core: gstvalue: fix ANY/EMPTY caps (features) hash
They should be special cases as both do not have any actual caps/features.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/9037>
2025-05-21 16:03:15 +00:00
Sebastian Dröge
bd3c267adb meta: Add gst_meta_api_type_tags_contain_only()
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/9004>
2025-05-21 12:13:56 +00:00
Sebastian Dröge
6877ca4d62 pipeline: Store the actual latency even if no static latency was configured
Previously the latency was only stored if a static latency was configured on the
pipeline, which caused gst_pipeline_get_configured_latency() to always return
GST_CLOCK_TIME_NONE in that case.

Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/4429

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8972>
2025-05-17 08:58:58 +00:00
Sebastian Dröge
08c56f3e2d element: ref-sink the correct pad template when replacing an existing one
templ is the new one that is being stored and that needs to be ref-sinked,
padtempl is the old one that just needs to be unreffed.

Fixes leaking the old template, and also makes sure that the new template is not
floating which can cause use-after-frees with bindings as they might wrongly
take ownership of a still floating template.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8988>
2025-05-16 17:47:47 +00:00
Doug Nazar
5867c7900a all: Annotate *_set_property() contructor only props without free
Properties that are marked constructor only aren't required to be freed
before g_value_dup_*() as they can only be called once during construction.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8978>
2025-05-13 19:15:21 -04:00
Xavier Claessens
cff1d1962b gstmessage: Debug error message is nullable
When debug is NULL, gst-launch-1.0 won't print
"Additional debug info:" line.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8943>
2025-05-10 22:13:22 +00:00
Santosh Mahto
700b665bf7 gstanalytics: Add transform function to copy the tensor meta
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8825>
2025-05-10 20:58:52 +00:00
Thibault Saunier
33f58f9da7 gst: debug: Add information about active tracers in dot files
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8820>
2025-04-24 13:06:55 +00:00
Thibault Saunier
476bd6109e macos: Move macos function documentation to the .h so the introspection has the information
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8854>
2025-04-22 19:25:30 +00:00
Thibault Saunier
d1f43f781a tracerutils: Do not warn on empty string as tracername
It doesn't matter if there is an "empty tracer" specified.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8860>
2025-04-17 18:40:05 +00:00
Shengqi Yu (喻盛琪)
b144375974 pluginloader: fix pending_plugins Glist use-after-free issue
When plugin_loader_load_and_sync returns false in plugin_loader_replay_pending,
the cur Glist l->pending_plugins will be added to the blacklist.
However, the l->pending_plugins might have already been loaded and freed in handle_rx_packet,
so causing a use-after-free issue.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8747>
2025-04-16 05:06:40 +00:00
Seungha Yang
7d51dc615d pluginloader-win32: Fix helper executable path under devenv
lpApplicationName argument of CreateProcessW should be complete path
of executable.

Fixing regression introduced by
https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8614

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8746>
2025-04-01 19:04:01 +00:00
Guillaume Desmottes
4e65d16bfc gstvalue: add hashing
Will be used to implement the Hash trait in gstreamer-rs, see
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1639

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8518>
2025-04-01 14:38:01 +02:00
Guillaume Desmottes
bde69a4fab taglist: add _gst_tag_list_structure() as internal API
Will be needed to implement hash on GValue.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8518>
2025-04-01 14:37:26 +02:00
Guillaume Desmottes
76e9e4ceb6 gstvalue: rename internal table to gst_value_hash_table
Will use the gst_value_hash symbol to implement a new method.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8518>
2025-04-01 14:37:26 +02:00
Doug Nazar
86161c084e tracer: Free various props before being set
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8648>
2025-03-27 09:03:18 +00:00
Doug Nazar
5f90a4ae67 all: Annotate *_set_property() contructor only props without free
Properties that are marked constructor only aren't required to be freed
before g_value_dup_string() as they can only be called once during construction.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8648>
2025-03-27 09:03:18 +00:00
David Smitmanis
f8f75503b7 pluginloader-win32: Correctly handle whitespace paths when executing gst-plugin-scanner
On Windows, if the path to gst-plugin-scanner.exe contained
whitespace, gstreamer would via CreateProcessW attempt to execute
several files "up" the path tree; e.g. if the scanner path was
"C:\Program Files\gstreamer app\gst-plugin-scanner.exe", it would try
to execute C:\Program, C:\Program.exe, C:\Program Files\gstreamer.exe"
and so on.

This is how CreateProcessW behaves with unquoted whitespace arguments
in lpCommandLine if lpApplicationName is NULL.

By passing the binary path as lpApplicationName instead, the problem
is avoided.

Also quote arguments to gst-plugin-scanner.exe as they are paths as well.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8614>
2025-03-25 21:58:00 +00:00
Branko Subasic
2f2b19be83 tracer: Make it compile when tracer hooks are disabled
The GST_TRACER_POOL_BUFFER_(DE)QUEUED macros used when tracer hooks are
disabled took only one argument, causing compile errors when building
with tracer hooks disabled.

Change-Id: I0958c0b018f1fc4a6d84ab0bdd9e42895ae1fe77
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8638>
2025-03-14 11:07:03 +00:00
Thibault Saunier
9979936703 tracer: Add a hook to track when buffers are queued/dequeued in pools
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8617>
2025-03-12 14:49:22 +00:00
Thibault Saunier
c3bf39e7a4 tracer: Add memory init/free hooks
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8510>
2025-02-20 12:48:45 +00:00
Guillaume Desmottes
368492ba88 gstvalue: fix leak in gst_value_deserialize_bytes()
The GValue needs to take ownership.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8515>
2025-02-19 19:12:55 +00:00
Guillaume Desmottes
1b04ec5cb2 gstvalue: fix leak in gst_value_deserialize_g_date_time()
gst_date_time_to_g_date_time() does not take ownership.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8515>
2025-02-19 19:12:55 +00:00
Sebastian Dröge
a4a1de05f1 gstreamer: Fix various gobject-introspection warnings
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8501>
2025-02-18 12:02:55 +00:00
Sebastian Dröge
f902f70659 buffer: Mark gst_buffer_extract() size parameter as in-parameter
Otherwise it's considered an out-parameter because of its relationship with
the dest array pointer.

Suggested-by: Sergey Bugaev <bugaevc@gmail.com>
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8494>
2025-02-18 08:16:19 +00:00
Xavier Claessens
f25668a223 gststructure: Fix deserialization of GStrv
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8438>
2025-02-17 08:31:36 +00:00
Xavier Claessens
e06e977304 gstvalue: Add (de)serialize of G_TYPE_STRV
This allows setting strv properties from gst-launch-1.0, such as uris in
uriplaylistbin.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8438>
2025-02-17 08:31:36 +00:00
Thibault Saunier
174460770b gst: Allow tracers to set the GST_DEBUG_DUMP_DOT_DIR
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7999>
2025-02-15 18:01:37 +00:00
Thibault Saunier
4b74819671 core: debugutils: Write dot files atomically
Replace fopen/fputs with g_file_set_contents() to ensure dot files are written
atomically. This prevents tools like gst-dots-viewer from reading partially
written files when watching the dot folder.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7999>
2025-02-15 18:01:36 +00:00
Alicia Boya García
ee97c89c51 gstreamer: parse: Log bus error messages during construction
Suppose you invoke gst-launch with this invalid pipeline:

```
$ gst-launch-1.0  videotestsrc num-buffers=10 ! x264enc name=enc ! mux.sink_0 \
    mpegtsmux name=mux ! fakesink
0:00:00.018631594 351169      0xb523090 ERROR           GST_PIPELINE
subprojects/gstreamer/gst/parse/grammar.y:1151:gst_parse_perform_link:
could not link enc to mux
WARNING: erroneous pipeline: could not link enc to mux
```

The error message you get is not very helpful. This is a pity, because
this is where the error comes from:

```c
static GstPad *
gst_base_ts_mux_request_new_pad (GstElement * element, GstPadTemplate * templ,
    const gchar * name, const GstCaps * caps)
{ // [...]
    GST_ELEMENT_ERROR (element, STREAM, MUX,
        ("Invalid Elementary stream PID (0x%02u < 0x40)", pid), (NULL));
    return NULL;
```

mpegtsmux posted an error with an explanation of why the linking failed.
However, since the error ocurred within gst_parse_launchv(), gst-launch
could not have set a bus handler, and the error message got discarded.

This patch attempts to make gst-launch more user-friendly by setting a
temporary bus handler during early bin construction to catch error
messages like this.

The errors are logged as ERROR level in the GST_PIPELINE category.
However, this is not enough, as GST_LEVEL_DEFAULT defaults to
GST_LEVEL_NONE in releases. In other words, outside of the dev
environment, GStreamer won't print ERROR logs by default.

To make sure the errors can reach users of packaged versions of
GStreamer, a new AtomicRcBox-based struct is added: reason_receiver_t.
graph_t owns a reference to reason_receiver_t and so does the temporary
bus handler.

When the temporary bus handler receives an error message, the `reason`
field of `reason_receiver_t` is filled with the error message.
Later, when SET_ERROR() is called as a consequence of the operation that
posted the error having returned failure, the reason message is
extracted and added to the GError message.

This is how the resulting error would look in the example from above:

    WARNING: erroneous pipeline: could not link enc to mux --
    GstMpegTsMux <mux> posted an error message: Invalid Elementary
    stream PID (0x00 < 0x40)

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8417>
2025-02-15 00:04:46 +00:00
Alexander Slobodeniuk
238ef923aa tracerrecord: fix missing GObject vtable chainups
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8452>
2025-02-11 22:49:06 +01:00
Alexander Slobodeniuk
ac1fb2464a tracer: fix missing GObject vtable chainups
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8452>
2025-02-11 22:49:06 +01:00
Alicia Boya García
cf2dc2f94c gstreamer: parse: Fix log in gst_parse_perform_link
Suppose you're trying to debug why this pipeline doesn't work:

```
$ GST_DEBUG=GST_PIPELINE:DEBUG gst-launch-1.0 \
    videotestsrc num-buffers=10 ! x264enc name=enc ! mux.sink_0  \
    mpegtsmux name=mux ! fakesink
```

You will encounter this line in the logs:

> gst_parse_perform_link: linking some pad of GstX264Enc named enc to
> pad  mux of GstMpegTsMux named mux (0/1) with caps "(NULL)"

It would seem that the element name is being read as a pad name as well,
and that made me wonder if the parsing was not working. However, it was
just a bug in the code printing that log. This patch fixes that bug.

Note that it is possible to specify more than one pad name for each side
of the link. For instance, the following is a valid pipeline that will
remux the video and audio of an MP4 file into MKV:

```
$ GST_DEBUG=GST_PIPELINE:DEBUG gst-launch \
    filesrc location=input.mp4 ! qtdemux name=demux  \
    multiqueue name=mq  \
    matroskamux name=mux ! filesink location=output.mkv  \
    demux.video_0,audio_0 ! mq.sink_0,sink_1  \
    mq.src_0,src_1 ! mux.video_0,audio_0
```

The new logging accomodates this by using a new utility function to join
strings of pad name lists instead of `PRETTY_PAD_NAME_FMT` (which only
supports one pad name). For example:

> linking pads {video_0, audio_0} of GstQTDemux named demux to pads
> {sink_0, sink_1} of GstMultiQueue named mq with caps "(NULL)"

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8415>
2025-02-06 11:20:39 +00:00
Patricia Muscalu
6b547ffc4b tracers: Fix build problem when tracer hooks are disabled
"undefined reference to `GST_TRACER_PAD_SEND_EVENT_PRE'
undefined reference to `GST_TRACER_PAD_SEND_EVENT_POST'"
errors are generated when trying to build GStreamer with
the following build configuration:
meson setup -Dgstreamer:tracer_hooks=false build

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8419>
2025-02-06 10:24:12 +00:00
Corentin Damman
0268ee9c52 pluginloader-win32: create no window
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8387>
2025-02-05 14:18:22 +00:00
Jordan Yelloz
2619a59f82 gstiterator: Added error handling to filtered iterators
Otherwise, if the underlying iterator returns GST_ITERATOR_ERROR, the filtered
iterator will crash.

With this change, the filtered iterator propagates the error back to the caller.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8367>
2025-01-28 06:31:09 +00:00
Alicia Boya García
6d9552295f tracing: add hooks for gst_pad_send_event_unchecked()
Similar to de30de865cd, this allows to follow the flow of events as they
arrive to a pad rather than only when they are pushed to a peer.

The hook is installed in gst_pad_send_event_unchecked() instead of
gst_pad_send_event() because the latter is often omitted: that is the
case especifically in gst_pad_push_event_unchecked(), where most event
propagation occurs.

This patch also makes use of the new hooks in the log tracer to log the
begining and end of the send_event processing.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8330>
2025-01-27 11:08:52 +00:00
Alicia Boya García
a35bf1e384 tracers: signal pad-push-event when pushing sticky events
Previously, the tracer pad-push-event was only signalled on
gst_pad_push_event().  However, the sticky event handling code in
GStreamer uses gst_pad_push_event_unchecked() instead, which meant those
events were not logged.

This patch extends the definition of the pad-push-event tracer to cover
both calls to gst_pad_push_event() and any direct calls to
gst_pad_push_event_unchecked() that skip the former inside GstPad
private code.

gst_pad_push_event_unchecked() returns GstFlowReturn instead of
gboolean like gst_pad_push_event(). To maintain API compatibility, the
GstFlowReturn is converted to gboolean.

Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/4182

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8342>
2025-01-27 08:56:03 +00:00
Rares Branici
345eae97d4 pluginloader-win32: create no window
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8354>
2025-01-23 19:48:28 +00:00
Silvio Lazzeretti
a6eb1de87d gstpluginloader-win32: fix use after free in find_helper_bin_location
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8352>
2025-01-23 19:28:54 +00:00
Nirbheek Chauhan
29098aeba8 gstdevice: Fetch device provider from message source
The GstDevice removed may not have a parent anymore when we check
whether the provider is hidden. Let's fetch the provider from the
message source, which is more reliable.

Fixes a racy nullptr deref on macOS when a device is unplugged:

```
libgstreamer-1.0.0.dylib!is_provider_hidden (gstreamer/subprojects/gstreamer/gst/gstdevicemonitor.c:240)
libgstreamer-1.0.0.dylib!bus_sync_message (gstreamer/subprojects/gstreamer/gst/gstdevicemonitor.c:286)
libgstreamer-1.0.0.dylib!gst_bus_post (gstreamer/subprojects/gstreamer/gst/gstbus.c:358)
libgstreamer-1.0.0.dylib!gst_device_provider_device_remove (gstreamer/subprojects/gstreamer/gst/gstdeviceprovider.c:685)
libgstosxaudio.dylib!gst_osx_audio_device_provider_update_devices ([...]/sys/osxaudio/gstosxaudiodeviceprovider.c:539)
libgstosxaudio.dylib!_audio_devices_changed_cb ([...]/sys/osxaudio/gstosxaudiodeviceprovider.c:313)
CoreAudio!HALObject::PropertiesChanged(unsigned int, AudioObjectPropertyAddress const*) (Unknown Source:0)
CoreAudio!HALSystem::PropertiesChanged(unsigned int, AudioObjectPropertyAddress const*) (Unknown Source:0)
CoreAudio!HALSystem::ObjectsPublishedAndDied(...) (Unknown Source:0)
CoreAudio!HALSystem::AudioObjectsPublishedAndDied(...) (Unknown Source:0)
CoreAudio!HALC_ShellPlugIn::ReconcileDeviceList(bool, bool) (Unknown Source:0)
CoreAudio!HALC_ShellPlugIn::CreateAggregateDevice(__CFDictionary const*, unsigned int&) (Unknown Source:0)
CoreAudio!AudioHardwareCreateAggregateDevice_mac_imp (Unknown Source:0)
AudioDSP!___lldb_unnamed_symbol15046 (Unknown Source:0)
AudioDSP!___lldb_unnamed_symbol15038 (Unknown Source:0)
AudioDSP!___lldb_unnamed_symbol33307 (Unknown Source:0)
AudioToolboxCore!APComponent::newInstance(...) (Unknown Source:0)
AudioToolboxCore!instantiate(...) (Unknown Source:0)
AudioToolboxCore!__AudioComponentInstanceNew_block_invoke (Unknown Source:0)
AudioToolboxCore!Synchronously (Unknown Source:0)
```

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8320>
2025-01-20 15:44:20 +05:30
Mathieu Duponchelle
7983ecff1c docs: generate hotdoc configs for libraries with our helper script
With this patch, configure time is identical no matter whether doc is
enabled or not.

The configuration files also now contain explicitly-listed sources with
no wildcards.

For the four libraries where hotdoc needs to use clang to generate the
documentation (as opposed to the rest of the libraries where hotdoc uses
the gir), the script will call pkg-config to determine the appropriate
C flags.

This means a side effect of this patch is that pkg-config files are now
generated for the gstadaptivedemux and gstopencv libraries.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8312>
2025-01-17 20:36:06 +01:00
Thibault Saunier
e77a16b2e6 gst: utils: Add a multiply_int64 variant
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8262>
2025-01-17 15:13:14 +00:00
Edward Hervey
39a1b61469 gstreamer: Make switch passthrough as such
vasnprintf requires special handling since the following 'case' is #ifdef'ed

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8229>
2025-01-13 12:51:44 +00:00
Ruben Gonzalez
47c29127b6 tracers: Fix issue in the BC layer added in refactor to simplify params handling
Issue added in refactor done in commit 5e18499372, which includes a
logic to not break the backward compatibility. Issue found with Rust
pcap-writer tracer, fixes https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/issues/644

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8248>
2025-01-06 20:29:00 +01:00