Commit graph

221 commits

Author SHA1 Message Date
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
Sebastian Dröge eda1d3d4a7 Update for Value trait refactoring 2021-04-25 14:45:08 +03:00
Sebastian Dröge d746bf91e1 gstreamer: Provide better bindings for ElementFactoryListType
Make it an actual bitflags type instead of just an u64 alias and add all
the constants. As it's not defined as bitflags in C this needs to be
done manually.
2021-02-19 12:56:54 +02:00
Marijn Suijten 89c7883202 gstreamer: Automatically generate Allocator::alloc
Parameter mutability has been fixed (and reverted, hence overridden with
const=true)for this function in gstreamer; it can now be automatically
generated.
2021-02-15 20:19:38 +01:00
Sebastian Dröge ea0eb4fa70 gstreamer/paramspecs: Add bindings for GST_PARAM_CONTROLLABLE and related custom paramspec flags 2021-01-25 13:56:55 +02:00
Sebastian Dröge 68839c0e79 Re-export all dependency crates and their preludes
This makes code in examples potentially simpler.
2020-12-20 19:40:34 +02:00
Guillaume Gomez ff5a36561a Fix license header situation 2020-12-15 11:53:31 +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
Sebastian Dröge 9d9522016b gstreamer: Update manual code to 2018 edition 2020-11-22 19:15:20 +02:00
Marijn Suijten e88994a0b7 use cfg_if to refactor some #[cfg()] / #[cfg(not())] pairs 2020-11-19 16:39:31 +01:00
Marijn Suijten bd75778fcb Add doc(cfg()) on all manual files 2020-11-19 16:39:31 +01:00
Marijn Suijten 3f373f623a Enable feature(doc_cfg) in all lib.rs
The next version of gir is going to generate doc(cfg()) attributes on
many symbols to show feature-dependence hints. While autogenerated sys
crates get this attribute in their own (generated) lib.rs file the safe
wrapper crates do not have such an autogenerated lib.rs file.
2020-11-19 16:39:31 +01:00
François Laignel 9fb0c4937b ProxyPad: impl ExtManual functions as trait functions, not associated functions 2020-11-17 16:35:31 +01:00
Sebastian Dröge 027de84349 Update for class struct handling changes in the glib bindings
See https://github.com/gtk-rs/gtk-rs/pull/10
2020-11-05 16:41:48 +02:00
François Laignel ae9d97dfca ClockTime & opt Formats: fix PartialOrd impl, remove Ord and add min & max
- `PartialOrd` was returning `true` for expressions such as
  - `ClockTime::none() < ClockTime::from_seconds(1)`.
  - `ClockTime::from_seconds(1) > ClockTime::none()`.
- Remove `Ord` because `ClockTime` is not a total order due to
  `ClockTime::none()`. See test `not_ord`.

This also applies to others `Format(Option<{u32,u64}>)` types.
2020-10-20 23:40:18 +02:00
Sebastian Dröge 531014a35c gstreamer/clock: Improve ClockId bindings
There is now a separate type for Single and Periodic clock ids. This
allows to have API that is only for one type on that specific type
instead of doing runtime checks, and allows for more refined async
waiting API.
2020-10-10 10:25:44 +00:00
Alexey Galakhov 4120ded424 Add gstreamer-controller 2020-09-30 16:28:51 +00:00
Sebastian Dröge af01f1bc67 gstreamer: Simplify MiniObject bindings by removing one layer of abstraction
And instead directly implementing this via the macro on the target
types.
2020-06-30 11:06:02 +03: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
Sebastian Dröge ede4588e0c gstreamer: Add bindings for ProtectionMeta 2020-06-02 16:05:01 +03:00
Sebastian Dröge 834b6d8d69 gstreamer/proxypad: Convert default pad functions to plain functions on ProxyPad instead of a trait
This allows to use them properly when overriding these functions.
2020-04-23 15:37:18 +03:00
Sebastian Dröge aea43c428c gstreamer: Add Stream::debug() and StreamCollection::debug()
These provide more helpful debug output than just the pointer when
printing.
2020-04-14 17:31:54 +00:00
Sebastian Dröge 42d09c2834 gstreamer/buffer: Move BufferCursor/BufferRefCursor into its own module
It's quite a bit of code and can be kept nicely separate.
2020-04-07 12:59:24 +03:00
Sebastian Dröge 5fc68e252d gstreamer: Add missing BufferCursorRef re-export 2020-04-06 21:00:42 +03:00
Sebastian Dröge a884a419db gstreamer/buffer: Add a BufferCursor / BufferCursorRef helper structs
This implements Read/Seek or Write/Seek and allows to read/write/seek
into the buffer without merging the memories inside.

The writer also only maps the memory write-only as compared to all other
ways of accessing the buffer/memory data in a writable way, which have
to map it read-write.

See https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/425
for a similar API proposal for GStreamer core.
2020-04-06 20:15:35 +03:00
Sebastian Dröge d7e6c2e37f gstreamer/pad: Add support for filling the passed in buffer in the getrange function
Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/issues/242
2020-04-02 19:58:09 +03:00
Sebastian Dröge cddccf9502 gstreamer/promise: Add Future constructor for Promise
This returns a tuple that basically works like a oneshot channel: the
Promise acts as the "sender" and once the promise resolves the
"receiver" contains the result.
2020-02-09 19:08:41 +02:00
Valmir Pretto 6263922b6d gstreamer: BusStream tests 2020-02-04 10:33:34 -03:00
Valmir Pretto 7663589d94 gstreamer: BusStream cleanup
A few small readability changes
2020-02-04 10:33:25 -03:00
Sebastian Dröge 63a8afafa5 gstreamer: Use more accurate types for Seqnum, GroupId and MetaSeqnum
For the latter introduce an actual opaque type that allows using them
for comparison purposes but is not just a plain u64.

For the former represent them as opaque type around an NonZeroU32. 0 is
the invalid case and does not happen in the majority of functions. Where
it can happen, represent this case by using an Option<_> instead.

This makes it harder to mis-use these types.

Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/issues/209
2020-01-25 00:07:36 +02:00
Sebastian Dröge 7230aee069 Switch everything from lazy_static to once_cell::Lazy
Fewer macros, faster compile-time and the Lazy type will likely end up
in the standard library in a similar form to this.
2020-01-22 19:57:41 +02:00
Sebastian Dröge b17f04e866 bus: Make bus Stream private and add functions on the bus directly for it
Also add a helper function that allows filtering the stream directly.
2020-01-22 10:05:36 +02:00
Sebastian Dröge aa29567171 gstreamer/element: Add call_async_future() that returns a future
The future would resolve into the return value of the closure that is
called asynchronously on the thread pool, and allows asynchronous
awaiting for it to finish.

  let res = element.call_async(|element| {
      element.set_state(gst::State::Playing)
  }).await;

  assert_eq!(res, Ok(gst::StateChangeSuccess::Success))
2020-01-20 12:03:59 +02:00
Guillaume Desmottes 01c4d08501 gstreamer: use thiserror crate
Make code simpler and fix deprecated warning when building on nightly as
Error::description is being deprecated.
2020-01-10 18:54:50 +05:30
Guillaume Desmottes c298577139 gstreamer: add MemoryRef::dump() 2019-12-24 09:15:34 +05:30
Sebastian Dröge 0c944cb26e gstreamer: Add documentation to gst::deinit() about when it's safe to be called 2019-11-14 12:11:10 +00:00
Sebastian Dröge 77c6741ae0 Update to futures 0.3 and require Rust 1.39
Also use async/await in the futures examples.
2019-11-11 12:18:49 +01:00
Guillaume Gomez 9e30687d8e Fix glib reexports 2019-11-11 11:34:09 +01:00
Sebastian Dröge 2d2459ed52 Export traits from the crate level and ensure that all traits are in the preludes 2019-10-17 13:30:35 +03:00
Sebastian Dröge bacf4998ce clock: Add some more ClockId API for being able to implement clock subclasses 2019-09-25 17:22:15 +03:00
Sebastian Dröge 52509b4b95 Remove subclassing feature and make it the default 2019-09-09 11:51:07 +03:00
Jan Alexander Steffens (heftig) a30935ad1f
Iterator: Add a wrapper implementing std's Iterator
Transposing the item type lets us be a std-compatible Iterator.

The iterator is automatically resynced when resuming iteration after
yielding Resync. This lets some combinators like `collect` and `find`
work properly.
2019-09-04 14:34:05 +02:00
Sebastian Dröge ae58a469d1 meta: Add support for ReferenceTimestampMeta 2019-07-14 22:32:10 +03:00
Sebastian Dröge b87ffa17bb Run rustfmt also over all the generated code 2019-06-18 13:12:00 +03:00
Guillaume Desmottes 7a69a1137c gstreamer: plugin_feature: use Rank enum 2019-06-04 12:56:18 +03:00
Sebastian Dröge 004ce5d392 gstreamer: Re-export the paste crate for the gst_plugin_define! macro
And only depend on the paste crate if the subclass feature is requested.
2019-05-27 22:46:26 +02:00
Vivia Nikolaidou 32e1d68d36 allocator: Expose GstAllocator 2019-05-24 10:32:57 +00:00
Vivia Nikolaidou 922af1d606 Add GstMemory bindings
Part of https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/issues/12
2019-05-24 10:32:57 +00:00
Sebastian Dröge b5dcbe3897 gstreamer/proxypad: Move default functions to extension trait 2019-05-24 10:04:16 +00:00
Vivia Nikolaidou 496fc61873 pipeline: Add to lib.rs 2019-05-12 16:41:18 +03:00
Vivia Nikolaidou 05d936fcee gstreamer: Add binding for GstMessageType and gst_bus_timed_pop_filtered
Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/issues/168
2019-05-10 19:35:13 +03: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 9d79280929 Add some more functions for generically handling tags 2019-01-23 15:54:00 +02:00
Sebastian Dröge 598e012568 Add bindings for gst::tags::register() 2019-01-23 15:52:51 +02:00
François Laignel 84ba2d7971 Use dedicated type DeviceMonitorFilterId
See https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/issues/174
2019-01-19 14:52:15 +01:00
Sebastian Dröge bfcdec782e Switch to stable rustfmt and add skip annotations for the generated code to the lib.rs 2019-01-16 17:10:01 +02: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 d780b92f21 Use an extension trait instead of a custom type for the GStreamer param specs
This way they can simply be created via glib::ParamSpec::fraction() for
example.
2018-12-11 12:37:15 +02:00
Sebastian Dröge 1515707655 Add bindings for the array/fraction param spec constructors 2018-11-29 19:18:45 +00:00
Sebastian Dröge d2b911a629 Port GhostPad subclassing 2018-11-21 16:14:06 +02:00
Sebastian Dröge ec2a0635ca Port Pad subclassing 2018-11-21 16:14:06 +02:00
Sebastian Dröge 97211e869b Port Pipeline subclassing 2018-11-21 16:14:06 +02:00
Sebastian Dröge 55dac7eeb4 Port Bin subclassing 2018-11-21 16:14:06 +02:00
Sebastian Dröge 56319f9294 Move subclassing infrastructure into the main bindings
And port Element bindings to the new infrastructure.
2018-11-21 16:14:06 +02:00
Sebastian Dröge 0947c8f087 Rename gst::Bin traits from BinExt to GstBinExt to prevent conflicts with gtk::Bin 2018-10-28 11:30:41 +00:00
Sebastian Dröge cb23d20270 Implement support for buffer Metas
Fixes https://github.com/sdroege/gstreamer-rs/issues/103
2018-09-29 11:44:55 +03:00
Sebastian Dröge 6fd0ed4cb3 Move all minobjects to newtype wrapper types
For consistency with external crates and to help rustdoc, which gets
confused on impl blocks for type aliases.
2018-09-28 18:11:46 +03:00
Sebastian Dröge a43c78f2c5 Run everything through rustfmt 2018-09-28 13:15:18 +03:00
Sebastian Dröge 564f9faf84 Add support for CapsFeatures
Fixes https://github.com/sdroege/gstreamer-rs/issues/13
2018-09-28 13:15:18 +03:00
Philippe Normand 58741b7ea2 gstreamer: Implement deinit() function
This function is especially usefull when using the leaks tracer. It was removed
in commit e7a0543c.
2018-08-04 18:39:53 +03:00
François Laignel 0eb6bcf0c0 serde: restrain unneeded visibilities 2018-07-30 23:18:30 +03:00
François Laignel 9f2f684188 format: serde: avoid redundant () for some types 2018-07-30 23:18:30 +03:00
François Laignel 90b046fbcf serde: separate serde impl and tests from base module
+ fix erroneous `datetime` instead of `buffer` in `BufferRef::serialize`
+ remove ser/de for `Value`s with types `ULong` & `ILong`
2018-07-30 23:18:30 +03:00
François Laignel 862afe5cc7 Buffer: serde impl 2018-07-30 23:18:30 +03:00
François Laignel 778e11742f value: serde impl 2018-07-30 23:18:30 +03:00
François Laignel 0d65b7f1ed DateTime: serde impl 2018-07-30 23:18:30 +03:00
Sebastian Dröge 33a6aab6d7 Run everything through latest rustfmt 2018-07-27 13:36:40 +03:00
François Laignel be9ef0d152 Tags: implement generic iterators
This is the continuation of PR #107 by @ystreet
2018-07-12 07:22:39 +02:00
Sebastian Dröge e0972ae1e5 Get rid of manual usage of callback_guard! 2018-06-24 14:52:50 +03:00
Sebastian Dröge c31921e093 Further work-arounds for floating reference handling changes between 1.12 and 1.14
This fixes various memory-safety issues caused by broken reference
counting. We have to handle pre-1.14 and post-1.14 differently in
constructors.

See https://bugzilla.gnome.org/show_bug.cgi?id=743062#c30
2018-05-09 12:20:59 +03:00
Sebastian Dröge 2cefd9aea6 Re-run everything through rustfmt 2018-04-25 11:13:14 +03:00
Sebastian Dröge a276c226fd Port BusStream to futures 0.2 2018-04-23 20:27:17 +03:00
Sebastian Dröge 492c3d656c Run everything through rustfmt again 2018-04-01 11:57:58 +03:00
François Laignel cd56d60352 Bus::get_pollfd generate doc for both unix & windows
There are different implementations and signatures for `get_pollfd` depending
on whether the target platform is unix or windows. When generating the doc,
we need both implementations to appear regardless of the target platform. This
commit is inspired by the way Rust `std` library deals with `process::Command`
OS dependent variants
(https://doc.rust-lang.org/std/process/struct.Command.html#impl-CommandExt).

Documentation can't be accurate though as we can't use the`std::os::windows`
on `unix` and vice versa. As a workaround a fake fd class matching the other
platform is declared.

This could be further enhanced once `#[doc(cfg(...))]` is stabilized
(https://github.com/rust-lang/rust/issues/43781) by declaring `#[doc(cfg(unix))]`
or `#[doc(cfg(windows))]` instead of the hard coded comments `This is supported
on **Windows/Unix** only`. Unfortunately, these comments disappear when
generating will `--all-features` because they are not part of the documentation
in the gir file.
2018-03-19 13:48:59 +02:00
Sebastian Dröge 3a755219f4 Add Promise bindings 2018-03-19 10:32:07 +02:00
Sebastian Dröge 4864a1e089 Fix build 2018-03-19 10:32:07 +02:00
Sebastian Dröge de8f4694f5 Add initial BufferPool bindings 2018-03-07 11:08:21 +02:00
Sebastian Dröge a3b294f0f2 Add back callback guards 2018-03-02 21:34:29 +02:00
Sebastian Dröge f1426c82ba Remove callback guards
Since Rust 1.24 it is safe to let panics go to the FFI boundary
2018-02-17 19:58:41 +02:00
Sebastian Dröge ad219dd171 Remove PAD_PROBE_ID_INVALID and Default impls for PadProbeId and NotifyWatchId
These should never ever be 0, and passing 0 to any of the functions
using them will result in assertions.
2018-01-25 21:06:39 +02:00
Sebastian Dröge 9066cf0634 Add ErrorMessage type
This can be used to propagate an element error via a Result until the
place where it can be actually posted on an element.
2017-12-20 20:00:05 +02:00
Sebastian Dröge e0dc84c10a Run everything through rustfmt again 2017-12-20 19:30:14 +02:00
Sebastian Dröge 95c9f92549 Add StreamCollection::iter() 2017-12-20 18:54:56 +02:00
Sebastian Dröge 6d8cfa5de0 Add support for TypeFind and implement Ord on Rank and TypeFindProbability
Fixes https://github.com/sdroege/gstreamer-rs/issues/11
2017-12-19 19:14:12 +02:00
Sebastian Dröge 5108c941ed Various nullability fixes to plugin bindings, and add add_dependency() API
Also fix structure ownership for the cache data API
2017-12-17 14:26:17 +02:00
Sebastian Dröge 7065d1d884 Add constants for COPY_ALL and COPY_METADATA buffer copy flags 2017-12-16 17:40:47 +02:00
Sebastian Dröge c99928d030 Change FormatValue related API to be more convenient to use
FormatValue is now renamed to GenericFormattedValue and the API slightly
changed. In addition there is now a FormattedValue trait, and a
SpecificFormattedValue trait plus types for Bytes, Buffers and the
existing ClockTime.

This allows to create functions like
  Pad::query_duration<F: SpecificFormattedValue>() -> Option<F>
and doesn't require the caller to unwrap the generic value anymore,
which is completely unneeded in these cases.

In addition, Segment became FormattedSegment<T> with API to
upcast/downcast between the specific formatted values and the generic
formatted value. This greatly simplifies usage of Segments.
2017-12-09 19:45:18 +02:00
Sebastian Dröge 55f044dd83 Add newtype wrappers and INVALID constants for event/message GroupId and Seqnum 2017-12-05 21:33:04 +02:00