1use glib::{prelude::*, translate::*};
4
5use crate::{ffi, Allocator};
6
7impl Allocator {
8 pub fn memory_type(&self) -> &'static glib::GStr {
9 let obj: *const ffi::GstAllocator = self.to_glib_none().0;
10 unsafe { glib::GStr::from_ptr((*obj).mem_type) }
11 }
12
13 #[doc(alias = "gst_allocator_register")]
14 pub fn register(name: &str, allocator: impl IsA<Allocator>) {
15 skip_assert_initialized!();
16 unsafe {
17 #[cfg(not(feature = "v1_22"))]
18 {
19 if crate::version() < (1, 20, 5, 0) {
21 ffi::gst_allocator_register(
22 name.to_glib_full(),
23 allocator.upcast().into_glib_ptr(),
24 );
25 } else {
26 ffi::gst_allocator_register(
27 name.to_glib_none().0,
28 allocator.upcast().into_glib_ptr(),
29 );
30 }
31 }
32 #[cfg(feature = "v1_22")]
33 {
34 ffi::gst_allocator_register(
35 name.to_glib_none().0,
36 allocator.upcast().into_glib_ptr(),
37 );
38 }
39 }
40 }
41}