Commit graph

65 commits

Author SHA1 Message Date
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
Guillaume Desmottes c5d19e7c80 miniobject: implement ptr_eq() on ref type 2022-08-12 11:15:08 +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
Guillaume Gomez c1d3ed5eac Use IntoGlibPtr trait instead of implementing into_ptr 2022-05-07 13:38:11 +02: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 eecce101da gstreamer: Implement FromValue for mini object references 2022-01-24 13:13:24 +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
Guillaume Gomez ac9b1e881c Add missing #[must_use] attribute for clippy 2022-01-04 19:43:07 +01:00
Sebastian Dröge 1e18c59d2a Implement glib::ValueTypeOptional for various types 2021-12-16 17:40:39 +00:00
Sebastian Dröge 1856d47a06 gstreamer: Add bindings to MiniObject together with casting functionality
This is only possible with 1.20 because gst_mini_object_get_type() was
added then. Previous versions only provide bindings for the specific
types, like Caps, Event, etc.

Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/issues/353
2021-09-19 13:12:58 +00: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 10c93807fb Replace explicit type with Self in for_value_type::<> turbofish 2021-04-30 10:02:47 +02:00
Sebastian Dröge eda1d3d4a7 Update for Value trait refactoring 2021-04-25 14:45:08 +03:00
François Laignel 1395d773c3 manual fixes remove get prefix round 2 2021-04-20 18:18:02 +02:00
François Laignel 6ab9164dca fix-getters-calls 0.3.0 pass 2021-04-20 18:18:02 +02:00
Marijn Suijten 9cc488db4c gstreamer/miniobject: Make get_type function optional
Static typing is needed for `Value` interop, but not every type
(GLMemory in this instance) requires that.
2021-04-17 07:54:40 +00:00
Sebastian Dröge 8d983066f5 gstreamer: Store ffi::GstCaps inside gst::Caps and equivalent for other miniobjects
Simplifies code and prepares for the next changes.
2021-04-03 17:43:50 +03:00
Sebastian Dröge 53aae7ddba Remove gst_ prefix from all macros except for the logging macros
The latter stay e.g. gst_debug! to be more clear and not conflict with
e.g. the debug! macro from the log crate.
2020-12-20 19:40:34 +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 a6c8fe0c8a Use repr(transparent) where it is more correct and get rid of some unneeded repr(C) 2020-10-24 17:09:10 +00:00
Sebastian Dröge 4c216bca3a Remove unneeded PhantomData markers
And as a side-effect also get rid of the lifetime parameter of
gst::TypeFind that was completely unused anyway.
2020-10-24 17:09:10 +00:00
Sebastian Dröge dbc76f1053 gstreamer/miniobject: Remove DerefMut and AsMut impls
They were side-stepping the miniobject writability mechanism.
2020-06-30 15:23:50 +03: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 7086a754be Add various glib::Value trait impls for borrowed versions of types
For SDPMessageRef, StructureRef and CapsFeatureRef this involves the
conversion from and to a glib::Value. Specifically this means that e.g.
a StructureRef can be retrieved from a glib::Value via borrowing, i.e.
without creating a copy of the structure first.

For all mini objects only retrieval from a glib::Value is implemented as
the other direction would allow to get multiple immutable references
from a mutable reference without borrowing, which is not allowed and
would make it possible to observe a mini object changing while having an
immutable reference to it.
2020-05-27 13:17:54 +03:00
Guillaume Gomez c07fe14191 gstreamer*: Add missing init checks 2020-04-12 17:25:54 +03:00
Sebastian Dröge 62e9af58c6 Fix some clippy warnings 2020-04-11 21:18:18 +03:00
Sebastian Dröge 62c0f5ef42 Use mem::ManuallyDrop instead of mem::forget() everywhere
It makes the intentions clearer and potentially results in simpler
assembly, at least in debug builds.
2020-04-09 16:57:06 +03:00
Sebastian Dröge 019afd54f9 Update for new from_glib_borrow signature
See https://github.com/gtk-rs/glib/pull/605
2020-04-05 18:48:48 +03:00
Sebastian Dröge 9d5ae8ed14 gstreamer: Don't take mini objects by value for append() and similar operations
Compared to
  let foo = Foo::bar(foo);
the new form is easier to follow
  foo.bar();
2020-03-07 00:31:30 +02:00
Sebastian Dröge e6f65a5032 gstreamer/miniobject: ToOwned::to_owned() on references has to create a copy
Otherwise it's possible to create a new owned reference from a mutable
reference, and then there is a mutable and immutable reference to the
same data at the same time, which is simply not allowed.

https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/issues/204
2019-05-24 10:04:16 +00:00
Sebastian Dröge b2b8bfab52 Add manual implementations for various new 1.16 functions 2019-04-23 20:45:39 +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 fa988fe73d Make gst_define_mini_object_wrapper! macro work stand-alone without requiring specific names in scope 2018-12-08 12:53:10 +02:00
Sebastian Dröge 5d9a3b4272 Use ptr::add(i) instead of ptr::offset(i as isize) 2018-10-11 11:58:01 +03:00
Sebastian Dröge c56e9ddfea Also implement copy() returning the wrapper miniobject on the reference type
This way CapsRef::copy() will return a Caps, and not a GstRc<CapsRef>.
2018-10-05 16:36:15 +03:00
Sebastian Dröge 30b9527112 Implement ::copy() directly on miniobject wrapper types
This provides the additional wrapping as the one via get via deref will
only give back a GstRc<T> without the additional wrapping.
2018-10-03 16:54:00 +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 26ee546d1a Always derive Clone for miniobject wrappers 2018-09-28 17:42:52 +03:00
Sebastian Dröge 74024447fe Add macro to define newtype wrappers around MiniObjects
To allow implementing them in a meaningful way in external crates.
2018-09-28 17:37:27 +03:00
Sebastian Dröge 33a6aab6d7 Run everything through latest rustfmt 2018-07-27 13:36:40 +03:00
Sebastian Dröge e88017f914 Ensure that miniobjects are writable before creating a mutable borrow 2018-07-06 10:29:09 +02:00
Sebastian Dröge 492c3d656c Run everything through rustfmt again 2018-04-01 11:57:58 +03:00
Sebastian Dröge fca0287dec Use ptr::NonNull in various places 2018-04-01 11:29:55 +03: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 e1d134c4be Run everything through latest rustfmt-nightly 2017-10-17 12:06:51 +03:00
Sebastian Dröge 1f16a39ca4 Move gst_mini_object_copy() from GstRc<T> to MiniObject directly
It can also be called on the shallow references.
2017-10-12 17:58:46 +03:00