Commit graph

33 commits

Author SHA1 Message Date
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 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
François Laignel 9453d63631 gst/pad: [Ghost]PadBuilder: inherit name from template or target when possible
This commit adds convenience auto naming in the following cases:

* When building from a non wildcard-named template, the name of the template is
  automatically assigned to the Pad. User can override with a specific name by
  calling `name()` on the `PadBuilder`.
* When building with a target and no name was provided via the above, the
  GhostPad is named after the target.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1255>
2023-05-12 10:55:46 +00:00
François Laignel 7cb5473ba6 gst: Pad move name definition to builders
Also apply consistent naming for builder/non-builder constructors.

See discussion in:
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/issues/448#note_1799092

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1255>
2023-05-12 10:55:46 +00: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 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 1541fbf32a gstreamer: Add many new doc aliases for C function 2021-12-12 17:52:32 +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
Bilal Elmoussaoui 890cd03632 manual renames of to_glib into into_glib 2021-04-27 19:44:41 +02: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
Marijn Suijten 827ff99965 lib: Only export traits (Ext and ExtManual) from prelude
In gir it was brought up [1] that some traits (in particular
`*ExtManual`) are exported from the crate root in addition to the
prelude, cluttering the environment unnecessarily.  This commit removes
all these reexports, leaving those in prelude (that were already there)
only.

After this commit everything matching `Ext(Manual)?\b` in `lib.rs` sits
within `pub mod prelude {};`.

[1]: https://github.com/gtk-rs/gir/pull/1111
2021-04-26 11:25:23 +02:00
François Laignel 99616ec0b4 post fix-getters manual updates 2021-04-13 17:54:40 +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
Sebastian Dröge 9d9522016b gstreamer: Update manual code to 2018 edition 2020-11-22 19:15:20 +02:00
Sebastian Dröge 81aba1b8a2 gstreamer/ghost_pad: Add convenience constructors with target pad
Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/issues/275
2020-07-10 12:12:03 +00:00
Sebastian Dröge 4246a560fc gstreamer/ghost_pad: Move GhostPad specific code into the ghost_pad module 2020-07-10 12:12:03 +00:00
Sebastian Dröge 0c0d671922 gstreamer/pad: Don't provide constructors anymore but instead a builder
This handles safely setting the pad functions during construction and
also has special support for ghost pads.

Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/issues/247
2020-06-22 10:55:24 +03:00
Guillaume Desmottes a954c03bc0 functions: rename constructors in manual API
The idiomatic way for Rust constructors is to be named from_XXX()
instead of new_from_XXX() and with_XXX() instead of new_with_XXX().

Fix #460
2020-06-11 12:33:52 +02:00
Sebastian Dröge be3c378f28 Use Results instead of Options where they signal an error instead of just a missing value
Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/issues/216
2019-12-17 22:21:28 +02:00
Sebastian Dröge 86e969d964 Remove various Into<Option<_>> trait bounds from functions
In autogenerated code these were already replaced but some manual code
still kept them.
2019-05-24 10:04:16 +00:00
Sebastian Dröge e7898c1b24 Update manual code 2019-04-15 19:19:19 +03:00
François Laignel 333d71f92b Update functions returning bool to use Result<(), glib::BoolError>
See https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/issues/171
2019-01-17 23:13:44 +01:00
Sebastian Dröge 43ec33a1db Remove some code that is nowadays generated by the glib_wrapper! macro 2019-01-16 15:23:53 +02:00
Sebastian Dröge 931c485150 Update manual code for glib API changes 2019-01-16 13:52:56 +02:00
Sebastian Dröge d2b911a629 Port GhostPad subclassing 2018-11-21 16:14:06 +02:00
Sebastian Dröge eb0a804a50 Run everything through latest rustfmt 2018-10-08 15:02:23 +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 ffb5869dd1 Use the correct pad type for the proxy/ghost pad default pad functions 2017-12-17 11:24:03 +02:00
Sebastian Dröge 03285a6311 Run everything through latest rustfmt-nightly 2017-07-31 12:16:42 +01:00
Sebastian Dröge 21888daab6 Add GhostPad bindings 2017-07-29 14:19:15 +01:00