Commit graph

1186 commits

Author SHA1 Message Date
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
Sebastian Dröge b06a692dea Fix a new beta clippy warning
warning: unused return value of `std::boxed::Box::<T>::from_raw` that must be used
  --> gstreamer-rtsp-server/src/rtsp_session_pool.rs:23:5
   |
23 |     Box::<F>::from_raw(ptr as *mut _);
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: `#[warn(unused_must_use)]` on by default
   = note: call `drop(from_raw(ptr))` if you intend to drop the `Box`
2022-08-10 10:27:27 +00:00
Sebastian Dröge 2cb7fc8122 gstreamer: Add GstParamSpecBuilderExt trait to easily allow setting controllable, mutable-ready and other extension flags 2022-08-10 12:28:05 +03:00
Sebastian Dröge 446f09fec6 gstreamer: Implement new ParamSpecBuilderExt trait from glib 2022-08-10 12:03:51 +03:00
François Laignel 2d17d46c50 gst: use Signed where applicable 2022-07-18 23:26:20 +02:00
François Laignel 414222aa99 gst/format: Signed wrapper
Functions such as Segment::to_running_time_full replicate the C
signature for the return type: an integer indicates whether the
resulting value must be interpreted as positive or negative.
In Rust, alternatives are usually represented using an enum.

This commit implements an enum wrapper to represent the sign
and adds functions to FormattedValue to ease Signed handling.
2022-07-18 23:26:20 +02:00
Sebastian Dröge b5920ee729 Regenerate with latest gir 2022-07-18 13:25:36 +03:00
Sebastian Dröge cf1a64ecf8 gstreamer: Hide some useless enum variants that only make sense in C 2022-07-18 13:13:48 +03: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 865df62f8d gst/format: add CompatibleFormattedValue
The trait CompatibleFormattedValue can be used to check argument
compatibility to a certain Format. This is convenient to define
function which accept several FormattedValues which must hold
values of the same Format.

This trait enforces format compatibility at compilation time for
SpecificFormattedValues and at runtime when a GenericFormattedValue
is provided.

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
Paolo Borelli f2a2e6702c caps: add new_empty_simple constructor 2022-07-05 14:49:21 +02:00
Sebastian Dröge 4dade30f0d Fix/silence a couple new clippy warnings 2022-06-30 13:08:33 +00:00
Sebastian Dröge 65629426cb tracer: Add bindings for new pad chain hooks 2022-06-30 08:46:06 +03:00
Sebastian Dröge 90aaa32957 Regenerate 2022-06-30 08:46:06 +03:00
Sebastian Dröge c61d913ec6 tracer: Add support for the 1.20 "plugin-feature-loaded" hook 2022-06-29 10:13:59 +03:00
Sebastian Dröge 9e77ab3212 tracer: Re-order trait functions slightly for the order to make more sense 2022-06-29 10:13:36 +03:00
Sebastian Dröge 14f485d0b1 bus: Take ownership of the message in post() 2022-06-28 23:36:08 +03:00
Sebastian Dröge 20ac231146 gstreamer: Allow borrowing Segments from Values without copying 2022-06-27 22:28:49 +03:00
Sebastian Dröge c9d07219c8 Store whether GStreamer was initialized in an AtomicBool
Avoids a function call in the normal case.
2022-06-27 10:28:28 +03:00
Sebastian Dröge b28664ccbd gstreamer: Fix serde serialization tests
ron serialization is now writing `1.0` instead of just `1`.
2022-06-24 11:13:06 +03:00
Stephan Seitz c254c5fd1a gstreamer: add PadProbeId::as_raw()
This allows to convert PadProbeId to numberic values without
taking them by value (like `into_glib`).

See https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/issues/382#note_1391236
2022-05-23 08:19:47 +00:00
Sebastian Dröge cb1f08a425 gstreamer: Implement FusedFuture for PromiseFuture 2022-05-22 12:42:42 +03:00
Sebastian Dröge aaf601831e gstreamer: Index structures/taglist more safely
Accessing after the length will lead to a critical warning and should
not happen.
2022-05-22 12:42:42 +03:00
Sebastian Dröge d4430ecc6a Implement more iterator functions / traits in custom iterators for efficiency reasons 2022-05-22 12:42:42 +03:00
Philippe Renon 8f1c94f45d Regenerate with latest gir 2022-05-20 17:48:40 +02:00
Sebastian Dröge e76ae3f434 gstreamer: Fix a few new clippy warnings 2022-05-20 11:19:07 +03:00
Philippe Renon 5d2f36fac3 gstreamer: implement FromGlibPtrBorrow trait for gst::Structure
needed for callbacks that pass GstStructure by reference
for example: the PlaySignalAdapter error and warning signals

needed by https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1036
2022-05-17 23:19:35 +02:00
Sebastian Dröge 45e16f7753 gstreamer: Add #[must_use] annotation to PadTemplateBuilder 2022-05-08 11:41:54 +03:00
Guillaume Gomez c1d3ed5eac Use IntoGlibPtr trait instead of implementing into_ptr 2022-05-07 13:38:11 +02:00
Sebastian Dröge cd49659fae gstreamer: Add a PadTemplateBuilder
And only allow setting documentation caps via that. It's not actually
allowed to update the documentation caps at random times as it is not
thread-safe.
2022-05-06 16:57:06 +03:00
Sebastian Dröge 0aa59be45c gstreamer: Improve accessors to various pad template fields 2022-05-06 16:22:40 +03:00
Sebastian Dröge 45856ac35b gstreamer: Return a glib::List instead of a Vec for the pad template list
Avoids an unnecessary allocation for the `Vec`.
2022-05-06 12:42:52 +03:00
Vivienne Watermeier 1b22be2e15 Add De/Serialization for most bitflag types
Represents combinations of flags with a '+' separated string of nicks,
or an empty string for no flags set.

Note that most flag types will ignore any flags using multiple bits when
serializing, since in most cases these flags cover all used bits.
2022-05-06 09:05:52 +00:00
Vivienne Watermeier 94b5a13f4b Regenerate with Gir.toml changes 2022-05-06 09:05:52 +00:00
Sebastian Dröge 4a28a188d9 Regenerate with latest gir/gir-files 2022-05-03 15:37:25 +03:00
Sebastian Dröge 2b7a63fc8e gstreamer: Implement FusedStream for the Bus stream 2022-04-30 21:10:59 +03: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
Jan Alexander Steffens (heftig) 7d2ab1450e gstreamer: Export subclass::TaskPoolFunction
This must be accessible in order to subclass TaskPool.
2022-04-07 17:57:59 +00: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 9a8ca0cadd gstreamer: Add bindings for the new 1.22 selectable query 2022-04-06 10:18:48 +03:00
Sebastian Dröge 627f4d798e gstreamer: Get rid of some duplicated feature cfg attributes 2022-04-06 10:18:48 +03:00
Sebastian Dröge bcf4f63ac6 gstreamer: Don't make the bitrate query available at all with v1_16 2022-04-06 09:51:19 +03:00
Sebastian Dröge b36b63c60a Regenerate with latest gir files 2022-04-06 09:38:34 +03:00
Sebastian Dröge 23e4d1efa8 Regenerate with latest GStreamer gir files 2022-04-05 19:49:05 +00:00
Sebastian Dröge 8d03a0d032 gstreamer: Complete the Task bindings 2022-04-04 18:56:25 +03:00
Sebastian Dröge 4d002786ec gstreamer: Don't re-export traits from the crate root 2022-04-04 08:51:04 +00:00
Sebastian Dröge 73ab9054c4 Don't use unnecessary RefCell wrappers for FnMut callbacks
They don't add any safety as this is via unsafe code anyway and are not
needed to get mutable references in this context anyway, while adding a
bit of runtime overhead.
2022-04-03 11:15:19 +03:00
Jan Alexander Steffens (heftig) b7afdd4dd0
gstreamer: Add TaskPool bindings and subclassing
Fixes: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/issues/14
2022-03-30 23:01:21 +02:00
Jan Alexander Steffens (heftig) 44b2eba600
Update gir 2022-03-30 22:36:53 +02:00
Sebastian Dröge 07be60a22f Don't unnecessarily borrow dereferenced values explicitly
warning: this expression borrows a value the compiler would automatically borrow
  --> gstreamer-rtsp-server/src/rtsp_session_pool.rs:16:5
   |
16 |     (&mut *func.borrow_mut())(&from_glib_borrow(pool)).into_glib()
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^ help: change this to: `(*func.borrow_mut())`
   |
   = note: `#[warn(clippy::needless_borrow)]` on by default
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
2022-03-24 12:40:52 +02:00
Sebastian Dröge 609a744d6c Regenerate autogenerated bindings 2022-03-17 18:05:13 +02:00
Sebastian Dröge 12f1483d43 gstreamer: Create plugins with version 1.21 if v1_22 is selected 2022-03-17 11:06:26 +02:00
Christian Meissl 44d39f8824 Add infrastructure for casting from/to memory subtypes 2022-03-12 14:19:40 +00:00
Sebastian Dröge b69043d462 gstreamer: Require Send and not Sync for the values of an Array / List
`Sync` is more than required here: only sending of the values to another
thread is required.
2022-03-08 14:46:13 +02:00
Sebastian Dröge 1f7a0f29d9 gstreamer: Update for optional glib::Value type refactoring 2022-03-07 13:20:08 +02:00
Sebastian Dröge 0f22eb7633 Remove now unnecessary Send+Sync impls for element/etc subclasses
This is now automatically implemented.
2022-02-28 18:25:15 +02:00
Sebastian Dröge 319f1c68a5 gstreamer: Simplify and speed up log message string construction
For pre-1.20 simply use `%s` as format string instead of escaping the
`%` inline while writing. This allows a simpler implementation and is
also faster, see https://github.com/gtk-rs/gtk-rs-core/pull/583.
2022-02-26 13:33:00 +02:00
Sebastian Dröge fc1185b951 gstreamer: Add builders for the fraction/array paramspecs 2022-02-22 00:00:39 +02: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
Marijn Suijten 462e19dee9 gstreamer/plugin_1_14: Use minor version 20 instead of 19 for v1_20
Now that gstreamer 1.20 is out all v1_20 plugins will be linked against
the 1.20 stable release, not the unstable 1.19 development release.
2022-02-18 11:33:17 +01:00
Sebastian Dröge d68c359db5 gstreamer: Fix downcast_ref() / downcast_mut() impls on MiniObjectRef
They have to return the `Ref` type and not the owned type.
2022-02-16 12:13:19 +02:00
Sebastian Dröge a1fed48e8c gstreamer: Add Debug impl for MiniObject / MiniObjectRef 2022-02-16 12:13:03 +02: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
Christian Meissl 033dac2270 support for subclassing buffer pool 2022-02-08 15:59:55 +01:00
Sebastian Dröge 0173b73170 Handle empty slices correctly
Passing `NULL` to `slice::from_raw_parts` is invalid.
2022-02-07 12:50:37 +02:00
Sebastian Dröge 47ae1c8658 Regenerate with latest gir files 2022-02-04 12:35:01 +02:00
Sebastian Dröge deced8b3b8 Regenerate with latest GStreamer gir files 2022-01-29 18:17:26 +02:00
Sebastian Dröge 26f2ed30ae Regenerate with latest gst-gir-files 2022-01-25 13:10:58 +02:00
Sebastian Dröge 06cf5de45f Get rid of fragile dependency and use GLib API instead 2022-01-24 19:33:15 +02:00
Sebastian Dröge 13eb483444 Regenerate everything with latest gir 2022-01-24 19:29:18 +02:00
Sebastian Dröge eecce101da gstreamer: Implement FromValue for mini object references 2022-01-24 13:13:24 +00:00
Sebastian Dröge b66a00ed07 gstreamer: Minor cleanup 2022-01-24 14:48:36 +02:00
Sebastian Dröge ab0eb8a1a4 gstreamer: Add bindings for gst_debug_log_get_line() 2022-01-24 14:48:21 +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
Sebastian Dröge 68d492bb33 gstreamer: Mark Structure and CapsFeatures as #[repr(transparent)] too 2022-01-17 19:42:20 +00:00
Jan Alexander Steffens (heftig) fb56bbda6e gstreamer: Split parsers for owned and borrowed views
When we have a view like `Caps<&EventRef>`, we can return a `CapsRef`
borrowing from the wrapped `EventRef`. This way, the `CapsRef` we return
can outlive the view itself.

This is in contrast to a `Caps<Event>` view which owns the `Event`.
Here, the `CapsRef` we return cannot outlive the view.

gstreamer-rs 0.18 consolidated code and treated everything like the
latter case. Fix this by duplicating the accessors for each case.

Fixes: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/issues/367
2022-01-17 19:13:47 +00:00
Sebastian Dröge 8f5e373882 gstreamer: Mark miniobject wrapper types as #[repr(transparent)]
That way they're treated everywhere exactly like a raw pointer.
2022-01-17 18:04:40 +00:00
Sebastian Dröge 8fa1076dfa Replace Foo::from_instance(foo) with foo.imp() 2022-01-17 19:34:06 +02:00
Sebastian Dröge 711a4bb76e gstreamer: Silence a new clippy warning in the tests 2022-01-14 12:58:26 +02:00
Sebastian Dröge 605c633579 Ignore clippy::non_send_fields_in_send_ty lint
It's useless in its current shape and wrongly triggering on all types.

See https://github.com/rust-lang/rust-clippy/issues/8045
2022-01-13 23:38:11 +02:00
Sebastian Dröge 9eb479cf78 Regenerate everything 2022-01-12 15:40:36 +02:00
Sebastian Dröge 843d3749b7 caps: Add bindings for foreach(), map_in_place() and filter_map_in_place()` 2022-01-11 13:37:40 +00:00
Sebastian Dröge 1b46bca2db structure: Add bindings for foreach(), map_in_place() and filter_map_in_place()` 2022-01-11 13:37:40 +00:00
Sebastian Dröge 6d63180bfc Update for glib::Quark API changes 2022-01-11 12:50:13 +02:00
Guillaume Gomez ac9b1e881c Add missing #[must_use] attribute for clippy 2022-01-04 19:43:07 +01:00
Guillaume Gomez 27dd305cb4 Regen to get #[must_use] attributes generated 2022-01-04 19:02:58 +01:00
Sebastian Dröge bbcd221e8d Change from impl_() to imp() 2021-12-28 17:50:06 +02:00
Sebastian Dröge 1e18c59d2a Implement glib::ValueTypeOptional for various types 2021-12-16 17:40:39 +00:00
Luca BRUNO c30eff771a
Regenerate with latest gir (gboolean return codes) 2021-12-14 11:43:30 +00: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 9bf5f641ff Regenerate with latest gir 2021-12-12 17:54:20 +02:00
Sebastian Dröge 1541fbf32a gstreamer: Add many new doc aliases for C function 2021-12-12 17:52:32 +02:00
Luca BRUNO d1cc8d1298
Regenerate with latest gir (assert safe gerror) 2021-12-07 12:07:45 +00:00
Sebastian Dröge ee1a5e8395 Add #[must_use] attribute to many builders 2021-12-04 10:26:08 +02:00
Sebastian Dröge f6dc14b946 Add a few missing docs aliases for constants 2021-12-03 10:19:22 +02:00
Sebastian Dröge 7d968d78bb Silence false needless_option_as_deref clippy warnings
See https://github.com/rust-lang/rust-clippy/issues/8047
2021-12-02 17:52:23 +02:00
Mathieu Duponchelle 8e6c08f8fd gstreamer/value_serde: fix nested structures
When serializing a structure, if it contains a nested structure
the serialization / deserialization code goes through value_serde,
which was lacking support for Structure.
2021-12-01 17:41:48 +00:00
Sebastian Dröge c965217e54 gstreamer: bufferlist: Implement buffer foreach functions around ControlFlow enum
This makes it clearer than a plain `bool` or `Result<Option<Buffer>, Option<Buffer>>`.

Also pass a `&Buffer` instead of a `&BufferRef` to the immutable foreach
function to allow taking references of the buffer outside the scope of
the closure by cloning instead of requiring a full copy.
2021-12-01 14:16:33 +02:00