Commit graph

1713 commits

Author SHA1 Message Date
François Laignel
88a52d9ea1 gst: anticipate GQuark to GstIdStr lifetime changes
GStreamer fixes a memory leak due to GQuarks by switching to GstIdStr.
The consequence is that strings previously backed by a GQuark returned by a
function will now get their lifetime bound to that of its owner, while the
GQuark version ensured static lifetime.

Because some functions return a string with the assumption that they are static
and because we can't alter the API for existing versions of the bindings, this
MR temporarily forces affected strings as GQuarks, thus gaining static lifetime
regardless of the GStreamer version actually being used.

For newer versions of the bindings, the API will be fixed and GQuarks will be
removed in favor a leakless solution.

See: https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7432
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1519>
2024-09-11 09:19:35 +00:00
François Laignel
96ec17b1e9 structure: fix doc
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1519>
2024-09-11 09:19:35 +00:00
François Laignel
1b578b6113 tags: fix index() lifetime bind
The signature for `TagListRef::index` didn't bind the lifetime of the returned
`TagValue` to `&self`. This causes the following code to compile:

```rust
 1 let title = {
 2     let mut tags = TagList::new();
 3     {
 4         let tags = tags.get_mut().unwrap();
 5         tags.add::<Title>(&"some title", TagMergeMode::Append);
 6     }
 7
 8     let title = tags.index::<Title>(0).unwrap();
 9     assert_eq!(title.get(), "some title");
10
11     title
12 };
13
14 assert_eq!(title.get(), "some title");
```

... but it panics at runtime on the last `title.get()`:

```
Invalid tag type: WrongValueType(ValueTypeMismatchError
    { actual: <invalid>, requested: gchararray })
```

Indeed, the `title` `TagValue` is freed with the `tags` on line 12.

This commit fixes the function signature so the returned `TagValue` can't
outlive its `TagListRef`.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1518>
2024-09-10 19:40:33 +00:00
Sebastian Dröge
628f040e2d Fix new 1.81 clippy warnings
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1515>
2024-09-05 21:52:35 +03:00
Sebastian Dröge
ed6aac91bd Remove deprecated API
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1513>
2024-08-28 09:44:55 +03:00
Sebastian Dröge
497f15acd3 Update CHANGELOG.md for 0.23.1 2024-08-27 20:42:18 +03:00
Sebastian Dröge
a145ce6ab1 Ignore a new 1.80 clippy warning
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1491>
2024-08-13 15:41:44 +03:00
Sebastian Dröge
bc96a99576 Regenerate with latest gir
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1496>
2024-08-07 18:16:07 +03:00
Sebastian Dröge
73d9793f5b Fix new 1.80 clippy warnings
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1496>
2024-08-07 18:16:07 +03:00
Piotr Brzeziński
7be6a9fef4 gstreamer: bufferlist: Fix remove() range end being off by one
The end index was being calculated the same way as the start one, which is incorrect.
It should be +1'd when range is inclusive and left as-is if it's exclusive, not the other way around.
Fixed and added a simple test to verify correctness.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1490>
2024-07-30 14:19:42 +02:00
Guillaume Desmottes
2ae1e4a511 gstreamer: format: Percent: add getters
We had constructor from the percent/ppm/ratio values but not getters
to get those values.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1488>
2024-07-26 09:30:18 +02:00
Sebastian Dröge
658b8c2231 gstreamer: meta: Pass an empty tag array instead of NULL to gst_meta_register_custom()
NULL gives a critical warning but an empty, NULL-terminated array gives
the desired result.

Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/issues/516

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1483>
2024-07-18 13:04:42 +03:00
Sebastian Dröge
0f5c0e935c Update CHANGELOG.md for 0.23.0 release
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1482>
2024-07-17 16:52:53 +03:00
Sebastian Dröge
0ed46425f6 Regenerate with latest gir-files
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1481>
2024-07-11 17:48:59 +03:00
Sebastian Dröge
9b76ef35cf Regenerate with latest gir / gir files
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1480>
2024-07-08 09:37:34 +03:00
Sebastian Dröge
94313e67c5 gstreamer: Unconditionally use gst_parse_context_copy()
It's available since 1.12.1 and the minimum supported version for the
bindings is 1.14 nowadays.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1478>
2024-07-06 11:21:31 +00:00
Sebastian Dröge
a871f71515 gstreamer: Use obj = x instead of obj: x in debug log macros
And deprecate the old usage. This gives better tooling support, and
especially allows rustfmt to format the macro body correctly.

Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/issues/513

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1477>
2024-07-06 14:08:03 +03:00
Sebastian Dröge
adf3e9236a gstreamer: childproxy: Include child property name in error message when lookup fails
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1472>
2024-06-28 12:20:47 +03:00
Sebastian Dröge
7a5096b1e4 gstreamer: clock: Manually implement bindings for calibration related function
The rate is using two clock times in C but this is really just a u64.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1470>
2024-06-21 16:34:27 +03:00
Sebastian Dröge
f3d7e18bcd Update to system-deps 7
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1469>
2024-06-20 20:58:27 +03:00
Sebastian Dröge
53ede03b3b Update CHANGELOG.md for 0.22.6
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1467>
2024-06-19 20:51:31 +03:00
Sebastian Dröge
45ec7cedd9 Use Option::is_some_and(...) instead of Option::map_or(false, ...)
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1466>
2024-06-19 11:17:58 +03:00
François Laignel
8527c0e39e Add new setters for collection Value setters in Builders
E.g. (also applies to `property`):

* `field_from_iter()`,
* `field_if_not_empty()`.

Use a macro to factorize implementation & documentation of `field` / `property`
convenience setters.

Also:

* add some `*_if_not_empty` for some iterator based setters.
* add `*_if` for predicate based setters.

Related to https://github.com/gtk-rs/gtk-rs-core/pull/1377

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1431>
2024-06-14 17:00:36 +02:00
Sebastian Dröge
f99c519a00 Fix various new 1.79 clippy warnings
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1461>
2024-06-14 08:08:27 +03:00
Sebastian Dröge
6bab9de772 gstreamer: Actually re-export ByteSliceExt trait from prelude instead of the Dump struct
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1460>
2024-06-12 19:35:55 +03:00
Sebastian Dröge
7c87874c28 gstreamer: Add bindings for generic message details API
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1457>
2024-06-11 10:18:08 +03:00
Sebastian Dröge
b59a92b29e Regenerate with latest gir
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1457>
2024-06-11 08:29:32 +03:00
Bilal Elmoussaoui
e6ed67cbc5 Regenerate with properties annotations supports
Removes some duplicated getters/setters

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1452>
2024-06-07 10:15:53 +00:00
Tim-Philipp Müller
c545154472 log: fix panic when using a log id with a formatted log message
Would panic because of a missing NUL terminator:

thread '<unnamed>' panicked at .. glib/src/gstring.rs:61:9:
assertion failed: !bytes.is_empty() && bytes[bytes.len() - 1] == 0

 3: glib::gstring::GStr::from_utf8_with_nul_unchecked
 4: gstreamer::log::DebugCategory::log_id_unfiltered_internal
      at gstreamer-rs/gstreamer/src/log.rs:465
 5: gstreamer::log::DebugCategory::log_id_unfiltered
      at gstreamer-rs/gstreamer/src/log.rs:425

Also enable logging on the category, so the logging code paths
are actually run here in the tests.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1451>
2024-06-02 17:32:26 +03:00
Bilal Elmoussaoui
4ebec84f5e Adapt to no longer renamed ffi crates
Allows us to set all the crates in the main workspace file, so changing
their versions or branch is much simpler and reduce the amount of noise
in the diff

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1450>
2024-06-02 11:20:55 +02:00
Bilal Elmoussaoui
10aff0d66e Regenerate with latest gir
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1450>
2024-06-01 15:14:58 +02:00
Sebastian Dröge
413a6baa8c Update CHANGELOG.md for 0.22.5 2024-05-23 16:06:42 +03:00
Sebastian Dröge
9e2c6268cb gstreamer: Use usize instead of u32 for various indices
This affects buffers, caps, caps features, structures and tag lists and
makes it easier to use them with other Rust APIs that use usize-based
indicing.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1445>
2024-05-22 08:15:08 +00:00
Tim-Philipp Müller
4cda565a39 gstreamer: bufferlist: add another test for foreach_mut
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1446>
2024-05-22 06:59:40 +00:00
Sebastian Dröge
805cd6c591 gstreamer: bufferlist: Change remove function to take a range instead of index + length
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1444>
2024-05-21 08:21:17 +03:00
Sebastian Dröge
a0e58ec359 gstreamer: bufferlist: Check index/length when removing a buffer
Out of range values give assertions in the C function.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1444>
2024-05-21 08:19:30 +03:00
Sebastian Dröge
9f151466b7 gstreamer: bufferlist: Check for out of range indices before trying to get buffer
Passing an index bigger than the length will cause an assertion in the C
function.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1444>
2024-05-21 08:11:41 +03:00
Sebastian Dröge
c3619b45aa Update to itertools 0.13
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1443>
2024-05-20 14:03:58 +03:00
Seungha Yang
f59029b57c event: Fix leak in SelectStreamsBuilder
gst_event_new_select_streams() does not take ownership of GList

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1442>
2024-05-16 14:30:52 +00:00
Sebastian Dröge
b468280353 Improve code generation with panic=abort around panic handling code
None of that can ever be called in that case but the compiler can't know
that in more complicated cases like these. Handling it explicitly allows
no handling code to be generated at all here, like would already happen
everywhere else.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1441>
2024-05-16 16:38:15 +03:00
Sebastian Dröge
5af4a262b8 Regenerate with latest GStreamer gir files
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1440>
2024-05-10 10:09:10 +03:00
Sebastian Dröge
2a9d0d035f Fix various new 1.78 clippy warnings
Quite a bit of API was accidentally not exported but apparently nobody
was using it.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1437>
2024-05-02 18:13:27 +03:00
Sebastian Dröge
fe1fe5b114 gstreamer: Use a reference to a pointer of correct mutability for from_glib_ptr_borrow()
This hopefully makes it easier to use and harder to get the returned
lifetime wrong.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1436>
2024-04-30 15:39:15 +03:00
Sebastian Dröge
ba4bd5c631 Add 1.26 version features and update 1.24 requirement from 1.23 to 1.24
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1435>
2024-04-30 12:36:37 +03:00
Sebastian Dröge
873aeff133 Regenerate with latest GStreamer gir files
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1435>
2024-04-30 12:36:37 +03:00
Nick Steel
b7b5352353 log: Log trait adapter around the GStreamer debug system
Allows usage of normal `log` crate macros, and for other crates
using those macros to have their log messages go to the GStreamer
debug logs.

This implementation is based on the one found in Servo.

Fixes #187

DebugCategoryLogger is optional via 'log' feature
check category above threshold
skip_assert_initialized for constructor and helper

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1426>
2024-04-29 16:16:47 +01:00
Sebastian Dröge
57050f66c6 Regenerate with latest gir / gir-files
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1429>
2024-04-27 11:31:11 +03:00
François Laignel
953e3747f2 Pad: allow building a Pad with an automatically generated name
For convenience, the `Pad` builder checks a name is provided when a wildcard-
named template is used. For `GhostPad`s, the builder tries to assign the name of
the target `Pad` making sure the provided `name` conforms to the `PadTemplate`.

This commit adds a function to optionally keep the `gst::Object` automatically
generated unique `Pad` name (such as `ghostpad4`) and reorganises name handling
so it is processed when `build` is invoked.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1428>
2024-04-26 09:57:28 +00:00
François Laignel
db03c8edd1 Add field_if_some setter for builder ClockTime fields
Optional `ClockTime` fields already implemented their setters in such a way
that they could accept either `Option<ClockTime>` or `ClockTime`. This commit
adds `field_if_some()` setter variants for builder `ClockTime` builder fields
for consistency with other builder fields.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1424>
2024-04-17 17:15:41 +02:00
François Laignel
ea25c9262b Add field_if_some setter for builders
This commit adds `_if_some()` variants for builder field setters.
The variants aim at improving usability when setting optional fields.
E.g. currently, we need to write something like:

```rust
let opt_value = ...;
let mut sb = gst::Structure::builder("test")
    .field("mandatory_field", "mandatory");

if let Some(value) = opt_value
    sb = sb.field("optional_field", value);
}

let s = sb.build();
```

With `_if_some()`, this can be written like this:

```rust
let opt_value = ...;
let s = gst::Structure::builder("test")
    .field("mandatory_field", "mandatory")
    .field_if_some("optional_field", opt_value)
    .build();
```

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1424>
2024-04-17 17:15:39 +02:00