Commit graph

8711 commits

Author SHA1 Message Date
Sebastian Dröge b55d6c0b02 systemclock: Don't start the system clock at 0 on Windows
We kept the start time around and subtracted it everywhere for "easy of
debugging", but we don't do anything like this anywhere else and it
only complicates the code unnecessarily.
2020-03-09 15:17:08 +02:00
Sebastian Dröge daf7df28dd systemclock: Don't divide by zero on Windows if high performance timers are not available 2020-03-09 15:16:00 +02:00
Sebastian Dröge 5edc20188a caps: Don't assert in fixate() on EMPTY/ANY caps and document EMPTY/ANY behaviour on more functions
fixate() will return empty caps if it gets empty caps passed and assert
early if any caps are provided as there's no meaningful way of fixating
any caps.

truncate() and simplify() will return the input caps in case of
any/empty caps as before, but slightly optimized and as documented
behaviour.

Also add tests for this and a few other operations behaviour on
empty/any caps.
2020-03-09 10:10:09 +00:00
Tim-Philipp Müller 602b13c6c3 debugutils: skip "parent" property for elements when dumping pipeline graph
Seems unnecessary to print the parent name for every
element in the pipeline graph, it's clear from the
graph what the parent element is and it's hard to
imagine a case where this is useful info rather than
just distracting spam. So far this was only done for
pads, but we should just do it for everything.
2020-02-19 19:01:25 +00:00
Sebastian Dröge 733246f1b4 bus: Make setting/replacing/clearing the sync handler thread-safe
Previously we would use the object lock only for storing the sync
handler and its user_data in a local variable, then unlock it and only
then call the sync handler. Between unlocking and calling the sync
handler it might be unset and the user_data be freed, causing it to be
called with a freed pointer.

To prevent this add a refcounting wrapper struct around the sync
handler, hold the object lock while retrieving it and increasing the
reference count and only actually free it once the reference count
reaches zero.

As a side-effect we can now also allow to actually replace the sync
handler. Previously it was only allowed to clear it after initially
setting it according to the docs, but the code still allowed to clear it
and then set a different one.

Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer/issues/506
2020-02-14 14:41:46 +00:00
Henry Wilkes 412e97beb4 caps: keep ANY caps empty internally
Keep the ANY caps empty internally when appending and merging
caps/structures. Previously, an ANY caps could end up containing
internal structures, which could be fetched by the user, and gave the
caps a non-zero length.

Also, made sure that `gst_caps_set_features_simple` frees the features
if caps is empty.
2020-02-12 14:41:40 +00:00
Henry Wilkes 407e32588d caps: fix is_strictly_equal
Fixed gst_caps_is_strictly_equal() to take into account whether either of
the caps are ANY caps. Previously, two ANY caps could be considered not
strictly equal if one of them still contained some remnant *internal*
structure (this can happen if an ANY caps has emerged from an append or
merge operation). Also, an ANY caps with no remnant internal structures
was considered strictly equal to an EMPTY caps. Similarly, a non-ANY caps
was considered strictly equal to an ANY caps if its remnant internal
structures happened to match.

Also changed gst_caps_is_fixed to take into account that an ANY caps
should not be considered fixed even if it contains a single remnant
internal fixed structure. This affects gst_caps_is_equal(), which uses a
separate method if both caps are fixed. Previously, this meant that a
non-ANY fixed caps was considered equal to an ANY caps if it contained a
single matching remnant internal structure.

Added some tests for these two equality methods, which covers the above
examples, as well as asserts existing behaviour.

Fixes #496
2020-02-12 14:41:40 +00:00
Olivier Crête b4ba9ec089 systemclock: No need to check for CLOCK_TAI in the meson
POSIX defines CLOCK_MONOTONIC to always be a macro, so I think
it's safe to assume that CLOCK_TAI will also be.
2020-01-27 17:16:14 +00:00
Ederson de Souza 216d6dd0f0 GstSystemClock: Add GST_CLOCK_TYPE_TAI
GST_CLOCK_TYPE_TAI is GStreamer abstraction for CLOCK_TAI. Main
motivation for this patch is support for transmission offloading features
- when network packets are timestamped with the time they are deemed to
be actually transmitted. Linux API for that requires that time to be
in CLOCK_TAI coordinate.

With GST_CLOCK_TYPE_TAI, applications can use CLOCK_TAI directly on
their pipelines, avoiding the need to cross timestamp packet times. By
leveraging system's CLOCK_TAI, applications also don't need to keep track
of leap seconds - less burden for them. Just keep system's CLOCK_TAI
accurate and use it.
2020-01-27 17:16:14 +00:00
Sebastian Dröge 47765e164b bin: Don't consider having a group-id or being STREAM_START if we have not a single STREAM_START message
This would cause us to set GST_GROUP_ID_INVALID as group-id in the
aggregated STREAM_START message if there are no sinks at all or none of
them have a STREAM_START message, which is simply wrong.

If we have not a single STREAM_START message then the bin should not be
considered STREAM_START.
2020-01-25 00:02:20 +02:00
Sebastian Dröge 1b2f968efc event/message: Don't allow setting invalid group ids
They are optional on STREAM_START messages/events but if available
should have at least a valid value.

For STREAM_GROUP_DONE events don't allow creating it with an invalid
group id as this does not make any sense.
2020-01-24 17:53:30 +02:00
Jan Alexander Steffens (heftig) f018b4eddc
bin: Fix deep-element-removed log message
child and bin were switched.

https://gitlab.freedesktop.org/gstreamer/gstreamer/merge_requests/354
2020-01-09 20:08:38 +01:00
Thibault Saunier 20301a8820 docs: Document the new 'redirect-location' error message detail field 2020-01-06 17:47:40 -03:00
Stefan Sauer 19b28788cf parse: add support for presets
Add new parse syntax: @preset="<preset-name>" to load presets.
Fixes #86
2019-12-28 04:02:16 +00:00
Seungha Yang 52706146f5 pluginfeature: Allow updating initial rank of plugin feature
Introducing "GST_PLUGIN_FEATURE_RANK" environment variable in order for users
to adjust rank of plugin(s) via environment.

A "feature" and "rank" key-value pair should be separable by ":",
and each key-value pair is recognized per "," delimiters. The rank
can be a numerical value or one of pre-defined rank values
such as "NONE", "MARGINAL", "SECONDARY", and "PRIMARY" in case-insensitive manner.

In addition to pre-defined { NONE, MARGINAL, SECONDARY, PRIMARY },
"MAX" can be passed to key value used to ensure having a higher rank
than other plugin features.

Example)
- GST_PLUGIN_FEATURE_RANK=qtdemux:256,h264parse:NONE
Set rank of qtdemux plugin to 256 (primary) and 0 (none) for h264parse.
2019-12-26 19:49:00 +00:00
Nirbheek Chauhan 72daeee2c4 gstinfo: Add new API for getting debug log lines
If you're using a custom log handler, you had to reverse-engineer the
debug log format and create your own format function. Now, you can
call `gst_debug_log_get_line()` and it will return a string (without
ANSI escape color codes) representation instead.

This is useful in situations when you need to log the ordinary
gst_debug log to a resource that can't be opened as a `FILE` handle.

Also includes a test.
2019-12-25 08:50:17 +05:30
Niels De Graef 0cb3940c94 bin: Add method to find elements by factory name
A common use case of a dynamically built pipeline is that you want to
(conditionally) find a certain element, e.g. the `rtpbin`s in a
`uridecodebin`. If that element has a fixed name inside its parent bin
(and only has a single instance) this can be easily done by
`gst_bin_get_by_name()`.

If there are multiple instances of the element however, you can only use
`gst_bin_iterate_all_by_interface()`, but this doesn't work if you don't
have the specific `GType` (which is often the case, due to plugins being
dynamically loaded). As such, another fallback could be to use the
well-known name of the element's factory (in case of our example, this
is of course `"rtpbin"`).
2019-12-20 14:29:19 +01:00
Stéphane Cerveau 1d549ea324 gstreamer: use of g_value_dup_string
Use helper method to get string from GValue.
2019-12-18 15:57:54 +01:00
Peter Seiderer 4a827e11b4 pluginloader: handle fsync interrupted by signal (EINTR)
According to [1] EINTR is a possible errno for fsync(),
so handle it as all other EINTR (do/while(errno == EINTR)).

Signed-off-by: Peter Seiderer <ps.report@gmx.net>
2019-12-12 20:49:36 +01:00
Peter Seiderer 96aa27910a registry: handle fsync interrupted by signal (EINTR)
According to [1] EINTR is a possible errno for fsync(),
so handle it as all other EINTR (do/while(errno == EINTR)).

Signed-off-by: Peter Seiderer <ps.report@gmx.net>
2019-12-12 20:49:36 +01:00
Olivier Crête 0a8d14acc9 Remove deprecated GTimeVal
GTimeVal won't work past 2038
2019-12-10 19:18:32 -05:00
Mathieu Duponchelle e79def14a5 device, elementfactory: relax floating requirement
Using g_assert() is a bit too extreme, as it will abort the whole
program unless G_DISABLE_ASSERTS is true.

Switch to g_critical()
2019-12-10 13:31:50 +01:00
Sebastian Dröge 020eb2c346 bus: Clean up #ifdefs to compile with debugging enabled in all combinations
Thanks to Roland Jon for finding this.
2019-12-05 08:21:54 +00:00
Mathieu Duponchelle a90220cce1 device, elementfactory: don't enforce floating status
The reference we receive when calling g_object_new should be
floating, but we can't force it at our level.

Switch from g_object_force_floating() to a simple assertion.

See https://gitlab.freedesktop.org/gstreamer/gst-python/issues/27
2019-12-05 01:44:35 +00:00
Sebastian Dröge 7af50da2c9 bus: Use new GSource dispose function
Without this it is possible that we have a GSource with reference count
0 stored in the GstBus that is currently in the process of being
destroyed. gst_bus_remove_watch() might then access it, increase its
reference count to 1 again, call GSource API on it and then unref it,
which will then finalize it a second time.

The dispose function allows the GSource to be resurrected until it
returned so the above would be safe now.

This caused some spurious crashes during shutdown in various
applications.
2019-12-04 08:24:04 +00:00
Edward Hervey 3b71c4a4e7 GstBuffer: size-related optimization
Avoid calling generic function when it's possible to directly
return/get sizes
2019-11-27 14:25:19 +00:00
Edward Hervey e3d2eb1f16 GstBuffer: Inline fast-path for merged memory 2019-11-27 14:25:19 +00:00
Tim-Philipp Müller 6c2dfe5ebe docs: mention gst_parse_bin_from_description() in gst_parse_launch() docs 2019-11-27 09:41:36 +00:00
Linus Svensson 47c50b086e datetime: Add constructor for timestamps in microseconds 2019-11-25 13:31:11 +01:00
Stéphane Cerveau 8a20d66b10 gstbuffer: update documentation
remove unclear documentation about GST_BUFFER_FLAG_MARKER
2019-11-18 00:15:31 +00:00
Havard Graff 7b38def8e0 structure: add gst_structure_take
(╯°□°)╯︵ ┻━┻
2019-11-14 10:08:38 +00:00
Wonchul Lee 5c6314d68b event: Fix gir warning
It fixes below gir warnings.
../subprojects/gstreamer/gst/gstevent.c:2246: Warning: Gst:
gst_event_new_instant_rate_sync_time: unknown parameter
'rate_multiplier' in documentation comment, should be 'rate'
../subprojects/gstreamer/gst/gstevent.c:2296: Warning: Gst:
gst_event_parse_instant_rate_sync_time: unknown parameter
'rate_multiplier' in documentation comment, should be 'rate'
2019-11-12 15:19:28 +09:00
Víctor Manuel Jáquez Leal 78041a7748 gst/parse: define pure-parser depending on bison version
After release bison 2.5 the declaration %pure-parser was deprecated
in favor of %define api.pure

Nonetheless, until bison 3.4, the declaration was treated as backward
compatibility, but now bison shows a warning:

  warning: deprecated directive, use ‘%define api.pure’

The patch's approach is to handle both directives according with the
used bison's version, by string replacement at source configuration
stage.
2019-11-05 12:55:08 +01:00
Nayana Topolsky e8c782d119 pad: clear sticky event tag upon stream-start
When playing gapless there were situations when some sticky events
like tags were stuck at some pad and then revived much later.
Therefore it is better to clear them upon stream-start.

Fixes #360
2019-11-04 12:01:47 +00:00
Seungha Yang d8b8a13285 taglist: Fix broken empty set character in code
Previous one was not a valid ASCII empty set character.
'tig' and 'git log -p' couldn't represent it as expected.
2019-11-03 19:06:58 +00:00
Jan Schmidt acf66273f5 pipeline: Instant rate change handling
Implement aggregation of INSTANT_RATE_REQUEST messages and sending of
INSTANT_RATE_SYNC_TIME events.
2019-11-03 19:47:40 +11:00
Sebastian Dröge 74412496cf event/message: Add new instant-rate-sync-time event and instant-rate-request message 2019-11-03 19:47:40 +11:00
Sebastian Dröge be3c4d00cf event: Add new GST_EVENT_INSTANT_RATE_CHANGE and GST_SEEK_FLAGS_INSTANT_RATE_CHANGE
A seek with that flag set must be non-flushing, not change the playback
direction and start/stop position. A seek handler will then send the new
GST_EVENT_INSTANT_RATE_CHANGE event downstream for downstream elements
to immediately apply the new playback rate before the new in-band segment
event arrives.
2019-11-03 19:47:40 +11:00
Víctor Manuel Jáquez Leal 9707db909d elementfactory: add GST_ELEMENT_FACTORY_TYPE_HARDWARE
This new symbol matches with the elements within "Hardware" class.
2019-11-02 15:11:12 +01:00
Sebastian Dröge 487a3f9a30 bin: Drop need-context messages without source instead of crashing 2019-10-22 09:46:19 +03:00
Tim-Philipp Müller 10d9e18f02 Remove autotools build system 2019-10-13 16:10:42 +01:00
Edward Hervey 6babf1f086 core: Avoid usage of deprecated API
GTimeval and related functions are now deprecated in glib.
Replacement APIs have been present since 2.26
2019-10-10 15:53:16 +02:00
Aaron Boxer 509f6201e1 documentation: fix a number of typos 2019-10-06 11:12:11 -04:00
Sebastian Dröge 9fb84ea7f4 gst: Don't pass miniobjects to GST_DEBUG_OBJECT() and similar macros
The argument must be at least a GObject according to the GstLogFunction
definition, and while the default C log function handles miniobjects
just fine this is crashing bindings and user-supplied log functions that
(rightfully) don't expect anything but GObjects.
2019-09-30 11:52:03 +03:00
Mathieu Duponchelle 0dafe6e639 gstvalue: use value_nick for serialization
not value_name . This was causing incorrect launch lines to be
displayed by gst-device-monitor, and the deserialization code
below works with nicks.
2019-09-17 01:09:05 +00:00
Mathieu Duponchelle a9e2776074 deviceprovider: set the bus to non-flushing before calling klass->start
Not posting DEVICE_ADDED messages while a device provider is being
started makes things awkward for applications, as they have to call
get_devices() after starting the monitor.

This requires redundant code on the application side, and as far as
I understand also could cause race conditions, when a device gets
added between the calls to gst_device_monitor_start() and
gst_device_monitor_get_devices(), causing the application to "see"
the same device twice.
2019-09-16 23:56:44 +00:00
Sebastian Dröge 9cf764b2ec element: Enforce that elements created by gst_element_factory_create/make() are floating
Bindings might have a hard time making sure that the reference is indeed
still floating after returning here.

See https://gitlab.freedesktop.org/gstreamer/gstreamer/issues/444
2019-09-12 09:50:17 +00:00
Sebastian Dröge 341ee45155 device: Enforce that elements created by gst_device_create_element() are floating
Bindings might have a hard time making sure that the reference is indeed
still floating after returning here.

See https://gitlab.freedesktop.org/gstreamer/gstreamer/issues/444
2019-09-12 09:50:17 +00:00
Sebastian Dröge 1edcf747ee device: gst_device_create_element() is transfer floating, not transfer full
Fixing the annotation fixes leaking of the created element in all
bindings using GObject-Introspection.

Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer/issues/444
2019-09-12 09:50:17 +00:00
Niels De Graef 4812c4087f Don't pass default GLib marshallers for signals
By passing NULL to `g_signal_new` instead of a marshaller, GLib will
actually internally optimize the signal (if the marshaller is available
in GLib itself) by also setting the valist marshaller. This makes the
signal emission a bit more performant than the regular marshalling,
which still needs to box into `GValue` and call libffi in case of a
generic marshaller.

Note that for custom marshallers, one would use
`g_signal_set_va_marshaller()` with the valist marshaller instead.
2019-09-09 12:16:24 +00:00
Vivia Nikolaidou 7774aae713 pad: Added gst_pad_get_single_internal_link
gst_pad_iterate_internal_links is usually used to find a single internal
link that a pad has, e.g. to find the corresponding pad of a multiqueue.
Added a helper function that will return either a single internal link,
if there's no other, or NULL.
2019-09-05 11:49:18 +03:00
David Svensson Fors f8d70b475c miniobject: free qdata array when the last qdata is removed
In cases with many long-lived buffers that have qdata only very
briefly, the memory overhead of keeping an array of 16 GstQData
structs for each buffer can be significant. We free the array when
the last qdata is removed, like it was done in 1.14.

Fixes #436
2019-09-04 16:31:53 +02:00
Nicolas Dufresne 80a76a4b4d bin: Fix minor race when adding to a bin
This patch simply add a null check around a case where a child may have
been unparented concurrently to the deep_add_remove operation. This was
found by accident in the form of an "IS_GST_OBJECT" assertion, but had
no other known side effect in that test.
2019-09-03 15:42:17 -04:00
Niels De Graef 9e69c90869 object: Use g_object_notify_by_pspec()
`g_object_notify()` actually takes a global lock to look up the
`GParamSpec` that corresponds to the given property name. It's not a
huge performance hit, but it's easily avoidable by using the
`_by_pspec()` variant.
2019-08-25 21:32:44 +02:00
Seungha Yang e6c43380bb info: Take lock around all prinf on Windows
On Windows, concurrent colored gstreamr debug output and usual
stdout/stderr string will cause broken output on terminal.
Since it's OS specific behavior, that's hard to completely avoid it
but we can protect it at least among our printing interfaces side.
2019-08-24 12:15:56 +00:00
Mathieu Duponchelle 7e87a05e5a docstrings: port ulinks to markdown links 2019-08-23 18:17:41 +02:00
Johan Sternerup a4d5c95638 utils: Avoid memory merge in gst_util_dump_buffer()
For buffers with multiple memory chunks, gst_buffer_map() has the side
effect of merging the memory chunks into one contiguous
chunk. Since gst_util_dump_mem() used gst_buffer_map() the internals
of the buffer could actually change as a result of printing it.

For the case of a buffer containing several memory chunks,
gst_memory_map() is now used to obtain the memory address and each
memory chunk is dumped separately preceded by a header line. The
behaviour for a buffer containing a single memory chunk is left unchanged.
2019-08-21 08:37:50 +02:00
Jan Alexander Steffens (heftig) 1d5a1e8235 element: Added gst_element_get_current_clock_time and gst_element_get_current_running_time
Helper functions for getting the element clock's time, and the clock
time minus base time, respectively.
2019-08-12 12:59:27 +03:00
Sebastian Dröge 533fbf766e registry: Use plugin directory from the build system for relocateable Windows builds
Instead of guessing something based on preprocessor defines and magic.
2019-08-09 07:22:38 +00:00
Thibault Saunier d6c14e70a1 device-monitor: list hidden providers before listing devices
The way it was implemented could make the list updated after the
list of device was filled with supposdely hidden devices
2019-08-07 15:20:39 -04:00
Tim-Philipp Müller 8841c3a22f message: fix up enum value for GST_MESSAGE_DEVICE_CHANGED
This was added in 1.16 and accidentally duplicated the value of
the existing GST_MESSAGE_REDIRECT.

As the only known user of this message is GStreamer core itself,
and it is quite an obscure message, it seems best to just fix up
the enum value even if that technically breaks API.

Fixes #418
2019-08-06 08:02:09 +00:00
Doug Nazar 7b596ba6c6 info: Fix deadlock in gst_ring_buffer_logger_log
gst_ring_buffer_logger_log calls several functions while formatting
the message which may in turn log a message while we already hold
the mutex. Do all formatting first before acquiring the mutex to
avoid this and reduce the time we hold the mutex.
2019-08-05 15:24:03 +00:00
Sebastian Dröge 55e79c3772 info: Free some more memory on gst_deinit() 2019-07-15 11:35:07 +03:00
Sebastian Dröge 04a7334140 info: Deprecate gst_debug_category_free()
And change it to do nothing at all.

As debug categories don't use reference counting and they can be
retrieved from anywhere at any time by name, it is fundamentally unsafe
to free them at any point in time except for right before the end of the
process.

No code apart from a unit test seems to be currently using the function,
so deprecate it and also change it to do nothing at all.
2019-07-15 11:35:07 +03:00
Jan Schmidt 318a6169f7 gsttracerutils: Fix build with disabled tracer hooks.
Add a stub gst_tracing_get_active_tracers() call when building
with tracer hooks disabled.
2019-07-07 20:42:56 +10:00
Nirbheek Chauhan e5a3f12ff2 gstinfo: Fix typo in debug log message 2019-07-02 15:13:26 +05:30
Nirbheek Chauhan 1685f38bb2 gsttracer: Add new API to fetch the list of active tracers
This will be useful in the next commit where we add action-signals on
the leaks tracer to get information about leaks and to manipulate
checkpoints as a replacement for the SIGUSR1 and SIGUSR2 signals for
doing the same.
2019-07-02 15:13:26 +05:30
Nicolas Dufresne 8a9b20a18b bufferpool: Fix the buffer size reset code
The offset in gst_buffer_resize() is additive. So to move back the
offset to zero, we need to pass the opposite of the current offset. This
was raised through the related unit test failingon 32bit as on 64bit
the alignment padding was enough to hide the issue. The test was
modified to also fail on 64bit. This patch will remove spurious
assertions like:

  assertion 'bufmax >= bufoffs + offset + size' failed

Fixes #316
2019-07-01 16:49:04 -04:00
Nirbheek Chauhan aae5f58dd1 tracerrecord: Be stricter while parsing record templates
It's not really possible for us to recover when someone uses the
gst_tracer_record_new() API incorrectly. Also, document a piece of
somewhat-obscure code.
2019-07-01 13:33:13 +00:00
Nirbheek Chauhan f336fdd088 gstsystemclock: Mark the clock as MAY_BE_LEAKED
It is freed in gst_deinit(), but otherwise it is leaked.
2019-07-01 11:51:46 +00:00
Nirbheek Chauhan 4ba6898f24 gstinfo: Rework stack trace detection a bit
Ensure that the code paths for HAVE_UNWIND and HAVE_DBGHELP are never
taken at the same time, even if the build file code changes.

Prefer DbgHelp over libunwind on Windows in case both are somehow
available because DbgHelp is only available when building with the
MSVC toolchain, and libunwind won't give us debug symbols from objects
built with the MSVC toolchain.

Also, print slightly more useful messages for the level of stack trace
support enabled, and document what each if conditional does.
2019-07-01 10:36:09 +00:00
Nirbheek Chauhan 145f8546c4 gstinfo: Add an explicit enum for GST_STACK_TRACE_SHOW_NONE
The code implicitly uses this value when the stack trace is not FULL.
Mostly useful for documenting the behaviour when each flag is passed
and for translating to/from strings.
2019-07-01 10:36:09 +00:00
Nirbheek Chauhan 5f89225bc2 gstplugin: Don't stat plugins when building for UWP
When using GStreamer with Universal Windows Platform apps, dynamic
plugins can only be loaded by filename (without a path) using
gst_plugin_load_file() which will call into g_module_open().

On Windows, GModule calls LoadLibrary() on the filename, but with
UWP we need to use LoadPackagedLibrary() which is basically the same
as LoadLibrary(), except it looks only for DLLs (by name) that have
been packaged as assets with the app.

These assets are not files and cannot be accessed using normal file
APIs such as open() or stat().

The upstream glib merge request for adding LoadPackagedLibrary support
is: https://gitlab.gnome.org/GNOME/glib/merge_requests/951

NOTE: Whitespcae removal is to make gst-indent happy
2019-06-28 13:44:49 +05:30
Nirbheek Chauhan 9b7eaa3ed5 gstconfig.h.in: Windows ARM64 does not allow unaligned access 2019-06-28 13:01:14 +05:30
Mathieu Duponchelle c34fe82b5b devicemonitor: add debug category 2019-06-21 13:38:58 +00:00
Michael Bunk 4bc68bb3fe Fixing various typos 2019-06-20 15:20:27 +00:00
Havard Graff 0257c7813b gstmeta: Optimize get_tags() by using private quark table 2019-06-17 09:50:32 +02:00
Havard Graff ce7e6a9406 pad: increase debug-level to warning for fatal outcomes 2019-06-13 16:30:14 +00:00
Niels De Graef 09141c6e1f Use G_DEFINE_AUTOPTR_CLEANUP_FUNC unconditionally
Since we started depending on GLib 2.44, we can be sure this macro is
defined (it will be a no-op on compilers that don't support it). For
plugins we should just start using `G_DECLARE_FINAL_TYPE` which means
we no longer need the macro there, but for most types in core we don't
want to break ABI, which means it's better to just keep it like it is
(and use the `#ifdef` instead).
2019-06-04 08:50:59 +02:00
Mathieu Duponchelle bcb4be455e gstelement: fix links to the gsterror page 2019-05-31 01:56:08 +02:00
Mathieu Duponchelle cce397cc50 gsttaglist: do not link to symbols from gst-plugins-base in doc 2019-05-31 01:45:41 +02:00
Mathieu Duponchelle ca17a6c791 doc: remove xml from comments 2019-05-29 21:33:42 +02:00
Thibault Saunier e31f06f7f9 registry: Avoid discovering plugins in hotdoc private directories 2019-05-16 18:22:20 +00:00
Edward Hervey 7aee718394 gstpad: Probes that return HANDLED can reset the data info field
Before GST_PAD_PROBE_HANDLED was introduced, we had to handle the case
where some probes would reset the probe info data field to NULL. This would
be considered an invalid use-case.

But with GST_PAD_PROBE_HANDLED it is totally fine to reset that, since
the probe has "handled" it.
2019-05-16 15:13:48 +02:00
Thibault Saunier 949fba4b1f doc: Fix hotdoc warnings
* Making sure that `static inline` function are in the GIR (by first
  defining them, and make sure to mark as skiped)
* Do not try to link to unexisting symbols
* Also generate GIR information about gst_tracers
2019-05-13 16:34:09 -04:00
Thibault Saunier a0c65067e0 Port to hotdoc 2019-05-13 16:34:09 -04:00
Thibault Saunier 3d5dbfb457 gst: Add a GParamSpecFlag to force gst-inspect to use pspec default value
Instead of the object value, this should be used every time a random
value will be returned by g_object_get This is also useful to make the
values returned by inspecting element stable accross runs.
2019-05-13 11:33:49 -04:00
Thibault Saunier 4e29b4aa34 doc: Add some missing docstrings 2019-05-13 11:33:49 -04:00
Thibault Saunier 5b2da0835e doc: Fix and add some missing docstrings 2019-05-13 11:33:49 -04:00
Thibault Saunier 4d259e8af3 structure: Mark _from_string as constructor 2019-05-13 11:33:49 -04:00
Nirbheek Chauhan ebd918c0f6 meson: Pass -DGST_STATIC_COMPILATION for static builds
This is only needed on Windows when building with MSVC, but it is safe
to pass it everywhere.

Closes https://gitlab.freedesktop.org/gstreamer/gstreamer/issues/398
2019-05-13 14:42:28 +05:30
Nirbheek Chauhan b19de413b9 meson: Link to objects instea of static helper library
Otherwise the objects from that static helper library are not included
in the gstreamer-1.0 static library. This was supposed to be fixed in
Meson, but the pull request hasn't been merged yet:
https://github.com/mesonbuild/meson/pull/3939

Closes https://gitlab.freedesktop.org/gstreamer/gstreamer/issues/398
2019-05-13 13:24:42 +05:30
Niels De Graef 8d180557eb uri: Add gst_clear_uri()
Basically, you can use this instead of using `gst_uri_unref()` (which
needs to be preceded by a NULL-check).

See https://gitlab.freedesktop.org/gstreamer/gstreamer/issues/275
and https://gitlab.freedesktop.org/gstreamer/gstreamer/merge_requests/3
2019-05-10 14:59:23 +02:00
Niels De Graef cfca53ce67 gst: Add support for g_autoptr(GstPromise) 2019-05-08 12:11:50 +02:00
Niklas Hambüchen f5ccb2215a Make get_flex_version.py script executable
Like all other scripts in the same dir.

It has a hashbang, so it should be executable.
2019-05-01 15:46:56 +02:00
Mathieu Duponchelle 21a02e7672 gstsegment: Add GST_SEEK_FLAG_TRICKMODE_FORWARD_PREDICTED
This is generally useful, and mandated by the ONVIF streaming
spec, section 6.5.3

<https://www.onvif.org/specs/stream/ONVIF-Streaming-Spec.pdf>
2019-04-24 15:30:22 +00:00
Sebastian Dröge a42aaf87d5 gst: Fix various Since markers 2019-04-23 15:08:18 +03:00
Sebastian Dröge 26aa7a6d36 caps: Add Since: 1.16 marker to gst_caps_copy() 2019-04-23 14:53:11 +03:00
Mathieu Duponchelle dc5a62f702 gstinfo: clean up function pointer names hashtable
And add strduped function pointer names to the global quark
table, so that they don't get reported as lost by valgrind.

This allows us to use GST_DEBUG when running tests under
valgrind.
2019-04-17 23:03:56 +02:00
Philipp Zabel b99bca2790 event: fix seek event creation
Creating seek events segfaults on 32-bit ARM since commit 2fa15d5371
('event: add new seek parameter, "trickmode-interval"'), which missed
casting the trickmode-interval initializer in the variable argument list
to guint64.
2019-04-12 18:30:12 +02:00
Sebastian Dröge e0c9d4f879 controlbinding: Check if the weak pointer was cleared before explicitly removing it
Otherwise we'll get an assertion if the object behind the weak pointer
was already destroyed in the meantime as we would pass NULL as first
argument to g_object_remove_weak_pointer().
2019-04-10 10:18:54 +03:00
Mathieu Duponchelle 2fa15d5371 event: add new seek parameter, "trickmode-interval"
When performing a key unit trickmode seek, it may be useful to
specify a minimum interval between the output frames, either
in very high rate cases, or as a protection against streams
that may contain an overly large amount of key frames.

One use case is ONVIF Section 6.5.3:

<https://www.onvif.org/specs/stream/ONVIF-Streaming-Spec.pdf>
2019-04-01 17:13:32 +00:00
Stephane Cerveau a01c4965de gst_element_get_factory: update documentation
Inform about a potential NULL result.
2019-03-14 13:12:52 +01:00
Stephane Cerveau b5af526c9c gst_element_factory_get_metadata: protect from null factory 2019-03-13 18:46:14 +01:00
Santiago Carot-Nemesio 706e10ad05 gsttaskpool: Do not block tasks while cleaning up the taskpool
There is a deadlock if any thread from the pool tries to push
a new task while other thread is waiting for the pool of threads
to finish. With this patch the thread will get an error when it
tries to add a new task while the taskpool is being cleaned up.
2019-03-08 17:27:30 +01:00
Marco Trevisan (Treviño) b5286f0560 gsturi: Fix annotation on get_path to return a nullable
Use proper syntax or the (nullable): part will be part of the description
2019-03-06 19:46:46 +01:00
Marco Trevisan (Treviño) 951dc50d34 gstmessage: Fix annotations on details
Details argument should be nullable, but the docstring uses a wrong syntax.
2019-03-06 19:34:12 +01:00
Mathieu Duponchelle 5dc149f4f2 gstbuffer: store meta in add order
The previous implementation of add was implemented as a prepend,
switch to append as that seems like the expected order.
2019-03-04 12:57:02 +00:00
Santiago Carot-Nemesio e322250fb1 taskpool: Set error in case something goes wrong in the default handlers 2019-02-28 17:02:30 +01:00
Tim-Philipp Müller 8d3ca40e9d meson: dist get_flex_version.py 2019-02-26 13:24:28 +00:00
Philipp Zabel b611c4e0af plugin: add 0BSD as valid license
Add the zero-clause BSD license, which is an alteration of the ISC
license, to the list of valid licenses.
2019-02-25 14:58:22 +01:00
Philipp Zabel bef07f73a2 plugin: fix link to 3-clause BSD license
The current link points to the 2-clause BSD license,
explicitly link to the 3-clause version of the license.
2019-02-25 14:51:18 +01:00
Nirbheek Chauhan a1447b036c gstmacros.h: Fix restrict definition on MSVC
Turns out it's exposed as `__restrict`, not as `restrict`.

https://gitlab.freedesktop.org/gstreamer/gstreamer/merge_requests/95#note_120782
2019-02-20 17:51:40 +05:30
Nirbheek Chauhan ea4b086142 gstmacros.h: Fix check for 'restrict' keyword
MSVC also defines it as a keyword. Fixes build errors in projects that
include MSVC's xkeycheck.h which ensures that keywords aren't overriden
with a define.
2019-02-20 01:25:11 +05:30
Seungha Yang 790f193d63 buffer: Don't miss return value on Windows build
... and use InterlockedExchangeAdd64 for the 64bit value.
InterlockedExchangeAdd is 32bit version.
2019-02-18 10:21:18 +09:00
Sebastian Dröge 2108c6228a bus: Make removing of signal/bus watches thread-safe
Between getting the GSource with the mutex and destroying it, something
else might've destroyed it already and we would have a dangling pointer.

Keep an additional reference just in case.
2019-02-15 13:23:37 +02:00
Sebastian Dröge 8de3344ecc bus: Don't allow removing signal watches with gst_bus_remove_watch()
Signal watches are reference counted and gst_bus_remove_watch() would
immediately remove it, breaking the reference counting. Only
gst_bus_remove_signal_watch() should be used for removing signal
watches.
2019-02-15 13:21:35 +02:00
Lawrence Troup 2276336621 pad: Document that pad unlink function is called with pad lock held
Fixes #353
2019-02-13 11:56:15 +00:00
Tim-Philipp Müller f62ee97592 buffer: store sequence number for metas
For metas where order might be significant if multiple metas are
attached to the same buffer, so store a sequence number with the
meta when adding it to the buffer. This allows users of the meta
to make sure metas are processed in the right order.

We need a 64-bit integer for the sequence number here in the API,
a 32-bit one might overflow too easily with high packet/buffer
rates. We could do it rtp-seqnum style of course, but that's a
bit of a pain.

We could also make it so that gst_buffer_add_meta() just keeps metas in
order or rely on the order we add the metas in, but that seems too
fragile overall, when buffers (incl. metas) get merged or split.

Also add a compare function for easier sorting.

We store the seqnum in the MetaItem struct here and not in the
GstMeta struct since there's no padding in the GstMeta struct.
We could add a private struct to GstMeta before the start of
GstMeta, but that's what MetaItem effectively is implementation-
wise. We can still change this later if we want, since it's all
private.

Fixes #262
2019-02-12 17:53:08 +00:00
Sebastian Dröge 335826a3eb deviceprovider: It's (transfer none) not (transfer-none) 2019-02-09 11:35:59 +02:00
Thibault Saunier 97aa82387f device-provider: Allow notifying application of device changes
Thi introduces new APIs to post a `DEVICE_CHANGED` message on the
bus so the application is notifies when a device is modified. For
example, if the "defaultness" of a device was changed or any property
that can be changed at any time. Atomically changing the device
object notifying that way allow us to abtract away the internal threads.

New APIS:
  - gst_message_new_device_changed
  - gst_message_parse_device_changed
  - gst_device_provider_device_changed
2019-02-08 13:44:02 -03:00
Nirbheek Chauhan c164b88ac1 meson: Extract flex version using a regex inside a script
Different builds of Flex on different platforms output different strings
in --version. For example:

macOS:
flex 2.5.35 Apple(flex-31)

Windows:
win_flex.exe 2.6.4
C:\Program Files (x86)\GnuWin32\bin\flex.EXE version 2.5.4

We need to look for a string that looks like a version, which means
a regex till https://github.com/mesonbuild/meson/issues/1609 is fixed.

Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer/issues/356
2019-02-08 16:54:10 +05:30
Sebastian Dröge d3a2ed10fe datetime: new() and new_local_time() constructors are not nullable 2019-01-29 14:49:28 +00:00
Sebastian Dröge f6816d5412 pad: Constructors are all not nullable
They can't possibly return NULL except in case of assertions.
2019-01-29 14:49:28 +00:00
Sebastian Dröge 92b38d2a00 padtemplate: Constructors are all nullable as they check the template name 2019-01-29 14:49:28 +00:00
Mathieu Duponchelle 57cefb5932 gstinfo: add Windows stacktraces support
This uses the DbgHelp library if available
2019-01-28 14:29:23 +00:00
Nicolas Dufresne c816ec4f0e pad: Remove unneeded 64bit upcast in debug trace
The hook->hook_id is a gulong for which there are no portability issues
when tracing in printf format with %lu. So use %lu and remove the upcast
to 64 bit. This makes the code more consistent with everything else
tracing that hook_id and other gulong id.
2019-01-26 01:42:22 +00:00
Sebastian Dröge 5688773b91 taglist: Remove (scope call) annotation from gst_tag_register()
This was added in 7fdb15d6a2 but it is wrong. (scope call) is for
closures that only have to stay valid for the scope of the call, but the
tag merge function has to stay valid for the whole lifetime of the
application instead.

There's no appropriate scope annotation for that so we have to skip
these functions for now.
2019-01-24 07:52:34 +00:00
Mathieu Duponchelle 59c31d8d0f meson: improve flex version parsing
the output of flex --version can contain more than one space
2019-01-23 21:15:09 +01:00
Sebastian Dröge a143d9cb0c pad: Fix printf format when printing hook id
It's a gulong so we have to cast it to a guint64 when using it with
G_GUINT64_FORMAT.

Spotted by Vincent Penvern.
2019-01-15 16:07:04 +00:00
Daniel Drake e0c9b04538 deviceprovider: fix counting number of times started
GstDeviceProvider has a started_count private variable counter,
and the gst_device_provider_start() documentation emphasizes the
importance of balancing the start and stop calls.

However, when starting a provider that is already started, the
current code will never increment the counter more than once.

So you start it twice, but it will have start_count 1, which is the
maximum value it will ever see.

Then when you stop it twice, on the 2nd stop, after decrementing the
counter in gst_device_provider_stop():

  else if (provider->priv->started_count < 1) {
    g_critical
        ("Trying to stop a GstDeviceProvider %s which is already stopped",
        GST_OBJECT_NAME (provider));

and the program is killed.

Fix this by incrementing the counter when starting a device provider that
was already started.
2019-01-14 16:26:44 +08:00
Sebastian Dröge 37edc474e3 Revert "bin: Hold the state lock while removing elements from a bin"
This reverts commit 7f70d7a945
2019-01-10 12:05:34 +00:00
Jan Alexander Steffens (heftig) c5eddea72a structure: Support stepped ranges when fixating
The step restriction was completely ignored until now.
2019-01-09 23:03:08 +00:00
Jan Alexander Steffens (heftig) b77f7b6820 structure: Use GLib's CLAMP macro for fixating ranges
Just a bit of refactoring.
2019-01-09 23:03:08 +00:00
Sebastian Dröge cacc834d8f element: Add note about racyness to gst_element_set_locked_state()
This is racy if the state lock of the parent bin is not taken. The
parent bin might've just checked the flag in another thread and as the
next step proceed to change the child element's state.
2019-01-09 16:12:26 +02:00
Sebastian Dröge 7f70d7a945 bin: Hold the state lock while removing elements from a bin
We need to take the state lock here to ensure that we're
not currently just before setting the state of this child
element. Otherwise it can happen that we removed the element
here and e.g. set it to NULL state, and shortly afterwards
have another thread set it to a higher state again as part of
a state change for the whole bin.

When adding an element to the bin this is not needed as we
require callers to always ensure after adding to the bin that
the new element is set to the correct state.
2019-01-07 14:08:00 +02:00
Edward Hervey 7c1d700384 parse: Move variable to block where it's used
There was a dead assignment used outside of the bin/pipeline creation
which was confusing (and unused). Just move that variable to
where it is actually used.

(Note that that variable was not needed outside of that block since
the refactoring done in 2b33d33185 )
2018-12-15 11:46:26 +01:00
Sebastian Dröge 4af3b3f159 pad: Print some debug information about pad probe hooks we remove 2018-12-14 18:37:53 +02:00
Guillaume Desmottes e03f086fae gstcaps: add gst_caps_set_features_simple()
Convenient helper setting a caps feature on all the structures of a
caps.
2018-12-11 16:39:30 +01:00
Dardo D Kleiner 6318e7c675 buffer: Fix memory corruption in gst_buffer_foreach_meta() when removing metas
Fix corruption of meta list head when removing metas at the beginning
during iteration. Linked list handling in gst_buffer_foreach_meta
failed to track the previous entry and update the correct next pointer
when removing items from beyond the head of the list, resulting in
arbitrary list pointer corruption.

Closes #332
2018-12-05 20:50:45 +00:00
Jordan Petridis 84512152c1
Run gst-indent through the files
This is required before we enabled an indent test in the CI.

https://gitlab.freedesktop.org/gstreamer/gstreamer-project/issues/33
2018-11-28 05:58:53 +02:00
Seungha Yang 3332e39baa gst: Fix string leak when G_VALUE_COLLECT_INIT() was failed
Returned string should be freed

Fixes #319
2018-11-12 20:12:41 +09:00
Sebastian Dröge 5f469abbed debugutils: Make sure that GST_DEBUG_GRAPH_SHOW_VERBOSE gets the correct value in introspection
Currently in Python it would become a signed 64 bit value but should
actually be an unsigned 32 bit value with all bits set.

This is the same problem as with GST_MESSAGE_TYPE_ANY.

See https://bugzilla.gnome.org/show_bug.cgi?id=732633
2018-11-10 19:08:52 +00:00
Havard Graff 1335110409 tests: fix tests when compiling with glib_checks=disabled
We won't be able to do ASSERT_CRITICAL, but the main body of the tests
are still valid, and given we ship GStreamer with this configuration, it
is important to be able to run some tests against it.
2018-11-10 15:37:36 +00:00
Sebastian Dröge 1fda8c3bcf clock: Move clock GWeakRef to a private GstClockEntry struct
There's no need for it to be in the public struct and we can keep the
padding for things to be added in the future.
2018-11-08 09:07:07 +00:00
Matthew Waters 4fc4ad87d5 query: add a new bitrate query
Allows determining from downstream what the expected bitrate of a stream
may be which is useful in queue2 for setting time based limits when
upstream does not provide timing information.

Implement bitrate query handling in queue2

https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/issues/60
2018-11-07 15:04:14 +00:00
Havard Graff c6e5f59b2c systemclock: pre-calculate the ratio for multiplying the perf-count on win
Saves a lot of computations.
2018-11-06 10:39:05 +01:00
Havard Graff 4b3872f757 gstpad: use hook_id instead of hook in called_probes list
A pointer to a hook in this list can easily not be unique, given both
the slice-allocator reusing memory, and the OS re-using freed blocks
in malloc.

By doing many repeated add and remove of probes, this becomes very easily
reproduced.

Instead use hook_id, which *is* unique for a added GHook.
2018-11-06 10:04:00 +01:00
Matthew Waters ddfcc28c8b gst/buffer: add a new function for wrapping GBytes
One restriction on the GBytes is that the data cannot be NULL as this is
explicitly forbidden by GstMemory.

Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer/issues/318
2018-11-06 16:12:42 +11:00
Jan Alexander Steffens (heftig) 92d5d5bc57
gst_clear_*: Remove volatile from arguments
g_clear_pointer is not thread-safe and never was. GLib similarly removed
the volatile from g_clear_object in 2aacef39b1.

Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer/issues/327
2018-11-05 14:16:36 +01:00