Commit graph

1492 commits

Author SHA1 Message Date
Sebastian Dröge
ae688406f8 gstreamer: Allocate debug messages up to 256 bytes on the stack and only then spill over into the heap
With this, debug logging from Rust is completely allocation-less for
short messages and string literals.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1179>
2023-01-03 10:28:43 +00:00
Sebastian Dröge
06a0dbacba gstreamer: Don't inline debug logging function
It's relatively big and increases code size and stack usage quite a bit,
and having a function call for logging is not going to make much of a
difference as it happens *after* filtering for the debug level
threshold.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1179>
2023-01-03 10:28:43 +00:00
Sebastian Dröge
036a020b62 gstreamer: Optimize various from/to Vec FFI translation functions
Use memcpys if possible instead of manual loops, and directly write into
the `Vec` memory and set the length afterwards to avoid having the
reallocate logic at every step.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1181>
2023-01-03 12:06:29 +02:00
Sebastian Dröge
882513d33a Make use of the new TransparentType / TransparentPtrType traits
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1178>
2023-01-02 19:07:24 +02:00
Sebastian Dröge
e6e5d25e48 Update CHANGELOG.md for 0.19.5 2022-12-27 12:53:30 +02:00
Sebastian Dröge
3d0f563111 Update minimum supported Rust version to 1.64
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1175>
2022-12-25 14:54:38 +02:00
Sebastian Dröge
146b4fc08e gstreamer: Fix glib::GStr API changes 2022-12-25 00:25:42 +02:00
Sebastian Dröge
cdc7aa4846 gstreamer: Allow returning Handled from BufferList pad probes
This is handled exactly the same way as buffers.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1174>
2022-12-23 12:21:18 +00:00
Sebastian Dröge
d6cc452cf3 Use PhantomData as Stash::Storage if nothing has to be stored except for a lifetime
This reduces the size of all stashes from two pointers to one.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1171>
2022-12-20 17:07:39 +00:00
Sebastian Dröge
f166e80a79 gstreamer: Only use a single temporary Vec for [T]::to_glib_none() for miniobjects
The value itself is already kept alive via the stash and we only need a
temporary `Vec` to be able to append the terminating `NULL` pointer.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1171>
2022-12-20 17:07:39 +00:00
Sebastian Dröge
3764bf75f8 Regenerate with latest GStreamer gir files
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1170>
2022-12-16 22:09:29 +02:00
Sebastian Dröge
8c22ba25f8 Update CHANGELOG.md for 0.19.4 2022-12-16 11:56:04 +02:00
Sebastian Dröge
e3ad1918dc Fix various new clippy warnings
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1164>
2022-12-13 11:29:45 +02:00
Sebastian Dröge
0fa8d0d62f gstreamer: Fix formatting if a string literal needs formatting
E.g. "blabla {some_variable}" is a string literal but needs formatting,
so we can't just pass it as a literal to the logger.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1161>
2022-12-11 12:20:35 +02:00
Sebastian Dröge
2a935320e7 gstreamer: Replace some generic function parameters with impl trait
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1160>
2022-12-10 20:18:11 +02:00
Sebastian Dröge
ef5d5f50e4 gstreamer: Actually log the function name instead of the module name
As there is no way to get the function name as a string literal
currently, we have to copy locally into a NUL-terminated array.
Up to 256 bytes this is managed on the stack, otherwise a heap
allocation is necessary.

For the <256 bytes case the compiler is optimizing most of this away.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1160>
2022-12-10 20:18:11 +02:00
Sebastian Dröge
355ebc243f gstreamer: Add DebugCategory::above_threshold() to check if the category's threshold is above the given level
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1160>
2022-12-10 20:18:11 +02:00
Sebastian Dröge
b58d518aa3 gstreamer: Use glib::GStr for DebugMessage string API too
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1160>
2022-12-10 20:18:11 +02:00
Sebastian Dröge
de04e3f827 gstreamer: Reduce allocations in custom logging functions for the file/function strings
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1160>
2022-12-10 20:18:11 +02:00
Sebastian Dröge
0e7f5a19df gstreamer: Require using a NUL-terminated UTF-8 string or a string literal for the logging ID
Otherwise each log will involve a new allocation just for the ID.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1160>
2022-12-10 20:18:11 +02:00
Sebastian Dröge
2be477b753 gstreamer: Make logging of messages from a string literal allocation-free if using GStreamer 1.20 or newer
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1160>
2022-12-10 20:18:11 +02:00
Sebastian Dröge
3a61276cdd gstreamer: Reduce some allocations for passing the filename/module name to the logging functions
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1160>
2022-12-10 20:18:11 +02:00
Sebastian Dröge
750422d8eb gstreamer: Reduce some code duplication in the logging code
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1160>
2022-12-10 15:48:02 +02:00
Sebastian Dröge
3ab7bc7648 gstreamer: Add bindings for new 1.22 debug log ID API
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1159>
2022-12-09 17:37:01 +02:00
Sebastian Dröge
a54c234fc6 gstreamer: Directly use fields for DebugCategory getters
This allows for better optimizations as it doesn't go through an opaque
FFI function.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1159>
2022-12-09 17:37:01 +02:00
Sebastian Dröge
e8859951d3 gstreamer: Ignore EventType::to_sticky_ordering
This is handled manually via the `PartialOrd` impl.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1159>
2022-12-09 17:37:01 +02:00
Sebastian Dröge
7012fa638e Regenerate with latest gir/gir-files/gst-gir-files
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1159>
2022-12-09 17:37:01 +02:00
Sebastian Dröge
b89b98b6e9 Update CHANGELOG.md for 0.19.3 2022-11-28 10:16:21 +02:00
Sebastian Dröge
b5fcbc9657 gstreamer: Get rid of some unnecessary unsafe API usage
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1157>
2022-11-27 00:59:38 +02:00
Sebastian Dröge
0bc16c65f0 gstreamer: Add some API for add new items to a gst::Array and gst::List
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1157>
2022-11-27 00:59:38 +02:00
Sebastian Dröge
ae4dd88f3d Update for GLib Into<Value> changes
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1156>
2022-11-26 15:19:35 +02:00
Sebastian Dröge
0b013001b7 Regenerate with latest gir
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1156>
2022-11-26 15:01:10 +02:00
Sebastian Dröge
3da927a856 gstreamer: Fix sticky event ordering for instant-rate-change
The event type for instant-rate-change events was poorly chosen, leading
to them being re-sent too late and even after EOS.

See https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3387

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1154>
2022-11-21 13:43:22 +02:00
Sebastian Dröge
cbfc19ccfc Regenerate with latest GStreamer gir files
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1153>
2022-11-21 13:29:38 +02:00
Sebastian Dröge
fa5491e6b3 Use borrowed miniobject/structure types in more places
When the function does not keep around an additional reference of the
value this is correct and more flexible for callers.

https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/issues/420

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1152>
2022-11-21 12:40:37 +02:00
Sebastian Dröge
5a0152b469 gstreamer: tracer: Pass &QueryRef instead of &Query to the functions
To make it impossible for implementor to keep around a reference to the
query as that would break element code that actually tries to answer the
query.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1152>
2022-11-21 12:40:37 +02:00
Sebastian Dröge
1264eb10ac gstreamer: Add PartialEq impls between owned/borrowed miniobjects/structures
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1152>
2022-11-21 12:40:37 +02:00
Sebastian Dröge
56b9b66027 gstreamer: Implement FromIterator<Caps> and Extend<Caps> for Caps
This allows easily generating new/extending existing caps from an
iterator.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1151>
2022-11-21 10:10:04 +02:00
Sebastian Dröge
774fafd987 gstreamer: Implement From<T> for Signed<T>
This makes usage simpler in a few places.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1150>
2022-11-18 12:07:13 +02:00
Edward Hervey
77fd187986 format: Add Signed<T> <=> signed integer conversions
Co-authored-by: Sebastian Dröge <sebastian@centricular.com>
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1149>
2022-11-16 16:32:24 +02:00
Sebastian Dröge
88791294a5 Update CHANGELOG.md for 0.19.2 2022-11-13 20:13:29 +02:00
Sebastian Dröge
9ba448427d Regenerate with latest gir
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1148>
2022-11-12 17:40:16 +02:00
Elie Génard
f1c8869447 gstreamer: Add gst::Allocator subclassing support 2022-11-08 19:28:42 +00:00
Sebastian Dröge
d3543efec2 gstreamer: Manually implement Allocator::register()
Due to a bug it causes use-after-free in versions < 1.20.5, so work
around that here.
2022-11-08 19:07:48 +02:00
Sebastian Dröge
32c432655f Regenerate with latest GStreamer gir files 2022-11-08 18:15:34 +02:00
Sebastian Dröge
01e24d2018 Fix various new clippy warnings 2022-11-01 11:10:57 +02:00
Sebastian Dröge
2bffc4e5ec Fix 0.19.1 release date in the changelog 2022-10-24 12:34:21 +03:00
Sebastian Dröge
708ad14422 Update CHANGELOG.md for 0.19.1 2022-10-24 12:32:45 +03:00
Sebastian Dröge
90b8ee2022 Move from imp.instance() to imp.obj()
It's doing the same thing and is shorter.
2022-10-23 23:06:44 +03:00
François Laignel
87ea535bc1 gst/log: accept non-ref obj in macros 2022-10-23 20:44:38 +02:00
Sebastian Dröge
031133c179 Update versions to 0.20.0 2022-10-22 20:27:42 +03:00
Sebastian Dröge
7331dbc440 Update CHANGELOG.md for 0.19.0 2022-10-22 20:22:10 +03:00
Sebastian Dröge
bf7c770457 Regenerate with latest gir files 2022-10-22 20:22:10 +03:00
Sebastian Dröge
a1165a7456 gstreamer: Add bin/pipeline builders
And also implement the Default trait for them.
2022-10-22 17:36:36 +03:00
François Laignel
0e5a4f05f8 gst: fix Element::request_new_pad signature
See:

https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1133#note_1600152
2022-10-21 11:30:02 +02:00
François Laignel
4ebdfb8602 Use impl Into<Option<_>> for functions impacted by nullability fixes
This commit addresses the functions which signatures changed in
commit f9690817 so that users can still use e.g.
`query.set_result(val)` instead of `query.set_result(Some(val))`.

See [1] for an attempt at generalizing this approach.

[1]: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1133
2022-10-21 11:30:02 +02:00
Sebastian Dröge
130cc9d63b element: Implement linking functions manually for better error reporting
Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/issues/318
2022-10-19 17:59:04 +03:00
Sebastian Dröge
7423b1dea6 elementfactory: Change make() / create() to builders and keep the old variants as create_with_name() / make_with_name()
As a side-effect, this also now includes the element factory name in the
error messages instead of giving the same error string for every
factory.

Partially fixes https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/issues/318

Also let them all go through the same, single object construction code.
2022-10-19 17:48:39 +03:00
Sebastian Dröge
7ad75d4b1f elementfactory: ElementFactory::create_with_properties() is available in any GStreamer version
As it's re-implemented here now instead of calling into the C function.
2022-10-19 13:53:06 +03:00
Sebastian Dröge
9c282ec7c3 gstreamer: Implement ElementFactory::create_with_properties() manually
This way we can get the same property checks as normal object
construction would provide.

Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/issues/402
2022-10-18 16:27:10 +00:00
Sebastian Dröge
67e3183922 Regenerate with latest gir and gir-files 2022-10-18 18:16:51 +03:00
Sebastian Dröge
19f7aaf413 Generate only a single versions file for sys crates too 2022-10-18 18:15:01 +03:00
Sebastian Dröge
9a9ce252a4 Fix usage of dox feature 2022-10-18 18:15:01 +03:00
Sebastian Dröge
d80227e566 Trust nullability annotations everywhere 2022-10-18 18:15:01 +03:00
Sebastian Dröge
f9690817ad Fix nullability handling in some functions in manual code 2022-10-18 18:15:01 +03:00
Vivia Nikolaidou
8d3ada5d89 pad: Catch panics in pad task functions
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/issues/246
2022-10-18 10:38:12 +00:00
François Laignel
49faa03c98 gst/format: make from_u64 constructors const
This commit makes the formatted values' main constructors `const`,
so that they can be used in constant definitions.

`from_usize` constructors can't be made const because `try_into`
can't be used in `const` functions as of rustc 1.64.0. Same for
`Percent::from_ratio`: floating point arithmetic is not allowed.
2022-10-18 11:24:57 +02:00
François Laignel
384783b242 gst/format: introduce Constructor traits
Introduce a set of Constructor traits which are implemented on
integer of float depending on the formatted values. This traits
allows building formatted values using expressions such as:

```rust
let buffer_nb = 20.buffers();
let size = 42.k_bytes();
let duration = 15.minutes() + 30.seconds();
let quantity = 42.default_format();
let progress = 20.percent();
let progress = 0.2.percent_ratio();
```
2022-10-18 11:24:08 +02:00
Vivia Nikolaidou
39bb9abc3c caps: Add .structure() to CapsBuilder
Allows us to get the structure, to read fields after adding them to the
builder.
2022-10-14 16:24:51 +03:00
Sebastian Dröge
734afa998b gstreamer: Implement pad default functions as associated functions
Making them associated functions clearer that special care is required
and avoid conflicts with the same functions in ghostpad/proxypad.
2022-10-12 18:29:52 +03:00
Sebastian Dröge
7d10f9f4c8 Regenerate with latest gir/gir-files 2022-10-12 15:05:07 +03:00
François Laignel
dcf6d16496 gst/format: new panicking constructors and some Percent fixes
Previous proposition for constructing specific formatted values was
to use an operation such as `42 * Default::ONE` which, in retrospect,
doesn't seem idiomatic.

This commit adds `from_u64` and `from_usize` constructors for most
formatted values. Having `from_usize` is convenient when dealing with
quantities related to containers indices or length.

This also fixes the `Percent` from float constructors from which was
derived the `ONE` constant as well as previous display implementation.

Also removed the `pub` specifier for `Undefined` inner value. It wasn't
removed in a previous commit as `Undefined` can use the full range of
the inner type. But now, it seems preferable not to expose the inner
value for proper encapsulation and so as to reduce the differences with
other formatted values (kind of least astonishment principle).
2022-10-11 13:25:53 +02:00
François Laignel
08551bb1bc format/specific: don't expose inner as pub
... users would be able to bypass the range checks and build a
defined Rust value which would be interpreted as `None` in C code.

Added format module examples for formatted values constructions.
2022-10-10 19:23:35 +02:00
François Laignel
f6336b1be3 gst/format: fix Percent Display impl
- The `GST_FORMAT_PERCENT_SCALE` was not used to compute the value
  to display.
- Added `Display` examples in the format module documentation.
- Simplified `glib_newtype_display` macro.
2022-10-10 18:44:59 +02:00
François Laignel
8e2c621a9f gst/lib: cleanup format re-exports 2022-10-10 15:10:10 +02:00
Sebastian Dröge
a4d901ee63 gstreamer: Add an gst::element_error! variant that works on element implementations 2022-10-10 15:01:07 +03:00
Sebastian Dröge
7bd4d770ff gstreamer: Remove unnecessary trait bounds 2022-10-10 15:01:07 +03:00
Sebastian Dröge
f17781e188 Change *Impl trait methods to only take &self and not Self::Type in addition 2022-10-10 15:01:07 +03:00
Sebastian Dröge
25c53c4276 gstreamer: Implement new logging variants that work ObjectSubclass values 2022-10-10 15:01:07 +03:00
François Laignel
274a5bd020 gst/format: implement GenericSignedFormattedValue
The `Signed` version for `GenericFormattedValue` was implemented as
`Signed<GenericFormattedValue>`, which failed to represent properly
the `None` variants when applicable and could represent inconsistent
`Signed` variant combined with `GenericFormattedValue` formats which
are internaly represented as signed integers.
2022-10-09 20:00:40 +02:00
François Laignel
04b6710f84 format/Other: use u64 internally instead of i64 2022-10-09 20:00:38 +02:00
François Laignel
8a7813d04c gst: move format_serde.rs under format module 2022-10-09 18:53:57 +02:00
Sebastian Dröge
dac3cf67f4 Update for additional translation trait impls in gtk-rs-core 2022-10-08 15:35:37 +03:00
Sebastian Dröge
3cd902513d Update for glib::Object::new() API changes 2022-10-07 21:45:01 +03:00
Sebastian Dröge
dcd53bd16e Regenerate with latest gir 2022-10-07 20:30:24 +03:00
Sebastian Dröge
c64b6ac68b tracer: Use Results instead of plain success/failure enums
This makes it more convenient to handle the success/failure cases in
tracer implementations and is more consistent.
2022-10-02 10:45:14 +03:00
Sebastian Dröge
ade0aad6b0 tracer: Make buffer in pull-range-post function optional
Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/issues/410
2022-10-02 10:36:05 +03:00
François Laignel
bff1354b74 gst/format: module doc 2022-10-01 13:16:06 +02:00
François Laignel
e2fe1d6371 gst/format: macros minor cleanups 2022-10-01 13:16:06 +02:00
François Laignel
57d8d46ab6 gst/format: fix some ops and add others
Some operations were implemented on types that wouldn't result in
the expected physical unit. E.g.:

- `ClockTime / ClockTime` results in a unit-less factor.
- `u64 / ClockTime` would result in a `1 / ClockTime`. Since we don't
  use any `Frequency` type, this operation is removed. Users should
  use the `ClockTime` accessors to compute the expected value.

This commit also adds:

- multiplications with integers as the left hand side operands.
- `Partial{Eq,Ord} for `Signed<T>` with `T` as left hand side operand.
- `opt_add` / `opt_sub` for `Signed<T>` with `T` as left or right hand
   side operands.
- missing tests for `Partial{Eq,Ord}` and `OptionOrd`.

This implementation can interfere with unrelated code and was removed:

- `Signed<usize>.` `PartialOrd` makes existing code computing the len
  of slices needing type annotation because the len is later used in
  a comparison for which the compiler is unable to determine if
  the len is `Signed<usize>` or `usize`.
2022-10-01 13:15:11 +02:00
François Laignel
eb4d997f0a gst/format: shuffle types and traits 2022-10-01 00:49:42 +02:00
François Laignel
79377337a4 gst/format: move related modules under a directory 2022-10-01 00:49:39 +02:00
69ea30dbda
gstreamer: meta: Allow to register custom meta without transform function 2022-09-29 14:05:35 +02:00
François Laignel
99e344af4d gst/format: simplify some ops impl
The `SpecificFormattedValue` types are newtypes of `u64` or `u32`
and they all implement `Copy`. It shouldn't be needed to implement
operations on `&Type` nor `&inner_type`.
2022-09-22 00:05:28 +02:00
François Laignel
86549dc06e gst/Segment: return immediately from some functions...
... if the input `is_none`.
2022-09-21 17:20:43 +00:00
François Laignel
8595b67218 gst/Signed: impl option-operations traits 2022-09-21 17:20:43 +00:00
François Laignel
183a399d1d gst/Signed: impl MulDiv 2022-09-21 17:20:43 +00:00
François Laignel
2b4fcb131e gst/Signed: impl div & mul 2022-09-21 17:20:43 +00:00
François Laignel
1411c9e35e gst/Signed: use a new trait for into_{signed,positive,negative}
The functions `into_{signed,positive,negative}` used to be implemented
on the `FormattedValue` trait for convenience. This was wrong for the
following reasons:

- They aren't specific to `FormattedValue`s: they can also be
  implemented for regular unsigned integers such as `u64`, `usize` or
  `u32`.
- They were implemented for `format::Undefined` and all variants of
  `GenericFormattedValue`, some of which are already signed.

This commit introduces the new trait `UnsignedIntoSigned`, which makes
it possible to fix both of the above problems.

Users can build a `Signed` from an `Undefined`, an `i64`, `isize` or
`i32` thanks to the `From` trait implementations.
2022-09-21 17:20:43 +00:00
François Laignel
960befb2f5 gst/Signed: move signed ops macro to macro.rs
This will help with the implementation of Signed muls & divs for
`FormattedValue`s since we need to know about the inner types.
2022-09-21 17:20:43 +00:00