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/1522>
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/1520>
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/1494>
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>
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>
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>
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>
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>
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>