Commit graph

64 commits

Author SHA1 Message Date
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
Sebastian Dröge a252de69b1 audio: Don't store a copy of the AudioInfo in AudioFrame
Instead just reference the one inside the FFI struct directly by making
sure that the memory representation of the FFI and Rust type are the
same.

This reduces the size of `AudioFrame` by about half.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1244>
2023-04-06 21:08:51 +03:00
Sebastian Dröge eadb3c6db2 audio: Reduce size of AudioInfo from 832 to 320 bytes and make audio channel position handling more efficient
Assume that there are never more than 64 named channel positions and by
that provide an 1:1 mapping between the C and Rust types.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1198>
2023-01-23 12:58:16 +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 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 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
Arun Raghavan c3a950f207 audio: Add bindings for GstAudioFilter
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1165>
2022-12-13 12:27:05 -05: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 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
Vivia Nikolaidou 6f51444c1f audio: Add channel_mask() and default_channel_mask() to AudioCapsBuilder
Also use default_channel_mask() where applicable
2022-10-14 16:58:19 +03:00
Vivia Nikolaidou 6d4ad712c7 examples, audio, pbutils, video: Use AudioCapsBuilder and VideoCapsBuilder
Simplify caps creation code
2022-10-14 13:59:51 +03:00
François Laignel 8e2c621a9f gst/lib: cleanup format re-exports 2022-10-10 15:10:10 +02:00
Sebastian Dröge 879d6a4548 audio: Use new 1.63 std::array::from_fn instead of the external array-init crate 2022-09-05 18:10:17 +03: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
Sebastian Dröge ee1a5e8395 Add #[must_use] attribute to many builders 2021-12-04 10:26:08 +02:00
Sebastian Dröge b4a3738b82 Move more code to caps/structure builders
Instead of the new() functions requiring slices. The code reads cleaner.
2021-10-24 18:57:15 +03:00
François Laignel e31ce9d07b Manual ClockTime updates 2021-06-04 22:09:38 +02:00
Guillaume Gomez 5ba79976a9 Generate missing doc aliases for newtypes 2021-06-01 15:15:59 +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
Marijn Suijten 66b60a0822 audio: Fix all clippy::use_self warnings 2021-04-30 10:02:55 +02:00
Marijn Suijten 10c93807fb Replace explicit type with Self in for_value_type::<> turbofish 2021-04-30 10:02:47 +02:00
Bilal Elmoussaoui 890cd03632 manual renames of to_glib into into_glib 2021-04-27 19:44:41 +02:00
Sebastian Dröge eda1d3d4a7 Update for Value trait refactoring 2021-04-25 14:45:08 +03:00
François Laignel 6ab9164dca fix-getters-calls 0.3.0 pass 2021-04-20 18:18:02 +02:00
François Laignel 53be8e5f58 fix-getters-{def,calls} pass 2021-04-13 17:54:40 +02:00
Sebastian Dröge ce1148b474 Update everything for glib macro renamings 2020-12-18 00:56:47 +02:00
Guillaume Gomez ff5a36561a Fix license header situation 2020-12-15 11:53:31 +01:00
Guillaume Gomez fb56af8d84 Update from_glib calls and put them in unsafe blocks 2020-12-08 15:50:15 +01:00
Marijn Suijten 2447664df6 Replace Result<(), fmt::Error> with fmt::Result 2020-12-07 12:09:39 +01:00
Sebastian Dröge 4a928136ed gstreamer-audio: Update manual code to 2018 edition 2020-11-22 19:15:20 +02:00
Sebastian Dröge 947ac8db5c Name functions returning a builder builder(), not new()
And also make the video event API more consistent with the normal event
API.

Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/issues/269
2020-06-25 19:42:33 +03:00
Sebastian Dröge be00953ec6 audio: Add AudioInfo::is_valid() and guard against finfo being NULL when retrieving the audio format 2020-06-07 18:58:54 +03:00
Tony Jinwoo Ahn c563fb6f44 gstreamer-audio/audio_info: Change functions from returning Option to Result
Partial work for:
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/issues/216
2019-12-14 14:10:06 +00:00
Sebastian Dröge 1eb5525a27 Update array-init to 0.1 and gl_generator to 0.13 2019-07-24 14:23:15 +03:00
Sebastian Dröge 3a8d05075d Switch everything from mem::uninitialized() to MaybeUninit or mem::zeroed()
And also fix a few cases where mem::uninitialized() was simply wrong to
use.
2019-07-11 17:56:50 +03:00
Guillaume Desmottes f84e94db78 audio: AudioInfo: display format info in Debug 2019-07-03 15:27:30 +02:00
Sebastian Dröge e7898c1b24 Update manual code 2019-04-15 19:19:19 +03:00
Sebastian Dröge 8c39da4e5b Update to Rust 1.31 linter-specific attributes 2019-03-04 15:16:01 +02:00
Sebastian Dröge bd0cbe99b3 Add more Debug impls to everything possible 2019-01-22 17:46:08 +02:00
Sebastian Dröge 255243c16a Implement Sync for VideoInfo and AudioInfo
They are immutable on the Rust side after all.
2018-09-22 10:56:25 +03:00
Sebastian Dröge 33a6aab6d7 Run everything through latest rustfmt 2018-07-27 13:36:40 +03:00
Sebastian Dröge 694bcaa697 Fix all clippy warnings
Or silence the ones we don't care about.
2018-07-20 10:28:20 +03:00
Sebastian Dröge f271c99498 Implement fmt::Debug for AudioInfo 2018-06-08 10:19:06 +03:00
Sebastian Dröge 2cefd9aea6 Re-run everything through rustfmt 2018-04-25 11:13:14 +03:00
Sebastian Dröge 492c3d656c Run everything through rustfmt again 2018-04-01 11:57:58 +03:00
Sebastian Dröge 4864a1e089 Fix build 2018-03-19 10:32:07 +02:00
Sebastian Dröge 4117c01ff2 Run everything through latest rustfmt-nightly 2018-02-22 11:18:37 +01:00
Sebastian Dröge e0dc84c10a Run everything through rustfmt again 2017-12-20 19:30:14 +02:00
Sebastian Dröge 8bdd24a840 Run everything through rustfmt again 2017-12-16 14:53:00 +02:00
Sebastian Dröge 70e031b729 VideoInfo/AudioInfo are not Sync, only Send 2017-12-16 11:40:36 +02:00