Commit graph

1359 commits

Author SHA1 Message Date
Sebastian Dröge
3cd902513d Update for glib::Object::new() API changes 2022-10-07 21:45:01 +03:00
Sebastian Dröge
dcd53bd16e Regenerate with latest gir 2022-10-07 20:30:24 +03:00
Sebastian Dröge
c64b6ac68b tracer: Use Results instead of plain success/failure enums
This makes it more convenient to handle the success/failure cases in
tracer implementations and is more consistent.
2022-10-02 10:45:14 +03:00
Sebastian Dröge
ade0aad6b0 tracer: Make buffer in pull-range-post function optional
Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/issues/410
2022-10-02 10:36:05 +03:00
François Laignel
bff1354b74 gst/format: module doc 2022-10-01 13:16:06 +02:00
François Laignel
e2fe1d6371 gst/format: macros minor cleanups 2022-10-01 13:16:06 +02:00
François Laignel
57d8d46ab6 gst/format: fix some ops and add others
Some operations were implemented on types that wouldn't result in
the expected physical unit. E.g.:

- `ClockTime / ClockTime` results in a unit-less factor.
- `u64 / ClockTime` would result in a `1 / ClockTime`. Since we don't
  use any `Frequency` type, this operation is removed. Users should
  use the `ClockTime` accessors to compute the expected value.

This commit also adds:

- multiplications with integers as the left hand side operands.
- `Partial{Eq,Ord} for `Signed<T>` with `T` as left hand side operand.
- `opt_add` / `opt_sub` for `Signed<T>` with `T` as left or right hand
   side operands.
- missing tests for `Partial{Eq,Ord}` and `OptionOrd`.

This implementation can interfere with unrelated code and was removed:

- `Signed<usize>.` `PartialOrd` makes existing code computing the len
  of slices needing type annotation because the len is later used in
  a comparison for which the compiler is unable to determine if
  the len is `Signed<usize>` or `usize`.
2022-10-01 13:15:11 +02:00
François Laignel
eb4d997f0a gst/format: shuffle types and traits 2022-10-01 00:49:42 +02:00
François Laignel
79377337a4 gst/format: move related modules under a directory 2022-10-01 00:49:39 +02:00
69ea30dbda
gstreamer: meta: Allow to register custom meta without transform function 2022-09-29 14:05:35 +02:00
François Laignel
99e344af4d gst/format: simplify some ops impl
The `SpecificFormattedValue` types are newtypes of `u64` or `u32`
and they all implement `Copy`. It shouldn't be needed to implement
operations on `&Type` nor `&inner_type`.
2022-09-22 00:05:28 +02:00
François Laignel
86549dc06e gst/Segment: return immediately from some functions...
... if the input `is_none`.
2022-09-21 17:20:43 +00:00
François Laignel
8595b67218 gst/Signed: impl option-operations traits 2022-09-21 17:20:43 +00:00
François Laignel
183a399d1d gst/Signed: impl MulDiv 2022-09-21 17:20:43 +00:00
François Laignel
2b4fcb131e gst/Signed: impl div & mul 2022-09-21 17:20:43 +00:00
François Laignel
1411c9e35e gst/Signed: use a new trait for into_{signed,positive,negative}
The functions `into_{signed,positive,negative}` used to be implemented
on the `FormattedValue` trait for convenience. This was wrong for the
following reasons:

- They aren't specific to `FormattedValue`s: they can also be
  implemented for regular unsigned integers such as `u64`, `usize` or
  `u32`.
- They were implemented for `format::Undefined` and all variants of
  `GenericFormattedValue`, some of which are already signed.

This commit introduces the new trait `UnsignedIntoSigned`, which makes
it possible to fix both of the above problems.

Users can build a `Signed` from an `Undefined`, an `i64`, `isize` or
`i32` thanks to the `From` trait implementations.
2022-09-21 17:20:43 +00:00
François Laignel
960befb2f5 gst/Signed: move signed ops macro to macro.rs
This will help with the implementation of Signed muls & divs for
`FormattedValue`s since we need to know about the inner types.
2022-09-21 17:20:43 +00:00
François Laignel
0d229b4c69 gst/format: separate non trait ops format macros from common ops 2022-09-21 17:20:43 +00:00
François Laignel
432cb36611 gst/Signed: add tests and fix some ops impl 2022-09-21 17:20:43 +00:00
François Laignel
8e6afe147e gst/Signed: impl Display and Displayable 2022-09-21 17:20:43 +00:00
François Laignel
a1dbc7a0ee gst/format: use fmt::Display whenever possible
Previous implementation for the glib format new types built a
`String` for the displayable value. This commit uses `fmt`
mechanisms so as to limit useless allocations.
2022-09-21 17:20:43 +00:00
François Laignel
e0d9f886e3 gst/format: add Signed::{positive, negative}
It's more convenient to use than:

```rust
    signed_val.positive_or(()).ok()
```
2022-09-21 17:20:43 +00:00
François Laignel
55ef309b16 gst/ClockTime: panic building from GST_CLOCK_TIME_NONE
Using `ClockTime::from_nseconds` it was possible to build a valid
`ClockTime` which would match `GST_CLOCK_TIME_NONE` when passed to
the C API, leading to unexpected behaviour as `GST_CLOCK_TIME_NONE`
is represented as an `Option::<ClockTime>::None` in Rust.

This commit panics when this function is called with
`GST_CLOCK_TIME_NONE` (defined as `u64::MAX`). This is similar to
what happens when calling other `ClockTime` constructors (e.g.
`from_seconds`) with too large a value: the internal multiplication
overflows leading to a panic.
2022-09-21 17:20:43 +00:00
François Laignel
b8e1c25c85 gst/log: log arg eval fix non regression test 2022-09-21 17:20:43 +00:00
Sebastian Dröge
64829ac47a gstreamer: Use type parameters instead of trait objects for TypeFindFactory::call_function()
No need to do dynamic dispatch here.
2022-09-16 11:26:24 +03:00
Sebastian Dröge
1b10c5324d gstreamer: Add BinImpl::do_latency() 2022-09-16 06:54:55 +00:00
Sebastian Dröge
8a6de3ca4f gstreamer: Implement various operations on Signed for working with it more easily 2022-09-14 12:20:47 +03:00
François Laignel
f294339240 log: differ formatted args evaluation
When the `format_args!` macro is used, formatted args are evaluated
in order to form the argument collection that ends up being formatted
when requested to do so.

For the log macro, this means that any argument that is an expression
was evaluated even if the log level was below current threshold. This
can be examplified by the following code:

```rust
    gst::debug!(CAT, "{}", {
        println!("fmt arg executed");
        "A debug log"
    });
```

This used to print "fmt arg executed" even when the log threshold for
`CAT` was filtering `debug` out.

Note that this could break existing code that would incorrectly rely
on the side effect.
2022-09-13 19:25:14 +02:00
Sebastian Dröge
dec112d0a8 Regenerate with latest gir/gir-files/gst-gir-files 2022-09-13 12:13:07 +03:00
François Laignel
f014505e1c regen: rename feature 'ser_de' as 'serde' 2022-09-12 19:36:32 +02:00
François Laignel
069c6a2c01 Rename feature 'ser_de' as 'serde'
When I introduced the 'ser_de' feature, I couldn't find a way to
name it 'serde' while also make it pull the optional 'serde'
crate together with the other related dependencies.

With rustc >= 1.60 we can use 'dep:serde' to refer to the 'serde'
dependency as part of the 'serde' feature.
2022-09-12 19:36:30 +02:00
Sebastian Dröge
efe13948cc ci: Update gst-gir-files and bring autogenerated code in sync 2022-09-04 20:51:07 +03:00
Sebastian Dröge
35c6af424d Update minimum supported Rust version to 1.63 2022-09-04 10:37:13 +03:00
Sebastian Dröge
201eed8400 gstreamer: Sync param spec API with glib 2022-09-04 10:34:05 +03:00
Sebastian Dröge
44d899a0eb Regenerate with latest gir / gir-files / gst-gir-files 2022-08-31 11:13:08 +03:00
Guillaume Desmottes
e229288ecd gstreamer: manually implement Debug on PromiseReply
The default implementation was not very useful:

PromiseReply(
    Promise {
        inner: Shared {
            inner: 0x00007ff108001090,
        },
    },
)
2022-08-29 08:59:21 +00:00
Guillaume Desmottes
1e24e2d133 gstreamer: caps: improve Debug implementation 2022-08-25 10:54:16 +02:00
Guillaume Desmottes
0c9158f404 gstreamer: taglist: improve Debug implementation 2022-08-25 10:54:16 +02:00
Guillaume Desmottes
64c09353b7 gstreamer: structure: improve Debug implementation
g_strdup_value_contents() output is not easily readable with nested
structures
2022-08-25 10:54:16 +02:00
Thibault Saunier
e9d95eda59 gstreamer: Add extension trait to mark API as plugins API
This adds an extension trait implemented for GType so we can
add and check plugins API status.
Required so we can document plugins written in rust.
2022-08-24 10:38:06 -04:00
Sebastian Dröge
76f01516e3 Regenerate with latest GStreamer gir files 2022-08-19 19:42:05 +03:00
Sebastian Dröge
8d9abb935b gstreamer: Update to ron 0.8 2022-08-16 13:09:49 +03:00
François Laignel
be2de21602 Update option-operations to 0.5.0
This fixes the trait `OptionEq` not being exported in `prelude`.
2022-08-15 22:44:53 +02:00
Sebastian Dröge
fbad0fd0bc Regenerate with latest gir / gir-files / gst-gir-files 2022-08-14 14:02:50 +03:00
Guillaume Desmottes
c5d19e7c80 miniobject: implement ptr_eq() on ref type 2022-08-12 11:15:08 +02:00
Guillaume Desmottes
c0fd8a8aad gstreamer: add BufferRef::ptr_eq() 2022-08-12 08:29:49 +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
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