1 | // Take a look at the license at the top of the repository in the LICENSE file. |
2 | |
3 | use glib::{translate::*, Cast, IsA}; |
4 | |
5 | use crate::Allocator; |
6 | |
7 | impl Allocator { |
8 | #[doc (alias = "gst_allocator_register" )] |
9 | pub fn register(name: &str, allocator: impl IsA<Allocator>) { |
10 | skip_assert_initialized!(); |
11 | unsafe { |
12 | #[cfg (not(feature = "v1_22" ))] |
13 | { |
14 | // See https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3364 |
15 | if crate::version() < (1, 20, 5, 0) { |
16 | ffi::gst_allocator_register( |
17 | name.to_glib_full(), |
18 | allocator.upcast().into_glib_ptr(), |
19 | ); |
20 | } else { |
21 | ffi::gst_allocator_register( |
22 | name.to_glib_none().0, |
23 | allocator.upcast().into_glib_ptr(), |
24 | ); |
25 | } |
26 | } |
27 | #[cfg (feature = "v1_22" )] |
28 | { |
29 | ffi::gst_allocator_register( |
30 | name.to_glib_none().0, |
31 | allocator.upcast().into_glib_ptr(), |
32 | ); |
33 | } |
34 | } |
35 | } |
36 | } |
37 | |