Commit graph

141 commits

Author SHA1 Message Date
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
Bilal Elmoussaoui aaea288abf Adapt to no longer re-exported traits
Some of the traits were moved to prelude or translate
and no longer in the main scope of the crate

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1382>
2024-02-03 10:48:37 +01:00
Sebastian Dröge 0b4c602c6f Provide a more convenient function for setting other fields on message/event builders
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1372>
2023-12-31 15:53:10 +02:00
Sebastian Dröge 83a562e227 Fix/silence various 1.72 clippy warnings
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1306>
2023-08-28 16:50:41 +00:00
Sebastian Dröge 2290262c2e gstreamer: Add fmt::Debug impls for owned Event/Query/Message too
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1269>
2023-05-24 10:36:08 +03:00
Guillaume Desmottes 71b77c513d gstreamer: message: add structure to Debug views
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1268>
2023-05-23 15:24:19 +02:00
Guillaume Desmottes 3ffba2453d gstreamer: message: manually implement Debug
Allow us to display more useful information.

Fix #466

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1267>
2023-05-23 10:32:42 +02:00
Guillaume Desmottes 041a1f2a8e gstreamer: message: implement Display on Error, Warning and Info
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1267>
2023-05-23 08:36:13 +02:00
Sebastian Dröge 3699da7314 Remove dox feature and replace by docsrs configuration
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1256>
2023-05-04 09:19:29 +03:00
Sebastian Dröge 5cea810820 gstreamer: Add bindings for Message::structure_mut()
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1204>
2023-01-26 15:28:42 +02:00
Sebastian Dröge 37bfb78fdc Change some assertions to debug assertions
These assertions can only trigger because of bugs in the bindings
implementation or in the C code and not because of bugs in calling code,
so using debug assertions is perfectly fine for them and reduces the
number of assertions inlined everywhere in release builds.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1188>
2023-01-14 17:13:46 +02:00
Sebastian Dröge f235dc987d Inline various trivial functions
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1177>
2023-01-11 11:33:54 +02:00
Sebastian Dröge 277d63601c gstreamer: Return glib::GString for the error/warning/info message debug string
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1184>
2023-01-06 10:41:55 +02:00
Sebastian Dröge 1e793f3b65 gstreamer: Return some values by reference instead
Less refcounting.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1183>
2023-01-05 12:09:57 +02:00
Sebastian Dröge 567ce0a3bf Group and merge imports in all manual code
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1182>
2023-01-04 13:25:17 +02:00
Sebastian Dröge f9690817ad Fix nullability handling in some functions in manual code 2022-10-18 18:15:01 +03:00
François Laignel 8e2c621a9f gst/lib: cleanup format re-exports 2022-10-10 15:10:10 +02:00
Guillaume Desmottes 2dcd5cf9eb as_ptr() and as_mut_ptr() accessors are safe
Nothing unsafe about getting a pointer, deferencing it is unsafe.
2022-08-12 08:29:49 +02:00
François Laignel a787197254 Use CompatibleFormattedValue where applicable
See https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1059
2022-07-11 19:45:52 +02:00
François Laignel fe319af598 Implement FormattedValue on any candidate type
The trait FormattedValue was only implemented on types which
could implement the full range of values for a Format. In order
to declare a function which could take both the intrinsic type
of any Format (e.g. `ClockTime`) as well the full range of values
(e.g. `Option<ClockTime>`), the argument was declared:

```rust
    impl Into<GenericFormattedValue>,
```

This commit implements `FormattedValue` for any type representing
a format. E.g.: both `ClockTime` and `Option<ClockTime>` will now
implement `FormattedValue`. The trait `FormattedValueFullRange`
is implemented on types which can be built from any raw value.

These changes are intended to help for the implementation of a
means to enforce format conformity at compilation time for
functions with multiple formatted value arguments.

The following signatures were found to be incorrect and are fixed:

- `message::StepDone`: forced the type for `amount` and `duration`
  to be of the same type, when `duration` is expected to be of the
  `Time` format.
- `query::Convert::set`: the two arguments were forced to the same
  type, so potentialy the same format, unless a
  `GenericFormattedValue` was used.

See https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1059
2022-07-11 19:45:52 +02:00
Guillaume Gomez c1d3ed5eac Use IntoGlibPtr trait instead of implementing into_ptr 2022-05-07 13:38:11 +02:00
Sebastian Dröge 7420a72831 gstreamer: Add error/warning/info message constructors from a pre-existing glib::Error 2022-04-21 15:33:51 +03:00
Sebastian Dröge 40dcdcbf5c gstreamer: Simplify error/warning/info message builders 2022-04-21 15:03:50 +03:00
Sebastian Dröge 4651c9db4d Update minimum supported version to 1.14
This is the version that is available in Ubuntu 18.04.
2022-04-07 12:45:47 +03:00
Sebastian Dröge 627f4d798e gstreamer: Get rid of some duplicated feature cfg attributes 2022-04-06 10:18:48 +03:00
François Laignel 972c4e75ac remove gst_ prefix for log macros
It's quite quite common to use similar macros in the form `log::debug!`
or `glib::clone!`. This MR renames the gst log macros so that we can
`gst::debug!` instead of `gst_debug!` and whithout the need for
`use gst::gst_debug`.
2022-02-21 18:56:06 +01:00
Sebastian Dröge d1f978f9f1 gstreamer: Improve StreamsSelectedBuilder::streams()
It's much easier to use if it takes any kind of iterator instead of a
slice of references.
2022-02-14 13:44:19 +02:00
Sebastian Dröge 5e2249d368 message/query/event: Implement views in a more consistent way
Co-authored-by: Jan Alexander Steffens (heftig) <jan.steffens@ltnglobal.com>
2022-01-19 13:29:59 +02:00
Paolo Borelli 97f59d34fa Add the has_name() fn to EventRef, MessageRef and StructureRef
They are handy and they match the C api
2021-12-14 09:59:39 +01:00
Sebastian Dröge ee1a5e8395 Add #[must_use] attribute to many builders 2021-12-04 10:26:08 +02:00
Sebastian Dröge ddf398e3da gstreamer: Add various missing doc aliases to event/message/query functions
This is going to make it easier to find them from the corresponding C
function names.
2021-11-19 10:38:46 +00:00
Sebastian Dröge 67af5ac569 gstreamer: Add support for 1.18 instant rate request message 2021-10-17 14:39:38 +03:00
Sebastian Dröge cdddf48f08 gstreamer: Correctly mark various messages as new in 1.10/1.16 2021-10-17 14:33:34 +03:00
Sebastian Dröge d01ed466d0 gstreamer: Use #[non_exhaustive] annotation instead of a dummy enum variant 2021-10-17 14:04:18 +03:00
François Laignel e31ce9d07b Manual ClockTime updates 2021-06-04 22:09:38 +02:00
François Laignel 90bb458e64 Rework ClockTime & FormattedValues 2021-06-04 22:09:38 +02:00
Marijn Suijten 540062b97c Add missing doc aliases to manual code
Using the same script as [1], called with:

    python3 add_doc_alias.py gstreamer*/**/src

[1]: https://github.com/gtk-rs/gtk-rs-core/pull/83
2021-05-19 22:36:18 +02:00
François Laignel 49583597ed manual code: fix-getters-def doc aliases 2021-05-03 20:46:57 +02:00
Marijn Suijten f89e840d27 Remove redundant prelude imports
When importing the prelude of a crate like `gst` the `glib` prelude is
provided too.  Shedding these imports saves quite a few lines and
adheres to keeping it simple; we're not reexporting base/parent preludes
for no reason :)
2021-04-29 12:05:13 +02:00
Bilal Elmoussaoui 890cd03632 manual renames of to_glib into into_glib 2021-04-27 19:44:41 +02:00
Sebastian Dröge 1d59ea91c5 Clean up various imports everywhere 2021-04-26 15:16:58 +03:00
Marijn Suijten 2c40ce10ab gstreamer,pbutils: Only import traits from prelude
Future changes will make all traits - both manual and auto - unavailable
from the crate root; they can then only be imported from the `prelude`.
2021-04-26 13:24:02 +02:00
Sebastian Dröge eda1d3d4a7 Update for Value trait refactoring 2021-04-25 14:45:08 +03:00
François Laignel 53be8e5f58 fix-getters-{def,calls} pass 2021-04-13 17:54:40 +02:00
Sebastian Dröge 53aae7ddba Remove gst_ prefix from all macros except for the logging macros
The latter stay e.g. gst_debug! to be more clear and not conflict with
e.g. the debug! macro from the log crate.
2020-12-20 19:40:34 +02:00
Guillaume Gomez ff5a36561a Fix license header situation 2020-12-15 11:53:31 +01:00
François Laignel 0dce894b13 gstreamer/message: 2d attempt at printing src for Debug impl
1st attempt in c987bb0c was reverted by 89c4f68f due to
clippy "redundant clone" warning.
2020-12-13 19:44:34 +01:00
Guillaume Gomez 8f9d76bb8c Revert "Remove unnecessary dox feature"
This reverts commit 9dd8bd9095.
2020-11-27 14:37:49 +01:00
Guillaume Gomez 9dd8bd9095 Remove unnecessary dox feature 2020-11-25 15:54:02 +01:00