diff --git a/gstreamer/Cargo.toml b/gstreamer/Cargo.toml index 3a35c5e93..93258ec46 100644 --- a/gstreamer/Cargo.toml +++ b/gstreamer/Cargo.toml @@ -11,14 +11,13 @@ homepage = "https://gstreamer.freedesktop.org" documentation = "https://gstreamer.pages.freedesktop.org/gstreamer-rs/gstreamer/" keywords = ["gstreamer", "multimedia", "audio", "video", "gnome"] build = "build.rs" +edition = "2018" [dependencies] bitflags = "1.0" cfg-if = "1.0" libc = "0.2" -glib-sys = { git = "https://github.com/gtk-rs/gtk-rs" } -gobject-sys = { git = "https://github.com/gtk-rs/gtk-rs" } -gstreamer-sys = { path = "../gstreamer/sys", features = ["v1_8"] } +ffi = { package = "gstreamer-sys", path = "../gstreamer/sys", features = ["v1_8"] } glib = { git = "https://github.com/gtk-rs/gtk-rs" } num-rational = { version = "0.3", default-features = false, features = [] } once_cell = "1.0" @@ -43,14 +42,14 @@ futures-executor = "0.3.1" [features] default = [] -v1_10 = ["gstreamer-sys/v1_10"] -v1_12 = ["gstreamer-sys/v1_12", "v1_10"] -v1_14 = ["gstreamer-sys/v1_14", "v1_12"] -v1_16 = ["gstreamer-sys/v1_16", "v1_14"] -v1_18 = ["gstreamer-sys/v1_18", "v1_16"] +v1_10 = ["ffi/v1_10"] +v1_12 = ["ffi/v1_12", "v1_10"] +v1_14 = ["ffi/v1_14", "v1_12"] +v1_16 = ["ffi/v1_16", "v1_14"] +v1_18 = ["ffi/v1_18", "v1_16"] embed-lgpl-docs = ["gstreamer-rs-lgpl-docs"] purge-lgpl-docs = ["gstreamer-rs-lgpl-docs"] -dox = ["v1_18", "gstreamer-sys/dox", "glib/dox", "ser_de"] +dox = ["v1_18", "ffi/dox", "glib/dox", "ser_de"] ser_de = ["num-rational/serde", "serde", "serde_bytes", "serde_derive"] [package.metadata.docs.rs] diff --git a/gstreamer/Gir.toml b/gstreamer/Gir.toml index faffeb904..ef7f2ceeb 100644 --- a/gstreamer/Gir.toml +++ b/gstreamer/Gir.toml @@ -171,7 +171,7 @@ final_type = true name = "Gst.BufferFlags" status = "generate" [[object.derive]] - name = "Serialize, Deserialize" + name = "serde::Serialize, serde::Deserialize" cfg_condition = "feature = \"ser_de\"" [[object.member]] @@ -225,7 +225,7 @@ status = "generate" name = "Gst.Format" status = "generate" [[object.derive]] - name = "Serialize, Deserialize" + name = "serde::Serialize, serde::Deserialize" cfg_condition = "feature = \"ser_de\"" [[object.derive]] name = "Debug, PartialEq, Eq, PartialOrd, Ord, Hash" @@ -247,7 +247,7 @@ status = "generate" name = "Gst.SegmentFlags" status = "generate" [[object.derive]] - name = "Serialize, Deserialize" + name = "serde::Serialize, serde::Deserialize" cfg_condition = "feature = \"ser_de\"" [[object.member]] name = "trickmode_forward_predicted" @@ -282,7 +282,7 @@ manual_traits = ["TagSetterExtManual"] name = "Gst.TocScope" status = "generate" [[object.derive]] - name = "Serialize, Deserialize" + name = "serde::Serialize, serde::Deserialize" cfg_condition = "feature = \"ser_de\"" [[object.derive]] name = "Debug, PartialEq, Eq, PartialOrd, Ord, Hash" @@ -291,7 +291,7 @@ status = "generate" name = "Gst.TocEntryType" status = "generate" [[object.derive]] - name = "Serialize, Deserialize" + name = "serde::Serialize, serde::Deserialize" cfg_condition = "feature = \"ser_de\"" [[object.derive]] name = "Debug, PartialEq, Eq, PartialOrd, Ord, Hash" @@ -300,7 +300,7 @@ status = "generate" name = "Gst.TocLoopType" status = "generate" [[object.derive]] - name = "Serialize, Deserialize" + name = "serde::Serialize, serde::Deserialize" cfg_condition = "feature = \"ser_de\"" [[object.derive]] name = "Debug, PartialEq, Eq, PartialOrd, Ord, Hash" @@ -411,7 +411,7 @@ ref_mode = "ref" name = "Gst.TagScope" status = "generate" [[object.derive]] - name = "Serialize, Deserialize" + name = "serde::Serialize, serde::Deserialize" cfg_condition = "feature = \"ser_de\"" [[object.derive]] name = "Debug, PartialEq, Eq, PartialOrd, Ord, Hash" diff --git a/gstreamer/src/allocation_params.rs b/gstreamer/src/allocation_params.rs index da37295ff..1cf872607 100644 --- a/gstreamer/src/allocation_params.rs +++ b/gstreamer/src/allocation_params.rs @@ -10,10 +10,10 @@ use std::mem; use glib::translate::*; -use MemoryFlags; +use crate::MemoryFlags; #[derive(Debug, Clone)] -pub struct AllocationParams(gst_sys::GstAllocationParams); +pub struct AllocationParams(ffi::GstAllocationParams); unsafe impl Send for AllocationParams {} unsafe impl Sync for AllocationParams {} @@ -38,7 +38,7 @@ impl AllocationParams { pub fn new(flags: MemoryFlags, align: usize, prefix: usize, padding: usize) -> Self { assert_initialized_main_thread!(); let allocationparams = unsafe { - let mut allocationparams: gst_sys::GstAllocationParams = mem::zeroed(); + let mut allocationparams: ffi::GstAllocationParams = mem::zeroed(); allocationparams.flags = flags.to_glib(); allocationparams.align = align; @@ -51,13 +51,13 @@ impl AllocationParams { AllocationParams(allocationparams) } - pub fn as_ptr(&self) -> *const gst_sys::GstAllocationParams { + pub fn as_ptr(&self) -> *const ffi::GstAllocationParams { &self.0 } } -impl From for AllocationParams { - fn from(params: gst_sys::GstAllocationParams) -> Self { +impl From for AllocationParams { + fn from(params: ffi::GstAllocationParams) -> Self { skip_assert_initialized!(); AllocationParams(params) } diff --git a/gstreamer/src/allocator.rs b/gstreamer/src/allocator.rs index 1aa6b38a0..8da69eaf1 100644 --- a/gstreamer/src/allocator.rs +++ b/gstreamer/src/allocator.rs @@ -8,14 +8,12 @@ use std::ptr; -use gst_sys; - use glib::translate::from_glib_full; use glib::IsA; -use AllocationParams; -use Allocator; -use Memory; +use crate::AllocationParams; +use crate::Allocator; +use crate::Memory; pub trait AllocatorExtManual: 'static { fn alloc( @@ -32,7 +30,7 @@ impl> AllocatorExtManual for O { params: Option<&AllocationParams>, ) -> Result { unsafe { - let ret = gst_sys::gst_allocator_alloc( + let ret = ffi::gst_allocator_alloc( self.as_ptr() as *mut _, size, match params { @@ -41,7 +39,7 @@ impl> AllocatorExtManual for O { }, ); if ret.is_null() { - Err(glib_bool_error!("Failed to allocate memory")) + Err(glib::glib_bool_error!("Failed to allocate memory")) } else { Ok(from_glib_full(ret)) } diff --git a/gstreamer/src/bin.rs b/gstreamer/src/bin.rs index d10a605c4..1428db5b2 100644 --- a/gstreamer/src/bin.rs +++ b/gstreamer/src/bin.rs @@ -6,12 +6,11 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use Bin; -use BinFlags; -use Element; -use LoggableError; +use crate::Bin; +use crate::BinFlags; +use crate::Element; +use crate::LoggableError; -use glib; use glib::object::Cast; use glib::object::IsA; use glib::signal::connect_raw; @@ -19,8 +18,6 @@ use glib::signal::SignalHandlerId; use glib::translate::*; use glib::GString; -use gst_sys; - use std::boxed::Box as Box_; use std::mem::transmute; use std::path; @@ -36,20 +33,24 @@ pub trait GstBinExtManual: 'static { #[cfg(any(feature = "v1_18", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))] - fn iterate_all_by_element_factory_name(&self, factory_name: &str) -> ::Iterator; - fn iterate_all_by_interface(&self, iface: glib::types::Type) -> ::Iterator; - fn iterate_elements(&self) -> ::Iterator; - fn iterate_recurse(&self) -> ::Iterator; - fn iterate_sinks(&self) -> ::Iterator; - fn iterate_sorted(&self) -> ::Iterator; - fn iterate_sources(&self) -> ::Iterator; + fn iterate_all_by_element_factory_name(&self, factory_name: &str) -> crate::Iterator; + fn iterate_all_by_interface(&self, iface: glib::types::Type) -> crate::Iterator; + fn iterate_elements(&self) -> crate::Iterator; + fn iterate_recurse(&self) -> crate::Iterator; + fn iterate_sinks(&self) -> crate::Iterator; + fn iterate_sorted(&self) -> crate::Iterator; + fn iterate_sources(&self) -> crate::Iterator; fn get_children(&self) -> Vec; - fn debug_to_dot_data(&self, details: ::DebugGraphDetails) -> GString; - fn debug_to_dot_file>(&self, details: ::DebugGraphDetails, file_name: Q); + fn debug_to_dot_data(&self, details: crate::DebugGraphDetails) -> GString; + fn debug_to_dot_file>( + &self, + details: crate::DebugGraphDetails, + file_name: Q, + ); fn debug_to_dot_file_with_ts>( &self, - details: ::DebugGraphDetails, + details: crate::DebugGraphDetails, file_name: Q, ); @@ -64,11 +65,8 @@ impl> GstBinExtManual for O { fn add_many>(&self, elements: &[&E]) -> Result<(), glib::BoolError> { for e in elements { unsafe { - glib_result_from_gboolean!( - gst_sys::gst_bin_add( - self.as_ref().to_glib_none().0, - e.as_ref().to_glib_none().0 - ), + glib::glib_result_from_gboolean!( + ffi::gst_bin_add(self.as_ref().to_glib_none().0, e.as_ref().to_glib_none().0), "Failed to add elements" )?; } @@ -80,8 +78,8 @@ impl> GstBinExtManual for O { fn remove_many>(&self, elements: &[&E]) -> Result<(), glib::BoolError> { for e in elements { unsafe { - glib_result_from_gboolean!( - gst_sys::gst_bin_remove( + glib::glib_result_from_gboolean!( + ffi::gst_bin_remove( self.as_ref().to_glib_none().0, e.as_ref().to_glib_none().0, ), @@ -112,108 +110,96 @@ impl> GstBinExtManual for O { #[cfg(any(feature = "v1_18", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))] - fn iterate_all_by_element_factory_name(&self, factory_name: &str) -> ::Iterator { + fn iterate_all_by_element_factory_name(&self, factory_name: &str) -> crate::Iterator { unsafe { - from_glib_full(gst_sys::gst_bin_iterate_all_by_element_factory_name( + from_glib_full(ffi::gst_bin_iterate_all_by_element_factory_name( self.as_ref().to_glib_none().0, factory_name.to_glib_none().0, )) } } - fn iterate_all_by_interface(&self, iface: glib::types::Type) -> ::Iterator { + fn iterate_all_by_interface(&self, iface: glib::types::Type) -> crate::Iterator { unsafe { - from_glib_full(gst_sys::gst_bin_iterate_all_by_interface( + from_glib_full(ffi::gst_bin_iterate_all_by_interface( self.as_ref().to_glib_none().0, iface.to_glib(), )) } } - fn iterate_elements(&self) -> ::Iterator { + fn iterate_elements(&self) -> crate::Iterator { unsafe { - from_glib_full(gst_sys::gst_bin_iterate_elements( + from_glib_full(ffi::gst_bin_iterate_elements( self.as_ref().to_glib_none().0, )) } } - fn iterate_recurse(&self) -> ::Iterator { - unsafe { - from_glib_full(gst_sys::gst_bin_iterate_recurse( - self.as_ref().to_glib_none().0, - )) - } + fn iterate_recurse(&self) -> crate::Iterator { + unsafe { from_glib_full(ffi::gst_bin_iterate_recurse(self.as_ref().to_glib_none().0)) } } - fn iterate_sinks(&self) -> ::Iterator { - unsafe { - from_glib_full(gst_sys::gst_bin_iterate_sinks( - self.as_ref().to_glib_none().0, - )) - } + fn iterate_sinks(&self) -> crate::Iterator { + unsafe { from_glib_full(ffi::gst_bin_iterate_sinks(self.as_ref().to_glib_none().0)) } } - fn iterate_sorted(&self) -> ::Iterator { - unsafe { - from_glib_full(gst_sys::gst_bin_iterate_sorted( - self.as_ref().to_glib_none().0, - )) - } + fn iterate_sorted(&self) -> crate::Iterator { + unsafe { from_glib_full(ffi::gst_bin_iterate_sorted(self.as_ref().to_glib_none().0)) } } - fn iterate_sources(&self) -> ::Iterator { - unsafe { - from_glib_full(gst_sys::gst_bin_iterate_sources( - self.as_ref().to_glib_none().0, - )) - } + fn iterate_sources(&self) -> crate::Iterator { + unsafe { from_glib_full(ffi::gst_bin_iterate_sources(self.as_ref().to_glib_none().0)) } } fn get_children(&self) -> Vec { unsafe { - let bin: &gst_sys::GstBin = &*(self.as_ptr() as *const _); - let _guard = ::utils::MutexGuard::lock(&bin.element.object.lock); + let bin: &ffi::GstBin = &*(self.as_ptr() as *const _); + let _guard = crate::utils::MutexGuard::lock(&bin.element.object.lock); FromGlibPtrContainer::from_glib_none(bin.children) } } - fn debug_to_dot_data(&self, details: ::DebugGraphDetails) -> GString { - ::debug_bin_to_dot_data(self, details) + fn debug_to_dot_data(&self, details: crate::DebugGraphDetails) -> GString { + crate::debug_bin_to_dot_data(self, details) } - fn debug_to_dot_file>(&self, details: ::DebugGraphDetails, file_name: Q) { - ::debug_bin_to_dot_file(self, details, file_name) + fn debug_to_dot_file>( + &self, + details: crate::DebugGraphDetails, + file_name: Q, + ) { + crate::debug_bin_to_dot_file(self, details, file_name) } fn debug_to_dot_file_with_ts>( &self, - details: ::DebugGraphDetails, + details: crate::DebugGraphDetails, file_name: Q, ) { - ::debug_bin_to_dot_file_with_ts(self, details, file_name) + crate::debug_bin_to_dot_file_with_ts(self, details, file_name) } fn set_bin_flags(&self, flags: BinFlags) { unsafe { - let ptr: *mut gst_sys::GstObject = self.as_ptr() as *mut _; - let _guard = ::utils::MutexGuard::lock(&(*ptr).lock); + let ptr: *mut ffi::GstObject = self.as_ptr() as *mut _; + let _guard = crate::utils::MutexGuard::lock(&(*ptr).lock); (*ptr).flags |= flags.to_glib(); } } fn unset_bin_flags(&self, flags: BinFlags) { unsafe { - let ptr: *mut gst_sys::GstObject = self.as_ptr() as *mut _; - let _guard = ::utils::MutexGuard::lock(&(*ptr).lock); + let ptr: *mut ffi::GstObject = self.as_ptr() as *mut _; + let _guard = crate::utils::MutexGuard::lock(&(*ptr).lock); (*ptr).flags &= !flags.to_glib(); } } fn get_bin_flags(&self) -> BinFlags { unsafe { - let ptr: *mut gst_sys::GstObject = self.as_ptr() as *mut _; - let _guard = ::utils::MutexGuard::lock(&(*ptr).lock); + let ptr: *mut ffi::GstObject = self.as_ptr() as *mut _; + let _guard = crate::utils::MutexGuard::lock(&(*ptr).lock); from_glib((*ptr).flags) } } @@ -223,9 +209,9 @@ unsafe extern "C" fn do_latency_trampoline< P, F: Fn(&P) -> Result<(), LoggableError> + Send + Sync + 'static, >( - this: *mut gst_sys::GstBin, - f: glib_sys::gpointer, -) -> glib_sys::gboolean + this: *mut ffi::GstBin, + f: glib::ffi::gpointer, +) -> glib::ffi::gboolean where P: IsA, { @@ -243,16 +229,16 @@ where #[cfg(test)] mod tests { use super::*; - use prelude::*; + use crate::prelude::*; #[test] fn test_get_children() { - ::init().unwrap(); + crate::init().unwrap(); - let bin = ::Bin::new(None); - bin.add(&::ElementFactory::make("identity", Some("identity0")).unwrap()) + let bin = crate::Bin::new(None); + bin.add(&crate::ElementFactory::make("identity", Some("identity0")).unwrap()) .unwrap(); - bin.add(&::ElementFactory::make("identity", Some("identity1")).unwrap()) + bin.add(&crate::ElementFactory::make("identity", Some("identity1")).unwrap()) .unwrap(); let mut child_names = bin diff --git a/gstreamer/src/buffer.rs b/gstreamer/src/buffer.rs index 89bf88f73..3a018745a 100644 --- a/gstreamer/src/buffer.rs +++ b/gstreamer/src/buffer.rs @@ -15,35 +15,32 @@ use std::slice; use std::u64; use std::usize; -use meta::*; -use BufferCursor; -use BufferFlags; -use BufferRefCursor; -use ClockTime; -use Memory; -use MemoryRef; +use crate::meta::*; +use crate::BufferCursor; +use crate::BufferFlags; +use crate::BufferRefCursor; +use crate::ClockTime; +use crate::Memory; +use crate::MemoryRef; -use glib; use glib::translate::{from_glib, from_glib_full, FromGlib, FromGlibPtrFull, ToGlib}; -use glib_sys; -use gst_sys; pub enum Readable {} pub enum Writable {} -gst_define_mini_object_wrapper!(Buffer, BufferRef, gst_sys::GstBuffer, || { - gst_sys::gst_buffer_get_type() +gst_define_mini_object_wrapper!(Buffer, BufferRef, ffi::GstBuffer, || { + ffi::gst_buffer_get_type() }); pub struct BufferMap<'a, T> { buffer: &'a BufferRef, - map_info: gst_sys::GstMapInfo, + map_info: ffi::GstMapInfo, phantom: PhantomData, } pub struct MappedBuffer { buffer: Option, - map_info: gst_sys::GstMapInfo, + map_info: ffi::GstMapInfo, phantom: PhantomData, } @@ -51,23 +48,23 @@ impl Buffer { pub fn new() -> Self { assert_initialized_main_thread!(); - unsafe { from_glib_full(gst_sys::gst_buffer_new()) } + unsafe { from_glib_full(ffi::gst_buffer_new()) } } pub fn with_size(size: usize) -> Result { assert_initialized_main_thread!(); unsafe { - Option::<_>::from_glib_full(gst_sys::gst_buffer_new_allocate( + Option::<_>::from_glib_full(ffi::gst_buffer_new_allocate( ptr::null_mut(), size, ptr::null_mut(), )) - .ok_or_else(|| glib_bool_error!("Failed to allocate buffer")) + .ok_or_else(|| glib::glib_bool_error!("Failed to allocate buffer")) } } - unsafe extern "C" fn drop_box(vec: glib_sys::gpointer) { + unsafe extern "C" fn drop_box(vec: glib::ffi::gpointer) { let slice: Box = Box::from_raw(vec as *mut T); drop(slice); } @@ -82,13 +79,13 @@ impl Buffer { (slice.len(), slice.as_mut_ptr()) }; let user_data = Box::into_raw(b); - from_glib_full(gst_sys::gst_buffer_new_wrapped_full( + from_glib_full(ffi::gst_buffer_new_wrapped_full( 0, - data as glib_sys::gpointer, + data as glib::ffi::gpointer, size, 0, size, - user_data as glib_sys::gpointer, + user_data as glib::ffi::gpointer, Some(Self::drop_box::), )) } @@ -104,13 +101,13 @@ impl Buffer { (slice.len(), slice.as_ptr()) }; let user_data = Box::into_raw(b); - from_glib_full(gst_sys::gst_buffer_new_wrapped_full( - gst_sys::GST_MEMORY_FLAG_READONLY, - data as glib_sys::gpointer, + from_glib_full(ffi::gst_buffer_new_wrapped_full( + ffi::GST_MEMORY_FLAG_READONLY, + data as glib::ffi::gpointer, size, 0, size, - user_data as glib_sys::gpointer, + user_data as glib::ffi::gpointer, Some(Self::drop_box::), )) } @@ -119,10 +116,10 @@ impl Buffer { pub fn into_mapped_buffer_readable(self) -> Result, Self> { unsafe { let mut map_info = mem::MaybeUninit::zeroed(); - let res: bool = from_glib(gst_sys::gst_buffer_map( + let res: bool = from_glib(ffi::gst_buffer_map( self.as_mut_ptr(), map_info.as_mut_ptr(), - gst_sys::GST_MAP_READ, + ffi::GST_MAP_READ, )); if res { Ok(MappedBuffer { @@ -139,10 +136,10 @@ impl Buffer { pub fn into_mapped_buffer_writable(self) -> Result, Self> { unsafe { let mut map_info = mem::MaybeUninit::zeroed(); - let res: bool = from_glib(gst_sys::gst_buffer_map( + let res: bool = from_glib(ffi::gst_buffer_map( self.as_mut_ptr(), map_info.as_mut_ptr(), - gst_sys::GST_MAP_READWRITE, + ffi::GST_MAP_READWRITE, )); if res { Ok(MappedBuffer { @@ -167,7 +164,7 @@ impl Buffer { pub fn append(&mut self, other: Self) { skip_assert_initialized!(); unsafe { - let ptr = gst_sys::gst_buffer_append(self.as_mut_ptr(), other.into_ptr()); + let ptr = ffi::gst_buffer_append(self.as_mut_ptr(), other.into_ptr()); self.replace_ptr(ptr); } } @@ -183,19 +180,16 @@ impl BufferRef { pub fn map_readable(&self) -> Result, glib::BoolError> { unsafe { let mut map_info = mem::MaybeUninit::zeroed(); - let res = gst_sys::gst_buffer_map( - self.as_mut_ptr(), - map_info.as_mut_ptr(), - gst_sys::GST_MAP_READ, - ); - if res == glib_sys::GTRUE { + let res = + ffi::gst_buffer_map(self.as_mut_ptr(), map_info.as_mut_ptr(), ffi::GST_MAP_READ); + if res == glib::ffi::GTRUE { Ok(BufferMap { buffer: self, map_info: map_info.assume_init(), phantom: PhantomData, }) } else { - Err(glib_bool_error!("Failed to map buffer readable")) + Err(glib::glib_bool_error!("Failed to map buffer readable")) } } } @@ -203,52 +197,52 @@ impl BufferRef { pub fn map_writable(&mut self) -> Result, glib::BoolError> { unsafe { let mut map_info = mem::MaybeUninit::zeroed(); - let res = gst_sys::gst_buffer_map( + let res = ffi::gst_buffer_map( self.as_mut_ptr(), map_info.as_mut_ptr(), - gst_sys::GST_MAP_READWRITE, + ffi::GST_MAP_READWRITE, ); - if res == glib_sys::GTRUE { + if res == glib::ffi::GTRUE { Ok(BufferMap { buffer: self, map_info: map_info.assume_init(), phantom: PhantomData, }) } else { - Err(glib_bool_error!("Failed to map buffer writable")) + Err(glib::glib_bool_error!("Failed to map buffer writable")) } } } pub fn copy_region( &self, - flags: ::BufferCopyFlags, + flags: crate::BufferCopyFlags, offset: usize, size: Option, ) -> Result { let size_real = size.unwrap_or(usize::MAX); unsafe { - Option::<_>::from_glib_full(gst_sys::gst_buffer_copy_region( + Option::<_>::from_glib_full(ffi::gst_buffer_copy_region( self.as_mut_ptr(), flags.to_glib(), offset, size_real, )) - .ok_or_else(|| glib_bool_error!("Failed to copy region of buffer")) + .ok_or_else(|| glib::glib_bool_error!("Failed to copy region of buffer")) } } pub fn copy_into( &self, dest: &mut BufferRef, - flags: ::BufferCopyFlags, + flags: crate::BufferCopyFlags, offset: usize, size: Option, ) -> Result<(), glib::BoolError> { let size_real = size.unwrap_or(usize::MAX); unsafe { - glib_result_from_gboolean!( - gst_sys::gst_buffer_copy_into( + glib::glib_result_from_gboolean!( + ffi::gst_buffer_copy_into( dest.as_mut_ptr(), self.as_mut_ptr(), flags.to_glib(), @@ -268,10 +262,10 @@ impl BufferRef { let copied = unsafe { let src = slice.as_ptr(); - gst_sys::gst_buffer_fill( + ffi::gst_buffer_fill( self.as_mut_ptr(), offset, - src as glib_sys::gconstpointer, + src as glib::ffi::gconstpointer, size, ) }; @@ -291,7 +285,7 @@ impl BufferRef { let copied = unsafe { let dest = slice.as_mut_ptr(); - gst_sys::gst_buffer_extract(self.as_mut_ptr(), offset, dest as glib_sys::gpointer, size) + ffi::gst_buffer_extract(self.as_mut_ptr(), offset, dest as glib::ffi::gpointer, size) }; if copied == size { @@ -303,19 +297,19 @@ impl BufferRef { pub fn copy_deep(&self) -> Result { unsafe { - Option::<_>::from_glib_full(gst_sys::gst_buffer_copy_deep(self.as_ptr())) - .ok_or_else(|| glib_bool_error!("Failed to deep copy buffer")) + Option::<_>::from_glib_full(ffi::gst_buffer_copy_deep(self.as_ptr())) + .ok_or_else(|| glib::glib_bool_error!("Failed to deep copy buffer")) } } pub fn get_size(&self) -> usize { - unsafe { gst_sys::gst_buffer_get_size(self.as_mut_ptr()) } + unsafe { ffi::gst_buffer_get_size(self.as_mut_ptr()) } } pub fn get_maxsize(&self) -> usize { unsafe { let mut maxsize = mem::MaybeUninit::uninit(); - gst_sys::gst_buffer_get_sizes_range( + ffi::gst_buffer_get_sizes_range( self.as_mut_ptr(), 0, -1, @@ -331,7 +325,7 @@ impl BufferRef { assert!(self.get_maxsize() >= size); unsafe { - gst_sys::gst_buffer_set_size(self.as_mut_ptr(), size as isize); + ffi::gst_buffer_set_size(self.as_mut_ptr(), size as isize); } } @@ -398,7 +392,7 @@ impl BufferRef { pub fn get_meta(&self) -> Option> { unsafe { - let meta = gst_sys::gst_buffer_get_meta(self.as_mut_ptr(), T::get_meta_api().to_glib()); + let meta = ffi::gst_buffer_get_meta(self.as_mut_ptr(), T::get_meta_api().to_glib()); if meta.is_null() { None } else { @@ -407,9 +401,9 @@ impl BufferRef { } } - pub fn get_meta_mut(&mut self) -> Option> { + pub fn get_meta_mut(&mut self) -> Option> { unsafe { - let meta = gst_sys::gst_buffer_get_meta(self.as_mut_ptr(), T::get_meta_api().to_glib()); + let meta = ffi::gst_buffer_get_meta(self.as_mut_ptr(), T::get_meta_api().to_glib()); if meta.is_null() { None } else { @@ -428,10 +422,10 @@ impl BufferRef { pub fn foreach_meta) -> bool>(&self, func: F) -> bool { unsafe extern "C" fn trampoline) -> bool>( - buffer: *mut gst_sys::GstBuffer, - meta: *mut *mut gst_sys::GstMeta, - user_data: glib_sys::gpointer, - ) -> glib_sys::gboolean { + buffer: *mut ffi::GstBuffer, + meta: *mut *mut ffi::GstMeta, + user_data: glib::ffi::gpointer, + ) -> glib::ffi::gboolean { let func = user_data as *const _ as usize as *mut F; let res = (*func)(Meta::from_ptr(BufferRef::from_ptr(buffer), *meta)); @@ -441,7 +435,7 @@ impl BufferRef { unsafe { let func_ptr: &F = &func; - from_glib(gst_sys::gst_buffer_foreach_meta( + from_glib(ffi::gst_buffer_foreach_meta( self.as_ptr() as *mut _, Some(trampoline::), func_ptr as *const _ as usize as *mut _, @@ -449,17 +443,19 @@ impl BufferRef { } } - pub fn foreach_meta_mut) -> Result>( + pub fn foreach_meta_mut< + F: FnMut(MetaRefMut) -> Result, + >( &mut self, func: F, ) -> bool { unsafe extern "C" fn trampoline< - F: FnMut(MetaRefMut) -> Result, + F: FnMut(MetaRefMut) -> Result, >( - buffer: *mut gst_sys::GstBuffer, - meta: *mut *mut gst_sys::GstMeta, - user_data: glib_sys::gpointer, - ) -> glib_sys::gboolean { + buffer: *mut ffi::GstBuffer, + meta: *mut *mut ffi::GstMeta, + user_data: glib::ffi::gpointer, + ) -> glib::ffi::gboolean { let func = user_data as *const _ as usize as *mut F; let res = (*func)(Meta::from_mut_ptr(BufferRef::from_mut_ptr(buffer), *meta)); @@ -475,7 +471,7 @@ impl BufferRef { unsafe { let func_ptr: &F = &func; - from_glib(gst_sys::gst_buffer_foreach_meta( + from_glib(ffi::gst_buffer_foreach_meta( self.as_ptr() as *mut _, Some(trampoline::), func_ptr as *const _ as usize as *mut _, @@ -484,7 +480,7 @@ impl BufferRef { } pub fn append_memory(&mut self, mem: Memory) { - unsafe { gst_sys::gst_buffer_append_memory(self.as_mut_ptr(), mem.into_ptr()) } + unsafe { ffi::gst_buffer_append_memory(self.as_mut_ptr(), mem.into_ptr()) } } pub fn find_memory(&self, offset: usize, size: Option) -> Option<(u32, u32, usize)> { @@ -493,7 +489,7 @@ impl BufferRef { let mut length = mem::MaybeUninit::uninit(); let mut skip = mem::MaybeUninit::uninit(); - let res = from_glib(gst_sys::gst_buffer_find_memory( + let res = from_glib(ffi::gst_buffer_find_memory( self.as_mut_ptr(), offset, size.unwrap_or(usize::MAX), @@ -512,7 +508,7 @@ impl BufferRef { pub fn get_all_memory(&self) -> Option { unsafe { - let res = gst_sys::gst_buffer_get_all_memory(self.as_mut_ptr()); + let res = ffi::gst_buffer_get_all_memory(self.as_mut_ptr()); if res.is_null() { None } else { @@ -522,7 +518,7 @@ impl BufferRef { } pub fn get_max_memory() -> u32 { - unsafe { gst_sys::gst_buffer_get_max_memory() } + unsafe { ffi::gst_buffer_get_max_memory() } } pub fn get_memory(&self, idx: u32) -> Option { @@ -530,7 +526,7 @@ impl BufferRef { None } else { unsafe { - let res = gst_sys::gst_buffer_get_memory(self.as_mut_ptr(), idx); + let res = ffi::gst_buffer_get_memory(self.as_mut_ptr(), idx); if res.is_null() { None } else { @@ -543,7 +539,7 @@ impl BufferRef { pub fn get_memory_range(&self, idx: u32, length: Option) -> Option { assert!(idx + length.unwrap_or(0) < self.n_memory()); unsafe { - let res = gst_sys::gst_buffer_get_memory_range( + let res = ffi::gst_buffer_get_memory_range( self.as_mut_ptr(), idx, match length { @@ -561,7 +557,7 @@ impl BufferRef { pub fn insert_memory(&mut self, idx: Option, mem: Memory) { unsafe { - gst_sys::gst_buffer_insert_memory( + ffi::gst_buffer_insert_memory( self.as_mut_ptr(), match idx { Some(val) => val as i32, @@ -573,16 +569,12 @@ impl BufferRef { } pub fn is_all_memory_writable(&self) -> bool { - unsafe { - from_glib(gst_sys::gst_buffer_is_all_memory_writable( - self.as_mut_ptr(), - )) - } + unsafe { from_glib(ffi::gst_buffer_is_all_memory_writable(self.as_mut_ptr())) } } pub fn is_memory_range_writable(&self, idx: u32, length: Option) -> bool { unsafe { - from_glib(gst_sys::gst_buffer_is_memory_range_writable( + from_glib(ffi::gst_buffer_is_memory_range_writable( self.as_mut_ptr(), idx, match length { @@ -594,22 +586,22 @@ impl BufferRef { } pub fn n_memory(&self) -> u32 { - unsafe { gst_sys::gst_buffer_n_memory(self.as_ptr() as *mut _) } + unsafe { ffi::gst_buffer_n_memory(self.as_ptr() as *mut _) } } pub fn peek_memory(&self, idx: u32) -> &MemoryRef { assert!(idx < self.n_memory()); - unsafe { MemoryRef::from_ptr(gst_sys::gst_buffer_peek_memory(self.as_mut_ptr(), idx)) } + unsafe { MemoryRef::from_ptr(ffi::gst_buffer_peek_memory(self.as_mut_ptr(), idx)) } } pub fn peek_memory_mut(&mut self, idx: u32) -> Result<&mut MemoryRef, glib::BoolError> { assert!(idx < self.n_memory()); unsafe { - let mem = gst_sys::gst_buffer_peek_memory(self.as_mut_ptr(), idx); - if gst_sys::gst_mini_object_is_writable(mem as *mut _) == glib_sys::GFALSE { - Err(glib_bool_error!("Memory not writable")) + let mem = ffi::gst_buffer_peek_memory(self.as_mut_ptr(), idx); + if ffi::gst_mini_object_is_writable(mem as *mut _) == glib::ffi::GFALSE { + Err(glib::glib_bool_error!("Memory not writable")) } else { - Ok(MemoryRef::from_mut_ptr(gst_sys::gst_buffer_peek_memory( + Ok(MemoryRef::from_mut_ptr(ffi::gst_buffer_peek_memory( self.as_mut_ptr(), idx, ))) @@ -618,22 +610,22 @@ impl BufferRef { } pub fn prepend_memory(&mut self, mem: Memory) { - unsafe { gst_sys::gst_buffer_prepend_memory(self.as_mut_ptr(), mem.into_ptr()) } + unsafe { ffi::gst_buffer_prepend_memory(self.as_mut_ptr(), mem.into_ptr()) } } pub fn remove_all_memory(&mut self) { - unsafe { gst_sys::gst_buffer_remove_all_memory(self.as_mut_ptr()) } + unsafe { ffi::gst_buffer_remove_all_memory(self.as_mut_ptr()) } } pub fn remove_memory(&mut self, idx: u32) { assert!(idx < self.n_memory()); - unsafe { gst_sys::gst_buffer_remove_memory(self.as_mut_ptr(), idx) } + unsafe { ffi::gst_buffer_remove_memory(self.as_mut_ptr(), idx) } } pub fn remove_memory_range(&mut self, idx: u32, length: Option) { assert!(idx + length.unwrap_or(0) < self.n_memory()); unsafe { - gst_sys::gst_buffer_remove_memory_range( + ffi::gst_buffer_remove_memory_range( self.as_mut_ptr(), idx, match length { @@ -645,18 +637,18 @@ impl BufferRef { } pub fn replace_all_memory(&mut self, mem: Memory) { - unsafe { gst_sys::gst_buffer_replace_all_memory(self.as_mut_ptr(), mem.into_ptr()) } + unsafe { ffi::gst_buffer_replace_all_memory(self.as_mut_ptr(), mem.into_ptr()) } } pub fn replace_memory(&mut self, idx: u32, mem: Memory) { assert!(idx < self.n_memory()); - unsafe { gst_sys::gst_buffer_replace_memory(self.as_mut_ptr(), idx, mem.into_ptr()) } + unsafe { ffi::gst_buffer_replace_memory(self.as_mut_ptr(), idx, mem.into_ptr()) } } pub fn replace_memory_range(&mut self, idx: u32, length: Option, mem: Memory) { assert!(idx + length.unwrap_or(0) < self.n_memory()); unsafe { - gst_sys::gst_buffer_replace_memory_range( + ffi::gst_buffer_replace_memory_range( self.as_mut_ptr(), idx, match length { @@ -674,7 +666,7 @@ impl BufferRef { pub fn iter_memories_mut(&mut self) -> Result { if !self.is_all_memory_writable() { - Err(glib_bool_error!("Not all memory are writable")) + Err(glib::glib_bool_error!("Not all memory are writable")) } else { Ok(IterMut::new(self)) } @@ -699,7 +691,7 @@ macro_rules! define_meta_iter( ($name:ident, $typ:ty, $mtyp:ty, $prepare_buffer:expr, $from_ptr:expr) => { pub struct $name<'a, T: MetaAPI + 'a> { buffer: $typ, - state: glib_sys::gpointer, + state: glib::ffi::gpointer, meta_api: glib::Type, items: PhantomData<$mtyp>, } @@ -737,7 +729,7 @@ macro_rules! define_meta_iter( fn next(&mut self) -> Option { loop { unsafe { - let meta = gst_sys::gst_buffer_iterate_meta(self.buffer.as_mut_ptr(), &mut self.state); + let meta = ffi::gst_buffer_iterate_meta(self.buffer.as_mut_ptr(), &mut self.state); if meta.is_null() { return None; @@ -758,14 +750,14 @@ define_meta_iter!( MetaIter, &'a BufferRef, MetaRef<'a, T>, - |buffer: *const gst_sys::GstBuffer| BufferRef::from_ptr(buffer), + |buffer: *const ffi::GstBuffer| BufferRef::from_ptr(buffer), |buffer, meta| T::from_ptr(buffer, meta as *const ::GstType) ); define_meta_iter!( MetaIterMut, &'a mut BufferRef, - MetaRefMut<'a, T, ::meta::Iterated>, - |buffer: *mut gst_sys::GstBuffer| BufferRef::from_mut_ptr(buffer), + MetaRefMut<'a, T, crate::meta::Iterated>, + |buffer: *mut ffi::GstBuffer| BufferRef::from_mut_ptr(buffer), |buffer: &'a mut BufferRef, meta| T::from_mut_ptr(buffer, meta as *mut ::GstType) ); @@ -852,11 +844,11 @@ define_iter!( &'a BufferRef, &'a MemoryRef, |buffer: &BufferRef, idx| { - let ptr = gst_sys::gst_buffer_peek_memory(buffer.as_mut_ptr(), idx); + let ptr = ffi::gst_buffer_peek_memory(buffer.as_mut_ptr(), idx); if ptr.is_null() { None } else { - Some(MemoryRef::from_ptr(ptr as *const gst_sys::GstMemory)) + Some(MemoryRef::from_ptr(ptr as *const ffi::GstMemory)) } } ); @@ -866,11 +858,11 @@ define_iter!( &'a mut BufferRef, &'a mut MemoryRef, |buffer: &mut BufferRef, idx| { - let ptr = gst_sys::gst_buffer_peek_memory(buffer.as_mut_ptr(), idx); + let ptr = ffi::gst_buffer_peek_memory(buffer.as_mut_ptr(), idx); if ptr.is_null() { None } else { - Some(MemoryRef::from_mut_ptr(ptr as *mut gst_sys::GstMemory)) + Some(MemoryRef::from_mut_ptr(ptr as *mut ffi::GstMemory)) } } ); @@ -922,7 +914,7 @@ impl fmt::Debug for BufferRef { .field( "metas", &DebugIter(RefCell::new( - self.iter_meta::<::Meta>().map(|m| m.get_api()), + self.iter_meta::().map(|m| m.get_api()), )), ) .finish() @@ -1012,7 +1004,7 @@ impl<'a, T> Eq for BufferMap<'a, T> {} impl<'a, T> Drop for BufferMap<'a, T> { fn drop(&mut self) { unsafe { - gst_sys::gst_buffer_unmap(self.buffer.as_mut_ptr(), &mut self.map_info); + ffi::gst_buffer_unmap(self.buffer.as_mut_ptr(), &mut self.map_info); } } } @@ -1036,7 +1028,7 @@ impl MappedBuffer { pub fn into_buffer(mut self) -> Buffer { let buffer = self.buffer.take().unwrap(); unsafe { - gst_sys::gst_buffer_unmap(buffer.as_mut_ptr(), &mut self.map_info); + ffi::gst_buffer_unmap(buffer.as_mut_ptr(), &mut self.map_info); } buffer @@ -1079,7 +1071,7 @@ impl Drop for MappedBuffer { fn drop(&mut self) { if let Some(ref buffer) = self.buffer { unsafe { - gst_sys::gst_buffer_unmap(buffer.as_mut_ptr(), &mut self.map_info); + ffi::gst_buffer_unmap(buffer.as_mut_ptr(), &mut self.map_info); } } } @@ -1104,10 +1096,10 @@ impl Eq for MappedBuffer {} unsafe impl Send for MappedBuffer {} unsafe impl Sync for MappedBuffer {} -pub const BUFFER_COPY_METADATA: ::BufferCopyFlags = - ::BufferCopyFlags::from_bits_truncate(gst_sys::GST_BUFFER_COPY_METADATA); -pub const BUFFER_COPY_ALL: ::BufferCopyFlags = - ::BufferCopyFlags::from_bits_truncate(gst_sys::GST_BUFFER_COPY_ALL); +pub const BUFFER_COPY_METADATA: crate::BufferCopyFlags = + crate::BufferCopyFlags::from_bits_truncate(ffi::GST_BUFFER_COPY_METADATA); +pub const BUFFER_COPY_ALL: crate::BufferCopyFlags = + crate::BufferCopyFlags::from_bits_truncate(ffi::GST_BUFFER_COPY_ALL); #[cfg(test)] mod tests { @@ -1115,7 +1107,7 @@ mod tests { #[test] fn test_fields() { - ::init().unwrap(); + crate::init().unwrap(); let mut buffer = Buffer::new(); @@ -1136,7 +1128,7 @@ mod tests { #[test] fn test_writability() { - ::init().unwrap(); + crate::init().unwrap(); let mut buffer = Buffer::from_slice(vec![1, 2, 3, 4]); { @@ -1184,16 +1176,16 @@ mod tests { #[test] #[allow(clippy::cognitive_complexity)] fn test_memories() { - ::init().unwrap(); + crate::init().unwrap(); let mut buffer = Buffer::new(); { let buffer = buffer.get_mut().unwrap(); - buffer.append_memory(::Memory::from_mut_slice(vec![0; 5])); - buffer.append_memory(::Memory::from_mut_slice(vec![0; 5])); - buffer.append_memory(::Memory::from_mut_slice(vec![0; 5])); - buffer.append_memory(::Memory::from_mut_slice(vec![0; 5])); - buffer.append_memory(::Memory::from_mut_slice(vec![0; 10])); + buffer.append_memory(crate::Memory::from_mut_slice(vec![0; 5])); + buffer.append_memory(crate::Memory::from_mut_slice(vec![0; 5])); + buffer.append_memory(crate::Memory::from_mut_slice(vec![0; 5])); + buffer.append_memory(crate::Memory::from_mut_slice(vec![0; 5])); + buffer.append_memory(crate::Memory::from_mut_slice(vec![0; 10])); } assert!(buffer.is_all_memory_writable()); @@ -1295,78 +1287,84 @@ mod tests { #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_14")))] #[test] fn test_meta_foreach() { - ::init().unwrap(); + crate::init().unwrap(); let mut buffer = Buffer::new(); { let buffer = buffer.get_mut().unwrap(); - ::ReferenceTimestampMeta::add( + crate::ReferenceTimestampMeta::add( buffer, - &::Caps::builder("foo/bar").build(), - ::ClockTime::from(0), - ::CLOCK_TIME_NONE, + &crate::Caps::builder("foo/bar").build(), + crate::ClockTime::from(0), + crate::CLOCK_TIME_NONE, ); - ::ReferenceTimestampMeta::add( + crate::ReferenceTimestampMeta::add( buffer, - &::Caps::builder("foo/bar").build(), - ::SECOND, - ::CLOCK_TIME_NONE, + &crate::Caps::builder("foo/bar").build(), + crate::SECOND, + crate::CLOCK_TIME_NONE, ); } let mut res = vec![]; buffer.foreach_meta(|meta| { - let meta = meta.downcast_ref::<::ReferenceTimestampMeta>().unwrap(); + let meta = meta + .downcast_ref::() + .unwrap(); res.push(meta.get_timestamp()); true }); - assert_eq!(&[::ClockTime::from(0), ::SECOND][..], &res[..]); + assert_eq!(&[crate::ClockTime::from(0), crate::SECOND][..], &res[..]); } #[cfg(any(feature = "v1_14", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_14")))] #[test] fn test_meta_foreach_mut() { - ::init().unwrap(); + crate::init().unwrap(); let mut buffer = Buffer::new(); { let buffer = buffer.get_mut().unwrap(); - ::ReferenceTimestampMeta::add( + crate::ReferenceTimestampMeta::add( buffer, - &::Caps::builder("foo/bar").build(), - ::ClockTime::from(0), - ::CLOCK_TIME_NONE, + &crate::Caps::builder("foo/bar").build(), + crate::ClockTime::from(0), + crate::CLOCK_TIME_NONE, ); - ::ReferenceTimestampMeta::add( + crate::ReferenceTimestampMeta::add( buffer, - &::Caps::builder("foo/bar").build(), - ::SECOND, - ::CLOCK_TIME_NONE, + &crate::Caps::builder("foo/bar").build(), + crate::SECOND, + crate::CLOCK_TIME_NONE, ); } let mut res = vec![]; buffer.get_mut().unwrap().foreach_meta_mut(|mut meta| { - let meta = meta.downcast_ref::<::ReferenceTimestampMeta>().unwrap(); + let meta = meta + .downcast_ref::() + .unwrap(); res.push(meta.get_timestamp()); - if meta.get_timestamp() == ::SECOND { + if meta.get_timestamp() == crate::SECOND { Ok(false) } else { Ok(true) } }); - assert_eq!(&[::ClockTime::from(0), ::SECOND][..], &res[..]); + assert_eq!(&[crate::ClockTime::from(0), crate::SECOND][..], &res[..]); let mut res = vec![]; buffer.foreach_meta(|meta| { - let meta = meta.downcast_ref::<::ReferenceTimestampMeta>().unwrap(); + let meta = meta + .downcast_ref::() + .unwrap(); res.push(meta.get_timestamp()); true }); - assert_eq!(&[::ClockTime::from(0)][..], &res[..]); + assert_eq!(&[crate::ClockTime::from(0)][..], &res[..]); } } diff --git a/gstreamer/src/buffer_cursor.rs b/gstreamer/src/buffer_cursor.rs index 83147edc3..46f8899ee 100644 --- a/gstreamer/src/buffer_cursor.rs +++ b/gstreamer/src/buffer_cursor.rs @@ -14,14 +14,10 @@ use std::ptr; use std::u64; use std::usize; -use Buffer; -use BufferRef; +use crate::Buffer; +use crate::BufferRef; -use glib; -use glib_sys; -use gst_sys; - -use buffer::{Readable, Writable}; +use crate::buffer::{Readable, Writable}; pub struct BufferCursor { buffer: Option, @@ -30,7 +26,7 @@ pub struct BufferCursor { cur_mem_idx: u32, cur_offset: u64, cur_mem_offset: usize, - map_info: gst_sys::GstMapInfo, + map_info: ffi::GstMapInfo, phantom: PhantomData, } @@ -41,7 +37,7 @@ pub struct BufferRefCursor { cur_mem_idx: u32, cur_offset: u64, cur_mem_offset: usize, - map_info: gst_sys::GstMapInfo, + map_info: ffi::GstMapInfo, } macro_rules! define_seek_impl( @@ -91,7 +87,7 @@ macro_rules! define_seek_impl( if idx != self.cur_mem_idx && !self.map_info.memory.is_null() { unsafe { - gst_sys::gst_memory_unmap(self.map_info.memory, &mut self.map_info); + ffi::gst_memory_unmap(self.map_info.memory, &mut self.map_info); self.map_info.memory = ptr::null_mut(); } } @@ -124,14 +120,14 @@ macro_rules! define_read_write_fn_impl( unsafe { // Work around lifetime annotation issues with closures let get_buffer_ref: fn(&Self) -> &BufferRef = $get_buffer_ref; - let memory = gst_sys::gst_buffer_peek_memory( + let memory = ffi::gst_buffer_peek_memory( get_buffer_ref($self).as_mut_ptr(), $self.cur_mem_idx, ); assert!(!memory.is_null()); - if gst_sys::gst_memory_map(memory, &mut $self.map_info, $map_flags) - == glib_sys::GFALSE + if ffi::gst_memory_map(memory, &mut $self.map_info, $map_flags) + == glib::ffi::GFALSE { return Err(io::Error::new( io::ErrorKind::InvalidData, @@ -162,7 +158,7 @@ macro_rules! define_read_write_fn_impl( // If we're at the end of the current memory, unmap and advance to the next memory if $self.cur_mem_offset == $self.map_info.size { unsafe { - gst_sys::gst_memory_unmap($self.map_info.memory, &mut $self.map_info); + ffi::gst_memory_unmap($self.map_info.memory, &mut $self.map_info); } $self.map_info.memory = ptr::null_mut(); $self.cur_mem_idx += 1; @@ -182,8 +178,8 @@ macro_rules! define_read_impl( data, &mut [u8], $get_buffer_ref, - gst_sys::GST_MAP_READ, - |map_info: &gst_sys::GstMapInfo, off, data: &mut [u8], to_copy| unsafe { + ffi::GST_MAP_READ, + |map_info: &ffi::GstMapInfo, off, data: &mut [u8], to_copy| unsafe { ptr::copy_nonoverlapping( (map_info.data as *const u8).add(off), data.as_mut_ptr(), @@ -204,8 +200,8 @@ macro_rules! define_write_impl( data, &[u8], $get_buffer_ref, - gst_sys::GST_MAP_WRITE, - |map_info: &gst_sys::GstMapInfo, off, data: &[u8], to_copy| unsafe { + ffi::GST_MAP_WRITE, + |map_info: &ffi::GstMapInfo, off, data: &[u8], to_copy| unsafe { ptr::copy_nonoverlapping( data.as_ptr(), (map_info.data as *mut u8).add(off), @@ -219,7 +215,7 @@ macro_rules! define_write_impl( fn flush(&mut self) -> Result<(), io::Error> { if !self.map_info.memory.is_null() { unsafe { - gst_sys::gst_memory_unmap(self.map_info.memory, &mut self.map_info); + ffi::gst_memory_unmap(self.map_info.memory, &mut self.map_info); self.map_info.memory = ptr::null_mut(); } } @@ -247,7 +243,7 @@ impl Drop for BufferCursor { fn drop(&mut self) { if !self.map_info.memory.is_null() { unsafe { - gst_sys::gst_memory_unmap(self.map_info.memory, &mut self.map_info); + ffi::gst_memory_unmap(self.map_info.memory, &mut self.map_info); } } } @@ -306,7 +302,7 @@ impl BufferCursor { pub(crate) fn new_writable(buffer: Buffer) -> Result, glib::BoolError> { skip_assert_initialized!(); if !buffer.is_writable() || !buffer.is_all_memory_writable() { - return Err(glib_bool_error!("Not all memories are writable")); + return Err(glib::glib_bool_error!("Not all memories are writable")); } let size = buffer.get_size() as u64; @@ -346,7 +342,7 @@ impl Drop for BufferRefCursor { fn drop(&mut self) { if !self.map_info.memory.is_null() { unsafe { - gst_sys::gst_memory_unmap(self.map_info.memory, &mut self.map_info); + ffi::gst_memory_unmap(self.map_info.memory, &mut self.map_info); } } } @@ -410,7 +406,7 @@ impl<'a> BufferRefCursor<&'a mut BufferRef> { ) -> Result, glib::BoolError> { skip_assert_initialized!(); if !buffer.is_all_memory_writable() { - return Err(glib_bool_error!("Not all memories are writable")); + return Err(glib::glib_bool_error!("Not all memories are writable")); } let size = buffer.get_size() as u64; @@ -440,16 +436,16 @@ mod tests { fn test_buffer_cursor() { use std::io::{self, Read, Seek, Write}; - ::init().unwrap(); + crate::init().unwrap(); let mut buffer = Buffer::new(); { let buffer = buffer.get_mut().unwrap(); - buffer.append_memory(::Memory::from_mut_slice(vec![0; 5])); - buffer.append_memory(::Memory::from_mut_slice(vec![0; 5])); - buffer.append_memory(::Memory::from_mut_slice(vec![0; 5])); - buffer.append_memory(::Memory::from_mut_slice(vec![0; 5])); - buffer.append_memory(::Memory::from_mut_slice(vec![0; 10])); + buffer.append_memory(crate::Memory::from_mut_slice(vec![0; 5])); + buffer.append_memory(crate::Memory::from_mut_slice(vec![0; 5])); + buffer.append_memory(crate::Memory::from_mut_slice(vec![0; 5])); + buffer.append_memory(crate::Memory::from_mut_slice(vec![0; 5])); + buffer.append_memory(crate::Memory::from_mut_slice(vec![0; 10])); } assert!(buffer.is_all_memory_writable()); @@ -532,16 +528,16 @@ mod tests { fn test_buffer_cursor_ref() { use std::io::{self, Read, Seek, Write}; - ::init().unwrap(); + crate::init().unwrap(); let mut buffer = Buffer::new(); { let buffer = buffer.get_mut().unwrap(); - buffer.append_memory(::Memory::from_mut_slice(vec![0; 5])); - buffer.append_memory(::Memory::from_mut_slice(vec![0; 5])); - buffer.append_memory(::Memory::from_mut_slice(vec![0; 5])); - buffer.append_memory(::Memory::from_mut_slice(vec![0; 5])); - buffer.append_memory(::Memory::from_mut_slice(vec![0; 10])); + buffer.append_memory(crate::Memory::from_mut_slice(vec![0; 5])); + buffer.append_memory(crate::Memory::from_mut_slice(vec![0; 5])); + buffer.append_memory(crate::Memory::from_mut_slice(vec![0; 5])); + buffer.append_memory(crate::Memory::from_mut_slice(vec![0; 5])); + buffer.append_memory(crate::Memory::from_mut_slice(vec![0; 10])); } assert!(buffer.is_all_memory_writable()); diff --git a/gstreamer/src/buffer_pool.rs b/gstreamer/src/buffer_pool.rs index e4183ae9a..27016a1b7 100644 --- a/gstreamer/src/buffer_pool.rs +++ b/gstreamer/src/buffer_pool.rs @@ -6,17 +6,14 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use AllocationParams; -use Allocator; -use BufferPool; -use Structure; +use crate::AllocationParams; +use crate::Allocator; +use crate::BufferPool; +use crate::Structure; -use glib; use glib::translate::{from_glib, from_glib_full, from_glib_none, ToGlib, ToGlibPtr, ToGlibPtrMut}; use glib::IsA; -use gst_sys; - use std::mem; use std::ops; use std::ptr; @@ -25,27 +22,27 @@ use std::ptr; pub struct BufferPoolConfig(Structure); impl ops::Deref for BufferPoolConfig { - type Target = ::StructureRef; + type Target = crate::StructureRef; - fn deref(&self) -> &::StructureRef { + fn deref(&self) -> &crate::StructureRef { self.0.deref() } } impl ops::DerefMut for BufferPoolConfig { - fn deref_mut(&mut self) -> &mut ::StructureRef { + fn deref_mut(&mut self) -> &mut crate::StructureRef { self.0.deref_mut() } } -impl AsRef<::StructureRef> for BufferPoolConfig { - fn as_ref(&self) -> &::StructureRef { +impl AsRef for BufferPoolConfig { + fn as_ref(&self) -> &crate::StructureRef { self.0.as_ref() } } -impl AsMut<::StructureRef> for BufferPoolConfig { - fn as_mut(&mut self) -> &mut ::StructureRef { +impl AsMut for BufferPoolConfig { + fn as_mut(&mut self) -> &mut crate::StructureRef { self.0.as_mut() } } @@ -53,7 +50,7 @@ impl AsMut<::StructureRef> for BufferPoolConfig { impl BufferPoolConfig { pub fn add_option(&mut self, option: &str) { unsafe { - gst_sys::gst_buffer_pool_config_add_option( + ffi::gst_buffer_pool_config_add_option( self.0.to_glib_none_mut().0, option.to_glib_none().0, ); @@ -62,7 +59,7 @@ impl BufferPoolConfig { pub fn has_option(&self, option: &str) -> bool { unsafe { - from_glib(gst_sys::gst_buffer_pool_config_has_option( + from_glib(ffi::gst_buffer_pool_config_has_option( self.0.to_glib_none().0, option.to_glib_none().0, )) @@ -71,11 +68,11 @@ impl BufferPoolConfig { pub fn get_options(&self) -> Vec { unsafe { - let n = gst_sys::gst_buffer_pool_config_n_options(self.0.to_glib_none().0) as usize; + let n = ffi::gst_buffer_pool_config_n_options(self.0.to_glib_none().0) as usize; let mut options = Vec::with_capacity(n); for i in 0..n { - options.push(from_glib_none(gst_sys::gst_buffer_pool_config_get_option( + options.push(from_glib_none(ffi::gst_buffer_pool_config_get_option( self.0.to_glib_none().0, i as u32, ))); @@ -87,13 +84,13 @@ impl BufferPoolConfig { pub fn set_params( &mut self, - caps: Option<&::Caps>, + caps: Option<&crate::Caps>, size: u32, min_buffers: u32, max_buffers: u32, ) { unsafe { - gst_sys::gst_buffer_pool_config_set_params( + ffi::gst_buffer_pool_config_set_params( self.0.to_glib_none_mut().0, caps.to_glib_none().0, size, @@ -103,14 +100,14 @@ impl BufferPoolConfig { } } - pub fn get_params(&self) -> Option<(Option<::Caps>, u32, u32, u32)> { + pub fn get_params(&self) -> Option<(Option, u32, u32, u32)> { unsafe { let mut caps = ptr::null_mut(); let mut size = mem::MaybeUninit::uninit(); let mut min_buffers = mem::MaybeUninit::uninit(); let mut max_buffers = mem::MaybeUninit::uninit(); - let ret: bool = from_glib(gst_sys::gst_buffer_pool_config_get_params( + let ret: bool = from_glib(ffi::gst_buffer_pool_config_get_params( self.0.to_glib_none().0, &mut caps, size.as_mut_ptr(), @@ -132,14 +129,14 @@ impl BufferPoolConfig { pub fn validate_params( &self, - caps: Option<&::Caps>, + caps: Option<&crate::Caps>, size: u32, min_buffers: u32, max_buffers: u32, ) -> Result<(), glib::BoolError> { unsafe { - glib_result_from_gboolean!( - gst_sys::gst_buffer_pool_config_validate_params( + glib::glib_result_from_gboolean!( + ffi::gst_buffer_pool_config_validate_params( self.0.to_glib_none().0, caps.to_glib_none().0, size, @@ -155,7 +152,7 @@ impl BufferPoolConfig { unsafe { let mut allocator = ptr::null_mut(); let mut params = mem::MaybeUninit::zeroed(); - let ret = from_glib(gst_sys::gst_buffer_pool_config_get_allocator( + let ret = from_glib(ffi::gst_buffer_pool_config_get_allocator( self.0.to_glib_none().0, &mut allocator, params.as_mut_ptr(), @@ -171,7 +168,7 @@ impl BufferPoolConfig { pub fn set_allocator(&self, allocator: Option<&Allocator>, params: Option<&AllocationParams>) { assert!(allocator.is_some() || params.is_some()); unsafe { - gst_sys::gst_buffer_pool_config_set_allocator( + ffi::gst_buffer_pool_config_set_allocator( self.0.to_glib_none().0, allocator.to_glib_none().0, match params { @@ -185,16 +182,16 @@ impl BufferPoolConfig { } #[derive(Debug)] -pub struct BufferPoolAcquireParams(gst_sys::GstBufferPoolAcquireParams); +pub struct BufferPoolAcquireParams(ffi::GstBufferPoolAcquireParams); unsafe impl Send for BufferPoolAcquireParams {} unsafe impl Sync for BufferPoolAcquireParams {} impl BufferPoolAcquireParams { - pub fn with_flags(flags: ::BufferPoolAcquireFlags) -> Self { + pub fn with_flags(flags: crate::BufferPoolAcquireFlags) -> Self { skip_assert_initialized!(); - BufferPoolAcquireParams(gst_sys::GstBufferPoolAcquireParams { - format: gst_sys::GST_FORMAT_UNDEFINED, + BufferPoolAcquireParams(ffi::GstBufferPoolAcquireParams { + format: ffi::GST_FORMAT_UNDEFINED, start: -1, stop: -1, flags: flags.to_glib(), @@ -202,14 +199,14 @@ impl BufferPoolAcquireParams { }) } - pub fn with_start_stop( + pub fn with_start_stop( start: T, stop: T, - flags: ::BufferPoolAcquireFlags, + flags: crate::BufferPoolAcquireFlags, ) -> Self { skip_assert_initialized!(); unsafe { - BufferPoolAcquireParams(gst_sys::GstBufferPoolAcquireParams { + BufferPoolAcquireParams(ffi::GstBufferPoolAcquireParams { format: start.get_format().to_glib(), start: start.to_raw_value(), stop: stop.to_raw_value(), @@ -219,20 +216,20 @@ impl BufferPoolAcquireParams { } } - pub fn flags(&self) -> ::BufferPoolAcquireFlags { + pub fn flags(&self) -> crate::BufferPoolAcquireFlags { from_glib(self.0.flags) } - pub fn format(&self) -> ::Format { + pub fn format(&self) -> crate::Format { from_glib(self.0.format) } - pub fn start(&self) -> ::GenericFormattedValue { - ::GenericFormattedValue::new(from_glib(self.0.format), self.0.start) + pub fn start(&self) -> crate::GenericFormattedValue { + crate::GenericFormattedValue::new(from_glib(self.0.format), self.0.start) } - pub fn stop(&self) -> ::GenericFormattedValue { - ::GenericFormattedValue::new(from_glib(self.0.format), self.0.stop) + pub fn stop(&self) -> crate::GenericFormattedValue { + crate::GenericFormattedValue::new(from_glib(self.0.format), self.0.stop) } } @@ -247,23 +244,23 @@ impl PartialEq for BufferPoolAcquireParams { impl Eq for BufferPoolAcquireParams {} #[doc(hidden)] -impl<'a> ToGlibPtr<'a, *const gst_sys::GstBufferPoolAcquireParams> for BufferPoolAcquireParams { +impl<'a> ToGlibPtr<'a, *const ffi::GstBufferPoolAcquireParams> for BufferPoolAcquireParams { type Storage = &'a Self; fn to_glib_none( &'a self, - ) -> glib::translate::Stash<'a, *const gst_sys::GstBufferPoolAcquireParams, Self> { + ) -> glib::translate::Stash<'a, *const ffi::GstBufferPoolAcquireParams, Self> { glib::translate::Stash(&self.0, self) } } #[doc(hidden)] -impl<'a> ToGlibPtrMut<'a, *mut gst_sys::GstBufferPoolAcquireParams> for BufferPoolAcquireParams { +impl<'a> ToGlibPtrMut<'a, *mut ffi::GstBufferPoolAcquireParams> for BufferPoolAcquireParams { type Storage = &'a mut Self; fn to_glib_none_mut( &'a mut self, - ) -> glib::translate::StashMut<'a, *mut gst_sys::GstBufferPoolAcquireParams, Self> { + ) -> glib::translate::StashMut<'a, *mut ffi::GstBufferPoolAcquireParams, Self> { glib::translate::StashMut(&mut self.0, self) } } @@ -271,12 +268,12 @@ impl<'a> ToGlibPtrMut<'a, *mut gst_sys::GstBufferPoolAcquireParams> for BufferPo impl BufferPool { pub fn new() -> BufferPool { assert_initialized_main_thread!(); - let (major, minor, _, _) = ::version(); + let (major, minor, _, _) = crate::version(); if (major, minor) > (1, 12) { - unsafe { from_glib_full(gst_sys::gst_buffer_pool_new()) } + unsafe { from_glib_full(ffi::gst_buffer_pool_new()) } } else { // Work-around for 1.14 switching from transfer-floating to transfer-full - unsafe { from_glib_none(gst_sys::gst_buffer_pool_new()) } + unsafe { from_glib_none(ffi::gst_buffer_pool_new()) } } } } @@ -296,22 +293,22 @@ pub trait BufferPoolExtManual: 'static { fn acquire_buffer( &self, params: Option<&BufferPoolAcquireParams>, - ) -> Result<::Buffer, ::FlowError>; - fn release_buffer(&self, buffer: ::Buffer); + ) -> Result; + fn release_buffer(&self, buffer: crate::Buffer); } impl> BufferPoolExtManual for O { fn get_config(&self) -> BufferPoolConfig { unsafe { - let ptr = gst_sys::gst_buffer_pool_get_config(self.as_ref().to_glib_none().0); + let ptr = ffi::gst_buffer_pool_get_config(self.as_ref().to_glib_none().0); BufferPoolConfig(from_glib_full(ptr)) } } fn set_config(&self, config: BufferPoolConfig) -> Result<(), glib::error::BoolError> { unsafe { - glib_result_from_gboolean!( - gst_sys::gst_buffer_pool_set_config( + glib::glib_result_from_gboolean!( + ffi::gst_buffer_pool_set_config( self.as_ref().to_glib_none().0, config.0.into_ptr() ), @@ -323,7 +320,7 @@ impl> BufferPoolExtManual for O { fn is_flushing(&self) -> bool { unsafe { let stash = self.as_ref().to_glib_none(); - let ptr: *mut gst_sys::GstBufferPool = stash.0; + let ptr: *mut ffi::GstBufferPool = stash.0; from_glib((*ptr).flushing) } @@ -332,12 +329,12 @@ impl> BufferPoolExtManual for O { fn acquire_buffer( &self, params: Option<&BufferPoolAcquireParams>, - ) -> Result<::Buffer, ::FlowError> { + ) -> Result { let params_ptr = params.to_glib_none().0 as *mut _; unsafe { let mut buffer = ptr::null_mut(); - let ret: ::FlowReturn = from_glib(gst_sys::gst_buffer_pool_acquire_buffer( + let ret: crate::FlowReturn = from_glib(ffi::gst_buffer_pool_acquire_buffer( self.as_ref().to_glib_none().0, &mut buffer, params_ptr, @@ -347,12 +344,9 @@ impl> BufferPoolExtManual for O { } } - fn release_buffer(&self, buffer: ::Buffer) { + fn release_buffer(&self, buffer: crate::Buffer) { unsafe { - gst_sys::gst_buffer_pool_release_buffer( - self.as_ref().to_glib_none().0, - buffer.into_ptr(), - ); + ffi::gst_buffer_pool_release_buffer(self.as_ref().to_glib_none().0, buffer.into_ptr()); } } } @@ -360,20 +354,21 @@ impl> BufferPoolExtManual for O { #[cfg(test)] mod tests { use super::*; - use prelude::*; + use crate::prelude::*; #[test] fn test_pool() { - ::init().unwrap(); + crate::init().unwrap(); - let pool = ::BufferPool::new(); + let pool = crate::BufferPool::new(); let mut config = pool.get_config(); - config.set_params(Some(&::Caps::new_simple("foo/bar", &[])), 1024, 0, 2); + config.set_params(Some(&crate::Caps::new_simple("foo/bar", &[])), 1024, 0, 2); pool.set_config(config).unwrap(); pool.set_active(true).unwrap(); - let params = ::BufferPoolAcquireParams::with_flags(::BufferPoolAcquireFlags::DONTWAIT); + let params = + crate::BufferPoolAcquireParams::with_flags(crate::BufferPoolAcquireFlags::DONTWAIT); let _buf1 = pool.acquire_buffer(Some(¶ms)).unwrap(); let buf2 = pool.acquire_buffer(Some(¶ms)).unwrap(); diff --git a/gstreamer/src/buffer_serde.rs b/gstreamer/src/buffer_serde.rs index 1a199261f..472464ab0 100644 --- a/gstreamer/src/buffer_serde.rs +++ b/gstreamer/src/buffer_serde.rs @@ -11,10 +11,10 @@ use serde::ser; use serde::ser::{Serialize, SerializeStruct, Serializer}; use serde_bytes::{ByteBuf, Bytes}; -use Buffer; -use BufferFlags; -use BufferRef; -use ClockTime; +use crate::Buffer; +use crate::BufferFlags; +use crate::BufferRef; +use crate::ClockTime; // TODO: try `Either` to merge the base reprensentations for ser and de // while avoiding unneeded copy @@ -44,7 +44,7 @@ impl<'a> Serialize for Buffer { } } -#[derive(Deserialize)] +#[derive(serde::Deserialize)] struct BufferDe { pts: ClockTime, dts: ClockTime, @@ -81,15 +81,12 @@ impl<'de> Deserialize<'de> for Buffer { #[cfg(test)] mod tests { - extern crate ron; - extern crate serde_json; - - use Buffer; - use BufferFlags; + use crate::Buffer; + use crate::BufferFlags; #[test] fn test_serialize() { - ::init().unwrap(); + crate::init().unwrap(); let mut buffer = Buffer::from_slice(vec![1, 2, 3, 4]); { @@ -143,7 +140,7 @@ mod tests { #[test] fn test_deserialize() { - ::init().unwrap(); + crate::init().unwrap(); let buffer_ron = r#" ( @@ -196,7 +193,7 @@ mod tests { #[test] fn test_serde_roundtrip() { - ::init().unwrap(); + crate::init().unwrap(); let mut buffer = Buffer::from_slice(vec![1, 2, 3, 4]); { diff --git a/gstreamer/src/bufferlist.rs b/gstreamer/src/bufferlist.rs index c7a0b92e5..8b21067f2 100644 --- a/gstreamer/src/bufferlist.rs +++ b/gstreamer/src/bufferlist.rs @@ -6,35 +6,33 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use glib; use glib::translate::{from_glib, from_glib_full, from_glib_none, ToGlib}; -use gst_sys; use std::fmt; use std::ptr; -use Buffer; -use BufferRef; +use crate::Buffer; +use crate::BufferRef; -gst_define_mini_object_wrapper!(BufferList, BufferListRef, gst_sys::GstBufferList, || { - gst_sys::gst_buffer_list_get_type() +gst_define_mini_object_wrapper!(BufferList, BufferListRef, ffi::GstBufferList, || { + ffi::gst_buffer_list_get_type() }); impl BufferList { pub fn new() -> Self { assert_initialized_main_thread!(); - unsafe { from_glib_full(gst_sys::gst_buffer_list_new()) } + unsafe { from_glib_full(ffi::gst_buffer_list_new()) } } pub fn new_sized(size: usize) -> Self { assert_initialized_main_thread!(); - unsafe { from_glib_full(gst_sys::gst_buffer_list_new_sized(size as u32)) } + unsafe { from_glib_full(ffi::gst_buffer_list_new_sized(size as u32)) } } } impl BufferListRef { pub fn insert(&mut self, idx: i32, buffer: Buffer) { unsafe { - gst_sys::gst_buffer_list_insert(self.as_mut_ptr(), idx, buffer.into_ptr()); + ffi::gst_buffer_list_insert(self.as_mut_ptr(), idx, buffer.into_ptr()); } } @@ -43,16 +41,16 @@ impl BufferListRef { } pub fn copy_deep(&self) -> BufferList { - unsafe { from_glib_full(gst_sys::gst_buffer_list_copy_deep(self.as_ptr())) } + unsafe { from_glib_full(ffi::gst_buffer_list_copy_deep(self.as_ptr())) } } pub fn remove(&mut self, idx: u32, len: u32) { - unsafe { gst_sys::gst_buffer_list_remove(self.as_mut_ptr(), idx, len) } + unsafe { ffi::gst_buffer_list_remove(self.as_mut_ptr(), idx, len) } } pub fn get(&self, idx: u32) -> Option<&BufferRef> { unsafe { - let ptr = gst_sys::gst_buffer_list_get(self.as_mut_ptr(), idx); + let ptr = ffi::gst_buffer_list_get(self.as_mut_ptr(), idx); if ptr.is_null() { None } else { @@ -63,7 +61,7 @@ impl BufferListRef { pub fn get_owned(&self, idx: u32) -> Option { unsafe { - let ptr = gst_sys::gst_buffer_list_get(self.as_mut_ptr(), idx); + let ptr = ffi::gst_buffer_list_get(self.as_mut_ptr(), idx); from_glib_none(ptr) } } @@ -72,7 +70,7 @@ impl BufferListRef { #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_14")))] pub fn get_writable(&mut self, idx: u32) -> Option<&mut BufferRef> { unsafe { - let ptr = gst_sys::gst_buffer_list_get_writable(self.as_mut_ptr(), idx); + let ptr = ffi::gst_buffer_list_get_writable(self.as_mut_ptr(), idx); if ptr.is_null() { None } else { @@ -82,13 +80,13 @@ impl BufferListRef { } pub fn len(&self) -> usize { - unsafe { gst_sys::gst_buffer_list_length(self.as_mut_ptr()) as usize } + unsafe { ffi::gst_buffer_list_length(self.as_mut_ptr()) as usize } } #[cfg(any(feature = "v1_14", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_14")))] pub fn calculate_size(&self) -> usize { - unsafe { gst_sys::gst_buffer_list_calculate_size(self.as_mut_ptr()) as usize } + unsafe { ffi::gst_buffer_list_calculate_size(self.as_mut_ptr()) as usize } } pub fn is_empty(&self) -> bool { @@ -105,10 +103,10 @@ impl BufferListRef { pub fn foreach bool>(&self, func: F) -> bool { unsafe extern "C" fn trampoline bool>( - buffer: *mut *mut gst_sys::GstBuffer, + buffer: *mut *mut ffi::GstBuffer, idx: u32, - user_data: glib_sys::gpointer, - ) -> glib_sys::gboolean { + user_data: glib::ffi::gpointer, + ) -> glib::ffi::gboolean { let func = user_data as *const _ as usize as *mut F; let res = (*func)(BufferRef::from_ptr(*buffer), idx); @@ -118,7 +116,7 @@ impl BufferListRef { unsafe { let func_ptr: &F = &func; - from_glib(gst_sys::gst_buffer_list_foreach( + from_glib(ffi::gst_buffer_list_foreach( self.as_ptr() as *mut _, Some(trampoline::), func_ptr as *const _ as usize as *mut _, @@ -133,10 +131,10 @@ impl BufferListRef { unsafe extern "C" fn trampoline< F: FnMut(Buffer, u32) -> Result, Option>, >( - buffer: *mut *mut gst_sys::GstBuffer, + buffer: *mut *mut ffi::GstBuffer, idx: u32, - user_data: glib_sys::gpointer, - ) -> glib_sys::gboolean { + user_data: glib::ffi::gpointer, + ) -> glib::ffi::gboolean { let func = user_data as *const _ as usize as *mut F; let res = (*func)(Buffer::from_glib_full(*buffer), idx); @@ -147,11 +145,11 @@ impl BufferListRef { } Ok(Some(b)) => { *buffer = b.into_ptr(); - glib_sys::GTRUE + glib::ffi::GTRUE } Err(Some(b)) => { *buffer = b.into_ptr(); - glib_sys::GFALSE + glib::ffi::GFALSE } } } @@ -159,7 +157,7 @@ impl BufferListRef { unsafe { let func_ptr: &F = &func; - from_glib(gst_sys::gst_buffer_list_foreach( + from_glib(ffi::gst_buffer_list_foreach( self.as_ptr() as *mut _, Some(trampoline::), func_ptr as *const _ as usize as *mut _, @@ -186,7 +184,7 @@ impl fmt::Debug for BufferListRef { let (pts, dts) = self .get(0) .map(|b| (b.get_pts(), b.get_dts())) - .unwrap_or((::ClockTime::none(), ::ClockTime::none())); + .unwrap_or((crate::ClockTime::none(), crate::ClockTime::none())); f.debug_struct("BufferList") .field("ptr", unsafe { &self.as_ptr() }) @@ -272,17 +270,17 @@ mod tests { #[test] fn test_foreach() { - ::init().unwrap(); + crate::init().unwrap(); let mut buffer_list = BufferList::new(); { let buffer_list = buffer_list.get_mut().unwrap(); let mut buffer = Buffer::new(); - buffer.get_mut().unwrap().set_pts(::ClockTime::from(0)); + buffer.get_mut().unwrap().set_pts(crate::ClockTime::from(0)); buffer_list.add(buffer); let mut buffer = Buffer::new(); - buffer.get_mut().unwrap().set_pts(::SECOND); + buffer.get_mut().unwrap().set_pts(crate::SECOND); buffer_list.add(buffer); } @@ -293,26 +291,26 @@ mod tests { true }); - assert_eq!(res, &[(::ClockTime::from(0), 0), (::SECOND, 1)]); + assert_eq!(res, &[(crate::ClockTime::from(0), 0), (crate::SECOND, 1)]); } #[test] fn test_foreach_mut() { - ::init().unwrap(); + crate::init().unwrap(); let mut buffer_list = BufferList::new(); { let buffer_list = buffer_list.get_mut().unwrap(); let mut buffer = Buffer::new(); - buffer.get_mut().unwrap().set_pts(::ClockTime::from(0)); + buffer.get_mut().unwrap().set_pts(crate::ClockTime::from(0)); buffer_list.add(buffer); let mut buffer = Buffer::new(); - buffer.get_mut().unwrap().set_pts(::SECOND); + buffer.get_mut().unwrap().set_pts(crate::SECOND); buffer_list.add(buffer); let mut buffer = Buffer::new(); - buffer.get_mut().unwrap().set_pts(2 * ::SECOND); + buffer.get_mut().unwrap().set_pts(2 * crate::SECOND); buffer_list.add(buffer); } @@ -320,20 +318,24 @@ mod tests { buffer_list.get_mut().unwrap().foreach_mut(|buffer, idx| { res.push((buffer.get_pts(), idx)); - if buffer.get_pts() == ::ClockTime::from(0) { + if buffer.get_pts() == crate::ClockTime::from(0) { Ok(Some(buffer)) - } else if buffer.get_pts() == ::SECOND { + } else if buffer.get_pts() == crate::SECOND { Ok(None) } else { let mut new_buffer = Buffer::new(); - new_buffer.get_mut().unwrap().set_pts(3 * ::SECOND); + new_buffer.get_mut().unwrap().set_pts(3 * crate::SECOND); Ok(Some(new_buffer)) } }); assert_eq!( res, - &[(::ClockTime::from(0), 0), (::SECOND, 1), (2 * ::SECOND, 1)] + &[ + (crate::ClockTime::from(0), 0), + (crate::SECOND, 1), + (2 * crate::SECOND, 1) + ] ); let mut res = vec![]; @@ -343,6 +345,9 @@ mod tests { true }); - assert_eq!(res, &[(::ClockTime::from(0), 0), (3 * ::SECOND, 1)]); + assert_eq!( + res, + &[(crate::ClockTime::from(0), 0), (3 * crate::SECOND, 1)] + ); } } diff --git a/gstreamer/src/bufferlist_serde.rs b/gstreamer/src/bufferlist_serde.rs index cc9ffc940..f96db3b78 100644 --- a/gstreamer/src/bufferlist_serde.rs +++ b/gstreamer/src/bufferlist_serde.rs @@ -11,9 +11,9 @@ use serde::ser::{Serialize, SerializeSeq, Serializer}; use std::fmt; -use Buffer; -use BufferList; -use BufferListRef; +use crate::Buffer; +use crate::BufferList; +use crate::BufferListRef; impl Serialize for BufferListRef { fn serialize(&self, serializer: S) -> Result { @@ -67,15 +67,13 @@ impl<'de> Deserialize<'de> for BufferList { #[cfg(test)] mod tests { - extern crate ron; - - use BufferList; + use crate::BufferList; #[test] fn test_serialize() { - use Buffer; + use crate::Buffer; - ::init().unwrap(); + crate::init().unwrap(); let mut buffer_list = BufferList::new(); { @@ -140,7 +138,7 @@ mod tests { #[test] fn test_deserialize() { - ::init().unwrap(); + crate::init().unwrap(); let buffer_list_ron = r#" [ @@ -189,9 +187,9 @@ mod tests { #[test] fn test_serde_roundtrip() { - use Buffer; + use crate::Buffer; - ::init().unwrap(); + crate::init().unwrap(); let mut buffer_list = BufferList::new(); { diff --git a/gstreamer/src/bus.rs b/gstreamer/src/bus.rs index bda99081f..39da5b85c 100644 --- a/gstreamer/src/bus.rs +++ b/gstreamer/src/bus.rs @@ -9,26 +9,23 @@ use futures_channel::mpsc::{self, UnboundedReceiver}; use futures_core::Stream; use futures_util::{future, StreamExt}; -use glib; +use glib::ffi::{gboolean, gpointer}; use glib::prelude::*; use glib::source::{Continue, Priority, SourceId}; use glib::translate::*; -use glib_sys; -use glib_sys::{gboolean, gpointer}; -use gst_sys; use std::cell::RefCell; use std::mem::transmute; use std::pin::Pin; use std::task::{Context, Poll}; -use Bus; -use BusSyncReply; -use Message; -use MessageType; +use crate::Bus; +use crate::BusSyncReply; +use crate::Message; +use crate::MessageType; unsafe extern "C" fn trampoline_watch Continue + 'static>( - bus: *mut gst_sys::GstBus, - msg: *mut gst_sys::GstMessage, + bus: *mut ffi::GstBus, + msg: *mut ffi::GstMessage, func: gpointer, ) -> gboolean { let func: &RefCell = &*(func as *const RefCell); @@ -50,15 +47,15 @@ fn into_raw_watch Continue + 'static>(func: F) -> gp unsafe extern "C" fn trampoline_sync< F: Fn(&Bus, &Message) -> BusSyncReply + Send + Sync + 'static, >( - bus: *mut gst_sys::GstBus, - msg: *mut gst_sys::GstMessage, + bus: *mut ffi::GstBus, + msg: *mut ffi::GstMessage, func: gpointer, -) -> gst_sys::GstBusSyncReply { +) -> ffi::GstBusSyncReply { let f: &F = &*(func as *const F); let res = f(&from_glib_borrow(bus), &Message::from_glib_borrow(msg)).to_glib(); - if res == gst_sys::GST_BUS_DROP { - gst_sys::gst_mini_object_unref(msg as *mut _); + if res == ffi::GST_BUS_DROP { + ffi::gst_mini_object_unref(msg as *mut _); } res @@ -82,7 +79,7 @@ fn into_raw_sync BusSyncReply + Send + Sync + 'static>( impl Bus { pub fn add_signal_watch_full(&self, priority: Priority) { unsafe { - gst_sys::gst_bus_add_signal_watch_full(self.to_glib_none().0, priority.to_glib()); + ffi::gst_bus_add_signal_watch_full(self.to_glib_none().0, priority.to_glib()); } } @@ -92,20 +89,20 @@ impl Bus { { skip_assert_initialized!(); unsafe { - let source = gst_sys::gst_bus_create_watch(self.to_glib_none().0); - glib_sys::g_source_set_callback( + let source = ffi::gst_bus_create_watch(self.to_glib_none().0); + glib::ffi::g_source_set_callback( source, Some(transmute::< _, - unsafe extern "C" fn(glib_sys::gpointer) -> i32, + unsafe extern "C" fn(glib::ffi::gpointer) -> i32, >(trampoline_watch:: as *const ())), into_raw_watch(func), Some(destroy_closure_watch::), ); - glib_sys::g_source_set_priority(source, priority.to_glib()); + glib::ffi::g_source_set_priority(source, priority.to_glib()); if let Some(name) = name { - glib_sys::g_source_set_name(source, name.to_glib_none().0); + glib::ffi::g_source_set_name(source, name.to_glib_none().0); } from_glib_full(source) @@ -117,16 +114,16 @@ impl Bus { F: FnMut(&Bus, &Message) -> Continue + Send + 'static, { unsafe { - let res = gst_sys::gst_bus_add_watch_full( + let res = ffi::gst_bus_add_watch_full( self.to_glib_none().0, - glib_sys::G_PRIORITY_DEFAULT, + glib::ffi::G_PRIORITY_DEFAULT, Some(trampoline_watch::), into_raw_watch(func), Some(destroy_closure_watch::), ); if res == 0 { - Err(glib_bool_error!("Bus already has a watch")) + Err(glib::glib_bool_error!("Bus already has a watch")) } else { Ok(from_glib(res)) } @@ -140,16 +137,16 @@ impl Bus { unsafe { assert!(glib::MainContext::ref_thread_default().is_owner()); - let res = gst_sys::gst_bus_add_watch_full( + let res = ffi::gst_bus_add_watch_full( self.to_glib_none().0, - glib_sys::G_PRIORITY_DEFAULT, + glib::ffi::G_PRIORITY_DEFAULT, Some(trampoline_watch::), into_raw_watch(func), Some(destroy_closure_watch::), ); if res == 0 { - Err(glib_bool_error!("Bus already has a watch")) + Err(glib::glib_bool_error!("Bus already has a watch")) } else { Ok(from_glib(res)) } @@ -169,21 +166,21 @@ impl Bus { // This is not thread-safe before 1.16.3, see // https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/merge_requests/416 - if ::version() < (1, 16, 3, 0) { - if !gobject_sys::g_object_get_qdata(bus as *mut _, SET_ONCE_QUARK.to_glib()) + if crate::version() < (1, 16, 3, 0) { + if !glib::gobject_ffi::g_object_get_qdata(bus as *mut _, SET_ONCE_QUARK.to_glib()) .is_null() { panic!("Bus sync handler can only be set once"); } - gobject_sys::g_object_set_qdata( + glib::gobject_ffi::g_object_set_qdata( bus as *mut _, SET_ONCE_QUARK.to_glib(), 1 as *mut _, ); } - gst_sys::gst_bus_set_sync_handler( + ffi::gst_bus_set_sync_handler( bus, Some(trampoline_sync::), into_raw_sync(func), @@ -195,14 +192,14 @@ impl Bus { pub fn unset_sync_handler(&self) { // This is not thread-safe before 1.16.3, see // https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/merge_requests/416 - if ::version() < (1, 16, 3, 0) { + if crate::version() < (1, 16, 3, 0) { return; } unsafe { use std::ptr; - gst_sys::gst_bus_set_sync_handler(self.to_glib_none().0, None, ptr::null_mut(), None) + ffi::gst_bus_set_sync_handler(self.to_glib_none().0, None, ptr::null_mut(), None) } } @@ -210,7 +207,7 @@ impl Bus { self.iter_timed(0.into()) } - pub fn iter_timed(&self, timeout: ::ClockTime) -> Iter { + pub fn iter_timed(&self, timeout: crate::ClockTime) -> Iter { Iter { bus: self, timeout } } @@ -223,7 +220,7 @@ impl Bus { pub fn iter_timed_filtered<'a>( &'a self, - timeout: ::ClockTime, + timeout: crate::ClockTime, msg_types: &'a [MessageType], ) -> impl Iterator + 'a { self.iter_timed(timeout) @@ -232,7 +229,7 @@ impl Bus { pub fn timed_pop_filtered( &self, - timeout: ::ClockTime, + timeout: crate::ClockTime, msg_types: &[MessageType], ) -> Option { loop { @@ -271,7 +268,7 @@ impl Bus { #[derive(Debug)] pub struct Iter<'a> { bus: &'a Bus, - timeout: ::ClockTime, + timeout: crate::ClockTime, } impl<'a> Iterator for Iter<'a> { @@ -330,7 +327,7 @@ mod tests { #[test] fn test_sync_handler() { - ::init().unwrap(); + crate::init().unwrap(); let bus = Bus::new(); let msgs = Arc::new(Mutex::new(Vec::new())); @@ -340,31 +337,31 @@ mod tests { BusSyncReply::Pass }); - bus.post(&::message::Eos::new()).unwrap(); + bus.post(&crate::message::Eos::new()).unwrap(); let msgs = msgs.lock().unwrap(); assert_eq!(msgs.len(), 1); match msgs[0].view() { - ::MessageView::Eos(_) => (), + crate::MessageView::Eos(_) => (), _ => unreachable!(), } } #[test] fn test_bus_stream() { - ::init().unwrap(); + crate::init().unwrap(); let bus = Bus::new(); let bus_stream = bus.stream(); - let eos_message = ::message::Eos::new(); + let eos_message = crate::message::Eos::new(); bus.post(&eos_message).unwrap(); let bus_future = bus_stream.into_future(); let (message, _) = futures_executor::block_on(bus_future); match message.unwrap().view() { - ::MessageView::Eos(_) => (), + crate::MessageView::Eos(_) => (), _ => unreachable!(), } } diff --git a/gstreamer/src/bus_unix.rs b/gstreamer/src/bus_unix.rs index 966cdfbbc..c9cedf109 100644 --- a/gstreamer/src/bus_unix.rs +++ b/gstreamer/src/bus_unix.rs @@ -7,9 +7,8 @@ // except according to those terms. #[macro_use] -cfg_if! { +cfg_if::cfg_if! { if #[cfg(unix)] { - use gst_sys; use glib::translate::ToGlibPtr; use std::mem; @@ -35,7 +34,7 @@ impl UnixBusExtManual for Bus { #[cfg(unix)] unsafe { let mut pollfd = mem::MaybeUninit::zeroed(); - gst_sys::gst_bus_get_pollfd(self.to_glib_none().0, pollfd.as_mut_ptr()); + ffi::gst_bus_get_pollfd(self.to_glib_none().0, pollfd.as_mut_ptr()); let pollfd = pollfd.assume_init(); pollfd.fd } diff --git a/gstreamer/src/bus_windows.rs b/gstreamer/src/bus_windows.rs index f8ab4de4a..76cc7648e 100644 --- a/gstreamer/src/bus_windows.rs +++ b/gstreamer/src/bus_windows.rs @@ -7,9 +7,8 @@ // except according to those terms. #[macro_use] -cfg_if! { +cfg_if::cfg_if! { if #[cfg(windows)] { - use gst_sys; use glib::translate::ToGlibPtr; use std::mem; @@ -35,7 +34,7 @@ impl WindowsBusExtManual for Bus { #[cfg(windows)] unsafe { let mut pollfd = mem::MaybeUninit::zeroed(); - gst_sys::gst_bus_get_pollfd(self.to_glib_none().0, pollfd.as_mut_ptr()); + ffi::gst_bus_get_pollfd(self.to_glib_none().0, pollfd.as_mut_ptr()); let pollfd = pollfd.assume_init(); pollfd.fd as *mut _ } diff --git a/gstreamer/src/caps.rs b/gstreamer/src/caps.rs index 1fdd33a9a..d13bebe18 100644 --- a/gstreamer/src/caps.rs +++ b/gstreamer/src/caps.rs @@ -6,23 +6,19 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use caps_features::*; +use crate::caps_features::*; +use crate::structure::*; use std::fmt; use std::marker::PhantomData; use std::ptr; use std::str; -use structure::*; -use CapsIntersectMode; +use crate::CapsIntersectMode; -use glib; use glib::translate::{from_glib, from_glib_full, FromGlibPtrFull, ToGlib, ToGlibPtr}; use glib::value::ToSendValue; -use gst_sys; -gst_define_mini_object_wrapper!(Caps, CapsRef, gst_sys::GstCaps, || { - gst_sys::gst_caps_get_type() -}); +gst_define_mini_object_wrapper!(Caps, CapsRef, ffi::GstCaps, || { ffi::gst_caps_get_type() }); impl Caps { pub fn builder(name: &str) -> Builder { @@ -47,12 +43,12 @@ impl Caps { pub fn new_empty() -> Self { assert_initialized_main_thread!(); - unsafe { from_glib_full(gst_sys::gst_caps_new_empty()) } + unsafe { from_glib_full(ffi::gst_caps_new_empty()) } } pub fn new_any() -> Self { assert_initialized_main_thread!(); - unsafe { from_glib_full(gst_sys::gst_caps_new_any()) } + unsafe { from_glib_full(ffi::gst_caps_new_any()) } } pub fn new_simple(name: &str, values: &[(&str, &dyn ToSendValue)]) -> Self { @@ -101,9 +97,9 @@ impl Caps { // See https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/388 assert!(!self.is_any()); let ptr = if self.is_empty() { - gst_sys::gst_caps_new_empty() + ffi::gst_caps_new_empty() } else { - gst_sys::gst_caps_fixate(self.as_mut_ptr()) + ffi::gst_caps_fixate(self.as_mut_ptr()) }; self.replace_ptr(ptr); } @@ -112,7 +108,7 @@ impl Caps { pub fn merge(&mut self, other: Self) { skip_assert_initialized!(); unsafe { - let ptr = gst_sys::gst_caps_merge(self.as_mut_ptr(), other.into_ptr()); + let ptr = ffi::gst_caps_merge(self.as_mut_ptr(), other.into_ptr()); self.replace_ptr(ptr); } } @@ -120,7 +116,7 @@ impl Caps { pub fn merge_structure(&mut self, structure: Structure) { skip_assert_initialized!(); unsafe { - let ptr = gst_sys::gst_caps_merge_structure(self.as_mut_ptr(), structure.into_ptr()); + let ptr = ffi::gst_caps_merge_structure(self.as_mut_ptr(), structure.into_ptr()); self.replace_ptr(ptr); } } @@ -128,7 +124,7 @@ impl Caps { pub fn merge_structure_full(&mut self, structure: Structure, features: Option) { skip_assert_initialized!(); unsafe { - let ptr = gst_sys::gst_caps_merge_structure_full( + let ptr = ffi::gst_caps_merge_structure_full( self.as_mut_ptr(), structure.into_ptr(), features.map(|f| f.into_ptr()).unwrap_or(ptr::null_mut()), @@ -140,7 +136,7 @@ impl Caps { pub fn normalize(&mut self) { skip_assert_initialized!(); unsafe { - let ptr = gst_sys::gst_caps_normalize(self.as_mut_ptr()); + let ptr = ffi::gst_caps_normalize(self.as_mut_ptr()); self.replace_ptr(ptr); } } @@ -148,7 +144,7 @@ impl Caps { pub fn simplify(&mut self) { skip_assert_initialized!(); unsafe { - let ptr = gst_sys::gst_caps_simplify(self.as_mut_ptr()); + let ptr = ffi::gst_caps_simplify(self.as_mut_ptr()); self.replace_ptr(ptr); } } @@ -156,7 +152,7 @@ impl Caps { pub fn truncate(&mut self) { skip_assert_initialized!(); unsafe { - let ptr = gst_sys::gst_caps_truncate(self.as_mut_ptr()); + let ptr = ffi::gst_caps_truncate(self.as_mut_ptr()); self.replace_ptr(ptr); } } @@ -168,8 +164,8 @@ impl str::FromStr for Caps { fn from_str(s: &str) -> Result { assert_initialized_main_thread!(); unsafe { - Option::<_>::from_glib_full(gst_sys::gst_caps_from_string(s.to_glib_none().0)) - .ok_or_else(|| glib_bool_error!("Failed to parse caps from string")) + Option::<_>::from_glib_full(ffi::gst_caps_from_string(s.to_glib_none().0)) + .ok_or_else(|| glib::glib_bool_error!("Failed to parse caps from string")) } } } @@ -180,7 +176,7 @@ impl CapsRef { let value = value.to_value(); unsafe { - gst_sys::gst_caps_set_value( + ffi::gst_caps_set_value( self.as_mut_ptr(), name.to_glib_none().0, value.to_glib_none().0, @@ -195,7 +191,7 @@ impl CapsRef { } unsafe { - let structure = gst_sys::gst_caps_get_structure(self.as_ptr(), idx); + let structure = ffi::gst_caps_get_structure(self.as_ptr(), idx); if structure.is_null() { return None; } @@ -210,7 +206,7 @@ impl CapsRef { } unsafe { - let structure = gst_sys::gst_caps_get_structure(self.as_ptr(), idx); + let structure = ffi::gst_caps_get_structure(self.as_ptr(), idx); if structure.is_null() { return None; } @@ -225,7 +221,7 @@ impl CapsRef { } unsafe { - let features = gst_sys::gst_caps_get_features(self.as_ptr(), idx); + let features = ffi::gst_caps_get_features(self.as_ptr(), idx); Some(CapsFeaturesRef::from_glib_borrow(features)) } } @@ -236,7 +232,7 @@ impl CapsRef { } unsafe { - let features = gst_sys::gst_caps_get_features(self.as_ptr(), idx); + let features = ffi::gst_caps_get_features(self.as_ptr(), idx); Some(CapsFeaturesRef::from_glib_borrow_mut(features)) } } @@ -245,7 +241,7 @@ impl CapsRef { assert!(idx < self.get_size()); unsafe { - gst_sys::gst_caps_set_features( + ffi::gst_caps_set_features( self.as_mut_ptr(), idx, features.map(|f| f.into_ptr()).unwrap_or(ptr::null_mut()), @@ -257,7 +253,7 @@ impl CapsRef { #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_16")))] pub fn set_features_simple(&mut self, features: Option) { unsafe { - gst_sys::gst_caps_set_features_simple( + ffi::gst_caps_set_features_simple( self.as_mut_ptr(), features.map(|f| f.into_ptr()).unwrap_or(ptr::null_mut()), ) @@ -265,7 +261,7 @@ impl CapsRef { } pub fn get_size(&self) -> u32 { - unsafe { gst_sys::gst_caps_get_size(self.as_ptr()) } + unsafe { ffi::gst_caps_get_size(self.as_ptr()) } } pub fn iter(&self) -> Iter { @@ -285,12 +281,12 @@ impl CapsRef { } pub fn append_structure(&mut self, structure: Structure) { - unsafe { gst_sys::gst_caps_append_structure(self.as_mut_ptr(), structure.into_ptr()) } + unsafe { ffi::gst_caps_append_structure(self.as_mut_ptr(), structure.into_ptr()) } } pub fn append_structure_full(&mut self, structure: Structure, features: Option) { unsafe { - gst_sys::gst_caps_append_structure_full( + ffi::gst_caps_append_structure_full( self.as_mut_ptr(), structure.into_ptr(), features.map(|f| f.into_ptr()).unwrap_or(ptr::null_mut()), @@ -299,25 +295,20 @@ impl CapsRef { } pub fn remove_structure(&mut self, idx: u32) { - unsafe { gst_sys::gst_caps_remove_structure(self.as_mut_ptr(), idx) } + unsafe { ffi::gst_caps_remove_structure(self.as_mut_ptr(), idx) } } pub fn append(&mut self, other: Caps) { - unsafe { gst_sys::gst_caps_append(self.as_mut_ptr(), other.into_ptr()) } + unsafe { ffi::gst_caps_append(self.as_mut_ptr(), other.into_ptr()) } } pub fn can_intersect(&self, other: &Self) -> bool { - unsafe { - from_glib(gst_sys::gst_caps_can_intersect( - self.as_ptr(), - other.as_ptr(), - )) - } + unsafe { from_glib(ffi::gst_caps_can_intersect(self.as_ptr(), other.as_ptr())) } } pub fn intersect(&self, other: &Self) -> Caps { unsafe { - from_glib_full(gst_sys::gst_caps_intersect( + from_glib_full(ffi::gst_caps_intersect( self.as_mut_ptr(), other.as_mut_ptr(), )) @@ -326,7 +317,7 @@ impl CapsRef { pub fn intersect_with_mode(&self, other: &Self, mode: CapsIntersectMode) -> Caps { unsafe { - from_glib_full(gst_sys::gst_caps_intersect_full( + from_glib_full(ffi::gst_caps_intersect_full( self.as_mut_ptr(), other.as_mut_ptr(), mode.to_glib(), @@ -336,7 +327,7 @@ impl CapsRef { pub fn is_always_compatible(&self, other: &Self) -> bool { unsafe { - from_glib(gst_sys::gst_caps_is_always_compatible( + from_glib(ffi::gst_caps_is_always_compatible( self.as_ptr(), other.as_ptr(), )) @@ -344,29 +335,24 @@ impl CapsRef { } pub fn is_any(&self) -> bool { - unsafe { from_glib(gst_sys::gst_caps_is_any(self.as_ptr())) } + unsafe { from_glib(ffi::gst_caps_is_any(self.as_ptr())) } } pub fn is_empty(&self) -> bool { - unsafe { from_glib(gst_sys::gst_caps_is_empty(self.as_ptr())) } + unsafe { from_glib(ffi::gst_caps_is_empty(self.as_ptr())) } } pub fn is_fixed(&self) -> bool { - unsafe { from_glib(gst_sys::gst_caps_is_fixed(self.as_ptr())) } + unsafe { from_glib(ffi::gst_caps_is_fixed(self.as_ptr())) } } pub fn is_equal_fixed(&self, other: &Self) -> bool { - unsafe { - from_glib(gst_sys::gst_caps_is_equal_fixed( - self.as_ptr(), - other.as_ptr(), - )) - } + unsafe { from_glib(ffi::gst_caps_is_equal_fixed(self.as_ptr(), other.as_ptr())) } } pub fn is_strictly_equal(&self, other: &Self) -> bool { unsafe { - from_glib(gst_sys::gst_caps_is_strictly_equal( + from_glib(ffi::gst_caps_is_strictly_equal( self.as_ptr(), other.as_ptr(), )) @@ -374,17 +360,12 @@ impl CapsRef { } pub fn is_subset(&self, superset: &Self) -> bool { - unsafe { - from_glib(gst_sys::gst_caps_is_subset( - self.as_ptr(), - superset.as_ptr(), - )) - } + unsafe { from_glib(ffi::gst_caps_is_subset(self.as_ptr(), superset.as_ptr())) } } pub fn is_subset_structure(&self, structure: &StructureRef) -> bool { unsafe { - from_glib(gst_sys::gst_caps_is_subset_structure( + from_glib(ffi::gst_caps_is_subset_structure( self.as_ptr(), structure.as_ptr(), )) @@ -397,7 +378,7 @@ impl CapsRef { features: Option<&CapsFeaturesRef>, ) -> bool { unsafe { - from_glib(gst_sys::gst_caps_is_subset_structure_full( + from_glib(ffi::gst_caps_is_subset_structure_full( self.as_ptr(), structure.as_ptr(), features.map(|f| f.as_ptr()).unwrap_or(ptr::null()), @@ -408,7 +389,7 @@ impl CapsRef { pub fn subtract(&self, other: &Self) -> Caps { skip_assert_initialized!(); unsafe { - from_glib_full(gst_sys::gst_caps_subtract( + from_glib_full(ffi::gst_caps_subtract( self.as_mut_ptr(), other.as_mut_ptr(), )) @@ -487,12 +468,12 @@ define_iter!( &'a CapsRef, &'a StructureRef, |caps: &CapsRef, idx| { - let ptr = gst_sys::gst_caps_get_structure(caps.as_ptr(), idx); + let ptr = ffi::gst_caps_get_structure(caps.as_ptr(), idx); if ptr.is_null() { None } else { Some(StructureRef::from_glib_borrow( - ptr as *const gst_sys::GstStructure, + ptr as *const ffi::GstStructure, )) } } @@ -502,12 +483,12 @@ define_iter!( &'a mut CapsRef, &'a mut StructureRef, |caps: &CapsRef, idx| { - let ptr = gst_sys::gst_caps_get_structure(caps.as_ptr(), idx); + let ptr = ffi::gst_caps_get_structure(caps.as_ptr(), idx); if ptr.is_null() { None } else { Some(StructureRef::from_glib_borrow_mut( - ptr as *mut gst_sys::GstStructure, + ptr as *mut ffi::GstStructure, )) } } @@ -517,14 +498,14 @@ define_iter!( &'a CapsRef, (&'a StructureRef, &'a CapsFeaturesRef), |caps: &CapsRef, idx| { - let ptr1 = gst_sys::gst_caps_get_structure(caps.as_ptr(), idx); - let ptr2 = gst_sys::gst_caps_get_features(caps.as_ptr(), idx); + let ptr1 = ffi::gst_caps_get_structure(caps.as_ptr(), idx); + let ptr2 = ffi::gst_caps_get_features(caps.as_ptr(), idx); if ptr1.is_null() || ptr2.is_null() { None } else { Some(( - StructureRef::from_glib_borrow(ptr1 as *const gst_sys::GstStructure), - CapsFeaturesRef::from_glib_borrow(ptr2 as *const gst_sys::GstCapsFeatures), + StructureRef::from_glib_borrow(ptr1 as *const ffi::GstStructure), + CapsFeaturesRef::from_glib_borrow(ptr2 as *const ffi::GstCapsFeatures), )) } } @@ -534,14 +515,14 @@ define_iter!( &'a mut CapsRef, (&'a mut StructureRef, &'a mut CapsFeaturesRef), |caps: &CapsRef, idx| { - let ptr1 = gst_sys::gst_caps_get_structure(caps.as_ptr(), idx); - let ptr2 = gst_sys::gst_caps_get_features(caps.as_ptr(), idx); + let ptr1 = ffi::gst_caps_get_structure(caps.as_ptr(), idx); + let ptr2 = ffi::gst_caps_get_features(caps.as_ptr(), idx); if ptr1.is_null() || ptr2.is_null() { None } else { Some(( - StructureRef::from_glib_borrow_mut(ptr1 as *mut gst_sys::GstStructure), - CapsFeaturesRef::from_glib_borrow_mut(ptr2 as *mut gst_sys::GstCapsFeatures), + StructureRef::from_glib_borrow_mut(ptr1 as *mut ffi::GstStructure), + CapsFeaturesRef::from_glib_borrow_mut(ptr2 as *mut ffi::GstCapsFeatures), )) } } @@ -575,15 +556,14 @@ impl fmt::Debug for CapsRef { impl fmt::Display for CapsRef { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - let s = - unsafe { glib::GString::from_glib_full(gst_sys::gst_caps_to_string(self.as_ptr())) }; + let s = unsafe { glib::GString::from_glib_full(ffi::gst_caps_to_string(self.as_ptr())) }; f.write_str(&s) } } impl PartialEq for CapsRef { fn eq(&self, other: &CapsRef) -> bool { - unsafe { from_glib(gst_sys::gst_caps_is_equal(self.as_ptr(), other.as_ptr())) } + unsafe { from_glib(ffi::gst_caps_is_equal(self.as_ptr(), other.as_ptr())) } } } @@ -593,7 +573,7 @@ pub enum NoFeature {} pub enum HasFeatures {} pub struct Builder { - s: ::Structure, + s: crate::Structure, features: Option, phantom: PhantomData, } @@ -612,7 +592,7 @@ impl Builder { fn new(name: &str) -> Builder { skip_assert_initialized!(); Builder { - s: ::Structure::new_empty(name), + s: crate::Structure::new_empty(name), features: None, phantom: PhantomData, } @@ -655,7 +635,7 @@ pub enum AnyFeatures {} pub enum SomeFeatures {} pub struct BuilderFull { - caps: ::Caps, + caps: crate::Caps, features: Option, phantom: PhantomData, } @@ -744,12 +724,12 @@ impl BuilderFull { #[cfg(test)] mod tests { use super::*; - use Array; - use Fraction; + use crate::Array; + use crate::Fraction; #[test] fn test_simple() { - ::init().unwrap(); + crate::init().unwrap(); let mut caps = Caps::new_simple( "foo/bar", @@ -786,7 +766,7 @@ mod tests { assert!(caps .get_features(0) .unwrap() - .is_equal(::CAPS_FEATURES_MEMORY_SYSTEM_MEMORY.as_ref())); + .is_equal(crate::CAPS_FEATURES_MEMORY_SYSTEM_MEMORY.as_ref())); { let caps = caps.get_mut().unwrap(); @@ -800,7 +780,7 @@ mod tests { #[test] fn test_builder() { - ::init().unwrap(); + crate::init().unwrap(); let caps = Caps::builder("foo/bar") .field("int", &12) @@ -829,7 +809,7 @@ mod tests { #[test] fn test_display() { - ::init().unwrap(); + crate::init().unwrap(); let caps = Caps::new_simple("foo/bar", &[]); format!("{}", caps); @@ -837,7 +817,7 @@ mod tests { #[test] fn test_builder_full() { - ::init().unwrap(); + crate::init().unwrap(); let caps = Caps::builder_full() .structure(Structure::builder("audio/x-raw").build()) @@ -873,7 +853,7 @@ mod tests { #[test] fn test_builder_full_with_features() { - ::init().unwrap(); + crate::init().unwrap(); let caps = Caps::builder_full_with_features(CapsFeatures::new(&["foo:bla"])) .structure(Structure::builder("audio/x-raw").build()) @@ -890,7 +870,7 @@ mod tests { #[test] fn test_builder_full_with_any_features() { - ::init().unwrap(); + crate::init().unwrap(); let caps = Caps::builder_full_with_any_features() .structure(Structure::builder("audio/x-raw").build()) @@ -906,7 +886,7 @@ mod tests { #[test] fn test_new_from_iter() { - ::init().unwrap(); + crate::init().unwrap(); let caps = Caps::builder_full_with_any_features() .structure(Structure::builder("audio/x-raw").build()) diff --git a/gstreamer/src/caps_features.rs b/gstreamer/src/caps_features.rs index f3898312a..9d626f617 100644 --- a/gstreamer/src/caps_features.rs +++ b/gstreamer/src/caps_features.rs @@ -16,14 +16,11 @@ use std::str; use once_cell::sync::Lazy; -use glib; +use glib::ffi::gpointer; use glib::translate::{ from_glib, from_glib_full, FromGlibPtrFull, FromGlibPtrNone, GlibPtrDefault, Stash, StashMut, ToGlibPtr, ToGlibPtrMut, }; -use glib_sys::gpointer; -use gobject_sys; -use gst_sys; pub struct CapsFeatures(ptr::NonNull); unsafe impl Send for CapsFeatures {} @@ -45,7 +42,7 @@ impl CapsFeatures { assert_initialized_main_thread!(); unsafe { CapsFeatures(ptr::NonNull::new_unchecked( - gst_sys::gst_caps_features_new_empty() as *mut CapsFeaturesRef, + ffi::gst_caps_features_new_empty() as *mut CapsFeaturesRef, )) } } @@ -54,14 +51,14 @@ impl CapsFeatures { assert_initialized_main_thread!(); unsafe { CapsFeatures(ptr::NonNull::new_unchecked( - gst_sys::gst_caps_features_new_any() as *mut CapsFeaturesRef, + ffi::gst_caps_features_new_any() as *mut CapsFeaturesRef, )) } } - pub unsafe fn into_ptr(self) -> *mut gst_sys::GstCapsFeatures { + pub unsafe fn into_ptr(self) -> *mut ffi::GstCapsFeatures { let s = mem::ManuallyDrop::new(self); - s.0.as_ptr() as *mut CapsFeaturesRef as *mut gst_sys::GstCapsFeatures + s.0.as_ptr() as *mut CapsFeaturesRef as *mut ffi::GstCapsFeatures } } @@ -94,7 +91,7 @@ impl AsMut for CapsFeatures { impl Clone for CapsFeatures { fn clone(&self) -> Self { unsafe { - let ptr = gst_sys::gst_caps_features_copy(&self.0.as_ref().0) as *mut CapsFeaturesRef; + let ptr = ffi::gst_caps_features_copy(&self.0.as_ref().0) as *mut CapsFeaturesRef; assert!(!ptr.is_null()); CapsFeatures(ptr::NonNull::new_unchecked(ptr)) } @@ -103,7 +100,7 @@ impl Clone for CapsFeatures { impl Drop for CapsFeatures { fn drop(&mut self) { - unsafe { gst_sys::gst_caps_features_free(&mut self.0.as_mut().0) } + unsafe { ffi::gst_caps_features_free(&mut self.0.as_mut().0) } } } @@ -129,9 +126,9 @@ impl str::FromStr for CapsFeatures { fn from_str(s: &str) -> Result { assert_initialized_main_thread!(); unsafe { - let ptr = gst_sys::gst_caps_features_from_string(s.to_glib_none().0); + let ptr = ffi::gst_caps_features_from_string(s.to_glib_none().0); if ptr.is_null() { - return Err(glib_bool_error!( + return Err(glib::glib_bool_error!( "Failed to parse caps features from string" )); } @@ -157,69 +154,69 @@ impl BorrowMut for CapsFeatures { impl glib::types::StaticType for CapsFeatures { fn static_type() -> glib::types::Type { - unsafe { from_glib(gst_sys::gst_caps_features_get_type()) } + unsafe { from_glib(ffi::gst_caps_features_get_type()) } } } -impl<'a> ToGlibPtr<'a, *const gst_sys::GstCapsFeatures> for CapsFeatures { +impl<'a> ToGlibPtr<'a, *const ffi::GstCapsFeatures> for CapsFeatures { type Storage = &'a Self; - fn to_glib_none(&'a self) -> Stash<'a, *const gst_sys::GstCapsFeatures, Self> { + fn to_glib_none(&'a self) -> Stash<'a, *const ffi::GstCapsFeatures, Self> { unsafe { Stash(&self.0.as_ref().0, self) } } - fn to_glib_full(&self) -> *const gst_sys::GstCapsFeatures { - unsafe { gst_sys::gst_caps_features_copy(&self.0.as_ref().0) } + fn to_glib_full(&self) -> *const ffi::GstCapsFeatures { + unsafe { ffi::gst_caps_features_copy(&self.0.as_ref().0) } } } -impl<'a> ToGlibPtr<'a, *mut gst_sys::GstCapsFeatures> for CapsFeatures { +impl<'a> ToGlibPtr<'a, *mut ffi::GstCapsFeatures> for CapsFeatures { type Storage = &'a Self; - fn to_glib_none(&'a self) -> Stash<'a, *mut gst_sys::GstCapsFeatures, Self> { + fn to_glib_none(&'a self) -> Stash<'a, *mut ffi::GstCapsFeatures, Self> { unsafe { Stash(&self.0.as_ref().0 as *const _ as *mut _, self) } } - fn to_glib_full(&self) -> *mut gst_sys::GstCapsFeatures { - unsafe { gst_sys::gst_caps_features_copy(&self.0.as_ref().0) } + fn to_glib_full(&self) -> *mut ffi::GstCapsFeatures { + unsafe { ffi::gst_caps_features_copy(&self.0.as_ref().0) } } } -impl<'a> ToGlibPtrMut<'a, *mut gst_sys::GstCapsFeatures> for CapsFeatures { +impl<'a> ToGlibPtrMut<'a, *mut ffi::GstCapsFeatures> for CapsFeatures { type Storage = &'a mut Self; - fn to_glib_none_mut(&'a mut self) -> StashMut<*mut gst_sys::GstCapsFeatures, Self> { + fn to_glib_none_mut(&'a mut self) -> StashMut<*mut ffi::GstCapsFeatures, Self> { unsafe { StashMut(&mut self.0.as_mut().0, self) } } } -impl FromGlibPtrNone<*const gst_sys::GstCapsFeatures> for CapsFeatures { - unsafe fn from_glib_none(ptr: *const gst_sys::GstCapsFeatures) -> Self { +impl FromGlibPtrNone<*const ffi::GstCapsFeatures> for CapsFeatures { + unsafe fn from_glib_none(ptr: *const ffi::GstCapsFeatures) -> Self { assert!(!ptr.is_null()); - let ptr = gst_sys::gst_caps_features_copy(ptr); + let ptr = ffi::gst_caps_features_copy(ptr); assert!(!ptr.is_null()); CapsFeatures(ptr::NonNull::new_unchecked(ptr as *mut CapsFeaturesRef)) } } -impl FromGlibPtrNone<*mut gst_sys::GstCapsFeatures> for CapsFeatures { - unsafe fn from_glib_none(ptr: *mut gst_sys::GstCapsFeatures) -> Self { +impl FromGlibPtrNone<*mut ffi::GstCapsFeatures> for CapsFeatures { + unsafe fn from_glib_none(ptr: *mut ffi::GstCapsFeatures) -> Self { assert!(!ptr.is_null()); - let ptr = gst_sys::gst_caps_features_copy(ptr); + let ptr = ffi::gst_caps_features_copy(ptr); assert!(!ptr.is_null()); CapsFeatures(ptr::NonNull::new_unchecked(ptr as *mut CapsFeaturesRef)) } } -impl FromGlibPtrFull<*const gst_sys::GstCapsFeatures> for CapsFeatures { - unsafe fn from_glib_full(ptr: *const gst_sys::GstCapsFeatures) -> Self { +impl FromGlibPtrFull<*const ffi::GstCapsFeatures> for CapsFeatures { + unsafe fn from_glib_full(ptr: *const ffi::GstCapsFeatures) -> Self { assert!(!ptr.is_null()); CapsFeatures(ptr::NonNull::new_unchecked(ptr as *mut CapsFeaturesRef)) } } -impl FromGlibPtrFull<*mut gst_sys::GstCapsFeatures> for CapsFeatures { - unsafe fn from_glib_full(ptr: *mut gst_sys::GstCapsFeatures) -> Self { +impl FromGlibPtrFull<*mut ffi::GstCapsFeatures> for CapsFeatures { + unsafe fn from_glib_full(ptr: *mut ffi::GstCapsFeatures) -> Self { assert!(!ptr.is_null()); CapsFeatures(ptr::NonNull::new_unchecked(ptr as *mut CapsFeaturesRef)) } @@ -248,35 +245,33 @@ impl glib::value::SetValueOptional for CapsFeatures { } impl GlibPtrDefault for CapsFeatures { - type GlibType = *mut gst_sys::GstCapsFeatures; + type GlibType = *mut ffi::GstCapsFeatures; } #[repr(transparent)] -pub struct CapsFeaturesRef(gst_sys::GstCapsFeatures); +pub struct CapsFeaturesRef(ffi::GstCapsFeatures); impl CapsFeaturesRef { - pub unsafe fn from_glib_borrow<'a>( - ptr: *const gst_sys::GstCapsFeatures, - ) -> &'a CapsFeaturesRef { + pub unsafe fn from_glib_borrow<'a>(ptr: *const ffi::GstCapsFeatures) -> &'a CapsFeaturesRef { assert!(!ptr.is_null()); &*(ptr as *mut CapsFeaturesRef) } pub unsafe fn from_glib_borrow_mut<'a>( - ptr: *mut gst_sys::GstCapsFeatures, + ptr: *mut ffi::GstCapsFeatures, ) -> &'a mut CapsFeaturesRef { assert!(!ptr.is_null()); &mut *(ptr as *mut CapsFeaturesRef) } - pub unsafe fn as_ptr(&self) -> *const gst_sys::GstCapsFeatures { - self as *const Self as *const gst_sys::GstCapsFeatures + pub unsafe fn as_ptr(&self) -> *const ffi::GstCapsFeatures { + self as *const Self as *const ffi::GstCapsFeatures } - pub unsafe fn as_mut_ptr(&self) -> *mut gst_sys::GstCapsFeatures { - self as *const Self as *mut gst_sys::GstCapsFeatures + pub unsafe fn as_mut_ptr(&self) -> *mut ffi::GstCapsFeatures { + self as *const Self as *mut ffi::GstCapsFeatures } pub fn is_empty(&self) -> bool { @@ -284,12 +279,12 @@ impl CapsFeaturesRef { } pub fn is_any(&self) -> bool { - unsafe { from_glib(gst_sys::gst_caps_features_is_any(self.as_ptr())) } + unsafe { from_glib(ffi::gst_caps_features_is_any(self.as_ptr())) } } pub fn contains(&self, feature: &str) -> bool { unsafe { - from_glib(gst_sys::gst_caps_features_contains( + from_glib(ffi::gst_caps_features_contains( self.as_ptr(), feature.to_glib_none().0, )) @@ -297,7 +292,7 @@ impl CapsFeaturesRef { } pub fn get_size(&self) -> u32 { - unsafe { gst_sys::gst_caps_features_get_size(self.as_ptr()) } + unsafe { ffi::gst_caps_features_get_size(self.as_ptr()) } } pub fn get_nth(&self, idx: u32) -> Option<&str> { @@ -306,7 +301,7 @@ impl CapsFeaturesRef { } unsafe { - let feature = gst_sys::gst_caps_features_get_nth(self.as_ptr(), idx); + let feature = ffi::gst_caps_features_get_nth(self.as_ptr(), idx); if feature.is_null() { return None; } @@ -316,11 +311,11 @@ impl CapsFeaturesRef { } pub fn add(&mut self, feature: &str) { - unsafe { gst_sys::gst_caps_features_add(self.as_mut_ptr(), feature.to_glib_none().0) } + unsafe { ffi::gst_caps_features_add(self.as_mut_ptr(), feature.to_glib_none().0) } } pub fn remove(&mut self, feature: &str) { - unsafe { gst_sys::gst_caps_features_remove(self.as_mut_ptr(), feature.to_glib_none().0) } + unsafe { ffi::gst_caps_features_remove(self.as_mut_ptr(), feature.to_glib_none().0) } } pub fn iter(&self) -> Iter { @@ -330,7 +325,7 @@ impl CapsFeaturesRef { // This is not an equivalence relation with regards to ANY. Everything is equal to ANY pub fn is_equal(&self, other: &CapsFeaturesRef) -> bool { unsafe { - from_glib(gst_sys::gst_caps_features_is_equal( + from_glib(ffi::gst_caps_features_is_equal( self.as_ptr(), other.as_ptr(), )) @@ -340,18 +335,18 @@ impl CapsFeaturesRef { impl glib::types::StaticType for CapsFeaturesRef { fn static_type() -> glib::types::Type { - unsafe { from_glib(gst_sys::gst_structure_get_type()) } + unsafe { from_glib(ffi::gst_structure_get_type()) } } } impl<'a> glib::value::FromValueOptional<'a> for &'a CapsFeaturesRef { unsafe fn from_value_optional(v: &'a glib::Value) -> Option { - let ptr = gobject_sys::g_value_get_boxed(v.to_glib_none().0); + let ptr = glib::gobject_ffi::g_value_get_boxed(v.to_glib_none().0); if ptr.is_null() { None } else { Some(CapsFeaturesRef::from_glib_borrow( - ptr as *const gst_sys::GstCapsFeatures, + ptr as *const ffi::GstCapsFeatures, )) } } @@ -359,16 +354,16 @@ impl<'a> glib::value::FromValueOptional<'a> for &'a CapsFeaturesRef { impl glib::value::SetValue for CapsFeaturesRef { unsafe fn set_value(v: &mut glib::Value, s: &Self) { - gobject_sys::g_value_set_boxed(v.to_glib_none_mut().0, s.as_ptr() as gpointer); + glib::gobject_ffi::g_value_set_boxed(v.to_glib_none_mut().0, s.as_ptr() as gpointer); } } impl glib::value::SetValueOptional for CapsFeaturesRef { unsafe fn set_value_optional(v: &mut glib::Value, s: Option<&Self>) { if let Some(s) = s { - gobject_sys::g_value_set_boxed(v.to_glib_none_mut().0, s.as_ptr() as gpointer); + glib::gobject_ffi::g_value_set_boxed(v.to_glib_none_mut().0, s.as_ptr() as gpointer); } else { - gobject_sys::g_value_set_boxed(v.to_glib_none_mut().0, ptr::null_mut()); + glib::gobject_ffi::g_value_set_boxed(v.to_glib_none_mut().0, ptr::null_mut()); } } } @@ -402,7 +397,7 @@ impl<'a> Iterator for Iter<'a> { } unsafe { - let feature = gst_sys::gst_caps_features_get_nth(self.caps_features.as_ptr(), self.idx); + let feature = ffi::gst_caps_features_get_nth(self.caps_features.as_ptr(), self.idx); if feature.is_null() { return None; } @@ -434,7 +429,7 @@ impl<'a> DoubleEndedIterator for Iter<'a> { unsafe { let feature = - gst_sys::gst_caps_features_get_nth(self.caps_features.as_ptr(), self.n_features); + ffi::gst_caps_features_get_nth(self.caps_features.as_ptr(), self.n_features); if feature.is_null() { return None; } @@ -457,7 +452,7 @@ impl fmt::Debug for CapsFeaturesRef { impl fmt::Display for CapsFeaturesRef { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { let s = unsafe { - glib::GString::from_glib_full(gst_sys::gst_caps_features_to_string(self.as_ptr())) + glib::GString::from_glib_full(ffi::gst_caps_features_to_string(self.as_ptr())) }; f.write_str(&s) } @@ -467,9 +462,7 @@ impl ToOwned for CapsFeaturesRef { type Owned = CapsFeatures; fn to_owned(&self) -> CapsFeatures { - unsafe { - from_glib_full(gst_sys::gst_caps_features_copy(self.as_ptr() as *const _) as *mut _) - } + unsafe { from_glib_full(ffi::gst_caps_features_copy(self.as_ptr() as *const _) as *mut _) } } } @@ -477,7 +470,7 @@ unsafe impl Sync for CapsFeaturesRef {} unsafe impl Send for CapsFeaturesRef {} pub static CAPS_FEATURE_MEMORY_SYSTEM_MEMORY: Lazy<&'static str> = Lazy::new(|| unsafe { - CStr::from_ptr(gst_sys::GST_CAPS_FEATURE_MEMORY_SYSTEM_MEMORY) + CStr::from_ptr(ffi::GST_CAPS_FEATURE_MEMORY_SYSTEM_MEMORY) .to_str() .unwrap() }); @@ -490,7 +483,7 @@ mod tests { #[test] fn test_from_value_optional() { - ::init().unwrap(); + crate::init().unwrap(); let a = glib::value::Value::from(None::<&CapsFeatures>); assert!(a.get::().unwrap().is_none()); diff --git a/gstreamer/src/caps_features_serde.rs b/gstreamer/src/caps_features_serde.rs index 5b7f8da5a..068e75ede 100644 --- a/gstreamer/src/caps_features_serde.rs +++ b/gstreamer/src/caps_features_serde.rs @@ -12,8 +12,8 @@ use serde::ser::{Serialize, SerializeSeq, Serializer}; use std::fmt; -use CapsFeatures; -use CapsFeaturesRef; +use crate::CapsFeatures; +use crate::CapsFeaturesRef; enum CapsFeaturesVariantKinds { Any, diff --git a/gstreamer/src/caps_serde.rs b/gstreamer/src/caps_serde.rs index 4ffe32ce4..247e9d2b7 100644 --- a/gstreamer/src/caps_serde.rs +++ b/gstreamer/src/caps_serde.rs @@ -12,12 +12,12 @@ use serde::ser::{Serialize, SerializeSeq, SerializeTuple, Serializer}; use std::fmt; -use Caps; -use CapsFeatures; -use CapsFeaturesRef; -use CapsRef; -use Structure; -use StructureRef; +use crate::Caps; +use crate::CapsFeatures; +use crate::CapsFeaturesRef; +use crate::CapsRef; +use crate::Structure; +use crate::StructureRef; enum CapsVariantKinds { Any, @@ -57,7 +57,7 @@ impl<'a> Serialize for CapsForIterSe<'a> { let mut seq = serializer.serialize_seq(Some(size))?; for (structure, features) in iter { let features = if !features.is_any() - && features.is_equal(::CAPS_FEATURES_MEMORY_SYSTEM_MEMORY.as_ref()) + && features.is_equal(crate::CAPS_FEATURES_MEMORY_SYSTEM_MEMORY.as_ref()) { None } else { @@ -229,16 +229,14 @@ impl<'de> Deserialize<'de> for Caps { #[cfg(test)] mod tests { - extern crate ron; - - use Array; - use Caps; - use CapsFeatures; - use Fraction; + use crate::Array; + use crate::Caps; + use crate::CapsFeatures; + use crate::Fraction; #[test] fn test_serialize() { - ::init().unwrap(); + crate::init().unwrap(); let caps = Caps::builder("foo/bar") .field("int", &12) @@ -349,9 +347,9 @@ mod tests { #[test] fn test_deserialize() { - use Structure; + use crate::Structure; - ::init().unwrap(); + crate::init().unwrap(); let caps_ron = "Any"; let caps: Caps = ron::de::from_str(caps_ron).unwrap(); @@ -468,7 +466,7 @@ mod tests { #[test] fn test_serde_roundtrip() { - ::init().unwrap(); + crate::init().unwrap(); let caps = Caps::new_any(); let caps_ser = ron::ser::to_string(&caps).unwrap(); diff --git a/gstreamer/src/child_proxy.rs b/gstreamer/src/child_proxy.rs index a541dcba0..e80717646 100644 --- a/gstreamer/src/child_proxy.rs +++ b/gstreamer/src/child_proxy.rs @@ -6,12 +6,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use glib; +use crate::ChildProxy; use glib::object::IsA; use glib::translate::*; -use gst_sys; use std::ptr; -use ChildProxy; pub trait ChildProxyExtManual: 'static { fn get_child_property(&self, name: &str) -> Option; @@ -25,7 +23,7 @@ pub trait ChildProxyExtManual: 'static { impl> ChildProxyExtManual for O { fn get_child_property(&self, name: &str) -> Option { unsafe { - let found: bool = from_glib(gst_sys::gst_child_proxy_lookup( + let found: bool = from_glib(ffi::gst_child_proxy_lookup( self.as_ref().to_glib_none().0, name.to_glib_none().0, ptr::null_mut(), @@ -36,7 +34,7 @@ impl> ChildProxyExtManual for O { } let mut value = glib::Value::uninitialized(); - gst_sys::gst_child_proxy_get_property( + ffi::gst_child_proxy_get_property( self.as_ref().to_glib_none().0, name.to_glib_none().0, value.to_glib_none_mut().0, @@ -51,18 +49,18 @@ impl> ChildProxyExtManual for O { value: &dyn glib::ToValue, ) -> Result<(), glib::BoolError> { unsafe { - let found: bool = from_glib(gst_sys::gst_child_proxy_lookup( + let found: bool = from_glib(ffi::gst_child_proxy_lookup( self.as_ref().to_glib_none().0, name.to_glib_none().0, ptr::null_mut(), ptr::null_mut(), )); if !found { - return Err(glib_bool_error!("Child property not found")); + return Err(glib::glib_bool_error!("Child property not found")); } let value = value.to_value(); - gst_sys::gst_child_proxy_set_property( + ffi::gst_child_proxy_set_property( self.as_ref().to_glib_none().0, name.to_glib_none().0, value.to_glib_none().0, diff --git a/gstreamer/src/clock.rs b/gstreamer/src/clock.rs index 298df4210..82f1086dc 100644 --- a/gstreamer/src/clock.rs +++ b/gstreamer/src/clock.rs @@ -6,26 +6,24 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use glib; +use crate::Clock; +use crate::ClockEntryType; +use crate::ClockError; +use crate::ClockFlags; +use crate::ClockReturn; +use crate::ClockSuccess; +use crate::ClockTime; +use crate::ClockTimeDiff; +use glib::ffi::{gboolean, gpointer}; #[cfg(any(feature = "v1_16", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_16")))] use glib::prelude::*; use glib::translate::*; use glib::IsA; -use glib_sys::{gboolean, gpointer}; -use gst_sys; use libc::c_void; use std::cmp; use std::convert; use std::ptr; -use Clock; -use ClockEntryType; -use ClockError; -use ClockFlags; -use ClockReturn; -use ClockSuccess; -use ClockTime; -use ClockTimeDiff; use futures_core::{Future, Stream}; use std::marker::Unpin; @@ -33,40 +31,37 @@ use std::pin::Pin; use std::sync::atomic; use std::sync::atomic::AtomicI32; -glib_wrapper! { +glib::glib_wrapper! { #[derive(Debug, PartialOrd, Ord, PartialEq, Eq, Hash)] pub struct ClockId(Shared); match fn { - ref => |ptr| gst_sys::gst_clock_id_ref(ptr), - unref => |ptr| gst_sys::gst_clock_id_unref(ptr), + ref => |ptr| ffi::gst_clock_id_ref(ptr), + unref => |ptr| ffi::gst_clock_id_unref(ptr), } } impl ClockId { pub fn get_time(&self) -> ClockTime { - unsafe { from_glib(gst_sys::gst_clock_id_get_time(self.to_glib_none().0)) } + unsafe { from_glib(ffi::gst_clock_id_get_time(self.to_glib_none().0)) } } pub fn unschedule(&self) { - unsafe { gst_sys::gst_clock_id_unschedule(self.to_glib_none().0) } + unsafe { ffi::gst_clock_id_unschedule(self.to_glib_none().0) } } pub fn wait(&self) -> (Result, ClockTimeDiff) { unsafe { let mut jitter = 0; - let res: ClockReturn = from_glib(gst_sys::gst_clock_id_wait( - self.to_glib_none().0, - &mut jitter, - )); + let res: ClockReturn = + from_glib(ffi::gst_clock_id_wait(self.to_glib_none().0, &mut jitter)); (res.into_result(), jitter) } } pub fn compare_by_time(&self, other: &Self) -> cmp::Ordering { unsafe { - let res = - gst_sys::gst_clock_id_compare_func(self.to_glib_none().0, other.to_glib_none().0); + let res = ffi::gst_clock_id_compare_func(self.to_glib_none().0, other.to_glib_none().0); res.cmp(&0) } } @@ -74,14 +69,14 @@ impl ClockId { #[cfg(any(feature = "v1_16", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_16")))] pub fn get_clock(&self) -> Option { - unsafe { from_glib_full(gst_sys::gst_clock_id_get_clock(self.to_glib_none().0)) } + unsafe { from_glib_full(ffi::gst_clock_id_get_clock(self.to_glib_none().0)) } } #[cfg(any(feature = "v1_16", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_16")))] pub fn uses_clock>(&self, clock: &P) -> bool { unsafe { - from_glib(gst_sys::gst_clock_id_uses_clock( + from_glib(ffi::gst_clock_id_uses_clock( self.to_glib_none().0, clock.as_ref().as_ptr(), )) @@ -90,14 +85,14 @@ impl ClockId { pub fn get_type(&self) -> ClockEntryType { unsafe { - let ptr: *mut gst_sys::GstClockEntry = self.to_glib_none().0 as *mut _; + let ptr: *mut ffi::GstClockEntry = self.to_glib_none().0 as *mut _; from_glib((*ptr).type_) } } pub fn get_status(&self) -> &AtomicClockReturn { unsafe { - let ptr: *mut gst_sys::GstClockEntry = self.to_glib_none().0 as *mut _; + let ptr: *mut ffi::GstClockEntry = self.to_glib_none().0 as *mut _; &*((&(*ptr).status) as *const i32 as *const AtomicClockReturn) } } @@ -128,7 +123,7 @@ impl convert::TryFrom for SingleShotClockId { skip_assert_initialized!(); match id.get_type() { ClockEntryType::Single => Ok(SingleShotClockId(id)), - _ => Err(glib_bool_error!("Not a single-shot clock id")), + _ => Err(glib::glib_bool_error!("Not a single-shot clock id")), } } } @@ -143,8 +138,8 @@ impl SingleShotClockId { F: FnOnce(&Clock, ClockTime, &ClockId) + Send + 'static, { unsafe extern "C" fn trampoline( - clock: *mut gst_sys::GstClock, - time: gst_sys::GstClockTime, + clock: *mut ffi::GstClock, + time: ffi::GstClockTime, id: gpointer, func: gpointer, ) -> gboolean { @@ -157,7 +152,7 @@ impl SingleShotClockId { &from_glib_borrow(id), ); - glib_sys::GTRUE + glib::ffi::GTRUE } unsafe extern "C" fn destroy_notify< @@ -171,7 +166,7 @@ impl SingleShotClockId { let func: Box> = Box::new(Some(func)); let ret: ClockReturn = unsafe { - from_glib(gst_sys::gst_clock_id_wait_async( + from_glib(ffi::gst_clock_id_wait_async( self.to_glib_none().0, Some(trampoline::), Box::into_raw(func) as gpointer, @@ -236,7 +231,7 @@ impl convert::TryFrom for PeriodicClockId { skip_assert_initialized!(); match id.get_type() { ClockEntryType::Periodic => Ok(PeriodicClockId(id)), - _ => Err(glib_bool_error!("Not a periodic clock id")), + _ => Err(glib::glib_bool_error!("Not a periodic clock id")), } } } @@ -244,7 +239,7 @@ impl convert::TryFrom for PeriodicClockId { impl PeriodicClockId { pub fn get_interval(&self) -> ClockTime { unsafe { - let ptr: *mut gst_sys::GstClockEntry = self.to_glib_none().0 as *mut _; + let ptr: *mut ffi::GstClockEntry = self.to_glib_none().0 as *mut _; from_glib((*ptr).interval) } } @@ -258,8 +253,8 @@ impl PeriodicClockId { F: Fn(&Clock, ClockTime, &ClockId) + Send + 'static, { unsafe extern "C" fn trampoline( - clock: *mut gst_sys::GstClock, - time: gst_sys::GstClockTime, + clock: *mut ffi::GstClock, + time: ffi::GstClockTime, id: gpointer, func: gpointer, ) -> gboolean { @@ -269,7 +264,7 @@ impl PeriodicClockId { from_glib(time), &from_glib_borrow(id), ); - glib_sys::GTRUE + glib::ffi::GTRUE } unsafe extern "C" fn destroy_notify( @@ -280,7 +275,7 @@ impl PeriodicClockId { let func: Box = Box::new(func); let ret: ClockReturn = unsafe { - from_glib(gst_sys::gst_clock_id_wait_async( + from_glib(ffi::gst_clock_id_wait_async( self.to_glib_none().0, Some(trampoline::), Box::into_raw(func) as gpointer, @@ -351,7 +346,7 @@ impl Clock { ) -> ClockTime { skip_assert_initialized!(); unsafe { - from_glib(gst_sys::gst_clock_adjust_with_calibration( + from_glib(ffi::gst_clock_adjust_with_calibration( ptr::null_mut(), internal_target.to_glib(), cinternal.to_glib(), @@ -371,7 +366,7 @@ impl Clock { ) -> ClockTime { skip_assert_initialized!(); unsafe { - from_glib(gst_sys::gst_clock_unadjust_with_calibration( + from_glib(ffi::gst_clock_unadjust_with_calibration( ptr::null_mut(), external_target.to_glib(), cinternal.to_glib(), @@ -412,10 +407,10 @@ impl> ClockExtManual for O { fn new_periodic_id(&self, start_time: ClockTime, interval: ClockTime) -> PeriodicClockId { assert!(start_time.is_some()); assert!(interval.is_some()); - assert_ne!(interval, ::ClockTime::from(0)); + assert_ne!(interval, crate::ClockTime::from(0)); unsafe { - PeriodicClockId(from_glib_full(gst_sys::gst_clock_new_periodic_id( + PeriodicClockId(from_glib_full(ffi::gst_clock_new_periodic_id( self.as_ref().to_glib_none().0, start_time.to_glib(), interval.to_glib(), @@ -431,7 +426,7 @@ impl> ClockExtManual for O { ) -> Result<(), glib::BoolError> { skip_assert_initialized!(); unsafe { - let res: bool = from_glib(gst_sys::gst_clock_periodic_id_reinit( + let res: bool = from_glib(ffi::gst_clock_periodic_id_reinit( self.as_ref().to_glib_none().0, id.to_glib_none().0, start_time.to_glib(), @@ -440,7 +435,7 @@ impl> ClockExtManual for O { if res { Ok(()) } else { - Err(glib_bool_error!("Failed to reinit periodic clock id")) + Err(glib::glib_bool_error!("Failed to reinit periodic clock id")) } } } @@ -449,7 +444,7 @@ impl> ClockExtManual for O { assert!(time.is_some()); unsafe { - SingleShotClockId(from_glib_full(gst_sys::gst_clock_new_single_shot_id( + SingleShotClockId(from_glib_full(ffi::gst_clock_new_single_shot_id( self.as_ref().to_glib_none().0, time.to_glib(), ))) @@ -462,7 +457,7 @@ impl> ClockExtManual for O { time: ClockTime, ) -> Result<(), glib::BoolError> { unsafe { - let res: bool = from_glib(gst_sys::gst_clock_single_shot_id_reinit( + let res: bool = from_glib(ffi::gst_clock_single_shot_id_reinit( self.as_ref().to_glib_none().0, id.to_glib_none().0, time.to_glib(), @@ -470,31 +465,33 @@ impl> ClockExtManual for O { if res { Ok(()) } else { - Err(glib_bool_error!("Failed to reinit single shot clock id")) + Err(glib::glib_bool_error!( + "Failed to reinit single shot clock id" + )) } } } fn set_clock_flags(&self, flags: ClockFlags) { unsafe { - let ptr: *mut gst_sys::GstObject = self.as_ptr() as *mut _; - let _guard = ::utils::MutexGuard::lock(&(*ptr).lock); + let ptr: *mut ffi::GstObject = self.as_ptr() as *mut _; + let _guard = crate::utils::MutexGuard::lock(&(*ptr).lock); (*ptr).flags |= flags.to_glib(); } } fn unset_clock_flags(&self, flags: ClockFlags) { unsafe { - let ptr: *mut gst_sys::GstObject = self.as_ptr() as *mut _; - let _guard = ::utils::MutexGuard::lock(&(*ptr).lock); + let ptr: *mut ffi::GstObject = self.as_ptr() as *mut _; + let _guard = crate::utils::MutexGuard::lock(&(*ptr).lock); (*ptr).flags &= !flags.to_glib(); } } fn get_clock_flags(&self) -> ClockFlags { unsafe { - let ptr: *mut gst_sys::GstObject = self.as_ptr() as *mut _; - let _guard = ::utils::MutexGuard::lock(&(*ptr).lock); + let ptr: *mut ffi::GstObject = self.as_ptr() as *mut _; + let _guard = crate::utils::MutexGuard::lock(&(*ptr).lock); from_glib((*ptr).flags) } } @@ -508,11 +505,11 @@ mod tests { #[test] fn test_wait() { - ::init().unwrap(); + crate::init().unwrap(); let clock = SystemClock::obtain(); let now = clock.get_time(); - let id = clock.new_single_shot_id(now + 20 * ::MSECOND); + let id = clock.new_single_shot_id(now + 20 * crate::MSECOND); let (res, _) = id.wait(); assert!(res == Ok(ClockSuccess::Ok) || res == Err(ClockError::Early)); @@ -520,13 +517,13 @@ mod tests { #[test] fn test_wait_async() { - ::init().unwrap(); + crate::init().unwrap(); let (sender, receiver) = channel(); let clock = SystemClock::obtain(); let now = clock.get_time(); - let id = clock.new_single_shot_id(now + 20 * ::MSECOND); + let id = clock.new_single_shot_id(now + 20 * crate::MSECOND); let res = id.wait_async(move |_, _, _| { sender.send(()).unwrap(); }); @@ -538,11 +535,11 @@ mod tests { #[test] fn test_wait_periodic() { - ::init().unwrap(); + crate::init().unwrap(); let clock = SystemClock::obtain(); let now = clock.get_time(); - let id = clock.new_periodic_id(now + 20 * ::MSECOND, 20 * ::MSECOND); + let id = clock.new_periodic_id(now + 20 * crate::MSECOND, 20 * crate::MSECOND); let (res, _) = id.wait(); assert!(res == Ok(ClockSuccess::Ok) || res == Err(ClockError::Early)); @@ -553,13 +550,13 @@ mod tests { #[test] fn test_wait_async_periodic() { - ::init().unwrap(); + crate::init().unwrap(); let (sender, receiver) = channel(); let clock = SystemClock::obtain(); let now = clock.get_time(); - let id = clock.new_periodic_id(now + 20 * ::MSECOND, 20 * ::MSECOND); + let id = clock.new_periodic_id(now + 20 * crate::MSECOND, 20 * crate::MSECOND); let res = id.wait_async(move |_, _, _| { let _ = sender.send(()); }); diff --git a/gstreamer/src/clock_time.rs b/gstreamer/src/clock_time.rs index a88015da7..d676f5cb9 100644 --- a/gstreamer/src/clock_time.rs +++ b/gstreamer/src/clock_time.rs @@ -6,9 +6,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use glib; use glib::translate::*; -use gst_sys; use std::time::Duration; use std::{cmp, convert, fmt}; @@ -17,27 +15,27 @@ pub struct ClockTime(pub Option); impl ClockTime { pub fn hours(&self) -> Option { - (*self / ::SECOND / 60 / 60).0 + (*self / crate::SECOND / 60 / 60).0 } pub fn minutes(&self) -> Option { - (*self / ::SECOND / 60).0 + (*self / crate::SECOND / 60).0 } pub fn seconds(&self) -> Option { - (*self / ::SECOND).0 + (*self / crate::SECOND).0 } pub fn mseconds(&self) -> Option { - (*self / ::MSECOND).0 + (*self / crate::MSECOND).0 } pub fn useconds(&self) -> Option { - (*self / ::USECOND).0 + (*self / crate::USECOND).0 } pub fn nseconds(&self) -> Option { - (*self / ::NSECOND).0 + (*self / crate::NSECOND).0 } pub fn nanoseconds(&self) -> Option { @@ -46,22 +44,22 @@ impl ClockTime { pub fn from_seconds(seconds: u64) -> ClockTime { skip_assert_initialized!(); - seconds * ::SECOND + seconds * crate::SECOND } pub fn from_mseconds(mseconds: u64) -> ClockTime { skip_assert_initialized!(); - mseconds * ::MSECOND + mseconds * crate::MSECOND } pub fn from_useconds(useconds: u64) -> ClockTime { skip_assert_initialized!(); - useconds * ::USECOND + useconds * crate::USECOND } pub fn from_nseconds(nseconds: u64) -> ClockTime { skip_assert_initialized!(); - nseconds * ::NSECOND + nseconds * crate::NSECOND } } @@ -182,22 +180,22 @@ impl fmt::Display for ClockTime { #[doc(hidden)] impl ToGlib for ClockTime { - type GlibType = gst_sys::GstClockTime; + type GlibType = ffi::GstClockTime; - fn to_glib(&self) -> gst_sys::GstClockTime { + fn to_glib(&self) -> ffi::GstClockTime { match self.0 { - None => gst_sys::GST_CLOCK_TIME_NONE, + None => ffi::GST_CLOCK_TIME_NONE, Some(v) => v, } } } #[doc(hidden)] -impl FromGlib for ClockTime { - fn from_glib(value: gst_sys::GstClockTime) -> Self { +impl FromGlib for ClockTime { + fn from_glib(value: ffi::GstClockTime) -> Self { skip_assert_initialized!(); match value { - gst_sys::GST_CLOCK_TIME_NONE => ClockTime(None), + ffi::GST_CLOCK_TIME_NONE => ClockTime(None), value => ClockTime(Some(value)), } } @@ -239,7 +237,7 @@ impl From for ClockTime { let nanos = d.as_nanos(); if nanos > std::u64::MAX as u128 { - ::CLOCK_TIME_NONE + crate::CLOCK_TIME_NONE } else { ClockTime::from_nseconds(nanos as u64) } @@ -254,7 +252,7 @@ impl convert::TryFrom for Duration { t.nanoseconds() .map(Duration::from_nanos) - .ok_or_else(|| glib_bool_error!("Can't convert ClockTime::NONE to Duration")) + .ok_or_else(|| glib::glib_bool_error!("Can't convert ClockTime::NONE to Duration")) } } diff --git a/gstreamer/src/clock_time_serde.rs b/gstreamer/src/clock_time_serde.rs index f7eb04006..222603af6 100644 --- a/gstreamer/src/clock_time_serde.rs +++ b/gstreamer/src/clock_time_serde.rs @@ -12,7 +12,7 @@ use serde::ser::{Serialize, Serializer}; use std::fmt; -use ClockTime; +use crate::ClockTime; impl<'a> Serialize for ClockTime { fn serialize(&self, serializer: S) -> Result { @@ -52,14 +52,11 @@ impl<'de> Deserialize<'de> for ClockTime { #[cfg(test)] mod tests { - extern crate ron; - extern crate serde_json; - - use ClockTime; + use crate::ClockTime; #[test] fn test_serialize() { - ::init().unwrap(); + crate::init().unwrap(); // Some let clocktime = ClockTime::from_nseconds(42_123_456_789); @@ -85,7 +82,7 @@ mod tests { #[test] fn test_deserialize() { - ::init().unwrap(); + crate::init().unwrap(); // Some let clocktime_ron = "Some(42123456789)"; @@ -114,7 +111,7 @@ mod tests { #[test] fn test_serde_roundtrip() { - ::init().unwrap(); + crate::init().unwrap(); // Some let clocktime = ClockTime::from_nseconds(42_123_456_789); diff --git a/gstreamer/src/context.rs b/gstreamer/src/context.rs index cd8b63ba6..c61d2af08 100644 --- a/gstreamer/src/context.rs +++ b/gstreamer/src/context.rs @@ -9,22 +9,19 @@ use std::ffi::CStr; use std::fmt; -use gst_sys; - -use glib; use glib::translate::{from_glib, from_glib_full, ToGlib, ToGlibPtr}; -use StructureRef; +use crate::StructureRef; -gst_define_mini_object_wrapper!(Context, ContextRef, gst_sys::GstContext, || { - gst_sys::gst_context_get_type() +gst_define_mini_object_wrapper!(Context, ContextRef, ffi::GstContext, || { + ffi::gst_context_get_type() }); impl Context { pub fn new(context_type: &str, persistent: bool) -> Self { assert_initialized_main_thread!(); unsafe { - from_glib_full(gst_sys::gst_context_new( + from_glib_full(ffi::gst_context_new( context_type.to_glib_none().0, persistent.to_glib(), )) @@ -35,14 +32,14 @@ impl Context { impl ContextRef { pub fn get_context_type(&self) -> &str { unsafe { - let raw = gst_sys::gst_context_get_context_type(self.as_mut_ptr()); + let raw = ffi::gst_context_get_context_type(self.as_mut_ptr()); CStr::from_ptr(raw).to_str().unwrap() } } pub fn has_context_type(&self, context_type: &str) -> bool { unsafe { - from_glib(gst_sys::gst_context_has_context_type( + from_glib(ffi::gst_context_has_context_type( self.as_mut_ptr(), context_type.to_glib_none().0, )) @@ -50,18 +47,16 @@ impl ContextRef { } pub fn is_persistent(&self) -> bool { - unsafe { from_glib(gst_sys::gst_context_is_persistent(self.as_mut_ptr())) } + unsafe { from_glib(ffi::gst_context_is_persistent(self.as_mut_ptr())) } } pub fn get_structure(&self) -> &StructureRef { - unsafe { - StructureRef::from_glib_borrow(gst_sys::gst_context_get_structure(self.as_mut_ptr())) - } + unsafe { StructureRef::from_glib_borrow(ffi::gst_context_get_structure(self.as_mut_ptr())) } } pub fn get_mut_structure(&mut self) -> &mut StructureRef { unsafe { - StructureRef::from_glib_borrow_mut(gst_sys::gst_context_writable_structure( + StructureRef::from_glib_borrow_mut(ffi::gst_context_writable_structure( self.as_mut_ptr(), )) } diff --git a/gstreamer/src/control_binding.rs b/gstreamer/src/control_binding.rs index 6820a8d99..1eb544e4a 100644 --- a/gstreamer/src/control_binding.rs +++ b/gstreamer/src/control_binding.rs @@ -6,11 +6,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use crate::ClockTime; +use crate::ControlBinding; use glib::object::IsA; use glib::translate::*; -use gst_sys; -use ClockTime; -use ControlBinding; pub trait ControlBindingExtManual: 'static { fn get_g_value_array( @@ -30,13 +29,13 @@ impl> ControlBindingExtManual for O { ) -> Result<(), glib::error::BoolError> { let n_values = values.len() as u32; unsafe { - glib_result_from_gboolean!( - gst_sys::gst_control_binding_get_g_value_array( + glib::glib_result_from_gboolean!( + ffi::gst_control_binding_get_g_value_array( self.as_ref().to_glib_none().0, timestamp.to_glib(), interval.to_glib(), n_values, - values.as_mut_ptr() as *mut gobject_sys::GValue, + values.as_mut_ptr() as *mut glib::gobject_ffi::GValue, ), "Failed to get value array" ) diff --git a/gstreamer/src/control_source.rs b/gstreamer/src/control_source.rs index 09d571302..7d80eba79 100644 --- a/gstreamer/src/control_source.rs +++ b/gstreamer/src/control_source.rs @@ -6,11 +6,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use crate::ClockTime; +use crate::ControlSource; use glib::object::IsA; use glib::translate::*; -use gst_sys; -use ClockTime; -use ControlSource; pub trait ControlSourceExtManual: 'static { fn get_value_array( @@ -30,8 +29,8 @@ impl> ControlSourceExtManual for O { ) -> Result<(), glib::error::BoolError> { let n_values = values.len() as u32; unsafe { - glib_result_from_gboolean!( - gst_sys::gst_control_source_get_value_array( + glib::glib_result_from_gboolean!( + ffi::gst_control_source_get_value_array( self.as_ref().to_glib_none().0, timestamp.to_glib(), interval.to_glib(), diff --git a/gstreamer/src/date_time.rs b/gstreamer/src/date_time.rs index 43063f6f8..d86b2d480 100644 --- a/gstreamer/src/date_time.rs +++ b/gstreamer/src/date_time.rs @@ -10,7 +10,7 @@ use std::cmp; use std::convert; use std::fmt; -use DateTime; +use crate::DateTime; impl DateTime { pub fn to_utc(&self) -> Result { @@ -28,7 +28,7 @@ impl DateTime { self.to_g_date_time() .and_then(|d| { d.to_utc() - .ok_or_else(|| glib_bool_error!("Can't convert datetime to UTC")) + .ok_or_else(|| glib::glib_bool_error!("Can't convert datetime to UTC")) }) .and_then(|d| DateTime::from_g_date_time(&d)) } else { @@ -48,7 +48,7 @@ impl DateTime { .and_then(|d| d.to_g_date_time()) .and_then(|d| { d.to_utc() - .ok_or_else(|| glib_bool_error!("Can't convert datetime to UTC")) + .ok_or_else(|| glib::glib_bool_error!("Can't convert datetime to UTC")) }) .and_then(|d| { DateTime::new( @@ -273,7 +273,7 @@ mod tests { #[allow(clippy::cognitive_complexity)] #[test] fn test_to_utc() { - ::init().unwrap(); + crate::init().unwrap(); // Hour offset let utc_date_time = DateTime::new(2f32, 2019, 8, 20, 20, 9, 42.123_456f64) @@ -324,7 +324,7 @@ mod tests { #[test] fn test_partial_ord() { - ::init().unwrap(); + crate::init().unwrap(); // Different years assert!( @@ -429,7 +429,7 @@ mod tests { #[test] fn test_eq() { - ::init().unwrap(); + crate::init().unwrap(); assert_eq!( DateTime::new(2f32, 2018, 5, 28, 16, 6, 42.123_456f64).unwrap(), diff --git a/gstreamer/src/date_time_serde.rs b/gstreamer/src/date_time_serde.rs index ca6a37dc1..7fea3a9fa 100644 --- a/gstreamer/src/date_time_serde.rs +++ b/gstreamer/src/date_time_serde.rs @@ -12,12 +12,12 @@ use glib::translate::{FromGlib, ToGlib}; use glib::value::{SetValue, SetValueOptional}; use glib::StaticType; +use crate::DateTime; use serde::de::{Deserialize, Deserializer, Error}; use serde::ser; use serde::ser::{Serialize, Serializer}; -use DateTime; -#[derive(Serialize, Deserialize)] +#[derive(serde::Serialize, serde::Deserialize)] enum DateTimeVariants { Y(i32), YM(i32, i32), @@ -115,18 +115,18 @@ impl TryFrom for Date { DateTimeVariants::YMD(y, m, d) => { let month = glib::DateMonth::from_glib(m); if let glib::DateMonth::__Unknown(_) = month { - return Err(glib_bool_error!("Out of range `month` for `Date`")); + return Err(glib::glib_bool_error!("Out of range `month` for `Date`")); } Ok(Date(glib::Date::new_dmy( d.try_into() - .map_err(|_| glib_bool_error!("Out of range `day` for `Date`"))?, + .map_err(|_| glib::glib_bool_error!("Out of range `day` for `Date`"))?, month, y.try_into() - .map_err(|_| glib_bool_error!("Out of range `year` for `Date`"))?, + .map_err(|_| glib::glib_bool_error!("Out of range `year` for `Date`"))?, ))) } - _ => Err(glib_bool_error!( + _ => Err(glib::glib_bool_error!( "Incompatible variant for `Date` (expecting \"YMD\")" )), } @@ -171,14 +171,11 @@ impl<'de> Deserialize<'de> for DateTime { #[cfg(test)] mod tests { - extern crate ron; - extern crate serde_json; - - use DateTime; + use crate::DateTime; #[test] fn test_serialize() { - ::init().unwrap(); + crate::init().unwrap(); let mut pretty_config = ron::ser::PrettyConfig::default(); pretty_config.new_line = "".to_string(); @@ -215,7 +212,7 @@ mod tests { #[test] fn test_deserialize() { - ::init().unwrap(); + crate::init().unwrap(); let datetime_ron = "YMDhmsTz(2018, 5, 28, 16, 6, 42.123456, 2)"; let datetime_de: DateTime = ron::de::from_str(datetime_ron).unwrap(); @@ -253,7 +250,7 @@ mod tests { #[test] fn test_serde_roundtrip() { - ::init().unwrap(); + crate::init().unwrap(); let datetime = DateTime::new(2f32, 2018, 5, 28, 16, 6, 42.123_456f64).unwrap(); let datetime_ser = ron::ser::to_string(&datetime).unwrap(); diff --git a/gstreamer/src/device_monitor.rs b/gstreamer/src/device_monitor.rs index 960a4a021..e5ac085bb 100644 --- a/gstreamer/src/device_monitor.rs +++ b/gstreamer/src/device_monitor.rs @@ -6,26 +6,23 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use Caps; -use DeviceMonitor; +use crate::Caps; +use crate::DeviceMonitor; -use glib; use glib::object::IsA; use glib::translate::*; -use gst_sys; - use std::num::NonZeroU32; impl DeviceMonitor { pub fn new() -> DeviceMonitor { assert_initialized_main_thread!(); - let (major, minor, _, _) = ::version(); + let (major, minor, _, _) = crate::version(); if (major, minor) > (1, 12) { - unsafe { from_glib_full(gst_sys::gst_device_monitor_new()) } + unsafe { from_glib_full(ffi::gst_device_monitor_new()) } } else { // Work-around for 1.14 switching from transfer-floating to transfer-full - unsafe { from_glib_none(gst_sys::gst_device_monitor_new()) } + unsafe { from_glib_none(ffi::gst_device_monitor_new()) } } } } @@ -73,7 +70,7 @@ impl> DeviceMonitorExtManual for O { caps: Option<&Caps>, ) -> Option { let id = unsafe { - gst_sys::gst_device_monitor_add_filter( + ffi::gst_device_monitor_add_filter( self.as_ref().to_glib_none().0, classes.to_glib_none().0, caps.to_glib_none().0, @@ -92,8 +89,8 @@ impl> DeviceMonitorExtManual for O { filter_id: DeviceMonitorFilterId, ) -> Result<(), glib::error::BoolError> { unsafe { - glib_result_from_gboolean!( - gst_sys::gst_device_monitor_remove_filter( + glib::glib_result_from_gboolean!( + ffi::gst_device_monitor_remove_filter( self.as_ref().to_glib_none().0, filter_id.to_glib() ), diff --git a/gstreamer/src/device_provider.rs b/gstreamer/src/device_provider.rs index 6a67259f5..5416abe62 100644 --- a/gstreamer/src/device_provider.rs +++ b/gstreamer/src/device_provider.rs @@ -6,9 +6,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use DeviceProvider; -use Plugin; -use Rank; +use crate::DeviceProvider; +use crate::Plugin; +use crate::Rank; use glib::object::IsA; use glib::translate::ToGlib; @@ -16,9 +16,6 @@ use glib::translate::ToGlibPtr; use std::ffi::CStr; -use gobject_sys; -use gst_sys; - impl DeviceProvider { pub fn register( plugin: Option<&Plugin>, @@ -28,8 +25,8 @@ impl DeviceProvider { ) -> Result<(), glib::error::BoolError> { assert_initialized_main_thread!(); unsafe { - glib_result_from_gboolean!( - gst_sys::gst_device_provider_register( + glib::glib_result_from_gboolean!( + ffi::gst_device_provider_register( plugin.to_glib_none().0, name.to_glib_none().0, rank.to_glib() as u32, @@ -48,10 +45,10 @@ pub trait DeviceProviderExtManual: 'static { impl> DeviceProviderExtManual for O { fn get_metadata<'a>(&self, key: &str) -> Option<&'a str> { unsafe { - let klass = (*(self.as_ptr() as *mut gobject_sys::GTypeInstance)).g_class - as *mut gst_sys::GstDeviceProviderClass; + let klass = (*(self.as_ptr() as *mut glib::gobject_ffi::GTypeInstance)).g_class + as *mut ffi::GstDeviceProviderClass; - let ptr = gst_sys::gst_device_provider_class_get_metadata(klass, key.to_glib_none().0); + let ptr = ffi::gst_device_provider_class_get_metadata(klass, key.to_glib_none().0); if ptr.is_null() { None diff --git a/gstreamer/src/element.rs b/gstreamer/src/element.rs index 3235ac11a..5fc9c3b47 100644 --- a/gstreamer/src/element.rs +++ b/gstreamer/src/element.rs @@ -6,11 +6,27 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use Element; +use crate::Element; use once_cell::sync::Lazy; -use glib; +use crate::ClockTime; +use crate::ElementFlags; +use crate::Event; +use crate::Format; +use crate::FormattedValue; +use crate::GenericFormattedValue; +use crate::Pad; +use crate::PadTemplate; +use crate::Plugin; +use crate::QueryRef; +use crate::Rank; +use crate::SpecificFormattedValue; +use crate::State; +use crate::StateChange; +use crate::StateChangeError; +use crate::StateChangeReturn; +use crate::StateChangeSuccess; #[cfg(any(feature = "v1_10", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))] use glib::object::Cast; @@ -21,23 +37,6 @@ use glib::translate::FromGlibPtrBorrow; use glib::translate::{ from_glib, from_glib_full, from_glib_none, FromGlib, FromGlibPtrContainer, ToGlib, ToGlibPtr, }; -use ClockTime; -use ElementFlags; -use Event; -use Format; -use FormattedValue; -use GenericFormattedValue; -use Pad; -use PadTemplate; -use Plugin; -use QueryRef; -use Rank; -use SpecificFormattedValue; -use State; -use StateChange; -use StateChangeError; -use StateChangeReturn; -use StateChangeSuccess; use std::ffi::CStr; #[cfg(any(feature = "v1_10", feature = "dox"))] @@ -52,21 +51,13 @@ use std::num::NonZeroU64; #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))] use std::pin::Pin; -use libc; - -#[cfg(any(feature = "v1_10", feature = "dox"))] -#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))] -use glib_sys; -use gobject_sys; -use gst_sys; - impl Element { pub fn link_many>(elements: &[&E]) -> Result<(), glib::BoolError> { skip_assert_initialized!(); for e in elements.windows(2) { unsafe { - glib_result_from_gboolean!( - gst_sys::gst_element_link( + glib::glib_result_from_gboolean!( + ffi::gst_element_link( e[0].as_ref().to_glib_none().0, e[1].as_ref().to_glib_none().0, ), @@ -82,7 +73,7 @@ impl Element { skip_assert_initialized!(); for e in elements.windows(2) { unsafe { - gst_sys::gst_element_unlink( + ffi::gst_element_unlink( e[0].as_ref().to_glib_none().0, e[1].as_ref().to_glib_none().0, ); @@ -98,8 +89,8 @@ impl Element { ) -> Result<(), glib::error::BoolError> { assert_initialized_main_thread!(); unsafe { - glib_result_from_gboolean!( - gst_sys::gst_element_register( + glib::glib_result_from_gboolean!( + ffi::gst_element_register( plugin.to_glib_none().0, name.to_glib_none().0, rank.to_glib() as u32, @@ -163,7 +154,7 @@ pub trait ElementExtManual: 'static { fn get_pad_template_list(&self) -> Vec; #[allow(clippy::too_many_arguments)] - fn message_full( + fn message_full( &self, type_: ElementMessageType, code: T, @@ -183,7 +174,7 @@ pub trait ElementExtManual: 'static { #[cfg(any(feature = "v1_10", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))] #[allow(clippy::too_many_arguments)] - fn message_full_with_details( + fn message_full_with_details( &self, type_: ElementMessageType, code: T, @@ -192,15 +183,15 @@ pub trait ElementExtManual: 'static { file: &str, function: &str, line: u32, - structure: ::Structure, + structure: crate::Structure, ); - fn post_message(&self, message: ::Message) -> Result<(), glib::error::BoolError>; - fn post_error_message(&self, msg: ::ErrorMessage); + fn post_message(&self, message: crate::Message) -> Result<(), glib::error::BoolError>; + fn post_error_message(&self, msg: crate::ErrorMessage); - fn iterate_pads(&self) -> ::Iterator; - fn iterate_sink_pads(&self) -> ::Iterator; - fn iterate_src_pads(&self) -> ::Iterator; + fn iterate_pads(&self) -> crate::Iterator; + fn iterate_sink_pads(&self) -> crate::Iterator; + fn iterate_src_pads(&self) -> crate::Iterator; fn get_pads(&self) -> Vec; fn get_sink_pads(&self) -> Vec; @@ -249,15 +240,15 @@ pub trait ElementExtManual: 'static { fn seek>( &self, rate: f64, - flags: ::SeekFlags, - start_type: ::SeekType, + flags: crate::SeekFlags, + start_type: crate::SeekType, start: V, - stop_type: ::SeekType, + stop_type: crate::SeekType, stop: V, ) -> Result<(), glib::error::BoolError>; fn seek_simple>( &self, - seek_flags: ::SeekFlags, + seek_flags: crate::SeekFlags, seek_pos: V, ) -> Result<(), glib::error::BoolError>; @@ -277,14 +268,14 @@ pub trait ElementExtManual: 'static { F: FnOnce(&Self) -> T + Send + 'static, T: Send + 'static; - fn get_current_running_time(&self) -> ::ClockTime; - fn get_current_clock_time(&self) -> ::ClockTime; + fn get_current_running_time(&self) -> crate::ClockTime; + fn get_current_clock_time(&self) -> crate::ClockTime; } impl> ElementExtManual for O { fn get_element_class(&self) -> &glib::Class { unsafe { - let klass = (*(self.as_ptr() as *mut gobject_sys::GTypeInstance)).g_class + let klass = (*(self.as_ptr() as *mut glib::gobject_ffi::GTypeInstance)).g_class as *const glib::Class; &*klass } @@ -295,7 +286,7 @@ impl> ElementExtManual for O { transition: StateChange, ) -> Result { let ret: StateChangeReturn = unsafe { - from_glib(gst_sys::gst_element_change_state( + from_glib(ffi::gst_element_change_state( self.as_ref().to_glib_none().0, transition.to_glib(), )) @@ -308,7 +299,7 @@ impl> ElementExtManual for O { ret: StateChangeReturn, ) -> Result { let ret: StateChangeReturn = unsafe { - from_glib(gst_sys::gst_element_continue_state( + from_glib(ffi::gst_element_continue_state( self.as_ref().to_glib_none().0, ret.to_glib(), )) @@ -323,7 +314,7 @@ impl> ElementExtManual for O { unsafe { let mut state = mem::MaybeUninit::uninit(); let mut pending = mem::MaybeUninit::uninit(); - let ret: StateChangeReturn = from_glib(gst_sys::gst_element_get_state( + let ret: StateChangeReturn = from_glib(ffi::gst_element_get_state( self.as_ref().to_glib_none().0, state.as_mut_ptr(), pending.as_mut_ptr(), @@ -339,7 +330,7 @@ impl> ElementExtManual for O { fn set_state(&self, state: State) -> Result { let ret: StateChangeReturn = unsafe { - from_glib(gst_sys::gst_element_set_state( + from_glib(ffi::gst_element_set_state( self.as_ref().to_glib_none().0, state.to_glib(), )) @@ -349,7 +340,7 @@ impl> ElementExtManual for O { fn query(&self, query: &mut QueryRef) -> bool { unsafe { - from_glib(gst_sys::gst_element_query( + from_glib(ffi::gst_element_query( self.as_ref().to_glib_none().0, query.as_mut_ptr(), )) @@ -358,7 +349,7 @@ impl> ElementExtManual for O { fn send_event(&self, event: Event) -> bool { unsafe { - from_glib(gst_sys::gst_element_send_event( + from_glib(ffi::gst_element_send_event( self.as_ref().to_glib_none().0, event.into_ptr(), )) @@ -379,29 +370,29 @@ impl> ElementExtManual for O { fn set_element_flags(&self, flags: ElementFlags) { unsafe { - let ptr: *mut gst_sys::GstObject = self.as_ptr() as *mut _; - let _guard = ::utils::MutexGuard::lock(&(*ptr).lock); + let ptr: *mut ffi::GstObject = self.as_ptr() as *mut _; + let _guard = crate::utils::MutexGuard::lock(&(*ptr).lock); (*ptr).flags |= flags.to_glib(); } } fn unset_element_flags(&self, flags: ElementFlags) { unsafe { - let ptr: *mut gst_sys::GstObject = self.as_ptr() as *mut _; - let _guard = ::utils::MutexGuard::lock(&(*ptr).lock); + let ptr: *mut ffi::GstObject = self.as_ptr() as *mut _; + let _guard = crate::utils::MutexGuard::lock(&(*ptr).lock); (*ptr).flags &= !flags.to_glib(); } } fn get_element_flags(&self) -> ElementFlags { unsafe { - let ptr: *mut gst_sys::GstObject = self.as_ptr() as *mut _; - let _guard = ::utils::MutexGuard::lock(&(*ptr).lock); + let ptr: *mut ffi::GstObject = self.as_ptr() as *mut _; + let _guard = crate::utils::MutexGuard::lock(&(*ptr).lock); from_glib((*ptr).flags) } } - fn message_full( + fn message_full( &self, type_: ElementMessageType, code: T, @@ -413,12 +404,12 @@ impl> ElementExtManual for O { ) { unsafe { let type_ = match type_ { - ElementMessageType::Error => gst_sys::GST_MESSAGE_ERROR, - ElementMessageType::Warning => gst_sys::GST_MESSAGE_WARNING, - ElementMessageType::Info => gst_sys::GST_MESSAGE_INFO, + ElementMessageType::Error => ffi::GST_MESSAGE_ERROR, + ElementMessageType::Warning => ffi::GST_MESSAGE_WARNING, + ElementMessageType::Info => ffi::GST_MESSAGE_INFO, }; - gst_sys::gst_element_message_full( + ffi::gst_element_message_full( self.as_ref().to_glib_none().0, type_, T::domain().to_glib(), @@ -434,7 +425,7 @@ impl> ElementExtManual for O { #[cfg(any(feature = "v1_10", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))] - fn message_full_with_details( + fn message_full_with_details( &self, type_: ElementMessageType, code: T, @@ -443,16 +434,16 @@ impl> ElementExtManual for O { file: &str, function: &str, line: u32, - structure: ::Structure, + structure: crate::Structure, ) { unsafe { let type_ = match type_ { - ElementMessageType::Error => gst_sys::GST_MESSAGE_ERROR, - ElementMessageType::Warning => gst_sys::GST_MESSAGE_WARNING, - ElementMessageType::Info => gst_sys::GST_MESSAGE_INFO, + ElementMessageType::Error => ffi::GST_MESSAGE_ERROR, + ElementMessageType::Warning => ffi::GST_MESSAGE_WARNING, + ElementMessageType::Info => ffi::GST_MESSAGE_INFO, }; - gst_sys::gst_element_message_full_with_details( + ffi::gst_element_message_full_with_details( self.as_ref().to_glib_none().0, type_, T::domain().to_glib(), @@ -467,20 +458,17 @@ impl> ElementExtManual for O { } } - fn post_message(&self, message: ::Message) -> Result<(), glib::error::BoolError> { + fn post_message(&self, message: crate::Message) -> Result<(), glib::error::BoolError> { unsafe { - glib_result_from_gboolean!( - gst_sys::gst_element_post_message( - self.as_ref().to_glib_none().0, - message.into_ptr() - ), + glib::glib_result_from_gboolean!( + ffi::gst_element_post_message(self.as_ref().to_glib_none().0, message.into_ptr()), "Failed to post message" ) } } - fn post_error_message(&self, msg: ::ErrorMessage) { - let ::ErrorMessage { + fn post_error_message(&self, msg: crate::ErrorMessage) { + let crate::ErrorMessage { error_domain, error_code, ref message, @@ -491,9 +479,9 @@ impl> ElementExtManual for O { } = msg; unsafe { - gst_sys::gst_element_message_full( + ffi::gst_element_message_full( self.as_ref().to_glib_none().0, - gst_sys::GST_MESSAGE_ERROR, + ffi::GST_MESSAGE_ERROR, error_domain.to_glib(), error_code, message.to_glib_full(), @@ -505,25 +493,25 @@ impl> ElementExtManual for O { } } - fn iterate_pads(&self) -> ::Iterator { + fn iterate_pads(&self) -> crate::Iterator { unsafe { - from_glib_full(gst_sys::gst_element_iterate_pads( + from_glib_full(ffi::gst_element_iterate_pads( self.as_ref().to_glib_none().0, )) } } - fn iterate_sink_pads(&self) -> ::Iterator { + fn iterate_sink_pads(&self) -> crate::Iterator { unsafe { - from_glib_full(gst_sys::gst_element_iterate_sink_pads( + from_glib_full(ffi::gst_element_iterate_sink_pads( self.as_ref().to_glib_none().0, )) } } - fn iterate_src_pads(&self) -> ::Iterator { + fn iterate_src_pads(&self) -> crate::Iterator { unsafe { - from_glib_full(gst_sys::gst_element_iterate_src_pads( + from_glib_full(ffi::gst_element_iterate_src_pads( self.as_ref().to_glib_none().0, )) } @@ -531,48 +519,48 @@ impl> ElementExtManual for O { fn get_pads(&self) -> Vec { unsafe { - let elt: &gst_sys::GstElement = &*(self.as_ptr() as *const _); - let _guard = ::utils::MutexGuard::lock(&elt.object.lock); + let elt: &ffi::GstElement = &*(self.as_ptr() as *const _); + let _guard = crate::utils::MutexGuard::lock(&elt.object.lock); FromGlibPtrContainer::from_glib_none(elt.pads) } } fn get_sink_pads(&self) -> Vec { unsafe { - let elt: &gst_sys::GstElement = &*(self.as_ptr() as *const _); - let _guard = ::utils::MutexGuard::lock(&elt.object.lock); + let elt: &ffi::GstElement = &*(self.as_ptr() as *const _); + let _guard = crate::utils::MutexGuard::lock(&elt.object.lock); FromGlibPtrContainer::from_glib_none(elt.sinkpads) } } fn get_src_pads(&self) -> Vec { unsafe { - let elt: &gst_sys::GstElement = &*(self.as_ptr() as *const _); - let _guard = ::utils::MutexGuard::lock(&elt.object.lock); + let elt: &ffi::GstElement = &*(self.as_ptr() as *const _); + let _guard = crate::utils::MutexGuard::lock(&elt.object.lock); FromGlibPtrContainer::from_glib_none(elt.srcpads) } } fn num_pads(&self) -> u16 { unsafe { - let elt: &gst_sys::GstElement = &*(self.as_ptr() as *const _); - let _guard = ::utils::MutexGuard::lock(&elt.object.lock); + let elt: &ffi::GstElement = &*(self.as_ptr() as *const _); + let _guard = crate::utils::MutexGuard::lock(&elt.object.lock); elt.numpads } } fn num_sink_pads(&self) -> u16 { unsafe { - let elt: &gst_sys::GstElement = &*(self.as_ptr() as *const _); - let _guard = ::utils::MutexGuard::lock(&elt.object.lock); + let elt: &ffi::GstElement = &*(self.as_ptr() as *const _); + let _guard = crate::utils::MutexGuard::lock(&elt.object.lock); elt.numsinkpads } } fn num_src_pads(&self) -> u16 { unsafe { - let elt: &gst_sys::GstElement = &*(self.as_ptr() as *const _); - let _guard = ::utils::MutexGuard::lock(&elt.object.lock); + let elt: &ffi::GstElement = &*(self.as_ptr() as *const _); + let _guard = crate::utils::MutexGuard::lock(&elt.object.lock); elt.numsrcpads } } @@ -586,7 +574,7 @@ impl> ElementExtManual for O { ) -> NotifyWatchId { let property_name = property_name.to_glib_none(); unsafe { - from_glib(gst_sys::gst_element_add_property_deep_notify_watch( + from_glib(ffi::gst_element_add_property_deep_notify_watch( self.as_ref().to_glib_none().0, property_name.0, include_value.to_glib(), @@ -603,7 +591,7 @@ impl> ElementExtManual for O { ) -> NotifyWatchId { let property_name = property_name.to_glib_none(); unsafe { - from_glib(gst_sys::gst_element_add_property_notify_watch( + from_glib(ffi::gst_element_add_property_notify_watch( self.as_ref().to_glib_none().0, property_name.0, include_value.to_glib(), @@ -615,7 +603,7 @@ impl> ElementExtManual for O { #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))] fn remove_property_notify_watch(&self, watch_id: NotifyWatchId) { unsafe { - gst_sys::gst_element_remove_property_notify_watch( + ffi::gst_element_remove_property_notify_watch( self.as_ref().to_glib_none().0, watch_id.to_glib(), ); @@ -629,7 +617,7 @@ impl> ElementExtManual for O { let src_val = src_val.into(); unsafe { let mut dest_val = mem::MaybeUninit::uninit(); - let ret = from_glib(gst_sys::gst_element_query_convert( + let ret = from_glib(ffi::gst_element_query_convert( self.as_ref().to_glib_none().0, src_val.get_format().to_glib(), src_val.to_raw_value(), @@ -652,7 +640,7 @@ impl> ElementExtManual for O { let src_val = src_val.into(); unsafe { let mut dest_val = mem::MaybeUninit::uninit(); - let ret = from_glib(gst_sys::gst_element_query_convert( + let ret = from_glib(ffi::gst_element_query_convert( self.as_ref().to_glib_none().0, src_val.get_format().to_glib(), src_val.get_value(), @@ -673,7 +661,7 @@ impl> ElementExtManual for O { fn query_duration(&self) -> Option { unsafe { let mut duration = mem::MaybeUninit::uninit(); - let ret = from_glib(gst_sys::gst_element_query_duration( + let ret = from_glib(ffi::gst_element_query_duration( self.as_ref().to_glib_none().0, T::get_default_format().to_glib(), duration.as_mut_ptr(), @@ -689,7 +677,7 @@ impl> ElementExtManual for O { fn query_duration_generic(&self, format: Format) -> Option { unsafe { let mut duration = mem::MaybeUninit::uninit(); - let ret = from_glib(gst_sys::gst_element_query_duration( + let ret = from_glib(ffi::gst_element_query_duration( self.as_ref().to_glib_none().0, format.to_glib(), duration.as_mut_ptr(), @@ -705,7 +693,7 @@ impl> ElementExtManual for O { fn query_position(&self) -> Option { unsafe { let mut cur = mem::MaybeUninit::uninit(); - let ret = from_glib(gst_sys::gst_element_query_position( + let ret = from_glib(ffi::gst_element_query_position( self.as_ref().to_glib_none().0, T::get_default_format().to_glib(), cur.as_mut_ptr(), @@ -721,7 +709,7 @@ impl> ElementExtManual for O { fn query_position_generic(&self, format: Format) -> Option { unsafe { let mut cur = mem::MaybeUninit::uninit(); - let ret = from_glib(gst_sys::gst_element_query_position( + let ret = from_glib(ffi::gst_element_query_position( self.as_ref().to_glib_none().0, format.to_glib(), cur.as_mut_ptr(), @@ -737,10 +725,10 @@ impl> ElementExtManual for O { fn seek>( &self, rate: f64, - flags: ::SeekFlags, - start_type: ::SeekType, + flags: crate::SeekFlags, + start_type: crate::SeekType, start: V, - stop_type: ::SeekType, + stop_type: crate::SeekType, stop: V, ) -> Result<(), glib::error::BoolError> { let start = start.into(); @@ -749,8 +737,8 @@ impl> ElementExtManual for O { assert_eq!(stop.get_format(), start.get_format()); unsafe { - glib_result_from_gboolean!( - gst_sys::gst_element_seek( + glib::glib_result_from_gboolean!( + ffi::gst_element_seek( self.as_ref().to_glib_none().0, rate, start.get_format().to_glib(), @@ -767,13 +755,13 @@ impl> ElementExtManual for O { fn seek_simple>( &self, - seek_flags: ::SeekFlags, + seek_flags: crate::SeekFlags, seek_pos: V, ) -> Result<(), glib::error::BoolError> { let seek_pos = seek_pos.into(); unsafe { - glib_result_from_gboolean!( - gst_sys::gst_element_seek_simple( + glib::glib_result_from_gboolean!( + ffi::gst_element_seek_simple( self.as_ref().to_glib_none().0, seek_pos.get_format().to_glib(), seek_flags.to_glib(), @@ -793,8 +781,8 @@ impl> ElementExtManual for O { let user_data: Box> = Box::new(Some(func)); unsafe extern "C" fn trampoline, F: FnOnce(&O) + Send + 'static>( - element: *mut gst_sys::GstElement, - user_data: glib_sys::gpointer, + element: *mut ffi::GstElement, + user_data: glib::ffi::gpointer, ) { let user_data: &mut Option = &mut *(user_data as *mut _); let callback = user_data.take().unwrap(); @@ -803,13 +791,13 @@ impl> ElementExtManual for O { } unsafe extern "C" fn free_user_data, F: FnOnce(&O) + Send + 'static>( - user_data: glib_sys::gpointer, + user_data: glib::ffi::gpointer, ) { let _: Box> = Box::from_raw(user_data as *mut _); } unsafe { - gst_sys::gst_element_call_async( + ffi::gst_element_call_async( self.as_ref().to_glib_none().0, Some(trampoline::), Box::into_raw(user_data) as *mut _, @@ -840,8 +828,8 @@ impl> ElementExtManual for O { Box::pin(receiver.map(|res| res.expect("sender dropped"))) } - fn get_current_running_time(&self) -> ::ClockTime { - use ElementExt; + fn get_current_running_time(&self) -> crate::ClockTime { + use crate::ElementExt; let base_time = self.get_base_time(); let clock_time = self.get_current_clock_time(); @@ -849,14 +837,14 @@ impl> ElementExtManual for O { clock_time - base_time } - fn get_current_clock_time(&self) -> ::ClockTime { - use ClockExt; - use ElementExt; + fn get_current_clock_time(&self) -> crate::ClockTime { + use crate::ClockExt; + use crate::ElementExt; if let Some(clock) = self.get_clock() { clock.get_time() } else { - ::CLOCK_TIME_NONE + crate::CLOCK_TIME_NONE } } } @@ -864,10 +852,9 @@ impl> ElementExtManual for O { pub unsafe trait ElementClassExt { fn get_metadata<'a>(&self, key: &str) -> Option<&'a str> { unsafe { - let klass = self as *const _ as *const gst_sys::GstElementClass; + let klass = self as *const _ as *const ffi::GstElementClass; - let ptr = - gst_sys::gst_element_class_get_metadata(klass as *mut _, key.to_glib_none().0); + let ptr = ffi::gst_element_class_get_metadata(klass as *mut _, key.to_glib_none().0); if ptr.is_null() { None @@ -879,9 +866,9 @@ pub unsafe trait ElementClassExt { fn get_pad_template(&self, name: &str) -> Option { unsafe { - let klass = self as *const _ as *const gst_sys::GstElementClass; + let klass = self as *const _ as *const ffi::GstElementClass; - from_glib_none(gst_sys::gst_element_class_get_pad_template( + from_glib_none(ffi::gst_element_class_get_pad_template( klass as *mut _, name.to_glib_none().0, )) @@ -890,9 +877,9 @@ pub unsafe trait ElementClassExt { fn get_pad_template_list(&self) -> Vec { unsafe { - let klass = self as *const _ as *const gst_sys::GstElementClass; + let klass = self as *const _ as *const ffi::GstElementClass; - FromGlibPtrContainer::from_glib_none(gst_sys::gst_element_class_get_pad_template_list( + FromGlibPtrContainer::from_glib_none(ffi::gst_element_class_get_pad_template_list( klass as *mut _, )) } @@ -902,32 +889,32 @@ pub unsafe trait ElementClassExt { unsafe impl> ElementClassExt for glib::object::Class {} pub static ELEMENT_METADATA_AUTHOR: Lazy<&'static str> = Lazy::new(|| unsafe { - CStr::from_ptr(gst_sys::GST_ELEMENT_METADATA_AUTHOR) + CStr::from_ptr(ffi::GST_ELEMENT_METADATA_AUTHOR) .to_str() .unwrap() }); pub static ELEMENT_METADATA_DESCRIPTION: Lazy<&'static str> = Lazy::new(|| unsafe { - CStr::from_ptr(gst_sys::GST_ELEMENT_METADATA_DESCRIPTION) + CStr::from_ptr(ffi::GST_ELEMENT_METADATA_DESCRIPTION) .to_str() .unwrap() }); pub static ELEMENT_METADATA_DOC_URI: Lazy<&'static str> = Lazy::new(|| unsafe { - CStr::from_ptr(gst_sys::GST_ELEMENT_METADATA_DOC_URI) + CStr::from_ptr(ffi::GST_ELEMENT_METADATA_DOC_URI) .to_str() .unwrap() }); pub static ELEMENT_METADATA_ICON_NAME: Lazy<&'static str> = Lazy::new(|| unsafe { - CStr::from_ptr(gst_sys::GST_ELEMENT_METADATA_ICON_NAME) + CStr::from_ptr(ffi::GST_ELEMENT_METADATA_ICON_NAME) .to_str() .unwrap() }); pub static ELEMENT_METADATA_KLASS: Lazy<&'static str> = Lazy::new(|| unsafe { - CStr::from_ptr(gst_sys::GST_ELEMENT_METADATA_KLASS) + CStr::from_ptr(ffi::GST_ELEMENT_METADATA_KLASS) .to_str() .unwrap() }); pub static ELEMENT_METADATA_LONGNAME: Lazy<&'static str> = Lazy::new(|| unsafe { - CStr::from_ptr(gst_sys::GST_ELEMENT_METADATA_LONGNAME) + CStr::from_ptr(ffi::GST_ELEMENT_METADATA_LONGNAME) .to_str() .unwrap() }); @@ -1400,16 +1387,16 @@ macro_rules! gst_element_info( #[cfg(test)] mod tests { use super::*; + use crate::prelude::*; use glib::GString; - use prelude::*; #[cfg(feature = "v1_10")] use std::sync::mpsc::channel; #[test] fn test_get_pads() { - ::init().unwrap(); + crate::init().unwrap(); - let identity = ::ElementFactory::make("identity", None).unwrap(); + let identity = crate::ElementFactory::make("identity", None).unwrap(); let mut pad_names = identity .get_pads() @@ -1439,9 +1426,9 @@ mod tests { #[test] #[cfg(feature = "v1_14")] fn test_foreach_pad() { - ::init().unwrap(); + crate::init().unwrap(); - let identity = ::ElementFactory::make("identity", None).unwrap(); + let identity = crate::ElementFactory::make("identity", None).unwrap(); let mut pad_names = Vec::new(); identity.foreach_pad(|_element, pad| { @@ -1456,9 +1443,9 @@ mod tests { #[cfg(feature = "v1_10")] #[test] fn test_call_async() { - ::init().unwrap(); + crate::init().unwrap(); - let identity = ::ElementFactory::make("identity", None).unwrap(); + let identity = crate::ElementFactory::make("identity", None).unwrap(); let (sender, receiver) = channel(); identity.call_async(move |_| { diff --git a/gstreamer/src/enums.rs b/gstreamer/src/enums.rs index dc983e181..b85983ff5 100644 --- a/gstreamer/src/enums.rs +++ b/gstreamer/src/enums.rs @@ -6,14 +6,14 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use crate::ClockReturn; +use crate::FlowReturn; +use crate::PadLinkReturn; +use crate::State; +use crate::StateChange; +use crate::StateChangeReturn; use std::{cmp, ops}; use thiserror::Error; -use ClockReturn; -use FlowReturn; -use PadLinkReturn; -use State; -use StateChange; -use StateChangeReturn; use glib::translate::*; use glib::value::FromValue; @@ -352,104 +352,104 @@ impl From> for ClockReturn { } } -impl PartialEq for ::TypeFindProbability { - fn eq(&self, other: &::TypeFindProbability) -> bool { +impl PartialEq for crate::TypeFindProbability { + fn eq(&self, other: &crate::TypeFindProbability) -> bool { (self.to_glib() as u32).eq(&(other.to_glib() as u32)) } } -impl Eq for ::TypeFindProbability {} +impl Eq for crate::TypeFindProbability {} -impl PartialOrd for ::TypeFindProbability { +impl PartialOrd for crate::TypeFindProbability { fn partial_cmp(&self, other: &Self) -> Option { (self.to_glib() as u32).partial_cmp(&(other.to_glib() as u32)) } } -impl Ord for ::TypeFindProbability { +impl Ord for crate::TypeFindProbability { fn cmp(&self, other: &Self) -> cmp::Ordering { (self.to_glib() as u32).cmp(&(other.to_glib() as u32)) } } -impl ops::Add for ::TypeFindProbability { - type Output = ::TypeFindProbability; +impl ops::Add for crate::TypeFindProbability { + type Output = crate::TypeFindProbability; - fn add(self, rhs: u32) -> ::TypeFindProbability { + fn add(self, rhs: u32) -> crate::TypeFindProbability { let res = (self.to_glib() as u32).saturating_add(rhs); from_glib(res as i32) } } -impl ops::AddAssign for ::TypeFindProbability { +impl ops::AddAssign for crate::TypeFindProbability { fn add_assign(&mut self, rhs: u32) { let res = (self.to_glib() as u32).saturating_add(rhs); *self = from_glib(res as i32); } } -impl ops::Sub for ::TypeFindProbability { - type Output = ::TypeFindProbability; +impl ops::Sub for crate::TypeFindProbability { + type Output = crate::TypeFindProbability; - fn sub(self, rhs: u32) -> ::TypeFindProbability { + fn sub(self, rhs: u32) -> crate::TypeFindProbability { let res = (self.to_glib() as u32).saturating_sub(rhs); from_glib(res as i32) } } -impl ops::SubAssign for ::TypeFindProbability { +impl ops::SubAssign for crate::TypeFindProbability { fn sub_assign(&mut self, rhs: u32) { let res = (self.to_glib() as u32).saturating_sub(rhs); *self = from_glib(res as i32); } } -impl PartialEq for ::Rank { - fn eq(&self, other: &::Rank) -> bool { +impl PartialEq for crate::Rank { + fn eq(&self, other: &crate::Rank) -> bool { (self.to_glib() as u32).eq(&(other.to_glib() as u32)) } } -impl Eq for ::Rank {} +impl Eq for crate::Rank {} -impl PartialOrd for ::Rank { +impl PartialOrd for crate::Rank { fn partial_cmp(&self, other: &Self) -> Option { (self.to_glib() as u32).partial_cmp(&(other.to_glib() as u32)) } } -impl Ord for ::Rank { +impl Ord for crate::Rank { fn cmp(&self, other: &Self) -> cmp::Ordering { (self.to_glib() as u32).cmp(&(other.to_glib() as u32)) } } -impl ops::Add for ::Rank { - type Output = ::Rank; +impl ops::Add for crate::Rank { + type Output = crate::Rank; - fn add(self, rhs: u32) -> ::Rank { + fn add(self, rhs: u32) -> crate::Rank { let res = (self.to_glib() as u32).saturating_add(rhs); from_glib(res as i32) } } -impl ops::AddAssign for ::Rank { +impl ops::AddAssign for crate::Rank { fn add_assign(&mut self, rhs: u32) { let res = (self.to_glib() as u32).saturating_add(rhs); *self = from_glib(res as i32); } } -impl ops::Sub for ::Rank { - type Output = ::Rank; +impl ops::Sub for crate::Rank { + type Output = crate::Rank; - fn sub(self, rhs: u32) -> ::Rank { + fn sub(self, rhs: u32) -> crate::Rank { let res = (self.to_glib() as u32).saturating_sub(rhs); from_glib(res as i32) } } -impl ops::SubAssign for ::Rank { +impl ops::SubAssign for crate::Rank { fn sub_assign(&mut self, rhs: u32) { let res = (self.to_glib() as u32).saturating_sub(rhs); *self = from_glib(res as i32); @@ -512,58 +512,58 @@ pub enum MessageType { #[doc(hidden)] impl ToGlib for MessageType { - type GlibType = gst_sys::GstMessageType; + type GlibType = ffi::GstMessageType; - fn to_glib(&self) -> gst_sys::GstMessageType { + fn to_glib(&self) -> ffi::GstMessageType { match *self { - MessageType::Unknown => gst_sys::GST_MESSAGE_UNKNOWN, - MessageType::Eos => gst_sys::GST_MESSAGE_EOS, - MessageType::Error => gst_sys::GST_MESSAGE_ERROR, - MessageType::Warning => gst_sys::GST_MESSAGE_WARNING, - MessageType::Info => gst_sys::GST_MESSAGE_INFO, - MessageType::Tag => gst_sys::GST_MESSAGE_TAG, - MessageType::Buffering => gst_sys::GST_MESSAGE_BUFFERING, - MessageType::StateChanged => gst_sys::GST_MESSAGE_STATE_CHANGED, - MessageType::StateDirty => gst_sys::GST_MESSAGE_STATE_DIRTY, - MessageType::StepDone => gst_sys::GST_MESSAGE_STEP_DONE, - MessageType::ClockProvide => gst_sys::GST_MESSAGE_CLOCK_PROVIDE, - MessageType::ClockLost => gst_sys::GST_MESSAGE_CLOCK_LOST, - MessageType::NewClock => gst_sys::GST_MESSAGE_NEW_CLOCK, - MessageType::StructureChange => gst_sys::GST_MESSAGE_STRUCTURE_CHANGE, - MessageType::StreamStatus => gst_sys::GST_MESSAGE_STREAM_STATUS, - MessageType::Application => gst_sys::GST_MESSAGE_APPLICATION, - MessageType::Element => gst_sys::GST_MESSAGE_ELEMENT, - MessageType::SegmentStart => gst_sys::GST_MESSAGE_SEGMENT_START, - MessageType::SegmentDone => gst_sys::GST_MESSAGE_SEGMENT_DONE, - MessageType::DurationChanged => gst_sys::GST_MESSAGE_DURATION_CHANGED, - MessageType::Latency => gst_sys::GST_MESSAGE_LATENCY, - MessageType::AsyncStart => gst_sys::GST_MESSAGE_ASYNC_START, - MessageType::AsyncDone => gst_sys::GST_MESSAGE_ASYNC_DONE, - MessageType::RequestState => gst_sys::GST_MESSAGE_REQUEST_STATE, - MessageType::StepStart => gst_sys::GST_MESSAGE_STEP_START, - MessageType::Qos => gst_sys::GST_MESSAGE_QOS, - MessageType::Progress => gst_sys::GST_MESSAGE_PROGRESS, - MessageType::Toc => gst_sys::GST_MESSAGE_TOC, - MessageType::ResetTime => gst_sys::GST_MESSAGE_RESET_TIME, - MessageType::StreamStart => gst_sys::GST_MESSAGE_STREAM_START, - MessageType::NeedContext => gst_sys::GST_MESSAGE_NEED_CONTEXT, - MessageType::HaveContext => gst_sys::GST_MESSAGE_HAVE_CONTEXT, - MessageType::Extended => gst_sys::GST_MESSAGE_EXTENDED, - MessageType::DeviceAdded => gst_sys::GST_MESSAGE_DEVICE_ADDED, - MessageType::DeviceRemoved => gst_sys::GST_MESSAGE_DEVICE_REMOVED, - MessageType::PropertyNotify => gst_sys::GST_MESSAGE_PROPERTY_NOTIFY, - MessageType::StreamCollection => gst_sys::GST_MESSAGE_STREAM_COLLECTION, - MessageType::StreamsSelected => gst_sys::GST_MESSAGE_STREAMS_SELECTED, - MessageType::Redirect => gst_sys::GST_MESSAGE_REDIRECT, + MessageType::Unknown => ffi::GST_MESSAGE_UNKNOWN, + MessageType::Eos => ffi::GST_MESSAGE_EOS, + MessageType::Error => ffi::GST_MESSAGE_ERROR, + MessageType::Warning => ffi::GST_MESSAGE_WARNING, + MessageType::Info => ffi::GST_MESSAGE_INFO, + MessageType::Tag => ffi::GST_MESSAGE_TAG, + MessageType::Buffering => ffi::GST_MESSAGE_BUFFERING, + MessageType::StateChanged => ffi::GST_MESSAGE_STATE_CHANGED, + MessageType::StateDirty => ffi::GST_MESSAGE_STATE_DIRTY, + MessageType::StepDone => ffi::GST_MESSAGE_STEP_DONE, + MessageType::ClockProvide => ffi::GST_MESSAGE_CLOCK_PROVIDE, + MessageType::ClockLost => ffi::GST_MESSAGE_CLOCK_LOST, + MessageType::NewClock => ffi::GST_MESSAGE_NEW_CLOCK, + MessageType::StructureChange => ffi::GST_MESSAGE_STRUCTURE_CHANGE, + MessageType::StreamStatus => ffi::GST_MESSAGE_STREAM_STATUS, + MessageType::Application => ffi::GST_MESSAGE_APPLICATION, + MessageType::Element => ffi::GST_MESSAGE_ELEMENT, + MessageType::SegmentStart => ffi::GST_MESSAGE_SEGMENT_START, + MessageType::SegmentDone => ffi::GST_MESSAGE_SEGMENT_DONE, + MessageType::DurationChanged => ffi::GST_MESSAGE_DURATION_CHANGED, + MessageType::Latency => ffi::GST_MESSAGE_LATENCY, + MessageType::AsyncStart => ffi::GST_MESSAGE_ASYNC_START, + MessageType::AsyncDone => ffi::GST_MESSAGE_ASYNC_DONE, + MessageType::RequestState => ffi::GST_MESSAGE_REQUEST_STATE, + MessageType::StepStart => ffi::GST_MESSAGE_STEP_START, + MessageType::Qos => ffi::GST_MESSAGE_QOS, + MessageType::Progress => ffi::GST_MESSAGE_PROGRESS, + MessageType::Toc => ffi::GST_MESSAGE_TOC, + MessageType::ResetTime => ffi::GST_MESSAGE_RESET_TIME, + MessageType::StreamStart => ffi::GST_MESSAGE_STREAM_START, + MessageType::NeedContext => ffi::GST_MESSAGE_NEED_CONTEXT, + MessageType::HaveContext => ffi::GST_MESSAGE_HAVE_CONTEXT, + MessageType::Extended => ffi::GST_MESSAGE_EXTENDED, + MessageType::DeviceAdded => ffi::GST_MESSAGE_DEVICE_ADDED, + MessageType::DeviceRemoved => ffi::GST_MESSAGE_DEVICE_REMOVED, + MessageType::PropertyNotify => ffi::GST_MESSAGE_PROPERTY_NOTIFY, + MessageType::StreamCollection => ffi::GST_MESSAGE_STREAM_COLLECTION, + MessageType::StreamsSelected => ffi::GST_MESSAGE_STREAMS_SELECTED, + MessageType::Redirect => ffi::GST_MESSAGE_REDIRECT, MessageType::__Unknown(value) => value as u32, } } } #[doc(hidden)] -impl FromGlib for MessageType { +impl FromGlib for MessageType { #[allow(clippy::unreadable_literal)] - fn from_glib(value: gst_sys::GstMessageType) -> Self { + fn from_glib(value: ffi::GstMessageType) -> Self { skip_assert_initialized!(); match value { 0 => MessageType::Unknown, @@ -612,7 +612,7 @@ impl FromGlib for MessageType { impl StaticType for MessageType { fn static_type() -> Type { - unsafe { from_glib(gst_sys::gst_message_type_get_type()) } + unsafe { from_glib(ffi::gst_message_type_get_type()) } } } @@ -624,13 +624,13 @@ impl<'a> FromValueOptional<'a> for MessageType { impl<'a> FromValue<'a> for MessageType { unsafe fn from_value(value: &Value) -> Self { - from_glib(gobject_sys::g_value_get_flags(value.to_glib_none().0)) + from_glib(glib::gobject_ffi::g_value_get_flags(value.to_glib_none().0)) } } impl SetValue for MessageType { unsafe fn set_value(value: &mut Value, this: &Self) { - gobject_sys::g_value_set_flags(value.to_glib_none_mut().0, this.to_glib()) + glib::gobject_ffi::g_value_set_flags(value.to_glib_none_mut().0, this.to_glib()) } } diff --git a/gstreamer/src/error.rs b/gstreamer/src/error.rs index 58221d370..eef6c6809 100644 --- a/gstreamer/src/error.rs +++ b/gstreamer/src/error.rs @@ -8,7 +8,6 @@ use thiserror::Error; -use glib; use glib::IsA; #[macro_export] @@ -62,7 +61,7 @@ pub struct ErrorMessage { } impl ErrorMessage { - pub fn new( + pub fn new( error: &T, message: Option<&str>, debug: Option<&str>, @@ -102,14 +101,14 @@ macro_rules! gst_loggable_error( #[macro_export] macro_rules! gst_result_from_gboolean( // Plain strings - ($gst_sys_bool:expr, $cat:expr, $msg:expr) => { - $crate::glib::glib_result_from_gboolean!($gst_sys_bool, $msg) + ($ffi_bool:expr, $cat:expr, $msg:expr) => { + $crate::glib::glib_result_from_gboolean!($ffi_bool, $msg) .map_err(|bool_err| $crate::LoggableError::new($cat.clone(), bool_err)) }; // Format strings - ($gst_sys_bool:expr, $cat:expr, $($msg:tt)*) => { { - $crate::glib::glib_result_from_gboolean!($gst_sys_bool, $($msg)*) + ($ffi_bool:expr, $cat:expr, $($msg:tt)*) => { { + $crate::glib::glib_result_from_gboolean!($ffi_bool, $($msg)*) .map_err(|bool_err| $crate::LoggableError::new($cat.clone(), bool_err)) }}; ); @@ -117,12 +116,12 @@ macro_rules! gst_result_from_gboolean( #[derive(Debug, Clone, Error)] #[error("Error {:?}: {:?} at {}:{}", .category.get_name(), .bool_error.message, .bool_error.filename, .bool_error.line)] pub struct LoggableError { - category: ::DebugCategory, + category: crate::DebugCategory, bool_error: glib::BoolError, } impl LoggableError { - pub fn new(category: ::DebugCategory, bool_error: glib::BoolError) -> LoggableError { + pub fn new(category: crate::DebugCategory, bool_error: glib::BoolError) -> LoggableError { assert_initialized_main_thread!(); LoggableError { category, @@ -133,7 +132,7 @@ impl LoggableError { pub fn log(&self) { self.category.log( None as Option<&glib::Object>, - ::DebugLevel::Error, + crate::DebugLevel::Error, self.bool_error.filename, self.bool_error.function, self.bool_error.line, @@ -144,7 +143,7 @@ impl LoggableError { pub fn log_with_object>(&self, obj: &O) { self.category.log( Some(obj), - ::DebugLevel::Error, + crate::DebugLevel::Error, self.bool_error.filename, self.bool_error.function, self.bool_error.line, @@ -152,7 +151,7 @@ impl LoggableError { ); } - pub fn category(&self) -> ::DebugCategory { + pub fn category(&self) -> crate::DebugCategory { self.category } } @@ -161,7 +160,7 @@ impl From for LoggableError { fn from(bool_error: glib::BoolError) -> Self { skip_assert_initialized!(); LoggableError { - category: *::CAT_RUST, + category: *crate::CAT_RUST, bool_error, } } @@ -173,10 +172,10 @@ mod tests { #[test] fn error_message() { - ::init().unwrap(); + crate::init().unwrap(); let e = ErrorMessage::new( - &::CoreError::Failed, + &crate::CoreError::Failed, Some("message"), Some("debug"), "filename", @@ -191,7 +190,7 @@ mod tests { #[test] fn logabble_error() { - ::init().unwrap(); + crate::init().unwrap(); let e: LoggableError = glib::BoolError::new("msg", "filename", "function", 7).into(); assert_eq!( diff --git a/gstreamer/src/event.rs b/gstreamer/src/event.rs index fdf01d114..8c11503c2 100644 --- a/gstreamer/src/event.rs +++ b/gstreamer/src/event.rs @@ -6,9 +6,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use gst_sys; -use structure::*; -use GenericFormattedValue; +use crate::structure::*; +use crate::GenericFormattedValue; use std::cmp; use std::ffi::CStr; @@ -18,7 +17,6 @@ use std::num::NonZeroU32; use std::ops::Deref; use std::ptr; -use glib; use glib::translate::{from_glib, from_glib_full, from_glib_none, ToGlib, ToGlibPtr}; use glib::value::ToSendValue; @@ -26,7 +24,7 @@ use glib::value::ToSendValue; #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))] use glib::translate::FromGlibPtrContainer; -use EventType; +use crate::EventType; #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub struct Seqnum(pub(crate) NonZeroU32); @@ -34,7 +32,7 @@ pub struct Seqnum(pub(crate) NonZeroU32); impl Seqnum { pub fn next() -> Self { unsafe { - let v = gst_sys::gst_util_seqnum_next(); + let v = ffi::gst_util_seqnum_next(); if v == 0 { Seqnum::next() } else { @@ -61,7 +59,7 @@ impl cmp::PartialOrd for Seqnum { impl cmp::Ord for Seqnum { fn cmp(&self, other: &Seqnum) -> cmp::Ordering { unsafe { - let ret = gst_sys::gst_util_seqnum_compare(self.0.get(), other.0.get()); + let ret = ffi::gst_util_seqnum_compare(self.0.get(), other.0.get()); ret.cmp(&0) } } @@ -73,7 +71,7 @@ pub struct GroupId(pub(crate) NonZeroU32); impl GroupId { pub fn next() -> Self { unsafe { - let v = gst_sys::gst_util_group_id_next(); + let v = ffi::gst_util_group_id_next(); if v == 0 { GroupId::next() } else { @@ -85,23 +83,23 @@ impl GroupId { impl EventType { pub fn is_upstream(self) -> bool { - (self.to_glib() as u32) & gst_sys::GST_EVENT_TYPE_UPSTREAM != 0 + (self.to_glib() as u32) & ffi::GST_EVENT_TYPE_UPSTREAM != 0 } pub fn is_downstream(self) -> bool { - (self.to_glib() as u32) & gst_sys::GST_EVENT_TYPE_DOWNSTREAM != 0 + (self.to_glib() as u32) & ffi::GST_EVENT_TYPE_DOWNSTREAM != 0 } pub fn is_serialized(self) -> bool { - (self.to_glib() as u32) & gst_sys::GST_EVENT_TYPE_SERIALIZED != 0 + (self.to_glib() as u32) & ffi::GST_EVENT_TYPE_SERIALIZED != 0 } pub fn is_sticky(self) -> bool { - (self.to_glib() as u32) & gst_sys::GST_EVENT_TYPE_STICKY != 0 + (self.to_glib() as u32) & ffi::GST_EVENT_TYPE_STICKY != 0 } pub fn is_sticky_multi(self) -> bool { - (self.to_glib() as u32) & gst_sys::GST_EVENT_TYPE_STICKY_MULTI != 0 + (self.to_glib() as u32) & ffi::GST_EVENT_TYPE_STICKY_MULTI != 0 } } @@ -114,9 +112,9 @@ impl PartialOrd for EventType { let v1 = self.to_glib() as u32; let v2 = other.to_glib() as u32; - let stream_start = gst_sys::GST_EVENT_STREAM_START as u32; - let segment = gst_sys::GST_EVENT_SEGMENT as u32; - let eos = gst_sys::GST_EVENT_EOS as u32; + let stream_start = ffi::GST_EVENT_STREAM_START as u32; + let segment = ffi::GST_EVENT_SEGMENT as u32; + let eos = ffi::GST_EVENT_EOS as u32; // Strictly ordered range between stream_start and segment, // and EOS is bigger than everything else @@ -137,30 +135,30 @@ impl PartialOrd for EventType { } } -gst_define_mini_object_wrapper!(Event, EventRef, gst_sys::GstEvent, || { - gst_sys::gst_event_get_type() +gst_define_mini_object_wrapper!(Event, EventRef, ffi::GstEvent, || { + ffi::gst_event_get_type() }); impl EventRef { pub fn get_seqnum(&self) -> Seqnum { unsafe { - let seqnum = gst_sys::gst_event_get_seqnum(self.as_mut_ptr()); + let seqnum = ffi::gst_event_get_seqnum(self.as_mut_ptr()); assert_ne!(seqnum, 0); Seqnum(NonZeroU32::new_unchecked(seqnum)) } } pub fn get_running_time_offset(&self) -> i64 { - unsafe { gst_sys::gst_event_get_running_time_offset(self.as_mut_ptr()) } + unsafe { ffi::gst_event_get_running_time_offset(self.as_mut_ptr()) } } pub fn set_running_time_offset(&mut self, offset: i64) { - unsafe { gst_sys::gst_event_set_running_time_offset(self.as_mut_ptr(), offset) } + unsafe { ffi::gst_event_set_running_time_offset(self.as_mut_ptr(), offset) } } pub fn get_structure(&self) -> Option<&StructureRef> { unsafe { - let structure = gst_sys::gst_event_get_structure(self.as_mut_ptr()); + let structure = ffi::gst_event_get_structure(self.as_mut_ptr()); if structure.is_null() { None } else { @@ -171,9 +169,7 @@ impl EventRef { pub fn structure_mut(&mut self) -> &mut StructureRef { unsafe { - StructureRef::from_glib_borrow_mut(gst_sys::gst_event_writable_structure( - self.as_mut_ptr(), - )) + StructureRef::from_glib_borrow_mut(ffi::gst_event_writable_structure(self.as_mut_ptr())) } } @@ -205,45 +201,39 @@ impl EventRef { let type_ = unsafe { (*self.as_ptr()).type_ }; match type_ { - gst_sys::GST_EVENT_FLUSH_START => EventView::FlushStart(FlushStart(self)), - gst_sys::GST_EVENT_FLUSH_STOP => EventView::FlushStop(FlushStop(self)), - gst_sys::GST_EVENT_STREAM_START => EventView::StreamStart(StreamStart(self)), - gst_sys::GST_EVENT_CAPS => EventView::Caps(Caps(self)), - gst_sys::GST_EVENT_SEGMENT => EventView::Segment(Segment(self)), - gst_sys::GST_EVENT_STREAM_COLLECTION => { - EventView::StreamCollection(StreamCollection(self)) - } - gst_sys::GST_EVENT_TAG => EventView::Tag(Tag(self)), - gst_sys::GST_EVENT_BUFFERSIZE => EventView::BufferSize(BufferSize(self)), - gst_sys::GST_EVENT_SINK_MESSAGE => EventView::SinkMessage(SinkMessage(self)), - gst_sys::GST_EVENT_STREAM_GROUP_DONE => { - EventView::StreamGroupDone(StreamGroupDone(self)) - } - gst_sys::GST_EVENT_EOS => EventView::Eos(Eos(self)), - gst_sys::GST_EVENT_TOC => EventView::Toc(Toc(self)), - gst_sys::GST_EVENT_PROTECTION => EventView::Protection(Protection(self)), - gst_sys::GST_EVENT_SEGMENT_DONE => EventView::SegmentDone(SegmentDone(self)), - gst_sys::GST_EVENT_GAP => EventView::Gap(Gap(self)), - gst_sys::GST_EVENT_QOS => EventView::Qos(Qos(self)), - gst_sys::GST_EVENT_SEEK => EventView::Seek(Seek(self)), - gst_sys::GST_EVENT_NAVIGATION => EventView::Navigation(Navigation(self)), - gst_sys::GST_EVENT_LATENCY => EventView::Latency(Latency(self)), - gst_sys::GST_EVENT_STEP => EventView::Step(Step(self)), - gst_sys::GST_EVENT_RECONFIGURE => EventView::Reconfigure(Reconfigure(self)), - gst_sys::GST_EVENT_TOC_SELECT => EventView::TocSelect(TocSelect(self)), - gst_sys::GST_EVENT_SELECT_STREAMS => EventView::SelectStreams(SelectStreams(self)), - gst_sys::GST_EVENT_CUSTOM_UPSTREAM => EventView::CustomUpstream(CustomUpstream(self)), - gst_sys::GST_EVENT_CUSTOM_DOWNSTREAM => { - EventView::CustomDownstream(CustomDownstream(self)) - } - gst_sys::GST_EVENT_CUSTOM_DOWNSTREAM_OOB => { + ffi::GST_EVENT_FLUSH_START => EventView::FlushStart(FlushStart(self)), + ffi::GST_EVENT_FLUSH_STOP => EventView::FlushStop(FlushStop(self)), + ffi::GST_EVENT_STREAM_START => EventView::StreamStart(StreamStart(self)), + ffi::GST_EVENT_CAPS => EventView::Caps(Caps(self)), + ffi::GST_EVENT_SEGMENT => EventView::Segment(Segment(self)), + ffi::GST_EVENT_STREAM_COLLECTION => EventView::StreamCollection(StreamCollection(self)), + ffi::GST_EVENT_TAG => EventView::Tag(Tag(self)), + ffi::GST_EVENT_BUFFERSIZE => EventView::BufferSize(BufferSize(self)), + ffi::GST_EVENT_SINK_MESSAGE => EventView::SinkMessage(SinkMessage(self)), + ffi::GST_EVENT_STREAM_GROUP_DONE => EventView::StreamGroupDone(StreamGroupDone(self)), + ffi::GST_EVENT_EOS => EventView::Eos(Eos(self)), + ffi::GST_EVENT_TOC => EventView::Toc(Toc(self)), + ffi::GST_EVENT_PROTECTION => EventView::Protection(Protection(self)), + ffi::GST_EVENT_SEGMENT_DONE => EventView::SegmentDone(SegmentDone(self)), + ffi::GST_EVENT_GAP => EventView::Gap(Gap(self)), + ffi::GST_EVENT_QOS => EventView::Qos(Qos(self)), + ffi::GST_EVENT_SEEK => EventView::Seek(Seek(self)), + ffi::GST_EVENT_NAVIGATION => EventView::Navigation(Navigation(self)), + ffi::GST_EVENT_LATENCY => EventView::Latency(Latency(self)), + ffi::GST_EVENT_STEP => EventView::Step(Step(self)), + ffi::GST_EVENT_RECONFIGURE => EventView::Reconfigure(Reconfigure(self)), + ffi::GST_EVENT_TOC_SELECT => EventView::TocSelect(TocSelect(self)), + ffi::GST_EVENT_SELECT_STREAMS => EventView::SelectStreams(SelectStreams(self)), + ffi::GST_EVENT_CUSTOM_UPSTREAM => EventView::CustomUpstream(CustomUpstream(self)), + ffi::GST_EVENT_CUSTOM_DOWNSTREAM => EventView::CustomDownstream(CustomDownstream(self)), + ffi::GST_EVENT_CUSTOM_DOWNSTREAM_OOB => { EventView::CustomDownstreamOob(CustomDownstreamOob(self)) } - gst_sys::GST_EVENT_CUSTOM_DOWNSTREAM_STICKY => { + ffi::GST_EVENT_CUSTOM_DOWNSTREAM_STICKY => { EventView::CustomDownstreamSticky(CustomDownstreamSticky(self)) } - gst_sys::GST_EVENT_CUSTOM_BOTH => EventView::CustomBoth(CustomBoth(self)), - gst_sys::GST_EVENT_CUSTOM_BOTH_OOB => EventView::CustomBothOob(CustomBothOob(self)), + ffi::GST_EVENT_CUSTOM_BOTH => EventView::CustomBoth(CustomBoth(self)), + ffi::GST_EVENT_CUSTOM_BOTH_OOB => EventView::CustomBothOob(CustomBothOob(self)), _ => EventView::Other, } } @@ -260,7 +250,7 @@ impl fmt::Debug for EventRef { f.debug_struct("Event") .field("ptr", unsafe { &self.as_ptr() }) .field("type", &unsafe { - let type_ = gst_sys::gst_event_type_get_name((*self.as_ptr()).type_); + let type_ = ffi::gst_event_type_get_name((*self.as_ptr()).type_); CStr::from_ptr(type_).to_str().unwrap() }) .field("seqnum", &self.get_seqnum()) @@ -350,7 +340,7 @@ impl<'a> FlushStop<'a> { unsafe { let mut reset_time = mem::MaybeUninit::uninit(); - gst_sys::gst_event_parse_flush_stop(self.as_mut_ptr(), reset_time.as_mut_ptr()); + ffi::gst_event_parse_flush_stop(self.as_mut_ptr(), reset_time.as_mut_ptr()); from_glib(reset_time.assume_init()) } @@ -374,16 +364,16 @@ impl<'a> StreamStart<'a> { unsafe { let mut stream_id = ptr::null(); - gst_sys::gst_event_parse_stream_start(self.as_mut_ptr(), &mut stream_id); + ffi::gst_event_parse_stream_start(self.as_mut_ptr(), &mut stream_id); CStr::from_ptr(stream_id).to_str().unwrap() } } - pub fn get_stream_flags(&self) -> ::StreamFlags { + pub fn get_stream_flags(&self) -> crate::StreamFlags { unsafe { let mut stream_flags = mem::MaybeUninit::uninit(); - gst_sys::gst_event_parse_stream_flags(self.as_mut_ptr(), stream_flags.as_mut_ptr()); + ffi::gst_event_parse_stream_flags(self.as_mut_ptr(), stream_flags.as_mut_ptr()); from_glib(stream_flags.assume_init()) } @@ -393,7 +383,7 @@ impl<'a> StreamStart<'a> { unsafe { let mut group_id = mem::MaybeUninit::uninit(); - gst_sys::gst_event_parse_group_id(self.as_mut_ptr(), group_id.as_mut_ptr()); + ffi::gst_event_parse_group_id(self.as_mut_ptr(), group_id.as_mut_ptr()); let group_id = group_id.assume_init(); if group_id == 0 { @@ -406,10 +396,10 @@ impl<'a> StreamStart<'a> { #[cfg(any(feature = "v1_10", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))] - pub fn get_stream(&self) -> Option<::Stream> { + pub fn get_stream(&self) -> Option { unsafe { let mut stream = ptr::null_mut(); - gst_sys::gst_event_parse_stream(self.as_mut_ptr(), &mut stream); + ffi::gst_event_parse_stream(self.as_mut_ptr(), &mut stream); from_glib_full(stream) } } @@ -418,26 +408,26 @@ impl<'a> StreamStart<'a> { declare_concrete_event!(Caps); impl<'a> Caps<'a> { #[allow(clippy::new_ret_no_self)] - pub fn new(caps: &::Caps) -> Event { + pub fn new(caps: &crate::Caps) -> Event { skip_assert_initialized!(); Self::builder(caps).build() } - pub fn builder(caps: &::Caps) -> CapsBuilder { + pub fn builder(caps: &crate::Caps) -> CapsBuilder { assert_initialized_main_thread!(); CapsBuilder::new(caps) } - pub fn get_caps(&self) -> &'a ::CapsRef { + pub fn get_caps(&self) -> &'a crate::CapsRef { unsafe { let mut caps = ptr::null_mut(); - gst_sys::gst_event_parse_caps(self.as_mut_ptr(), &mut caps); - ::CapsRef::from_ptr(caps) + ffi::gst_event_parse_caps(self.as_mut_ptr(), &mut caps); + crate::CapsRef::from_ptr(caps) } } - pub fn get_caps_owned(&self) -> ::Caps { + pub fn get_caps_owned(&self) -> crate::Caps { unsafe { from_glib_none(self.get_caps().as_ptr()) } } } @@ -445,22 +435,24 @@ impl<'a> Caps<'a> { declare_concrete_event!(Segment); impl<'a> Segment<'a> { #[allow(clippy::new_ret_no_self)] - pub fn new(segment: &::FormattedSegment) -> Event { + pub fn new(segment: &crate::FormattedSegment) -> Event { skip_assert_initialized!(); Self::builder(segment).build() } - pub fn builder(segment: &::FormattedSegment) -> SegmentBuilder { + pub fn builder( + segment: &crate::FormattedSegment, + ) -> SegmentBuilder { assert_initialized_main_thread!(); SegmentBuilder::new(segment.as_ref()) } - pub fn get_segment(&self) -> &'a ::Segment { + pub fn get_segment(&self) -> &'a crate::Segment { unsafe { let mut segment = ptr::null(); - gst_sys::gst_event_parse_segment(self.as_mut_ptr(), &mut segment); - &*(segment as *mut gst_sys::GstSegment as *mut ::Segment) + ffi::gst_event_parse_segment(self.as_mut_ptr(), &mut segment); + &*(segment as *mut ffi::GstSegment as *mut crate::Segment) } } } @@ -470,25 +462,25 @@ impl<'a> StreamCollection<'a> { #[cfg(any(feature = "v1_10", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))] #[allow(clippy::new_ret_no_self)] - pub fn new(stream_collection: &::StreamCollection) -> Event { + pub fn new(stream_collection: &crate::StreamCollection) -> Event { skip_assert_initialized!(); Self::builder(stream_collection).build() } #[cfg(any(feature = "v1_10", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))] - pub fn builder(stream_collection: &::StreamCollection) -> StreamCollectionBuilder { + pub fn builder(stream_collection: &crate::StreamCollection) -> StreamCollectionBuilder { assert_initialized_main_thread!(); StreamCollectionBuilder::new(stream_collection) } #[cfg(any(feature = "v1_10", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))] - pub fn get_stream_collection(&self) -> ::StreamCollection { + pub fn get_stream_collection(&self) -> crate::StreamCollection { unsafe { let mut stream_collection = ptr::null_mut(); - gst_sys::gst_event_parse_stream_collection(self.as_mut_ptr(), &mut stream_collection); + ffi::gst_event_parse_stream_collection(self.as_mut_ptr(), &mut stream_collection); from_glib_full(stream_collection) } } @@ -497,26 +489,26 @@ impl<'a> StreamCollection<'a> { declare_concrete_event!(Tag); impl<'a> Tag<'a> { #[allow(clippy::new_ret_no_self)] - pub fn new(tags: ::TagList) -> Event { + pub fn new(tags: crate::TagList) -> Event { skip_assert_initialized!(); Self::builder(tags).build() } - pub fn builder(tags: ::TagList) -> TagBuilder<'a> { + pub fn builder(tags: crate::TagList) -> TagBuilder<'a> { assert_initialized_main_thread!(); TagBuilder::new(tags) } - pub fn get_tag(&self) -> &'a ::TagListRef { + pub fn get_tag(&self) -> &'a crate::TagListRef { unsafe { let mut tags = ptr::null_mut(); - gst_sys::gst_event_parse_tag(self.as_mut_ptr(), &mut tags); - ::TagListRef::from_ptr(tags) + ffi::gst_event_parse_tag(self.as_mut_ptr(), &mut tags); + crate::TagListRef::from_ptr(tags) } } - pub fn get_tag_owned(&self) -> ::TagList { + pub fn get_tag_owned(&self) -> crate::TagList { unsafe { from_glib_none(self.get_tag().as_ptr()) } } } @@ -524,22 +516,22 @@ impl<'a> Tag<'a> { declare_concrete_event!(BufferSize); impl<'a> BufferSize<'a> { #[allow(clippy::new_ret_no_self)] - pub fn new>(minsize: V, maxsize: V, async: bool) -> Event { + pub fn new>(minsize: V, maxsize: V, r#async: bool) -> Event { skip_assert_initialized!(); - Self::builder(minsize, maxsize, async).build() + Self::builder(minsize, maxsize, r#async).build() } pub fn builder>( minsize: V, maxsize: V, - async: bool, + r#async: bool, ) -> BufferSizeBuilder<'a> { assert_initialized_main_thread!(); let minsize = minsize.into(); let maxsize = maxsize.into(); assert_eq!(minsize.get_format(), maxsize.get_format()); - BufferSizeBuilder::new(minsize, maxsize, async) + BufferSizeBuilder::new(minsize, maxsize, r#async) } pub fn get(&self) -> (GenericFormattedValue, GenericFormattedValue, bool) { @@ -549,7 +541,7 @@ impl<'a> BufferSize<'a> { let mut maxsize = mem::MaybeUninit::uninit(); let mut async_ = mem::MaybeUninit::uninit(); - gst_sys::gst_event_parse_buffer_size( + ffi::gst_event_parse_buffer_size( self.as_mut_ptr(), fmt.as_mut_ptr(), minsize.as_mut_ptr(), @@ -568,21 +560,21 @@ impl<'a> BufferSize<'a> { declare_concrete_event!(SinkMessage); impl<'a> SinkMessage<'a> { #[allow(clippy::new_ret_no_self)] - pub fn new(name: &'a str, msg: &'a ::Message) -> Event { + pub fn new(name: &'a str, msg: &'a crate::Message) -> Event { skip_assert_initialized!(); Self::builder(name, msg).build() } - pub fn builder(name: &'a str, msg: &'a ::Message) -> SinkMessageBuilder<'a> { + pub fn builder(name: &'a str, msg: &'a crate::Message) -> SinkMessageBuilder<'a> { assert_initialized_main_thread!(); SinkMessageBuilder::new(name, msg) } - pub fn get_message(&self) -> ::Message { + pub fn get_message(&self) -> crate::Message { unsafe { let mut msg = ptr::null_mut(); - gst_sys::gst_event_parse_sink_message(self.as_mut_ptr(), &mut msg); + ffi::gst_event_parse_sink_message(self.as_mut_ptr(), &mut msg); from_glib_full(msg) } } @@ -611,7 +603,7 @@ impl<'a> StreamGroupDone<'a> { unsafe { let mut group_id = mem::MaybeUninit::uninit(); - gst_sys::gst_event_parse_stream_group_done(self.as_mut_ptr(), group_id.as_mut_ptr()); + ffi::gst_event_parse_stream_group_done(self.as_mut_ptr(), group_id.as_mut_ptr()); let group_id = group_id.assume_init(); assert_ne!(group_id, 0); @@ -639,27 +631,30 @@ impl<'a> Toc<'a> { // FIXME could use false for updated as default // Even better: use an enum for updated so that it is more explicit than true / false #[allow(clippy::new_ret_no_self)] - pub fn new(toc: &::Toc, updated: bool) -> Event { + pub fn new(toc: &crate::Toc, updated: bool) -> Event { skip_assert_initialized!(); Self::builder(toc, updated).build() } - pub fn builder(toc: &::Toc, updated: bool) -> TocBuilder { + pub fn builder(toc: &crate::Toc, updated: bool) -> TocBuilder { assert_initialized_main_thread!(); TocBuilder::new(toc, updated) } - pub fn get_toc(&self) -> (&'a ::TocRef, bool) { + pub fn get_toc(&self) -> (&'a crate::TocRef, bool) { unsafe { let mut toc = ptr::null_mut(); let mut updated = mem::MaybeUninit::uninit(); - gst_sys::gst_event_parse_toc(self.as_mut_ptr(), &mut toc, updated.as_mut_ptr()); - (::TocRef::from_ptr(toc), from_glib(updated.assume_init())) + ffi::gst_event_parse_toc(self.as_mut_ptr(), &mut toc, updated.as_mut_ptr()); + ( + crate::TocRef::from_ptr(toc), + from_glib(updated.assume_init()), + ) } } - pub fn get_toc_owned(&self) -> (::Toc, bool) { + pub fn get_toc_owned(&self) -> (crate::Toc, bool) { unsafe { let (toc, updated) = self.get_toc(); (from_glib_none(toc.as_ptr()), updated) @@ -670,23 +665,23 @@ impl<'a> Toc<'a> { declare_concrete_event!(Protection); impl<'a> Protection<'a> { #[allow(clippy::new_ret_no_self)] - pub fn new(system_id: &'a str, data: &'a ::Buffer) -> Event { + pub fn new(system_id: &'a str, data: &'a crate::Buffer) -> Event { skip_assert_initialized!(); Self::builder(system_id, data).build() } - pub fn builder(system_id: &'a str, data: &'a ::Buffer) -> ProtectionBuilder<'a> { + pub fn builder(system_id: &'a str, data: &'a crate::Buffer) -> ProtectionBuilder<'a> { assert_initialized_main_thread!(); ProtectionBuilder::new(system_id, data) } - pub fn get(&self) -> (&'a str, &'a ::BufferRef, Option<&'a str>) { + pub fn get(&self) -> (&'a str, &'a crate::BufferRef, Option<&'a str>) { unsafe { let mut system_id = ptr::null(); let mut buffer = ptr::null_mut(); let mut origin = ptr::null(); - gst_sys::gst_event_parse_protection( + ffi::gst_event_parse_protection( self.as_mut_ptr(), &mut system_id, &mut buffer, @@ -695,7 +690,7 @@ impl<'a> Protection<'a> { ( CStr::from_ptr(system_id).to_str().unwrap(), - ::BufferRef::from_ptr(buffer), + crate::BufferRef::from_ptr(buffer), if origin.is_null() { None } else { @@ -705,7 +700,7 @@ impl<'a> Protection<'a> { } } - pub fn get_owned(&self) -> (&'a str, ::Buffer, Option<&'a str>) { + pub fn get_owned(&self) -> (&'a str, crate::Buffer, Option<&'a str>) { unsafe { let (system_id, buffer, origin) = self.get(); (system_id, from_glib_none(buffer.as_ptr()), origin) @@ -732,7 +727,7 @@ impl<'a> SegmentDone<'a> { let mut fmt = mem::MaybeUninit::uninit(); let mut position = mem::MaybeUninit::uninit(); - gst_sys::gst_event_parse_segment_done( + ffi::gst_event_parse_segment_done( self.as_mut_ptr(), fmt.as_mut_ptr(), position.as_mut_ptr(), @@ -746,22 +741,22 @@ impl<'a> SegmentDone<'a> { declare_concrete_event!(Gap); impl<'a> Gap<'a> { #[allow(clippy::new_ret_no_self)] - pub fn new(timestamp: ::ClockTime, duration: ::ClockTime) -> Event { + pub fn new(timestamp: crate::ClockTime, duration: crate::ClockTime) -> Event { skip_assert_initialized!(); Self::builder(timestamp, duration).build() } - pub fn builder(timestamp: ::ClockTime, duration: ::ClockTime) -> GapBuilder<'a> { + pub fn builder(timestamp: crate::ClockTime, duration: crate::ClockTime) -> GapBuilder<'a> { assert_initialized_main_thread!(); GapBuilder::new(timestamp, duration) } - pub fn get(&self) -> (::ClockTime, ::ClockTime) { + pub fn get(&self) -> (crate::ClockTime, crate::ClockTime) { unsafe { let mut timestamp = mem::MaybeUninit::uninit(); let mut duration = mem::MaybeUninit::uninit(); - gst_sys::gst_event_parse_gap( + ffi::gst_event_parse_gap( self.as_mut_ptr(), timestamp.as_mut_ptr(), duration.as_mut_ptr(), @@ -778,29 +773,34 @@ impl<'a> Gap<'a> { declare_concrete_event!(Qos); impl<'a> Qos<'a> { #[allow(clippy::new_ret_no_self)] - pub fn new(type_: ::QOSType, proportion: f64, diff: i64, timestamp: ::ClockTime) -> Event { + pub fn new( + type_: crate::QOSType, + proportion: f64, + diff: i64, + timestamp: crate::ClockTime, + ) -> Event { skip_assert_initialized!(); Self::builder(type_, proportion, diff, timestamp).build() } pub fn builder( - type_: ::QOSType, + type_: crate::QOSType, proportion: f64, diff: i64, - timestamp: ::ClockTime, + timestamp: crate::ClockTime, ) -> QosBuilder<'a> { assert_initialized_main_thread!(); QosBuilder::new(type_, proportion, diff, timestamp) } - pub fn get(&self) -> (::QOSType, f64, i64, ::ClockTime) { + pub fn get(&self) -> (crate::QOSType, f64, i64, crate::ClockTime) { unsafe { let mut type_ = mem::MaybeUninit::uninit(); let mut proportion = mem::MaybeUninit::uninit(); let mut diff = mem::MaybeUninit::uninit(); let mut timestamp = mem::MaybeUninit::uninit(); - gst_sys::gst_event_parse_qos( + ffi::gst_event_parse_qos( self.as_mut_ptr(), type_.as_mut_ptr(), proportion.as_mut_ptr(), @@ -823,10 +823,10 @@ impl<'a> Seek<'a> { #[allow(clippy::new_ret_no_self)] pub fn new>( rate: f64, - flags: ::SeekFlags, - start_type: ::SeekType, + flags: crate::SeekFlags, + start_type: crate::SeekType, start: V, - stop_type: ::SeekType, + stop_type: crate::SeekType, stop: V, ) -> Event { skip_assert_initialized!(); @@ -835,10 +835,10 @@ impl<'a> Seek<'a> { pub fn builder>( rate: f64, - flags: ::SeekFlags, - start_type: ::SeekType, + flags: crate::SeekFlags, + start_type: crate::SeekType, start: V, - stop_type: ::SeekType, + stop_type: crate::SeekType, stop: V, ) -> SeekBuilder<'a> { assert_initialized_main_thread!(); @@ -853,10 +853,10 @@ impl<'a> Seek<'a> { &self, ) -> ( f64, - ::SeekFlags, - ::SeekType, + crate::SeekFlags, + crate::SeekType, GenericFormattedValue, - ::SeekType, + crate::SeekType, GenericFormattedValue, ) { unsafe { @@ -868,7 +868,7 @@ impl<'a> Seek<'a> { let mut stop_type = mem::MaybeUninit::uninit(); let mut stop = mem::MaybeUninit::uninit(); - gst_sys::gst_event_parse_seek( + ffi::gst_event_parse_seek( self.as_mut_ptr(), rate.as_mut_ptr(), fmt.as_mut_ptr(), @@ -892,11 +892,11 @@ impl<'a> Seek<'a> { #[cfg(any(feature = "v1_16", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_16")))] - pub fn get_trickmode_interval(&self) -> ::ClockTime { + pub fn get_trickmode_interval(&self) -> crate::ClockTime { unsafe { let mut trickmode_interval = mem::MaybeUninit::uninit(); - gst_sys::gst_event_parse_seek_trickmode_interval( + ffi::gst_event_parse_seek_trickmode_interval( self.as_mut_ptr(), trickmode_interval.as_mut_ptr(), ); @@ -909,12 +909,12 @@ impl<'a> Seek<'a> { declare_concrete_event!(Navigation); impl<'a> Navigation<'a> { #[allow(clippy::new_ret_no_self)] - pub fn new(structure: ::Structure) -> Event { + pub fn new(structure: crate::Structure) -> Event { skip_assert_initialized!(); Self::builder(structure).build() } - pub fn builder(structure: ::Structure) -> NavigationBuilder<'a> { + pub fn builder(structure: crate::Structure) -> NavigationBuilder<'a> { assert_initialized_main_thread!(); NavigationBuilder::new(structure) } @@ -923,21 +923,21 @@ impl<'a> Navigation<'a> { declare_concrete_event!(Latency); impl<'a> Latency<'a> { #[allow(clippy::new_ret_no_self)] - pub fn new(latency: ::ClockTime) -> Event { + pub fn new(latency: crate::ClockTime) -> Event { skip_assert_initialized!(); Self::builder(latency).build() } - pub fn builder(latency: ::ClockTime) -> LatencyBuilder<'a> { + pub fn builder(latency: crate::ClockTime) -> LatencyBuilder<'a> { assert_initialized_main_thread!(); LatencyBuilder::new(latency) } - pub fn get_latency(&self) -> ::ClockTime { + pub fn get_latency(&self) -> crate::ClockTime { unsafe { let mut latency = mem::MaybeUninit::uninit(); - gst_sys::gst_event_parse_latency(self.as_mut_ptr(), latency.as_mut_ptr()); + ffi::gst_event_parse_latency(self.as_mut_ptr(), latency.as_mut_ptr()); from_glib(latency.assume_init()) } @@ -975,7 +975,7 @@ impl<'a> Step<'a> { let mut flush = mem::MaybeUninit::uninit(); let mut intermediate = mem::MaybeUninit::uninit(); - gst_sys::gst_event_parse_step( + ffi::gst_event_parse_step( self.as_mut_ptr(), fmt.as_mut_ptr(), amount.as_mut_ptr(), @@ -1028,7 +1028,7 @@ impl<'a> TocSelect<'a> { unsafe { let mut uid = ptr::null_mut(); - gst_sys::gst_event_parse_toc_select(self.as_mut_ptr(), &mut uid); + ffi::gst_event_parse_toc_select(self.as_mut_ptr(), &mut uid); CStr::from_ptr(uid).to_str().unwrap() } @@ -1058,7 +1058,7 @@ impl<'a> SelectStreams<'a> { unsafe { let mut streams = ptr::null_mut(); - gst_sys::gst_event_parse_select_streams(self.as_mut_ptr(), &mut streams); + ffi::gst_event_parse_select_streams(self.as_mut_ptr(), &mut streams); FromGlibPtrContainer::from_glib_full(streams) } @@ -1068,12 +1068,12 @@ impl<'a> SelectStreams<'a> { declare_concrete_event!(CustomUpstream); impl<'a> CustomUpstream<'a> { #[allow(clippy::new_ret_no_self)] - pub fn new(structure: ::Structure) -> Event { + pub fn new(structure: crate::Structure) -> Event { skip_assert_initialized!(); Self::builder(structure).build() } - pub fn builder(structure: ::Structure) -> CustomUpstreamBuilder<'a> { + pub fn builder(structure: crate::Structure) -> CustomUpstreamBuilder<'a> { assert_initialized_main_thread!(); CustomUpstreamBuilder::new(structure) } @@ -1082,12 +1082,12 @@ impl<'a> CustomUpstream<'a> { declare_concrete_event!(CustomDownstream); impl<'a> CustomDownstream<'a> { #[allow(clippy::new_ret_no_self)] - pub fn new(structure: ::Structure) -> Event { + pub fn new(structure: crate::Structure) -> Event { skip_assert_initialized!(); Self::builder(structure).build() } - pub fn builder(structure: ::Structure) -> CustomDownstreamBuilder<'a> { + pub fn builder(structure: crate::Structure) -> CustomDownstreamBuilder<'a> { assert_initialized_main_thread!(); CustomDownstreamBuilder::new(structure) } @@ -1096,12 +1096,12 @@ impl<'a> CustomDownstream<'a> { declare_concrete_event!(CustomDownstreamOob); impl<'a> CustomDownstreamOob<'a> { #[allow(clippy::new_ret_no_self)] - pub fn new(structure: ::Structure) -> Event { + pub fn new(structure: crate::Structure) -> Event { skip_assert_initialized!(); Self::builder(structure).build() } - pub fn builder(structure: ::Structure) -> CustomDownstreamOobBuilder<'a> { + pub fn builder(structure: crate::Structure) -> CustomDownstreamOobBuilder<'a> { assert_initialized_main_thread!(); CustomDownstreamOobBuilder::new(structure) } @@ -1110,12 +1110,12 @@ impl<'a> CustomDownstreamOob<'a> { declare_concrete_event!(CustomDownstreamSticky); impl<'a> CustomDownstreamSticky<'a> { #[allow(clippy::new_ret_no_self)] - pub fn new(structure: ::Structure) -> Event { + pub fn new(structure: crate::Structure) -> Event { skip_assert_initialized!(); Self::builder(structure).build() } - pub fn builder(structure: ::Structure) -> CustomDownstreamStickyBuilder<'a> { + pub fn builder(structure: crate::Structure) -> CustomDownstreamStickyBuilder<'a> { assert_initialized_main_thread!(); CustomDownstreamStickyBuilder::new(structure) } @@ -1124,12 +1124,12 @@ impl<'a> CustomDownstreamSticky<'a> { declare_concrete_event!(CustomBoth); impl<'a> CustomBoth<'a> { #[allow(clippy::new_ret_no_self)] - pub fn new(structure: ::Structure) -> Event { + pub fn new(structure: crate::Structure) -> Event { skip_assert_initialized!(); Self::builder(structure).build() } - pub fn builder(structure: ::Structure) -> CustomBothBuilder<'a> { + pub fn builder(structure: crate::Structure) -> CustomBothBuilder<'a> { assert_initialized_main_thread!(); CustomBothBuilder::new(structure) } @@ -1138,12 +1138,12 @@ impl<'a> CustomBoth<'a> { declare_concrete_event!(CustomBothOob); impl<'a> CustomBothOob<'a> { #[allow(clippy::new_ret_no_self)] - pub fn new(structure: ::Structure) -> Event { + pub fn new(structure: crate::Structure) -> Event { skip_assert_initialized!(); Self::builder(structure).build() } - pub fn builder(structure: ::Structure) -> CustomBothOobBuilder<'a> { + pub fn builder(structure: crate::Structure) -> CustomBothOobBuilder<'a> { assert_initialized_main_thread!(); CustomBothOobBuilder::new(structure) } @@ -1222,17 +1222,17 @@ macro_rules! event_builder_generic_impl { unsafe { let event = $new_fn(&mut self); if let Some(seqnum) = self.builder.seqnum { - gst_sys::gst_event_set_seqnum(event, seqnum.0.get()); + ffi::gst_event_set_seqnum(event, seqnum.0.get()); } if let Some(running_time_offset) = self.builder.running_time_offset { - gst_sys::gst_event_set_running_time_offset(event, running_time_offset); + ffi::gst_event_set_running_time_offset(event, running_time_offset); } if !self.builder.other_fields.is_empty() { - let s = StructureRef::from_glib_borrow_mut( - gst_sys::gst_event_writable_structure(event), - ); + let s = StructureRef::from_glib_borrow_mut(ffi::gst_event_writable_structure( + event, + )); for (k, v) in self.builder.other_fields { s.set_value(k, v.to_send_value()); @@ -1257,7 +1257,7 @@ impl<'a> FlushStartBuilder<'a> { } } - event_builder_generic_impl!(|_| gst_sys::gst_event_new_flush_start()); + event_builder_generic_impl!(|_| ffi::gst_event_new_flush_start()); } pub struct FlushStopBuilder<'a> { @@ -1273,19 +1273,17 @@ impl<'a> FlushStopBuilder<'a> { } } - event_builder_generic_impl!(|s: &Self| gst_sys::gst_event_new_flush_stop( - s.reset_time.to_glib() - )); + event_builder_generic_impl!(|s: &Self| ffi::gst_event_new_flush_stop(s.reset_time.to_glib())); } pub struct StreamStartBuilder<'a> { builder: EventBuilder<'a>, stream_id: &'a str, - flags: Option<::StreamFlags>, + flags: Option, group_id: Option, #[cfg(any(feature = "v1_10", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))] - stream: Option<::Stream>, + stream: Option, } impl<'a> StreamStartBuilder<'a> { @@ -1302,7 +1300,7 @@ impl<'a> StreamStartBuilder<'a> { } } - pub fn flags(self, flags: ::StreamFlags) -> Self { + pub fn flags(self, flags: crate::StreamFlags) -> Self { Self { flags: Some(flags), ..self @@ -1318,7 +1316,7 @@ impl<'a> StreamStartBuilder<'a> { #[cfg(any(feature = "v1_10", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))] - pub fn stream(self, stream: ::Stream) -> Self { + pub fn stream(self, stream: crate::Stream) -> Self { Self { stream: Some(stream), ..self @@ -1326,17 +1324,17 @@ impl<'a> StreamStartBuilder<'a> { } event_builder_generic_impl!(|s: &Self| { - let ev = gst_sys::gst_event_new_stream_start(s.stream_id.to_glib_none().0); + let ev = ffi::gst_event_new_stream_start(s.stream_id.to_glib_none().0); if let Some(flags) = s.flags { - gst_sys::gst_event_set_stream_flags(ev, flags.to_glib()); + ffi::gst_event_set_stream_flags(ev, flags.to_glib()); } if let Some(group_id) = s.group_id { - gst_sys::gst_event_set_group_id(ev, group_id.0.get()); + ffi::gst_event_set_group_id(ev, group_id.0.get()); } #[cfg(any(feature = "v1_10", feature = "dox"))] if let Some(ref stream) = s.stream { - gst_sys::gst_event_set_stream(ev, stream.to_glib_none().0); + ffi::gst_event_set_stream(ev, stream.to_glib_none().0); } ev @@ -1345,11 +1343,11 @@ impl<'a> StreamStartBuilder<'a> { pub struct CapsBuilder<'a> { builder: EventBuilder<'a>, - caps: &'a ::Caps, + caps: &'a crate::Caps, } impl<'a> CapsBuilder<'a> { - fn new(caps: &'a ::Caps) -> Self { + fn new(caps: &'a crate::Caps) -> Self { skip_assert_initialized!(); Self { builder: EventBuilder::new(), @@ -1357,16 +1355,16 @@ impl<'a> CapsBuilder<'a> { } } - event_builder_generic_impl!(|s: &Self| gst_sys::gst_event_new_caps(s.caps.as_mut_ptr())); + event_builder_generic_impl!(|s: &Self| ffi::gst_event_new_caps(s.caps.as_mut_ptr())); } pub struct SegmentBuilder<'a> { builder: EventBuilder<'a>, - segment: &'a ::Segment, + segment: &'a crate::Segment, } impl<'a> SegmentBuilder<'a> { - fn new(segment: &'a ::Segment) -> Self { + fn new(segment: &'a crate::Segment) -> Self { skip_assert_initialized!(); Self { builder: EventBuilder::new(), @@ -1374,22 +1372,20 @@ impl<'a> SegmentBuilder<'a> { } } - event_builder_generic_impl!(|s: &Self| gst_sys::gst_event_new_segment( - s.segment.to_glib_none().0 - )); + event_builder_generic_impl!(|s: &Self| ffi::gst_event_new_segment(s.segment.to_glib_none().0)); } #[cfg(any(feature = "v1_10", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))] pub struct StreamCollectionBuilder<'a> { builder: EventBuilder<'a>, - stream_collection: &'a ::StreamCollection, + stream_collection: &'a crate::StreamCollection, } #[cfg(any(feature = "v1_10", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))] impl<'a> StreamCollectionBuilder<'a> { - fn new(stream_collection: &'a ::StreamCollection) -> Self { + fn new(stream_collection: &'a crate::StreamCollection) -> Self { skip_assert_initialized!(); Self { builder: EventBuilder::new(), @@ -1397,18 +1393,18 @@ impl<'a> StreamCollectionBuilder<'a> { } } - event_builder_generic_impl!(|s: &Self| gst_sys::gst_event_new_stream_collection( + event_builder_generic_impl!(|s: &Self| ffi::gst_event_new_stream_collection( s.stream_collection.to_glib_none().0 )); } pub struct TagBuilder<'a> { builder: EventBuilder<'a>, - tags: Option<::TagList>, + tags: Option, } impl<'a> TagBuilder<'a> { - fn new(tags: ::TagList) -> Self { + fn new(tags: crate::TagList) -> Self { skip_assert_initialized!(); Self { builder: EventBuilder::new(), @@ -1418,7 +1414,7 @@ impl<'a> TagBuilder<'a> { event_builder_generic_impl!(|s: &mut Self| { let tags = s.tags.take().unwrap(); - gst_sys::gst_event_new_tag(tags.into_ptr()) + ffi::gst_event_new_tag(tags.into_ptr()) }); } @@ -1426,36 +1422,36 @@ pub struct BufferSizeBuilder<'a> { builder: EventBuilder<'a>, minsize: GenericFormattedValue, maxsize: GenericFormattedValue, - async: bool, + r#async: bool, } impl<'a> BufferSizeBuilder<'a> { - fn new(minsize: GenericFormattedValue, maxsize: GenericFormattedValue, async: bool) -> Self { + fn new(minsize: GenericFormattedValue, maxsize: GenericFormattedValue, r#async: bool) -> Self { skip_assert_initialized!(); Self { builder: EventBuilder::new(), minsize, maxsize, - async, + r#async, } } - event_builder_generic_impl!(|s: &Self| gst_sys::gst_event_new_buffer_size( + event_builder_generic_impl!(|s: &Self| ffi::gst_event_new_buffer_size( s.minsize.get_format().to_glib(), s.minsize.get_value(), s.maxsize.get_value(), - s.async.to_glib(), + s.r#async.to_glib(), )); } pub struct SinkMessageBuilder<'a> { builder: EventBuilder<'a>, name: &'a str, - msg: &'a ::Message, + msg: &'a crate::Message, } impl<'a> SinkMessageBuilder<'a> { - fn new(name: &'a str, msg: &'a ::Message) -> Self { + fn new(name: &'a str, msg: &'a crate::Message) -> Self { skip_assert_initialized!(); Self { builder: EventBuilder::new(), @@ -1464,7 +1460,7 @@ impl<'a> SinkMessageBuilder<'a> { } } - event_builder_generic_impl!(|s: &Self| gst_sys::gst_event_new_sink_message( + event_builder_generic_impl!(|s: &Self| ffi::gst_event_new_sink_message( s.name.to_glib_none().0, s.msg.as_mut_ptr() )); @@ -1488,7 +1484,7 @@ impl<'a> StreamGroupDoneBuilder<'a> { } } - event_builder_generic_impl!(|s: &Self| gst_sys::gst_event_new_stream_group_done( + event_builder_generic_impl!(|s: &Self| ffi::gst_event_new_stream_group_done( s.group_id.0.get() )); } @@ -1505,17 +1501,17 @@ impl<'a> EosBuilder<'a> { } } - event_builder_generic_impl!(|_| gst_sys::gst_event_new_eos()); + event_builder_generic_impl!(|_| ffi::gst_event_new_eos()); } pub struct TocBuilder<'a> { builder: EventBuilder<'a>, - toc: &'a ::Toc, + toc: &'a crate::Toc, updated: bool, } impl<'a> TocBuilder<'a> { - fn new(toc: &'a ::Toc, updated: bool) -> Self { + fn new(toc: &'a crate::Toc, updated: bool) -> Self { skip_assert_initialized!(); Self { builder: EventBuilder::new(), @@ -1524,7 +1520,7 @@ impl<'a> TocBuilder<'a> { } } - event_builder_generic_impl!(|s: &Self| gst_sys::gst_event_new_toc( + event_builder_generic_impl!(|s: &Self| ffi::gst_event_new_toc( s.toc.to_glib_none().0, s.updated.to_glib() )); @@ -1533,12 +1529,12 @@ impl<'a> TocBuilder<'a> { pub struct ProtectionBuilder<'a> { builder: EventBuilder<'a>, system_id: &'a str, - data: &'a ::Buffer, + data: &'a crate::Buffer, origin: Option<&'a str>, } impl<'a> ProtectionBuilder<'a> { - fn new(system_id: &'a str, data: &'a ::Buffer) -> Self { + fn new(system_id: &'a str, data: &'a crate::Buffer) -> Self { skip_assert_initialized!(); Self { builder: EventBuilder::new(), @@ -1555,7 +1551,7 @@ impl<'a> ProtectionBuilder<'a> { } } - event_builder_generic_impl!(|s: &Self| gst_sys::gst_event_new_protection( + event_builder_generic_impl!(|s: &Self| ffi::gst_event_new_protection( s.system_id.to_glib_none().0, s.data.as_mut_ptr(), s.origin.to_glib_none().0, @@ -1576,7 +1572,7 @@ impl<'a> SegmentDoneBuilder<'a> { } } - event_builder_generic_impl!(|s: &Self| gst_sys::gst_event_new_segment_done( + event_builder_generic_impl!(|s: &Self| ffi::gst_event_new_segment_done( s.position.get_format().to_glib(), s.position.get_value() )); @@ -1584,12 +1580,12 @@ impl<'a> SegmentDoneBuilder<'a> { pub struct GapBuilder<'a> { builder: EventBuilder<'a>, - timestamp: ::ClockTime, - duration: ::ClockTime, + timestamp: crate::ClockTime, + duration: crate::ClockTime, } impl<'a> GapBuilder<'a> { - fn new(timestamp: ::ClockTime, duration: ::ClockTime) -> Self { + fn new(timestamp: crate::ClockTime, duration: crate::ClockTime) -> Self { skip_assert_initialized!(); Self { builder: EventBuilder::new(), @@ -1598,7 +1594,7 @@ impl<'a> GapBuilder<'a> { } } - event_builder_generic_impl!(|s: &Self| gst_sys::gst_event_new_gap( + event_builder_generic_impl!(|s: &Self| ffi::gst_event_new_gap( s.timestamp.to_glib(), s.duration.to_glib() )); @@ -1606,14 +1602,14 @@ impl<'a> GapBuilder<'a> { pub struct QosBuilder<'a> { builder: EventBuilder<'a>, - type_: ::QOSType, + type_: crate::QOSType, proportion: f64, diff: i64, - timestamp: ::ClockTime, + timestamp: crate::ClockTime, } impl<'a> QosBuilder<'a> { - fn new(type_: ::QOSType, proportion: f64, diff: i64, timestamp: ::ClockTime) -> Self { + fn new(type_: crate::QOSType, proportion: f64, diff: i64, timestamp: crate::ClockTime) -> Self { skip_assert_initialized!(); Self { builder: EventBuilder::new(), @@ -1624,7 +1620,7 @@ impl<'a> QosBuilder<'a> { } } - event_builder_generic_impl!(|s: &Self| gst_sys::gst_event_new_qos( + event_builder_generic_impl!(|s: &Self| ffi::gst_event_new_qos( s.type_.to_glib(), s.proportion, s.diff, @@ -1635,22 +1631,22 @@ impl<'a> QosBuilder<'a> { pub struct SeekBuilder<'a> { builder: EventBuilder<'a>, rate: f64, - flags: ::SeekFlags, - start_type: ::SeekType, + flags: crate::SeekFlags, + start_type: crate::SeekType, start: GenericFormattedValue, - stop_type: ::SeekType, + stop_type: crate::SeekType, stop: GenericFormattedValue, #[allow(unused)] - trickmode_interval: Option<::ClockTime>, + trickmode_interval: Option, } impl<'a> SeekBuilder<'a> { fn new( rate: f64, - flags: ::SeekFlags, - start_type: ::SeekType, + flags: crate::SeekFlags, + start_type: crate::SeekType, start: GenericFormattedValue, - stop_type: ::SeekType, + stop_type: crate::SeekType, stop: GenericFormattedValue, ) -> Self { skip_assert_initialized!(); @@ -1669,7 +1665,7 @@ impl<'a> SeekBuilder<'a> { event_builder_generic_impl!(|s: &Self| { #[allow(clippy::let_and_return)] { - let ev = gst_sys::gst_event_new_seek( + let ev = ffi::gst_event_new_seek( s.rate, s.start.get_format().to_glib(), s.flags.to_glib(), @@ -1681,7 +1677,7 @@ impl<'a> SeekBuilder<'a> { #[cfg(any(feature = "v1_16", feature = "dox"))] if let Some(trickmode_interval) = s.trickmode_interval { - gst_sys::gst_event_set_seek_trickmode_interval(ev, trickmode_interval.to_glib()); + ffi::gst_event_set_seek_trickmode_interval(ev, trickmode_interval.to_glib()); } ev @@ -1705,17 +1701,17 @@ impl<'a> NavigationBuilder<'a> { event_builder_generic_impl!(|s: &mut Self| { let structure = s.structure.take().unwrap(); - gst_sys::gst_event_new_navigation(structure.into_ptr()) + ffi::gst_event_new_navigation(structure.into_ptr()) }); } pub struct LatencyBuilder<'a> { builder: EventBuilder<'a>, - latency: ::ClockTime, + latency: crate::ClockTime, } impl<'a> LatencyBuilder<'a> { - fn new(latency: ::ClockTime) -> Self { + fn new(latency: crate::ClockTime) -> Self { skip_assert_initialized!(); Self { builder: EventBuilder::new(), @@ -1723,7 +1719,7 @@ impl<'a> LatencyBuilder<'a> { } } - event_builder_generic_impl!(|s: &Self| gst_sys::gst_event_new_latency(s.latency.to_glib())); + event_builder_generic_impl!(|s: &Self| ffi::gst_event_new_latency(s.latency.to_glib())); } pub struct StepBuilder<'a> { @@ -1746,7 +1742,7 @@ impl<'a> StepBuilder<'a> { } } - event_builder_generic_impl!(|s: &Self| gst_sys::gst_event_new_step( + event_builder_generic_impl!(|s: &Self| ffi::gst_event_new_step( s.amount.get_format().to_glib(), s.amount.get_value() as u64, s.rate, @@ -1767,7 +1763,7 @@ impl<'a> ReconfigureBuilder<'a> { } } - event_builder_generic_impl!(|_| gst_sys::gst_event_new_reconfigure()); + event_builder_generic_impl!(|_| ffi::gst_event_new_reconfigure()); } pub struct TocSelectBuilder<'a> { @@ -1784,9 +1780,7 @@ impl<'a> TocSelectBuilder<'a> { } } - event_builder_generic_impl!(|s: &Self| gst_sys::gst_event_new_toc_select( - s.uid.to_glib_none().0 - )); + event_builder_generic_impl!(|s: &Self| ffi::gst_event_new_toc_select(s.uid.to_glib_none().0)); } #[cfg(any(feature = "v1_10", feature = "dox"))] @@ -1807,7 +1801,7 @@ impl<'a> SelectStreamsBuilder<'a> { } } - event_builder_generic_impl!(|s: &Self| gst_sys::gst_event_new_select_streams( + event_builder_generic_impl!(|s: &Self| ffi::gst_event_new_select_streams( s.streams.to_glib_full() )); } @@ -1828,7 +1822,7 @@ impl<'a> CustomUpstreamBuilder<'a> { event_builder_generic_impl!(|s: &mut Self| { let structure = s.structure.take().unwrap(); - gst_sys::gst_event_new_custom(gst_sys::GST_EVENT_CUSTOM_UPSTREAM, structure.into_ptr()) + ffi::gst_event_new_custom(ffi::GST_EVENT_CUSTOM_UPSTREAM, structure.into_ptr()) }); } @@ -1848,7 +1842,7 @@ impl<'a> CustomDownstreamBuilder<'a> { event_builder_generic_impl!(|s: &mut Self| { let structure = s.structure.take().unwrap(); - gst_sys::gst_event_new_custom(gst_sys::GST_EVENT_CUSTOM_DOWNSTREAM, structure.into_ptr()) + ffi::gst_event_new_custom(ffi::GST_EVENT_CUSTOM_DOWNSTREAM, structure.into_ptr()) }); } @@ -1868,10 +1862,7 @@ impl<'a> CustomDownstreamOobBuilder<'a> { event_builder_generic_impl!(|s: &mut Self| { let structure = s.structure.take().unwrap(); - gst_sys::gst_event_new_custom( - gst_sys::GST_EVENT_CUSTOM_DOWNSTREAM_OOB, - structure.into_ptr(), - ) + ffi::gst_event_new_custom(ffi::GST_EVENT_CUSTOM_DOWNSTREAM_OOB, structure.into_ptr()) }); } @@ -1891,8 +1882,8 @@ impl<'a> CustomDownstreamStickyBuilder<'a> { event_builder_generic_impl!(|s: &mut Self| { let structure = s.structure.take().unwrap(); - gst_sys::gst_event_new_custom( - gst_sys::GST_EVENT_CUSTOM_DOWNSTREAM_STICKY, + ffi::gst_event_new_custom( + ffi::GST_EVENT_CUSTOM_DOWNSTREAM_STICKY, structure.into_ptr(), ) }); @@ -1914,7 +1905,7 @@ impl<'a> CustomBothBuilder<'a> { event_builder_generic_impl!(|s: &mut Self| { let structure = s.structure.take().unwrap(); - gst_sys::gst_event_new_custom(gst_sys::GST_EVENT_CUSTOM_BOTH, structure.into_ptr()) + ffi::gst_event_new_custom(ffi::GST_EVENT_CUSTOM_BOTH, structure.into_ptr()) }); } @@ -1934,7 +1925,7 @@ impl<'a> CustomBothOobBuilder<'a> { event_builder_generic_impl!(|s: &mut Self| { let structure = s.structure.take().unwrap(); - gst_sys::gst_event_new_custom(gst_sys::GST_EVENT_CUSTOM_BOTH_OOB, structure.into_ptr()) + ffi::gst_event_new_custom(ffi::GST_EVENT_CUSTOM_BOTH_OOB, structure.into_ptr()) }); } @@ -1944,7 +1935,7 @@ mod tests { #[test] fn test_simple() { - ::init().unwrap(); + crate::init().unwrap(); // Event without arguments let flush_start_evt = FlushStart::new(); @@ -1987,7 +1978,7 @@ mod tests { #[test] fn test_get_structure_mut() { - ::init().unwrap(); + crate::init().unwrap(); let mut flush_start_evt = FlushStart::new(); diff --git a/gstreamer/src/format.rs b/gstreamer/src/format.rs index cea74a9ab..e99495850 100644 --- a/gstreamer/src/format.rs +++ b/gstreamer/src/format.rs @@ -6,17 +6,17 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use crate::ClockTime; +use crate::Format; use muldiv::MulDiv; use std::convert::TryFrom; use std::ops; use thiserror::Error; -use ClockTime; -use Format; use std::cmp; #[derive(PartialEq, Eq, Hash, Clone, Copy, Debug)] -#[cfg_attr(feature = "ser_de", derive(Serialize, Deserialize))] +#[cfg_attr(feature = "ser_de", derive(serde::Serialize, serde::Deserialize))] pub enum GenericFormattedValue { Undefined(Undefined), Default(Default), @@ -615,7 +615,7 @@ impl FormattedValue for Percent { unsafe fn from_raw(format: Format, value: i64) -> Self { debug_assert_eq!(format, Format::Percent); - if value < 0 || value > gst_sys::GST_FORMAT_PERCENT_MAX { + if value < 0 || value > ffi::GST_FORMAT_PERCENT_MAX { Percent(None) } else { Percent(Some(value as u32)) @@ -688,7 +688,7 @@ impl TryFrom for Percent { Err(TryPercentFromFloatError(())) } else { Ok(Percent(Some( - (v * gst_sys::GST_FORMAT_PERCENT_SCALE as f64).round() as u32, + (v * ffi::GST_FORMAT_PERCENT_SCALE as f64).round() as u32, ))) } } @@ -703,7 +703,7 @@ impl TryFrom for Percent { Err(TryPercentFromFloatError(())) } else { Ok(Percent(Some( - (v * gst_sys::GST_FORMAT_PERCENT_SCALE as f32).round() as u32, + (v * ffi::GST_FORMAT_PERCENT_SCALE as f32).round() as u32, ))) } } @@ -713,9 +713,9 @@ impl TryFrom for Percent { mod tests { #[test] fn test_clock_time() { - ::init().unwrap(); + crate::init().unwrap(); - let t1 = ::SECOND; + let t1 = crate::SECOND; let t2 = 2 * t1; let t3 = &t1 * 2; let mut t4 = t2 + t3; @@ -723,7 +723,7 @@ mod tests { assert_eq!(t4.nanoseconds(), Some(5_000_000_000)); - let t5 = t4 - 6 * ::SECOND; + let t5 = t4 - 6 * crate::SECOND; assert!(t5.is_none()); } } diff --git a/gstreamer/src/format_serde.rs b/gstreamer/src/format_serde.rs index 8f57c3b7d..ae3e18d78 100644 --- a/gstreamer/src/format_serde.rs +++ b/gstreamer/src/format_serde.rs @@ -9,7 +9,7 @@ use serde::de::{Deserialize, Deserializer}; use serde::ser::{Serialize, Serializer}; -use format::{Buffers, Bytes, Default, Percent, Undefined}; +use crate::format::{Buffers, Bytes, Default, Percent, Undefined}; // Manual implementation for some types that would otherwise yield representations such as: // "Default((Some(42)))" @@ -63,18 +63,15 @@ impl<'de> Deserialize<'de> for Percent { #[cfg(test)] mod tests { - extern crate ron; - extern crate serde_json; - - use format::{Buffers, Bytes, Default, Percent, Undefined}; + use crate::format::{Buffers, Bytes, Default, Percent, Undefined}; + use crate::ClockTime; + use crate::Format; + use crate::GenericFormattedValue; use std::convert::TryFrom; - use ClockTime; - use Format; - use GenericFormattedValue; #[test] fn test_serialize() { - ::init().unwrap(); + crate::init().unwrap(); let mut pretty_config = ron::ser::PrettyConfig::default(); pretty_config.new_line = "".to_string(); @@ -136,7 +133,7 @@ mod tests { #[test] fn test_deserialize() { - ::init().unwrap(); + crate::init().unwrap(); let value_ron = "Default(Some(42))"; let value_de: GenericFormattedValue = ron::de::from_str(value_ron).unwrap(); @@ -157,7 +154,7 @@ mod tests { #[test] fn test_serde_roundtrip() { - ::init().unwrap(); + crate::init().unwrap(); macro_rules! test_roundrip( ($value:expr) => { diff --git a/gstreamer/src/functions.rs b/gstreamer/src/functions.rs index f1ea01dae..8541d8a68 100644 --- a/gstreamer/src/functions.rs +++ b/gstreamer/src/functions.rs @@ -6,18 +6,16 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use auto::functions::parse_bin_from_description; -use glib; +use crate::auto::functions::parse_bin_from_description; use glib::translate::*; use glib::Cast; -use gst_sys; use std::ptr; -use Bin; -use Element; -use Object; -use ParseContext; -use ParseFlags; +use crate::Bin; +use crate::Element; +use crate::Object; +use crate::ParseContext; +use crate::ParseFlags; pub fn parse_bin_from_description_with_name( bin_description: &str, @@ -29,7 +27,7 @@ pub fn parse_bin_from_description_with_name( if !bin_name.is_empty() { let obj = bin.clone().upcast::(); unsafe { - gst_sys::gst_object_set_name(obj.to_glib_none().0, bin_name.to_glib_none().0); + ffi::gst_object_set_name(obj.to_glib_none().0, bin_name.to_glib_none().0); } } Ok(bin) @@ -44,7 +42,7 @@ pub fn parse_bin_from_description_full( assert_initialized_main_thread!(); unsafe { let mut error = ptr::null_mut(); - let ret = gst_sys::gst_parse_bin_from_description_full( + let ret = ffi::gst_parse_bin_from_description_full( bin_description.to_glib_none().0, ghost_unlinked_pads.to_glib(), context.to_glib_none_mut().0, @@ -72,7 +70,7 @@ pub fn parse_bin_from_description_with_name_full( if !bin_name.is_empty() { let obj = bin.clone().upcast::(); unsafe { - gst_sys::gst_object_set_name(obj.to_glib_none().0, bin_name.to_glib_none().0); + ffi::gst_object_set_name(obj.to_glib_none().0, bin_name.to_glib_none().0); } } Ok(bin) @@ -86,7 +84,7 @@ pub fn parse_launch_full( assert_initialized_main_thread!(); unsafe { let mut error = ptr::null_mut(); - let ret = gst_sys::gst_parse_launch_full( + let ret = ffi::gst_parse_launch_full( pipeline_description.to_glib_none().0, context.to_glib_none_mut().0, flags.to_glib(), @@ -108,7 +106,7 @@ pub fn parse_launchv_full( assert_initialized_main_thread!(); unsafe { let mut error = ptr::null_mut(); - let ret = gst_sys::gst_parse_launchv_full( + let ret = ffi::gst_parse_launchv_full( argv.to_glib_none().0, context.to_glib_none_mut().0, flags.to_glib(), @@ -147,7 +145,7 @@ pub fn calculate_linear_regression( let mut xbase = mem::MaybeUninit::uninit(); let mut r_squared = mem::MaybeUninit::uninit(); - let res = from_glib(gst_sys::gst_calculate_linear_regression( + let res = from_glib(ffi::gst_calculate_linear_regression( xy.as_ptr() as *const u64, temp.map(|temp| temp.as_mut_ptr() as *mut u64) .unwrap_or(ptr::null_mut()), @@ -174,13 +172,13 @@ pub fn calculate_linear_regression( #[cfg(any(feature = "v1_18", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))] -pub fn type_is_plugin_api(type_: glib::types::Type) -> Option<::PluginAPIFlags> { +pub fn type_is_plugin_api(type_: glib::types::Type) -> Option { assert_initialized_main_thread!(); unsafe { use std::mem; let mut flags = mem::MaybeUninit::uninit(); - let ret = from_glib(gst_sys::gst_type_is_plugin_api( + let ret = from_glib(ffi::gst_type_is_plugin_api( type_.to_glib(), flags.as_mut_ptr(), )); @@ -196,12 +194,12 @@ pub fn type_is_plugin_api(type_: glib::types::Type) -> Option<::PluginAPIFlags> #[cfg(test)] mod tests { use super::*; - use prelude::*; + use crate::prelude::*; #[cfg(feature = "v1_12")] #[test] fn test_calculate_linear_regression() { - ::init().unwrap(); + crate::init().unwrap(); let values = [(0, 0), (1, 1), (2, 2), (3, 3)]; @@ -216,7 +214,7 @@ mod tests { #[test] fn test_parse_bin_from_description_with_name() { - ::init().unwrap(); + crate::init().unwrap(); let bin = parse_bin_from_description_with_name("fakesrc ! fakesink", false, "all_fake").unwrap(); diff --git a/gstreamer/src/ghost_pad.rs b/gstreamer/src/ghost_pad.rs index 22ef16170..c2912eadf 100644 --- a/gstreamer/src/ghost_pad.rs +++ b/gstreamer/src/ghost_pad.rs @@ -6,22 +6,21 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use crate::FlowError; +use crate::FlowSuccess; +use crate::GhostPad; +use crate::LoggableError; +use crate::Object; +use crate::Pad; +use crate::PadBuilder; +use crate::PadExt; +use crate::PadExtManual; +use crate::PadFlags; +use crate::PadGetRangeSuccess; +use crate::PadMode; +use crate::StaticPadTemplate; use glib::prelude::*; use glib::translate::*; -use gst_sys; -use FlowError; -use FlowSuccess; -use GhostPad; -use LoggableError; -use Object; -use Pad; -use PadBuilder; -use PadExt; -use PadExtManual; -use PadFlags; -use PadGetRangeSuccess; -use PadMode; -use StaticPadTemplate; impl GhostPad { pub fn activate_mode_default, Q: IsA>( @@ -32,9 +31,9 @@ impl GhostPad { ) -> Result<(), glib::BoolError> { skip_assert_initialized!(); unsafe { - glib_result_from_gboolean!( - gst_sys::gst_ghost_pad_activate_mode_default( - pad.to_glib_none().0 as *mut gst_sys::GstPad, + glib::glib_result_from_gboolean!( + ffi::gst_ghost_pad_activate_mode_default( + pad.to_glib_none().0 as *mut ffi::GstPad, parent.map(|p| p.as_ref()).to_glib_none().0, mode.to_glib(), active.to_glib(), @@ -52,9 +51,9 @@ impl GhostPad { ) -> Result<(), glib::BoolError> { skip_assert_initialized!(); unsafe { - glib_result_from_gboolean!( - gst_sys::gst_ghost_pad_internal_activate_mode_default( - pad.to_glib_none().0 as *mut gst_sys::GstPad, + glib::glib_result_from_gboolean!( + ffi::gst_ghost_pad_internal_activate_mode_default( + pad.to_glib_none().0 as *mut ffi::GstPad, parent.map(|p| p.as_ref()).to_glib_none().0, mode.to_glib(), active.to_glib(), @@ -67,12 +66,12 @@ impl GhostPad { } } - pub fn new(name: Option<&str>, direction: ::PadDirection) -> Self { + pub fn new(name: Option<&str>, direction: crate::PadDirection) -> Self { skip_assert_initialized!(); Self::builder(name, direction).build() } - pub fn builder(name: Option<&str>, direction: ::PadDirection) -> PadBuilder { + pub fn builder(name: Option<&str>, direction: crate::PadDirection) -> PadBuilder { skip_assert_initialized!(); PadBuilder::new(name, direction) } @@ -90,12 +89,15 @@ impl GhostPad { PadBuilder::from_static_template(templ, name) } - pub fn from_template(templ: &::PadTemplate, name: Option<&str>) -> Self { + pub fn from_template(templ: &crate::PadTemplate, name: Option<&str>) -> Self { skip_assert_initialized!(); Self::builder_with_template(templ, name).build() } - pub fn builder_with_template(templ: &::PadTemplate, name: Option<&str>) -> PadBuilder { + pub fn builder_with_template( + templ: &crate::PadTemplate, + name: Option<&str>, + ) -> PadBuilder { skip_assert_initialized!(); PadBuilder::from_template(templ, name) } @@ -109,14 +111,14 @@ impl GhostPad { } pub fn from_template_with_target>( - templ: &::PadTemplate, + templ: &crate::PadTemplate, name: Option<&str>, target: &P, ) -> Result { skip_assert_initialized!(); if target.get_direction() != templ.get_property_direction() { - return Err(glib_bool_error!( + return Err(glib::glib_bool_error!( "Template and target have different directions" )); } @@ -128,14 +130,17 @@ impl GhostPad { impl + IsA> PadBuilder { pub fn proxy_pad_activate_function(self, func: F) -> Self where - F: Fn(&::ProxyPad, Option<&::Object>) -> Result<(), LoggableError> + Send + Sync + 'static, + F: Fn(&crate::ProxyPad, Option<&crate::Object>) -> Result<(), LoggableError> + + Send + + Sync + + 'static, { - use ProxyPadExt; + use crate::ProxyPadExt; unsafe { let proxy = self .0 - .unsafe_cast_ref::<::ProxyPad>() + .unsafe_cast_ref::() .get_internal() .unwrap(); proxy.set_activate_function(func); @@ -146,17 +151,22 @@ impl + IsA> PadBuilder { pub fn proxy_pad_activatemode_function(self, func: F) -> Self where - F: Fn(&::ProxyPad, Option<&::Object>, ::PadMode, bool) -> Result<(), LoggableError> + F: Fn( + &crate::ProxyPad, + Option<&crate::Object>, + crate::PadMode, + bool, + ) -> Result<(), LoggableError> + Send + Sync + 'static, { - use ProxyPadExt; + use crate::ProxyPadExt; unsafe { let proxy = self .0 - .unsafe_cast_ref::<::ProxyPad>() + .unsafe_cast_ref::() .get_internal() .unwrap(); proxy.set_activatemode_function(func); @@ -167,17 +177,21 @@ impl + IsA> PadBuilder { pub fn proxy_pad_chain_function(self, func: F) -> Self where - F: Fn(&::ProxyPad, Option<&::Object>, ::Buffer) -> Result + F: Fn( + &crate::ProxyPad, + Option<&crate::Object>, + crate::Buffer, + ) -> Result + Send + Sync + 'static, { - use ProxyPadExt; + use crate::ProxyPadExt; unsafe { let proxy = self .0 - .unsafe_cast_ref::<::ProxyPad>() + .unsafe_cast_ref::() .get_internal() .unwrap(); proxy.set_chain_function(func); @@ -188,17 +202,21 @@ impl + IsA> PadBuilder { pub fn proxy_pad_chain_list_function(self, func: F) -> Self where - F: Fn(&::ProxyPad, Option<&::Object>, ::BufferList) -> Result + F: Fn( + &crate::ProxyPad, + Option<&crate::Object>, + crate::BufferList, + ) -> Result + Send + Sync + 'static, { - use ProxyPadExt; + use crate::ProxyPadExt; unsafe { let proxy = self .0 - .unsafe_cast_ref::<::ProxyPad>() + .unsafe_cast_ref::() .get_internal() .unwrap(); proxy.set_chain_list_function(func); @@ -209,14 +227,17 @@ impl + IsA> PadBuilder { pub fn proxy_pad_event_function(self, func: F) -> Self where - F: Fn(&::ProxyPad, Option<&::Object>, ::Event) -> bool + Send + Sync + 'static, + F: Fn(&crate::ProxyPad, Option<&crate::Object>, crate::Event) -> bool + + Send + + Sync + + 'static, { - use ProxyPadExt; + use crate::ProxyPadExt; unsafe { let proxy = self .0 - .unsafe_cast_ref::<::ProxyPad>() + .unsafe_cast_ref::() .get_internal() .unwrap(); proxy.set_event_function(func); @@ -227,17 +248,21 @@ impl + IsA> PadBuilder { pub fn proxy_pad_event_full_function(self, func: F) -> Self where - F: Fn(&::ProxyPad, Option<&::Object>, ::Event) -> Result + F: Fn( + &crate::ProxyPad, + Option<&crate::Object>, + crate::Event, + ) -> Result + Send + Sync + 'static, { - use ProxyPadExt; + use crate::ProxyPadExt; unsafe { let proxy = self .0 - .unsafe_cast_ref::<::ProxyPad>() + .unsafe_cast_ref::() .get_internal() .unwrap(); proxy.set_event_full_function(func); @@ -249,22 +274,22 @@ impl + IsA> PadBuilder { pub fn proxy_pad_getrange_function(self, func: F) -> Self where F: Fn( - &::ProxyPad, - Option<&::Object>, + &crate::ProxyPad, + Option<&crate::Object>, u64, - Option<&mut ::BufferRef>, + Option<&mut crate::BufferRef>, u32, - ) -> Result + ) -> Result + Send + Sync + 'static, { - use ProxyPadExt; + use crate::ProxyPadExt; unsafe { let proxy = self .0 - .unsafe_cast_ref::<::ProxyPad>() + .unsafe_cast_ref::() .get_internal() .unwrap(); proxy.set_getrange_function(func); @@ -275,14 +300,17 @@ impl + IsA> PadBuilder { pub fn proxy_pad_iterate_internal_links_function(self, func: F) -> Self where - F: Fn(&::ProxyPad, Option<&::Object>) -> ::Iterator + Send + Sync + 'static, + F: Fn(&crate::ProxyPad, Option<&crate::Object>) -> crate::Iterator + + Send + + Sync + + 'static, { - use ProxyPadExt; + use crate::ProxyPadExt; unsafe { let proxy = self .0 - .unsafe_cast_ref::<::ProxyPad>() + .unsafe_cast_ref::() .get_internal() .unwrap(); proxy.set_iterate_internal_links_function(func); @@ -293,17 +321,21 @@ impl + IsA> PadBuilder { pub fn proxy_pad_link_function(self, func: F) -> Self where - F: Fn(&::ProxyPad, Option<&::Object>, &Pad) -> Result<::PadLinkSuccess, ::PadLinkError> + F: Fn( + &crate::ProxyPad, + Option<&crate::Object>, + &Pad, + ) -> Result + Send + Sync + 'static, { - use ProxyPadExt; + use crate::ProxyPadExt; unsafe { let proxy = self .0 - .unsafe_cast_ref::<::ProxyPad>() + .unsafe_cast_ref::() .get_internal() .unwrap(); proxy.set_link_function(func); @@ -314,14 +346,17 @@ impl + IsA> PadBuilder { pub fn proxy_pad_query_function(self, func: F) -> Self where - F: Fn(&::ProxyPad, Option<&::Object>, &mut ::QueryRef) -> bool + Send + Sync + 'static, + F: Fn(&crate::ProxyPad, Option<&crate::Object>, &mut crate::QueryRef) -> bool + + Send + + Sync + + 'static, { - use ProxyPadExt; + use crate::ProxyPadExt; unsafe { let proxy = self .0 - .unsafe_cast_ref::<::ProxyPad>() + .unsafe_cast_ref::() .get_internal() .unwrap(); proxy.set_query_function(func); @@ -332,14 +367,14 @@ impl + IsA> PadBuilder { pub fn proxy_pad_unlink_function(self, func: F) -> Self where - F: Fn(&::ProxyPad, Option<&::Object>) + Send + Sync + 'static, + F: Fn(&crate::ProxyPad, Option<&crate::Object>) + Send + Sync + 'static, { - use ProxyPadExt; + use crate::ProxyPadExt; unsafe { let proxy = self .0 - .unsafe_cast_ref::<::ProxyPad>() + .unsafe_cast_ref::() .get_internal() .unwrap(); proxy.set_unlink_function(func); @@ -349,12 +384,12 @@ impl + IsA> PadBuilder { } pub fn proxy_pad_flags(self, flags: PadFlags) -> Self { - use ProxyPadExt; + use crate::ProxyPadExt; unsafe { let proxy = self .0 - .unsafe_cast_ref::<::ProxyPad>() + .unsafe_cast_ref::() .get_internal() .unwrap(); proxy.set_pad_flags(flags); @@ -364,7 +399,7 @@ impl + IsA> PadBuilder { } pub fn build_with_target>(self, target: &P) -> Result { - use GhostPadExt; + use crate::GhostPadExt; assert_eq!(self.0.get_direction(), target.get_direction()); diff --git a/gstreamer/src/gobject.rs b/gstreamer/src/gobject.rs index 072759124..78e6b8f43 100644 --- a/gstreamer/src/gobject.rs +++ b/gstreamer/src/gobject.rs @@ -1,9 +1,6 @@ -use glib; use glib::translate::ToGlibPtr; use glib::IsA; -use gst_sys; - pub trait GObjectExtManualGst: 'static { fn set_property_from_str(&self, name: &str, value: &str); } @@ -11,7 +8,7 @@ pub trait GObjectExtManualGst: 'static { impl> GObjectExtManualGst for O { fn set_property_from_str(&self, name: &str, value: &str) { unsafe { - gst_sys::gst_util_set_object_arg( + ffi::gst_util_set_object_arg( self.as_ref().to_glib_none().0, name.to_glib_none().0, value.to_glib_none().0, diff --git a/gstreamer/src/iterator.rs b/gstreamer/src/iterator.rs index d51702dd0..fa9340bf4 100644 --- a/gstreamer/src/iterator.rs +++ b/gstreamer/src/iterator.rs @@ -6,15 +6,11 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use glib; +use glib::ffi::{gconstpointer, gpointer}; use glib::translate::*; use glib::value::{FromValueOptional, ToValue}; use glib::StaticType; use glib::Value; -use glib_sys; -use glib_sys::{gconstpointer, gpointer}; -use gobject_sys; -use gst_sys; use std::ffi::CString; use std::fmt; use std::iter; @@ -34,7 +30,7 @@ pub enum IteratorError { // Implemented manually so that we can use generics for the item pub struct Iterator { - iter: ptr::NonNull, + iter: ptr::NonNull, phantom: PhantomData, } @@ -42,7 +38,7 @@ impl Iterator where for<'a> T: FromValueOptional<'a> + 'static, { - pub unsafe fn into_ptr(self) -> *mut gst_sys::GstIterator { + pub unsafe fn into_ptr(self) -> *mut ffi::GstIterator { let s = mem::ManuallyDrop::new(self); let it = s.to_glib_none().0; it as *mut _ @@ -52,25 +48,24 @@ where pub fn next(&mut self) -> Result, IteratorError> { unsafe { let mut value = Value::uninitialized(); - let res = - gst_sys::gst_iterator_next(self.to_glib_none_mut().0, value.to_glib_none_mut().0); + let res = ffi::gst_iterator_next(self.to_glib_none_mut().0, value.to_glib_none_mut().0); #[allow(clippy::wildcard_in_or_patterns)] match res { - gst_sys::GST_ITERATOR_OK => match value.get::().expect("Iterator::next") { + ffi::GST_ITERATOR_OK => match value.get::().expect("Iterator::next") { Some(value) => Ok(Some(value)), None => Err(IteratorError::Error), }, - gst_sys::GST_ITERATOR_DONE => Ok(None), - gst_sys::GST_ITERATOR_RESYNC => Err(IteratorError::Resync), - gst_sys::GST_ITERATOR_ERROR | _ => Err(IteratorError::Error), + ffi::GST_ITERATOR_DONE => Ok(None), + ffi::GST_ITERATOR_RESYNC => Err(IteratorError::Resync), + ffi::GST_ITERATOR_ERROR | _ => Err(IteratorError::Error), } } } pub fn resync(&mut self) { unsafe { - gst_sys::gst_iterator_resync(self.to_glib_none_mut().0); + ffi::gst_iterator_resync(self.to_glib_none_mut().0); } } @@ -81,12 +76,12 @@ where unsafe { let func_box: Box bool + Send + Sync + 'static> = Box::new(func); let mut closure_value = glib::Value::from_type(from_glib(filter_boxed_get_type::())); - gobject_sys::g_value_take_boxed( + glib::gobject_ffi::g_value_take_boxed( closure_value.to_glib_none_mut().0, Arc::into_raw(Arc::new(func_box)) as gpointer, ); - from_glib_full(gst_sys::gst_iterator_filter( + from_glib_full(ffi::gst_iterator_filter( self.into_ptr(), Some(filter_trampoline::), closure_value.to_glib_none().0, @@ -104,7 +99,7 @@ where let mut func = func; let func_ptr = &mut func as *mut F as gpointer; - let res = from_glib(gst_sys::gst_iterator_find_custom( + let res = from_glib(ffi::gst_iterator_find_custom( self.to_glib_none_mut().0, Some(find_trampoline::), elem.to_glib_none_mut().0, @@ -126,7 +121,7 @@ where let mut func = func; let func_ptr = &mut func as *mut F as gpointer; - let res = gst_sys::gst_iterator_foreach( + let res = ffi::gst_iterator_foreach( self.to_glib_none_mut().0, Some(foreach_trampoline::), func_ptr, @@ -134,9 +129,9 @@ where #[allow(clippy::wildcard_in_or_patterns)] match res { - gst_sys::GST_ITERATOR_OK | gst_sys::GST_ITERATOR_DONE => Ok(()), - gst_sys::GST_ITERATOR_RESYNC => Err(IteratorError::Resync), - gst_sys::GST_ITERATOR_ERROR | _ => Err(IteratorError::Error), + ffi::GST_ITERATOR_OK | ffi::GST_ITERATOR_DONE => Ok(()), + ffi::GST_ITERATOR_RESYNC => Err(IteratorError::Resync), + ffi::GST_ITERATOR_ERROR | _ => Err(IteratorError::Error), } } } @@ -151,12 +146,12 @@ where let mut accum = Some(init); let mut ret = glib::Value::from_type(glib::Type::Pointer); - gobject_sys::g_value_set_pointer( + glib::gobject_ffi::g_value_set_pointer( ret.to_glib_none_mut().0, &mut accum as *mut _ as gpointer, ); - let res = gst_sys::gst_iterator_fold( + let res = ffi::gst_iterator_fold( self.to_glib_none_mut().0, Some(fold_trampoline::), ret.to_glib_none_mut().0, @@ -165,9 +160,9 @@ where #[allow(clippy::wildcard_in_or_patterns)] match res { - gst_sys::GST_ITERATOR_OK | gst_sys::GST_ITERATOR_DONE => Ok(accum.unwrap()), - gst_sys::GST_ITERATOR_RESYNC => Err(IteratorError::Resync), - gst_sys::GST_ITERATOR_ERROR | _ => Err(IteratorError::Error), + ffi::GST_ITERATOR_OK | ffi::GST_ITERATOR_DONE => Ok(accum.unwrap()), + ffi::GST_ITERATOR_RESYNC => Err(IteratorError::Resync), + ffi::GST_ITERATOR_ERROR | _ => Err(IteratorError::Error), } } } @@ -182,7 +177,7 @@ where static DUMMY_COOKIE: u32 = 0; unsafe { - let it = gst_sys::gst_iterator_new( + let it = ffi::gst_iterator_new( mem::size_of::>() as u32, T::static_type().to_glib(), ptr::null_mut(), @@ -219,7 +214,7 @@ struct RsIterator> where for<'a> T: FromValueOptional<'a> + StaticType + ToValue + Send + 'static, { - iter: gst_sys::GstIterator, + iter: ffi::GstIterator, imp: I, phantom: PhantomData, } @@ -233,8 +228,8 @@ where } unsafe extern "C" fn rs_iterator_copy>( - it: *const gst_sys::GstIterator, - copy: *mut gst_sys::GstIterator, + it: *const ffi::GstIterator, + copy: *mut ffi::GstIterator, ) where for<'a> T: FromValueOptional<'a> + StaticType + ToValue + Send + 'static, { @@ -244,7 +239,7 @@ unsafe extern "C" fn rs_iterator_copy>( ptr::write(&mut (*copy).imp, (*it).imp.clone()); } -unsafe extern "C" fn rs_iterator_free>(it: *mut gst_sys::GstIterator) +unsafe extern "C" fn rs_iterator_free>(it: *mut ffi::GstIterator) where for<'a> T: FromValueOptional<'a> + StaticType + ToValue + Send + 'static, { @@ -253,9 +248,9 @@ where } unsafe extern "C" fn rs_iterator_next>( - it: *mut gst_sys::GstIterator, - result: *mut gobject_sys::GValue, -) -> gst_sys::GstIteratorResult + it: *mut ffi::GstIterator, + result: *mut glib::gobject_ffi::GValue, +) -> ffi::GstIteratorResult where for<'a> T: FromValueOptional<'a> + StaticType + ToValue + Send + 'static, { @@ -264,17 +259,17 @@ where Some(Ok(value)) => { let value = value.to_value(); ptr::write(result, value.into_raw()); - gst_sys::GST_ITERATOR_OK + ffi::GST_ITERATOR_OK } - None => gst_sys::GST_ITERATOR_DONE, + None => ffi::GST_ITERATOR_DONE, Some(Err(res)) => match res { - IteratorError::Resync => gst_sys::GST_ITERATOR_RESYNC, - IteratorError::Error => gst_sys::GST_ITERATOR_ERROR, + IteratorError::Resync => ffi::GST_ITERATOR_RESYNC, + IteratorError::Error => ffi::GST_ITERATOR_ERROR, }, } } -unsafe extern "C" fn rs_iterator_resync>(it: *mut gst_sys::GstIterator) +unsafe extern "C" fn rs_iterator_resync>(it: *mut ffi::GstIterator) where for<'a> T: FromValueOptional<'a> + StaticType + ToValue + Send + 'static, { @@ -324,10 +319,10 @@ unsafe extern "C" fn filter_trampoline(value: gconstpointer, func: gconstpoin where for<'a> T: FromValueOptional<'a> + 'static, { - let value = value as *const gobject_sys::GValue; + let value = value as *const glib::gobject_ffi::GValue; - let func = func as *const gobject_sys::GValue; - let func = gobject_sys::g_value_get_boxed(func); + let func = func as *const glib::gobject_ffi::GValue; + let func = glib::gobject_ffi::g_value_get_boxed(func); let func = &*(func as *const &(dyn Fn(T) -> bool + Send + Sync + 'static)); let value = &*(value as *const glib::Value); @@ -357,12 +352,12 @@ unsafe extern "C" fn filter_boxed_unref(boxed: gpointer) { let _ = Arc::from_raw(boxed as *const Box bool + Send + Sync + 'static>); } -unsafe extern "C" fn filter_boxed_get_type() -> glib_sys::GType { +unsafe extern "C" fn filter_boxed_get_type() -> glib::ffi::GType { use once_cell::sync::Lazy; use std::collections::HashMap; use std::sync::Mutex; - static mut TYPES: Lazy>> = + static mut TYPES: Lazy>> = Lazy::new(|| Mutex::new(HashMap::new())); let mut types = TYPES.lock().unwrap(); @@ -380,8 +375,8 @@ unsafe extern "C" fn filter_boxed_get_type() -> glib_sy let iter_type_name = CString::new(format!("GstRsIteratorFilterBoxed-{}-{}", type_name, idx)) .unwrap(); - if gobject_sys::g_type_from_name(iter_type_name.as_ptr()) - == gobject_sys::G_TYPE_INVALID + if glib::gobject_ffi::g_type_from_name(iter_type_name.as_ptr()) + == glib::gobject_ffi::G_TYPE_INVALID { break iter_type_name; } @@ -389,13 +384,13 @@ unsafe extern "C" fn filter_boxed_get_type() -> glib_sy } }; - let type_ = gobject_sys::g_boxed_type_register_static( + let type_ = glib::gobject_ffi::g_boxed_type_register_static( iter_type_name.as_ptr(), Some(filter_boxed_ref::), Some(filter_boxed_unref::), ); - assert_ne!(type_, gobject_sys::G_TYPE_INVALID); + assert_ne!(type_, glib::gobject_ffi::G_TYPE_INVALID); type_ }; @@ -412,7 +407,7 @@ unsafe extern "C" fn find_trampoline bool>( where for<'a> T: FromValueOptional<'a> + 'static, { - let value = value as *const gobject_sys::GValue; + let value = value as *const glib::gobject_ffi::GValue; let func = func as *mut F; let value = &*(value as *const glib::Value); @@ -426,7 +421,7 @@ where } unsafe extern "C" fn foreach_trampoline( - value: *const gobject_sys::GValue, + value: *const glib::gobject_ffi::GValue, func: gpointer, ) where for<'a> T: FromValueOptional<'a> + 'static, @@ -442,10 +437,10 @@ unsafe extern "C" fn foreach_trampoline( } unsafe extern "C" fn fold_trampoline Result>( - value: *const gobject_sys::GValue, - ret: *mut gobject_sys::GValue, + value: *const glib::gobject_ffi::GValue, + ret: *mut glib::gobject_ffi::GValue, func: gpointer, -) -> glib_sys::gboolean +) -> glib::ffi::gboolean where for<'a> T: FromValueOptional<'a> + 'static, { @@ -453,23 +448,23 @@ where let value = &*(value as *const glib::Value); let value = value.get::().expect("Iterator fold_trampoline").unwrap(); - let accum = &mut *(gobject_sys::g_value_get_pointer(ret) as *mut Option); + let accum = &mut *(glib::gobject_ffi::g_value_get_pointer(ret) as *mut Option); match (*func)(accum.take().unwrap(), value) { Ok(next_accum) => { *accum = Some(next_accum); - glib_sys::GTRUE + glib::ffi::GTRUE } Err(next_accum) => { *accum = Some(next_accum); - glib_sys::GFALSE + glib::ffi::GFALSE } } } impl Clone for Iterator { fn clone(&self) -> Self { - unsafe { from_glib_full(gst_sys::gst_iterator_copy(self.to_glib_none().0)) } + unsafe { from_glib_full(ffi::gst_iterator_copy(self.to_glib_none().0)) } } } @@ -484,7 +479,7 @@ impl fmt::Debug for Iterator { impl Drop for Iterator { fn drop(&mut self) { unsafe { - gst_sys::gst_iterator_free(self.iter.as_ptr()); + ffi::gst_iterator_free(self.iter.as_ptr()); } } } @@ -503,26 +498,26 @@ where impl glib::types::StaticType for Iterator { fn static_type() -> glib::types::Type { - unsafe { glib::translate::from_glib(gst_sys::gst_iterator_get_type()) } + unsafe { glib::translate::from_glib(ffi::gst_iterator_get_type()) } } } #[doc(hidden)] impl<'a, T: StaticType> glib::value::FromValueOptional<'a> for Iterator { unsafe fn from_value_optional(value: &glib::Value) -> Option { - Option::>::from_glib_none( - gobject_sys::g_value_get_boxed(value.to_glib_none().0) as *mut gst_sys::GstIterator, - ) + Option::>::from_glib_none(glib::gobject_ffi::g_value_get_boxed( + value.to_glib_none().0, + ) as *mut ffi::GstIterator) } } #[doc(hidden)] impl glib::value::SetValue for Iterator { unsafe fn set_value(value: &mut glib::Value, this: &Self) { - gobject_sys::g_value_set_boxed( + glib::gobject_ffi::g_value_set_boxed( value.to_glib_none_mut().0, - glib::translate::ToGlibPtr::<*const gst_sys::GstIterator>::to_glib_none(this).0 - as glib_sys::gpointer, + glib::translate::ToGlibPtr::<*const ffi::GstIterator>::to_glib_none(this).0 + as glib::ffi::gpointer, ) } } @@ -530,76 +525,76 @@ impl glib::value::SetValue for Iterator { #[doc(hidden)] impl glib::value::SetValueOptional for Iterator { unsafe fn set_value_optional(value: &mut glib::Value, this: Option<&Self>) { - gobject_sys::g_value_set_boxed( + glib::gobject_ffi::g_value_set_boxed( value.to_glib_none_mut().0, - glib::translate::ToGlibPtr::<*const gst_sys::GstIterator>::to_glib_none(&this).0 - as glib_sys::gpointer, + glib::translate::ToGlibPtr::<*const ffi::GstIterator>::to_glib_none(&this).0 + as glib::ffi::gpointer, ) } } #[doc(hidden)] impl glib::translate::GlibPtrDefault for Iterator { - type GlibType = *mut gst_sys::GstIterator; + type GlibType = *mut ffi::GstIterator; } #[doc(hidden)] -impl<'a, T: 'static> glib::translate::ToGlibPtr<'a, *const gst_sys::GstIterator> for Iterator { +impl<'a, T: 'static> glib::translate::ToGlibPtr<'a, *const ffi::GstIterator> for Iterator { type Storage = &'a Iterator; - fn to_glib_none(&'a self) -> glib::translate::Stash<'a, *const gst_sys::GstIterator, Self> { + fn to_glib_none(&'a self) -> glib::translate::Stash<'a, *const ffi::GstIterator, Self> { glib::translate::Stash(self.iter.as_ptr(), self) } - fn to_glib_full(&self) -> *const gst_sys::GstIterator { + fn to_glib_full(&self) -> *const ffi::GstIterator { unimplemented!() } } #[doc(hidden)] -impl<'a, T: 'static> glib::translate::ToGlibPtrMut<'a, *mut gst_sys::GstIterator> for Iterator { +impl<'a, T: 'static> glib::translate::ToGlibPtrMut<'a, *mut ffi::GstIterator> for Iterator { type Storage = &'a mut Iterator; #[inline] fn to_glib_none_mut( &'a mut self, - ) -> glib::translate::StashMut<'a, *mut gst_sys::GstIterator, Self> { + ) -> glib::translate::StashMut<'a, *mut ffi::GstIterator, Self> { glib::translate::StashMut(self.iter.as_ptr(), self) } } #[doc(hidden)] -impl glib::translate::FromGlibPtrNone<*const gst_sys::GstIterator> for Iterator { +impl glib::translate::FromGlibPtrNone<*const ffi::GstIterator> for Iterator { #[inline] - unsafe fn from_glib_none(ptr: *const gst_sys::GstIterator) -> Self { + unsafe fn from_glib_none(ptr: *const ffi::GstIterator) -> Self { assert_ne!( - gobject_sys::g_type_is_a((*ptr).type_, T::static_type().to_glib()), - glib_sys::GFALSE + glib::gobject_ffi::g_type_is_a((*ptr).type_, T::static_type().to_glib()), + glib::ffi::GFALSE ); - from_glib_full(gst_sys::gst_iterator_copy(ptr)) + from_glib_full(ffi::gst_iterator_copy(ptr)) } } #[doc(hidden)] -impl glib::translate::FromGlibPtrNone<*mut gst_sys::GstIterator> for Iterator { +impl glib::translate::FromGlibPtrNone<*mut ffi::GstIterator> for Iterator { #[inline] - unsafe fn from_glib_none(ptr: *mut gst_sys::GstIterator) -> Self { + unsafe fn from_glib_none(ptr: *mut ffi::GstIterator) -> Self { assert_ne!( - gobject_sys::g_type_is_a((*ptr).type_, T::static_type().to_glib()), - glib_sys::GFALSE + glib::gobject_ffi::g_type_is_a((*ptr).type_, T::static_type().to_glib()), + glib::ffi::GFALSE ); - from_glib_full(gst_sys::gst_iterator_copy(ptr)) + from_glib_full(ffi::gst_iterator_copy(ptr)) } } #[doc(hidden)] -impl glib::translate::FromGlibPtrBorrow<*mut gst_sys::GstIterator> for Iterator { +impl glib::translate::FromGlibPtrBorrow<*mut ffi::GstIterator> for Iterator { #[inline] - unsafe fn from_glib_borrow(ptr: *mut gst_sys::GstIterator) -> Borrowed { + unsafe fn from_glib_borrow(ptr: *mut ffi::GstIterator) -> Borrowed { assert!(!ptr.is_null()); assert_ne!( - gobject_sys::g_type_is_a((*ptr).type_, T::static_type().to_glib()), - glib_sys::GFALSE + glib::gobject_ffi::g_type_is_a((*ptr).type_, T::static_type().to_glib()), + glib::ffi::GFALSE ); Borrowed::new(Self { iter: ptr::NonNull::new_unchecked(ptr), @@ -609,13 +604,13 @@ impl glib::translate::FromGlibPtrBorrow<*mut gst_sys::GstIterator } #[doc(hidden)] -impl glib::translate::FromGlibPtrFull<*mut gst_sys::GstIterator> for Iterator { +impl glib::translate::FromGlibPtrFull<*mut ffi::GstIterator> for Iterator { #[inline] - unsafe fn from_glib_full(ptr: *mut gst_sys::GstIterator) -> Self { + unsafe fn from_glib_full(ptr: *mut ffi::GstIterator) -> Self { assert!(!ptr.is_null()); assert_ne!( - gobject_sys::g_type_is_a((*ptr).type_, T::static_type().to_glib()), - glib_sys::GFALSE + glib::gobject_ffi::g_type_is_a((*ptr).type_, T::static_type().to_glib()), + glib::ffi::GFALSE ); Self { iter: ptr::NonNull::new_unchecked(ptr), @@ -683,7 +678,7 @@ mod tests { #[test] fn test_vec() { - ::init().unwrap(); + crate::init().unwrap(); let vec = vec![1i32, 2, 3]; let mut it = Iterator::from_vec(vec); @@ -706,7 +701,7 @@ mod tests { #[test] fn test_filter() { - ::init().unwrap(); + crate::init().unwrap(); let vec = vec![1i32, 2, 3]; let mut it = Iterator::from_vec(vec).filter(|val| val % 2 == 1); @@ -720,7 +715,7 @@ mod tests { #[test] fn test_find() { - ::init().unwrap(); + crate::init().unwrap(); // Our find let vec = vec![1i32, 2, 3]; @@ -730,7 +725,7 @@ mod tests { #[test] fn test_foreach() { - ::init().unwrap(); + crate::init().unwrap(); let vec = vec![1i32, 2, 3]; let mut sum = 0; @@ -741,7 +736,7 @@ mod tests { #[test] fn test_fold() { - ::init().unwrap(); + crate::init().unwrap(); // Our fold let vec = vec![1i32, 2, 3]; @@ -754,7 +749,7 @@ mod tests { #[test] fn test_std() { - ::init().unwrap(); + crate::init().unwrap(); let mut it = Iterator::from_vec(vec![1i32, 2, 3]).into_iter(); assert_eq!(it.next(), Some(Ok(1))); @@ -765,7 +760,7 @@ mod tests { #[test] fn test_into_iter() { - ::init().unwrap(); + crate::init().unwrap(); let mut v = vec![1i32, 2, 3].into_iter(); for x in Iterator::from_vec(vec![1i32, 2, 3]) { @@ -776,14 +771,14 @@ mod tests { #[test] fn test_std_resync_collect() { - use prelude::*; + use crate::prelude::*; use std::collections::BTreeSet; - ::init().unwrap(); + crate::init().unwrap(); - let bin = ::Bin::new(None); - let id1 = ::ElementFactory::make("identity", None).unwrap(); - let id2 = ::ElementFactory::make("identity", None).unwrap(); + let bin = crate::Bin::new(None); + let id1 = crate::ElementFactory::make("identity", None).unwrap(); + let id2 = crate::ElementFactory::make("identity", None).unwrap(); bin.add(&id1).unwrap(); @@ -808,13 +803,13 @@ mod tests { #[test] fn test_std_resync_find() { - use prelude::*; + use crate::prelude::*; - ::init().unwrap(); + crate::init().unwrap(); - let bin = ::Bin::new(None); - let id1 = ::ElementFactory::make("identity", None).unwrap(); - let id2 = ::ElementFactory::make("identity", None).unwrap(); + let bin = crate::Bin::new(None); + let id1 = crate::ElementFactory::make("identity", None).unwrap(); + let id2 = crate::ElementFactory::make("identity", None).unwrap(); bin.add(&id1).unwrap(); diff --git a/gstreamer/src/lib.rs b/gstreamer/src/lib.rs index 4c7847937..9d7e37916 100644 --- a/gstreamer/src/lib.rs +++ b/gstreamer/src/lib.rs @@ -8,54 +8,19 @@ #![cfg_attr(feature = "dox", feature(doc_cfg))] #![recursion_limit = "256"] -#[macro_use] -extern crate bitflags; -#[macro_use] -extern crate cfg_if; -extern crate libc; -extern crate once_cell; -extern crate thiserror; // Re-exported for the subclass gst_plugin_define! macro +pub use ffi; #[doc(hidden)] -pub extern crate glib_sys; +pub use glib; #[doc(hidden)] -pub extern crate gobject_sys; -#[doc(hidden)] -pub extern crate gstreamer_sys as gst_sys; -#[doc(hidden)] -pub extern crate paste; - -#[macro_use] -#[doc(hidden)] -pub extern crate glib; - -extern crate num_rational; - -extern crate futures_channel; -extern crate futures_core; -extern crate futures_util; - -extern crate muldiv; - -extern crate pretty_hex; - -#[cfg(feature = "ser_de")] -extern crate serde; -#[cfg(feature = "ser_de")] -extern crate serde_bytes; -#[cfg(feature = "ser_de")] -#[macro_use] -extern crate serde_derive; - -#[cfg(test)] -extern crate futures_executor; +pub use paste; use glib::translate::{from_glib, from_glib_full}; macro_rules! assert_initialized_main_thread { () => { - if unsafe { ::gst_sys::gst_is_initialized() } != ::glib_sys::GTRUE { + if unsafe { ffi::gst_is_initialized() } != glib::ffi::GTRUE { panic!("GStreamer has not been initialized. Call `gst::init` first."); } }; @@ -70,39 +35,39 @@ macro_rules! skip_assert_initialized { #[allow(clippy::match_same_arms)] #[allow(clippy::type_complexity)] mod auto; -pub use auto::functions::*; -pub use auto::*; +pub use crate::auto::functions::*; +pub use crate::auto::*; #[macro_use] mod log; -pub use log::*; +pub use crate::log::*; #[macro_use] mod error; -pub use error::*; +pub use crate::error::*; #[macro_use] pub mod miniobject; pub mod message; -pub use message::{Message, MessageErrorDomain, MessageRef, MessageView}; +pub use crate::message::{Message, MessageErrorDomain, MessageRef, MessageView}; mod value; -pub use value::*; +pub use crate::value::*; #[cfg(feature = "ser_de")] #[macro_use] mod value_serde; pub mod structure; -pub use structure::{Structure, StructureRef}; +pub use crate::structure::{Structure, StructureRef}; #[cfg(feature = "ser_de")] mod structure_serde; pub mod caps; -pub use caps::{Caps, CapsRef}; +pub use crate::caps::{Caps, CapsRef}; mod caps_features; #[cfg(feature = "ser_de")] mod caps_serde; -pub use caps_features::{ +pub use crate::caps_features::{ CapsFeatures, CapsFeaturesRef, CAPS_FEATURES_MEMORY_SYSTEM_MEMORY, CAPS_FEATURE_MEMORY_SYSTEM_MEMORY, }; @@ -110,7 +75,7 @@ pub use caps_features::{ mod caps_features_serde; pub mod tags; -pub use tags::{ +pub use crate::tags::{ tag_exists, tag_get_description, tag_get_flag, tag_get_nick, tag_get_type, Tag, TagList, TagListRef, }; @@ -120,42 +85,42 @@ mod tags_serde; pub mod meta; #[cfg(any(feature = "v1_16", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_16")))] -pub use meta::MetaSeqnum; +pub use crate::meta::MetaSeqnum; #[cfg(any(feature = "v1_14", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_14")))] -pub use meta::ReferenceTimestampMeta; -pub use meta::{Meta, MetaAPI, MetaRef, MetaRefMut, ParentBufferMeta, ProtectionMeta}; +pub use crate::meta::ReferenceTimestampMeta; +pub use crate::meta::{Meta, MetaAPI, MetaRef, MetaRefMut, ParentBufferMeta, ProtectionMeta}; pub mod buffer; -pub use buffer::{ +pub use crate::buffer::{ Buffer, BufferMap, BufferRef, MappedBuffer, BUFFER_COPY_ALL, BUFFER_COPY_METADATA, }; mod buffer_cursor; -pub use buffer_cursor::{BufferCursor, BufferRefCursor}; +pub use crate::buffer_cursor::{BufferCursor, BufferRefCursor}; pub mod memory; -pub use memory::{MappedMemory, Memory, MemoryMap, MemoryRef}; +pub use crate::memory::{MappedMemory, Memory, MemoryMap, MemoryRef}; #[cfg(feature = "ser_de")] mod buffer_serde; pub mod sample; -pub use sample::{Sample, SampleRef}; +pub use crate::sample::{Sample, SampleRef}; #[cfg(feature = "ser_de")] mod sample_serde; pub mod bufferlist; -pub use bufferlist::{BufferList, BufferListRef}; +pub use crate::bufferlist::{BufferList, BufferListRef}; #[cfg(feature = "ser_de")] mod bufferlist_serde; pub mod query; -pub use query::{Query, QueryRef, QueryView}; +pub use crate::query::{Query, QueryRef, QueryView}; pub mod event; -pub use event::{Event, EventRef, EventView, GroupId, Seqnum}; +pub use crate::event::{Event, EventRef, EventView, GroupId, Seqnum}; pub mod context; -pub use context::{Context, ContextRef}; +pub use crate::context::{Context, ContextRef}; mod static_caps; -pub use static_caps::*; +pub use crate::static_caps::*; mod static_pad_template; -pub use static_pad_template::*; +pub use crate::static_pad_template::*; #[cfg(any(feature = "v1_14", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_14")))] @@ -170,9 +135,9 @@ mod element; mod bin; mod allocator; -pub use allocator::AllocatorExtManual; +pub use crate::allocator::AllocatorExtManual; mod pipeline; -pub use pipeline::GstPipelineExtManual; +pub use crate::pipeline::GstPipelineExtManual; mod allocation_params; pub use self::allocation_params::AllocationParams; @@ -180,7 +145,7 @@ pub use self::allocation_params::AllocationParams; // OS dependent Bus extensions (also import the other plateform mod for doc) #[cfg(any(feature = "v1_14", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_14")))] -cfg_if! { +cfg_if::cfg_if! { if #[cfg(unix)] { mod bus_unix; #[cfg(feature = "dox")] @@ -203,31 +168,31 @@ mod date_time_serde; mod device_monitor; mod device_provider; mod enums; -pub use enums::MessageType; +pub use crate::enums::MessageType; mod ghost_pad; mod gobject; mod iterator; mod object; mod pad; -pub use pad::PadBuilder; +pub use crate::pad::PadBuilder; mod control_binding; mod control_source; mod parse_context; mod proxy_pad; -pub use proxy_pad::ProxyPadExtManual; +pub use crate::proxy_pad::ProxyPadExtManual; mod tag_setter; -pub use bin::GstBinExtManual; -pub use element::{ElementExtManual, ElementMessageType, NotifyWatchId}; -pub use element::{ +pub use crate::bin::GstBinExtManual; +pub use crate::element::{ElementExtManual, ElementMessageType, NotifyWatchId}; +pub use crate::element::{ ELEMENT_METADATA_AUTHOR, ELEMENT_METADATA_DESCRIPTION, ELEMENT_METADATA_DOC_URI, ELEMENT_METADATA_ICON_NAME, ELEMENT_METADATA_KLASS, ELEMENT_METADATA_LONGNAME, }; -pub use object::GstObjectExtManual; +pub use crate::object::GstObjectExtManual; // OS dependent Bus extensions (also import the other plateform trait for doc) #[cfg(any(feature = "v1_14", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_14")))] -cfg_if! { +cfg_if::cfg_if! { if #[cfg(unix)] { pub use bus_unix::UnixBusExtManual; #[cfg(feature = "dox")] @@ -240,23 +205,23 @@ cfg_if! { } pub use self::iterator::{Iterator, IteratorError, IteratorImpl, StdIterator}; -pub use child_proxy::ChildProxyExtManual; -pub use clock_time::ClockTime; -pub use device_monitor::{DeviceMonitorExtManual, DeviceMonitorFilterId}; -pub use device_provider::DeviceProviderExtManual; -pub use enums::{ +pub use crate::child_proxy::ChildProxyExtManual; +pub use crate::clock_time::ClockTime; +pub use crate::device_monitor::{DeviceMonitorExtManual, DeviceMonitorFilterId}; +pub use crate::device_provider::DeviceProviderExtManual; +pub use crate::enums::{ ClockError, ClockSuccess, FlowError, FlowSuccess, PadLinkError, PadLinkSuccess, StateChangeError, StateChangeSuccess, TagError, }; -pub use gobject::GObjectExtManualGst; -pub use pad::{PadExtManual, PadGetRangeSuccess, PadProbeData, PadProbeId, PadProbeInfo}; -pub use parse_context::ParseContext; +pub use crate::gobject::GObjectExtManualGst; +pub use crate::pad::{PadExtManual, PadGetRangeSuccess, PadProbeData, PadProbeId, PadProbeInfo}; +pub use crate::parse_context::ParseContext; mod plugin_feature; -pub use plugin_feature::PluginFeatureExtManual; -pub use tag_setter::TagSetterExtManual; +pub use crate::plugin_feature::PluginFeatureExtManual; +pub use crate::tag_setter::TagSetterExtManual; mod plugin; -pub use plugin::GstPluginExtManual; +pub use crate::plugin::GstPluginExtManual; #[cfg(any(feature = "v1_10", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))] pub mod stream; @@ -265,43 +230,45 @@ pub mod stream; pub mod stream_collection; mod typefind; -pub use typefind::*; +pub use crate::typefind::*; pub mod format; -pub use format::{FormattedValue, GenericFormattedValue, SpecificFormattedValue}; +pub use crate::format::{FormattedValue, GenericFormattedValue, SpecificFormattedValue}; #[cfg(feature = "ser_de")] mod format_serde; mod segment; -pub use segment::*; +pub use crate::segment::*; #[cfg(feature = "ser_de")] mod segment_serde; pub mod toc; -pub use toc::{Toc, TocEntry, TocEntryRef, TocRef}; +pub use crate::toc::{Toc, TocEntry, TocEntryRef, TocRef}; #[cfg(feature = "ser_de")] mod toc_serde; mod clock; -pub use clock::{AtomicClockReturn, ClockExtManual, ClockId, PeriodicClockId, SingleShotClockId}; +pub use crate::clock::{ + AtomicClockReturn, ClockExtManual, ClockId, PeriodicClockId, SingleShotClockId, +}; mod buffer_pool; -pub use buffer_pool::*; +pub use crate::buffer_pool::*; mod pad_template; mod param_spec; -pub use param_spec::*; +pub use crate::param_spec::*; pub mod functions; -pub use functions::*; +pub use crate::functions::*; use std::ptr; pub fn init() -> Result<(), glib::Error> { unsafe { let mut error = ptr::null_mut(); - if from_glib(gst_sys::gst_init_check( + if from_glib(ffi::gst_init_check( ptr::null_mut(), ptr::null_mut(), &mut error, @@ -320,10 +287,10 @@ pub fn init() -> Result<(), glib::Error> { /// This must only be called once during the lifetime of the process, once no GStreamer threads /// are running anymore and all GStreamer resources are released. pub unsafe fn deinit() { - gst_sys::gst_deinit(); + ffi::gst_deinit(); } -pub const BUFFER_OFFSET_NONE: u64 = gst_sys::GST_BUFFER_OFFSET_NONE; +pub const BUFFER_OFFSET_NONE: u64 = ffi::GST_BUFFER_OFFSET_NONE; pub const CLOCK_TIME_NONE: ClockTime = ClockTime(None); pub const SECOND: ClockTime = ClockTime(Some(1_000_000_000)); @@ -336,60 +303,60 @@ pub const MSECOND_VAL: u64 = 1_000_000; pub const USECOND_VAL: u64 = 1_000; pub const NSECOND_VAL: u64 = 1; -pub const FORMAT_PERCENT_MAX: u32 = gst_sys::GST_FORMAT_PERCENT_MAX as u32; -pub const FORMAT_PERCENT_SCALE: u32 = gst_sys::GST_FORMAT_PERCENT_SCALE as u32; +pub const FORMAT_PERCENT_MAX: u32 = ffi::GST_FORMAT_PERCENT_MAX as u32; +pub const FORMAT_PERCENT_SCALE: u32 = ffi::GST_FORMAT_PERCENT_SCALE as u32; // Re-export all the traits in a prelude module, so that applications // can always "use gst::prelude::*" without getting conflicts pub mod prelude { pub use glib::prelude::*; - pub use auto::traits::*; + pub use crate::auto::traits::*; - pub use meta::MetaAPI; + pub use crate::meta::MetaAPI; - pub use allocator::AllocatorExtManual; - pub use bin::GstBinExtManual; - pub use element::{ElementClassExt, ElementExtManual}; + pub use crate::allocator::AllocatorExtManual; + pub use crate::bin::GstBinExtManual; + pub use crate::element::{ElementClassExt, ElementExtManual}; // OS dependent Bus extensions (also import the other plateform trait for doc) #[cfg(any(feature = "v1_14", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_14")))] - cfg_if! { + cfg_if::cfg_if! { if #[cfg(unix)] { - pub use bus_unix::UnixBusExtManual; + pub use crate::bus_unix::UnixBusExtManual; #[cfg(feature = "dox")] - pub use bus_windows::WindowsBusExtManual; + pub use crate::bus_windows::WindowsBusExtManual; } else { - pub use bus_windows::WindowsBusExtManual; + pub use crate::bus_windows::WindowsBusExtManual; #[cfg(feature = "dox")] - pub use bus_unix::UnixBusExtManual; + pub use crate::bus_unix::UnixBusExtManual; } } - pub use buffer_pool::BufferPoolExtManual; - pub use child_proxy::ChildProxyExtManual; - pub use clock::ClockExtManual; - pub use device_monitor::DeviceMonitorExtManual; - pub use device_provider::DeviceProviderExtManual; - pub use gobject::GObjectExtManualGst; - pub use message::MessageErrorDomain; - pub use object::GstObjectExtManual; - pub use pad::PadExtManual; - pub use param_spec::GstParamSpecExt; - pub use pipeline::GstPipelineExtManual; - pub use plugin::GstPluginExtManual; - pub use plugin_feature::PluginFeatureExtManual; - pub use proxy_pad::ProxyPadExtManual; - pub use tag_setter::TagSetterExtManual; - pub use typefind::TypeFindImpl; - pub use value::GstValueExt; + pub use crate::buffer_pool::BufferPoolExtManual; + pub use crate::child_proxy::ChildProxyExtManual; + pub use crate::clock::ClockExtManual; + pub use crate::device_monitor::DeviceMonitorExtManual; + pub use crate::device_provider::DeviceProviderExtManual; + pub use crate::gobject::GObjectExtManualGst; + pub use crate::message::MessageErrorDomain; + pub use crate::object::GstObjectExtManual; + pub use crate::pad::PadExtManual; + pub use crate::param_spec::GstParamSpecExt; + pub use crate::pipeline::GstPipelineExtManual; + pub use crate::plugin::GstPluginExtManual; + pub use crate::plugin_feature::PluginFeatureExtManual; + pub use crate::proxy_pad::ProxyPadExtManual; + pub use crate::tag_setter::TagSetterExtManual; + pub use crate::typefind::TypeFindImpl; + pub use crate::value::GstValueExt; - pub use tags::{CustomTag, Tag}; + pub use crate::tags::{CustomTag, Tag}; pub use muldiv::MulDiv; - pub use format::{FormattedValue, SpecificFormattedValue}; + pub use crate::format::{FormattedValue, SpecificFormattedValue}; } mod utils; diff --git a/gstreamer/src/log.rs b/gstreamer/src/log.rs index c40388884..9ea50df32 100644 --- a/gstreamer/src/log.rs +++ b/gstreamer/src/log.rs @@ -6,7 +6,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use DebugLevel; +use crate::DebugLevel; use libc::c_char; use std::borrow::Cow; @@ -16,15 +16,12 @@ use std::ptr; use once_cell::sync::Lazy; -use gobject_sys; -use gst_sys; - +use glib::ffi::gpointer; use glib::translate::*; use glib::IsA; -use glib_sys::gpointer; #[derive(PartialEq, Eq)] -pub struct DebugMessage(ptr::NonNull); +pub struct DebugMessage(ptr::NonNull); impl fmt::Debug for DebugMessage { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { @@ -35,7 +32,7 @@ impl fmt::Debug for DebugMessage { impl DebugMessage { pub fn get(&self) -> Option> { unsafe { - let message = gst_sys::gst_debug_message_get(self.0.as_ptr()); + let message = ffi::gst_debug_message_get(self.0.as_ptr()); if message.is_null() { None @@ -47,17 +44,21 @@ impl DebugMessage { } #[derive(PartialEq, Eq, Clone, Copy)] -pub struct DebugCategory(ptr::NonNull); +pub struct DebugCategory(ptr::NonNull); impl DebugCategory { - pub fn new(name: &str, color: ::DebugColorFlags, description: Option<&str>) -> DebugCategory { + pub fn new( + name: &str, + color: crate::DebugColorFlags, + description: Option<&str>, + ) -> DebugCategory { skip_assert_initialized!(); extern "C" { fn _gst_debug_category_new( name: *const c_char, - color: gst_sys::GstDebugColorFlags, + color: ffi::GstDebugColorFlags, description: *const c_char, - ) -> *mut gst_sys::GstDebugCategory; + ) -> *mut ffi::GstDebugCategory; } // Gets the category if it exists already @@ -76,7 +77,7 @@ impl DebugCategory { skip_assert_initialized!(); unsafe { extern "C" { - fn _gst_debug_get_category(name: *const c_char) -> *mut gst_sys::GstDebugCategory; + fn _gst_debug_get_category(name: *const c_char) -> *mut ffi::GstDebugCategory; } let cat = _gst_debug_get_category(name.to_glib_none().0); @@ -89,25 +90,25 @@ impl DebugCategory { } } - pub fn get_threshold(self) -> ::DebugLevel { - from_glib(unsafe { gst_sys::gst_debug_category_get_threshold(self.0.as_ptr()) }) + pub fn get_threshold(self) -> crate::DebugLevel { + from_glib(unsafe { ffi::gst_debug_category_get_threshold(self.0.as_ptr()) }) } - pub fn set_threshold(self, threshold: ::DebugLevel) { - unsafe { gst_sys::gst_debug_category_set_threshold(self.0.as_ptr(), threshold.to_glib()) } + pub fn set_threshold(self, threshold: crate::DebugLevel) { + unsafe { ffi::gst_debug_category_set_threshold(self.0.as_ptr(), threshold.to_glib()) } } pub fn reset_threshold(self) { - unsafe { gst_sys::gst_debug_category_reset_threshold(self.0.as_ptr()) } + unsafe { ffi::gst_debug_category_reset_threshold(self.0.as_ptr()) } } - pub fn get_color(self) -> ::DebugColorFlags { - unsafe { from_glib(gst_sys::gst_debug_category_get_color(self.0.as_ptr())) } + pub fn get_color(self) -> crate::DebugColorFlags { + unsafe { from_glib(ffi::gst_debug_category_get_color(self.0.as_ptr())) } } pub fn get_name<'a>(self) -> &'a str { unsafe { - CStr::from_ptr(gst_sys::gst_debug_category_get_name(self.0.as_ptr())) + CStr::from_ptr(ffi::gst_debug_category_get_name(self.0.as_ptr())) .to_str() .unwrap() } @@ -115,7 +116,7 @@ impl DebugCategory { pub fn get_description<'a>(self) -> Option<&'a str> { unsafe { - let ptr = gst_sys::gst_debug_category_get_description(self.0.as_ptr()); + let ptr = ffi::gst_debug_category_get_description(self.0.as_ptr()); if ptr.is_null() { None @@ -129,7 +130,7 @@ impl DebugCategory { pub fn log>( self, obj: Option<&O>, - level: ::DebugLevel, + level: crate::DebugLevel, file: &str, module: &str, line: u32, @@ -142,12 +143,12 @@ impl DebugCategory { } let obj_ptr = match obj { - Some(obj) => obj.to_glib_none().0 as *mut gobject_sys::GObject, + Some(obj) => obj.to_glib_none().0 as *mut glib::gobject_ffi::GObject, None => ptr::null_mut(), }; unsafe { - gst_sys::gst_debug_log( + ffi::gst_debug_log( self.0.as_ptr(), level.to_glib(), file.to_glib_none().0, @@ -174,7 +175,7 @@ impl fmt::Debug for DebugCategory { pub static CAT_RUST: Lazy = Lazy::new(|| { DebugCategory::new( "GST_RUST", - ::DebugColorFlags::UNDERLINE, + crate::DebugColorFlags::UNDERLINE, Some("GStreamer's Rust binding core"), ) }); @@ -312,13 +313,13 @@ macro_rules! gst_log_with_level( ); unsafe extern "C" fn log_handler( - category: *mut gst_sys::GstDebugCategory, - level: gst_sys::GstDebugLevel, + category: *mut ffi::GstDebugCategory, + level: ffi::GstDebugLevel, file: *const c_char, function: *const c_char, line: i32, - object: *mut gobject_sys::GObject, - message: *mut gst_sys::GstDebugMessage, + object: *mut glib::gobject_ffi::GObject, + message: *mut ffi::GstDebugMessage, user_data: gpointer, ) where T: Fn(DebugCategory, DebugLevel, &str, &str, u32, Option<&LoggedObject>, &DebugMessage) @@ -360,10 +361,10 @@ unsafe impl Send for DebugLogFunction {} unsafe impl Sync for DebugLogFunction {} #[derive(Debug)] -pub struct LoggedObject(ptr::NonNull); +pub struct LoggedObject(ptr::NonNull); impl LoggedObject { - pub fn as_ptr(&self) -> *mut gobject_sys::GObject { + pub fn as_ptr(&self) -> *mut glib::gobject_ffi::GObject { self.0.as_ptr() } } @@ -373,16 +374,17 @@ impl fmt::Display for LoggedObject { unsafe { let ptr = self.0.as_ptr(); let g_type_instance = &mut (*ptr).g_type_instance; - if gobject_sys::g_type_check_instance_is_fundamentally_a( + if glib::gobject_ffi::g_type_check_instance_is_fundamentally_a( g_type_instance, - gobject_sys::g_object_get_type(), - ) != glib_sys::GFALSE + glib::gobject_ffi::g_object_get_type(), + ) != glib::ffi::GFALSE { let type_ = (*g_type_instance.g_class).g_type; - if gobject_sys::g_type_is_a(type_, gst_sys::gst_pad_get_type()) != glib_sys::GFALSE + if glib::gobject_ffi::g_type_is_a(type_, ffi::gst_pad_get_type()) + != glib::ffi::GFALSE { - let name_ptr = (*(ptr as *mut gst_sys::GstObject)).name; + let name_ptr = (*(ptr as *mut ffi::GstObject)).name; let name = if name_ptr.is_null() { "" } else { @@ -391,11 +393,11 @@ impl fmt::Display for LoggedObject { .unwrap_or("") }; - let parent_ptr = (*(ptr as *mut gst_sys::GstObject)).parent; + let parent_ptr = (*(ptr as *mut ffi::GstObject)).parent; let parent_name = if parent_ptr.is_null() { "" } else { - let name_ptr = (*(parent_ptr as *mut gst_sys::GstObject)).name; + let name_ptr = (*(parent_ptr as *mut ffi::GstObject)).name; if name_ptr.is_null() { "" } else { @@ -406,10 +408,10 @@ impl fmt::Display for LoggedObject { }; write!(f, "{}:{}", parent_name, name) - } else if gobject_sys::g_type_is_a(type_, gst_sys::gst_object_get_type()) - != glib_sys::GFALSE + } else if glib::gobject_ffi::g_type_is_a(type_, ffi::gst_object_get_type()) + != glib::ffi::GFALSE { - let name_ptr = (*(ptr as *mut gst_sys::GstObject)).name; + let name_ptr = (*(ptr as *mut ffi::GstObject)).name; let name = if name_ptr.is_null() { "" } else { @@ -419,7 +421,7 @@ impl fmt::Display for LoggedObject { }; write!(f, "{}", name) } else { - let type_name = CStr::from_ptr(gobject_sys::g_type_name(type_)); + let type_name = CStr::from_ptr(glib::gobject_ffi::g_type_name(type_)); write!( f, "{}:{:?}", @@ -445,7 +447,7 @@ where unsafe { let user_data = Box::new(function); let user_data_ptr = Box::into_raw(user_data) as gpointer; - gst_sys::gst_debug_add_log_function( + ffi::gst_debug_add_log_function( Some(log_handler::), user_data_ptr, Some(log_handler_data_free::), @@ -457,14 +459,14 @@ where pub fn debug_remove_default_log_function() { skip_assert_initialized!(); unsafe { - gst_sys::gst_debug_remove_log_function(None); + ffi::gst_debug_remove_log_function(None); } } pub fn debug_remove_log_function(log_fn: DebugLogFunction) { skip_assert_initialized!(); unsafe { - let removed = gst_sys::gst_debug_remove_log_function_by_data(log_fn.0.as_ptr()); + let removed = ffi::gst_debug_remove_log_function_by_data(log_fn.0.as_ptr()); assert_eq!(removed, 1); } } @@ -477,7 +479,7 @@ mod tests { #[test] fn get_existing() { - ::init().unwrap(); + crate::init().unwrap(); let perf_cat = DebugCategory::get("GST_PERFORMANCE") .expect("Unable to find `DebugCategory` with name \"GST_PERFORMANCE\""); @@ -486,11 +488,11 @@ mod tests { #[test] fn new_and_log() { - ::init().unwrap(); + crate::init().unwrap(); let cat = DebugCategory::new( "test-cat", - ::DebugColorFlags::empty(), + crate::DebugColorFlags::empty(), Some("some debug category"), ); @@ -503,7 +505,7 @@ mod tests { gst_trace!(cat, "meh"); gst_memdump!(cat, "meh"); - let obj = ::Bin::new(Some("meh")); + let obj = crate::Bin::new(Some("meh")); gst_error!(cat, obj: &obj, "meh"); gst_warning!(cat, obj: &obj, "meh"); gst_fixme!(cat, obj: &obj, "meh"); @@ -516,15 +518,15 @@ mod tests { #[test] fn log_handler() { - ::init().unwrap(); + crate::init().unwrap(); let cat = DebugCategory::new( "test-cat-log", - ::DebugColorFlags::empty(), + crate::DebugColorFlags::empty(), Some("some debug category"), ); cat.set_threshold(DebugLevel::Info); - let obj = ::Bin::new(Some("meh")); + let obj = crate::Bin::new(Some("meh")); let (sender, receiver) = mpsc::channel(); diff --git a/gstreamer/src/memory.rs b/gstreamer/src/memory.rs index 8179055c6..986784553 100644 --- a/gstreamer/src/memory.rs +++ b/gstreamer/src/memory.rs @@ -13,28 +13,25 @@ use std::ops; use std::ptr; use std::slice; -use gst_sys; - -use glib; use glib::translate::{from_glib, from_glib_full, from_glib_none, ToGlibPtr}; -use AllocationParams; -use Allocator; -use MemoryFlags; +use crate::AllocationParams; +use crate::Allocator; +use crate::MemoryFlags; -gst_define_mini_object_wrapper!(Memory, MemoryRef, gst_sys::GstMemory, || { - gst_sys::gst_memory_get_type() +gst_define_mini_object_wrapper!(Memory, MemoryRef, ffi::GstMemory, || { + ffi::gst_memory_get_type() }); pub struct MemoryMap<'a, T> { memory: &'a MemoryRef, - map_info: gst_sys::GstMapInfo, + map_info: ffi::GstMapInfo, phantom: PhantomData, } pub struct MappedMemory { memory: Option, - map_info: gst_sys::GstMapInfo, + map_info: ffi::GstMapInfo, phantom: PhantomData, } @@ -63,7 +60,7 @@ pub enum Readable {} pub enum Writable {} impl Memory { - unsafe extern "C" fn drop_box(vec: glib_sys::gpointer) { + unsafe extern "C" fn drop_box(vec: glib::ffi::gpointer) { let slice: Box = Box::from_raw(vec as *mut T); drop(slice); } @@ -71,7 +68,7 @@ impl Memory { pub fn with_size(size: usize) -> Self { assert_initialized_main_thread!(); unsafe { - from_glib_full(gst_sys::gst_allocator_alloc( + from_glib_full(ffi::gst_allocator_alloc( ptr::null_mut(), size, ptr::null_mut(), @@ -82,7 +79,7 @@ impl Memory { pub fn with_size_and_params(size: usize, params: &AllocationParams) -> Self { assert_initialized_main_thread!(); unsafe { - from_glib_full(gst_sys::gst_allocator_alloc( + from_glib_full(ffi::gst_allocator_alloc( ptr::null_mut(), size, params.as_ptr() as *mut _, @@ -99,13 +96,13 @@ impl Memory { (slice.len(), slice.as_ptr()) }; let user_data = Box::into_raw(b); - from_glib_full(gst_sys::gst_memory_new_wrapped( - gst_sys::GST_MEMORY_FLAG_READONLY, - data as glib_sys::gpointer, + from_glib_full(ffi::gst_memory_new_wrapped( + ffi::GST_MEMORY_FLAG_READONLY, + data as glib::ffi::gpointer, size, 0, size, - user_data as glib_sys::gpointer, + user_data as glib::ffi::gpointer, Some(Self::drop_box::), )) } @@ -121,13 +118,13 @@ impl Memory { (slice.len(), slice.as_mut_ptr()) }; let user_data = Box::into_raw(b); - from_glib_full(gst_sys::gst_memory_new_wrapped( + from_glib_full(ffi::gst_memory_new_wrapped( 0, - data as glib_sys::gpointer, + data as glib::ffi::gpointer, size, 0, size, - user_data as glib_sys::gpointer, + user_data as glib::ffi::gpointer, Some(Self::drop_box::), )) } @@ -136,10 +133,10 @@ impl Memory { pub fn into_mapped_memory_readable(self) -> Result, Self> { unsafe { let mut map_info = mem::MaybeUninit::zeroed(); - let res: bool = from_glib(gst_sys::gst_memory_map( + let res: bool = from_glib(ffi::gst_memory_map( self.as_mut_ptr(), map_info.as_mut_ptr(), - gst_sys::GST_MAP_READ, + ffi::GST_MAP_READ, )); if res { Ok(MappedMemory { @@ -156,10 +153,10 @@ impl Memory { pub fn into_mapped_memory_writable(self) -> Result, Self> { unsafe { let mut map_info = mem::MaybeUninit::zeroed(); - let res: bool = from_glib(gst_sys::gst_memory_map( + let res: bool = from_glib(ffi::gst_memory_map( self.as_mut_ptr(), map_info.as_mut_ptr(), - gst_sys::GST_MAP_READWRITE, + ffi::GST_MAP_READWRITE, )); if res { Ok(MappedMemory { @@ -216,7 +213,7 @@ impl MemoryRef { }; assert!(offset + pos_sz < (self.get_maxsize() as isize)); unsafe { - from_glib_full(gst_sys::gst_memory_copy( + from_glib_full(ffi::gst_memory_copy( self.as_mut_ptr(), offset, match size { @@ -230,7 +227,7 @@ impl MemoryRef { pub fn is_span(&self, mem2: &MemoryRef) -> Option { unsafe { let mut offset = mem::MaybeUninit::uninit(); - let res = from_glib(gst_sys::gst_memory_is_span( + let res = from_glib(ffi::gst_memory_is_span( self.as_mut_ptr(), mem2.as_mut_ptr(), offset.as_mut_ptr(), @@ -245,7 +242,7 @@ impl MemoryRef { pub fn is_type(&self, mem_type: &str) -> bool { unsafe { - from_glib(gst_sys::gst_memory_is_type( + from_glib(ffi::gst_memory_is_type( self.as_mut_ptr(), mem_type.to_glib_none().0, )) @@ -255,19 +252,16 @@ impl MemoryRef { pub fn map_readable(&self) -> Result, glib::BoolError> { unsafe { let mut map_info = mem::MaybeUninit::zeroed(); - let res = gst_sys::gst_memory_map( - self.as_mut_ptr(), - map_info.as_mut_ptr(), - gst_sys::GST_MAP_READ, - ); - if res == glib_sys::GTRUE { + let res = + ffi::gst_memory_map(self.as_mut_ptr(), map_info.as_mut_ptr(), ffi::GST_MAP_READ); + if res == glib::ffi::GTRUE { Ok(MemoryMap { memory: self, map_info: map_info.assume_init(), phantom: PhantomData, }) } else { - Err(glib_bool_error!("Failed to map memory readable")) + Err(glib::glib_bool_error!("Failed to map memory readable")) } } } @@ -275,19 +269,19 @@ impl MemoryRef { pub fn map_writable(&mut self) -> Result, glib::BoolError> { unsafe { let mut map_info = mem::MaybeUninit::zeroed(); - let res = gst_sys::gst_memory_map( + let res = ffi::gst_memory_map( self.as_mut_ptr(), map_info.as_mut_ptr(), - gst_sys::GST_MAP_READWRITE, + ffi::GST_MAP_READWRITE, ); - if res == glib_sys::GTRUE { + if res == glib::ffi::GTRUE { Ok(MemoryMap { memory: self, map_info: map_info.assume_init(), phantom: PhantomData, }) } else { - Err(glib_bool_error!("Failed to map memory writable")) + Err(glib::glib_bool_error!("Failed to map memory writable")) } } } @@ -299,7 +293,7 @@ impl MemoryRef { }; assert!(offset + pos_sz < (self.get_maxsize() as isize)); unsafe { - from_glib_full(gst_sys::gst_memory_share( + from_glib_full(ffi::gst_memory_share( self.as_ptr() as *mut _, offset, match size { @@ -312,7 +306,7 @@ impl MemoryRef { pub fn resize(&mut self, offset: isize, size: usize) { assert!(offset + (size as isize) < (self.get_maxsize() as isize)); - unsafe { gst_sys::gst_memory_resize(self.as_mut_ptr(), offset, size) } + unsafe { ffi::gst_memory_resize(self.as_mut_ptr(), offset, size) } } pub fn dump(&self, size: Option) -> Dump { @@ -385,7 +379,7 @@ impl<'a, T> Eq for MemoryMap<'a, T> {} impl<'a, T> Drop for MemoryMap<'a, T> { fn drop(&mut self) { unsafe { - gst_sys::gst_memory_unmap(self.memory.as_mut_ptr(), &mut self.map_info); + ffi::gst_memory_unmap(self.memory.as_mut_ptr(), &mut self.map_info); } } } @@ -409,7 +403,7 @@ impl MappedMemory { pub fn into_memory(mut self) -> Memory { let memory = self.memory.take().unwrap(); unsafe { - gst_sys::gst_memory_unmap(memory.as_mut_ptr(), &mut self.map_info); + ffi::gst_memory_unmap(memory.as_mut_ptr(), &mut self.map_info); } memory @@ -452,7 +446,7 @@ impl Drop for MappedMemory { fn drop(&mut self) { if let Some(ref memory) = self.memory { unsafe { - gst_sys::gst_memory_unmap(memory.as_mut_ptr(), &mut self.map_info); + ffi::gst_memory_unmap(memory.as_mut_ptr(), &mut self.map_info); } } } @@ -515,15 +509,15 @@ impl<'a> fmt::Debug for Dump<'a> { mod tests { #[test] fn test_dump() { - ::init().unwrap(); + crate::init().unwrap(); - let mem = ::Memory::from_slice(vec![1, 2, 3, 4]); + let mem = crate::Memory::from_slice(vec![1, 2, 3, 4]); println!("{}", mem.dump(Some(mem.get_size()))); - let mem = ::Memory::from_slice(vec![1, 2, 3, 4]); + let mem = crate::Memory::from_slice(vec![1, 2, 3, 4]); println!("{:?}", mem.dump(Some(2))); - let mem = ::Memory::from_slice(vec![0; 64]); + let mem = crate::Memory::from_slice(vec![0; 64]); dbg!(mem.dump(None)); } } diff --git a/gstreamer/src/message.rs b/gstreamer/src/message.rs index 1cb854d61..3e754794b 100644 --- a/gstreamer/src/message.rs +++ b/gstreamer/src/message.rs @@ -6,15 +6,14 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use gst_sys; -use structure::*; -use GenericFormattedValue; -use GroupId; -use GstObjectExt; -use MessageType; -use Object; -use Seqnum; -use TagList; +use crate::structure::*; +use crate::GenericFormattedValue; +use crate::GroupId; +use crate::GstObjectExt; +use crate::MessageType; +use crate::Object; +use crate::Seqnum; +use crate::TagList; use std::ffi::CStr; use std::fmt; @@ -23,14 +22,13 @@ use std::num::NonZeroU32; use std::ops::Deref; use std::ptr; -use glib; use glib::translate::{from_glib, from_glib_full, from_glib_none, mut_override, ToGlib, ToGlibPtr}; use glib::value::ToSendValue; use glib::Cast; use glib::IsA; -gst_define_mini_object_wrapper!(Message, MessageRef, gst_sys::GstMessage, || { - gst_sys::gst_message_get_type() +gst_define_mini_object_wrapper!(Message, MessageRef, ffi::GstMessage, || { + ffi::gst_message_get_type() }); impl MessageRef { @@ -40,7 +38,7 @@ impl MessageRef { pub fn get_seqnum(&self) -> Seqnum { unsafe { - let seqnum = gst_sys::gst_message_get_seqnum(self.as_mut_ptr()); + let seqnum = ffi::gst_message_get_seqnum(self.as_mut_ptr()); if seqnum == 0 { // seqnum for this message is invalid. This can happen with buggy elements @@ -48,8 +46,8 @@ impl MessageRef { // As a workaround, let's generate an unused valid seqnum. let next = Seqnum::next(); - ::gst_warning!( - ::CAT_RUST, + crate::gst_warning!( + crate::CAT_RUST, "get_seqnum detected invalid seqnum, returning next {:?}", next ); @@ -63,7 +61,7 @@ impl MessageRef { pub fn get_structure(&self) -> Option<&StructureRef> { unsafe { - let structure = gst_sys::gst_message_get_structure(self.as_mut_ptr()); + let structure = ffi::gst_message_get_structure(self.as_mut_ptr()); if structure.is_null() { None } else { @@ -76,53 +74,51 @@ impl MessageRef { let type_ = unsafe { (*self.as_ptr()).type_ }; match type_ { - gst_sys::GST_MESSAGE_EOS => MessageView::Eos(Eos(self)), - gst_sys::GST_MESSAGE_ERROR => MessageView::Error(Error(self)), - gst_sys::GST_MESSAGE_WARNING => MessageView::Warning(Warning(self)), - gst_sys::GST_MESSAGE_INFO => MessageView::Info(Info(self)), - gst_sys::GST_MESSAGE_TAG => MessageView::Tag(Tag(self)), - gst_sys::GST_MESSAGE_BUFFERING => MessageView::Buffering(Buffering(self)), - gst_sys::GST_MESSAGE_STATE_CHANGED => MessageView::StateChanged(StateChanged(self)), - gst_sys::GST_MESSAGE_STATE_DIRTY => MessageView::StateDirty(StateDirty(self)), - gst_sys::GST_MESSAGE_STEP_DONE => MessageView::StepDone(StepDone(self)), - gst_sys::GST_MESSAGE_CLOCK_PROVIDE => MessageView::ClockProvide(ClockProvide(self)), - gst_sys::GST_MESSAGE_CLOCK_LOST => MessageView::ClockLost(ClockLost(self)), - gst_sys::GST_MESSAGE_NEW_CLOCK => MessageView::NewClock(NewClock(self)), - gst_sys::GST_MESSAGE_STRUCTURE_CHANGE => { + ffi::GST_MESSAGE_EOS => MessageView::Eos(Eos(self)), + ffi::GST_MESSAGE_ERROR => MessageView::Error(Error(self)), + ffi::GST_MESSAGE_WARNING => MessageView::Warning(Warning(self)), + ffi::GST_MESSAGE_INFO => MessageView::Info(Info(self)), + ffi::GST_MESSAGE_TAG => MessageView::Tag(Tag(self)), + ffi::GST_MESSAGE_BUFFERING => MessageView::Buffering(Buffering(self)), + ffi::GST_MESSAGE_STATE_CHANGED => MessageView::StateChanged(StateChanged(self)), + ffi::GST_MESSAGE_STATE_DIRTY => MessageView::StateDirty(StateDirty(self)), + ffi::GST_MESSAGE_STEP_DONE => MessageView::StepDone(StepDone(self)), + ffi::GST_MESSAGE_CLOCK_PROVIDE => MessageView::ClockProvide(ClockProvide(self)), + ffi::GST_MESSAGE_CLOCK_LOST => MessageView::ClockLost(ClockLost(self)), + ffi::GST_MESSAGE_NEW_CLOCK => MessageView::NewClock(NewClock(self)), + ffi::GST_MESSAGE_STRUCTURE_CHANGE => { MessageView::StructureChange(StructureChange(self)) } - gst_sys::GST_MESSAGE_STREAM_STATUS => MessageView::StreamStatus(StreamStatus(self)), - gst_sys::GST_MESSAGE_APPLICATION => MessageView::Application(Application(self)), - gst_sys::GST_MESSAGE_ELEMENT => MessageView::Element(Element(self)), - gst_sys::GST_MESSAGE_SEGMENT_START => MessageView::SegmentStart(SegmentStart(self)), - gst_sys::GST_MESSAGE_SEGMENT_DONE => MessageView::SegmentDone(SegmentDone(self)), - gst_sys::GST_MESSAGE_DURATION_CHANGED => { + ffi::GST_MESSAGE_STREAM_STATUS => MessageView::StreamStatus(StreamStatus(self)), + ffi::GST_MESSAGE_APPLICATION => MessageView::Application(Application(self)), + ffi::GST_MESSAGE_ELEMENT => MessageView::Element(Element(self)), + ffi::GST_MESSAGE_SEGMENT_START => MessageView::SegmentStart(SegmentStart(self)), + ffi::GST_MESSAGE_SEGMENT_DONE => MessageView::SegmentDone(SegmentDone(self)), + ffi::GST_MESSAGE_DURATION_CHANGED => { MessageView::DurationChanged(DurationChanged(self)) } - gst_sys::GST_MESSAGE_LATENCY => MessageView::Latency(Latency(self)), - gst_sys::GST_MESSAGE_ASYNC_START => MessageView::AsyncStart(AsyncStart(self)), - gst_sys::GST_MESSAGE_ASYNC_DONE => MessageView::AsyncDone(AsyncDone(self)), - gst_sys::GST_MESSAGE_REQUEST_STATE => MessageView::RequestState(RequestState(self)), - gst_sys::GST_MESSAGE_STEP_START => MessageView::StepStart(StepStart(self)), - gst_sys::GST_MESSAGE_QOS => MessageView::Qos(Qos(self)), - gst_sys::GST_MESSAGE_PROGRESS => MessageView::Progress(Progress(self)), - gst_sys::GST_MESSAGE_TOC => MessageView::Toc(Toc(self)), - gst_sys::GST_MESSAGE_RESET_TIME => MessageView::ResetTime(ResetTime(self)), - gst_sys::GST_MESSAGE_STREAM_START => MessageView::StreamStart(StreamStart(self)), - gst_sys::GST_MESSAGE_NEED_CONTEXT => MessageView::NeedContext(NeedContext(self)), - gst_sys::GST_MESSAGE_HAVE_CONTEXT => MessageView::HaveContext(HaveContext(self)), - gst_sys::GST_MESSAGE_DEVICE_ADDED => MessageView::DeviceAdded(DeviceAdded(self)), - gst_sys::GST_MESSAGE_DEVICE_REMOVED => MessageView::DeviceRemoved(DeviceRemoved(self)), - gst_sys::GST_MESSAGE_PROPERTY_NOTIFY => { - MessageView::PropertyNotify(PropertyNotify(self)) - } - gst_sys::GST_MESSAGE_STREAM_COLLECTION => { + ffi::GST_MESSAGE_LATENCY => MessageView::Latency(Latency(self)), + ffi::GST_MESSAGE_ASYNC_START => MessageView::AsyncStart(AsyncStart(self)), + ffi::GST_MESSAGE_ASYNC_DONE => MessageView::AsyncDone(AsyncDone(self)), + ffi::GST_MESSAGE_REQUEST_STATE => MessageView::RequestState(RequestState(self)), + ffi::GST_MESSAGE_STEP_START => MessageView::StepStart(StepStart(self)), + ffi::GST_MESSAGE_QOS => MessageView::Qos(Qos(self)), + ffi::GST_MESSAGE_PROGRESS => MessageView::Progress(Progress(self)), + ffi::GST_MESSAGE_TOC => MessageView::Toc(Toc(self)), + ffi::GST_MESSAGE_RESET_TIME => MessageView::ResetTime(ResetTime(self)), + ffi::GST_MESSAGE_STREAM_START => MessageView::StreamStart(StreamStart(self)), + ffi::GST_MESSAGE_NEED_CONTEXT => MessageView::NeedContext(NeedContext(self)), + ffi::GST_MESSAGE_HAVE_CONTEXT => MessageView::HaveContext(HaveContext(self)), + ffi::GST_MESSAGE_DEVICE_ADDED => MessageView::DeviceAdded(DeviceAdded(self)), + ffi::GST_MESSAGE_DEVICE_REMOVED => MessageView::DeviceRemoved(DeviceRemoved(self)), + ffi::GST_MESSAGE_PROPERTY_NOTIFY => MessageView::PropertyNotify(PropertyNotify(self)), + ffi::GST_MESSAGE_STREAM_COLLECTION => { MessageView::StreamCollection(StreamCollection(self)) } - gst_sys::GST_MESSAGE_STREAMS_SELECTED => { + ffi::GST_MESSAGE_STREAMS_SELECTED => { MessageView::StreamsSelected(StreamsSelected(self)) } - gst_sys::GST_MESSAGE_DEVICE_CHANGED => MessageView::DeviceChanged(DeviceChanged(self)), + ffi::GST_MESSAGE_DEVICE_CHANGED => MessageView::DeviceChanged(DeviceChanged(self)), _ => MessageView::Other, } } @@ -145,7 +141,7 @@ impl fmt::Debug for MessageRef { // emitted a `Message` with an invalid `seqnum`. // We want to help the user find out there is something wrong here, // so they can investigate the origin. - let seqnum = unsafe { gst_sys::gst_message_get_seqnum(self.as_mut_ptr()) }; + let seqnum = unsafe { ffi::gst_message_get_seqnum(self.as_mut_ptr()) }; let seqnum = if seqnum != 0 { &seqnum as &dyn fmt::Debug } else { @@ -155,7 +151,7 @@ impl fmt::Debug for MessageRef { f.debug_struct("Message") .field("ptr", unsafe { &self.as_ptr() }) .field("type", &unsafe { - let type_ = gst_sys::gst_message_type_get_name((*self.as_ptr()).type_); + let type_ = ffi::gst_message_type_get_name((*self.as_ptr()).type_); CStr::from_ptr(type_).to_str().unwrap() }) .field("seqnum", seqnum) @@ -255,7 +251,7 @@ impl<'a> Error<'a> { unsafe { let mut error = ptr::null_mut(); - gst_sys::gst_message_parse_error(self.as_mut_ptr(), &mut error, ptr::null_mut()); + ffi::gst_message_parse_error(self.as_mut_ptr(), &mut error, ptr::null_mut()); from_glib_full(error) } @@ -265,7 +261,7 @@ impl<'a> Error<'a> { unsafe { let mut debug = ptr::null_mut(); - gst_sys::gst_message_parse_error(self.as_mut_ptr(), ptr::null_mut(), &mut debug); + ffi::gst_message_parse_error(self.as_mut_ptr(), ptr::null_mut(), &mut debug); from_glib_full(debug) } @@ -277,7 +273,7 @@ impl<'a> Error<'a> { unsafe { let mut details = ptr::null(); - gst_sys::gst_message_parse_error_details(self.as_mut_ptr(), &mut details); + ffi::gst_message_parse_error_details(self.as_mut_ptr(), &mut details); if details.is_null() { None @@ -305,7 +301,7 @@ impl<'a> Warning<'a> { unsafe { let mut error = ptr::null_mut(); - gst_sys::gst_message_parse_warning(self.as_mut_ptr(), &mut error, ptr::null_mut()); + ffi::gst_message_parse_warning(self.as_mut_ptr(), &mut error, ptr::null_mut()); from_glib_full(error) } @@ -315,7 +311,7 @@ impl<'a> Warning<'a> { unsafe { let mut debug = ptr::null_mut(); - gst_sys::gst_message_parse_warning(self.as_mut_ptr(), ptr::null_mut(), &mut debug); + ffi::gst_message_parse_warning(self.as_mut_ptr(), ptr::null_mut(), &mut debug); from_glib_full(debug) } @@ -327,7 +323,7 @@ impl<'a> Warning<'a> { unsafe { let mut details = ptr::null(); - gst_sys::gst_message_parse_error_details(self.as_mut_ptr(), &mut details); + ffi::gst_message_parse_error_details(self.as_mut_ptr(), &mut details); if details.is_null() { None @@ -355,7 +351,7 @@ impl<'a> Info<'a> { unsafe { let mut error = ptr::null_mut(); - gst_sys::gst_message_parse_info(self.as_mut_ptr(), &mut error, ptr::null_mut()); + ffi::gst_message_parse_info(self.as_mut_ptr(), &mut error, ptr::null_mut()); from_glib_full(error) } @@ -365,7 +361,7 @@ impl<'a> Info<'a> { unsafe { let mut debug = ptr::null_mut(); - gst_sys::gst_message_parse_info(self.as_mut_ptr(), ptr::null_mut(), &mut debug); + ffi::gst_message_parse_info(self.as_mut_ptr(), ptr::null_mut(), &mut debug); from_glib_full(debug) } @@ -377,7 +373,7 @@ impl<'a> Info<'a> { unsafe { let mut details = ptr::null(); - gst_sys::gst_message_parse_error_details(self.as_mut_ptr(), &mut details); + ffi::gst_message_parse_error_details(self.as_mut_ptr(), &mut details); if details.is_null() { None @@ -404,7 +400,7 @@ impl<'a> Tag<'a> { pub fn get_tags(&self) -> TagList { unsafe { let mut tags = ptr::null_mut(); - gst_sys::gst_message_parse_tag(self.as_mut_ptr(), &mut tags); + ffi::gst_message_parse_tag(self.as_mut_ptr(), &mut tags); from_glib_full(tags) } } @@ -426,19 +422,19 @@ impl<'a> Buffering<'a> { pub fn get_percent(&self) -> i32 { unsafe { let mut p = mem::MaybeUninit::uninit(); - gst_sys::gst_message_parse_buffering(self.as_mut_ptr(), p.as_mut_ptr()); + ffi::gst_message_parse_buffering(self.as_mut_ptr(), p.as_mut_ptr()); p.assume_init() } } - pub fn get_buffering_stats(&self) -> (::BufferingMode, i32, i32, i64) { + pub fn get_buffering_stats(&self) -> (crate::BufferingMode, i32, i32, i64) { unsafe { let mut mode = mem::MaybeUninit::uninit(); let mut avg_in = mem::MaybeUninit::uninit(); let mut avg_out = mem::MaybeUninit::uninit(); let mut buffering_left = mem::MaybeUninit::uninit(); - gst_sys::gst_message_parse_buffering_stats( + ffi::gst_message_parse_buffering_stats( self.as_mut_ptr(), mode.as_mut_ptr(), avg_in.as_mut_ptr(), @@ -459,21 +455,25 @@ impl<'a> Buffering<'a> { declare_concrete_message!(StateChanged); impl<'a> StateChanged<'a> { #[allow(clippy::new_ret_no_self)] - pub fn new(old: ::State, new: ::State, pending: ::State) -> Message { + pub fn new(old: crate::State, new: crate::State, pending: crate::State) -> Message { skip_assert_initialized!(); Self::builder(old, new, pending).build() } - pub fn builder(old: ::State, new: ::State, pending: ::State) -> StateChangedBuilder<'a> { + pub fn builder( + old: crate::State, + new: crate::State, + pending: crate::State, + ) -> StateChangedBuilder<'a> { assert_initialized_main_thread!(); StateChangedBuilder::new(old, new, pending) } - pub fn get_old(&self) -> ::State { + pub fn get_old(&self) -> crate::State { unsafe { let mut state = mem::MaybeUninit::uninit(); - gst_sys::gst_message_parse_state_changed( + ffi::gst_message_parse_state_changed( self.as_mut_ptr(), state.as_mut_ptr(), ptr::null_mut(), @@ -484,11 +484,11 @@ impl<'a> StateChanged<'a> { } } - pub fn get_current(&self) -> ::State { + pub fn get_current(&self) -> crate::State { unsafe { let mut state = mem::MaybeUninit::uninit(); - gst_sys::gst_message_parse_state_changed( + ffi::gst_message_parse_state_changed( self.as_mut_ptr(), ptr::null_mut(), state.as_mut_ptr(), @@ -499,11 +499,11 @@ impl<'a> StateChanged<'a> { } } - pub fn get_pending(&self) -> ::State { + pub fn get_pending(&self) -> crate::State { unsafe { let mut state = mem::MaybeUninit::uninit(); - gst_sys::gst_message_parse_state_changed( + ffi::gst_message_parse_state_changed( self.as_mut_ptr(), ptr::null_mut(), ptr::null_mut(), @@ -590,7 +590,7 @@ impl<'a> StepDone<'a> { let mut duration = mem::MaybeUninit::uninit(); let mut eos = mem::MaybeUninit::uninit(); - gst_sys::gst_message_parse_step_done( + ffi::gst_message_parse_step_done( self.as_mut_ptr(), format.as_mut_ptr(), amount.as_mut_ptr(), @@ -622,25 +622,21 @@ impl<'a> StepDone<'a> { declare_concrete_message!(ClockProvide); impl<'a> ClockProvide<'a> { #[allow(clippy::new_ret_no_self)] - pub fn new(clock: &::Clock, ready: bool) -> Message { + pub fn new(clock: &crate::Clock, ready: bool) -> Message { skip_assert_initialized!(); Self::builder(clock, ready).build() } - pub fn builder(clock: &::Clock, ready: bool) -> ClockProvideBuilder { + pub fn builder(clock: &crate::Clock, ready: bool) -> ClockProvideBuilder { assert_initialized_main_thread!(); ClockProvideBuilder::new(clock, ready) } - pub fn get_clock(&self) -> Option<::Clock> { + pub fn get_clock(&self) -> Option { let mut clock = ptr::null_mut(); unsafe { - gst_sys::gst_message_parse_clock_provide( - self.as_mut_ptr(), - &mut clock, - ptr::null_mut(), - ); + ffi::gst_message_parse_clock_provide(self.as_mut_ptr(), &mut clock, ptr::null_mut()); from_glib_none(clock) } @@ -650,7 +646,7 @@ impl<'a> ClockProvide<'a> { unsafe { let mut ready = mem::MaybeUninit::uninit(); - gst_sys::gst_message_parse_clock_provide( + ffi::gst_message_parse_clock_provide( self.as_mut_ptr(), ptr::null_mut(), ready.as_mut_ptr(), @@ -664,21 +660,21 @@ impl<'a> ClockProvide<'a> { declare_concrete_message!(ClockLost); impl<'a> ClockLost<'a> { #[allow(clippy::new_ret_no_self)] - pub fn new(clock: &::Clock) -> Message { + pub fn new(clock: &crate::Clock) -> Message { skip_assert_initialized!(); Self::builder(clock).build() } - pub fn builder(clock: &::Clock) -> ClockLostBuilder { + pub fn builder(clock: &crate::Clock) -> ClockLostBuilder { assert_initialized_main_thread!(); ClockLostBuilder::new(clock) } - pub fn get_clock(&self) -> Option<::Clock> { + pub fn get_clock(&self) -> Option { let mut clock = ptr::null_mut(); unsafe { - gst_sys::gst_message_parse_clock_lost(self.as_mut_ptr(), &mut clock); + ffi::gst_message_parse_clock_lost(self.as_mut_ptr(), &mut clock); from_glib_none(clock) } @@ -688,21 +684,21 @@ impl<'a> ClockLost<'a> { declare_concrete_message!(NewClock); impl<'a> NewClock<'a> { #[allow(clippy::new_ret_no_self)] - pub fn new(clock: &::Clock) -> Message { + pub fn new(clock: &crate::Clock) -> Message { skip_assert_initialized!(); Self::builder(clock).build() } - pub fn builder(clock: &::Clock) -> NewClockBuilder { + pub fn builder(clock: &crate::Clock) -> NewClockBuilder { assert_initialized_main_thread!(); NewClockBuilder::new(clock) } - pub fn get_clock(&self) -> Option<::Clock> { + pub fn get_clock(&self) -> Option { let mut clock = ptr::null_mut(); unsafe { - gst_sys::gst_message_parse_new_clock(self.as_mut_ptr(), &mut clock); + ffi::gst_message_parse_new_clock(self.as_mut_ptr(), &mut clock); from_glib_none(clock) } @@ -712,27 +708,27 @@ impl<'a> NewClock<'a> { declare_concrete_message!(StructureChange); impl<'a> StructureChange<'a> { #[allow(clippy::new_ret_no_self)] - pub fn new(type_: ::StructureChangeType, owner: &::Element, busy: bool) -> Message { + pub fn new(type_: crate::StructureChangeType, owner: &crate::Element, busy: bool) -> Message { skip_assert_initialized!(); Self::builder(type_, owner, busy).build() } pub fn builder( - type_: ::StructureChangeType, - owner: &::Element, + type_: crate::StructureChangeType, + owner: &crate::Element, busy: bool, ) -> StructureChangeBuilder { assert_initialized_main_thread!(); StructureChangeBuilder::new(type_, owner, busy) } - pub fn get(&self) -> (::StructureChangeType, ::Element, bool) { + pub fn get(&self) -> (crate::StructureChangeType, crate::Element, bool) { unsafe { let mut type_ = mem::MaybeUninit::uninit(); let mut owner = ptr::null_mut(); let mut busy = mem::MaybeUninit::uninit(); - gst_sys::gst_message_parse_structure_change( + ffi::gst_message_parse_structure_change( self.as_mut_ptr(), type_.as_mut_ptr(), &mut owner, @@ -751,26 +747,22 @@ impl<'a> StructureChange<'a> { declare_concrete_message!(StreamStatus); impl<'a> StreamStatus<'a> { #[allow(clippy::new_ret_no_self)] - pub fn new(type_: ::StreamStatusType, owner: &::Element) -> Message { + pub fn new(type_: crate::StreamStatusType, owner: &crate::Element) -> Message { skip_assert_initialized!(); Self::builder(type_, owner).build() } - pub fn builder(type_: ::StreamStatusType, owner: &::Element) -> StreamStatusBuilder { + pub fn builder(type_: crate::StreamStatusType, owner: &crate::Element) -> StreamStatusBuilder { assert_initialized_main_thread!(); StreamStatusBuilder::new(type_, owner) } - pub fn get(&self) -> (::StreamStatusType, ::Element) { + pub fn get(&self) -> (crate::StreamStatusType, crate::Element) { unsafe { let mut type_ = mem::MaybeUninit::uninit(); let mut owner = ptr::null_mut(); - gst_sys::gst_message_parse_stream_status( - self.as_mut_ptr(), - type_.as_mut_ptr(), - &mut owner, - ); + ffi::gst_message_parse_stream_status(self.as_mut_ptr(), type_.as_mut_ptr(), &mut owner); (from_glib(type_.assume_init()), from_glib_none(owner)) } @@ -778,7 +770,7 @@ impl<'a> StreamStatus<'a> { pub fn get_stream_status_object(&self) -> Option { unsafe { - let value = gst_sys::gst_message_get_stream_status_object(self.as_mut_ptr()); + let value = ffi::gst_message_get_stream_status_object(self.as_mut_ptr()); from_glib_none(value) } @@ -788,12 +780,12 @@ impl<'a> StreamStatus<'a> { declare_concrete_message!(Application); impl<'a> Application<'a> { #[allow(clippy::new_ret_no_self)] - pub fn new(structure: ::Structure) -> Message { + pub fn new(structure: crate::Structure) -> Message { skip_assert_initialized!(); Self::builder(structure).build() } - pub fn builder(structure: ::Structure) -> ApplicationBuilder<'a> { + pub fn builder(structure: crate::Structure) -> ApplicationBuilder<'a> { assert_initialized_main_thread!(); ApplicationBuilder::new(structure) } @@ -802,12 +794,12 @@ impl<'a> Application<'a> { declare_concrete_message!(Element); impl<'a> Element<'a> { #[allow(clippy::new_ret_no_self)] - pub fn new(structure: ::Structure) -> Message { + pub fn new(structure: crate::Structure) -> Message { skip_assert_initialized!(); Self::builder(structure).build() } - pub fn builder(structure: ::Structure) -> ElementBuilder<'a> { + pub fn builder(structure: crate::Structure) -> ElementBuilder<'a> { assert_initialized_main_thread!(); ElementBuilder::new(structure) } @@ -832,7 +824,7 @@ impl<'a> SegmentStart<'a> { let mut format = mem::MaybeUninit::uninit(); let mut position = mem::MaybeUninit::uninit(); - gst_sys::gst_message_parse_segment_start( + ffi::gst_message_parse_segment_start( self.as_mut_ptr(), format.as_mut_ptr(), position.as_mut_ptr(), @@ -862,7 +854,7 @@ impl<'a> SegmentDone<'a> { let mut format = mem::MaybeUninit::uninit(); let mut position = mem::MaybeUninit::uninit(); - gst_sys::gst_message_parse_segment_done( + ffi::gst_message_parse_segment_done( self.as_mut_ptr(), format.as_mut_ptr(), position.as_mut_ptr(), @@ -918,21 +910,21 @@ impl<'a> AsyncStart<'a> { declare_concrete_message!(AsyncDone); impl<'a> AsyncDone<'a> { #[allow(clippy::new_ret_no_self)] - pub fn new(running_time: ::ClockTime) -> Message { + pub fn new(running_time: crate::ClockTime) -> Message { skip_assert_initialized!(); Self::builder(running_time).build() } - pub fn builder(running_time: ::ClockTime) -> AsyncDoneBuilder<'a> { + pub fn builder(running_time: crate::ClockTime) -> AsyncDoneBuilder<'a> { assert_initialized_main_thread!(); AsyncDoneBuilder::new(running_time) } - pub fn get_running_time(&self) -> ::ClockTime { + pub fn get_running_time(&self) -> crate::ClockTime { unsafe { let mut running_time = mem::MaybeUninit::uninit(); - gst_sys::gst_message_parse_async_done(self.as_mut_ptr(), running_time.as_mut_ptr()); + ffi::gst_message_parse_async_done(self.as_mut_ptr(), running_time.as_mut_ptr()); from_glib(running_time.assume_init()) } @@ -942,21 +934,21 @@ impl<'a> AsyncDone<'a> { declare_concrete_message!(RequestState); impl<'a> RequestState<'a> { #[allow(clippy::new_ret_no_self)] - pub fn new(state: ::State) -> Message { + pub fn new(state: crate::State) -> Message { skip_assert_initialized!(); Self::builder(state).build() } - pub fn builder(state: ::State) -> RequestStateBuilder<'a> { + pub fn builder(state: crate::State) -> RequestStateBuilder<'a> { assert_initialized_main_thread!(); RequestStateBuilder::new(state) } - pub fn get_requested_state(&self) -> ::State { + pub fn get_requested_state(&self) -> crate::State { unsafe { let mut state = mem::MaybeUninit::uninit(); - gst_sys::gst_message_parse_request_state(self.as_mut_ptr(), state.as_mut_ptr()); + ffi::gst_message_parse_request_state(self.as_mut_ptr(), state.as_mut_ptr()); from_glib(state.assume_init()) } @@ -997,7 +989,7 @@ impl<'a> StepStart<'a> { let mut flush = mem::MaybeUninit::uninit(); let mut intermediate = mem::MaybeUninit::uninit(); - gst_sys::gst_message_parse_step_start( + ffi::gst_message_parse_step_start( self.as_mut_ptr(), active.as_mut_ptr(), format.as_mut_ptr(), @@ -1026,10 +1018,10 @@ impl<'a> Qos<'a> { #[allow(clippy::new_ret_no_self)] pub fn new( live: bool, - running_time: ::ClockTime, - stream_time: ::ClockTime, - timestamp: ::ClockTime, - duration: ::ClockTime, + running_time: crate::ClockTime, + stream_time: crate::ClockTime, + timestamp: crate::ClockTime, + duration: crate::ClockTime, ) -> Message { skip_assert_initialized!(); Self::builder(live, running_time, stream_time, timestamp, duration).build() @@ -1037,16 +1029,24 @@ impl<'a> Qos<'a> { pub fn builder( live: bool, - running_time: ::ClockTime, - stream_time: ::ClockTime, - timestamp: ::ClockTime, - duration: ::ClockTime, + running_time: crate::ClockTime, + stream_time: crate::ClockTime, + timestamp: crate::ClockTime, + duration: crate::ClockTime, ) -> QosBuilder<'a> { assert_initialized_main_thread!(); QosBuilder::new(live, running_time, stream_time, timestamp, duration) } - pub fn get(&self) -> (bool, ::ClockTime, ::ClockTime, ::ClockTime, ::ClockTime) { + pub fn get( + &self, + ) -> ( + bool, + crate::ClockTime, + crate::ClockTime, + crate::ClockTime, + crate::ClockTime, + ) { unsafe { let mut live = mem::MaybeUninit::uninit(); let mut running_time = mem::MaybeUninit::uninit(); @@ -1054,7 +1054,7 @@ impl<'a> Qos<'a> { let mut timestamp = mem::MaybeUninit::uninit(); let mut duration = mem::MaybeUninit::uninit(); - gst_sys::gst_message_parse_qos( + ffi::gst_message_parse_qos( self.as_mut_ptr(), live.as_mut_ptr(), running_time.as_mut_ptr(), @@ -1079,7 +1079,7 @@ impl<'a> Qos<'a> { let mut proportion = mem::MaybeUninit::uninit(); let mut quality = mem::MaybeUninit::uninit(); - gst_sys::gst_message_parse_qos_values( + ffi::gst_message_parse_qos_values( self.as_mut_ptr(), jitter.as_mut_ptr(), proportion.as_mut_ptr(), @@ -1100,7 +1100,7 @@ impl<'a> Qos<'a> { let mut processed = mem::MaybeUninit::uninit(); let mut dropped = mem::MaybeUninit::uninit(); - gst_sys::gst_message_parse_qos_stats( + ffi::gst_message_parse_qos_stats( self.as_mut_ptr(), format.as_mut_ptr(), processed.as_mut_ptr(), @@ -1124,23 +1124,27 @@ impl<'a> Qos<'a> { declare_concrete_message!(Progress); impl<'a> Progress<'a> { #[allow(clippy::new_ret_no_self)] - pub fn new(type_: ::ProgressType, code: &'a str, text: &'a str) -> Message { + pub fn new(type_: crate::ProgressType, code: &'a str, text: &'a str) -> Message { skip_assert_initialized!(); Self::builder(type_, code, text).build() } - pub fn builder(type_: ::ProgressType, code: &'a str, text: &'a str) -> ProgressBuilder<'a> { + pub fn builder( + type_: crate::ProgressType, + code: &'a str, + text: &'a str, + ) -> ProgressBuilder<'a> { assert_initialized_main_thread!(); ProgressBuilder::new(type_, code, text) } - pub fn get(&self) -> (::ProgressType, &'a str, &'a str) { + pub fn get(&self) -> (crate::ProgressType, &'a str, &'a str) { unsafe { let mut type_ = mem::MaybeUninit::uninit(); let mut code = ptr::null_mut(); let mut text = ptr::null_mut(); - gst_sys::gst_message_parse_progress( + ffi::gst_message_parse_progress( self.as_mut_ptr(), type_.as_mut_ptr(), &mut code, @@ -1160,21 +1164,21 @@ impl<'a> Toc<'a> { // FIXME could use false for updated as default // Even better: use an enum for updated so that it is more explicit than true / false #[allow(clippy::new_ret_no_self)] - pub fn new(toc: &::Toc, updated: bool) -> Message { + pub fn new(toc: &crate::Toc, updated: bool) -> Message { skip_assert_initialized!(); Self::builder(toc, updated).build() } - pub fn builder(toc: &::Toc, updated: bool) -> TocBuilder { + pub fn builder(toc: &crate::Toc, updated: bool) -> TocBuilder { assert_initialized_main_thread!(); TocBuilder::new(toc, updated) } - pub fn get_toc(&self) -> (::Toc, bool) { + pub fn get_toc(&self) -> (crate::Toc, bool) { unsafe { let mut toc = ptr::null_mut(); let mut updated = mem::MaybeUninit::uninit(); - gst_sys::gst_message_parse_toc(self.as_mut_ptr(), &mut toc, updated.as_mut_ptr()); + ffi::gst_message_parse_toc(self.as_mut_ptr(), &mut toc, updated.as_mut_ptr()); (from_glib_full(toc), from_glib(updated.assume_init())) } } @@ -1183,21 +1187,21 @@ impl<'a> Toc<'a> { declare_concrete_message!(ResetTime); impl<'a> ResetTime<'a> { #[allow(clippy::new_ret_no_self)] - pub fn new(running_time: ::ClockTime) -> Message { + pub fn new(running_time: crate::ClockTime) -> Message { skip_assert_initialized!(); Self::builder(running_time).build() } - pub fn builder(running_time: ::ClockTime) -> ResetTimeBuilder<'a> { + pub fn builder(running_time: crate::ClockTime) -> ResetTimeBuilder<'a> { assert_initialized_main_thread!(); ResetTimeBuilder::new(running_time) } - pub fn get_running_time(&self) -> ::ClockTime { + pub fn get_running_time(&self) -> crate::ClockTime { unsafe { let mut running_time = mem::MaybeUninit::uninit(); - gst_sys::gst_message_parse_reset_time(self.as_mut_ptr(), running_time.as_mut_ptr()); + ffi::gst_message_parse_reset_time(self.as_mut_ptr(), running_time.as_mut_ptr()); from_glib(running_time.assume_init()) } @@ -1221,7 +1225,7 @@ impl<'a> StreamStart<'a> { unsafe { let mut group_id = mem::MaybeUninit::uninit(); - if from_glib(gst_sys::gst_message_parse_group_id( + if from_glib(ffi::gst_message_parse_group_id( self.as_mut_ptr(), group_id.as_mut_ptr(), )) { @@ -1255,7 +1259,7 @@ impl<'a> NeedContext<'a> { unsafe { let mut context_type = ptr::null(); - gst_sys::gst_message_parse_context_type(self.as_mut_ptr(), &mut context_type); + ffi::gst_message_parse_context_type(self.as_mut_ptr(), &mut context_type); CStr::from_ptr(context_type).to_str().unwrap() } @@ -1265,20 +1269,20 @@ impl<'a> NeedContext<'a> { declare_concrete_message!(HaveContext); impl<'a> HaveContext<'a> { #[allow(clippy::new_ret_no_self)] - pub fn new(context: ::Context) -> Message { + pub fn new(context: crate::Context) -> Message { skip_assert_initialized!(); Self::builder(context).build() } - pub fn builder(context: ::Context) -> HaveContextBuilder<'a> { + pub fn builder(context: crate::Context) -> HaveContextBuilder<'a> { assert_initialized_main_thread!(); HaveContextBuilder::new(context) } - pub fn get_context(&self) -> ::Context { + pub fn get_context(&self) -> crate::Context { unsafe { let mut context = ptr::null_mut(); - gst_sys::gst_message_parse_have_context(self.as_mut_ptr(), &mut context); + ffi::gst_message_parse_have_context(self.as_mut_ptr(), &mut context); from_glib_full(context) } } @@ -1287,21 +1291,21 @@ impl<'a> HaveContext<'a> { declare_concrete_message!(DeviceAdded); impl<'a> DeviceAdded<'a> { #[allow(clippy::new_ret_no_self)] - pub fn new(device: &::Device) -> Message { + pub fn new(device: &crate::Device) -> Message { skip_assert_initialized!(); Self::builder(device).build() } - pub fn builder(device: &::Device) -> DeviceAddedBuilder { + pub fn builder(device: &crate::Device) -> DeviceAddedBuilder { assert_initialized_main_thread!(); DeviceAddedBuilder::new(device) } - pub fn get_device(&self) -> ::Device { + pub fn get_device(&self) -> crate::Device { unsafe { let mut device = ptr::null_mut(); - gst_sys::gst_message_parse_device_added(self.as_mut_ptr(), &mut device); + ffi::gst_message_parse_device_added(self.as_mut_ptr(), &mut device); from_glib_full(device) } @@ -1311,21 +1315,21 @@ impl<'a> DeviceAdded<'a> { declare_concrete_message!(DeviceRemoved); impl<'a> DeviceRemoved<'a> { #[allow(clippy::new_ret_no_self)] - pub fn new(device: &::Device) -> Message { + pub fn new(device: &crate::Device) -> Message { skip_assert_initialized!(); Self::builder(device).build() } - pub fn builder(device: &::Device) -> DeviceRemovedBuilder { + pub fn builder(device: &crate::Device) -> DeviceRemovedBuilder { assert_initialized_main_thread!(); DeviceRemovedBuilder::new(device) } - pub fn get_device(&self) -> ::Device { + pub fn get_device(&self) -> crate::Device { unsafe { let mut device = ptr::null_mut(); - gst_sys::gst_message_parse_device_removed(self.as_mut_ptr(), &mut device); + ffi::gst_message_parse_device_removed(self.as_mut_ptr(), &mut device); from_glib_full(device) } @@ -1357,7 +1361,7 @@ impl<'a> PropertyNotify<'a> { let mut property_name = ptr::null(); let mut value = ptr::null(); - gst_sys::gst_message_parse_property_notify( + ffi::gst_message_parse_property_notify( self.as_mut_ptr(), &mut object, &mut property_name, @@ -1382,25 +1386,25 @@ impl<'a> StreamCollection<'a> { #[cfg(any(feature = "v1_10", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))] #[allow(clippy::new_ret_no_self)] - pub fn new(collection: &::StreamCollection) -> Message { + pub fn new(collection: &crate::StreamCollection) -> Message { skip_assert_initialized!(); Self::builder(collection).build() } #[cfg(any(feature = "v1_10", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))] - pub fn builder(collection: &::StreamCollection) -> StreamCollectionBuilder { + pub fn builder(collection: &crate::StreamCollection) -> StreamCollectionBuilder { assert_initialized_main_thread!(); StreamCollectionBuilder::new(collection) } #[cfg(any(feature = "v1_10", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))] - pub fn get_stream_collection(&self) -> ::StreamCollection { + pub fn get_stream_collection(&self) -> crate::StreamCollection { unsafe { let mut collection = ptr::null_mut(); - gst_sys::gst_message_parse_stream_collection(self.as_mut_ptr(), &mut collection); + ffi::gst_message_parse_stream_collection(self.as_mut_ptr(), &mut collection); from_glib_full(collection) } @@ -1412,25 +1416,25 @@ impl<'a> StreamsSelected<'a> { #[cfg(any(feature = "v1_10", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))] #[allow(clippy::new_ret_no_self)] - pub fn new(collection: &::StreamCollection) -> Message { + pub fn new(collection: &crate::StreamCollection) -> Message { skip_assert_initialized!(); Self::builder(collection).build() } #[cfg(any(feature = "v1_10", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))] - pub fn builder(collection: &::StreamCollection) -> StreamsSelectedBuilder { + pub fn builder(collection: &crate::StreamCollection) -> StreamsSelectedBuilder { assert_initialized_main_thread!(); StreamsSelectedBuilder::new(collection) } #[cfg(any(feature = "v1_10", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))] - pub fn get_stream_collection(&self) -> ::StreamCollection { + pub fn get_stream_collection(&self) -> crate::StreamCollection { unsafe { let mut collection = ptr::null_mut(); - gst_sys::gst_message_parse_streams_selected(self.as_mut_ptr(), &mut collection); + ffi::gst_message_parse_streams_selected(self.as_mut_ptr(), &mut collection); from_glib_full(collection) } @@ -1438,13 +1442,13 @@ impl<'a> StreamsSelected<'a> { #[cfg(any(feature = "v1_10", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))] - pub fn get_streams(&self) -> Vec<::Stream> { + pub fn get_streams(&self) -> Vec { unsafe { - let n = gst_sys::gst_message_streams_selected_get_size(self.as_mut_ptr()); + let n = ffi::gst_message_streams_selected_get_size(self.as_mut_ptr()); (0..n) .map(|i| { - from_glib_full(gst_sys::gst_message_streams_selected_get_stream( + from_glib_full(ffi::gst_message_streams_selected_get_stream( self.as_mut_ptr(), i, )) @@ -1475,7 +1479,7 @@ impl<'a> Redirect<'a> { #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))] pub fn get_entries(&self) -> Vec<(&str, Option, Option<&StructureRef>)> { unsafe { - let n = gst_sys::gst_message_get_num_redirect_entries(self.as_mut_ptr()); + let n = ffi::gst_message_get_num_redirect_entries(self.as_mut_ptr()); (0..n) .map(|i| { @@ -1483,7 +1487,7 @@ impl<'a> Redirect<'a> { let mut tags = ptr::null_mut(); let mut structure = ptr::null(); - gst_sys::gst_message_parse_redirect_entry( + ffi::gst_message_parse_redirect_entry( self.as_mut_ptr(), i, &mut location, @@ -1513,26 +1517,29 @@ impl<'a> DeviceChanged<'a> { #[cfg(any(feature = "v1_16", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_16")))] #[allow(clippy::new_ret_no_self)] - pub fn new(device: &'a ::Device, changed_device: &'a ::Device) -> Message { + pub fn new(device: &'a crate::Device, changed_device: &'a crate::Device) -> Message { skip_assert_initialized!(); Self::builder(device, changed_device).build() } #[cfg(any(feature = "v1_16", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_16")))] - pub fn builder(device: &'a ::Device, changed_device: &'a ::Device) -> DeviceChangedBuilder<'a> { + pub fn builder( + device: &'a crate::Device, + changed_device: &'a crate::Device, + ) -> DeviceChangedBuilder<'a> { assert_initialized_main_thread!(); DeviceChangedBuilder::new(device, changed_device) } #[cfg(any(feature = "v1_16", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_16")))] - pub fn get_device_changed(&self) -> (::Device, ::Device) { + pub fn get_device_changed(&self) -> (crate::Device, crate::Device) { unsafe { let mut device = ptr::null_mut(); let mut changed_device = ptr::null_mut(); - gst_sys::gst_message_parse_device_changed( + ffi::gst_message_parse_device_changed( self.as_mut_ptr(), &mut device, &mut changed_device, @@ -1622,12 +1629,12 @@ macro_rules! message_builder_generic_impl { let src = self.builder.src.to_glib_none().0; let msg = $new_fn(&mut self, src); if let Some(seqnum) = self.builder.seqnum { - gst_sys::gst_message_set_seqnum(msg, seqnum.0.get()); + ffi::gst_message_set_seqnum(msg, seqnum.0.get()); } #[cfg(any(feature = "v1_14", feature = "dox"))] if !self.builder.other_fields.is_empty() { - let structure = gst_sys::gst_message_writable_structure(msg); + let structure = ffi::gst_message_writable_structure(msg); if !structure.is_null() { let structure = StructureRef::from_glib_borrow_mut(structure as *mut _); @@ -1656,15 +1663,15 @@ impl<'a> EosBuilder<'a> { } } - message_builder_generic_impl!(|_, src| gst_sys::gst_message_new_eos(src)); + message_builder_generic_impl!(|_, src| ffi::gst_message_new_eos(src)); } pub trait MessageErrorDomain: glib::error::ErrorDomain {} -impl MessageErrorDomain for ::CoreError {} -impl MessageErrorDomain for ::ResourceError {} -impl MessageErrorDomain for ::StreamError {} -impl MessageErrorDomain for ::LibraryError {} +impl MessageErrorDomain for crate::CoreError {} +impl MessageErrorDomain for crate::ResourceError {} +impl MessageErrorDomain for crate::StreamError {} +impl MessageErrorDomain for crate::LibraryError {} pub struct ErrorBuilder<'a, T> { builder: MessageBuilder<'a>, @@ -1704,7 +1711,7 @@ impl<'a, T: MessageErrorDomain> ErrorBuilder<'a, T> { } message_builder_generic_impl!(|s: &mut Self, src| { - cfg_if! { + cfg_if::cfg_if! { if #[cfg(any(feature = "v1_10", feature = "dox"))] { let details = match s.details.take() { None => ptr::null_mut(), @@ -1713,7 +1720,7 @@ impl<'a, T: MessageErrorDomain> ErrorBuilder<'a, T> { let error = glib::Error::new(s.error, s.message); - gst_sys::gst_message_new_error_with_details( + ffi::gst_message_new_error_with_details( src, mut_override(error.to_glib_none().0), s.debug.to_glib_none().0, @@ -1722,7 +1729,7 @@ impl<'a, T: MessageErrorDomain> ErrorBuilder<'a, T> { } else { let error = glib::Error::new(s.error, s.message); - gst_sys::gst_message_new_error( + ffi::gst_message_new_error( src, mut_override(error.to_glib_none().0), s.debug.to_glib_none().0, @@ -1770,7 +1777,7 @@ impl<'a, T: MessageErrorDomain> WarningBuilder<'a, T> { } message_builder_generic_impl!(|s: &mut Self, src| { - cfg_if! { + cfg_if::cfg_if! { if #[cfg(any(feature = "v1_10", feature = "dox"))] { let details = match s.details.take() { None => ptr::null_mut(), @@ -1779,7 +1786,7 @@ impl<'a, T: MessageErrorDomain> WarningBuilder<'a, T> { let error = glib::Error::new(s.error, s.message); - gst_sys::gst_message_new_warning_with_details( + ffi::gst_message_new_warning_with_details( src, mut_override(error.to_glib_none().0), s.debug.to_glib_none().0, @@ -1788,7 +1795,7 @@ impl<'a, T: MessageErrorDomain> WarningBuilder<'a, T> { } else { let error = glib::Error::new(s.error, s.message); - gst_sys::gst_message_new_warning( + ffi::gst_message_new_warning( src, mut_override(error.to_glib_none().0), s.debug.to_glib_none().0, @@ -1836,7 +1843,7 @@ impl<'a, T: MessageErrorDomain> InfoBuilder<'a, T> { } message_builder_generic_impl!(|s: &mut Self, src| { - cfg_if! { + cfg_if::cfg_if! { if #[cfg(any(feature = "v1_10", feature = "dox"))] { let details = match s.details.take() { None => ptr::null_mut(), @@ -1845,7 +1852,7 @@ impl<'a, T: MessageErrorDomain> InfoBuilder<'a, T> { let error = glib::Error::new(s.error, s.message); - gst_sys::gst_message_new_info_with_details( + ffi::gst_message_new_info_with_details( src, mut_override(error.to_glib_none().0), s.debug.to_glib_none().0, @@ -1854,7 +1861,7 @@ impl<'a, T: MessageErrorDomain> InfoBuilder<'a, T> { } else { let error = glib::Error::new(s.error, s.message); - gst_sys::gst_message_new_info( + ffi::gst_message_new_info( src, mut_override(error.to_glib_none().0), s.debug.to_glib_none().0, @@ -1878,7 +1885,7 @@ impl<'a> TagBuilder<'a> { } } - message_builder_generic_impl!(|s: &Self, src| gst_sys::gst_message_new_tag( + message_builder_generic_impl!(|s: &Self, src| ffi::gst_message_new_tag( src, s.tags.to_glib_full() )); @@ -1887,7 +1894,7 @@ impl<'a> TagBuilder<'a> { pub struct BufferingBuilder<'a> { builder: MessageBuilder<'a>, percent: i32, - stats: Option<(::BufferingMode, i32, i32, i64)>, + stats: Option<(crate::BufferingMode, i32, i32, i64)>, } impl<'a> BufferingBuilder<'a> { @@ -1902,7 +1909,7 @@ impl<'a> BufferingBuilder<'a> { pub fn stats( self, - mode: ::BufferingMode, + mode: crate::BufferingMode, avg_in: i32, avg_out: i32, buffering_left: i64, @@ -1915,10 +1922,10 @@ impl<'a> BufferingBuilder<'a> { } message_builder_generic_impl!(|s: &mut Self, src| { - let msg = gst_sys::gst_message_new_buffering(src, s.percent); + let msg = ffi::gst_message_new_buffering(src, s.percent); if let Some((mode, avg_in, avg_out, buffering_left)) = s.stats { - gst_sys::gst_message_set_buffering_stats( + ffi::gst_message_set_buffering_stats( msg, mode.to_glib(), avg_in, @@ -1933,13 +1940,13 @@ impl<'a> BufferingBuilder<'a> { pub struct StateChangedBuilder<'a> { builder: MessageBuilder<'a>, - old: ::State, - new: ::State, - pending: ::State, + old: crate::State, + new: crate::State, + pending: crate::State, } impl<'a> StateChangedBuilder<'a> { - fn new(old: ::State, new: ::State, pending: ::State) -> Self { + fn new(old: crate::State, new: crate::State, pending: crate::State) -> Self { skip_assert_initialized!(); Self { builder: MessageBuilder::new(), @@ -1949,7 +1956,7 @@ impl<'a> StateChangedBuilder<'a> { } } - message_builder_generic_impl!(|s: &mut Self, src| gst_sys::gst_message_new_state_changed( + message_builder_generic_impl!(|s: &mut Self, src| ffi::gst_message_new_state_changed( src, s.old.to_glib(), s.new.to_glib(), @@ -1969,7 +1976,7 @@ impl<'a> StateDirtyBuilder<'a> { } } - message_builder_generic_impl!(|_, src| gst_sys::gst_message_new_state_dirty(src)); + message_builder_generic_impl!(|_, src| ffi::gst_message_new_state_dirty(src)); } pub struct StepDoneBuilder<'a> { @@ -2004,7 +2011,7 @@ impl<'a> StepDoneBuilder<'a> { } } - message_builder_generic_impl!(|s: &mut Self, src| gst_sys::gst_message_new_step_done( + message_builder_generic_impl!(|s: &mut Self, src| ffi::gst_message_new_step_done( src, s.amount.get_format().to_glib(), s.amount.get_value() as u64, @@ -2018,12 +2025,12 @@ impl<'a> StepDoneBuilder<'a> { pub struct ClockProvideBuilder<'a> { builder: MessageBuilder<'a>, - clock: &'a ::Clock, + clock: &'a crate::Clock, ready: bool, } impl<'a> ClockProvideBuilder<'a> { - fn new(clock: &'a ::Clock, ready: bool) -> Self { + fn new(clock: &'a crate::Clock, ready: bool) -> Self { skip_assert_initialized!(); Self { builder: MessageBuilder::new(), @@ -2032,7 +2039,7 @@ impl<'a> ClockProvideBuilder<'a> { } } - message_builder_generic_impl!(|s: &mut Self, src| gst_sys::gst_message_new_clock_provide( + message_builder_generic_impl!(|s: &mut Self, src| ffi::gst_message_new_clock_provide( src, s.clock.to_glib_none().0, s.ready.to_glib() @@ -2041,11 +2048,11 @@ impl<'a> ClockProvideBuilder<'a> { pub struct ClockLostBuilder<'a> { builder: MessageBuilder<'a>, - clock: &'a ::Clock, + clock: &'a crate::Clock, } impl<'a> ClockLostBuilder<'a> { - fn new(clock: &'a ::Clock) -> Self { + fn new(clock: &'a crate::Clock) -> Self { skip_assert_initialized!(); Self { builder: MessageBuilder::new(), @@ -2053,7 +2060,7 @@ impl<'a> ClockLostBuilder<'a> { } } - message_builder_generic_impl!(|s: &mut Self, src| gst_sys::gst_message_new_clock_lost( + message_builder_generic_impl!(|s: &mut Self, src| ffi::gst_message_new_clock_lost( src, s.clock.to_glib_none().0 )); @@ -2061,11 +2068,11 @@ impl<'a> ClockLostBuilder<'a> { pub struct NewClockBuilder<'a> { builder: MessageBuilder<'a>, - clock: &'a ::Clock, + clock: &'a crate::Clock, } impl<'a> NewClockBuilder<'a> { - fn new(clock: &'a ::Clock) -> Self { + fn new(clock: &'a crate::Clock) -> Self { skip_assert_initialized!(); Self { builder: MessageBuilder::new(), @@ -2073,7 +2080,7 @@ impl<'a> NewClockBuilder<'a> { } } - message_builder_generic_impl!(|s: &mut Self, src| gst_sys::gst_message_new_new_clock( + message_builder_generic_impl!(|s: &mut Self, src| ffi::gst_message_new_new_clock( src, s.clock.to_glib_none().0 )); @@ -2081,13 +2088,13 @@ impl<'a> NewClockBuilder<'a> { pub struct StructureChangeBuilder<'a> { builder: MessageBuilder<'a>, - type_: ::StructureChangeType, - owner: &'a ::Element, + type_: crate::StructureChangeType, + owner: &'a crate::Element, busy: bool, } impl<'a> StructureChangeBuilder<'a> { - fn new(type_: ::StructureChangeType, owner: &'a ::Element, busy: bool) -> Self { + fn new(type_: crate::StructureChangeType, owner: &'a crate::Element, busy: bool) -> Self { skip_assert_initialized!(); Self { builder: MessageBuilder::new(), @@ -2097,25 +2104,23 @@ impl<'a> StructureChangeBuilder<'a> { } } - message_builder_generic_impl!( - |s: &mut Self, src| gst_sys::gst_message_new_structure_change( - src, - s.type_.to_glib(), - s.owner.to_glib_none().0, - s.busy.to_glib(), - ) - ); + message_builder_generic_impl!(|s: &mut Self, src| ffi::gst_message_new_structure_change( + src, + s.type_.to_glib(), + s.owner.to_glib_none().0, + s.busy.to_glib(), + )); } pub struct StreamStatusBuilder<'a> { builder: MessageBuilder<'a>, - type_: ::StreamStatusType, - owner: &'a ::Element, + type_: crate::StreamStatusType, + owner: &'a crate::Element, status_object: Option<&'a dyn glib::ToSendValue>, } impl<'a> StreamStatusBuilder<'a> { - fn new(type_: ::StreamStatusType, owner: &'a ::Element) -> Self { + fn new(type_: crate::StreamStatusType, owner: &'a crate::Element) -> Self { skip_assert_initialized!(); Self { builder: MessageBuilder::new(), @@ -2133,13 +2138,10 @@ impl<'a> StreamStatusBuilder<'a> { } message_builder_generic_impl!(|s: &mut Self, src| { - let msg = gst_sys::gst_message_new_stream_status( - src, - s.type_.to_glib(), - s.owner.to_glib_none().0, - ); + let msg = + ffi::gst_message_new_stream_status(src, s.type_.to_glib(), s.owner.to_glib_none().0); if let Some(status_object) = s.status_object { - gst_sys::gst_message_set_stream_status_object( + ffi::gst_message_set_stream_status_object( msg, status_object.to_send_value().to_glib_none().0, ); @@ -2150,11 +2152,11 @@ impl<'a> StreamStatusBuilder<'a> { pub struct ApplicationBuilder<'a> { builder: MessageBuilder<'a>, - structure: Option<::Structure>, + structure: Option, } impl<'a> ApplicationBuilder<'a> { - fn new(structure: ::Structure) -> Self { + fn new(structure: crate::Structure) -> Self { skip_assert_initialized!(); Self { builder: MessageBuilder::new(), @@ -2162,7 +2164,7 @@ impl<'a> ApplicationBuilder<'a> { } } - message_builder_generic_impl!(|s: &mut Self, src| gst_sys::gst_message_new_application( + message_builder_generic_impl!(|s: &mut Self, src| ffi::gst_message_new_application( src, s.structure.take().unwrap().into_ptr() )); @@ -2170,11 +2172,11 @@ impl<'a> ApplicationBuilder<'a> { pub struct ElementBuilder<'a> { builder: MessageBuilder<'a>, - structure: Option<::Structure>, + structure: Option, } impl<'a> ElementBuilder<'a> { - fn new(structure: ::Structure) -> Self { + fn new(structure: crate::Structure) -> Self { skip_assert_initialized!(); Self { builder: MessageBuilder::new(), @@ -2182,7 +2184,7 @@ impl<'a> ElementBuilder<'a> { } } - message_builder_generic_impl!(|s: &mut Self, src| gst_sys::gst_message_new_element( + message_builder_generic_impl!(|s: &mut Self, src| ffi::gst_message_new_element( src, s.structure.take().unwrap().into_ptr() )); @@ -2202,7 +2204,7 @@ impl<'a> SegmentStartBuilder<'a> { } } - message_builder_generic_impl!(|s: &mut Self, src| gst_sys::gst_message_new_segment_start( + message_builder_generic_impl!(|s: &mut Self, src| ffi::gst_message_new_segment_start( src, s.position.get_format().to_glib(), s.position.get_value(), @@ -2223,7 +2225,7 @@ impl<'a> SegmentDoneBuilder<'a> { } } - message_builder_generic_impl!(|s: &mut Self, src| gst_sys::gst_message_new_segment_done( + message_builder_generic_impl!(|s: &mut Self, src| ffi::gst_message_new_segment_done( src, s.position.get_format().to_glib(), s.position.get_value(), @@ -2242,7 +2244,7 @@ impl<'a> DurationChangedBuilder<'a> { } } - message_builder_generic_impl!(|_, src| gst_sys::gst_message_new_duration_changed(src)); + message_builder_generic_impl!(|_, src| ffi::gst_message_new_duration_changed(src)); } pub struct LatencyBuilder<'a> { @@ -2257,7 +2259,7 @@ impl<'a> LatencyBuilder<'a> { } } - message_builder_generic_impl!(|_, src| gst_sys::gst_message_new_latency(src)); + message_builder_generic_impl!(|_, src| ffi::gst_message_new_latency(src)); } pub struct AsyncStartBuilder<'a> { @@ -2272,16 +2274,16 @@ impl<'a> AsyncStartBuilder<'a> { } } - message_builder_generic_impl!(|_, src| gst_sys::gst_message_new_async_start(src)); + message_builder_generic_impl!(|_, src| ffi::gst_message_new_async_start(src)); } pub struct AsyncDoneBuilder<'a> { builder: MessageBuilder<'a>, - running_time: ::ClockTime, + running_time: crate::ClockTime, } impl<'a> AsyncDoneBuilder<'a> { - fn new(running_time: ::ClockTime) -> Self { + fn new(running_time: crate::ClockTime) -> Self { skip_assert_initialized!(); Self { builder: MessageBuilder::new(), @@ -2289,7 +2291,7 @@ impl<'a> AsyncDoneBuilder<'a> { } } - message_builder_generic_impl!(|s: &mut Self, src| gst_sys::gst_message_new_async_done( + message_builder_generic_impl!(|s: &mut Self, src| ffi::gst_message_new_async_done( src, s.running_time.to_glib() )); @@ -2297,11 +2299,11 @@ impl<'a> AsyncDoneBuilder<'a> { pub struct RequestStateBuilder<'a> { builder: MessageBuilder<'a>, - state: ::State, + state: crate::State, } impl<'a> RequestStateBuilder<'a> { - fn new(state: ::State) -> Self { + fn new(state: crate::State) -> Self { skip_assert_initialized!(); Self { builder: MessageBuilder::new(), @@ -2309,7 +2311,7 @@ impl<'a> RequestStateBuilder<'a> { } } - message_builder_generic_impl!(|s: &mut Self, src| gst_sys::gst_message_new_request_state( + message_builder_generic_impl!(|s: &mut Self, src| ffi::gst_message_new_request_state( src, s.state.to_glib() )); @@ -2343,7 +2345,7 @@ impl<'a> StepStartBuilder<'a> { } } - message_builder_generic_impl!(|s: &mut Self, src| gst_sys::gst_message_new_step_start( + message_builder_generic_impl!(|s: &mut Self, src| ffi::gst_message_new_step_start( src, s.active.to_glib(), s.amount.get_format().to_glib(), @@ -2357,10 +2359,10 @@ impl<'a> StepStartBuilder<'a> { pub struct QosBuilder<'a> { builder: MessageBuilder<'a>, live: bool, - running_time: ::ClockTime, - stream_time: ::ClockTime, - timestamp: ::ClockTime, - duration: ::ClockTime, + running_time: crate::ClockTime, + stream_time: crate::ClockTime, + timestamp: crate::ClockTime, + duration: crate::ClockTime, values: Option<(i64, f64, i32)>, stats: Option<(GenericFormattedValue, GenericFormattedValue)>, } @@ -2368,10 +2370,10 @@ pub struct QosBuilder<'a> { impl<'a> QosBuilder<'a> { fn new( live: bool, - running_time: ::ClockTime, - stream_time: ::ClockTime, - timestamp: ::ClockTime, - duration: ::ClockTime, + running_time: crate::ClockTime, + stream_time: crate::ClockTime, + timestamp: crate::ClockTime, + duration: crate::ClockTime, ) -> Self { skip_assert_initialized!(); Self { @@ -2404,7 +2406,7 @@ impl<'a> QosBuilder<'a> { } message_builder_generic_impl!(|s: &mut Self, src| { - let msg = gst_sys::gst_message_new_qos( + let msg = ffi::gst_message_new_qos( src, s.live.to_glib(), s.running_time.to_glib(), @@ -2413,10 +2415,10 @@ impl<'a> QosBuilder<'a> { s.duration.to_glib(), ); if let Some((jitter, proportion, quality)) = s.values { - gst_sys::gst_message_set_qos_values(msg, jitter, proportion, quality); + ffi::gst_message_set_qos_values(msg, jitter, proportion, quality); } if let Some((processed, dropped)) = s.stats { - gst_sys::gst_message_set_qos_stats( + ffi::gst_message_set_qos_stats( msg, processed.get_format().to_glib(), processed.get_value() as u64, @@ -2429,13 +2431,13 @@ impl<'a> QosBuilder<'a> { pub struct ProgressBuilder<'a> { builder: MessageBuilder<'a>, - type_: ::ProgressType, + type_: crate::ProgressType, code: &'a str, text: &'a str, } impl<'a> ProgressBuilder<'a> { - fn new(type_: ::ProgressType, code: &'a str, text: &'a str) -> Self { + fn new(type_: crate::ProgressType, code: &'a str, text: &'a str) -> Self { skip_assert_initialized!(); Self { builder: MessageBuilder::new(), @@ -2445,7 +2447,7 @@ impl<'a> ProgressBuilder<'a> { } } - message_builder_generic_impl!(|s: &mut Self, src| gst_sys::gst_message_new_progress( + message_builder_generic_impl!(|s: &mut Self, src| ffi::gst_message_new_progress( src, s.type_.to_glib(), s.code.to_glib_none().0, @@ -2455,12 +2457,12 @@ impl<'a> ProgressBuilder<'a> { pub struct TocBuilder<'a> { builder: MessageBuilder<'a>, - toc: &'a ::Toc, + toc: &'a crate::Toc, updated: bool, } impl<'a> TocBuilder<'a> { - fn new(toc: &'a ::Toc, updated: bool) -> Self { + fn new(toc: &'a crate::Toc, updated: bool) -> Self { skip_assert_initialized!(); Self { builder: MessageBuilder::new(), @@ -2469,7 +2471,7 @@ impl<'a> TocBuilder<'a> { } } - message_builder_generic_impl!(|s: &Self, src| gst_sys::gst_message_new_toc( + message_builder_generic_impl!(|s: &Self, src| ffi::gst_message_new_toc( src, s.toc.to_glib_none().0, s.updated.to_glib() @@ -2478,11 +2480,11 @@ impl<'a> TocBuilder<'a> { pub struct ResetTimeBuilder<'a> { builder: MessageBuilder<'a>, - running_time: ::ClockTime, + running_time: crate::ClockTime, } impl<'a> ResetTimeBuilder<'a> { - fn new(running_time: ::ClockTime) -> Self { + fn new(running_time: crate::ClockTime) -> Self { skip_assert_initialized!(); Self { builder: MessageBuilder::new(), @@ -2490,7 +2492,7 @@ impl<'a> ResetTimeBuilder<'a> { } } - message_builder_generic_impl!(|s: &mut Self, src| gst_sys::gst_message_new_reset_time( + message_builder_generic_impl!(|s: &mut Self, src| ffi::gst_message_new_reset_time( src, s.running_time.to_glib() )); @@ -2518,9 +2520,9 @@ impl<'a> StreamStartBuilder<'a> { } message_builder_generic_impl!(|s: &mut Self, src| { - let msg = gst_sys::gst_message_new_stream_start(src); + let msg = ffi::gst_message_new_stream_start(src); if let Some(group_id) = s.group_id { - gst_sys::gst_message_set_group_id(msg, group_id.0.get()); + ffi::gst_message_set_group_id(msg, group_id.0.get()); } msg }); @@ -2540,7 +2542,7 @@ impl<'a> NeedContextBuilder<'a> { } } - message_builder_generic_impl!(|s: &mut Self, src| gst_sys::gst_message_new_need_context( + message_builder_generic_impl!(|s: &mut Self, src| ffi::gst_message_new_need_context( src, s.context_type.to_glib_none().0 )); @@ -2548,11 +2550,11 @@ impl<'a> NeedContextBuilder<'a> { pub struct HaveContextBuilder<'a> { builder: MessageBuilder<'a>, - context: Option<::Context>, + context: Option, } impl<'a> HaveContextBuilder<'a> { - fn new(context: ::Context) -> Self { + fn new(context: crate::Context) -> Self { skip_assert_initialized!(); Self { builder: MessageBuilder::new(), @@ -2562,17 +2564,17 @@ impl<'a> HaveContextBuilder<'a> { message_builder_generic_impl!(|s: &mut Self, src| { let context = s.context.take().unwrap(); - gst_sys::gst_message_new_have_context(src, context.into_ptr()) + ffi::gst_message_new_have_context(src, context.into_ptr()) }); } pub struct DeviceAddedBuilder<'a> { builder: MessageBuilder<'a>, - device: &'a ::Device, + device: &'a crate::Device, } impl<'a> DeviceAddedBuilder<'a> { - fn new(device: &'a ::Device) -> Self { + fn new(device: &'a crate::Device) -> Self { skip_assert_initialized!(); Self { builder: MessageBuilder::new(), @@ -2580,7 +2582,7 @@ impl<'a> DeviceAddedBuilder<'a> { } } - message_builder_generic_impl!(|s: &mut Self, src| gst_sys::gst_message_new_device_added( + message_builder_generic_impl!(|s: &mut Self, src| ffi::gst_message_new_device_added( src, s.device.to_glib_none().0 )); @@ -2588,11 +2590,11 @@ impl<'a> DeviceAddedBuilder<'a> { pub struct DeviceRemovedBuilder<'a> { builder: MessageBuilder<'a>, - device: &'a ::Device, + device: &'a crate::Device, } impl<'a> DeviceRemovedBuilder<'a> { - fn new(device: &'a ::Device) -> Self { + fn new(device: &'a crate::Device) -> Self { skip_assert_initialized!(); Self { builder: MessageBuilder::new(), @@ -2600,7 +2602,7 @@ impl<'a> DeviceRemovedBuilder<'a> { } } - message_builder_generic_impl!(|s: &mut Self, src| gst_sys::gst_message_new_device_removed( + message_builder_generic_impl!(|s: &mut Self, src| ffi::gst_message_new_device_removed( src, s.device.to_glib_none().0 )); @@ -2635,7 +2637,7 @@ impl<'a> PropertyNotifyBuilder<'a> { message_builder_generic_impl!(|s: &mut Self, src| { let val = s.value.map(|v| v.to_send_value()); - gst_sys::gst_message_new_property_notify( + ffi::gst_message_new_property_notify( src, s.property_name.to_glib_none().0, mut_override( @@ -2651,13 +2653,13 @@ impl<'a> PropertyNotifyBuilder<'a> { #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))] pub struct StreamCollectionBuilder<'a> { builder: MessageBuilder<'a>, - collection: &'a ::StreamCollection, + collection: &'a crate::StreamCollection, } #[cfg(any(feature = "v1_10", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))] impl<'a> StreamCollectionBuilder<'a> { - fn new(collection: &'a ::StreamCollection) -> Self { + fn new(collection: &'a crate::StreamCollection) -> Self { skip_assert_initialized!(); Self { builder: MessageBuilder::new(), @@ -2665,12 +2667,9 @@ impl<'a> StreamCollectionBuilder<'a> { } } - message_builder_generic_impl!( - |s: &mut Self, src| gst_sys::gst_message_new_stream_collection( - src, - s.collection.to_glib_none().0 - ) - ); + message_builder_generic_impl!(|s: &mut Self, src| { + ffi::gst_message_new_stream_collection(src, s.collection.to_glib_none().0) + }); } #[cfg(any(feature = "v1_10", feature = "dox"))] @@ -2679,16 +2678,16 @@ pub struct StreamsSelectedBuilder<'a> { builder: MessageBuilder<'a>, #[cfg(any(feature = "v1_10", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))] - collection: &'a ::StreamCollection, + collection: &'a crate::StreamCollection, #[cfg(any(feature = "v1_10", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))] - streams: Option<&'a [&'a ::Stream]>, + streams: Option<&'a [&'a crate::Stream]>, } #[cfg(any(feature = "v1_10", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))] impl<'a> StreamsSelectedBuilder<'a> { - fn new(collection: &'a ::StreamCollection) -> Self { + fn new(collection: &'a crate::StreamCollection) -> Self { skip_assert_initialized!(); Self { builder: MessageBuilder::new(), @@ -2697,7 +2696,7 @@ impl<'a> StreamsSelectedBuilder<'a> { } } - pub fn streams(self, streams: &'a [&'a ::Stream]) -> Self { + pub fn streams(self, streams: &'a [&'a crate::Stream]) -> Self { Self { streams: Some(streams), ..self @@ -2705,10 +2704,10 @@ impl<'a> StreamsSelectedBuilder<'a> { } message_builder_generic_impl!(|s: &mut Self, src| { - let msg = gst_sys::gst_message_new_streams_selected(src, s.collection.to_glib_none().0); + let msg = ffi::gst_message_new_streams_selected(src, s.collection.to_glib_none().0); if let Some(streams) = s.streams { for stream in streams { - gst_sys::gst_message_streams_selected_add(msg, stream.to_glib_none().0); + ffi::gst_message_streams_selected_add(msg, stream.to_glib_none().0); } } msg @@ -2773,7 +2772,7 @@ impl<'a> RedirectBuilder<'a> { ptr::null_mut() }; - let msg = gst_sys::gst_message_new_redirect( + let msg = ffi::gst_message_new_redirect( src, s.location.to_glib_none().0, s.tag_list.to_glib_full(), @@ -2787,7 +2786,7 @@ impl<'a> RedirectBuilder<'a> { } else { ptr::null_mut() }; - gst_sys::gst_message_add_redirect_entry( + ffi::gst_message_add_redirect_entry( msg, location.to_glib_none().0, tag_list.to_glib_full(), @@ -2803,14 +2802,14 @@ impl<'a> RedirectBuilder<'a> { #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_16")))] pub struct DeviceChangedBuilder<'a> { builder: MessageBuilder<'a>, - device: &'a ::Device, - changed_device: &'a ::Device, + device: &'a crate::Device, + changed_device: &'a crate::Device, } #[cfg(any(feature = "v1_16", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_16")))] impl<'a> DeviceChangedBuilder<'a> { - fn new(device: &'a ::Device, changed_device: &'a ::Device) -> Self { + fn new(device: &'a crate::Device, changed_device: &'a crate::Device) -> Self { skip_assert_initialized!(); Self { builder: MessageBuilder::new(), @@ -2819,7 +2818,7 @@ impl<'a> DeviceChangedBuilder<'a> { } } - message_builder_generic_impl!(|s: &mut Self, src| gst_sys::gst_message_new_device_changed( + message_builder_generic_impl!(|s: &mut Self, src| ffi::gst_message_new_device_changed( src, s.device.to_glib_none().0, s.changed_device.to_glib_none().0, @@ -2832,7 +2831,7 @@ mod tests { #[test] fn test_simple() { - ::init().unwrap(); + crate::init().unwrap(); // Message without arguments let seqnum = Seqnum::next(); @@ -2858,7 +2857,7 @@ mod tests { #[cfg(feature = "v1_14")] #[test] fn test_other_fields() { - ::init().unwrap(); + crate::init().unwrap(); let seqnum = Seqnum::next(); let eos_msg = Eos::builder() @@ -2891,11 +2890,11 @@ mod tests { #[test] fn test_get_seqnum_valid() { - ::init().unwrap(); + crate::init().unwrap(); let msg = StreamStart::new(); let seqnum = Seqnum( - NonZeroU32::new(unsafe { gst_sys::gst_message_get_seqnum(msg.as_mut_ptr()) }).unwrap(), + NonZeroU32::new(unsafe { ffi::gst_message_get_seqnum(msg.as_mut_ptr()) }).unwrap(), ); match msg.view() { @@ -2906,14 +2905,14 @@ mod tests { #[test] fn test_get_seqnum_invalid() { - ::init().unwrap(); + crate::init().unwrap(); let msg = StreamStart::new(); let seqnum_init = msg.get_seqnum(); // Invalid the seqnum unsafe { - (*msg.as_mut_ptr()).seqnum = gst_sys::GST_SEQNUM_INVALID as u32; + (*msg.as_mut_ptr()).seqnum = ffi::GST_SEQNUM_INVALID as u32; assert_eq!(0, (*msg.as_ptr()).seqnum); }; diff --git a/gstreamer/src/meta.rs b/gstreamer/src/meta.rs index 199ab9558..2e7167ba2 100644 --- a/gstreamer/src/meta.rs +++ b/gstreamer/src/meta.rs @@ -10,25 +10,22 @@ use std::fmt; use std::marker::PhantomData; use std::ops; -use Buffer; -use BufferRef; +use crate::Buffer; +use crate::BufferRef; #[cfg(any(feature = "v1_14", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_14")))] -use Caps; +use crate::Caps; #[cfg(any(feature = "v1_14", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_14")))] -use CapsRef; +use crate::CapsRef; #[cfg(any(feature = "v1_14", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_14")))] -use ClockTime; +use crate::ClockTime; -use glib; #[cfg(any(feature = "v1_14", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_14")))] use glib::translate::ToGlib; use glib::translate::{from_glib, from_glib_none, FromGlib, ToGlibPtr}; -use glib_sys; -use gst_sys; pub unsafe trait MetaAPI: Sync + Send + Sized { type GstType; @@ -42,7 +39,7 @@ pub unsafe trait MetaAPI: Sync + Send + Sized { if meta_api != glib::Type::Invalid { assert_eq!( meta_api, - from_glib((*(*(ptr as *const gst_sys::GstMeta)).info).api) + from_glib((*(*(ptr as *const ffi::GstMeta)).info).api) ) } @@ -62,7 +59,7 @@ pub unsafe trait MetaAPI: Sync + Send + Sized { if meta_api != glib::Type::Invalid { assert_eq!( meta_api, - from_glib((*(*(ptr as *const gst_sys::GstMeta)).info).api) + from_glib((*(*(ptr as *const ffi::GstMeta)).info).api) ) } @@ -149,7 +146,7 @@ impl<'a, T: MetaAPI, U> AsRef> for MetaRefMut<'a, T, U> { impl<'a, T: MetaAPI> MetaRef<'a, T> { pub fn get_api(&self) -> glib::Type { unsafe { - let meta = self.meta as *const _ as *const gst_sys::GstMeta; + let meta = self.meta as *const _ as *const ffi::GstMeta; let info = (*meta).info; glib::Type::from_glib((*info).api) } @@ -159,8 +156,8 @@ impl<'a, T: MetaAPI> MetaRef<'a, T> { #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_16")))] pub fn get_seqnum(&self) -> MetaSeqnum { unsafe { - let meta = self.meta as *const _ as *const gst_sys::GstMeta; - MetaSeqnum(gst_sys::gst_meta_get_seqnum(meta)) + let meta = self.meta as *const _ as *const ffi::GstMeta; + MetaSeqnum(ffi::gst_meta_get_seqnum(meta)) } } @@ -185,7 +182,7 @@ impl<'a> MetaRef<'a, Meta> { impl<'a, T: MetaAPI, U> MetaRefMut<'a, T, U> { pub fn get_api(&self) -> glib::Type { unsafe { - let meta = self.meta as *const _ as *const gst_sys::GstMeta; + let meta = self.meta as *const _ as *const ffi::GstMeta; let info = (*meta).info; glib::Type::from_glib((*info).api) } @@ -195,8 +192,8 @@ impl<'a, T: MetaAPI, U> MetaRefMut<'a, T, U> { #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_16")))] pub fn get_seqnum(&self) -> u64 { unsafe { - let meta = self.meta as *const _ as *const gst_sys::GstMeta; - gst_sys::gst_meta_get_seqnum(meta) + let meta = self.meta as *const _ as *const ffi::GstMeta; + ffi::gst_meta_get_seqnum(meta) } } @@ -212,11 +209,11 @@ impl<'a, T: MetaAPI, U> MetaRefMut<'a, T, U> { impl<'a, T: MetaAPI> MetaRefMut<'a, T, Standalone> { pub fn remove(mut self) { unsafe { - let res = gst_sys::gst_buffer_remove_meta( + let res = ffi::gst_buffer_remove_meta( self.buffer.as_mut_ptr(), - self.as_mut_ptr() as *mut gst_sys::GstMeta, + self.as_mut_ptr() as *mut ffi::GstMeta, ); - assert_ne!(res, glib_sys::GFALSE); + assert_ne!(res, glib::ffi::GFALSE); } } } @@ -235,7 +232,7 @@ impl<'a, U> MetaRefMut<'a, Meta, U> { } #[repr(transparent)] -pub struct Meta(gst_sys::GstMeta); +pub struct Meta(ffi::GstMeta); unsafe impl Send for Meta {} unsafe impl Sync for Meta {} @@ -247,7 +244,7 @@ impl Meta { } unsafe impl MetaAPI for Meta { - type GstType = gst_sys::GstMeta; + type GstType = ffi::GstMeta; fn get_meta_api() -> glib::Type { glib::Type::Invalid @@ -263,7 +260,7 @@ impl fmt::Debug for Meta { } #[repr(transparent)] -pub struct ParentBufferMeta(gst_sys::GstParentBufferMeta); +pub struct ParentBufferMeta(ffi::GstParentBufferMeta); unsafe impl Send for ParentBufferMeta {} unsafe impl Sync for ParentBufferMeta {} @@ -272,7 +269,7 @@ impl ParentBufferMeta { pub fn add<'a>(buffer: &'a mut BufferRef, parent: &Buffer) -> MetaRefMut<'a, Self, Standalone> { skip_assert_initialized!(); unsafe { - let meta = gst_sys::gst_buffer_add_parent_buffer_meta( + let meta = ffi::gst_buffer_add_parent_buffer_meta( buffer.as_mut_ptr(), parent.to_glib_none().0, ); @@ -291,10 +288,10 @@ impl ParentBufferMeta { } unsafe impl MetaAPI for ParentBufferMeta { - type GstType = gst_sys::GstParentBufferMeta; + type GstType = ffi::GstParentBufferMeta; fn get_meta_api() -> glib::Type { - unsafe { from_glib(gst_sys::gst_parent_buffer_meta_api_get_type()) } + unsafe { from_glib(ffi::gst_parent_buffer_meta_api_get_type()) } } } @@ -307,36 +304,35 @@ impl fmt::Debug for ParentBufferMeta { } #[repr(transparent)] -pub struct ProtectionMeta(gst_sys::GstProtectionMeta); +pub struct ProtectionMeta(ffi::GstProtectionMeta); unsafe impl Send for ProtectionMeta {} unsafe impl Sync for ProtectionMeta {} impl ProtectionMeta { - pub fn add(buffer: &mut BufferRef, info: ::Structure) -> MetaRefMut { + pub fn add(buffer: &mut BufferRef, info: crate::Structure) -> MetaRefMut { skip_assert_initialized!(); unsafe { - let meta = - gst_sys::gst_buffer_add_protection_meta(buffer.as_mut_ptr(), info.into_ptr()); + let meta = ffi::gst_buffer_add_protection_meta(buffer.as_mut_ptr(), info.into_ptr()); Self::from_mut_ptr(buffer, meta) } } - pub fn get_info(&self) -> &::StructureRef { - unsafe { ::StructureRef::from_glib_borrow(self.0.info) } + pub fn get_info(&self) -> &crate::StructureRef { + unsafe { crate::StructureRef::from_glib_borrow(self.0.info) } } - pub fn get_info_mut(&mut self) -> &mut ::StructureRef { - unsafe { ::StructureRef::from_glib_borrow_mut(self.0.info) } + pub fn get_info_mut(&mut self) -> &mut crate::StructureRef { + unsafe { crate::StructureRef::from_glib_borrow_mut(self.0.info) } } } unsafe impl MetaAPI for ProtectionMeta { - type GstType = gst_sys::GstProtectionMeta; + type GstType = ffi::GstProtectionMeta; fn get_meta_api() -> glib::Type { - unsafe { from_glib(gst_sys::gst_protection_meta_api_get_type()) } + unsafe { from_glib(ffi::gst_protection_meta_api_get_type()) } } } @@ -351,7 +347,7 @@ impl fmt::Debug for ProtectionMeta { #[cfg(any(feature = "v1_14", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_14")))] #[repr(transparent)] -pub struct ReferenceTimestampMeta(gst_sys::GstReferenceTimestampMeta); +pub struct ReferenceTimestampMeta(ffi::GstReferenceTimestampMeta); #[cfg(any(feature = "v1_14", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_14")))] @@ -371,7 +367,7 @@ impl ReferenceTimestampMeta { ) -> MetaRefMut<'a, Self, Standalone> { skip_assert_initialized!(); unsafe { - let meta = gst_sys::gst_buffer_add_reference_timestamp_meta( + let meta = ffi::gst_buffer_add_reference_timestamp_meta( buffer.as_mut_ptr(), reference.to_glib_none().0, timestamp.to_glib(), @@ -402,10 +398,10 @@ impl ReferenceTimestampMeta { #[cfg(any(feature = "v1_14", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_14")))] unsafe impl MetaAPI for ReferenceTimestampMeta { - type GstType = gst_sys::GstReferenceTimestampMeta; + type GstType = ffi::GstReferenceTimestampMeta; fn get_meta_api() -> glib::Type { - unsafe { from_glib(gst_sys::gst_reference_timestamp_meta_api_get_type()) } + unsafe { from_glib(ffi::gst_reference_timestamp_meta_api_get_type()) } } } @@ -427,10 +423,10 @@ mod tests { #[test] fn test_add_get_iterate_meta() { - ::init().unwrap(); + crate::init().unwrap(); - let mut buffer = ::Buffer::new(); - let parent = ::Buffer::new(); + let mut buffer = crate::Buffer::new(); + let parent = crate::Buffer::new(); { let meta = ParentBufferMeta::add(buffer.get_mut().unwrap(), &parent); unsafe { diff --git a/gstreamer/src/miniobject.rs b/gstreamer/src/miniobject.rs index 99a2f88cd..32dc22c14 100644 --- a/gstreamer/src/miniobject.rs +++ b/gstreamer/src/miniobject.rs @@ -8,47 +8,47 @@ #[macro_export] macro_rules! gst_define_mini_object_wrapper( - ($name:ident, $ref_name:ident, $gst_sys_name:path, $get_type:expr) => { + ($name:ident, $ref_name:ident, $ffi_name:path, $get_type:expr) => { pub struct $name { - obj: ::std::ptr::NonNull<$ref_name>, + obj: std::ptr::NonNull<$ref_name>, } #[repr(transparent)] - pub struct $ref_name($gst_sys_name); + pub struct $ref_name($ffi_name); impl $name { - pub unsafe fn from_glib_none(ptr: *const $gst_sys_name) -> Self { + pub unsafe fn from_glib_none(ptr: *const $ffi_name) -> Self { skip_assert_initialized!(); assert!(!ptr.is_null()); - $crate::gst_sys::gst_mini_object_ref(ptr as *mut $crate::gst_sys::GstMiniObject); + $crate::ffi::gst_mini_object_ref(ptr as *mut $crate::ffi::GstMiniObject); $name { - obj: ::std::ptr::NonNull::new_unchecked(ptr as *mut $gst_sys_name as *mut $ref_name), + obj: std::ptr::NonNull::new_unchecked(ptr as *mut $ffi_name as *mut $ref_name), } } - pub unsafe fn from_glib_full(ptr: *const $gst_sys_name) -> Self { + pub unsafe fn from_glib_full(ptr: *const $ffi_name) -> Self { skip_assert_initialized!(); assert!(!ptr.is_null()); $name { - obj: ::std::ptr::NonNull::new_unchecked(ptr as *mut $gst_sys_name as *mut $ref_name), + obj: std::ptr::NonNull::new_unchecked(ptr as *mut $ffi_name as *mut $ref_name), } } - pub unsafe fn from_glib_borrow(ptr: *const $gst_sys_name) -> $crate::glib::translate::Borrowed { + pub unsafe fn from_glib_borrow(ptr: *const $ffi_name) -> $crate::glib::translate::Borrowed { skip_assert_initialized!(); assert!(!ptr.is_null()); $crate::glib::translate::Borrowed::new($name { - obj: ::std::ptr::NonNull::new_unchecked(ptr as *mut $gst_sys_name as *mut $ref_name), + obj: std::ptr::NonNull::new_unchecked(ptr as *mut $ffi_name as *mut $ref_name), }) } - pub unsafe fn replace_ptr(&mut self, ptr: *mut $gst_sys_name) { + pub unsafe fn replace_ptr(&mut self, ptr: *mut $ffi_name) { assert!(!ptr.is_null()); - self.obj = ::std::ptr::NonNull::new_unchecked(ptr as *mut $ref_name); + self.obj = std::ptr::NonNull::new_unchecked(ptr as *mut $ref_name); } pub fn make_mut(&mut self) -> &mut $ref_name { @@ -57,10 +57,10 @@ macro_rules! gst_define_mini_object_wrapper( return self.obj.as_mut(); } - let ptr = $crate::gst_sys::gst_mini_object_make_writable( - self.as_mut_ptr() as *mut $crate::gst_sys::GstMiniObject + let ptr = $crate::ffi::gst_mini_object_make_writable( + self.as_mut_ptr() as *mut $crate::ffi::GstMiniObject ); - self.replace_ptr(ptr as *mut $gst_sys_name); + self.replace_ptr(ptr as *mut $ffi_name); assert!(self.is_writable()); self.obj.as_mut() @@ -77,14 +77,14 @@ macro_rules! gst_define_mini_object_wrapper( pub fn is_writable(&self) -> bool { unsafe { - $crate::glib::translate::from_glib($crate::gst_sys::gst_mini_object_is_writable( - self.as_ptr() as *const $crate::gst_sys::GstMiniObject + $crate::glib::translate::from_glib($crate::ffi::gst_mini_object_is_writable( + self.as_ptr() as *const $crate::ffi::GstMiniObject )) } } - pub unsafe fn into_ptr(self) -> *mut $gst_sys_name { - let s = ::std::mem::ManuallyDrop::new(self); + pub unsafe fn into_ptr(self) -> *mut $ffi_name { + let s = std::mem::ManuallyDrop::new(self); s.as_mut_ptr() } } @@ -98,12 +98,12 @@ macro_rules! gst_define_mini_object_wrapper( impl Drop for $name { fn drop(&mut self) { unsafe { - $crate::gst_sys::gst_mini_object_unref(self.as_mut_ptr() as *mut $crate::gst_sys::GstMiniObject); + $crate::ffi::gst_mini_object_unref(self.as_mut_ptr() as *mut $crate::ffi::GstMiniObject); } } } - impl ::std::ops::Deref for $name { + impl std::ops::Deref for $name { type Target = $ref_name; fn deref(&self) -> &Self::Target { @@ -117,7 +117,7 @@ macro_rules! gst_define_mini_object_wrapper( } } - impl ::std::borrow::Borrow<$ref_name> for $name { + impl std::borrow::Borrow<$ref_name> for $name { fn borrow(&self) -> &$ref_name { &*self } @@ -129,71 +129,71 @@ macro_rules! gst_define_mini_object_wrapper( } } - impl<'a> $crate::glib::translate::ToGlibPtr<'a, *const $gst_sys_name> for $name { + impl<'a> $crate::glib::translate::ToGlibPtr<'a, *const $ffi_name> for $name { type Storage = &'a Self; - fn to_glib_none(&'a self) -> $crate::glib::translate::Stash<'a, *const $gst_sys_name, Self> { + fn to_glib_none(&'a self) -> $crate::glib::translate::Stash<'a, *const $ffi_name, Self> { $crate::glib::translate::Stash(unsafe { self.as_ptr() }, self) } - fn to_glib_full(&self) -> *const $gst_sys_name { + fn to_glib_full(&self) -> *const $ffi_name { unsafe { - $crate::gst_sys::gst_mini_object_ref(self.as_mut_ptr() as *mut $crate::gst_sys::GstMiniObject); + $crate::ffi::gst_mini_object_ref(self.as_mut_ptr() as *mut $crate::ffi::GstMiniObject); self.as_ptr() } } } - impl<'a> $crate::glib::translate::ToGlibPtr<'a, *mut $gst_sys_name> for $name { + impl<'a> $crate::glib::translate::ToGlibPtr<'a, *mut $ffi_name> for $name { type Storage = &'a Self; - fn to_glib_none(&'a self) -> $crate::glib::translate::Stash<'a, *mut $gst_sys_name, Self> { + fn to_glib_none(&'a self) -> $crate::glib::translate::Stash<'a, *mut $ffi_name, Self> { $crate::glib::translate::Stash(unsafe { self.as_mut_ptr() }, self) } - fn to_glib_full(&self) -> *mut $gst_sys_name { + fn to_glib_full(&self) -> *mut $ffi_name { unsafe { - $crate::gst_sys::gst_mini_object_ref(self.as_mut_ptr() as *mut $crate::gst_sys::GstMiniObject); + $crate::ffi::gst_mini_object_ref(self.as_mut_ptr() as *mut $crate::ffi::GstMiniObject); self.as_mut_ptr() } } } - impl<'a> $crate::glib::translate::ToGlibPtrMut<'a, *mut $gst_sys_name> for $name { + impl<'a> $crate::glib::translate::ToGlibPtrMut<'a, *mut $ffi_name> for $name { type Storage = &'a mut Self; - fn to_glib_none_mut(&'a mut self) -> $crate::glib::translate::StashMut<*mut $gst_sys_name, Self> { + fn to_glib_none_mut(&'a mut self) -> $crate::glib::translate::StashMut<*mut $ffi_name, Self> { self.make_mut(); $crate::glib::translate::StashMut(unsafe { self.as_mut_ptr() }, self) } } - impl<'a> $crate::glib::translate::ToGlibContainerFromSlice<'a, *mut *mut $gst_sys_name> for $name { + impl<'a> $crate::glib::translate::ToGlibContainerFromSlice<'a, *mut *mut $ffi_name> for $name { #[allow(clippy::type_complexity)] type Storage = ( - Vec<$crate::glib::translate::Stash<'a, *mut $gst_sys_name, Self>>, - Option>, + Vec<$crate::glib::translate::Stash<'a, *mut $ffi_name, Self>>, + Option>, ); - fn to_glib_none_from_slice(t: &'a [$name]) -> (*mut *mut $gst_sys_name, Self::Storage) { + fn to_glib_none_from_slice(t: &'a [$name]) -> (*mut *mut $ffi_name, Self::Storage) { skip_assert_initialized!(); let v: Vec<_> = t.iter().map(|s| $crate::glib::translate::ToGlibPtr::to_glib_none(s)).collect(); let mut v_ptr: Vec<_> = v.iter().map(|s| s.0).collect(); - v_ptr.push(::std::ptr::null_mut() as *mut $gst_sys_name); + v_ptr.push(std::ptr::null_mut() as *mut $ffi_name); - (v_ptr.as_ptr() as *mut *mut $gst_sys_name, (v, Some(v_ptr))) + (v_ptr.as_ptr() as *mut *mut $ffi_name, (v, Some(v_ptr))) } - fn to_glib_container_from_slice(t: &'a [$name]) -> (*mut *mut $gst_sys_name, Self::Storage) { + fn to_glib_container_from_slice(t: &'a [$name]) -> (*mut *mut $ffi_name, Self::Storage) { skip_assert_initialized!(); let v: Vec<_> = t.iter().map(|s| $crate::glib::translate::ToGlibPtr::to_glib_none(s)).collect(); let v_ptr = unsafe { - let v_ptr = $crate::glib_sys::g_malloc0(::std::mem::size_of::<*mut $gst_sys_name>() * t.len() + 1) - as *mut *mut $gst_sys_name; + let v_ptr = $crate::glib::ffi::g_malloc0(std::mem::size_of::<*mut $ffi_name>() * t.len() + 1) + as *mut *mut $ffi_name; for (i, s) in v.iter().enumerate() { - ::std::ptr::write(v_ptr.add(i), s.0); + std::ptr::write(v_ptr.add(i), s.0); } v_ptr @@ -202,14 +202,14 @@ macro_rules! gst_define_mini_object_wrapper( (v_ptr, (v, None)) } - fn to_glib_full_from_slice(t: &[$name]) -> *mut *mut $gst_sys_name { + fn to_glib_full_from_slice(t: &[$name]) -> *mut *mut $ffi_name { skip_assert_initialized!(); unsafe { - let v_ptr = $crate::glib_sys::g_malloc0(::std::mem::size_of::<*mut $gst_sys_name>() * t.len() + 1) - as *mut *mut $gst_sys_name; + let v_ptr = $crate::glib::ffi::g_malloc0(std::mem::size_of::<*mut $ffi_name>() * t.len() + 1) + as *mut *mut $ffi_name; for (i, s) in t.iter().enumerate() { - ::std::ptr::write(v_ptr.add(i), $crate::glib::translate::ToGlibPtr::to_glib_full(s)); + std::ptr::write(v_ptr.add(i), $crate::glib::translate::ToGlibPtr::to_glib_full(s)); } v_ptr @@ -217,152 +217,152 @@ macro_rules! gst_define_mini_object_wrapper( } } - impl<'a> $crate::glib::translate::ToGlibContainerFromSlice<'a, *const *mut $gst_sys_name> + impl<'a> $crate::glib::translate::ToGlibContainerFromSlice<'a, *const *mut $ffi_name> for $name { #[allow(clippy::type_complexity)] type Storage = ( - Vec<$crate::glib::translate::Stash<'a, *mut $gst_sys_name, $name>>, - Option>, + Vec<$crate::glib::translate::Stash<'a, *mut $ffi_name, $name>>, + Option>, ); - fn to_glib_none_from_slice(t: &'a [$name]) -> (*const *mut $gst_sys_name, Self::Storage) { + fn to_glib_none_from_slice(t: &'a [$name]) -> (*const *mut $ffi_name, Self::Storage) { skip_assert_initialized!(); let (ptr, stash) = - $crate::glib::translate::ToGlibContainerFromSlice::<'a, *mut *mut $gst_sys_name>::to_glib_none_from_slice(t); - (ptr as *const *mut $gst_sys_name, stash) + $crate::glib::translate::ToGlibContainerFromSlice::<'a, *mut *mut $ffi_name>::to_glib_none_from_slice(t); + (ptr as *const *mut $ffi_name, stash) } - fn to_glib_container_from_slice(_: &'a [$name]) -> (*const *mut $gst_sys_name, Self::Storage) { + fn to_glib_container_from_slice(_: &'a [$name]) -> (*const *mut $ffi_name, Self::Storage) { skip_assert_initialized!(); // Can't have consumer free a *const pointer unimplemented!() } - fn to_glib_full_from_slice(_: &[$name]) -> *const *mut $gst_sys_name { + fn to_glib_full_from_slice(_: &[$name]) -> *const *mut $ffi_name { skip_assert_initialized!(); // Can't have consumer free a *const pointer unimplemented!() } } - impl $crate::glib::translate::FromGlibPtrNone<*const $gst_sys_name> for $name { - unsafe fn from_glib_none(ptr: *const $gst_sys_name) -> Self { + impl $crate::glib::translate::FromGlibPtrNone<*const $ffi_name> for $name { + unsafe fn from_glib_none(ptr: *const $ffi_name) -> Self { Self::from_glib_none(ptr) } } - impl $crate::glib::translate::FromGlibPtrNone<*mut $gst_sys_name> for $name { - unsafe fn from_glib_none(ptr: *mut $gst_sys_name) -> Self { + impl $crate::glib::translate::FromGlibPtrNone<*mut $ffi_name> for $name { + unsafe fn from_glib_none(ptr: *mut $ffi_name) -> Self { Self::from_glib_none(ptr) } } - impl $crate::glib::translate::FromGlibPtrFull<*const $gst_sys_name> for $name { - unsafe fn from_glib_full(ptr: *const $gst_sys_name) -> Self { + impl $crate::glib::translate::FromGlibPtrFull<*const $ffi_name> for $name { + unsafe fn from_glib_full(ptr: *const $ffi_name) -> Self { Self::from_glib_full(ptr) } } - impl $crate::glib::translate::FromGlibPtrFull<*mut $gst_sys_name> for $name { - unsafe fn from_glib_full(ptr: *mut $gst_sys_name) -> Self { + impl $crate::glib::translate::FromGlibPtrFull<*mut $ffi_name> for $name { + unsafe fn from_glib_full(ptr: *mut $ffi_name) -> Self { Self::from_glib_full(ptr) } } - impl $crate::glib::translate::FromGlibPtrBorrow<*const $gst_sys_name> for $name { - unsafe fn from_glib_borrow(ptr: *const $gst_sys_name) -> $crate::glib::translate::Borrowed { + impl $crate::glib::translate::FromGlibPtrBorrow<*const $ffi_name> for $name { + unsafe fn from_glib_borrow(ptr: *const $ffi_name) -> $crate::glib::translate::Borrowed { Self::from_glib_borrow(ptr) } } - impl $crate::glib::translate::FromGlibPtrBorrow<*mut $gst_sys_name> for $name { - unsafe fn from_glib_borrow(ptr: *mut $gst_sys_name) -> $crate::glib::translate::Borrowed { + impl $crate::glib::translate::FromGlibPtrBorrow<*mut $ffi_name> for $name { + unsafe fn from_glib_borrow(ptr: *mut $ffi_name) -> $crate::glib::translate::Borrowed { Self::from_glib_borrow(ptr) } } - impl $crate::glib::translate::FromGlibContainerAsVec<*mut $gst_sys_name, *mut *mut $gst_sys_name> + impl $crate::glib::translate::FromGlibContainerAsVec<*mut $ffi_name, *mut *mut $ffi_name> for $name { - unsafe fn from_glib_none_num_as_vec(ptr: *mut *mut $gst_sys_name, num: usize) -> Vec { + unsafe fn from_glib_none_num_as_vec(ptr: *mut *mut $ffi_name, num: usize) -> Vec { if num == 0 || ptr.is_null() { return Vec::new(); } let mut res = Vec::with_capacity(num); for i in 0..num { - res.push($crate::glib::translate::from_glib_none(::std::ptr::read(ptr.add(i)))); + res.push($crate::glib::translate::from_glib_none(std::ptr::read(ptr.add(i)))); } res } - unsafe fn from_glib_container_num_as_vec(ptr: *mut *mut $gst_sys_name, num: usize) -> Vec { + unsafe fn from_glib_container_num_as_vec(ptr: *mut *mut $ffi_name, num: usize) -> Vec { let res = $crate::glib::translate::FromGlibContainerAsVec::from_glib_none_num_as_vec(ptr, num); - $crate::glib_sys::g_free(ptr as *mut _); + $crate::glib::ffi::g_free(ptr as *mut _); res } - unsafe fn from_glib_full_num_as_vec(ptr: *mut *mut $gst_sys_name, num: usize) -> Vec { + unsafe fn from_glib_full_num_as_vec(ptr: *mut *mut $ffi_name, num: usize) -> Vec { if num == 0 || ptr.is_null() { return Vec::new(); } let mut res = Vec::with_capacity(num); for i in 0..num { - res.push($crate::glib::translate::from_glib_full(::std::ptr::read(ptr.add(i)))); + res.push($crate::glib::translate::from_glib_full(std::ptr::read(ptr.add(i)))); } - $crate::glib_sys::g_free(ptr as *mut _); + $crate::glib::ffi::g_free(ptr as *mut _); res } } - impl $crate::glib::translate::FromGlibPtrArrayContainerAsVec<*mut $gst_sys_name, *mut *mut $gst_sys_name> + impl $crate::glib::translate::FromGlibPtrArrayContainerAsVec<*mut $ffi_name, *mut *mut $ffi_name> for $name { - unsafe fn from_glib_none_as_vec(ptr: *mut *mut $gst_sys_name) -> Vec { + unsafe fn from_glib_none_as_vec(ptr: *mut *mut $ffi_name) -> Vec { $crate::glib::translate::FromGlibContainerAsVec::from_glib_none_num_as_vec(ptr, glib::translate::c_ptr_array_len(ptr)) } - unsafe fn from_glib_container_as_vec(ptr: *mut *mut $gst_sys_name) -> Vec { + unsafe fn from_glib_container_as_vec(ptr: *mut *mut $ffi_name) -> Vec { $crate::glib::translate::FromGlibContainerAsVec::from_glib_container_num_as_vec(ptr, glib::translate::c_ptr_array_len(ptr)) } - unsafe fn from_glib_full_as_vec(ptr: *mut *mut $gst_sys_name) -> Vec { + unsafe fn from_glib_full_as_vec(ptr: *mut *mut $ffi_name) -> Vec { $crate::glib::translate::FromGlibContainerAsVec::from_glib_full_num_as_vec(ptr, glib::translate::c_ptr_array_len(ptr)) } } - impl $crate::glib::translate::FromGlibContainerAsVec<*mut $gst_sys_name, *const *mut $gst_sys_name> + impl $crate::glib::translate::FromGlibContainerAsVec<*mut $ffi_name, *const *mut $ffi_name> for $name { - unsafe fn from_glib_none_num_as_vec(ptr: *const *mut $gst_sys_name, num: usize) -> Vec { + unsafe fn from_glib_none_num_as_vec(ptr: *const *mut $ffi_name, num: usize) -> Vec { $crate::glib::translate::FromGlibContainerAsVec::from_glib_none_num_as_vec(ptr as *mut *mut _, num) } - unsafe fn from_glib_container_num_as_vec(_: *const *mut $gst_sys_name, _: usize) -> Vec { + unsafe fn from_glib_container_num_as_vec(_: *const *mut $ffi_name, _: usize) -> Vec { // Can't free a *const unimplemented!() } - unsafe fn from_glib_full_num_as_vec(_: *const *mut $gst_sys_name, _: usize) -> Vec { + unsafe fn from_glib_full_num_as_vec(_: *const *mut $ffi_name, _: usize) -> Vec { // Can't free a *const unimplemented!() } } - impl $crate::glib::translate::FromGlibPtrArrayContainerAsVec<*mut $gst_sys_name, *const *mut $gst_sys_name> for $name + impl $crate::glib::translate::FromGlibPtrArrayContainerAsVec<*mut $ffi_name, *const *mut $ffi_name> for $name { - unsafe fn from_glib_none_as_vec(ptr: *const *mut $gst_sys_name) -> Vec { + unsafe fn from_glib_none_as_vec(ptr: *const *mut $ffi_name) -> Vec { $crate::glib::translate::FromGlibPtrArrayContainerAsVec::from_glib_none_as_vec(ptr as *mut *mut _) } - unsafe fn from_glib_container_as_vec(_: *const *mut $gst_sys_name) -> Vec { + unsafe fn from_glib_container_as_vec(_: *const *mut $ffi_name) -> Vec { // Can't free a *const unimplemented!() } - unsafe fn from_glib_full_as_vec(_: *const *mut $gst_sys_name) -> Vec { + unsafe fn from_glib_full_as_vec(_: *const *mut $ffi_name) -> Vec { // Can't free a *const unimplemented!() } @@ -372,59 +372,59 @@ macro_rules! gst_define_mini_object_wrapper( for $name { unsafe fn from_value_optional(v: &'a glib::Value) -> Option { - let ptr = $crate::gobject_sys::g_value_get_boxed($crate::glib::translate::ToGlibPtr::to_glib_none(v).0); - $crate::glib::translate::from_glib_none(ptr as *const $gst_sys_name) + let ptr = $crate::glib::gobject_ffi::g_value_get_boxed($crate::glib::translate::ToGlibPtr::to_glib_none(v).0); + $crate::glib::translate::from_glib_none(ptr as *const $ffi_name) } } impl $crate::glib::value::SetValue for $name { unsafe fn set_value(v: &mut glib::Value, s: &Self) { - $crate::gobject_sys::g_value_set_boxed($crate::glib::translate::ToGlibPtrMut::to_glib_none_mut(v).0, s.as_ptr() as $crate::glib_sys::gpointer); + $crate::glib::gobject_ffi::g_value_set_boxed($crate::glib::translate::ToGlibPtrMut::to_glib_none_mut(v).0, s.as_ptr() as $crate::glib::ffi::gpointer); } } impl $crate::glib::value::SetValueOptional for $name { unsafe fn set_value_optional(v: &mut glib::Value, s: Option<&Self>) { if let Some(s) = s { - $crate::gobject_sys::g_value_set_boxed($crate::glib::translate::ToGlibPtrMut::to_glib_none_mut(v).0, s.as_ptr() as $crate::glib_sys::gpointer); + $crate::glib::gobject_ffi::g_value_set_boxed($crate::glib::translate::ToGlibPtrMut::to_glib_none_mut(v).0, s.as_ptr() as $crate::glib::ffi::gpointer); } else { - $crate::gobject_sys::g_value_set_boxed($crate::glib::translate::ToGlibPtrMut::to_glib_none_mut(v).0, ::std::ptr::null_mut()); + $crate::glib::gobject_ffi::g_value_set_boxed($crate::glib::translate::ToGlibPtrMut::to_glib_none_mut(v).0, std::ptr::null_mut()); } } } impl $crate::glib::translate::GlibPtrDefault for $name { - type GlibType = *mut $gst_sys_name; + type GlibType = *mut $ffi_name; } impl $ref_name { - pub unsafe fn as_ptr(&self) -> *const $gst_sys_name { - self as *const Self as *const $gst_sys_name + pub unsafe fn as_ptr(&self) -> *const $ffi_name { + self as *const Self as *const $ffi_name } - pub unsafe fn as_mut_ptr(&self) -> *mut $gst_sys_name { - self as *const Self as *mut $gst_sys_name + pub unsafe fn as_mut_ptr(&self) -> *mut $ffi_name { + self as *const Self as *mut $ffi_name } - pub unsafe fn from_ptr<'a>(ptr: *const $gst_sys_name) -> &'a Self { + pub unsafe fn from_ptr<'a>(ptr: *const $ffi_name) -> &'a Self { assert!(!ptr.is_null()); &*(ptr as *const Self) } - pub unsafe fn from_mut_ptr<'a>(ptr: *mut $gst_sys_name) -> &'a mut Self { + pub unsafe fn from_mut_ptr<'a>(ptr: *mut $ffi_name) -> &'a mut Self { assert!(!ptr.is_null()); assert_ne!( - $crate::gst_sys::gst_mini_object_is_writable(ptr as *mut $crate::gst_sys::GstMiniObject), - $crate::glib_sys::GFALSE + $crate::ffi::gst_mini_object_is_writable(ptr as *mut $crate::ffi::GstMiniObject), + $crate::glib::ffi::GFALSE ); &mut *(ptr as *mut Self) } pub fn copy(&self) -> $name { unsafe { - $name::from_glib_full($crate::gst_sys::gst_mini_object_copy( - self.as_ptr() as *const $crate::gst_sys::GstMiniObject - ) as *const $gst_sys_name) + $name::from_glib_full($crate::ffi::gst_mini_object_copy( + self.as_ptr() as *const $crate::ffi::GstMiniObject + ) as *const $ffi_name) } } } @@ -436,14 +436,14 @@ macro_rules! gst_define_mini_object_wrapper( } impl $crate::glib::translate::GlibPtrDefault for $ref_name { - type GlibType = *mut $gst_sys_name; + type GlibType = *mut $ffi_name; } impl<'a> $crate::glib::value::FromValueOptional<'a> for &'a $ref_name { unsafe fn from_value_optional(v: &'a glib::Value) -> Option { - let ptr = gobject_sys::g_value_get_boxed($crate::glib::translate::ToGlibPtr::to_glib_none(v).0); + let ptr = glib::gobject_ffi::g_value_get_boxed($crate::glib::translate::ToGlibPtr::to_glib_none(v).0); if ptr.is_null() { None } else { diff --git a/gstreamer/src/object.rs b/gstreamer/src/object.rs index 3c2e5f7ca..9eb106175 100644 --- a/gstreamer/src/object.rs +++ b/gstreamer/src/object.rs @@ -6,19 +6,16 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use glib; use glib::object::{Cast, ObjectExt}; use glib::signal::SignalHandlerId; use glib::translate::*; use glib::IsA; -use gobject_sys; - -use ClockTime; -use ObjectFlags; +use crate::ClockTime; +use crate::ObjectFlags; pub trait GstObjectExtManual: 'static { - fn connect_deep_notify( + fn connect_deep_notify( &self, name: Option<&str>, f: F, @@ -39,8 +36,10 @@ pub trait GstObjectExtManual: 'static { ) -> Result<(), glib::error::BoolError>; } -impl> GstObjectExtManual for O { - fn connect_deep_notify( +impl> GstObjectExtManual for O { + fn connect_deep_notify< + F: Fn(&Self, &crate::Object, &glib::ParamSpec) + Send + Sync + 'static, + >( &self, name: Option<&str>, f: F, @@ -52,7 +51,7 @@ impl> GstObjectExtManual for O { }; let obj: Borrowed = - unsafe { from_glib_borrow(self.as_ptr() as *mut gobject_sys::GObject) }; + unsafe { from_glib_borrow(self.as_ptr() as *mut glib::gobject_ffi::GObject) }; obj.connect(signal_name.as_str(), false, move |values| { // It would be nice to display the actual signal name in the panic messages below, @@ -60,20 +59,20 @@ impl> GstObjectExtManual for O { // which seems too much for the messages of development errors let obj: O = unsafe { values[0] - .get::<::Object>() + .get::() .unwrap_or_else(|err| { panic!("Object signal \"deep-notify\": values[0]: {}", err) }) .expect("Object signal \"deep-notify\": values[0] not defined") .unsafe_cast() }; - let prop_obj: ::Object = values[1] + let prop_obj: crate::Object = values[1] .get() .unwrap_or_else(|err| panic!("Object signal \"deep-notify\": values[1]: {}", err)) .expect("Object signal \"deep-notify\": values[1] not defined"); let pspec = unsafe { - let pspec = gobject_sys::g_value_get_param(values[2].to_glib_none().0); + let pspec = glib::gobject_ffi::g_value_get_param(values[2].to_glib_none().0); from_glib_none(pspec) }; @@ -86,24 +85,24 @@ impl> GstObjectExtManual for O { fn set_object_flags(&self, flags: ObjectFlags) { unsafe { - let ptr: *mut gst_sys::GstObject = self.as_ptr() as *mut _; - let _guard = ::utils::MutexGuard::lock(&(*ptr).lock); + let ptr: *mut ffi::GstObject = self.as_ptr() as *mut _; + let _guard = crate::utils::MutexGuard::lock(&(*ptr).lock); (*ptr).flags |= flags.to_glib(); } } fn unset_object_flags(&self, flags: ObjectFlags) { unsafe { - let ptr: *mut gst_sys::GstObject = self.as_ptr() as *mut _; - let _guard = ::utils::MutexGuard::lock(&(*ptr).lock); + let ptr: *mut ffi::GstObject = self.as_ptr() as *mut _; + let _guard = crate::utils::MutexGuard::lock(&(*ptr).lock); (*ptr).flags &= !flags.to_glib(); } } fn get_object_flags(&self) -> ObjectFlags { unsafe { - let ptr: *mut gst_sys::GstObject = self.as_ptr() as *mut _; - let _guard = ::utils::MutexGuard::lock(&(*ptr).lock); + let ptr: *mut ffi::GstObject = self.as_ptr() as *mut _; + let _guard = crate::utils::MutexGuard::lock(&(*ptr).lock); from_glib((*ptr).flags) } } @@ -117,14 +116,14 @@ impl> GstObjectExtManual for O { ) -> Result<(), glib::error::BoolError> { let n_values = values.len() as u32; unsafe { - glib_result_from_gboolean!( - gst_sys::gst_object_get_g_value_array( + glib::glib_result_from_gboolean!( + ffi::gst_object_get_g_value_array( self.as_ref().to_glib_none().0, property_name.to_glib_none().0, timestamp.to_glib(), interval.to_glib(), n_values, - values.as_mut_ptr() as *mut gobject_sys::GValue, + values.as_mut_ptr() as *mut glib::gobject_ffi::GValue, ), "Failed to get value array" ) @@ -135,15 +134,15 @@ impl> GstObjectExtManual for O { #[cfg(test)] mod tests { use super::*; - use prelude::*; + use crate::prelude::*; use std::sync::{Arc, Mutex}; #[test] fn test_deep_notify() { - ::init().unwrap(); + crate::init().unwrap(); - let bin = ::Bin::new(None); - let identity = ::ElementFactory::make("identity", Some("id")).unwrap(); + let bin = crate::Bin::new(None); + let identity = crate::ElementFactory::make("identity", Some("id")).unwrap(); bin.add(&identity).unwrap(); let notify = Arc::new(Mutex::new(None)); @@ -155,7 +154,7 @@ mod tests { identity.set_property("silent", &false).unwrap(); assert_eq!( *notify.lock().unwrap(), - Some((identity.upcast::<::Object>(), "silent")) + Some((identity.upcast::(), "silent")) ); } } diff --git a/gstreamer/src/pad.rs b/gstreamer/src/pad.rs index 1c49c2e1a..5b69eaffe 100644 --- a/gstreamer/src/pad.rs +++ b/gstreamer/src/pad.rs @@ -6,46 +6,40 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use Buffer; -use BufferList; -use Event; -use FlowError; -use FlowReturn; -use FlowSuccess; -use Format; -use FormattedValue; -use GenericFormattedValue; -use LoggableError; -use Pad; -use PadFlags; -use PadLinkCheck; -use PadLinkError; -use PadLinkReturn; -use PadLinkSuccess; -use PadProbeReturn; -use PadProbeType; -use Query; -use QueryRef; -use SpecificFormattedValue; -use StaticPadTemplate; +use crate::Buffer; +use crate::BufferList; +use crate::Event; +use crate::FlowError; +use crate::FlowReturn; +use crate::FlowSuccess; +use crate::Format; +use crate::FormattedValue; +use crate::GenericFormattedValue; +use crate::LoggableError; +use crate::Pad; +use crate::PadFlags; +use crate::PadLinkCheck; +use crate::PadLinkError; +use crate::PadLinkReturn; +use crate::PadLinkSuccess; +use crate::PadProbeReturn; +use crate::PadProbeType; +use crate::Query; +use crate::QueryRef; +use crate::SpecificFormattedValue; +use crate::StaticPadTemplate; use std::cell::RefCell; use std::mem; use std::num::NonZeroU64; use std::ptr; -use glib; +use glib::ffi::gpointer; use glib::object::{Cast, IsA}; use glib::translate::{ from_glib, from_glib_borrow, from_glib_full, FromGlib, FromGlibPtrBorrow, ToGlib, ToGlibPtr, }; use glib::StaticType; -use glib_sys; -use glib_sys::gpointer; - -use libc; - -use gst_sys; #[derive(Debug, PartialEq, Eq)] pub struct PadProbeId(NonZeroU64); @@ -83,7 +77,7 @@ pub enum PadProbeData<'a> { Query(&'a mut QueryRef), Event(Event), #[doc(hidden)] - __Unknown(*mut gst_sys::GstMiniObject), + __Unknown(*mut ffi::GstMiniObject), } unsafe impl<'a> Send for PadProbeData<'a> {} @@ -95,8 +89,8 @@ pub struct StreamLock<'a>(&'a Pad); impl<'a> Drop for StreamLock<'a> { fn drop(&mut self) { unsafe { - let pad: *mut gst_sys::GstPad = self.0.to_glib_none().0; - glib_sys::g_rec_mutex_unlock(&mut (*pad).stream_rec_lock); + let pad: *mut ffi::GstPad = self.0.to_glib_none().0; + glib::ffi::g_rec_mutex_unlock(&mut (*pad).stream_rec_lock); } } } @@ -104,7 +98,7 @@ impl<'a> Drop for StreamLock<'a> { #[derive(Debug)] pub enum PadGetRangeSuccess { FilledBuffer, - NewBuffer(::Buffer), + NewBuffer(crate::Buffer), } pub trait PadExtManual: 'static { @@ -123,34 +117,38 @@ pub trait PadExtManual: 'static { fn pull_range_fill( &self, offset: u64, - buffer: &mut ::BufferRef, + buffer: &mut crate::BufferRef, size: u32, ) -> Result<(), FlowError>; fn get_range(&self, offset: u64, size: u32) -> Result; fn get_range_fill( &self, offset: u64, - buffer: &mut ::BufferRef, + buffer: &mut crate::BufferRef, size: u32, ) -> Result<(), FlowError>; fn peer_query(&self, query: &mut QueryRef) -> bool; fn query(&self, query: &mut QueryRef) -> bool; - fn query_default>(&self, parent: Option<&P>, query: &mut QueryRef) -> bool; + fn query_default>( + &self, + parent: Option<&P>, + query: &mut QueryRef, + ) -> bool; fn proxy_query_caps(&self, query: &mut QueryRef) -> bool; fn proxy_query_accept_caps(&self, query: &mut QueryRef) -> bool; - fn event_default>(&self, parent: Option<&P>, event: Event) -> bool; + fn event_default>(&self, parent: Option<&P>, event: Event) -> bool; fn push_event(&self, event: Event) -> bool; fn send_event(&self, event: Event) -> bool; fn get_last_flow_result(&self) -> Result; - fn iterate_internal_links(&self) -> ::Iterator; - fn iterate_internal_links_default>( + fn iterate_internal_links(&self) -> crate::Iterator; + fn iterate_internal_links_default>( &self, parent: Option<&P>, - ) -> ::Iterator; + ) -> crate::Iterator; fn link>(&self, sinkpad: &P) -> Result; fn link_full>( @@ -163,36 +161,36 @@ pub trait PadExtManual: 'static { unsafe fn set_activate_function(&self, func: F) where - F: Fn(&Self, Option<&::Object>) -> Result<(), LoggableError> + Send + Sync + 'static; + F: Fn(&Self, Option<&crate::Object>) -> Result<(), LoggableError> + Send + Sync + 'static; unsafe fn set_activatemode_function(&self, func: F) where - F: Fn(&Self, Option<&::Object>, ::PadMode, bool) -> Result<(), LoggableError> + F: Fn(&Self, Option<&crate::Object>, crate::PadMode, bool) -> Result<(), LoggableError> + Send + Sync + 'static; unsafe fn set_chain_function(&self, func: F) where - F: Fn(&Self, Option<&::Object>, ::Buffer) -> Result + F: Fn(&Self, Option<&crate::Object>, crate::Buffer) -> Result + Send + Sync + 'static; unsafe fn set_chain_list_function(&self, func: F) where - F: Fn(&Self, Option<&::Object>, ::BufferList) -> Result + F: Fn(&Self, Option<&crate::Object>, crate::BufferList) -> Result + Send + Sync + 'static; unsafe fn set_event_function(&self, func: F) where - F: Fn(&Self, Option<&::Object>, ::Event) -> bool + Send + Sync + 'static; + F: Fn(&Self, Option<&crate::Object>, crate::Event) -> bool + Send + Sync + 'static; unsafe fn set_event_full_function(&self, func: F) where - F: Fn(&Self, Option<&::Object>, ::Event) -> Result + F: Fn(&Self, Option<&crate::Object>, crate::Event) -> Result + Send + Sync + 'static; @@ -201,33 +199,37 @@ pub trait PadExtManual: 'static { where F: Fn( &Self, - Option<&::Object>, + Option<&crate::Object>, u64, - Option<&mut ::BufferRef>, + Option<&mut crate::BufferRef>, u32, - ) -> Result + ) -> Result + Send + Sync + 'static; unsafe fn set_iterate_internal_links_function(&self, func: F) where - F: Fn(&Self, Option<&::Object>) -> ::Iterator + Send + Sync + 'static; + F: Fn(&Self, Option<&crate::Object>) -> crate::Iterator + Send + Sync + 'static; unsafe fn set_link_function(&self, func: F) where - F: Fn(&Self, Option<&::Object>, &Pad) -> Result<::PadLinkSuccess, ::PadLinkError> + F: Fn( + &Self, + Option<&crate::Object>, + &Pad, + ) -> Result + Send + Sync + 'static; unsafe fn set_query_function(&self, func: F) where - F: Fn(&Self, Option<&::Object>, &mut ::QueryRef) -> bool + Send + Sync + 'static; + F: Fn(&Self, Option<&crate::Object>, &mut crate::QueryRef) -> bool + Send + Sync + 'static; unsafe fn set_unlink_function(&self, func: F) where - F: Fn(&Self, Option<&::Object>) + Send + Sync + 'static; + F: Fn(&Self, Option<&crate::Object>) + Send + Sync + 'static; fn start_task(&self, func: F) -> Result<(), glib::BoolError>; @@ -263,7 +265,7 @@ pub trait PadExtManual: 'static { fn query_position(&self) -> Option; fn query_position_generic(&self, format: Format) -> Option; - fn get_mode(&self) -> ::PadMode; + fn get_mode(&self) -> crate::PadMode; fn sticky_events_foreach Result, Option>>( &self, @@ -286,7 +288,7 @@ impl> PadExtManual for O { { unsafe { let func_box: Box = Box::new(func); - let id = gst_sys::gst_pad_add_probe( + let id = ffi::gst_pad_add_probe( self.as_ref().to_glib_none().0, mask.to_glib(), Some(trampoline_pad_probe::), @@ -304,13 +306,13 @@ impl> PadExtManual for O { fn remove_probe(&self, id: PadProbeId) { unsafe { - gst_sys::gst_pad_remove_probe(self.as_ref().to_glib_none().0, id.to_glib()); + ffi::gst_pad_remove_probe(self.as_ref().to_glib_none().0, id.to_glib()); } } fn chain(&self, buffer: Buffer) -> Result { unsafe { - FlowReturn::from_glib(gst_sys::gst_pad_chain( + FlowReturn::from_glib(ffi::gst_pad_chain( self.as_ref().to_glib_none().0, buffer.into_ptr(), )) @@ -320,7 +322,7 @@ impl> PadExtManual for O { fn push(&self, buffer: Buffer) -> Result { unsafe { - FlowReturn::from_glib(gst_sys::gst_pad_push( + FlowReturn::from_glib(ffi::gst_pad_push( self.as_ref().to_glib_none().0, buffer.into_ptr(), )) @@ -330,7 +332,7 @@ impl> PadExtManual for O { fn chain_list(&self, list: BufferList) -> Result { unsafe { - FlowReturn::from_glib(gst_sys::gst_pad_chain_list( + FlowReturn::from_glib(ffi::gst_pad_chain_list( self.as_ref().to_glib_none().0, list.into_ptr(), )) @@ -340,7 +342,7 @@ impl> PadExtManual for O { fn push_list(&self, list: BufferList) -> Result { unsafe { - FlowReturn::from_glib(gst_sys::gst_pad_push_list( + FlowReturn::from_glib(ffi::gst_pad_push_list( self.as_ref().to_glib_none().0, list.into_ptr(), )) @@ -351,7 +353,7 @@ impl> PadExtManual for O { fn get_range(&self, offset: u64, size: u32) -> Result { unsafe { let mut buffer = ptr::null_mut(); - let ret: FlowReturn = from_glib(gst_sys::gst_pad_get_range( + let ret: FlowReturn = from_glib(ffi::gst_pad_get_range( self.as_ref().to_glib_none().0, offset, size, @@ -364,14 +366,14 @@ impl> PadExtManual for O { fn get_range_fill( &self, offset: u64, - buffer: &mut ::BufferRef, + buffer: &mut crate::BufferRef, size: u32, ) -> Result<(), FlowError> { assert!(buffer.get_size() >= size as usize); unsafe { let mut buffer_ref = buffer.as_mut_ptr(); - let ret: FlowReturn = from_glib(gst_sys::gst_pad_get_range( + let ret: FlowReturn = from_glib(ffi::gst_pad_get_range( self.as_ref().to_glib_none().0, offset, size, @@ -380,8 +382,8 @@ impl> PadExtManual for O { match ret.into_result_value(|| ()) { Ok(_) => { if buffer.as_mut_ptr() != buffer_ref { - gst_sys::gst_mini_object_unref(buffer_ref as *mut _); - Err(::FlowError::Error) + ffi::gst_mini_object_unref(buffer_ref as *mut _); + Err(crate::FlowError::Error) } else { Ok(()) } @@ -394,7 +396,7 @@ impl> PadExtManual for O { fn pull_range(&self, offset: u64, size: u32) -> Result { unsafe { let mut buffer = ptr::null_mut(); - let ret: FlowReturn = from_glib(gst_sys::gst_pad_pull_range( + let ret: FlowReturn = from_glib(ffi::gst_pad_pull_range( self.as_ref().to_glib_none().0, offset, size, @@ -407,14 +409,14 @@ impl> PadExtManual for O { fn pull_range_fill( &self, offset: u64, - buffer: &mut ::BufferRef, + buffer: &mut crate::BufferRef, size: u32, ) -> Result<(), FlowError> { assert!(buffer.get_size() >= size as usize); unsafe { let mut buffer_ref = buffer.as_mut_ptr(); - let ret: FlowReturn = from_glib(gst_sys::gst_pad_pull_range( + let ret: FlowReturn = from_glib(ffi::gst_pad_pull_range( self.as_ref().to_glib_none().0, offset, size, @@ -423,8 +425,8 @@ impl> PadExtManual for O { match ret.into_result_value(|| ()) { Ok(_) => { if buffer.as_mut_ptr() != buffer_ref { - gst_sys::gst_mini_object_unref(buffer_ref as *mut _); - Err(::FlowError::Error) + ffi::gst_mini_object_unref(buffer_ref as *mut _); + Err(crate::FlowError::Error) } else { Ok(()) } @@ -436,7 +438,7 @@ impl> PadExtManual for O { fn query(&self, query: &mut QueryRef) -> bool { unsafe { - from_glib(gst_sys::gst_pad_query( + from_glib(ffi::gst_pad_query( self.as_ref().to_glib_none().0, query.as_mut_ptr(), )) @@ -445,17 +447,21 @@ impl> PadExtManual for O { fn peer_query(&self, query: &mut QueryRef) -> bool { unsafe { - from_glib(gst_sys::gst_pad_peer_query( + from_glib(ffi::gst_pad_peer_query( self.as_ref().to_glib_none().0, query.as_mut_ptr(), )) } } - fn query_default>(&self, parent: Option<&P>, query: &mut QueryRef) -> bool { + fn query_default>( + &self, + parent: Option<&P>, + query: &mut QueryRef, + ) -> bool { skip_assert_initialized!(); unsafe { - from_glib(gst_sys::gst_pad_query_default( + from_glib(ffi::gst_pad_query_default( self.as_ref().to_glib_none().0, parent.map(|p| p.as_ref()).to_glib_none().0, query.as_mut_ptr(), @@ -465,7 +471,7 @@ impl> PadExtManual for O { fn proxy_query_accept_caps(&self, query: &mut QueryRef) -> bool { unsafe { - from_glib(gst_sys::gst_pad_proxy_query_accept_caps( + from_glib(ffi::gst_pad_proxy_query_accept_caps( self.as_ref().to_glib_none().0, query.as_mut_ptr(), )) @@ -474,17 +480,17 @@ impl> PadExtManual for O { fn proxy_query_caps(&self, query: &mut QueryRef) -> bool { unsafe { - from_glib(gst_sys::gst_pad_proxy_query_accept_caps( + from_glib(ffi::gst_pad_proxy_query_accept_caps( self.as_ref().to_glib_none().0, query.as_mut_ptr(), )) } } - fn event_default>(&self, parent: Option<&P>, event: Event) -> bool { + fn event_default>(&self, parent: Option<&P>, event: Event) -> bool { skip_assert_initialized!(); unsafe { - from_glib(gst_sys::gst_pad_event_default( + from_glib(ffi::gst_pad_event_default( self.as_ref().to_glib_none().0, parent.map(|p| p.as_ref()).to_glib_none().0, event.into_ptr(), @@ -494,7 +500,7 @@ impl> PadExtManual for O { fn push_event(&self, event: Event) -> bool { unsafe { - from_glib(gst_sys::gst_pad_push_event( + from_glib(ffi::gst_pad_push_event( self.as_ref().to_glib_none().0, event.into_ptr(), )) @@ -503,7 +509,7 @@ impl> PadExtManual for O { fn send_event(&self, event: Event) -> bool { unsafe { - from_glib(gst_sys::gst_pad_send_event( + from_glib(ffi::gst_pad_send_event( self.as_ref().to_glib_none().0, event.into_ptr(), )) @@ -512,27 +518,27 @@ impl> PadExtManual for O { fn get_last_flow_result(&self) -> Result { let ret: FlowReturn = unsafe { - from_glib(gst_sys::gst_pad_get_last_flow_return( + from_glib(ffi::gst_pad_get_last_flow_return( self.as_ref().to_glib_none().0, )) }; ret.into_result() } - fn iterate_internal_links(&self) -> ::Iterator { + fn iterate_internal_links(&self) -> crate::Iterator { unsafe { - from_glib_full(gst_sys::gst_pad_iterate_internal_links( + from_glib_full(ffi::gst_pad_iterate_internal_links( self.as_ref().to_glib_none().0, )) } } - fn iterate_internal_links_default>( + fn iterate_internal_links_default>( &self, parent: Option<&P>, - ) -> ::Iterator { + ) -> crate::Iterator { unsafe { - from_glib_full(gst_sys::gst_pad_iterate_internal_links_default( + from_glib_full(ffi::gst_pad_iterate_internal_links_default( self.as_ref().to_glib_none().0, parent.map(|p| p.as_ref()).to_glib_none().0, )) @@ -541,7 +547,7 @@ impl> PadExtManual for O { fn link>(&self, sinkpad: &P) -> Result { let ret: PadLinkReturn = unsafe { - from_glib(gst_sys::gst_pad_link( + from_glib(ffi::gst_pad_link( self.as_ref().to_glib_none().0, sinkpad.as_ref().to_glib_none().0, )) @@ -555,7 +561,7 @@ impl> PadExtManual for O { flags: PadLinkCheck, ) -> Result { let ret: PadLinkReturn = unsafe { - from_glib(gst_sys::gst_pad_link_full( + from_glib(ffi::gst_pad_link_full( self.as_ref().to_glib_none().0, sinkpad.as_ref().to_glib_none().0, flags.to_glib(), @@ -566,18 +572,18 @@ impl> PadExtManual for O { fn stream_lock(&self) -> StreamLock { unsafe { - let ptr: &mut gst_sys::GstPad = &mut *(self.as_ptr() as *mut _); - glib_sys::g_rec_mutex_lock(&mut ptr.stream_rec_lock); + let ptr: &mut ffi::GstPad = &mut *(self.as_ptr() as *mut _); + glib::ffi::g_rec_mutex_lock(&mut ptr.stream_rec_lock); StreamLock(self.upcast_ref()) } } unsafe fn set_activate_function(&self, func: F) where - F: Fn(&Self, Option<&::Object>) -> Result<(), LoggableError> + Send + Sync + 'static, + F: Fn(&Self, Option<&crate::Object>) -> Result<(), LoggableError> + Send + Sync + 'static, { let func_box: Box = Box::new(func); - gst_sys::gst_pad_set_activate_function_full( + ffi::gst_pad_set_activate_function_full( self.as_ref().to_glib_none().0, Some(trampoline_activate_function::), Box::into_raw(func_box) as gpointer, @@ -587,13 +593,13 @@ impl> PadExtManual for O { unsafe fn set_activatemode_function(&self, func: F) where - F: Fn(&Self, Option<&::Object>, ::PadMode, bool) -> Result<(), LoggableError> + F: Fn(&Self, Option<&crate::Object>, crate::PadMode, bool) -> Result<(), LoggableError> + Send + Sync + 'static, { let func_box: Box = Box::new(func); - gst_sys::gst_pad_set_activatemode_function_full( + ffi::gst_pad_set_activatemode_function_full( self.as_ref().to_glib_none().0, Some(trampoline_activatemode_function::), Box::into_raw(func_box) as gpointer, @@ -603,13 +609,13 @@ impl> PadExtManual for O { unsafe fn set_chain_function(&self, func: F) where - F: Fn(&Self, Option<&::Object>, ::Buffer) -> Result + F: Fn(&Self, Option<&crate::Object>, crate::Buffer) -> Result + Send + Sync + 'static, { let func_box: Box = Box::new(func); - gst_sys::gst_pad_set_chain_function_full( + ffi::gst_pad_set_chain_function_full( self.as_ref().to_glib_none().0, Some(trampoline_chain_function::), Box::into_raw(func_box) as gpointer, @@ -619,13 +625,13 @@ impl> PadExtManual for O { unsafe fn set_chain_list_function(&self, func: F) where - F: Fn(&Self, Option<&::Object>, ::BufferList) -> Result + F: Fn(&Self, Option<&crate::Object>, crate::BufferList) -> Result + Send + Sync + 'static, { let func_box: Box = Box::new(func); - gst_sys::gst_pad_set_chain_list_function_full( + ffi::gst_pad_set_chain_list_function_full( self.as_ref().to_glib_none().0, Some(trampoline_chain_list_function::), Box::into_raw(func_box) as gpointer, @@ -635,10 +641,10 @@ impl> PadExtManual for O { unsafe fn set_event_function(&self, func: F) where - F: Fn(&Self, Option<&::Object>, ::Event) -> bool + Send + Sync + 'static, + F: Fn(&Self, Option<&crate::Object>, crate::Event) -> bool + Send + Sync + 'static, { let func_box: Box = Box::new(func); - gst_sys::gst_pad_set_event_function_full( + ffi::gst_pad_set_event_function_full( self.as_ref().to_glib_none().0, Some(trampoline_event_function::), Box::into_raw(func_box) as gpointer, @@ -648,13 +654,13 @@ impl> PadExtManual for O { unsafe fn set_event_full_function(&self, func: F) where - F: Fn(&Self, Option<&::Object>, ::Event) -> Result + F: Fn(&Self, Option<&crate::Object>, crate::Event) -> Result + Send + Sync + 'static, { let func_box: Box = Box::new(func); - gst_sys::gst_pad_set_event_full_function_full( + ffi::gst_pad_set_event_full_function_full( self.as_ref().to_glib_none().0, Some(trampoline_event_full_function::), Box::into_raw(func_box) as gpointer, @@ -666,17 +672,17 @@ impl> PadExtManual for O { where F: Fn( &Self, - Option<&::Object>, + Option<&crate::Object>, u64, - Option<&mut ::BufferRef>, + Option<&mut crate::BufferRef>, u32, - ) -> Result + ) -> Result + Send + Sync + 'static, { let func_box: Box = Box::new(func); - gst_sys::gst_pad_set_getrange_function_full( + ffi::gst_pad_set_getrange_function_full( self.as_ref().to_glib_none().0, Some(trampoline_getrange_function::), Box::into_raw(func_box) as gpointer, @@ -686,10 +692,10 @@ impl> PadExtManual for O { unsafe fn set_iterate_internal_links_function(&self, func: F) where - F: Fn(&Self, Option<&::Object>) -> ::Iterator + Send + Sync + 'static, + F: Fn(&Self, Option<&crate::Object>) -> crate::Iterator + Send + Sync + 'static, { let func_box: Box = Box::new(func); - gst_sys::gst_pad_set_iterate_internal_links_function_full( + ffi::gst_pad_set_iterate_internal_links_function_full( self.as_ref().to_glib_none().0, Some(trampoline_iterate_internal_links_function::), Box::into_raw(func_box) as gpointer, @@ -699,13 +705,17 @@ impl> PadExtManual for O { unsafe fn set_link_function(&self, func: F) where - F: Fn(&Self, Option<&::Object>, &Pad) -> Result<::PadLinkSuccess, ::PadLinkError> + F: Fn( + &Self, + Option<&crate::Object>, + &Pad, + ) -> Result + Send + Sync + 'static, { let func_box: Box = Box::new(func); - gst_sys::gst_pad_set_link_function_full( + ffi::gst_pad_set_link_function_full( self.as_ref().to_glib_none().0, Some(trampoline_link_function::), Box::into_raw(func_box) as gpointer, @@ -715,10 +725,10 @@ impl> PadExtManual for O { unsafe fn set_query_function(&self, func: F) where - F: Fn(&Self, Option<&::Object>, &mut ::QueryRef) -> bool + Send + Sync + 'static, + F: Fn(&Self, Option<&crate::Object>, &mut crate::QueryRef) -> bool + Send + Sync + 'static, { let func_box: Box = Box::new(func); - gst_sys::gst_pad_set_query_function_full( + ffi::gst_pad_set_query_function_full( self.as_ref().to_glib_none().0, Some(trampoline_query_function::), Box::into_raw(func_box) as gpointer, @@ -728,10 +738,10 @@ impl> PadExtManual for O { unsafe fn set_unlink_function(&self, func: F) where - F: Fn(&Self, Option<&::Object>) + Send + Sync + 'static, + F: Fn(&Self, Option<&crate::Object>) + Send + Sync + 'static, { let func_box: Box = Box::new(func); - gst_sys::gst_pad_set_unlink_function_full( + ffi::gst_pad_set_unlink_function_full( self.as_ref().to_glib_none().0, Some(trampoline_unlink_function::), Box::into_raw(func_box) as gpointer, @@ -741,8 +751,8 @@ impl> PadExtManual for O { fn start_task(&self, func: F) -> Result<(), glib::BoolError> { unsafe { - glib_result_from_gboolean!( - gst_sys::gst_pad_start_task( + glib::glib_result_from_gboolean!( + ffi::gst_pad_start_task( self.as_ref().to_glib_none().0, Some(trampoline_pad_task::), into_raw_pad_task(func), @@ -760,7 +770,7 @@ impl> PadExtManual for O { let src_val = src_val.into(); unsafe { let mut dest_val = mem::MaybeUninit::uninit(); - let ret = from_glib(gst_sys::gst_pad_peer_query_convert( + let ret = from_glib(ffi::gst_pad_peer_query_convert( self.as_ref().to_glib_none().0, src_val.get_format().to_glib(), src_val.to_raw_value(), @@ -783,7 +793,7 @@ impl> PadExtManual for O { let src_val = src_val.into(); unsafe { let mut dest_val = mem::MaybeUninit::uninit(); - let ret = from_glib(gst_sys::gst_pad_peer_query_convert( + let ret = from_glib(ffi::gst_pad_peer_query_convert( self.as_ref().to_glib_none().0, src_val.get_format().to_glib(), src_val.to_raw_value(), @@ -804,7 +814,7 @@ impl> PadExtManual for O { fn peer_query_duration(&self) -> Option { unsafe { let mut duration = mem::MaybeUninit::uninit(); - let ret = from_glib(gst_sys::gst_pad_peer_query_duration( + let ret = from_glib(ffi::gst_pad_peer_query_duration( self.as_ref().to_glib_none().0, T::get_default_format().to_glib(), duration.as_mut_ptr(), @@ -820,7 +830,7 @@ impl> PadExtManual for O { fn peer_query_duration_generic(&self, format: Format) -> Option { unsafe { let mut duration = mem::MaybeUninit::uninit(); - let ret = from_glib(gst_sys::gst_pad_peer_query_duration( + let ret = from_glib(ffi::gst_pad_peer_query_duration( self.as_ref().to_glib_none().0, format.to_glib(), duration.as_mut_ptr(), @@ -836,7 +846,7 @@ impl> PadExtManual for O { fn peer_query_position(&self) -> Option { unsafe { let mut cur = mem::MaybeUninit::uninit(); - let ret = from_glib(gst_sys::gst_pad_peer_query_position( + let ret = from_glib(ffi::gst_pad_peer_query_position( self.as_ref().to_glib_none().0, T::get_default_format().to_glib(), cur.as_mut_ptr(), @@ -852,7 +862,7 @@ impl> PadExtManual for O { fn peer_query_position_generic(&self, format: Format) -> Option { unsafe { let mut cur = mem::MaybeUninit::uninit(); - let ret = from_glib(gst_sys::gst_pad_peer_query_position( + let ret = from_glib(ffi::gst_pad_peer_query_position( self.as_ref().to_glib_none().0, format.to_glib(), cur.as_mut_ptr(), @@ -873,7 +883,7 @@ impl> PadExtManual for O { unsafe { let mut dest_val = mem::MaybeUninit::uninit(); - let ret = from_glib(gst_sys::gst_pad_query_convert( + let ret = from_glib(ffi::gst_pad_query_convert( self.as_ref().to_glib_none().0, src_val.get_format().to_glib(), src_val.to_raw_value(), @@ -897,7 +907,7 @@ impl> PadExtManual for O { unsafe { let mut dest_val = mem::MaybeUninit::uninit(); - let ret = from_glib(gst_sys::gst_pad_query_convert( + let ret = from_glib(ffi::gst_pad_query_convert( self.as_ref().to_glib_none().0, src_val.get_format().to_glib(), src_val.get_value(), @@ -918,7 +928,7 @@ impl> PadExtManual for O { fn query_duration(&self) -> Option { unsafe { let mut duration = mem::MaybeUninit::uninit(); - let ret = from_glib(gst_sys::gst_pad_query_duration( + let ret = from_glib(ffi::gst_pad_query_duration( self.as_ref().to_glib_none().0, T::get_default_format().to_glib(), duration.as_mut_ptr(), @@ -934,7 +944,7 @@ impl> PadExtManual for O { fn query_duration_generic(&self, format: Format) -> Option { unsafe { let mut duration = mem::MaybeUninit::uninit(); - let ret = from_glib(gst_sys::gst_pad_query_duration( + let ret = from_glib(ffi::gst_pad_query_duration( self.as_ref().to_glib_none().0, format.to_glib(), duration.as_mut_ptr(), @@ -950,7 +960,7 @@ impl> PadExtManual for O { fn query_position(&self) -> Option { unsafe { let mut cur = mem::MaybeUninit::uninit(); - let ret = from_glib(gst_sys::gst_pad_query_position( + let ret = from_glib(ffi::gst_pad_query_position( self.as_ref().to_glib_none().0, T::get_default_format().to_glib(), cur.as_mut_ptr(), @@ -966,7 +976,7 @@ impl> PadExtManual for O { fn query_position_generic(&self, format: Format) -> Option { unsafe { let mut cur = mem::MaybeUninit::uninit(); - let ret = from_glib(gst_sys::gst_pad_query_position( + let ret = from_glib(ffi::gst_pad_query_position( self.as_ref().to_glib_none().0, format.to_glib(), cur.as_mut_ptr(), @@ -979,9 +989,9 @@ impl> PadExtManual for O { } } - fn get_mode(&self) -> ::PadMode { + fn get_mode(&self) -> crate::PadMode { unsafe { - let ptr: &gst_sys::GstPad = &*(self.as_ptr() as *const _); + let ptr: &ffi::GstPad = &*(self.as_ptr() as *const _); from_glib(ptr.mode) } } @@ -991,10 +1001,10 @@ impl> PadExtManual for O { func: F, ) { unsafe extern "C" fn trampoline( - _pad: *mut gst_sys::GstPad, - event: *mut *mut gst_sys::GstEvent, - user_data: glib_sys::gpointer, - ) -> glib_sys::gboolean { + _pad: *mut ffi::GstPad, + event: *mut *mut ffi::GstEvent, + user_data: glib::ffi::gpointer, + ) -> glib::ffi::gboolean { let func = user_data as *mut &mut (dyn FnMut(Event) -> Result, Option>); let res = (*func)(from_glib_full(*event)); @@ -1002,19 +1012,19 @@ impl> PadExtManual for O { match res { Ok(Some(ev)) => { *event = ev.into_ptr(); - glib_sys::GTRUE + glib::ffi::GTRUE } Err(Some(ev)) => { *event = ev.into_ptr(); - glib_sys::GFALSE + glib::ffi::GFALSE } Ok(None) => { *event = ptr::null_mut(); - glib_sys::GTRUE + glib::ffi::GTRUE } Err(None) => { *event = ptr::null_mut(); - glib_sys::GFALSE + glib::ffi::GFALSE } } } @@ -1025,9 +1035,9 @@ impl> PadExtManual for O { &mut func; let func_ptr = &func_obj as *const &mut (dyn FnMut(Event) -> Result, Option>) - as glib_sys::gpointer; + as glib::ffi::gpointer; - gst_sys::gst_pad_sticky_events_foreach( + ffi::gst_pad_sticky_events_foreach( self.as_ref().to_glib_none().0, Some(trampoline), func_ptr, @@ -1037,7 +1047,7 @@ impl> PadExtManual for O { fn store_sticky_event(&self, event: &Event) -> Result { let ret: FlowReturn = unsafe { - from_glib(gst_sys::gst_pad_store_sticky_event( + from_glib(ffi::gst_pad_store_sticky_event( self.as_ref().to_glib_none().0, event.to_glib_none().0, )) @@ -1047,31 +1057,31 @@ impl> PadExtManual for O { fn set_pad_flags(&self, flags: PadFlags) { unsafe { - let ptr: *mut gst_sys::GstObject = self.as_ptr() as *mut _; - let _guard = ::utils::MutexGuard::lock(&(*ptr).lock); + let ptr: *mut ffi::GstObject = self.as_ptr() as *mut _; + let _guard = crate::utils::MutexGuard::lock(&(*ptr).lock); (*ptr).flags |= flags.to_glib(); } } fn unset_pad_flags(&self, flags: PadFlags) { unsafe { - let ptr: *mut gst_sys::GstObject = self.as_ptr() as *mut _; - let _guard = ::utils::MutexGuard::lock(&(*ptr).lock); + let ptr: *mut ffi::GstObject = self.as_ptr() as *mut _; + let _guard = crate::utils::MutexGuard::lock(&(*ptr).lock); (*ptr).flags &= !flags.to_glib(); } } fn get_pad_flags(&self) -> PadFlags { unsafe { - let ptr: *mut gst_sys::GstObject = self.as_ptr() as *mut _; - let _guard = ::utils::MutexGuard::lock(&(*ptr).lock); + let ptr: *mut ffi::GstObject = self.as_ptr() as *mut _; + let _guard = crate::utils::MutexGuard::lock(&(*ptr).lock); from_glib((*ptr).flags) } } } unsafe fn create_probe_info<'a>( - info: *mut gst_sys::GstPadProbeInfo, + info: *mut ffi::GstPadProbeInfo, ) -> (PadProbeInfo<'a>, Option) { let mut data_type = None; let flow_ret: FlowReturn = from_glib((*info).ABI.abi.flow_ret); @@ -1083,27 +1093,27 @@ unsafe fn create_probe_info<'a>( data: if (*info).data.is_null() { None } else { - let data = (*info).data as *mut gst_sys::GstMiniObject; + let data = (*info).data as *mut ffi::GstMiniObject; (*info).data = ptr::null_mut(); if (*data).type_ == Buffer::static_type().to_glib() { data_type = Some(Buffer::static_type()); Some(PadProbeData::Buffer(from_glib_full( - data as *const gst_sys::GstBuffer, + data as *const ffi::GstBuffer, ))) } else if (*data).type_ == BufferList::static_type().to_glib() { data_type = Some(BufferList::static_type()); Some(PadProbeData::BufferList(from_glib_full( - data as *const gst_sys::GstBufferList, + data as *const ffi::GstBufferList, ))) } else if (*data).type_ == Query::static_type().to_glib() { data_type = Some(Query::static_type()); Some(PadProbeData::Query(QueryRef::from_mut_ptr( - data as *mut gst_sys::GstQuery, + data as *mut ffi::GstQuery, ))) } else if (*data).type_ == Event::static_type().to_glib() { data_type = Some(Event::static_type()); Some(PadProbeData::Event(from_glib_full( - data as *const gst_sys::GstEvent, + data as *const ffi::GstEvent, ))) } else { Some(PadProbeData::__Unknown(data)) @@ -1118,7 +1128,7 @@ unsafe fn update_probe_info( ret: PadProbeReturn, probe_info: PadProbeInfo, data_type: Option, - info: *mut gst_sys::GstPadProbeInfo, + info: *mut ffi::GstPadProbeInfo, ) { if ret == PadProbeReturn::Handled { // Handled queries need to be returned @@ -1184,10 +1194,10 @@ unsafe extern "C" fn trampoline_pad_probe< T, F: Fn(&T, &mut PadProbeInfo) -> PadProbeReturn + Send + Sync + 'static, >( - pad: *mut gst_sys::GstPad, - info: *mut gst_sys::GstPadProbeInfo, + pad: *mut ffi::GstPad, + info: *mut ffi::GstPadProbeInfo, func: gpointer, -) -> gst_sys::GstPadProbeReturn +) -> ffi::GstPadProbeReturn where T: IsA, { @@ -1207,11 +1217,11 @@ where unsafe extern "C" fn trampoline_activate_function< T, - F: Fn(&T, Option<&::Object>) -> Result<(), LoggableError> + Send + Sync + 'static, + F: Fn(&T, Option<&crate::Object>) -> Result<(), LoggableError> + Send + Sync + 'static, >( - pad: *mut gst_sys::GstPad, - parent: *mut gst_sys::GstObject, -) -> glib_sys::gboolean + pad: *mut ffi::GstPad, + parent: *mut ffi::GstObject, +) -> glib::ffi::gboolean where T: IsA, { @@ -1219,7 +1229,7 @@ where match func( &Pad::from_glib_borrow(pad).unsafe_cast_ref(), - Option::<::Object>::from_glib_borrow(parent) + Option::::from_glib_borrow(parent) .as_ref() .as_ref(), ) { @@ -1234,13 +1244,16 @@ where unsafe extern "C" fn trampoline_activatemode_function< T, - F: Fn(&T, Option<&::Object>, ::PadMode, bool) -> Result<(), LoggableError> + Send + Sync + 'static, + F: Fn(&T, Option<&crate::Object>, crate::PadMode, bool) -> Result<(), LoggableError> + + Send + + Sync + + 'static, >( - pad: *mut gst_sys::GstPad, - parent: *mut gst_sys::GstObject, - mode: gst_sys::GstPadMode, - active: glib_sys::gboolean, -) -> glib_sys::gboolean + pad: *mut ffi::GstPad, + parent: *mut ffi::GstObject, + mode: ffi::GstPadMode, + active: glib::ffi::gboolean, +) -> glib::ffi::gboolean where T: IsA, { @@ -1248,7 +1261,7 @@ where match func( &&Pad::from_glib_borrow(pad).unsafe_cast_ref(), - Option::<::Object>::from_glib_borrow(parent) + Option::::from_glib_borrow(parent) .as_ref() .as_ref(), from_glib(mode), @@ -1265,12 +1278,15 @@ where unsafe extern "C" fn trampoline_chain_function< T, - F: Fn(&T, Option<&::Object>, ::Buffer) -> Result + Send + Sync + 'static, + F: Fn(&T, Option<&crate::Object>, crate::Buffer) -> Result + + Send + + Sync + + 'static, >( - pad: *mut gst_sys::GstPad, - parent: *mut gst_sys::GstObject, - buffer: *mut gst_sys::GstBuffer, -) -> gst_sys::GstFlowReturn + pad: *mut ffi::GstPad, + parent: *mut ffi::GstObject, + buffer: *mut ffi::GstBuffer, +) -> ffi::GstFlowReturn where T: IsA, { @@ -1278,7 +1294,7 @@ where let res: FlowReturn = func( &Pad::from_glib_borrow(pad).unsafe_cast_ref(), - Option::<::Object>::from_glib_borrow(parent) + Option::::from_glib_borrow(parent) .as_ref() .as_ref(), from_glib_full(buffer), @@ -1289,15 +1305,15 @@ where unsafe extern "C" fn trampoline_chain_list_function< T, - F: Fn(&T, Option<&::Object>, ::BufferList) -> Result + F: Fn(&T, Option<&crate::Object>, crate::BufferList) -> Result + Send + Sync + 'static, >( - pad: *mut gst_sys::GstPad, - parent: *mut gst_sys::GstObject, - list: *mut gst_sys::GstBufferList, -) -> gst_sys::GstFlowReturn + pad: *mut ffi::GstPad, + parent: *mut ffi::GstObject, + list: *mut ffi::GstBufferList, +) -> ffi::GstFlowReturn where T: IsA, { @@ -1305,7 +1321,7 @@ where let res: FlowReturn = func( &Pad::from_glib_borrow(pad).unsafe_cast_ref(), - Option::<::Object>::from_glib_borrow(parent) + Option::::from_glib_borrow(parent) .as_ref() .as_ref(), from_glib_full(list), @@ -1316,12 +1332,12 @@ where unsafe extern "C" fn trampoline_event_function< T, - F: Fn(&T, Option<&::Object>, ::Event) -> bool + Send + Sync + 'static, + F: Fn(&T, Option<&crate::Object>, crate::Event) -> bool + Send + Sync + 'static, >( - pad: *mut gst_sys::GstPad, - parent: *mut gst_sys::GstObject, - event: *mut gst_sys::GstEvent, -) -> glib_sys::gboolean + pad: *mut ffi::GstPad, + parent: *mut ffi::GstObject, + event: *mut ffi::GstEvent, +) -> glib::ffi::gboolean where T: IsA, { @@ -1329,7 +1345,7 @@ where func( &Pad::from_glib_borrow(pad).unsafe_cast_ref(), - Option::<::Object>::from_glib_borrow(parent) + Option::::from_glib_borrow(parent) .as_ref() .as_ref(), from_glib_full(event), @@ -1339,12 +1355,15 @@ where unsafe extern "C" fn trampoline_event_full_function< T, - F: Fn(&T, Option<&::Object>, ::Event) -> Result + Send + Sync + 'static, + F: Fn(&T, Option<&crate::Object>, crate::Event) -> Result + + Send + + Sync + + 'static, >( - pad: *mut gst_sys::GstPad, - parent: *mut gst_sys::GstObject, - event: *mut gst_sys::GstEvent, -) -> gst_sys::GstFlowReturn + pad: *mut ffi::GstPad, + parent: *mut ffi::GstObject, + event: *mut ffi::GstEvent, +) -> ffi::GstFlowReturn where T: IsA, { @@ -1352,7 +1371,7 @@ where let res: FlowReturn = func( &Pad::from_glib_borrow(pad).unsafe_cast_ref(), - Option::<::Object>::from_glib_borrow(parent) + Option::::from_glib_borrow(parent) .as_ref() .as_ref(), from_glib_full(event), @@ -1365,21 +1384,21 @@ unsafe extern "C" fn trampoline_getrange_function< T, F: Fn( &T, - Option<&::Object>, + Option<&crate::Object>, u64, - Option<&mut ::BufferRef>, + Option<&mut crate::BufferRef>, u32, - ) -> Result + ) -> Result + Send + Sync + 'static, >( - pad: *mut gst_sys::GstPad, - parent: *mut gst_sys::GstObject, + pad: *mut ffi::GstPad, + parent: *mut ffi::GstObject, offset: u64, length: u32, - buffer: *mut *mut gst_sys::GstBuffer, -) -> gst_sys::GstFlowReturn + buffer: *mut *mut ffi::GstBuffer, +) -> ffi::GstFlowReturn where T: IsA, { @@ -1392,12 +1411,12 @@ where let mut passed_buffer = if (*buffer).is_null() { None } else { - Some(::BufferRef::from_mut_ptr(*buffer)) + Some(crate::BufferRef::from_mut_ptr(*buffer)) }; match func( &pad, - Option::<::Object>::from_glib_borrow(parent) + Option::::from_glib_borrow(parent) .as_ref() .as_ref(), offset, @@ -1407,7 +1426,7 @@ where Ok(PadGetRangeSuccess::NewBuffer(new_buffer)) => { if let Some(passed_buffer) = passed_buffer { gst_debug!( - ::CAT_PERFORMANCE, + crate::CAT_PERFORMANCE, obj: pad.unsafe_cast_ref::(), "Returned new buffer from getrange function, copying into passed buffer" ); @@ -1416,11 +1435,11 @@ where Ok(map) => map, Err(_) => { gst_error!( - ::CAT_RUST, + crate::CAT_RUST, obj: pad.unsafe_cast_ref::(), "Failed to map passed buffer writable" ); - return gst_sys::GST_FLOW_ERROR; + return ffi::GST_FLOW_ERROR; } }; @@ -1431,11 +1450,11 @@ where passed_buffer.set_size(copied_size); } - match new_buffer.copy_into(passed_buffer, ::BUFFER_COPY_METADATA, 0, None) { + match new_buffer.copy_into(passed_buffer, crate::BUFFER_COPY_METADATA, 0, None) { Ok(_) => FlowReturn::Ok.to_glib(), Err(_) => { gst_error!( - ::CAT_RUST, + crate::CAT_RUST, obj: pad.unsafe_cast_ref::(), "Failed to copy buffer metadata" ); @@ -1458,11 +1477,11 @@ where unsafe extern "C" fn trampoline_iterate_internal_links_function< T, - F: Fn(&T, Option<&::Object>) -> ::Iterator + Send + Sync + 'static, + F: Fn(&T, Option<&crate::Object>) -> crate::Iterator + Send + Sync + 'static, >( - pad: *mut gst_sys::GstPad, - parent: *mut gst_sys::GstObject, -) -> *mut gst_sys::GstIterator + pad: *mut ffi::GstPad, + parent: *mut ffi::GstObject, +) -> *mut ffi::GstIterator where T: IsA, { @@ -1471,7 +1490,7 @@ where // Steal the iterator and return it let ret = func( &Pad::from_glib_borrow(pad).unsafe_cast_ref(), - Option::<::Object>::from_glib_borrow(parent) + Option::::from_glib_borrow(parent) .as_ref() .as_ref(), ); @@ -1481,23 +1500,27 @@ where unsafe extern "C" fn trampoline_link_function< T, - F: Fn(&T, Option<&::Object>, &::Pad) -> Result<::PadLinkSuccess, ::PadLinkError> + F: Fn( + &T, + Option<&crate::Object>, + &crate::Pad, + ) -> Result + Send + Sync + 'static, >( - pad: *mut gst_sys::GstPad, - parent: *mut gst_sys::GstObject, - peer: *mut gst_sys::GstPad, -) -> gst_sys::GstPadLinkReturn + pad: *mut ffi::GstPad, + parent: *mut ffi::GstObject, + peer: *mut ffi::GstPad, +) -> ffi::GstPadLinkReturn where T: IsA, { let func: &F = &*((*pad).linkdata as *const F); - let res: ::PadLinkReturn = func( + let res: crate::PadLinkReturn = func( &Pad::from_glib_borrow(pad).unsafe_cast_ref(), - Option::<::Object>::from_glib_borrow(parent) + Option::::from_glib_borrow(parent) .as_ref() .as_ref(), &from_glib_borrow(peer), @@ -1508,12 +1531,12 @@ where unsafe extern "C" fn trampoline_query_function< T, - F: Fn(&T, Option<&::Object>, &mut ::QueryRef) -> bool + Send + Sync + 'static, + F: Fn(&T, Option<&crate::Object>, &mut crate::QueryRef) -> bool + Send + Sync + 'static, >( - pad: *mut gst_sys::GstPad, - parent: *mut gst_sys::GstObject, - query: *mut gst_sys::GstQuery, -) -> glib_sys::gboolean + pad: *mut ffi::GstPad, + parent: *mut ffi::GstObject, + query: *mut ffi::GstQuery, +) -> glib::ffi::gboolean where T: IsA, { @@ -1521,20 +1544,20 @@ where func( &Pad::from_glib_borrow(pad).unsafe_cast_ref(), - Option::<::Object>::from_glib_borrow(parent) + Option::::from_glib_borrow(parent) .as_ref() .as_ref(), - ::QueryRef::from_mut_ptr(query), + crate::QueryRef::from_mut_ptr(query), ) .to_glib() } unsafe extern "C" fn trampoline_unlink_function< T, - F: Fn(&T, Option<&::Object>) + Send + Sync + 'static, + F: Fn(&T, Option<&crate::Object>) + Send + Sync + 'static, >( - pad: *mut gst_sys::GstPad, - parent: *mut gst_sys::GstObject, + pad: *mut ffi::GstPad, + parent: *mut ffi::GstObject, ) where T: IsA, { @@ -1542,7 +1565,7 @@ unsafe extern "C" fn trampoline_unlink_function< func( &Pad::from_glib_borrow(pad).unsafe_cast_ref(), - Option::<::Object>::from_glib_borrow(parent) + Option::::from_glib_borrow(parent) .as_ref() .as_ref(), ) @@ -1568,12 +1591,12 @@ unsafe extern "C" fn destroy_closure_pad_task(ptr: gpointer) { } impl Pad { - pub fn new(name: Option<&str>, direction: ::PadDirection) -> Self { + pub fn new(name: Option<&str>, direction: crate::PadDirection) -> Self { skip_assert_initialized!(); Self::builder(name, direction).build() } - pub fn builder(name: Option<&str>, direction: ::PadDirection) -> PadBuilder { + pub fn builder(name: Option<&str>, direction: crate::PadDirection) -> PadBuilder { skip_assert_initialized!(); PadBuilder::new(name, direction) } @@ -1591,12 +1614,15 @@ impl Pad { PadBuilder::from_static_template(templ, name) } - pub fn from_template(templ: &::PadTemplate, name: Option<&str>) -> Self { + pub fn from_template(templ: &crate::PadTemplate, name: Option<&str>) -> Self { skip_assert_initialized!(); Self::builder_with_template(templ, name).build() } - pub fn builder_with_template(templ: &::PadTemplate, name: Option<&str>) -> PadBuilder { + pub fn builder_with_template( + templ: &crate::PadTemplate, + name: Option<&str>, + ) -> PadBuilder { skip_assert_initialized!(); PadBuilder::from_template(templ, name) } @@ -1605,7 +1631,7 @@ impl Pad { pub struct PadBuilder(pub(crate) T); impl + IsA> PadBuilder { - pub fn new(name: Option<&str>, direction: ::PadDirection) -> Self { + pub fn new(name: Option<&str>, direction: crate::PadDirection) -> Self { assert_initialized_main_thread!(); let pad = glib::Object::new( @@ -1617,11 +1643,11 @@ impl + IsA> PadBuilder { .unwrap(); // Ghost pads are a bit special - if let Some(pad) = pad.dynamic_cast_ref::<::GhostPad>() { + if let Some(pad) = pad.dynamic_cast_ref::() { unsafe { - let res = gst_sys::gst_ghost_pad_construct(pad.to_glib_none().0); + let res = ffi::gst_ghost_pad_construct(pad.to_glib_none().0); // This can't really fail... - assert_ne!(res, glib_sys::GFALSE, "Failed to construct ghost pad"); + assert_ne!(res, glib::ffi::GFALSE, "Failed to construct ghost pad"); } } @@ -1635,7 +1661,7 @@ impl + IsA> PadBuilder { Self::from_template(&templ, name) } - pub fn from_template(templ: &::PadTemplate, name: Option<&str>) -> Self { + pub fn from_template(templ: &crate::PadTemplate, name: Option<&str>) -> Self { assert_initialized_main_thread!(); use glib::ObjectExt; @@ -1676,11 +1702,11 @@ impl + IsA> PadBuilder { .unwrap(); // Ghost pads are a bit special - if let Some(pad) = pad.dynamic_cast_ref::<::GhostPad>() { + if let Some(pad) = pad.dynamic_cast_ref::() { unsafe { - let res = gst_sys::gst_ghost_pad_construct(pad.to_glib_none().0); + let res = ffi::gst_ghost_pad_construct(pad.to_glib_none().0); // This can't really fail... - assert_ne!(res, glib_sys::GFALSE, "Failed to construct ghost pad"); + assert_ne!(res, glib::ffi::GFALSE, "Failed to construct ghost pad"); } } @@ -1689,7 +1715,7 @@ impl + IsA> PadBuilder { pub fn activate_function(self, func: F) -> Self where - F: Fn(&T, Option<&::Object>) -> Result<(), LoggableError> + Send + Sync + 'static, + F: Fn(&T, Option<&crate::Object>) -> Result<(), LoggableError> + Send + Sync + 'static, { unsafe { self.0.set_activate_function(func); @@ -1700,7 +1726,7 @@ impl + IsA> PadBuilder { pub fn activatemode_function(self, func: F) -> Self where - F: Fn(&T, Option<&::Object>, ::PadMode, bool) -> Result<(), LoggableError> + F: Fn(&T, Option<&crate::Object>, crate::PadMode, bool) -> Result<(), LoggableError> + Send + Sync + 'static, @@ -1714,7 +1740,7 @@ impl + IsA> PadBuilder { pub fn chain_function(self, func: F) -> Self where - F: Fn(&T, Option<&::Object>, ::Buffer) -> Result + F: Fn(&T, Option<&crate::Object>, crate::Buffer) -> Result + Send + Sync + 'static, @@ -1728,7 +1754,7 @@ impl + IsA> PadBuilder { pub fn chain_list_function(self, func: F) -> Self where - F: Fn(&T, Option<&::Object>, ::BufferList) -> Result + F: Fn(&T, Option<&crate::Object>, crate::BufferList) -> Result + Send + Sync + 'static, @@ -1742,7 +1768,7 @@ impl + IsA> PadBuilder { pub fn event_function(self, func: F) -> Self where - F: Fn(&T, Option<&::Object>, ::Event) -> bool + Send + Sync + 'static, + F: Fn(&T, Option<&crate::Object>, crate::Event) -> bool + Send + Sync + 'static, { unsafe { self.0.set_event_function(func); @@ -1753,7 +1779,7 @@ impl + IsA> PadBuilder { pub fn event_full_function(self, func: F) -> Self where - F: Fn(&T, Option<&::Object>, ::Event) -> Result + F: Fn(&T, Option<&crate::Object>, crate::Event) -> Result + Send + Sync + 'static, @@ -1769,11 +1795,11 @@ impl + IsA> PadBuilder { where F: Fn( &T, - Option<&::Object>, + Option<&crate::Object>, u64, - Option<&mut ::BufferRef>, + Option<&mut crate::BufferRef>, u32, - ) -> Result + ) -> Result + Send + Sync + 'static, @@ -1787,7 +1813,7 @@ impl + IsA> PadBuilder { pub fn iterate_internal_links_function(self, func: F) -> Self where - F: Fn(&T, Option<&::Object>) -> ::Iterator + Send + Sync + 'static, + F: Fn(&T, Option<&crate::Object>) -> crate::Iterator + Send + Sync + 'static, { unsafe { self.0.set_iterate_internal_links_function(func); @@ -1798,7 +1824,11 @@ impl + IsA> PadBuilder { pub fn link_function(self, func: F) -> Self where - F: Fn(&T, Option<&::Object>, &Pad) -> Result<::PadLinkSuccess, ::PadLinkError> + F: Fn( + &T, + Option<&crate::Object>, + &Pad, + ) -> Result + Send + Sync + 'static, @@ -1812,7 +1842,7 @@ impl + IsA> PadBuilder { pub fn query_function(self, func: F) -> Self where - F: Fn(&T, Option<&::Object>, &mut ::QueryRef) -> bool + Send + Sync + 'static, + F: Fn(&T, Option<&crate::Object>, &mut crate::QueryRef) -> bool + Send + Sync + 'static, { unsafe { self.0.set_query_function(func); @@ -1823,7 +1853,7 @@ impl + IsA> PadBuilder { pub fn unlink_function(self, func: F) -> Self where - F: Fn(&T, Option<&::Object>) + Send + Sync + 'static, + F: Fn(&T, Option<&crate::Object>) + Send + Sync + 'static, { unsafe { self.0.set_unlink_function(func); @@ -1846,19 +1876,19 @@ impl + IsA> PadBuilder { #[cfg(test)] mod tests { use super::*; - use prelude::*; + use crate::prelude::*; use std::sync::mpsc::channel; use std::sync::{Arc, Mutex}; #[test] fn test_event_chain_functions() { - ::init().unwrap(); + crate::init().unwrap(); let events = Arc::new(Mutex::new(Vec::new())); let events_clone = events.clone(); let buffers = Arc::new(Mutex::new(Vec::new())); let buffers_clone = buffers.clone(); - let pad = ::Pad::builder(Some("sink"), ::PadDirection::Sink) + let pad = crate::Pad::builder(Some("sink"), crate::PadDirection::Sink) .event_function(move |_, _, event| { let mut events = events_clone.lock().unwrap(); events.push(event); @@ -1875,11 +1905,11 @@ mod tests { pad.set_active(true).unwrap(); - assert!(pad.send_event(::event::StreamStart::new("test"))); - let segment = ::FormattedSegment::<::ClockTime>::new(); - assert!(pad.send_event(::event::Segment::new(segment.as_ref()))); + assert!(pad.send_event(crate::event::StreamStart::new("test"))); + let segment = crate::FormattedSegment::::new(); + assert!(pad.send_event(crate::event::Segment::new(segment.as_ref()))); - assert_eq!(pad.chain(::Buffer::new()), Ok(FlowSuccess::Ok)); + assert_eq!(pad.chain(crate::Buffer::new()), Ok(FlowSuccess::Ok)); let events = events.lock().unwrap(); let buffers = buffers.lock().unwrap(); @@ -1887,29 +1917,29 @@ mod tests { assert_eq!(buffers.len(), 1); match events[0].view() { - ::EventView::StreamStart(..) => (), + crate::EventView::StreamStart(..) => (), _ => unreachable!(), } match events[1].view() { - ::EventView::Segment(..) => (), + crate::EventView::Segment(..) => (), _ => unreachable!(), } } #[test] fn test_getrange_function() { - ::init().unwrap(); + crate::init().unwrap(); - let pad = ::Pad::builder(Some("src"), ::PadDirection::Src) + let pad = crate::Pad::builder(Some("src"), crate::PadDirection::Src) .activate_function(|pad, _parent| { - pad.activate_mode(::PadMode::Pull, true) + pad.activate_mode(crate::PadMode::Pull, true) .map_err(|err| err.into()) }) .getrange_function(|_pad, _parent, offset, _buffer, size| { assert_eq!(offset, 0); assert_eq!(size, 5); - let buffer = ::Buffer::from_slice(b"abcde"); + let buffer = crate::Buffer::from_slice(b"abcde"); Ok(PadGetRangeSuccess::NewBuffer(buffer)) }) .build(); @@ -1919,7 +1949,7 @@ mod tests { let map = buffer.map_readable().unwrap(); assert_eq!(&*map, b"abcde"); - let mut buffer = ::Buffer::with_size(5).unwrap(); + let mut buffer = crate::Buffer::with_size(5).unwrap(); pad.get_range_fill(0, buffer.get_mut().unwrap(), 5).unwrap(); let map = buffer.map_readable().unwrap(); assert_eq!(&*map, b"abcde"); @@ -1927,9 +1957,9 @@ mod tests { pad.set_active(false).unwrap(); drop(pad); - let pad = ::Pad::builder(Some("src"), ::PadDirection::Src) + let pad = crate::Pad::builder(Some("src"), crate::PadDirection::Src) .activate_function(|pad, _parent| { - pad.activate_mode(::PadMode::Pull, true) + pad.activate_mode(crate::PadMode::Pull, true) .map_err(|err| err.into()) }) .getrange_function(|_pad, _parent, offset, buffer, size| { @@ -1939,7 +1969,7 @@ mod tests { buffer.copy_from_slice(0, b"fghij").unwrap(); Ok(PadGetRangeSuccess::FilledBuffer) } else { - let buffer = ::Buffer::from_slice(b"abcde"); + let buffer = crate::Buffer::from_slice(b"abcde"); Ok(PadGetRangeSuccess::NewBuffer(buffer)) } }) @@ -1950,7 +1980,7 @@ mod tests { let map = buffer.map_readable().unwrap(); assert_eq!(&*map, b"abcde"); - let mut buffer = ::Buffer::with_size(5).unwrap(); + let mut buffer = crate::Buffer::with_size(5).unwrap(); pad.get_range_fill(0, buffer.get_mut().unwrap(), 5).unwrap(); let map = buffer.map_readable().unwrap(); assert_eq!(&*map, b"fghij"); @@ -1958,9 +1988,9 @@ mod tests { #[test] fn test_task() { - ::init().unwrap(); + crate::init().unwrap(); - let pad = ::Pad::new(Some("sink"), ::PadDirection::Sink); + let pad = crate::Pad::new(Some("sink"), crate::PadDirection::Sink); let (sender, receiver) = channel(); let mut i = 0; @@ -1979,10 +2009,10 @@ mod tests { #[test] fn test_probe() { - ::init().unwrap(); + crate::init().unwrap(); - let (major, minor, micro, _) = ::version(); - let pad = ::Pad::new(Some("src"), ::PadDirection::Src); + let (major, minor, micro, _) = crate::version(); + let pad = crate::Pad::new(Some("src"), crate::PadDirection::Src); let events = Arc::new(Mutex::new(Vec::new())); let buffers = Arc::new(Mutex::new(Vec::new())); @@ -1996,34 +2026,34 @@ mod tests { { let events = events.clone(); - pad.add_probe(::PadProbeType::EVENT_DOWNSTREAM, move |_, info| { + pad.add_probe(crate::PadProbeType::EVENT_DOWNSTREAM, move |_, info| { if let Some(PadProbeData::Event(event)) = &info.data { let mut events = events.lock().unwrap(); events.push(event.clone()); } else { unreachable!(); } - ::PadProbeReturn::Ok + crate::PadProbeReturn::Ok }); } { let events = events.clone(); - pad.add_probe(::PadProbeType::EVENT_UPSTREAM, move |_, info| { + pad.add_probe(crate::PadProbeType::EVENT_UPSTREAM, move |_, info| { if let Some(PadProbeData::Event(event)) = info.data.take() { let mut events = events.lock().unwrap(); events.push(event); } else { unreachable!(); } - ::PadProbeReturn::Handled + crate::PadProbeReturn::Handled }); } { let buffers = buffers.clone(); let flow_override = flow_override; - pad.add_probe(::PadProbeType::BUFFER, move |_, info| { + pad.add_probe(crate::PadProbeType::BUFFER, move |_, info| { if let Some(PadProbeData::Buffer(buffer)) = info.data.take() { let mut buffers = buffers.lock().unwrap(); info.flow_res = if buffers.is_empty() { @@ -2035,28 +2065,32 @@ mod tests { } else { unreachable!(); } - ::PadProbeReturn::Handled + crate::PadProbeReturn::Handled }); } pad.set_active(true).unwrap(); - assert!(pad.send_event(::event::Latency::new(::ClockTime::from_nseconds(10)))); - assert!(pad.push_event(::event::StreamStart::new("test"))); - let segment = ::FormattedSegment::<::ClockTime>::new(); - assert!(pad.push_event(::event::Segment::new(segment.as_ref()))); + assert!( + pad.send_event(crate::event::Latency::new(crate::ClockTime::from_nseconds( + 10 + ))) + ); + assert!(pad.push_event(crate::event::StreamStart::new("test"))); + let segment = crate::FormattedSegment::::new(); + assert!(pad.push_event(crate::event::Segment::new(segment.as_ref()))); - assert_eq!(pad.push(::Buffer::new()), Ok(FlowSuccess::Ok)); - assert_eq!(pad.push(::Buffer::new()), flow_override); + assert_eq!(pad.push(crate::Buffer::new()), Ok(FlowSuccess::Ok)); + assert_eq!(pad.push(crate::Buffer::new()), flow_override); let events = events.lock().unwrap(); let buffers = buffers.lock().unwrap(); assert_eq!(events.len(), 3); assert_eq!(buffers.len(), 2); - assert_eq!(events[0].get_type(), ::EventType::Latency); - assert_eq!(events[1].get_type(), ::EventType::StreamStart); - assert_eq!(events[2].get_type(), ::EventType::Segment); + assert_eq!(events[0].get_type(), crate::EventType::Latency); + assert_eq!(events[1].get_type(), crate::EventType::StreamStart); + assert_eq!(events[2].get_type(), crate::EventType::Segment); assert!( buffers.iter().all(|b| b.is_writable()), diff --git a/gstreamer/src/pad_template.rs b/gstreamer/src/pad_template.rs index 71b509c0b..ab10cf56d 100644 --- a/gstreamer/src/pad_template.rs +++ b/gstreamer/src/pad_template.rs @@ -6,20 +6,13 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use crate::PadTemplate; +#[cfg(any(feature = "v1_14", feature = "dox"))] +#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_14")))] +use crate::StaticPadTemplate; #[cfg(any(feature = "v1_14", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_14")))] use glib::translate::*; -use PadTemplate; -#[cfg(any(feature = "v1_14", feature = "dox"))] -#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_14")))] -use StaticPadTemplate; - -#[cfg(any(feature = "v1_14", feature = "dox"))] -#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_14")))] -use glib; -#[cfg(any(feature = "v1_14", feature = "dox"))] -#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_14")))] -use gst_sys; impl PadTemplate { #[cfg(any(feature = "v1_14", feature = "dox"))] @@ -31,12 +24,12 @@ impl PadTemplate { assert_initialized_main_thread!(); unsafe { Option::<_>::from_glib_none( - gst_sys::gst_pad_template_new_from_static_pad_template_with_gtype( + ffi::gst_pad_template_new_from_static_pad_template_with_gtype( mut_override(pad_template.to_glib_none().0), pad_type.to_glib(), ), ) - .ok_or_else(|| glib_bool_error!("Failed to create PadTemplate")) + .ok_or_else(|| glib::glib_bool_error!("Failed to create PadTemplate")) } } } diff --git a/gstreamer/src/param_spec.rs b/gstreamer/src/param_spec.rs index 2717a8001..5ea65cc1e 100644 --- a/gstreamer/src/param_spec.rs +++ b/gstreamer/src/param_spec.rs @@ -6,9 +6,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use glib; use glib::translate::*; -use gst_sys; pub trait GstParamSpecExt { #[cfg(any(feature = "v1_14", feature = "dox"))] @@ -25,9 +23,9 @@ pub trait GstParamSpecExt { name: &str, nick: &str, blurb: &str, - min: ::Fraction, - max: ::Fraction, - default: ::Fraction, + min: crate::Fraction, + max: crate::Fraction, + default: crate::Fraction, flags: glib::ParamFlags, ) -> Self; } @@ -44,7 +42,7 @@ impl GstParamSpecExt for glib::ParamSpec { ) -> glib::ParamSpec { assert_initialized_main_thread!(); unsafe { - from_glib_full(gst_sys::gst_param_spec_array( + from_glib_full(ffi::gst_param_spec_array( name.to_glib_none().0, nick.to_glib_none().0, blurb.to_glib_none().0, @@ -58,14 +56,14 @@ impl GstParamSpecExt for glib::ParamSpec { name: &str, nick: &str, blurb: &str, - min: ::Fraction, - max: ::Fraction, - default: ::Fraction, + min: crate::Fraction, + max: crate::Fraction, + default: crate::Fraction, flags: glib::ParamFlags, ) -> glib::ParamSpec { assert_initialized_main_thread!(); unsafe { - from_glib_full(gst_sys::gst_param_spec_fraction( + from_glib_full(ffi::gst_param_spec_fraction( name.to_glib_none().0, nick.to_glib_none().0, blurb.to_glib_none().0, @@ -83,12 +81,11 @@ impl GstParamSpecExt for glib::ParamSpec { #[cfg(test)] mod tests { - use glib; - use prelude::*; + use crate::prelude::*; #[test] fn test_trait() { - ::init().unwrap(); + crate::init().unwrap(); let _pspec = glib::ParamSpec::fraction( "foo", diff --git a/gstreamer/src/parse_context.rs b/gstreamer/src/parse_context.rs index 0badea107..a9a0917ff 100644 --- a/gstreamer/src/parse_context.rs +++ b/gstreamer/src/parse_context.rs @@ -7,21 +7,19 @@ // except according to those terms. use glib::translate::*; -use gobject_sys; -use gst_sys; -glib_wrapper! { +glib::glib_wrapper! { #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] - pub struct ParseContext(Boxed); + pub struct ParseContext(Boxed); match fn { copy => |ptr| { - gobject_sys::g_boxed_copy(gst_sys::gst_parse_context_get_type(), ptr as *mut _) as *mut gst_sys::GstParseContext + glib::gobject_ffi::g_boxed_copy(ffi::gst_parse_context_get_type(), ptr as *mut _) as *mut ffi::GstParseContext }, free => |ptr| { - gobject_sys::g_boxed_free(gst_sys::gst_parse_context_get_type(), ptr as *mut _) + glib::gobject_ffi::g_boxed_free(ffi::gst_parse_context_get_type(), ptr as *mut _) }, - get_type => || gst_sys::gst_parse_context_get_type(), + get_type => || ffi::gst_parse_context_get_type(), } } @@ -30,12 +28,12 @@ unsafe impl Sync for ParseContext {} impl ParseContext { pub fn new() -> Self { - unsafe { from_glib_full(gst_sys::gst_parse_context_new()) } + unsafe { from_glib_full(ffi::gst_parse_context_new()) } } pub fn get_missing_elements(&self) -> Vec { unsafe { - FromGlibPtrContainer::from_glib_full(gst_sys::gst_parse_context_get_missing_elements( + FromGlibPtrContainer::from_glib_full(ffi::gst_parse_context_get_missing_elements( mut_override(self.to_glib_none().0), )) } diff --git a/gstreamer/src/pipeline.rs b/gstreamer/src/pipeline.rs index 738f7dc8d..e948092ec 100644 --- a/gstreamer/src/pipeline.rs +++ b/gstreamer/src/pipeline.rs @@ -9,7 +9,7 @@ use glib::translate::*; use glib::IsA; -use PipelineFlags; +use crate::PipelineFlags; pub trait GstPipelineExtManual: 'static { fn set_pipeline_flags(&self, flags: PipelineFlags); @@ -19,27 +19,27 @@ pub trait GstPipelineExtManual: 'static { fn get_pipeline_flags(&self) -> PipelineFlags; } -impl> GstPipelineExtManual for O { +impl> GstPipelineExtManual for O { fn set_pipeline_flags(&self, flags: PipelineFlags) { unsafe { - let ptr: *mut gst_sys::GstObject = self.as_ptr() as *mut _; - let _guard = ::utils::MutexGuard::lock(&(*ptr).lock); + let ptr: *mut ffi::GstObject = self.as_ptr() as *mut _; + let _guard = crate::utils::MutexGuard::lock(&(*ptr).lock); (*ptr).flags |= flags.to_glib(); } } fn unset_pipeline_flags(&self, flags: PipelineFlags) { unsafe { - let ptr: *mut gst_sys::GstObject = self.as_ptr() as *mut _; - let _guard = ::utils::MutexGuard::lock(&(*ptr).lock); + let ptr: *mut ffi::GstObject = self.as_ptr() as *mut _; + let _guard = crate::utils::MutexGuard::lock(&(*ptr).lock); (*ptr).flags &= !flags.to_glib(); } } fn get_pipeline_flags(&self) -> PipelineFlags { unsafe { - let ptr: *mut gst_sys::GstObject = self.as_ptr() as *mut _; - let _guard = ::utils::MutexGuard::lock(&(*ptr).lock); + let ptr: *mut ffi::GstObject = self.as_ptr() as *mut _; + let _guard = crate::utils::MutexGuard::lock(&(*ptr).lock); from_glib((*ptr).flags) } } diff --git a/gstreamer/src/plugin.rs b/gstreamer/src/plugin.rs index 870975695..015f19bf2 100644 --- a/gstreamer/src/plugin.rs +++ b/gstreamer/src/plugin.rs @@ -6,11 +6,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use gst_sys; -use Plugin; -use PluginFlags; -use Structure; -use StructureRef; +use crate::Plugin; +use crate::PluginFlags; +use crate::Structure; +use crate::StructureRef; use glib::translate::*; use glib::IsA; @@ -18,7 +17,7 @@ use glib::IsA; impl Plugin { pub fn get_cache_data(&self) -> Option<&StructureRef> { unsafe { - let cache_data = gst_sys::gst_plugin_get_cache_data(self.to_glib_none().0); + let cache_data = ffi::gst_plugin_get_cache_data(self.to_glib_none().0); if cache_data.is_null() { None } else { @@ -29,7 +28,7 @@ impl Plugin { pub fn set_cache_data(&self, cache_data: Structure) { unsafe { - gst_sys::gst_plugin_set_cache_data(self.to_glib_none().0, cache_data.into_ptr()); + ffi::gst_plugin_set_cache_data(self.to_glib_none().0, cache_data.into_ptr()); } } } @@ -40,16 +39,16 @@ pub trait GstPluginExtManual: 'static { fn get_plugin_name(&self) -> glib::GString; } -impl> GstPluginExtManual for O { +impl> GstPluginExtManual for O { fn get_plugin_flags(&self) -> PluginFlags { unsafe { - let ptr: *mut gst_sys::GstObject = self.as_ptr() as *mut _; - let _guard = ::utils::MutexGuard::lock(&(*ptr).lock); + let ptr: *mut ffi::GstObject = self.as_ptr() as *mut _; + let _guard = crate::utils::MutexGuard::lock(&(*ptr).lock); from_glib((*ptr).flags) } } fn get_plugin_name(&self) -> glib::GString { - unsafe { from_glib_none(gst_sys::gst_plugin_get_name(self.as_ref().to_glib_none().0)) } + unsafe { from_glib_none(ffi::gst_plugin_get_name(self.as_ref().to_glib_none().0)) } } } diff --git a/gstreamer/src/plugin_feature.rs b/gstreamer/src/plugin_feature.rs index ebfb5fe33..780f1e3c5 100644 --- a/gstreamer/src/plugin_feature.rs +++ b/gstreamer/src/plugin_feature.rs @@ -6,8 +6,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use PluginFeature; -use Rank; +use crate::PluginFeature; +use crate::Rank; use glib::object::IsA; use glib::translate::{from_glib, ToGlib, ToGlibPtr}; @@ -20,17 +20,14 @@ pub trait PluginFeatureExtManual: 'static { impl> PluginFeatureExtManual for O { fn get_rank(&self) -> Rank { unsafe { - let rank = gst_sys::gst_plugin_feature_get_rank(self.as_ref().to_glib_none().0); + let rank = ffi::gst_plugin_feature_get_rank(self.as_ref().to_glib_none().0); from_glib(rank as i32) } } fn set_rank(&self, rank: Rank) { unsafe { - gst_sys::gst_plugin_feature_set_rank( - self.as_ref().to_glib_none().0, - rank.to_glib() as u32, - ); + ffi::gst_plugin_feature_set_rank(self.as_ref().to_glib_none().0, rank.to_glib() as u32); } } } diff --git a/gstreamer/src/promise.rs b/gstreamer/src/promise.rs index e4182ff12..6ef722a20 100644 --- a/gstreamer/src/promise.rs +++ b/gstreamer/src/promise.rs @@ -6,26 +6,24 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use crate::PromiseResult; +use crate::Structure; +use crate::StructureRef; use glib::translate::*; -use glib_sys; -use gst_sys; -use PromiseResult; -use Structure; -use StructureRef; use std::marker::PhantomData; use std::pin::Pin; use std::ptr; use std::task::{Context, Poll}; -glib_wrapper! { +glib::glib_wrapper! { #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] - pub struct Promise(Shared); + pub struct Promise(Shared); match fn { - ref => |ptr| gst_sys::gst_mini_object_ref(ptr as *mut _), - unref => |ptr| gst_sys::gst_mini_object_unref(ptr as *mut _), - get_type => || gst_sys::gst_promise_get_type(), + ref => |ptr| ffi::gst_mini_object_ref(ptr as *mut _), + unref => |ptr| ffi::gst_mini_object_unref(ptr as *mut _), + get_type => || ffi::gst_promise_get_type(), } } @@ -39,7 +37,7 @@ pub enum PromiseError { impl Promise { pub fn new() -> Promise { assert_initialized_main_thread!(); - unsafe { from_glib_full(gst_sys::gst_promise_new()) } + unsafe { from_glib_full(ffi::gst_promise_new()) } } pub fn with_change_func(func: F) -> Promise @@ -52,8 +50,8 @@ impl Promise { unsafe extern "C" fn trampoline< F: FnOnce(Result, PromiseError>) + Send + 'static, >( - promise: *mut gst_sys::GstPromise, - user_data: glib_sys::gpointer, + promise: *mut ffi::GstPromise, + user_data: glib::ffi::gpointer, ) { let user_data: &mut Option = &mut *(user_data as *mut _); let callback = user_data.take().unwrap(); @@ -76,13 +74,13 @@ impl Promise { unsafe extern "C" fn free_user_data< F: FnOnce(Result, PromiseError>) + Send + 'static, >( - user_data: glib_sys::gpointer, + user_data: glib::ffi::gpointer, ) { let _: Box> = Box::from_raw(user_data as *mut _); } unsafe { - from_glib_full(gst_sys::gst_promise_new_with_change_func( + from_glib_full(ffi::gst_promise_new_with_change_func( Some(trampoline::), Box::into_raw(user_data) as *mut _, Some(free_user_data::), @@ -107,13 +105,13 @@ impl Promise { pub fn expire(&self) { unsafe { - gst_sys::gst_promise_expire(self.to_glib_none().0); + ffi::gst_promise_expire(self.to_glib_none().0); } } pub fn get_reply(&self) -> Option<&StructureRef> { unsafe { - let s = gst_sys::gst_promise_get_reply(self.to_glib_none().0); + let s = ffi::gst_promise_get_reply(self.to_glib_none().0); if s.is_null() { None } else { @@ -124,13 +122,13 @@ impl Promise { pub fn interrupt(&self) { unsafe { - gst_sys::gst_promise_interrupt(self.to_glib_none().0); + ffi::gst_promise_interrupt(self.to_glib_none().0); } } pub fn reply(&self, s: Option) { unsafe { - gst_sys::gst_promise_reply( + ffi::gst_promise_reply( self.to_glib_none().0, s.map(|s| s.into_ptr()).unwrap_or(ptr::null_mut()), ); @@ -138,7 +136,7 @@ impl Promise { } pub fn wait(&self) -> PromiseResult { - unsafe { from_glib(gst_sys::gst_promise_wait(self.to_glib_none().0)) } + unsafe { from_glib(ffi::gst_promise_wait(self.to_glib_none().0)) } } } @@ -167,7 +165,7 @@ impl<'a> std::future::Future for PromiseFuture<'a> { Poll::Ready(Ok(())) => { let res = match self.0.wait() { PromiseResult::Replied => unsafe { - let s = gst_sys::gst_promise_get_reply(self.0.to_glib_none().0); + let s = ffi::gst_promise_get_reply(self.0.to_glib_none().0); if s.is_null() { Ok(None) } else { @@ -196,7 +194,7 @@ mod tests { #[test] fn test_change_func() { - ::init().unwrap(); + crate::init().unwrap(); let (sender, receiver) = channel(); let promise = Promise::with_change_func(move |res| { diff --git a/gstreamer/src/proxy_pad.rs b/gstreamer/src/proxy_pad.rs index ffce3c00b..8ae8b50da 100644 --- a/gstreamer/src/proxy_pad.rs +++ b/gstreamer/src/proxy_pad.rs @@ -6,21 +6,19 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use crate::Buffer; +use crate::BufferList; +use crate::FlowError; +use crate::FlowReturn; +use crate::FlowSuccess; +use crate::Object; +use crate::Pad; +use crate::ProxyPad; use std::ptr; -use Buffer; -use BufferList; -use FlowError; -use FlowReturn; -use FlowSuccess; -use Object; -use Pad; -use ProxyPad; use glib::object::IsA; use glib::translate::{from_glib, from_glib_full, ToGlibPtr}; -use gst_sys; - pub trait ProxyPadExtManual: 'static { fn chain_default>( &self, @@ -44,7 +42,7 @@ pub trait ProxyPadExtManual: 'static { fn iterate_internal_links_default>( &self, parent: Option<&P>, - ) -> Option<::Iterator>; + ) -> Option>; } impl> ProxyPadExtManual for O { @@ -55,8 +53,8 @@ impl> ProxyPadExtManual for O { ) -> Result { skip_assert_initialized!(); let ret: FlowReturn = unsafe { - from_glib(gst_sys::gst_proxy_pad_chain_default( - self.as_ptr() as *mut gst_sys::GstPad, + from_glib(ffi::gst_proxy_pad_chain_default( + self.as_ptr() as *mut ffi::GstPad, parent.map(|p| p.as_ref()).to_glib_none().0, buffer.into_ptr(), )) @@ -71,8 +69,8 @@ impl> ProxyPadExtManual for O { ) -> Result { skip_assert_initialized!(); let ret: FlowReturn = unsafe { - from_glib(gst_sys::gst_proxy_pad_chain_list_default( - self.as_ptr() as *mut gst_sys::GstPad, + from_glib(ffi::gst_proxy_pad_chain_list_default( + self.as_ptr() as *mut ffi::GstPad, parent.map(|p| p.as_ref()).to_glib_none().0, list.into_ptr(), )) @@ -89,8 +87,8 @@ impl> ProxyPadExtManual for O { skip_assert_initialized!(); unsafe { let mut buffer = ptr::null_mut(); - let ret: FlowReturn = from_glib(gst_sys::gst_proxy_pad_getrange_default( - self.as_ptr() as *mut gst_sys::GstPad, + let ret: FlowReturn = from_glib(ffi::gst_proxy_pad_getrange_default( + self.as_ptr() as *mut ffi::GstPad, parent.map(|p| p.as_ref()).to_glib_none().0, offset, size, @@ -103,11 +101,11 @@ impl> ProxyPadExtManual for O { fn iterate_internal_links_default>( &self, parent: Option<&P>, - ) -> Option<::Iterator> { + ) -> Option> { skip_assert_initialized!(); unsafe { - from_glib_full(gst_sys::gst_proxy_pad_iterate_internal_links_default( - self.as_ptr() as *mut gst_sys::GstPad, + from_glib_full(ffi::gst_proxy_pad_iterate_internal_links_default( + self.as_ptr() as *mut ffi::GstPad, parent.map(|p| p.as_ref()).to_glib_none().0, )) } diff --git a/gstreamer/src/query.rs b/gstreamer/src/query.rs index b7fa4e6cf..acf9bc081 100644 --- a/gstreamer/src/query.rs +++ b/gstreamer/src/query.rs @@ -6,9 +6,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use gst_sys; -use structure::*; -use GenericFormattedValue; +use crate::structure::*; +use crate::GenericFormattedValue; use std::ffi::CStr; use std::fmt; @@ -16,18 +15,16 @@ use std::mem; use std::ops::{Deref, DerefMut}; use std::ptr; -use glib; use glib::translate::*; -use glib_sys; -gst_define_mini_object_wrapper!(Query, QueryRef, gst_sys::GstQuery, || { - gst_sys::gst_query_get_type() +gst_define_mini_object_wrapper!(Query, QueryRef, ffi::GstQuery, || { + ffi::gst_query_get_type() }); impl QueryRef { pub fn get_structure(&self) -> Option<&StructureRef> { unsafe { - let structure = gst_sys::gst_query_get_structure(self.as_mut_ptr()); + let structure = ffi::gst_query_get_structure(self.as_mut_ptr()); if structure.is_null() { None } else { @@ -38,44 +35,44 @@ impl QueryRef { pub fn get_mut_structure(&mut self) -> &mut StructureRef { unsafe { - let structure = gst_sys::gst_query_writable_structure(self.as_mut_ptr()); + let structure = ffi::gst_query_writable_structure(self.as_mut_ptr()); StructureRef::from_glib_borrow_mut(structure) } } pub fn is_downstream(&self) -> bool { - unsafe { ((*self.as_ptr()).type_ as u32) & gst_sys::GST_QUERY_TYPE_DOWNSTREAM != 0 } + unsafe { ((*self.as_ptr()).type_ as u32) & ffi::GST_QUERY_TYPE_DOWNSTREAM != 0 } } pub fn is_upstream(&self) -> bool { - unsafe { ((*self.as_ptr()).type_ as u32) & gst_sys::GST_QUERY_TYPE_UPSTREAM != 0 } + unsafe { ((*self.as_ptr()).type_ as u32) & ffi::GST_QUERY_TYPE_UPSTREAM != 0 } } pub fn is_serialized(&self) -> bool { - unsafe { ((*self.as_ptr()).type_ as u32) & gst_sys::GST_QUERY_TYPE_SERIALIZED != 0 } + unsafe { ((*self.as_ptr()).type_ as u32) & ffi::GST_QUERY_TYPE_SERIALIZED != 0 } } pub fn view(&self) -> QueryView<&Self> { let type_ = unsafe { (*self.as_ptr()).type_ }; match type_ { - gst_sys::GST_QUERY_POSITION => QueryView::Position(Position(self)), - gst_sys::GST_QUERY_DURATION => QueryView::Duration(Duration(self)), - gst_sys::GST_QUERY_LATENCY => QueryView::Latency(Latency(self)), - gst_sys::GST_QUERY_SEEKING => QueryView::Seeking(Seeking(self)), - gst_sys::GST_QUERY_SEGMENT => QueryView::Segment(Segment(self)), - gst_sys::GST_QUERY_CONVERT => QueryView::Convert(Convert(self)), - gst_sys::GST_QUERY_FORMATS => QueryView::Formats(Formats(self)), - gst_sys::GST_QUERY_BUFFERING => QueryView::Buffering(Buffering(self)), - gst_sys::GST_QUERY_CUSTOM => QueryView::Custom(Custom(self)), - gst_sys::GST_QUERY_URI => QueryView::Uri(Uri(self)), - gst_sys::GST_QUERY_ALLOCATION => QueryView::Allocation(Allocation(self)), - gst_sys::GST_QUERY_SCHEDULING => QueryView::Scheduling(Scheduling(self)), - gst_sys::GST_QUERY_ACCEPT_CAPS => QueryView::AcceptCaps(AcceptCaps(self)), - gst_sys::GST_QUERY_CAPS => QueryView::Caps(Caps(self)), - gst_sys::GST_QUERY_DRAIN => QueryView::Drain(Drain(self)), - gst_sys::GST_QUERY_CONTEXT => QueryView::Context(Context(self)), - gst_sys::GST_QUERY_BITRATE => QueryView::Bitrate(Bitrate(self)), + ffi::GST_QUERY_POSITION => QueryView::Position(Position(self)), + ffi::GST_QUERY_DURATION => QueryView::Duration(Duration(self)), + ffi::GST_QUERY_LATENCY => QueryView::Latency(Latency(self)), + ffi::GST_QUERY_SEEKING => QueryView::Seeking(Seeking(self)), + ffi::GST_QUERY_SEGMENT => QueryView::Segment(Segment(self)), + ffi::GST_QUERY_CONVERT => QueryView::Convert(Convert(self)), + ffi::GST_QUERY_FORMATS => QueryView::Formats(Formats(self)), + ffi::GST_QUERY_BUFFERING => QueryView::Buffering(Buffering(self)), + ffi::GST_QUERY_CUSTOM => QueryView::Custom(Custom(self)), + ffi::GST_QUERY_URI => QueryView::Uri(Uri(self)), + ffi::GST_QUERY_ALLOCATION => QueryView::Allocation(Allocation(self)), + ffi::GST_QUERY_SCHEDULING => QueryView::Scheduling(Scheduling(self)), + ffi::GST_QUERY_ACCEPT_CAPS => QueryView::AcceptCaps(AcceptCaps(self)), + ffi::GST_QUERY_CAPS => QueryView::Caps(Caps(self)), + ffi::GST_QUERY_DRAIN => QueryView::Drain(Drain(self)), + ffi::GST_QUERY_CONTEXT => QueryView::Context(Context(self)), + ffi::GST_QUERY_BITRATE => QueryView::Bitrate(Bitrate(self)), _ => QueryView::Other(Other(self)), } } @@ -96,7 +93,7 @@ impl fmt::Debug for QueryRef { f.debug_struct("Query") .field("ptr", unsafe { &self.as_ptr() }) .field("type", &unsafe { - let type_ = gst_sys::gst_query_type_get_name((*self.as_ptr()).type_); + let type_ = ffi::gst_query_type_get_name((*self.as_ptr()).type_); CStr::from_ptr(type_).to_str().unwrap() }) .field("structure", &self.get_structure()) @@ -105,40 +102,40 @@ impl fmt::Debug for QueryRef { } pub unsafe trait AsPtr { - unsafe fn as_ptr(&self) -> *mut gst_sys::GstQuery; + unsafe fn as_ptr(&self) -> *mut ffi::GstQuery; } pub unsafe trait AsMutPtr: AsPtr { - unsafe fn as_mut_ptr(&self) -> *mut gst_sys::GstQuery; + unsafe fn as_mut_ptr(&self) -> *mut ffi::GstQuery; } unsafe impl AsPtr for Query { - unsafe fn as_ptr(&self) -> *mut gst_sys::GstQuery { - QueryRef::as_ptr(self) as *mut gst_sys::GstQuery + unsafe fn as_ptr(&self) -> *mut ffi::GstQuery { + QueryRef::as_ptr(self) as *mut ffi::GstQuery } } unsafe impl AsMutPtr for Query { - unsafe fn as_mut_ptr(&self) -> *mut gst_sys::GstQuery { - QueryRef::as_ptr(self) as *mut gst_sys::GstQuery + unsafe fn as_mut_ptr(&self) -> *mut ffi::GstQuery { + QueryRef::as_ptr(self) as *mut ffi::GstQuery } } unsafe impl<'a> AsPtr for &'a QueryRef { - unsafe fn as_ptr(&self) -> *mut gst_sys::GstQuery { - QueryRef::as_ptr(self) as *mut gst_sys::GstQuery + unsafe fn as_ptr(&self) -> *mut ffi::GstQuery { + QueryRef::as_ptr(self) as *mut ffi::GstQuery } } unsafe impl<'a> AsPtr for &'a mut QueryRef { - unsafe fn as_ptr(&self) -> *mut gst_sys::GstQuery { - QueryRef::as_ptr(self) as *mut gst_sys::GstQuery + unsafe fn as_ptr(&self) -> *mut ffi::GstQuery { + QueryRef::as_ptr(self) as *mut ffi::GstQuery } } unsafe impl<'a> AsMutPtr for &'a mut QueryRef { - unsafe fn as_mut_ptr(&self) -> *mut gst_sys::GstQuery { - QueryRef::as_ptr(self) as *mut gst_sys::GstQuery + unsafe fn as_mut_ptr(&self) -> *mut ffi::GstQuery { + QueryRef::as_ptr(self) as *mut ffi::GstQuery } } @@ -225,13 +222,9 @@ macro_rules! declare_concrete_query( declare_concrete_query!(Position, T); impl Position { - pub fn new(fmt: ::Format) -> Self { + pub fn new(fmt: crate::Format) -> Self { assert_initialized_main_thread!(); - unsafe { - Self(from_glib_full(gst_sys::gst_query_new_position( - fmt.to_glib(), - ))) - } + unsafe { Self(from_glib_full(ffi::gst_query_new_position(fmt.to_glib()))) } } } @@ -241,17 +234,17 @@ impl Position { let mut fmt = mem::MaybeUninit::uninit(); let mut pos = mem::MaybeUninit::uninit(); - gst_sys::gst_query_parse_position(self.0.as_ptr(), fmt.as_mut_ptr(), pos.as_mut_ptr()); + ffi::gst_query_parse_position(self.0.as_ptr(), fmt.as_mut_ptr(), pos.as_mut_ptr()); GenericFormattedValue::new(from_glib(fmt.assume_init()), pos.assume_init()) } } - pub fn get_format(&self) -> ::Format { + pub fn get_format(&self) -> crate::Format { unsafe { let mut fmt = mem::MaybeUninit::uninit(); - gst_sys::gst_query_parse_position(self.0.as_ptr(), fmt.as_mut_ptr(), ptr::null_mut()); + ffi::gst_query_parse_position(self.0.as_ptr(), fmt.as_mut_ptr(), ptr::null_mut()); from_glib(fmt.assume_init()) } @@ -263,7 +256,7 @@ impl Position { let pos = pos.into(); assert_eq!(pos.get_format(), self.get_format()); unsafe { - gst_sys::gst_query_set_position( + ffi::gst_query_set_position( self.0.as_mut_ptr(), pos.get_format().to_glib(), pos.get_value(), @@ -274,13 +267,9 @@ impl Position { declare_concrete_query!(Duration, T); impl Duration { - pub fn new(fmt: ::Format) -> Self { + pub fn new(fmt: crate::Format) -> Self { assert_initialized_main_thread!(); - unsafe { - Self(from_glib_full(gst_sys::gst_query_new_duration( - fmt.to_glib(), - ))) - } + unsafe { Self(from_glib_full(ffi::gst_query_new_duration(fmt.to_glib()))) } } } @@ -290,17 +279,17 @@ impl Duration { let mut fmt = mem::MaybeUninit::uninit(); let mut pos = mem::MaybeUninit::uninit(); - gst_sys::gst_query_parse_duration(self.0.as_ptr(), fmt.as_mut_ptr(), pos.as_mut_ptr()); + ffi::gst_query_parse_duration(self.0.as_ptr(), fmt.as_mut_ptr(), pos.as_mut_ptr()); GenericFormattedValue::new(from_glib(fmt.assume_init()), pos.assume_init()) } } - pub fn get_format(&self) -> ::Format { + pub fn get_format(&self) -> crate::Format { unsafe { let mut fmt = mem::MaybeUninit::uninit(); - gst_sys::gst_query_parse_duration(self.0.as_ptr(), fmt.as_mut_ptr(), ptr::null_mut()); + ffi::gst_query_parse_duration(self.0.as_ptr(), fmt.as_mut_ptr(), ptr::null_mut()); from_glib(fmt.assume_init()) } @@ -312,7 +301,7 @@ impl Duration { let dur = dur.into(); assert_eq!(dur.get_format(), self.get_format()); unsafe { - gst_sys::gst_query_set_duration( + ffi::gst_query_set_duration( self.0.as_mut_ptr(), dur.get_format().to_glib(), dur.get_value(), @@ -325,7 +314,7 @@ declare_concrete_query!(Latency, T); impl Latency { pub fn new() -> Self { assert_initialized_main_thread!(); - unsafe { Self(from_glib_full(gst_sys::gst_query_new_latency())) } + unsafe { Self(from_glib_full(ffi::gst_query_new_latency())) } } } @@ -336,13 +325,13 @@ impl Default for Latency { } impl Latency { - pub fn get_result(&self) -> (bool, ::ClockTime, ::ClockTime) { + pub fn get_result(&self) -> (bool, crate::ClockTime, crate::ClockTime) { unsafe { let mut live = mem::MaybeUninit::uninit(); let mut min = mem::MaybeUninit::uninit(); let mut max = mem::MaybeUninit::uninit(); - gst_sys::gst_query_parse_latency( + ffi::gst_query_parse_latency( self.0.as_ptr(), live.as_mut_ptr(), min.as_mut_ptr(), @@ -359,9 +348,9 @@ impl Latency { } impl Latency { - pub fn set(&mut self, live: bool, min: ::ClockTime, max: ::ClockTime) { + pub fn set(&mut self, live: bool, min: crate::ClockTime, max: crate::ClockTime) { unsafe { - gst_sys::gst_query_set_latency( + ffi::gst_query_set_latency( self.0.as_mut_ptr(), live.to_glib(), min.to_glib(), @@ -373,13 +362,9 @@ impl Latency { declare_concrete_query!(Seeking, T); impl Seeking { - pub fn new(fmt: ::Format) -> Self { + pub fn new(fmt: crate::Format) -> Self { assert_initialized_main_thread!(); - unsafe { - Self(from_glib_full(gst_sys::gst_query_new_seeking( - fmt.to_glib(), - ))) - } + unsafe { Self(from_glib_full(ffi::gst_query_new_seeking(fmt.to_glib()))) } } } @@ -390,7 +375,7 @@ impl Seeking { let mut seekable = mem::MaybeUninit::uninit(); let mut start = mem::MaybeUninit::uninit(); let mut end = mem::MaybeUninit::uninit(); - gst_sys::gst_query_parse_seeking( + ffi::gst_query_parse_seeking( self.0.as_ptr(), fmt.as_mut_ptr(), seekable.as_mut_ptr(), @@ -406,10 +391,10 @@ impl Seeking { } } - pub fn get_format(&self) -> ::Format { + pub fn get_format(&self) -> crate::Format { unsafe { let mut fmt = mem::MaybeUninit::uninit(); - gst_sys::gst_query_parse_seeking( + ffi::gst_query_parse_seeking( self.0.as_ptr(), fmt.as_mut_ptr(), ptr::null_mut(), @@ -431,7 +416,7 @@ impl Seeking { assert_eq!(start.get_format(), end.get_format()); unsafe { - gst_sys::gst_query_set_seeking( + ffi::gst_query_set_seeking( self.0.as_mut_ptr(), start.get_format().to_glib(), seekable.to_glib(), @@ -444,13 +429,9 @@ impl Seeking { declare_concrete_query!(Segment, T); impl Segment { - pub fn new(fmt: ::Format) -> Self { + pub fn new(fmt: crate::Format) -> Self { assert_initialized_main_thread!(); - unsafe { - Self(from_glib_full(gst_sys::gst_query_new_segment( - fmt.to_glib(), - ))) - } + unsafe { Self(from_glib_full(ffi::gst_query_new_segment(fmt.to_glib()))) } } } @@ -462,7 +443,7 @@ impl Segment { let mut start = mem::MaybeUninit::uninit(); let mut stop = mem::MaybeUninit::uninit(); - gst_sys::gst_query_parse_segment( + ffi::gst_query_parse_segment( self.0.as_ptr(), rate.as_mut_ptr(), fmt.as_mut_ptr(), @@ -477,11 +458,11 @@ impl Segment { } } - pub fn get_format(&self) -> ::Format { + pub fn get_format(&self) -> crate::Format { unsafe { let mut fmt = mem::MaybeUninit::uninit(); - gst_sys::gst_query_parse_segment( + ffi::gst_query_parse_segment( self.0.as_ptr(), ptr::null_mut(), fmt.as_mut_ptr(), @@ -501,7 +482,7 @@ impl Segment { assert_eq!(start.get_format(), stop.get_format()); unsafe { - gst_sys::gst_query_set_segment( + ffi::gst_query_set_segment( self.0.as_mut_ptr(), rate, start.get_format().to_glib(), @@ -514,11 +495,11 @@ impl Segment { declare_concrete_query!(Convert, T); impl Convert { - pub fn new>(value: V, dest_fmt: ::Format) -> Self { + pub fn new>(value: V, dest_fmt: crate::Format) -> Self { assert_initialized_main_thread!(); let value = value.into(); unsafe { - Self(from_glib_full(gst_sys::gst_query_new_convert( + Self(from_glib_full(ffi::gst_query_new_convert( value.get_format().to_glib(), value.get_value(), dest_fmt.to_glib(), @@ -535,7 +516,7 @@ impl Convert { let mut dest_fmt = mem::MaybeUninit::uninit(); let mut dest = mem::MaybeUninit::uninit(); - gst_sys::gst_query_parse_convert( + ffi::gst_query_parse_convert( self.0.as_ptr(), src_fmt.as_mut_ptr(), src.as_mut_ptr(), @@ -549,13 +530,13 @@ impl Convert { } } - pub fn get(&self) -> (GenericFormattedValue, ::Format) { + pub fn get(&self) -> (GenericFormattedValue, crate::Format) { unsafe { let mut src_fmt = mem::MaybeUninit::uninit(); let mut src = mem::MaybeUninit::uninit(); let mut dest_fmt = mem::MaybeUninit::uninit(); - gst_sys::gst_query_parse_convert( + ffi::gst_query_parse_convert( self.0.as_ptr(), src_fmt.as_mut_ptr(), src.as_mut_ptr(), @@ -576,7 +557,7 @@ impl Convert { let dest = dest.into(); unsafe { - gst_sys::gst_query_set_convert( + ffi::gst_query_set_convert( self.0.as_mut_ptr(), src.get_format().to_glib(), src.get_value(), @@ -591,7 +572,7 @@ declare_concrete_query!(Formats, T); impl Formats { pub fn new() -> Self { assert_initialized_main_thread!(); - unsafe { Self(from_glib_full(gst_sys::gst_query_new_formats())) } + unsafe { Self(from_glib_full(ffi::gst_query_new_formats())) } } } @@ -602,16 +583,16 @@ impl Default for Formats { } impl Formats { - pub fn get_result(&self) -> Vec<::Format> { + pub fn get_result(&self) -> Vec { unsafe { let mut n = mem::MaybeUninit::uninit(); - gst_sys::gst_query_parse_n_formats(self.0.as_ptr(), n.as_mut_ptr()); + ffi::gst_query_parse_n_formats(self.0.as_ptr(), n.as_mut_ptr()); let n = n.assume_init(); let mut res = Vec::with_capacity(n as usize); for i in 0..n { let mut fmt = mem::MaybeUninit::uninit(); - gst_sys::gst_query_parse_nth_format(self.0.as_ptr(), i, fmt.as_mut_ptr()); + ffi::gst_query_parse_nth_format(self.0.as_ptr(), i, fmt.as_mut_ptr()); res.push(from_glib(fmt.assume_init())); } @@ -621,36 +602,28 @@ impl Formats { } impl Formats { - pub fn set(&mut self, formats: &[::Format]) { + pub fn set(&mut self, formats: &[crate::Format]) { unsafe { let v: Vec<_> = formats.iter().map(|f| f.to_glib()).collect(); - gst_sys::gst_query_set_formatsv( - self.0.as_mut_ptr(), - v.len() as i32, - v.as_ptr() as *mut _, - ); + ffi::gst_query_set_formatsv(self.0.as_mut_ptr(), v.len() as i32, v.as_ptr() as *mut _); } } } declare_concrete_query!(Buffering, T); impl Buffering { - pub fn new(fmt: ::Format) -> Self { + pub fn new(fmt: crate::Format) -> Self { assert_initialized_main_thread!(); - unsafe { - Self(from_glib_full(gst_sys::gst_query_new_buffering( - fmt.to_glib(), - ))) - } + unsafe { Self(from_glib_full(ffi::gst_query_new_buffering(fmt.to_glib()))) } } } impl Buffering { - pub fn get_format(&self) -> ::Format { + pub fn get_format(&self) -> crate::Format { unsafe { let mut fmt = mem::MaybeUninit::uninit(); - gst_sys::gst_query_parse_buffering_range( + ffi::gst_query_parse_buffering_range( self.0.as_ptr(), fmt.as_mut_ptr(), ptr::null_mut(), @@ -667,7 +640,7 @@ impl Buffering { let mut busy = mem::MaybeUninit::uninit(); let mut percent = mem::MaybeUninit::uninit(); - gst_sys::gst_query_parse_buffering_percent( + ffi::gst_query_parse_buffering_percent( self.0.as_ptr(), busy.as_mut_ptr(), percent.as_mut_ptr(), @@ -684,7 +657,7 @@ impl Buffering { let mut stop = mem::MaybeUninit::uninit(); let mut estimated_total = mem::MaybeUninit::uninit(); - gst_sys::gst_query_parse_buffering_range( + ffi::gst_query_parse_buffering_range( self.0.as_ptr(), fmt.as_mut_ptr(), start.as_mut_ptr(), @@ -699,14 +672,14 @@ impl Buffering { } } - pub fn get_stats(&self) -> (::BufferingMode, i32, i32, i64) { + pub fn get_stats(&self) -> (crate::BufferingMode, i32, i32, i64) { unsafe { let mut mode = mem::MaybeUninit::uninit(); let mut avg_in = mem::MaybeUninit::uninit(); let mut avg_out = mem::MaybeUninit::uninit(); let mut buffering_left = mem::MaybeUninit::uninit(); - gst_sys::gst_query_parse_buffering_stats( + ffi::gst_query_parse_buffering_stats( self.0.as_ptr(), mode.as_mut_ptr(), avg_in.as_mut_ptr(), @@ -726,7 +699,7 @@ impl Buffering { pub fn get_ranges(&self) -> Vec<(GenericFormattedValue, GenericFormattedValue)> { unsafe { let mut fmt = mem::MaybeUninit::uninit(); - gst_sys::gst_query_parse_buffering_range( + ffi::gst_query_parse_buffering_range( self.0.as_ptr(), fmt.as_mut_ptr(), ptr::null_mut(), @@ -735,12 +708,12 @@ impl Buffering { ); let fmt = from_glib(fmt.assume_init()); - let n = gst_sys::gst_query_get_n_buffering_ranges(self.0.as_ptr()); + let n = ffi::gst_query_get_n_buffering_ranges(self.0.as_ptr()); let mut res = Vec::with_capacity(n as usize); for i in 0..n { let mut start = mem::MaybeUninit::uninit(); let mut stop = mem::MaybeUninit::uninit(); - let s: bool = from_glib(gst_sys::gst_query_parse_nth_buffering_range( + let s: bool = from_glib(ffi::gst_query_parse_nth_buffering_range( self.0.as_ptr(), i, start.as_mut_ptr(), @@ -762,7 +735,7 @@ impl Buffering { impl Buffering { pub fn set_percent(&mut self, busy: bool, percent: i32) { unsafe { - gst_sys::gst_query_set_buffering_percent(self.0.as_mut_ptr(), busy.to_glib(), percent); + ffi::gst_query_set_buffering_percent(self.0.as_mut_ptr(), busy.to_glib(), percent); } } @@ -779,7 +752,7 @@ impl Buffering { assert_eq!(start.get_format(), stop.get_format()); unsafe { - gst_sys::gst_query_set_buffering_range( + ffi::gst_query_set_buffering_range( self.0.as_mut_ptr(), start.get_format().to_glib(), start.get_value(), @@ -791,14 +764,14 @@ impl Buffering { pub fn set_stats( &mut self, - mode: ::BufferingMode, + mode: crate::BufferingMode, avg_in: i32, avg_out: i32, buffering_left: i64, ) { skip_assert_initialized!(); unsafe { - gst_sys::gst_query_set_buffering_stats( + ffi::gst_query_set_buffering_stats( self.0.as_mut_ptr(), mode.to_glib(), avg_in, @@ -820,7 +793,7 @@ impl Buffering { let stop = stop.into(); assert_eq!(start.get_format(), fmt); assert_eq!(stop.get_format(), fmt); - gst_sys::gst_query_add_buffering_range( + ffi::gst_query_add_buffering_range( self.0.as_mut_ptr(), start.get_value(), stop.get_value(), @@ -832,11 +805,11 @@ impl Buffering { declare_concrete_query!(Custom, T); impl Custom { - pub fn new(structure: ::Structure) -> Self { + pub fn new(structure: crate::Structure) -> Self { assert_initialized_main_thread!(); unsafe { - Self(from_glib_full(gst_sys::gst_query_new_custom( - gst_sys::GST_QUERY_CUSTOM, + Self(from_glib_full(ffi::gst_query_new_custom( + ffi::GST_QUERY_CUSTOM, structure.into_ptr(), ))) } @@ -847,7 +820,7 @@ declare_concrete_query!(Uri, T); impl Uri { pub fn new() -> Self { assert_initialized_main_thread!(); - unsafe { Self(from_glib_full(gst_sys::gst_query_new_uri())) } + unsafe { Self(from_glib_full(ffi::gst_query_new_uri())) } } } @@ -861,7 +834,7 @@ impl Uri { pub fn get_uri(&self) -> Option { unsafe { let mut uri = ptr::null_mut(); - gst_sys::gst_query_parse_uri(self.0.as_ptr(), &mut uri); + ffi::gst_query_parse_uri(self.0.as_ptr(), &mut uri); from_glib_full(uri) } } @@ -869,12 +842,9 @@ impl Uri { pub fn get_redirection(&self) -> (Option, bool) { unsafe { let mut uri = ptr::null_mut(); - gst_sys::gst_query_parse_uri_redirection(self.0.as_ptr(), &mut uri); + ffi::gst_query_parse_uri_redirection(self.0.as_ptr(), &mut uri); let mut permanent = mem::MaybeUninit::uninit(); - gst_sys::gst_query_parse_uri_redirection_permanent( - self.0.as_ptr(), - permanent.as_mut_ptr(), - ); + ffi::gst_query_parse_uri_redirection_permanent(self.0.as_ptr(), permanent.as_mut_ptr()); (from_glib_full(uri), from_glib(permanent.assume_init())) } @@ -885,28 +855,25 @@ impl Uri { pub fn set_uri<'b, U: Into<&'b str>>(&mut self, uri: U) { let uri = uri.into(); unsafe { - gst_sys::gst_query_set_uri(self.0.as_mut_ptr(), uri.to_glib_none().0); + ffi::gst_query_set_uri(self.0.as_mut_ptr(), uri.to_glib_none().0); } } pub fn set_redirection<'b, U: Into<&'b str>>(&mut self, uri: U, permanent: bool) { let uri = uri.into(); unsafe { - gst_sys::gst_query_set_uri_redirection(self.0.as_mut_ptr(), uri.to_glib_none().0); - gst_sys::gst_query_set_uri_redirection_permanent( - self.0.as_mut_ptr(), - permanent.to_glib(), - ); + ffi::gst_query_set_uri_redirection(self.0.as_mut_ptr(), uri.to_glib_none().0); + ffi::gst_query_set_uri_redirection_permanent(self.0.as_mut_ptr(), permanent.to_glib()); } } } declare_concrete_query!(Allocation, T); impl Allocation { - pub fn new(caps: &::Caps, need_pool: bool) -> Self { + pub fn new(caps: &crate::Caps, need_pool: bool) -> Self { assert_initialized_main_thread!(); unsafe { - Self(from_glib_full(gst_sys::gst_query_new_allocation( + Self(from_glib_full(ffi::gst_query_new_allocation( caps.as_mut_ptr(), need_pool.to_glib(), ))) @@ -915,29 +882,29 @@ impl Allocation { } impl Allocation { - pub fn get(&self) -> (&::CapsRef, bool) { + pub fn get(&self) -> (&crate::CapsRef, bool) { unsafe { let mut caps = ptr::null_mut(); let mut need_pool = mem::MaybeUninit::uninit(); - gst_sys::gst_query_parse_allocation(self.0.as_ptr(), &mut caps, need_pool.as_mut_ptr()); + ffi::gst_query_parse_allocation(self.0.as_ptr(), &mut caps, need_pool.as_mut_ptr()); ( - ::CapsRef::from_ptr(caps), + crate::CapsRef::from_ptr(caps), from_glib(need_pool.assume_init()), ) } } - pub fn get_owned(&self) -> (::Caps, bool) { + pub fn get_owned(&self) -> (crate::Caps, bool) { unsafe { let (caps, need_pool) = self.get(); (from_glib_none(caps.as_ptr()), need_pool) } } - pub fn get_allocation_pools(&self) -> Vec<(Option<::BufferPool>, u32, u32, u32)> { + pub fn get_allocation_pools(&self) -> Vec<(Option, u32, u32, u32)> { unsafe { - let n = gst_sys::gst_query_get_n_allocation_pools(self.0.as_ptr()); + let n = ffi::gst_query_get_n_allocation_pools(self.0.as_ptr()); let mut pools = Vec::with_capacity(n as usize); for i in 0..n { let mut pool = ptr::null_mut(); @@ -945,7 +912,7 @@ impl Allocation { let mut min_buffers = mem::MaybeUninit::uninit(); let mut max_buffers = mem::MaybeUninit::uninit(); - gst_sys::gst_query_parse_nth_allocation_pool( + ffi::gst_query_parse_nth_allocation_pool( self.0.as_ptr(), i, &mut pool, @@ -965,24 +932,21 @@ impl Allocation { } } - pub fn get_allocation_metas(&self) -> Vec<(glib::Type, Option<&::StructureRef>)> { + pub fn get_allocation_metas(&self) -> Vec<(glib::Type, Option<&crate::StructureRef>)> { unsafe { - let n = gst_sys::gst_query_get_n_allocation_metas(self.0.as_ptr()); + let n = ffi::gst_query_get_n_allocation_metas(self.0.as_ptr()); let mut metas = Vec::with_capacity(n as usize); for i in 0..n { let mut structure = ptr::null(); - let api = gst_sys::gst_query_parse_nth_allocation_meta( - self.0.as_ptr(), - i, - &mut structure, - ); + let api = + ffi::gst_query_parse_nth_allocation_meta(self.0.as_ptr(), i, &mut structure); metas.push(( from_glib(api), if structure.is_null() { None } else { - Some(::StructureRef::from_glib_borrow(structure)) + Some(crate::StructureRef::from_glib_borrow(structure)) }, )); } @@ -991,14 +955,14 @@ impl Allocation { } } - pub fn find_allocation_meta(&self) -> Option { + pub fn find_allocation_meta(&self) -> Option { unsafe { let mut idx = mem::MaybeUninit::uninit(); - if gst_sys::gst_query_find_allocation_meta( + if ffi::gst_query_find_allocation_meta( self.0.as_ptr(), U::get_meta_api().to_glib(), idx.as_mut_ptr(), - ) != glib_sys::GFALSE + ) != glib::ffi::GFALSE { Some(idx.assume_init()) } else { @@ -1011,13 +975,13 @@ impl Allocation { impl Allocation { pub fn add_allocation_pool( &mut self, - pool: Option<&::BufferPool>, + pool: Option<&crate::BufferPool>, size: u32, min_buffers: u32, max_buffers: u32, ) { unsafe { - gst_sys::gst_query_add_allocation_pool( + ffi::gst_query_add_allocation_pool( self.0.as_mut_ptr(), pool.to_glib_none().0, size, @@ -1030,13 +994,13 @@ impl Allocation { pub fn set_nth_allocation_pool( &mut self, idx: u32, - pool: Option<&::BufferPool>, + pool: Option<&crate::BufferPool>, size: u32, min_buffers: u32, max_buffers: u32, ) { unsafe { - gst_sys::gst_query_set_nth_allocation_pool( + ffi::gst_query_set_nth_allocation_pool( self.0.as_mut_ptr(), idx, pool.to_glib_none().0, @@ -1049,13 +1013,16 @@ impl Allocation { pub fn remove_nth_allocation_pool(&mut self, idx: u32) { unsafe { - gst_sys::gst_query_remove_nth_allocation_pool(self.0.as_mut_ptr(), idx); + ffi::gst_query_remove_nth_allocation_pool(self.0.as_mut_ptr(), idx); } } - pub fn add_allocation_meta(&mut self, structure: Option<&::StructureRef>) { + pub fn add_allocation_meta( + &mut self, + structure: Option<&crate::StructureRef>, + ) { unsafe { - gst_sys::gst_query_add_allocation_meta( + ffi::gst_query_add_allocation_meta( self.0.as_mut_ptr(), U::get_meta_api().to_glib(), if let Some(structure) = structure { @@ -1069,7 +1036,7 @@ impl Allocation { pub fn remove_nth_allocation_meta(&mut self, idx: u32) { unsafe { - gst_sys::gst_query_remove_nth_allocation_meta(self.0.as_mut_ptr(), idx); + ffi::gst_query_remove_nth_allocation_meta(self.0.as_mut_ptr(), idx); } } } @@ -1078,7 +1045,7 @@ declare_concrete_query!(Scheduling, T); impl Scheduling { pub fn new() -> Self { assert_initialized_main_thread!(); - unsafe { Self(from_glib_full(gst_sys::gst_query_new_scheduling())) } + unsafe { Self(from_glib_full(ffi::gst_query_new_scheduling())) } } } @@ -1089,9 +1056,9 @@ impl Default for Scheduling { } impl Scheduling { - pub fn has_scheduling_mode(&self, mode: ::PadMode) -> bool { + pub fn has_scheduling_mode(&self, mode: crate::PadMode) -> bool { unsafe { - from_glib(gst_sys::gst_query_has_scheduling_mode( + from_glib(ffi::gst_query_has_scheduling_mode( self.0.as_ptr(), mode.to_glib(), )) @@ -1100,12 +1067,12 @@ impl Scheduling { pub fn has_scheduling_mode_with_flags( &self, - mode: ::PadMode, - flags: ::SchedulingFlags, + mode: crate::PadMode, + flags: crate::SchedulingFlags, ) -> bool { skip_assert_initialized!(); unsafe { - from_glib(gst_sys::gst_query_has_scheduling_mode_with_flags( + from_glib(ffi::gst_query_has_scheduling_mode_with_flags( self.0.as_ptr(), mode.to_glib(), flags.to_glib(), @@ -1113,12 +1080,12 @@ impl Scheduling { } } - pub fn get_scheduling_modes(&self) -> Vec<::PadMode> { + pub fn get_scheduling_modes(&self) -> Vec { unsafe { - let n = gst_sys::gst_query_get_n_scheduling_modes(self.0.as_ptr()); + let n = ffi::gst_query_get_n_scheduling_modes(self.0.as_ptr()); let mut res = Vec::with_capacity(n as usize); for i in 0..n { - res.push(from_glib(gst_sys::gst_query_parse_nth_scheduling_mode( + res.push(from_glib(ffi::gst_query_parse_nth_scheduling_mode( self.0.as_ptr(), i, ))); @@ -1128,14 +1095,14 @@ impl Scheduling { } } - pub fn get_result(&self) -> (::SchedulingFlags, i32, i32, i32) { + pub fn get_result(&self) -> (crate::SchedulingFlags, i32, i32, i32) { unsafe { let mut flags = mem::MaybeUninit::uninit(); let mut minsize = mem::MaybeUninit::uninit(); let mut maxsize = mem::MaybeUninit::uninit(); let mut align = mem::MaybeUninit::uninit(); - gst_sys::gst_query_parse_scheduling( + ffi::gst_query_parse_scheduling( self.0.as_ptr(), flags.as_mut_ptr(), minsize.as_mut_ptr(), @@ -1154,17 +1121,17 @@ impl Scheduling { } impl Scheduling { - pub fn add_scheduling_modes(&mut self, modes: &[::PadMode]) { + pub fn add_scheduling_modes(&mut self, modes: &[crate::PadMode]) { unsafe { for mode in modes { - gst_sys::gst_query_add_scheduling_mode(self.0.as_mut_ptr(), mode.to_glib()); + ffi::gst_query_add_scheduling_mode(self.0.as_mut_ptr(), mode.to_glib()); } } } - pub fn set(&mut self, flags: ::SchedulingFlags, minsize: i32, maxsize: i32, align: i32) { + pub fn set(&mut self, flags: crate::SchedulingFlags, minsize: i32, maxsize: i32, align: i32) { unsafe { - gst_sys::gst_query_set_scheduling( + ffi::gst_query_set_scheduling( self.0.as_mut_ptr(), flags.to_glib(), minsize, @@ -1177,10 +1144,10 @@ impl Scheduling { declare_concrete_query!(AcceptCaps, T); impl AcceptCaps { - pub fn new(caps: &::Caps) -> Self { + pub fn new(caps: &crate::Caps) -> Self { assert_initialized_main_thread!(); unsafe { - Self(from_glib_full(gst_sys::gst_query_new_accept_caps( + Self(from_glib_full(ffi::gst_query_new_accept_caps( caps.as_mut_ptr(), ))) } @@ -1188,22 +1155,22 @@ impl AcceptCaps { } impl AcceptCaps { - pub fn get_caps(&self) -> &::CapsRef { + pub fn get_caps(&self) -> &crate::CapsRef { unsafe { let mut caps = ptr::null_mut(); - gst_sys::gst_query_parse_accept_caps(self.0.as_ptr(), &mut caps); - ::CapsRef::from_ptr(caps) + ffi::gst_query_parse_accept_caps(self.0.as_ptr(), &mut caps); + crate::CapsRef::from_ptr(caps) } } - pub fn get_caps_owned(&self) -> ::Caps { + pub fn get_caps_owned(&self) -> crate::Caps { unsafe { from_glib_none(self.get_caps().as_ptr()) } } pub fn get_result(&self) -> bool { unsafe { let mut accepted = mem::MaybeUninit::uninit(); - gst_sys::gst_query_parse_accept_caps_result(self.0.as_ptr(), accepted.as_mut_ptr()); + ffi::gst_query_parse_accept_caps_result(self.0.as_ptr(), accepted.as_mut_ptr()); from_glib(accepted.assume_init()) } } @@ -1212,17 +1179,17 @@ impl AcceptCaps { impl AcceptCaps { pub fn set_result(&mut self, accepted: bool) { unsafe { - gst_sys::gst_query_set_accept_caps_result(self.0.as_mut_ptr(), accepted.to_glib()); + ffi::gst_query_set_accept_caps_result(self.0.as_mut_ptr(), accepted.to_glib()); } } } declare_concrete_query!(Caps, T); impl Caps { - pub fn new(filter: Option<&::Caps>) -> Self { + pub fn new(filter: Option<&crate::Caps>) -> Self { assert_initialized_main_thread!(); unsafe { - Self(from_glib_full(gst_sys::gst_query_new_caps( + Self(from_glib_full(ffi::gst_query_new_caps( filter.to_glib_none().0, ))) } @@ -1230,43 +1197,43 @@ impl Caps { } impl Caps { - pub fn get_filter(&self) -> Option<&::CapsRef> { + pub fn get_filter(&self) -> Option<&crate::CapsRef> { unsafe { let mut caps = ptr::null_mut(); - gst_sys::gst_query_parse_caps(self.0.as_ptr(), &mut caps); + ffi::gst_query_parse_caps(self.0.as_ptr(), &mut caps); if caps.is_null() { None } else { - Some(::CapsRef::from_ptr(caps)) + Some(crate::CapsRef::from_ptr(caps)) } } } - pub fn get_filter_owned(&self) -> Option<::Caps> { + pub fn get_filter_owned(&self) -> Option { unsafe { self.get_filter().map(|caps| from_glib_none(caps.as_ptr())) } } - pub fn get_result(&self) -> Option<&::CapsRef> { + pub fn get_result(&self) -> Option<&crate::CapsRef> { unsafe { let mut caps = ptr::null_mut(); - gst_sys::gst_query_parse_caps_result(self.0.as_ptr(), &mut caps); + ffi::gst_query_parse_caps_result(self.0.as_ptr(), &mut caps); if caps.is_null() { None } else { - Some(::CapsRef::from_ptr(caps)) + Some(crate::CapsRef::from_ptr(caps)) } } } - pub fn get_result_owned(&self) -> Option<::Caps> { + pub fn get_result_owned(&self) -> Option { unsafe { self.get_result().map(|caps| from_glib_none(caps.as_ptr())) } } } impl Caps { - pub fn set_result(&mut self, caps: &::Caps) { + pub fn set_result(&mut self, caps: &crate::Caps) { unsafe { - gst_sys::gst_query_set_caps_result(self.0.as_mut_ptr(), caps.as_mut_ptr()); + ffi::gst_query_set_caps_result(self.0.as_mut_ptr(), caps.as_mut_ptr()); } } } @@ -1275,7 +1242,7 @@ declare_concrete_query!(Drain, T); impl Drain { pub fn new() -> Self { assert_initialized_main_thread!(); - unsafe { Self(from_glib_full(gst_sys::gst_query_new_drain())) } + unsafe { Self(from_glib_full(ffi::gst_query_new_drain())) } } } @@ -1290,7 +1257,7 @@ impl Context { pub fn new(context_type: &str) -> Self { assert_initialized_main_thread!(); unsafe { - Self(from_glib_full(gst_sys::gst_query_new_context( + Self(from_glib_full(ffi::gst_query_new_context( context_type.to_glib_none().0, ))) } @@ -1298,19 +1265,19 @@ impl Context { } impl Context { - pub fn get_context(&self) -> Option<&::ContextRef> { + pub fn get_context(&self) -> Option<&crate::ContextRef> { unsafe { let mut context = ptr::null_mut(); - gst_sys::gst_query_parse_context(self.0.as_ptr(), &mut context); + ffi::gst_query_parse_context(self.0.as_ptr(), &mut context); if context.is_null() { None } else { - Some(::ContextRef::from_ptr(context)) + Some(crate::ContextRef::from_ptr(context)) } } } - pub fn get_context_owned(&self) -> Option<::Context> { + pub fn get_context_owned(&self) -> Option { unsafe { self.get_context() .map(|context| from_glib_none(context.as_ptr())) @@ -1320,16 +1287,16 @@ impl Context { pub fn get_context_type(&self) -> &str { unsafe { let mut context_type = ptr::null(); - gst_sys::gst_query_parse_context_type(self.0.as_ptr(), &mut context_type); + ffi::gst_query_parse_context_type(self.0.as_ptr(), &mut context_type); CStr::from_ptr(context_type).to_str().unwrap() } } } impl Context { - pub fn set_context(&mut self, context: &::Context) { + pub fn set_context(&mut self, context: &crate::Context) { unsafe { - gst_sys::gst_query_set_context(self.0.as_mut_ptr(), context.as_mut_ptr()); + ffi::gst_query_set_context(self.0.as_mut_ptr(), context.as_mut_ptr()); } } } @@ -1341,7 +1308,7 @@ declare_concrete_query!(Bitrate, T); impl Bitrate { pub fn new() -> Self { assert_initialized_main_thread!(); - unsafe { Self(from_glib_full(gst_sys::gst_query_new_bitrate())) } + unsafe { Self(from_glib_full(ffi::gst_query_new_bitrate())) } } } @@ -1359,7 +1326,7 @@ impl Bitrate { pub fn get_bitrate(&self) -> u32 { unsafe { let mut bitrate = mem::MaybeUninit::uninit(); - gst_sys::gst_query_parse_bitrate(self.0.as_ptr(), bitrate.as_mut_ptr()); + ffi::gst_query_parse_bitrate(self.0.as_ptr(), bitrate.as_mut_ptr()); bitrate.assume_init() } } @@ -1370,7 +1337,7 @@ impl Bitrate { #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_16")))] pub fn set_bitrate(&mut self, bitrate: u32) { unsafe { - gst_sys::gst_query_set_bitrate(self.0.as_mut_ptr(), bitrate); + ffi::gst_query_set_bitrate(self.0.as_mut_ptr(), bitrate); } } } @@ -1384,17 +1351,17 @@ mod tests { #[test] fn test_writability() { - ::init().unwrap(); + crate::init().unwrap(); fn check_mut(query: &mut QueryRef) { skip_assert_initialized!(); match query.view_mut() { QueryView::Position(ref mut p) => { let pos = p.get_result(); - assert_eq!(pos.try_into(), Ok(::CLOCK_TIME_NONE)); - p.set(3 * ::SECOND); + assert_eq!(pos.try_into(), Ok(crate::CLOCK_TIME_NONE)); + p.set(3 * crate::SECOND); let pos = p.get_result(); - assert_eq!(pos.try_into(), Ok(3 * ::SECOND)); + assert_eq!(pos.try_into(), Ok(3 * crate::SECOND)); } _ => panic!("Wrong concrete Query in Query"), } @@ -1405,7 +1372,7 @@ mod tests { match query.view() { QueryView::Position(ref p) => { let pos = p.get_result(); - assert_eq!(pos.try_into(), Ok(3 * ::SECOND)); + assert_eq!(pos.try_into(), Ok(3 * crate::SECOND)); unsafe { assert!(!p.as_mut_ptr().is_null()); } @@ -1414,9 +1381,9 @@ mod tests { } } - let mut p = Position::new(::Format::Time); + let mut p = Position::new(crate::Format::Time); let pos = p.get_result(); - assert_eq!(pos.try_into(), Ok(::CLOCK_TIME_NONE)); + assert_eq!(pos.try_into(), Ok(crate::CLOCK_TIME_NONE)); p.get_mut_structure().set("check_mut", &true); @@ -1438,8 +1405,8 @@ mod tests { #[test] fn test_into_query() { - ::init().unwrap(); - let d = Duration::new(::Format::Time); + crate::init().unwrap(); + let d = Duration::new(crate::Format::Time); let mut query: Query = d.into(); assert!(query.is_writable()); @@ -1447,7 +1414,7 @@ mod tests { let query = query.make_mut(); match query.view_mut() { QueryView::Duration(ref mut d) => { - d.set(2 * ::SECOND); + d.set(2 * crate::SECOND); } _ => (), } @@ -1455,7 +1422,7 @@ mod tests { match query.view() { QueryView::Duration(ref d) => { let duration = d.get_result(); - assert_eq!(duration.try_into(), Ok(2 * ::SECOND)); + assert_eq!(duration.try_into(), Ok(2 * crate::SECOND)); } _ => (), } @@ -1463,9 +1430,9 @@ mod tests { #[test] fn test_concrete_to_sys() { - ::init().unwrap(); + crate::init().unwrap(); - let p = Position::new(::Format::Time); + let p = Position::new(crate::Format::Time); unsafe { assert!(!p.as_mut_ptr().is_null()); } diff --git a/gstreamer/src/sample.rs b/gstreamer/src/sample.rs index 0239efa04..1f2353670 100644 --- a/gstreamer/src/sample.rs +++ b/gstreamer/src/sample.rs @@ -9,25 +9,22 @@ use std::fmt; use std::ptr; -use gst_sys; - -use glib; use glib::translate::{from_glib_full, from_glib_none, mut_override, ToGlibPtr}; -use Buffer; -use BufferList; -use BufferListRef; -use BufferRef; -use Caps; -use CapsRef; -use FormattedSegment; -use FormattedValue; -use Segment; -use Structure; -use StructureRef; +use crate::Buffer; +use crate::BufferList; +use crate::BufferListRef; +use crate::BufferRef; +use crate::Caps; +use crate::CapsRef; +use crate::FormattedSegment; +use crate::FormattedValue; +use crate::Segment; +use crate::Structure; +use crate::StructureRef; -gst_define_mini_object_wrapper!(Sample, SampleRef, gst_sys::GstSample, || { - gst_sys::gst_sample_get_type() +gst_define_mini_object_wrapper!(Sample, SampleRef, ffi::GstSample, || { + ffi::gst_sample_get_type() }); #[derive(Debug, Clone)] @@ -83,7 +80,7 @@ impl<'a> SampleBuilder<'a> { unsafe { let info = self.info.map(|i| i.into_ptr()).unwrap_or(ptr::null_mut()); - let sample: Sample = from_glib_full(gst_sys::gst_sample_new( + let sample: Sample = from_glib_full(ffi::gst_sample_new( self.buffer.to_glib_none().0, self.caps.to_glib_none().0, self.segment.to_glib_none().0, @@ -91,7 +88,7 @@ impl<'a> SampleBuilder<'a> { )); if let Some(buffer_list) = self.buffer_list { - gst_sys::gst_sample_set_buffer_list( + ffi::gst_sample_set_buffer_list( sample.to_glib_none().0, buffer_list.to_glib_none().0, ); @@ -117,7 +114,7 @@ impl Sample { impl SampleRef { pub fn get_buffer(&self) -> Option<&BufferRef> { unsafe { - let ptr = gst_sys::gst_sample_get_buffer(self.as_mut_ptr()); + let ptr = ffi::gst_sample_get_buffer(self.as_mut_ptr()); if ptr.is_null() { None } else { @@ -135,7 +132,7 @@ impl SampleRef { pub fn get_buffer_list(&self) -> Option<&BufferListRef> { unsafe { - let ptr = gst_sys::gst_sample_get_buffer_list(self.as_mut_ptr()); + let ptr = ffi::gst_sample_get_buffer_list(self.as_mut_ptr()); if ptr.is_null() { None } else { @@ -153,7 +150,7 @@ impl SampleRef { pub fn get_caps(&self) -> Option<&CapsRef> { unsafe { - let ptr = gst_sys::gst_sample_get_caps(self.as_mut_ptr()); + let ptr = ffi::gst_sample_get_caps(self.as_mut_ptr()); if ptr.is_null() { None } else { @@ -167,12 +164,12 @@ impl SampleRef { } pub fn get_segment(&self) -> Option { - unsafe { from_glib_none(gst_sys::gst_sample_get_segment(self.as_mut_ptr())) } + unsafe { from_glib_none(ffi::gst_sample_get_segment(self.as_mut_ptr())) } } pub fn get_info(&self) -> Option<&StructureRef> { unsafe { - let ptr = gst_sys::gst_sample_get_info(self.as_mut_ptr()); + let ptr = ffi::gst_sample_get_info(self.as_mut_ptr()); if ptr.is_null() { None } else { @@ -184,34 +181,32 @@ impl SampleRef { #[cfg(any(feature = "v1_16", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_16")))] pub fn set_buffer(&mut self, buffer: Option<&Buffer>) { - unsafe { gst_sys::gst_sample_set_buffer(self.as_mut_ptr(), buffer.to_glib_none().0) } + unsafe { ffi::gst_sample_set_buffer(self.as_mut_ptr(), buffer.to_glib_none().0) } } #[cfg(any(feature = "v1_16", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_16")))] pub fn set_buffer_list(&mut self, buffer_list: Option<&BufferList>) { - unsafe { - gst_sys::gst_sample_set_buffer_list(self.as_mut_ptr(), buffer_list.to_glib_none().0) - } + unsafe { ffi::gst_sample_set_buffer_list(self.as_mut_ptr(), buffer_list.to_glib_none().0) } } #[cfg(any(feature = "v1_16", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_16")))] pub fn set_caps(&mut self, caps: Option<&Caps>) { - unsafe { gst_sys::gst_sample_set_caps(self.as_mut_ptr(), caps.to_glib_none().0) } + unsafe { ffi::gst_sample_set_caps(self.as_mut_ptr(), caps.to_glib_none().0) } } #[cfg(any(feature = "v1_16", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_16")))] pub fn set_segment(&mut self, segment: Option<&Segment>) { - unsafe { gst_sys::gst_sample_set_segment(self.as_mut_ptr(), segment.to_glib_none().0) } + unsafe { ffi::gst_sample_set_segment(self.as_mut_ptr(), segment.to_glib_none().0) } } #[cfg(any(feature = "v1_16", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_16")))] pub fn set_info(&mut self, info: Option) { unsafe { - gst_sys::gst_sample_set_info( + ffi::gst_sample_set_info( self.as_mut_ptr(), info.map(|i| i.into_ptr()).unwrap_or(ptr::null_mut()), ); @@ -240,10 +235,10 @@ impl fmt::Debug for SampleRef { mod tests { #[test] fn test_sample_new_with_info() { - use Sample; - use Structure; + use crate::Sample; + use crate::Structure; - ::init().unwrap(); + crate::init().unwrap(); let info = Structure::builder("sample.info") .field("f3", &123i32) diff --git a/gstreamer/src/sample_serde.rs b/gstreamer/src/sample_serde.rs index a8fc6762f..da3ee734a 100644 --- a/gstreamer/src/sample_serde.rs +++ b/gstreamer/src/sample_serde.rs @@ -9,13 +9,13 @@ use serde::de::{Deserialize, Deserializer}; use serde::ser::{Serialize, SerializeStruct, Serializer}; -use Buffer; -use BufferList; -use Caps; -use Sample; -use SampleRef; -use Segment; -use Structure; +use crate::Buffer; +use crate::BufferList; +use crate::Caps; +use crate::Sample; +use crate::SampleRef; +use crate::Segment; +use crate::Structure; impl<'a> Serialize for SampleRef { fn serialize(&self, serializer: S) -> Result { @@ -35,7 +35,7 @@ impl<'a> Serialize for Sample { } } -#[derive(Deserialize)] +#[derive(serde::Deserialize)] struct SampleDe { buffer: Option, buffer_list: Option, @@ -82,21 +82,19 @@ impl<'de> Deserialize<'de> for Sample { #[cfg(test)] mod tests { - extern crate ron; - - use Buffer; - use Caps; - use ClockTime; - use Format; - use GenericFormattedValue; - use Sample; - use Segment; - use SegmentFlags; - use Structure; + use crate::Buffer; + use crate::Caps; + use crate::ClockTime; + use crate::Format; + use crate::GenericFormattedValue; + use crate::Sample; + use crate::Segment; + use crate::SegmentFlags; + use crate::Structure; #[test] fn test_serialize() { - ::init().unwrap(); + crate::init().unwrap(); let mut pretty_config = ron::ser::PrettyConfig::default(); pretty_config.new_line = "".to_string(); @@ -243,7 +241,7 @@ mod tests { #[test] fn test_deserialize() { - ::init().unwrap(); + crate::init().unwrap(); let buffer_ron = r#" ( @@ -328,7 +326,7 @@ mod tests { #[test] fn test_roundrip() { - ::init().unwrap(); + crate::init().unwrap(); // Segment present let sample = { diff --git a/gstreamer/src/segment.rs b/gstreamer/src/segment.rs index 66becac06..bfe638540 100644 --- a/gstreamer/src/segment.rs +++ b/gstreamer/src/segment.rs @@ -6,29 +6,25 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use glib; +use crate::Format; +use crate::FormattedValue; +use crate::GenericFormattedValue; +use crate::SeekFlags; +use crate::SeekType; use glib::translate::*; -use glib_sys; -use gobject_sys; -use gst_sys; use std::fmt; use std::marker::PhantomData; use std::mem; use std::ptr; -use Format; -use FormattedValue; -use GenericFormattedValue; -use SeekFlags; -use SeekType; pub type Segment = FormattedSegment; #[repr(transparent)] -pub struct FormattedSegment(gst_sys::GstSegment, PhantomData); +pub struct FormattedSegment(ffi::GstSegment, PhantomData); impl Segment { pub fn reset_with_format(&mut self, format: Format) { unsafe { - gst_sys::gst_segment_init(self.to_glib_none_mut().0, format.to_glib()); + ffi::gst_segment_init(self.to_glib_none_mut().0, format.to_glib()); } } @@ -78,7 +74,7 @@ impl FormattedSegment { assert_initialized_main_thread!(); let segment = unsafe { let mut segment = mem::MaybeUninit::zeroed(); - gst_sys::gst_segment_init(segment.as_mut_ptr(), T::get_default_format().to_glib()); + ffi::gst_segment_init(segment.as_mut_ptr(), T::get_default_format().to_glib()); segment.assume_init() }; FormattedSegment(segment, PhantomData) @@ -96,7 +92,7 @@ impl FormattedSegment { pub fn reset(&mut self) { unsafe { - gst_sys::gst_segment_init(&mut self.0, T::get_default_format().to_glib()); + ffi::gst_segment_init(&mut self.0, T::get_default_format().to_glib()); } } @@ -112,7 +108,7 @@ impl FormattedSegment { unsafe { let mut clip_start = mem::MaybeUninit::uninit(); let mut clip_stop = mem::MaybeUninit::uninit(); - let ret = from_glib(gst_sys::gst_segment_clip( + let ret = from_glib(ffi::gst_segment_clip( &self.0, start.get_format().to_glib(), start.to_raw_value() as u64, @@ -152,7 +148,7 @@ impl FormattedSegment { unsafe { let mut update = mem::MaybeUninit::uninit(); - let ret = from_glib(gst_sys::gst_segment_do_seek( + let ret = from_glib(ffi::gst_segment_do_seek( &mut self.0, rate, self.get_format().to_glib(), @@ -173,8 +169,8 @@ impl FormattedSegment { pub fn offset_running_time(&mut self, offset: i64) -> Result<(), glib::BoolError> { unsafe { - glib_result_from_gboolean!( - gst_sys::gst_segment_offset_running_time( + glib::glib_result_from_gboolean!( + ffi::gst_segment_offset_running_time( &mut self.0, self.get_format().to_glib(), offset, @@ -194,7 +190,7 @@ impl FormattedSegment { unsafe { T::from_raw( self.get_format(), - gst_sys::gst_segment_position_from_running_time( + ffi::gst_segment_position_from_running_time( &self.0, self.get_format().to_glib(), running_time.to_raw_value() as u64, @@ -212,7 +208,7 @@ impl FormattedSegment { unsafe { let mut position = mem::MaybeUninit::uninit(); - let ret = gst_sys::gst_segment_position_from_running_time_full( + let ret = ffi::gst_segment_position_from_running_time_full( &self.0, self.get_format().to_glib(), running_time.to_raw_value() as u64, @@ -235,7 +231,7 @@ impl FormattedSegment { unsafe { T::from_raw( self.get_format(), - gst_sys::gst_segment_position_from_stream_time( + ffi::gst_segment_position_from_stream_time( &self.0, self.get_format().to_glib(), stream_time.to_raw_value() as u64, @@ -253,7 +249,7 @@ impl FormattedSegment { unsafe { let mut position = mem::MaybeUninit::uninit(); - let ret = gst_sys::gst_segment_position_from_stream_time_full( + let ret = ffi::gst_segment_position_from_stream_time_full( &self.0, self.get_format().to_glib(), stream_time.to_raw_value() as u64, @@ -274,8 +270,8 @@ impl FormattedSegment { } unsafe { - glib_result_from_gboolean!( - gst_sys::gst_segment_set_running_time( + glib::glib_result_from_gboolean!( + ffi::gst_segment_set_running_time( &mut self.0, self.get_format().to_glib(), running_time.to_raw_value() as u64, @@ -295,7 +291,7 @@ impl FormattedSegment { unsafe { T::from_raw( self.get_format(), - gst_sys::gst_segment_to_running_time( + ffi::gst_segment_to_running_time( &self.0, self.get_format().to_glib(), position.to_raw_value() as u64, @@ -313,7 +309,7 @@ impl FormattedSegment { unsafe { let mut running_time = mem::MaybeUninit::uninit(); - let ret = gst_sys::gst_segment_to_running_time_full( + let ret = ffi::gst_segment_to_running_time_full( &self.0, self.get_format().to_glib(), position.to_raw_value() as u64, @@ -336,7 +332,7 @@ impl FormattedSegment { unsafe { T::from_raw( self.get_format(), - gst_sys::gst_segment_to_stream_time( + ffi::gst_segment_to_stream_time( &self.0, self.get_format().to_glib(), position.to_raw_value() as u64, @@ -354,7 +350,7 @@ impl FormattedSegment { unsafe { let mut stream_time = mem::MaybeUninit::uninit(); - let ret = gst_sys::gst_segment_to_stream_time_full( + let ret = ffi::gst_segment_to_stream_time_full( &self.0, self.get_format().to_glib(), position.to_raw_value() as u64, @@ -367,11 +363,11 @@ impl FormattedSegment { } } - pub fn get_flags(&self) -> ::SegmentFlags { + pub fn get_flags(&self) -> crate::SegmentFlags { from_glib(self.0.flags) } - pub fn set_flags(&mut self, flags: ::SegmentFlags) { + pub fn set_flags(&mut self, flags: crate::SegmentFlags) { self.0.flags = flags.to_glib(); } @@ -501,7 +497,7 @@ impl FormattedSegment { impl PartialEq for FormattedSegment { #[inline] fn eq(&self, other: &Self) -> bool { - unsafe { from_glib(gst_sys::gst_segment_is_equal(&self.0, &other.0)) } + unsafe { from_glib(ffi::gst_segment_is_equal(&self.0, &other.0)) } } } @@ -533,7 +529,7 @@ impl fmt::Debug for FormattedSegment { .field("format", &Format::Undefined) .finish(), Format::Time => { - let segment = segment.downcast_ref::<::ClockTime>().unwrap(); + let segment = segment.downcast_ref::().unwrap(); f.debug_struct("Segment") .field("format", &Format::Time) .field("start", &segment.get_start().to_string()) @@ -574,26 +570,26 @@ impl Default for FormattedSegment { impl glib::types::StaticType for FormattedSegment { fn static_type() -> glib::types::Type { - unsafe { glib::translate::from_glib(gst_sys::gst_segment_get_type()) } + unsafe { glib::translate::from_glib(ffi::gst_segment_get_type()) } } } #[doc(hidden)] impl<'a> glib::value::FromValueOptional<'a> for Segment { unsafe fn from_value_optional(value: &glib::Value) -> Option { - Option::::from_glib_none( - gobject_sys::g_value_get_boxed(value.to_glib_none().0) as *mut gst_sys::GstSegment - ) + Option::::from_glib_none(glib::gobject_ffi::g_value_get_boxed( + value.to_glib_none().0, + ) as *mut ffi::GstSegment) } } #[doc(hidden)] impl glib::value::SetValue for FormattedSegment { unsafe fn set_value(value: &mut glib::Value, this: &Self) { - gobject_sys::g_value_set_boxed( + glib::gobject_ffi::g_value_set_boxed( value.to_glib_none_mut().0, - glib::translate::ToGlibPtr::<*const gst_sys::GstSegment>::to_glib_none(this).0 - as glib_sys::gpointer, + glib::translate::ToGlibPtr::<*const ffi::GstSegment>::to_glib_none(this).0 + as glib::ffi::gpointer, ) } } @@ -601,78 +597,76 @@ impl glib::value::SetValue for FormattedSegment { #[doc(hidden)] impl glib::value::SetValueOptional for FormattedSegment { unsafe fn set_value_optional(value: &mut glib::Value, this: Option<&Self>) { - gobject_sys::g_value_set_boxed( + glib::gobject_ffi::g_value_set_boxed( value.to_glib_none_mut().0, - glib::translate::ToGlibPtr::<*const gst_sys::GstSegment>::to_glib_none(&this).0 - as glib_sys::gpointer, + glib::translate::ToGlibPtr::<*const ffi::GstSegment>::to_glib_none(&this).0 + as glib::ffi::gpointer, ) } } #[doc(hidden)] impl glib::translate::GlibPtrDefault for FormattedSegment { - type GlibType = *mut gst_sys::GstSegment; + type GlibType = *mut ffi::GstSegment; } #[doc(hidden)] -impl<'a, T: FormattedValue> glib::translate::ToGlibPtr<'a, *const gst_sys::GstSegment> +impl<'a, T: FormattedValue> glib::translate::ToGlibPtr<'a, *const ffi::GstSegment> for FormattedSegment { type Storage = &'a FormattedSegment; - fn to_glib_none(&'a self) -> glib::translate::Stash<'a, *const gst_sys::GstSegment, Self> { + fn to_glib_none(&'a self) -> glib::translate::Stash<'a, *const ffi::GstSegment, Self> { glib::translate::Stash(&self.0, self) } - fn to_glib_full(&self) -> *const gst_sys::GstSegment { + fn to_glib_full(&self) -> *const ffi::GstSegment { unimplemented!() } } #[doc(hidden)] -impl<'a, T: FormattedValue> glib::translate::ToGlibPtrMut<'a, *mut gst_sys::GstSegment> +impl<'a, T: FormattedValue> glib::translate::ToGlibPtrMut<'a, *mut ffi::GstSegment> for FormattedSegment { type Storage = &'a mut FormattedSegment; #[inline] - fn to_glib_none_mut( - &'a mut self, - ) -> glib::translate::StashMut<'a, *mut gst_sys::GstSegment, Self> { + fn to_glib_none_mut(&'a mut self) -> glib::translate::StashMut<'a, *mut ffi::GstSegment, Self> { glib::translate::StashMut(&mut self.0, self) } } #[doc(hidden)] -impl glib::translate::FromGlibPtrNone<*const gst_sys::GstSegment> for Segment { +impl glib::translate::FromGlibPtrNone<*const ffi::GstSegment> for Segment { #[inline] - unsafe fn from_glib_none(ptr: *const gst_sys::GstSegment) -> Self { + unsafe fn from_glib_none(ptr: *const ffi::GstSegment) -> Self { FormattedSegment(ptr::read(ptr), PhantomData) } } #[doc(hidden)] -impl glib::translate::FromGlibPtrNone<*mut gst_sys::GstSegment> for Segment { +impl glib::translate::FromGlibPtrNone<*mut ffi::GstSegment> for Segment { #[inline] - unsafe fn from_glib_none(ptr: *mut gst_sys::GstSegment) -> Self { + unsafe fn from_glib_none(ptr: *mut ffi::GstSegment) -> Self { FormattedSegment(ptr::read(ptr), PhantomData) } } #[doc(hidden)] -impl glib::translate::FromGlibPtrBorrow<*mut gst_sys::GstSegment> for Segment { +impl glib::translate::FromGlibPtrBorrow<*mut ffi::GstSegment> for Segment { #[inline] - unsafe fn from_glib_borrow(ptr: *mut gst_sys::GstSegment) -> Borrowed { + unsafe fn from_glib_borrow(ptr: *mut ffi::GstSegment) -> Borrowed { Borrowed::new(FormattedSegment(ptr::read(ptr), PhantomData)) } } #[doc(hidden)] -impl glib::translate::FromGlibPtrFull<*mut gst_sys::GstSegment> for Segment { +impl glib::translate::FromGlibPtrFull<*mut ffi::GstSegment> for Segment { #[inline] - unsafe fn from_glib_full(ptr: *mut gst_sys::GstSegment) -> Self { + unsafe fn from_glib_full(ptr: *mut ffi::GstSegment) -> Self { let segment = from_glib_none(ptr); - glib_sys::g_free(ptr as *mut _); + glib::ffi::g_free(ptr as *mut _); segment } } diff --git a/gstreamer/src/segment_serde.rs b/gstreamer/src/segment_serde.rs index 0182034a4..d3d4a2316 100644 --- a/gstreamer/src/segment_serde.rs +++ b/gstreamer/src/segment_serde.rs @@ -10,15 +10,15 @@ use serde::de; use serde::de::{Deserialize, Deserializer}; use serde::ser::{Serialize, Serializer}; -use Format; -use FormattedSegment; -use FormattedValue; -use GenericFormattedValue; -use Segment; -use SegmentFlags; -use SpecificFormattedValue; +use crate::Format; +use crate::FormattedSegment; +use crate::FormattedValue; +use crate::GenericFormattedValue; +use crate::Segment; +use crate::SegmentFlags; +use crate::SpecificFormattedValue; -#[derive(Serialize, Deserialize)] +#[derive(serde::Serialize, serde::Deserialize)] struct FormattedSegmentSerde { flags: SegmentFlags, rate: f64, @@ -114,17 +114,15 @@ impl<'de, T: FormattedValue + SpecificFormattedValue> Deserialize<'de> for Forma #[cfg(test)] mod tests { - extern crate ron; - - use ClockTime; - use Format; - use GenericFormattedValue; - use Segment; - use SegmentFlags; + use crate::ClockTime; + use crate::Format; + use crate::GenericFormattedValue; + use crate::Segment; + use crate::SegmentFlags; #[test] fn test_serialize() { - ::init().unwrap(); + crate::init().unwrap(); let mut segment = Segment::new(); segment.set_flags(SegmentFlags::RESET | SegmentFlags::SEGMENT); @@ -168,7 +166,7 @@ mod tests { #[test] fn test_deserialize_segment() { - ::init().unwrap(); + crate::init().unwrap(); let segment_ron = r#" ( @@ -228,10 +226,10 @@ mod tests { #[test] fn test_deserialize_formatted() { - use format::Time; - use FormattedSegment; + use crate::format::Time; + use crate::FormattedSegment; - ::init().unwrap(); + crate::init().unwrap(); let segment_ron = r#" ( @@ -270,7 +268,7 @@ mod tests { #[test] fn test_serde_roundtrip() { - ::init().unwrap(); + crate::init().unwrap(); let mut segment = Segment::new(); segment.set_flags(SegmentFlags::RESET | SegmentFlags::SEGMENT); diff --git a/gstreamer/src/static_caps.rs b/gstreamer/src/static_caps.rs index 49f3b789e..c770b7324 100644 --- a/gstreamer/src/static_caps.rs +++ b/gstreamer/src/static_caps.rs @@ -6,24 +6,19 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use Caps; +use crate::Caps; -use glib_sys; -use gobject_sys; -use gst_sys; - -use glib; use glib::translate::*; use std::ffi::CStr; use std::fmt; use std::ptr; -pub struct StaticCaps(ptr::NonNull); +pub struct StaticCaps(ptr::NonNull); impl StaticCaps { pub fn get(&self) -> Caps { - unsafe { from_glib_full(gst_sys::gst_static_caps_get(self.0.as_ptr())) } + unsafe { from_glib_full(ffi::gst_static_caps_get(self.0.as_ptr())) } } } @@ -42,26 +37,26 @@ impl fmt::Debug for StaticCaps { impl glib::types::StaticType for StaticCaps { fn static_type() -> glib::types::Type { - unsafe { glib::translate::from_glib(gst_sys::gst_static_caps_get_type()) } + unsafe { glib::translate::from_glib(ffi::gst_static_caps_get_type()) } } } #[doc(hidden)] impl<'a> glib::value::FromValueOptional<'a> for StaticCaps { unsafe fn from_value_optional(value: &glib::Value) -> Option { - Option::::from_glib_none( - gobject_sys::g_value_get_boxed(value.to_glib_none().0) as *mut gst_sys::GstStaticCaps - ) + Option::::from_glib_none(glib::gobject_ffi::g_value_get_boxed( + value.to_glib_none().0, + ) as *mut ffi::GstStaticCaps) } } #[doc(hidden)] impl glib::value::SetValue for StaticCaps { unsafe fn set_value(value: &mut glib::Value, this: &Self) { - gobject_sys::g_value_set_boxed( + glib::gobject_ffi::g_value_set_boxed( value.to_glib_none_mut().0, - glib::translate::ToGlibPtr::<*const gst_sys::GstStaticCaps>::to_glib_none(this).0 - as glib_sys::gpointer, + glib::translate::ToGlibPtr::<*const ffi::GstStaticCaps>::to_glib_none(this).0 + as glib::ffi::gpointer, ) } } @@ -69,63 +64,63 @@ impl glib::value::SetValue for StaticCaps { #[doc(hidden)] impl glib::value::SetValueOptional for StaticCaps { unsafe fn set_value_optional(value: &mut glib::Value, this: Option<&Self>) { - gobject_sys::g_value_set_boxed( + glib::gobject_ffi::g_value_set_boxed( value.to_glib_none_mut().0, - glib::translate::ToGlibPtr::<*const gst_sys::GstStaticCaps>::to_glib_none(&this).0 - as glib_sys::gpointer, + glib::translate::ToGlibPtr::<*const ffi::GstStaticCaps>::to_glib_none(&this).0 + as glib::ffi::gpointer, ) } } #[doc(hidden)] impl glib::translate::GlibPtrDefault for StaticCaps { - type GlibType = *mut gst_sys::GstStaticCaps; + type GlibType = *mut ffi::GstStaticCaps; } #[doc(hidden)] -impl<'a> glib::translate::ToGlibPtr<'a, *const gst_sys::GstStaticCaps> for StaticCaps { +impl<'a> glib::translate::ToGlibPtr<'a, *const ffi::GstStaticCaps> for StaticCaps { type Storage = &'a StaticCaps; - fn to_glib_none(&'a self) -> glib::translate::Stash<'a, *const gst_sys::GstStaticCaps, Self> { + fn to_glib_none(&'a self) -> glib::translate::Stash<'a, *const ffi::GstStaticCaps, Self> { glib::translate::Stash(self.0.as_ptr(), self) } - fn to_glib_full(&self) -> *const gst_sys::GstStaticCaps { + fn to_glib_full(&self) -> *const ffi::GstStaticCaps { unimplemented!() } } #[doc(hidden)] -impl glib::translate::FromGlibPtrNone<*const gst_sys::GstStaticCaps> for StaticCaps { +impl glib::translate::FromGlibPtrNone<*const ffi::GstStaticCaps> for StaticCaps { #[inline] - unsafe fn from_glib_none(ptr: *const gst_sys::GstStaticCaps) -> Self { + unsafe fn from_glib_none(ptr: *const ffi::GstStaticCaps) -> Self { assert!(!ptr.is_null()); StaticCaps(ptr::NonNull::new_unchecked(ptr as *mut _)) } } #[doc(hidden)] -impl glib::translate::FromGlibPtrNone<*mut gst_sys::GstStaticCaps> for StaticCaps { +impl glib::translate::FromGlibPtrNone<*mut ffi::GstStaticCaps> for StaticCaps { #[inline] - unsafe fn from_glib_none(ptr: *mut gst_sys::GstStaticCaps) -> Self { + unsafe fn from_glib_none(ptr: *mut ffi::GstStaticCaps) -> Self { assert!(!ptr.is_null()); StaticCaps(ptr::NonNull::new_unchecked(ptr)) } } #[doc(hidden)] -impl glib::translate::FromGlibPtrBorrow<*mut gst_sys::GstStaticCaps> for StaticCaps { +impl glib::translate::FromGlibPtrBorrow<*mut ffi::GstStaticCaps> for StaticCaps { #[inline] - unsafe fn from_glib_borrow(ptr: *mut gst_sys::GstStaticCaps) -> Borrowed { + unsafe fn from_glib_borrow(ptr: *mut ffi::GstStaticCaps) -> Borrowed { assert!(!ptr.is_null()); Borrowed::new(StaticCaps(ptr::NonNull::new_unchecked(ptr))) } } #[doc(hidden)] -impl glib::translate::FromGlibPtrFull<*mut gst_sys::GstStaticCaps> for StaticCaps { +impl glib::translate::FromGlibPtrFull<*mut ffi::GstStaticCaps> for StaticCaps { #[inline] - unsafe fn from_glib_full(_ptr: *mut gst_sys::GstStaticCaps) -> Self { + unsafe fn from_glib_full(_ptr: *mut ffi::GstStaticCaps) -> Self { unimplemented!(); } } diff --git a/gstreamer/src/static_pad_template.rs b/gstreamer/src/static_pad_template.rs index 97e33532e..624a1c70a 100644 --- a/gstreamer/src/static_pad_template.rs +++ b/gstreamer/src/static_pad_template.rs @@ -6,29 +6,24 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use Caps; -use PadTemplate; +use crate::Caps; +use crate::PadTemplate; -use glib_sys; -use gobject_sys; -use gst_sys; - -use glib; use glib::translate::*; use std::ffi::CStr; use std::fmt; use std::ptr; -pub struct StaticPadTemplate(ptr::NonNull); +pub struct StaticPadTemplate(ptr::NonNull); impl StaticPadTemplate { pub fn get(&self) -> PadTemplate { - unsafe { from_glib_full(gst_sys::gst_static_pad_template_get(self.0.as_ptr())) } + unsafe { from_glib_full(ffi::gst_static_pad_template_get(self.0.as_ptr())) } } pub fn get_caps(&self) -> Caps { - unsafe { from_glib_full(gst_sys::gst_static_pad_template_get_caps(self.0.as_ptr())) } + unsafe { from_glib_full(ffi::gst_static_pad_template_get_caps(self.0.as_ptr())) } } pub fn name_template<'a>(&self) -> &'a str { @@ -39,11 +34,11 @@ impl StaticPadTemplate { } } - pub fn direction(&self) -> ::PadDirection { + pub fn direction(&self) -> crate::PadDirection { unsafe { from_glib(self.0.as_ref().direction) } } - pub fn presence(&self) -> ::PadPresence { + pub fn presence(&self) -> crate::PadPresence { unsafe { from_glib(self.0.as_ref().presence) } } } @@ -58,13 +53,13 @@ impl fmt::Debug for StaticPadTemplate { CStr::from_ptr(self.0.as_ref().name_template).to_str() }) .field("direction", &unsafe { - from_glib::<_, ::PadDirection>(self.0.as_ref().direction) + from_glib::<_, crate::PadDirection>(self.0.as_ref().direction) }) .field("presence", &unsafe { - from_glib::<_, ::PadPresence>(self.0.as_ref().presence) + from_glib::<_, crate::PadPresence>(self.0.as_ref().presence) }) .field("static_caps", &unsafe { - from_glib_none::<_, ::StaticCaps>(&self.0.as_ref().static_caps as *const _) + from_glib_none::<_, crate::StaticCaps>(&self.0.as_ref().static_caps as *const _) }) .finish() } @@ -72,26 +67,26 @@ impl fmt::Debug for StaticPadTemplate { impl glib::types::StaticType for StaticPadTemplate { fn static_type() -> glib::types::Type { - unsafe { glib::translate::from_glib(gst_sys::gst_static_pad_template_get_type()) } + unsafe { glib::translate::from_glib(ffi::gst_static_pad_template_get_type()) } } } #[doc(hidden)] impl<'a> glib::value::FromValueOptional<'a> for StaticPadTemplate { unsafe fn from_value_optional(value: &glib::Value) -> Option { - Option::::from_glib_none(gobject_sys::g_value_get_boxed( + Option::::from_glib_none(glib::gobject_ffi::g_value_get_boxed( value.to_glib_none().0, - ) as *mut gst_sys::GstStaticPadTemplate) + ) as *mut ffi::GstStaticPadTemplate) } } #[doc(hidden)] impl glib::value::SetValue for StaticPadTemplate { unsafe fn set_value(value: &mut glib::Value, this: &Self) { - gobject_sys::g_value_set_boxed( + glib::gobject_ffi::g_value_set_boxed( value.to_glib_none_mut().0, - glib::translate::ToGlibPtr::<*const gst_sys::GstStaticPadTemplate>::to_glib_none(this).0 - as glib_sys::gpointer, + glib::translate::ToGlibPtr::<*const ffi::GstStaticPadTemplate>::to_glib_none(this).0 + as glib::ffi::gpointer, ) } } @@ -99,67 +94,65 @@ impl glib::value::SetValue for StaticPadTemplate { #[doc(hidden)] impl glib::value::SetValueOptional for StaticPadTemplate { unsafe fn set_value_optional(value: &mut glib::Value, this: Option<&Self>) { - gobject_sys::g_value_set_boxed( + glib::gobject_ffi::g_value_set_boxed( value.to_glib_none_mut().0, - glib::translate::ToGlibPtr::<*const gst_sys::GstStaticPadTemplate>::to_glib_none(&this) - .0 as glib_sys::gpointer, + glib::translate::ToGlibPtr::<*const ffi::GstStaticPadTemplate>::to_glib_none(&this).0 + as glib::ffi::gpointer, ) } } #[doc(hidden)] impl glib::translate::GlibPtrDefault for StaticPadTemplate { - type GlibType = *mut gst_sys::GstStaticPadTemplate; + type GlibType = *mut ffi::GstStaticPadTemplate; } #[doc(hidden)] -impl<'a> glib::translate::ToGlibPtr<'a, *const gst_sys::GstStaticPadTemplate> - for StaticPadTemplate -{ +impl<'a> glib::translate::ToGlibPtr<'a, *const ffi::GstStaticPadTemplate> for StaticPadTemplate { type Storage = &'a StaticPadTemplate; fn to_glib_none( &'a self, - ) -> glib::translate::Stash<'a, *const gst_sys::GstStaticPadTemplate, Self> { + ) -> glib::translate::Stash<'a, *const ffi::GstStaticPadTemplate, Self> { glib::translate::Stash(self.0.as_ptr(), self) } - fn to_glib_full(&self) -> *const gst_sys::GstStaticPadTemplate { + fn to_glib_full(&self) -> *const ffi::GstStaticPadTemplate { unimplemented!() } } #[doc(hidden)] -impl glib::translate::FromGlibPtrNone<*const gst_sys::GstStaticPadTemplate> for StaticPadTemplate { +impl glib::translate::FromGlibPtrNone<*const ffi::GstStaticPadTemplate> for StaticPadTemplate { #[inline] - unsafe fn from_glib_none(ptr: *const gst_sys::GstStaticPadTemplate) -> Self { + unsafe fn from_glib_none(ptr: *const ffi::GstStaticPadTemplate) -> Self { assert!(!ptr.is_null()); StaticPadTemplate(ptr::NonNull::new_unchecked(ptr as *mut _)) } } #[doc(hidden)] -impl glib::translate::FromGlibPtrNone<*mut gst_sys::GstStaticPadTemplate> for StaticPadTemplate { +impl glib::translate::FromGlibPtrNone<*mut ffi::GstStaticPadTemplate> for StaticPadTemplate { #[inline] - unsafe fn from_glib_none(ptr: *mut gst_sys::GstStaticPadTemplate) -> Self { + unsafe fn from_glib_none(ptr: *mut ffi::GstStaticPadTemplate) -> Self { assert!(!ptr.is_null()); StaticPadTemplate(ptr::NonNull::new_unchecked(ptr)) } } #[doc(hidden)] -impl glib::translate::FromGlibPtrBorrow<*mut gst_sys::GstStaticPadTemplate> for StaticPadTemplate { +impl glib::translate::FromGlibPtrBorrow<*mut ffi::GstStaticPadTemplate> for StaticPadTemplate { #[inline] - unsafe fn from_glib_borrow(ptr: *mut gst_sys::GstStaticPadTemplate) -> Borrowed { + unsafe fn from_glib_borrow(ptr: *mut ffi::GstStaticPadTemplate) -> Borrowed { assert!(!ptr.is_null()); Borrowed::new(StaticPadTemplate(ptr::NonNull::new_unchecked(ptr))) } } #[doc(hidden)] -impl glib::translate::FromGlibPtrFull<*mut gst_sys::GstStaticPadTemplate> for StaticPadTemplate { +impl glib::translate::FromGlibPtrFull<*mut ffi::GstStaticPadTemplate> for StaticPadTemplate { #[inline] - unsafe fn from_glib_full(_ptr: *mut gst_sys::GstStaticPadTemplate) -> Self { + unsafe fn from_glib_full(_ptr: *mut ffi::GstStaticPadTemplate) -> Self { unimplemented!(); } } diff --git a/gstreamer/src/stream.rs b/gstreamer/src/stream.rs index 79caa4f71..c92d14fa0 100644 --- a/gstreamer/src/stream.rs +++ b/gstreamer/src/stream.rs @@ -6,13 +6,12 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use crate::Caps; +use crate::Stream; +use crate::StreamFlags; +use crate::StreamType; use glib::translate::*; -use gst_sys; use std::fmt; -use Caps; -use Stream; -use StreamFlags; -use StreamType; impl Stream { pub fn new( @@ -25,10 +24,10 @@ impl Stream { let stream_id = stream_id.to_glib_none(); let caps = caps.to_glib_none(); - let (major, minor, _, _) = ::version(); + let (major, minor, _, _) = crate::version(); if (major, minor) > (1, 12) { unsafe { - from_glib_full(gst_sys::gst_stream_new( + from_glib_full(ffi::gst_stream_new( stream_id.0, caps.0, type_.to_glib(), @@ -38,7 +37,7 @@ impl Stream { } else { // Work-around for 1.14 switching from transfer-floating to transfer-full unsafe { - from_glib_none(gst_sys::gst_stream_new( + from_glib_none(ffi::gst_stream_new( stream_id.0, caps.0, type_.to_glib(), diff --git a/gstreamer/src/stream_collection.rs b/gstreamer/src/stream_collection.rs index eb96e2617..c826e460f 100644 --- a/gstreamer/src/stream_collection.rs +++ b/gstreamer/src/stream_collection.rs @@ -6,11 +6,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use crate::Stream; +use crate::StreamCollection; use glib::translate::*; -use gst_sys; use std::fmt; -use Stream; -use StreamCollection; #[derive(Debug)] pub struct Iter<'a> { @@ -74,10 +73,7 @@ pub struct StreamCollectionBuilder(StreamCollection); impl StreamCollectionBuilder { pub fn stream(self, stream: &Stream) -> Self { unsafe { - gst_sys::gst_stream_collection_add_stream( - (self.0).to_glib_none().0, - stream.to_glib_full(), - ); + ffi::gst_stream_collection_add_stream((self.0).to_glib_none().0, stream.to_glib_full()); } self @@ -86,7 +82,7 @@ impl StreamCollectionBuilder { pub fn streams>(self, streams: &[S]) -> Self { for stream in streams { unsafe { - gst_sys::gst_stream_collection_add_stream( + ffi::gst_stream_collection_add_stream( (self.0).to_glib_none().0, stream.as_ref().to_glib_full(), ); @@ -105,12 +101,12 @@ impl StreamCollection { pub fn builder(upstream_id: Option<&str>) -> StreamCollectionBuilder { assert_initialized_main_thread!(); let upstream_id = upstream_id.to_glib_none(); - let (major, minor, _, _) = ::version(); + let (major, minor, _, _) = crate::version(); let collection = if (major, minor) > (1, 12) { - unsafe { from_glib_full(gst_sys::gst_stream_collection_new(upstream_id.0)) } + unsafe { from_glib_full(ffi::gst_stream_collection_new(upstream_id.0)) } } else { // Work-around for 1.14 switching from transfer-floating to transfer-full - unsafe { from_glib_none(gst_sys::gst_stream_collection_new(upstream_id.0)) } + unsafe { from_glib_none(ffi::gst_stream_collection_new(upstream_id.0)) } }; StreamCollectionBuilder(collection) diff --git a/gstreamer/src/structure.rs b/gstreamer/src/structure.rs index f9cf9d8fe..2ad749073 100644 --- a/gstreamer/src/structure.rs +++ b/gstreamer/src/structure.rs @@ -16,17 +16,14 @@ use std::str; use thiserror::Error; -use Fraction; +use crate::Fraction; -use glib; +use glib::ffi::gpointer; use glib::translate::{ from_glib, from_glib_full, FromGlibPtrFull, FromGlibPtrNone, GlibPtrDefault, Stash, StashMut, ToGlib, ToGlibPtr, ToGlibPtrMut, }; use glib::value::{FromValue, FromValueOptional, SendValue, ToSendValue}; -use glib_sys::gpointer; -use gobject_sys; -use gst_sys; #[derive(Clone, Debug, Eq, PartialEq, Error)] pub enum GetError<'name> { @@ -68,7 +65,7 @@ impl Structure { pub fn new_empty(name: &str) -> Structure { assert_initialized_main_thread!(); unsafe { - let ptr = gst_sys::gst_structure_new_empty(name.to_glib_none().0) as *mut StructureRef; + let ptr = ffi::gst_structure_new_empty(name.to_glib_none().0) as *mut StructureRef; assert!(!ptr.is_null()); Structure(ptr::NonNull::new_unchecked(ptr)) } @@ -85,9 +82,9 @@ impl Structure { structure } - pub unsafe fn into_ptr(self) -> *mut gst_sys::GstStructure { + pub unsafe fn into_ptr(self) -> *mut ffi::GstStructure { let s = mem::ManuallyDrop::new(self); - s.0.as_ptr() as *mut StructureRef as *mut gst_sys::GstStructure + s.0.as_ptr() as *mut StructureRef as *mut ffi::GstStructure } #[allow(clippy::should_implement_trait)] @@ -100,7 +97,7 @@ impl Structure { iter.into_iter().for_each(|(f, v)| unsafe { let mut value = v.clone().into_raw(); - gst_sys::gst_structure_take_value( + ffi::gst_structure_take_value( &mut structure.0.as_mut().0, f.to_glib_none().0, &mut value, @@ -140,7 +137,7 @@ impl AsMut for Structure { impl Clone for Structure { fn clone(&self) -> Self { unsafe { - let ptr = gst_sys::gst_structure_copy(&self.0.as_ref().0) as *mut StructureRef; + let ptr = ffi::gst_structure_copy(&self.0.as_ref().0) as *mut StructureRef; assert!(!ptr.is_null()); Structure(ptr::NonNull::new_unchecked(ptr)) } @@ -149,7 +146,7 @@ impl Clone for Structure { impl Drop for Structure { fn drop(&mut self) { - unsafe { gst_sys::gst_structure_free(&mut self.0.as_mut().0) } + unsafe { ffi::gst_structure_free(&mut self.0.as_mut().0) } } } @@ -187,9 +184,11 @@ impl str::FromStr for Structure { fn from_str(s: &str) -> Result { assert_initialized_main_thread!(); unsafe { - let structure = gst_sys::gst_structure_from_string(s.to_glib_none().0, ptr::null_mut()); + let structure = ffi::gst_structure_from_string(s.to_glib_none().0, ptr::null_mut()); if structure.is_null() { - Err(glib_bool_error!("Failed to parse structure from string")) + Err(glib::glib_bool_error!( + "Failed to parse structure from string" + )) } else { Ok(Structure(ptr::NonNull::new_unchecked( structure as *mut StructureRef, @@ -216,7 +215,7 @@ impl ToOwned for StructureRef { fn to_owned(&self) -> Structure { unsafe { - let ptr = gst_sys::gst_structure_copy(&self.0) as *mut StructureRef; + let ptr = ffi::gst_structure_copy(&self.0) as *mut StructureRef; assert!(!ptr.is_null()); Structure(ptr::NonNull::new_unchecked(ptr)) } @@ -225,69 +224,69 @@ impl ToOwned for StructureRef { impl glib::types::StaticType for Structure { fn static_type() -> glib::types::Type { - unsafe { from_glib(gst_sys::gst_structure_get_type()) } + unsafe { from_glib(ffi::gst_structure_get_type()) } } } -impl<'a> ToGlibPtr<'a, *const gst_sys::GstStructure> for Structure { +impl<'a> ToGlibPtr<'a, *const ffi::GstStructure> for Structure { type Storage = &'a Self; - fn to_glib_none(&'a self) -> Stash<'a, *const gst_sys::GstStructure, Self> { + fn to_glib_none(&'a self) -> Stash<'a, *const ffi::GstStructure, Self> { unsafe { Stash(&self.0.as_ref().0, self) } } - fn to_glib_full(&self) -> *const gst_sys::GstStructure { - unsafe { gst_sys::gst_structure_copy(&self.0.as_ref().0) } + fn to_glib_full(&self) -> *const ffi::GstStructure { + unsafe { ffi::gst_structure_copy(&self.0.as_ref().0) } } } -impl<'a> ToGlibPtr<'a, *mut gst_sys::GstStructure> for Structure { +impl<'a> ToGlibPtr<'a, *mut ffi::GstStructure> for Structure { type Storage = &'a Self; - fn to_glib_none(&'a self) -> Stash<'a, *mut gst_sys::GstStructure, Self> { + fn to_glib_none(&'a self) -> Stash<'a, *mut ffi::GstStructure, Self> { unsafe { Stash(&self.0.as_ref().0 as *const _ as *mut _, self) } } - fn to_glib_full(&self) -> *mut gst_sys::GstStructure { - unsafe { gst_sys::gst_structure_copy(&self.0.as_ref().0) } + fn to_glib_full(&self) -> *mut ffi::GstStructure { + unsafe { ffi::gst_structure_copy(&self.0.as_ref().0) } } } -impl<'a> ToGlibPtrMut<'a, *mut gst_sys::GstStructure> for Structure { +impl<'a> ToGlibPtrMut<'a, *mut ffi::GstStructure> for Structure { type Storage = &'a mut Self; - fn to_glib_none_mut(&'a mut self) -> StashMut<*mut gst_sys::GstStructure, Self> { + fn to_glib_none_mut(&'a mut self) -> StashMut<*mut ffi::GstStructure, Self> { unsafe { StashMut(&mut self.0.as_mut().0, self) } } } -impl FromGlibPtrNone<*const gst_sys::GstStructure> for Structure { - unsafe fn from_glib_none(ptr: *const gst_sys::GstStructure) -> Self { +impl FromGlibPtrNone<*const ffi::GstStructure> for Structure { + unsafe fn from_glib_none(ptr: *const ffi::GstStructure) -> Self { assert!(!ptr.is_null()); - let ptr = gst_sys::gst_structure_copy(ptr); + let ptr = ffi::gst_structure_copy(ptr); assert!(!ptr.is_null()); Structure(ptr::NonNull::new_unchecked(ptr as *mut StructureRef)) } } -impl FromGlibPtrNone<*mut gst_sys::GstStructure> for Structure { - unsafe fn from_glib_none(ptr: *mut gst_sys::GstStructure) -> Self { +impl FromGlibPtrNone<*mut ffi::GstStructure> for Structure { + unsafe fn from_glib_none(ptr: *mut ffi::GstStructure) -> Self { assert!(!ptr.is_null()); - let ptr = gst_sys::gst_structure_copy(ptr); + let ptr = ffi::gst_structure_copy(ptr); assert!(!ptr.is_null()); Structure(ptr::NonNull::new_unchecked(ptr as *mut StructureRef)) } } -impl FromGlibPtrFull<*const gst_sys::GstStructure> for Structure { - unsafe fn from_glib_full(ptr: *const gst_sys::GstStructure) -> Self { +impl FromGlibPtrFull<*const ffi::GstStructure> for Structure { + unsafe fn from_glib_full(ptr: *const ffi::GstStructure) -> Self { assert!(!ptr.is_null()); Structure(ptr::NonNull::new_unchecked(ptr as *mut StructureRef)) } } -impl FromGlibPtrFull<*mut gst_sys::GstStructure> for Structure { - unsafe fn from_glib_full(ptr: *mut gst_sys::GstStructure) -> Self { +impl FromGlibPtrFull<*mut ffi::GstStructure> for Structure { + unsafe fn from_glib_full(ptr: *mut ffi::GstStructure) -> Self { assert!(!ptr.is_null()); Structure(ptr::NonNull::new_unchecked(ptr as *mut StructureRef)) } @@ -316,36 +315,34 @@ impl glib::value::SetValueOptional for Structure { } impl GlibPtrDefault for Structure { - type GlibType = *mut gst_sys::GstStructure; + type GlibType = *mut ffi::GstStructure; } #[repr(transparent)] -pub struct StructureRef(gst_sys::GstStructure); +pub struct StructureRef(ffi::GstStructure); unsafe impl Send for StructureRef {} unsafe impl Sync for StructureRef {} impl StructureRef { - pub unsafe fn from_glib_borrow<'a>(ptr: *const gst_sys::GstStructure) -> &'a StructureRef { + pub unsafe fn from_glib_borrow<'a>(ptr: *const ffi::GstStructure) -> &'a StructureRef { assert!(!ptr.is_null()); &*(ptr as *mut StructureRef) } - pub unsafe fn from_glib_borrow_mut<'a>( - ptr: *mut gst_sys::GstStructure, - ) -> &'a mut StructureRef { + pub unsafe fn from_glib_borrow_mut<'a>(ptr: *mut ffi::GstStructure) -> &'a mut StructureRef { assert!(!ptr.is_null()); &mut *(ptr as *mut StructureRef) } - pub unsafe fn as_ptr(&self) -> *const gst_sys::GstStructure { - self as *const Self as *const gst_sys::GstStructure + pub unsafe fn as_ptr(&self) -> *const ffi::GstStructure { + self as *const Self as *const ffi::GstStructure } - pub unsafe fn as_mut_ptr(&self) -> *mut gst_sys::GstStructure { - self as *const Self as *mut gst_sys::GstStructure + pub unsafe fn as_mut_ptr(&self) -> *mut ffi::GstStructure { + self as *const Self as *mut ffi::GstStructure } pub fn get<'structure, 'name, T: FromValueOptional<'structure>>( @@ -385,7 +382,7 @@ impl StructureRef { name: &'name str, ) -> Result<&SendValue, GetError<'name>> { unsafe { - let value = gst_sys::gst_structure_get_value(&self.0, name.to_glib_none().0); + let value = ffi::gst_structure_get_value(&self.0, name.to_glib_none().0); if value.is_null() { return Err(GetError::new_field_not_found(name)); @@ -403,25 +400,25 @@ impl StructureRef { pub fn set_value(&mut self, name: &str, value: SendValue) { unsafe { let mut value = value.into_raw(); - gst_sys::gst_structure_take_value(&mut self.0, name.to_glib_none().0, &mut value); + ffi::gst_structure_take_value(&mut self.0, name.to_glib_none().0, &mut value); } } pub fn get_name<'a>(&self) -> &'a str { unsafe { - CStr::from_ptr(gst_sys::gst_structure_get_name(&self.0)) + CStr::from_ptr(ffi::gst_structure_get_name(&self.0)) .to_str() .unwrap() } } pub fn set_name(&mut self, name: &str) { - unsafe { gst_sys::gst_structure_set_name(&mut self.0, name.to_glib_none().0) } + unsafe { ffi::gst_structure_set_name(&mut self.0, name.to_glib_none().0) } } pub fn has_field(&self, field: &str) -> bool { unsafe { - from_glib(gst_sys::gst_structure_has_field( + from_glib(ffi::gst_structure_has_field( &self.0, field.to_glib_none().0, )) @@ -430,7 +427,7 @@ impl StructureRef { pub fn has_field_with_type(&self, field: &str, type_: glib::Type) -> bool { unsafe { - from_glib(gst_sys::gst_structure_has_field_typed( + from_glib(ffi::gst_structure_has_field_typed( &self.0, field.to_glib_none().0, type_.to_glib(), @@ -440,7 +437,7 @@ impl StructureRef { pub fn remove_field(&mut self, field: &str) { unsafe { - gst_sys::gst_structure_remove_field(&mut self.0, field.to_glib_none().0); + ffi::gst_structure_remove_field(&mut self.0, field.to_glib_none().0); } } @@ -452,7 +449,7 @@ impl StructureRef { pub fn remove_all_fields(&mut self) { unsafe { - gst_sys::gst_structure_remove_all_fields(&mut self.0); + ffi::gst_structure_remove_all_fields(&mut self.0); } } @@ -466,7 +463,7 @@ impl StructureRef { pub fn get_nth_field_name<'a>(&self, idx: u32) -> Option<&'a str> { unsafe { - let field_name = gst_sys::gst_structure_nth_field_name(&self.0, idx); + let field_name = ffi::gst_structure_nth_field_name(&self.0, idx); if field_name.is_null() { return None; } @@ -476,28 +473,28 @@ impl StructureRef { } pub fn n_fields(&self) -> u32 { - unsafe { gst_sys::gst_structure_n_fields(&self.0) as u32 } + unsafe { ffi::gst_structure_n_fields(&self.0) as u32 } } pub fn can_intersect(&self, other: &StructureRef) -> bool { - unsafe { from_glib(gst_sys::gst_structure_can_intersect(&self.0, &other.0)) } + unsafe { from_glib(ffi::gst_structure_can_intersect(&self.0, &other.0)) } } pub fn intersect(&self, other: &StructureRef) -> Option { - unsafe { from_glib_full(gst_sys::gst_structure_intersect(&self.0, &other.0)) } + unsafe { from_glib_full(ffi::gst_structure_intersect(&self.0, &other.0)) } } pub fn is_subset(&self, superset: &StructureRef) -> bool { - unsafe { from_glib(gst_sys::gst_structure_is_subset(&self.0, &superset.0)) } + unsafe { from_glib(ffi::gst_structure_is_subset(&self.0, &superset.0)) } } pub fn fixate(&mut self) { - unsafe { gst_sys::gst_structure_fixate(&mut self.0) } + unsafe { ffi::gst_structure_fixate(&mut self.0) } } pub fn fixate_field(&mut self, name: &str) -> bool { unsafe { - from_glib(gst_sys::gst_structure_fixate_field( + from_glib(ffi::gst_structure_fixate_field( &mut self.0, name.to_glib_none().0, )) @@ -506,7 +503,7 @@ impl StructureRef { pub fn fixate_field_bool(&mut self, name: &str, target: bool) -> bool { unsafe { - from_glib(gst_sys::gst_structure_fixate_field_boolean( + from_glib(ffi::gst_structure_fixate_field_boolean( &mut self.0, name.to_glib_none().0, target.to_glib(), @@ -516,7 +513,7 @@ impl StructureRef { pub fn fixate_field_str(&mut self, name: &str, target: &str) -> bool { unsafe { - from_glib(gst_sys::gst_structure_fixate_field_string( + from_glib(ffi::gst_structure_fixate_field_string( &mut self.0, name.to_glib_none().0, target.to_glib_none().0, @@ -526,7 +523,7 @@ impl StructureRef { pub fn fixate_field_nearest_double(&mut self, name: &str, target: f64) -> bool { unsafe { - from_glib(gst_sys::gst_structure_fixate_field_nearest_double( + from_glib(ffi::gst_structure_fixate_field_nearest_double( &mut self.0, name.to_glib_none().0, target, @@ -543,7 +540,7 @@ impl StructureRef { let target = target.into(); unsafe { - from_glib(gst_sys::gst_structure_fixate_field_nearest_fraction( + from_glib(ffi::gst_structure_fixate_field_nearest_fraction( &mut self.0, name.to_glib_none().0, *target.numer(), @@ -554,7 +551,7 @@ impl StructureRef { pub fn fixate_field_nearest_int(&mut self, name: &str, target: i32) -> bool { unsafe { - from_glib(gst_sys::gst_structure_fixate_field_nearest_int( + from_glib(ffi::gst_structure_fixate_field_nearest_int( &mut self.0, name.to_glib_none().0, target, @@ -565,7 +562,7 @@ impl StructureRef { impl fmt::Display for StructureRef { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - let s = unsafe { glib::GString::from_glib_full(gst_sys::gst_structure_to_string(&self.0)) }; + let s = unsafe { glib::GString::from_glib_full(ffi::gst_structure_to_string(&self.0)) }; f.write_str(&s) } } @@ -578,7 +575,7 @@ impl fmt::Debug for StructureRef { impl PartialEq for StructureRef { fn eq(&self, other: &StructureRef) -> bool { - unsafe { from_glib(gst_sys::gst_structure_is_equal(&self.0, &other.0)) } + unsafe { from_glib(ffi::gst_structure_is_equal(&self.0, &other.0)) } } } @@ -586,18 +583,18 @@ impl Eq for StructureRef {} impl glib::types::StaticType for StructureRef { fn static_type() -> glib::types::Type { - unsafe { from_glib(gst_sys::gst_structure_get_type()) } + unsafe { from_glib(ffi::gst_structure_get_type()) } } } impl<'a> glib::value::FromValueOptional<'a> for &'a StructureRef { unsafe fn from_value_optional(v: &'a glib::Value) -> Option { - let ptr = gobject_sys::g_value_get_boxed(v.to_glib_none().0); + let ptr = glib::gobject_ffi::g_value_get_boxed(v.to_glib_none().0); if ptr.is_null() { None } else { Some(StructureRef::from_glib_borrow( - ptr as *const gst_sys::GstStructure, + ptr as *const ffi::GstStructure, )) } } @@ -605,16 +602,16 @@ impl<'a> glib::value::FromValueOptional<'a> for &'a StructureRef { impl glib::value::SetValue for StructureRef { unsafe fn set_value(v: &mut glib::Value, s: &Self) { - gobject_sys::g_value_set_boxed(v.to_glib_none_mut().0, s.as_ptr() as gpointer); + glib::gobject_ffi::g_value_set_boxed(v.to_glib_none_mut().0, s.as_ptr() as gpointer); } } impl glib::value::SetValueOptional for StructureRef { unsafe fn set_value_optional(v: &mut glib::Value, s: Option<&Self>) { if let Some(s) = s { - gobject_sys::g_value_set_boxed(v.to_glib_none_mut().0, s.as_ptr() as gpointer); + glib::gobject_ffi::g_value_set_boxed(v.to_glib_none_mut().0, s.as_ptr() as gpointer); } else { - gobject_sys::g_value_set_boxed(v.to_glib_none_mut().0, ptr::null_mut()); + glib::gobject_ffi::g_value_set_boxed(v.to_glib_none_mut().0, ptr::null_mut()); } } } @@ -759,7 +756,7 @@ mod tests { fn new_set_get() { use glib::{value, Type}; - ::init().unwrap(); + crate::init().unwrap(); let mut s = Structure::new_empty("test"); assert_eq!(s.get_name(), "test"); @@ -816,7 +813,7 @@ mod tests { #[test] fn test_builder() { - ::init().unwrap(); + crate::init().unwrap(); let s = Structure::builder("test") .field("f1", &"abc") @@ -832,7 +829,7 @@ mod tests { #[test] fn test_string_conversion() { - ::init().unwrap(); + crate::init().unwrap(); let a = "Test, f1=(string)abc, f2=(uint)123;"; @@ -845,7 +842,7 @@ mod tests { #[test] fn test_from_value_optional() { - ::init().unwrap(); + crate::init().unwrap(); let a = glib::value::Value::from(None::<&Structure>); assert!(a.get::().unwrap().is_none()); @@ -855,7 +852,7 @@ mod tests { #[test] fn test_new_from_iter() { - ::init().unwrap(); + crate::init().unwrap(); let s = Structure::builder("test") .field("f1", &"abc") diff --git a/gstreamer/src/structure_serde.rs b/gstreamer/src/structure_serde.rs index 1d90ead74..96a77abaa 100644 --- a/gstreamer/src/structure_serde.rs +++ b/gstreamer/src/structure_serde.rs @@ -6,7 +6,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use glib; use glib::{Date, ToValue}; use serde::de; @@ -16,16 +15,16 @@ use serde::ser::{Serialize, SerializeSeq, SerializeTuple, Serializer}; use std::fmt; -use Buffer; -use DateTime; -use Sample; +use crate::Buffer; +use crate::DateTime; +use crate::Sample; -use date_time_serde; -use value::*; -use value_serde::*; +use crate::date_time_serde; +use crate::value::*; +use crate::value_serde::*; -use Structure; -use StructureRef; +use crate::Structure; +use crate::StructureRef; struct FieldSe<'a>(&'static str, &'a glib::SendValue); impl<'a> Serialize for FieldSe<'a> { @@ -169,18 +168,16 @@ impl<'de> Deserialize<'de> for Structure { #[cfg(test)] mod tests { - extern crate ron; - use glib::{Date, DateMonth}; - use Array; - use DateTime; - use Fraction; - use Structure; + use crate::Array; + use crate::DateTime; + use crate::Fraction; + use crate::Structure; #[test] fn test_serialize() { - ::init().unwrap(); + crate::init().unwrap(); let s = Structure::builder("test") .field("f1", &"abc") @@ -221,7 +218,7 @@ mod tests { #[test] fn test_deserialize() { - ::init().unwrap(); + crate::init().unwrap(); let s_ron = r#" ("test", [ @@ -260,7 +257,7 @@ mod tests { #[test] fn test_serde_roundtrip() { - ::init().unwrap(); + crate::init().unwrap(); let s = Structure::builder("test") .field("f1", &"abc") diff --git a/gstreamer/src/subclass/bin.rs b/gstreamer/src/subclass/bin.rs index 19d1e4762..e3b4f531e 100644 --- a/gstreamer/src/subclass/bin.rs +++ b/gstreamer/src/subclass/bin.rs @@ -6,19 +6,16 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use glib_sys; -use gst_sys; - use glib::prelude::*; use glib::translate::*; use super::prelude::*; use glib::subclass::prelude::*; -use Bin; -use Element; -use LoggableError; -use Message; +use crate::Bin; +use crate::Element; +use crate::LoggableError; +use crate::Message; pub trait BinImpl: BinImplExt + ElementImpl { fn add_element(&self, bin: &Self::Type, element: &Element) -> Result<(), LoggableError> { @@ -50,16 +47,19 @@ impl BinImplExt for T { fn parent_add_element(&self, bin: &Self::Type, element: &Element) -> Result<(), LoggableError> { unsafe { let data = T::type_data(); - let parent_class = data.as_ref().get_parent_class() as *mut gst_sys::GstBinClass; + let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstBinClass; let f = (*parent_class).add_element.ok_or_else(|| { - gst_loggable_error!(::CAT_RUST, "Parent function `add_element` is not defined") + gst_loggable_error!( + crate::CAT_RUST, + "Parent function `add_element` is not defined" + ) })?; gst_result_from_gboolean!( f( - bin.unsafe_cast_ref::<::Bin>().to_glib_none().0, + bin.unsafe_cast_ref::().to_glib_none().0, element.to_glib_none().0 ), - ::CAT_RUST, + crate::CAT_RUST, "Failed to add the element using the parent function" ) } @@ -72,19 +72,19 @@ impl BinImplExt for T { ) -> Result<(), LoggableError> { unsafe { let data = T::type_data(); - let parent_class = data.as_ref().get_parent_class() as *mut gst_sys::GstBinClass; + let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstBinClass; let f = (*parent_class).remove_element.ok_or_else(|| { gst_loggable_error!( - ::CAT_RUST, + crate::CAT_RUST, "Parent function `remove_element` is not defined" ) })?; gst_result_from_gboolean!( f( - bin.unsafe_cast_ref::<::Bin>().to_glib_none().0, + bin.unsafe_cast_ref::().to_glib_none().0, element.to_glib_none().0 ), - ::CAT_RUST, + crate::CAT_RUST, "Failed to remove the element using the parent function" ) } @@ -93,10 +93,10 @@ impl BinImplExt for T { fn parent_handle_message(&self, bin: &Self::Type, message: Message) { unsafe { let data = T::type_data(); - let parent_class = data.as_ref().get_parent_class() as *mut gst_sys::GstBinClass; + let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstBinClass; if let Some(ref f) = (*parent_class).handle_message { f( - bin.unsafe_cast_ref::<::Bin>().to_glib_none().0, + bin.unsafe_cast_ref::().to_glib_none().0, message.into_ptr(), ); } @@ -109,7 +109,7 @@ where ::Instance: PanicPoison, { fn override_vfuncs(klass: &mut glib::Class) { - <::Element as IsSubclassable>::override_vfuncs(klass); + >::override_vfuncs(klass); let klass = klass.as_mut(); klass.add_element = Some(bin_add_element::); klass.remove_element = Some(bin_remove_element::); @@ -118,9 +118,9 @@ where } unsafe extern "C" fn bin_add_element( - ptr: *mut gst_sys::GstBin, - element: *mut gst_sys::GstElement, -) -> glib_sys::gboolean + ptr: *mut ffi::GstBin, + element: *mut ffi::GstElement, +) -> glib::ffi::gboolean where T::Instance: PanicPoison, { @@ -141,9 +141,9 @@ where } unsafe extern "C" fn bin_remove_element( - ptr: *mut gst_sys::GstBin, - element: *mut gst_sys::GstElement, -) -> glib_sys::gboolean + ptr: *mut ffi::GstBin, + element: *mut ffi::GstElement, +) -> glib::ffi::gboolean where T::Instance: PanicPoison, { @@ -154,8 +154,10 @@ where // If we get a floating reference passed simply return FALSE here. It can't be // stored inside this bin, and if we continued to use it we would take ownership // of this floating reference. - if gobject_sys::g_object_is_floating(element as *mut gobject_sys::GObject) != glib_sys::GFALSE { - return glib_sys::GFALSE; + if glib::gobject_ffi::g_object_is_floating(element as *mut glib::gobject_ffi::GObject) + != glib::ffi::GFALSE + { + return glib::ffi::GFALSE; } gst_panic_to_error!(&wrap, &instance.panicked(), false, { @@ -171,8 +173,8 @@ where } unsafe extern "C" fn bin_handle_message( - ptr: *mut gst_sys::GstBin, - message: *mut gst_sys::GstMessage, + ptr: *mut ffi::GstBin, + message: *mut ffi::GstMessage, ) where T::Instance: PanicPoison, { diff --git a/gstreamer/src/subclass/child_proxy.rs b/gstreamer/src/subclass/child_proxy.rs index 072fafa48..2d92d1c20 100644 --- a/gstreamer/src/subclass/child_proxy.rs +++ b/gstreamer/src/subclass/child_proxy.rs @@ -6,25 +6,18 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use glib_sys; -use gobject_sys; -use gst_sys; - -use glib; use glib::prelude::*; use glib::subclass::prelude::*; use glib::translate::*; -use libc; - -use ChildProxy; +use crate::ChildProxy; pub trait ChildProxyImpl: ObjectImpl + Send + Sync { fn get_child_by_name(&self, object: &Self::Type, name: &str) -> Option { unsafe { - let type_ = gst_sys::gst_child_proxy_get_type(); - let iface = gobject_sys::g_type_default_interface_ref(type_) - as *mut gst_sys::GstChildProxyInterface; + let type_ = ffi::gst_child_proxy_get_type(); + let iface = glib::gobject_ffi::g_type_default_interface_ref(type_) + as *mut ffi::GstChildProxyInterface; assert!(!iface.is_null()); let ret = ((*iface).get_child_by_name.as_ref().unwrap())( @@ -32,7 +25,7 @@ pub trait ChildProxyImpl: ObjectImpl + Send + Sync { name.to_glib_none().0, ); - gobject_sys::g_type_default_interface_unref(iface as glib_sys::gpointer); + glib::gobject_ffi::g_type_default_interface_unref(iface as glib::ffi::gpointer); from_glib_full(ret) } @@ -47,10 +40,10 @@ pub trait ChildProxyImpl: ObjectImpl + Send + Sync { unsafe impl IsImplementable for ChildProxy { unsafe extern "C" fn interface_init( - iface: glib_sys::gpointer, - _iface_data: glib_sys::gpointer, + iface: glib::ffi::gpointer, + _iface_data: glib::ffi::gpointer, ) { - let child_proxy_iface = &mut *(iface as *mut gst_sys::GstChildProxyInterface); + let child_proxy_iface = &mut *(iface as *mut ffi::GstChildProxyInterface); child_proxy_iface.get_child_by_name = Some(child_proxy_get_child_by_name::); child_proxy_iface.get_child_by_index = Some(child_proxy_get_child_by_index::); @@ -61,9 +54,9 @@ unsafe impl IsImplementable for ChildProxy { } unsafe extern "C" fn child_proxy_get_child_by_name( - child_proxy: *mut gst_sys::GstChildProxy, + child_proxy: *mut ffi::GstChildProxy, name: *const libc::c_char, -) -> *mut gobject_sys::GObject { +) -> *mut glib::gobject_ffi::GObject { let instance = &*(child_proxy as *mut T::Instance); let imp = instance.get_impl(); @@ -75,9 +68,9 @@ unsafe extern "C" fn child_proxy_get_child_by_name( } unsafe extern "C" fn child_proxy_get_child_by_index( - child_proxy: *mut gst_sys::GstChildProxy, + child_proxy: *mut ffi::GstChildProxy, index: u32, -) -> *mut gobject_sys::GObject { +) -> *mut glib::gobject_ffi::GObject { let instance = &*(child_proxy as *mut T::Instance); let imp = instance.get_impl(); @@ -89,7 +82,7 @@ unsafe extern "C" fn child_proxy_get_child_by_index( } unsafe extern "C" fn child_proxy_get_children_count( - child_proxy: *mut gst_sys::GstChildProxy, + child_proxy: *mut ffi::GstChildProxy, ) -> u32 { let instance = &*(child_proxy as *mut T::Instance); let imp = instance.get_impl(); @@ -98,8 +91,8 @@ unsafe extern "C" fn child_proxy_get_children_count( } unsafe extern "C" fn child_proxy_child_added( - child_proxy: *mut gst_sys::GstChildProxy, - child: *mut gobject_sys::GObject, + child_proxy: *mut ffi::GstChildProxy, + child: *mut glib::gobject_ffi::GObject, name: *const libc::c_char, ) { let instance = &*(child_proxy as *mut T::Instance); @@ -113,8 +106,8 @@ unsafe extern "C" fn child_proxy_child_added( } unsafe extern "C" fn child_proxy_child_removed( - child_proxy: *mut gst_sys::GstChildProxy, - child: *mut gobject_sys::GObject, + child_proxy: *mut ffi::GstChildProxy, + child: *mut glib::gobject_ffi::GObject, name: *const libc::c_char, ) { let instance = &*(child_proxy as *mut T::Instance); diff --git a/gstreamer/src/subclass/clock.rs b/gstreamer/src/subclass/clock.rs index d25e98649..85fd7d228 100644 --- a/gstreamer/src/subclass/clock.rs +++ b/gstreamer/src/subclass/clock.rs @@ -6,20 +6,17 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use gst_sys; - -use glib; use glib::prelude::*; use glib::subclass::prelude::*; use glib::translate::*; -use Clock; -use ClockError; -use ClockId; -use ClockReturn; -use ClockSuccess; -use ClockTime; -use ClockTimeDiff; +use crate::Clock; +use crate::ClockError; +use crate::ClockId; +use crate::ClockReturn; +use crate::ClockSuccess; +use crate::ClockTime; +use crate::ClockTimeDiff; pub trait ClockImpl: ClockImplExt + ObjectImpl + Send + Sync { fn change_resolution( @@ -97,7 +94,7 @@ impl ClockImplExt for T { ) -> ClockTime { unsafe { let data = T::type_data(); - let parent_class = data.as_ref().get_parent_class() as *mut gst_sys::GstClockClass; + let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstClockClass; if let Some(func) = (*parent_class).change_resolution { from_glib(func( @@ -114,7 +111,7 @@ impl ClockImplExt for T { fn parent_get_resolution(&self, clock: &Self::Type) -> ClockTime { unsafe { let data = T::type_data(); - let parent_class = data.as_ref().get_parent_class() as *mut gst_sys::GstClockClass; + let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstClockClass; from_glib( (*parent_class) @@ -128,7 +125,7 @@ impl ClockImplExt for T { fn parent_get_internal_time(&self, clock: &Self::Type) -> ClockTime { unsafe { let data = T::type_data(); - let parent_class = data.as_ref().get_parent_class() as *mut gst_sys::GstClockClass; + let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstClockClass; from_glib( (*parent_class) @@ -146,7 +143,7 @@ impl ClockImplExt for T { ) -> (Result, ClockTimeDiff) { unsafe { let data = T::type_data(); - let parent_class = data.as_ref().get_parent_class() as *mut gst_sys::GstClockClass; + let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstClockClass; let mut jitter = 0; ( @@ -156,11 +153,11 @@ impl ClockImplExt for T { .map(|f| { f( clock.unsafe_cast_ref::().to_glib_none().0, - id.to_glib_none().0 as *mut gst_sys::GstClockEntry, + id.to_glib_none().0 as *mut ffi::GstClockEntry, &mut jitter, ) }) - .unwrap_or(gst_sys::GST_CLOCK_UNSUPPORTED), + .unwrap_or(ffi::GST_CLOCK_UNSUPPORTED), ) .into_result(), jitter, @@ -175,17 +172,17 @@ impl ClockImplExt for T { ) -> Result { unsafe { let data = T::type_data(); - let parent_class = data.as_ref().get_parent_class() as *mut gst_sys::GstClockClass; + let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstClockClass; ClockReturn::from_glib( (*parent_class) .wait_async .map(|f| { f( clock.unsafe_cast_ref::().to_glib_none().0, - id.to_glib_none().0 as *mut gst_sys::GstClockEntry, + id.to_glib_none().0 as *mut ffi::GstClockEntry, ) }) - .unwrap_or(gst_sys::GST_CLOCK_UNSUPPORTED), + .unwrap_or(ffi::GST_CLOCK_UNSUPPORTED), ) .into_result() } @@ -194,11 +191,11 @@ impl ClockImplExt for T { fn parent_unschedule(&self, clock: &Self::Type, id: &ClockId) { unsafe { let data = T::type_data(); - let parent_class = data.as_ref().get_parent_class() as *mut gst_sys::GstClockClass; + let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstClockClass; if let Some(func) = (*parent_class).unschedule { func( clock.unsafe_cast_ref::().to_glib_none().0, - id.to_glib_none().0 as *mut gst_sys::GstClockEntry, + id.to_glib_none().0 as *mut ffi::GstClockEntry, ); } } @@ -211,28 +208,28 @@ impl ClockImplExt for T { { let clock = self.get_instance(); - cfg_if! { + cfg_if::cfg_if! { if #[cfg(feature = "v1_16")] { assert!(id.uses_clock(&clock)); } else { unsafe { - let ptr: *mut gst_sys::GstClockEntry = id.to_glib_none().0 as *mut _; + let ptr: *mut ffi::GstClockEntry = id.to_glib_none().0 as *mut _; assert_eq!((*ptr).clock, clock.as_ref().to_glib_none().0); } } } unsafe { - let ptr: *mut gst_sys::GstClockEntry = id.to_glib_none().0 as *mut _; + let ptr: *mut ffi::GstClockEntry = id.to_glib_none().0 as *mut _; if let Some(func) = (*ptr).func { func( clock.as_ref().to_glib_none().0, (*ptr).time, - ptr as gst_sys::GstClockID, + ptr as ffi::GstClockID, (*ptr).user_data, ); } - if (*ptr).type_ == gst_sys::GST_CLOCK_ENTRY_PERIODIC { + if (*ptr).type_ == ffi::GST_CLOCK_ENTRY_PERIODIC { (*ptr).time += (*ptr).interval; } } @@ -253,10 +250,10 @@ unsafe impl IsSubclassable for Clock { } unsafe extern "C" fn clock_change_resolution( - ptr: *mut gst_sys::GstClock, - old_resolution: gst_sys::GstClockTime, - new_resolution: gst_sys::GstClockTime, -) -> gst_sys::GstClockTime { + ptr: *mut ffi::GstClock, + old_resolution: ffi::GstClockTime, + new_resolution: ffi::GstClockTime, +) -> ffi::GstClockTime { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); @@ -270,8 +267,8 @@ unsafe extern "C" fn clock_change_resolution( } unsafe extern "C" fn clock_get_resolution( - ptr: *mut gst_sys::GstClock, -) -> gst_sys::GstClockTime { + ptr: *mut ffi::GstClock, +) -> ffi::GstClockTime { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); @@ -280,8 +277,8 @@ unsafe extern "C" fn clock_get_resolution( } unsafe extern "C" fn clock_get_internal_time( - ptr: *mut gst_sys::GstClock, -) -> gst_sys::GstClockTime { + ptr: *mut ffi::GstClock, +) -> ffi::GstClockTime { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); @@ -290,17 +287,17 @@ unsafe extern "C" fn clock_get_internal_time( } unsafe extern "C" fn clock_wait( - ptr: *mut gst_sys::GstClock, - id: *mut gst_sys::GstClockEntry, - jitter: *mut gst_sys::GstClockTimeDiff, -) -> gst_sys::GstClockReturn { + ptr: *mut ffi::GstClock, + id: *mut ffi::GstClockEntry, + jitter: *mut ffi::GstClockTimeDiff, +) -> ffi::GstClockReturn { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); let (res, j) = imp.wait( wrap.unsafe_cast_ref(), - &from_glib_borrow(id as gst_sys::GstClockID), + &from_glib_borrow(id as ffi::GstClockID), ); if !jitter.is_null() { *jitter = j; @@ -310,23 +307,23 @@ unsafe extern "C" fn clock_wait( } unsafe extern "C" fn clock_wait_async( - ptr: *mut gst_sys::GstClock, - id: *mut gst_sys::GstClockEntry, -) -> gst_sys::GstClockReturn { + ptr: *mut ffi::GstClock, + id: *mut ffi::GstClockEntry, +) -> ffi::GstClockReturn { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); ClockReturn::from(imp.wait_async( wrap.unsafe_cast_ref(), - &from_glib_borrow(id as gst_sys::GstClockID), + &from_glib_borrow(id as ffi::GstClockID), )) .to_glib() } unsafe extern "C" fn clock_unschedule( - ptr: *mut gst_sys::GstClock, - id: *mut gst_sys::GstClockEntry, + ptr: *mut ffi::GstClock, + id: *mut ffi::GstClockEntry, ) { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); @@ -334,6 +331,6 @@ unsafe extern "C" fn clock_unschedule( imp.unschedule( wrap.unsafe_cast_ref(), - &from_glib_borrow(id as gst_sys::GstClockID), + &from_glib_borrow(id as ffi::GstClockID), ); } diff --git a/gstreamer/src/subclass/device.rs b/gstreamer/src/subclass/device.rs index 25ba9c599..a880bc47d 100644 --- a/gstreamer/src/subclass/device.rs +++ b/gstreamer/src/subclass/device.rs @@ -6,16 +6,13 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use glib_sys; -use gst_sys; - use glib::prelude::*; use glib::subclass::prelude::*; use glib::translate::*; -use Device; -use Element; -use LoggableError; +use crate::Device; +use crate::Element; +use crate::LoggableError; use std::ptr; @@ -59,7 +56,7 @@ impl DeviceImplExt for T { ) -> Result { unsafe { let data = T::type_data(); - let parent_class = data.as_ref().get_parent_class() as *mut gst_sys::GstDeviceClass; + let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstDeviceClass; if let Some(f) = (*parent_class).create_element { let ptr = f( device.unsafe_cast_ref::().to_glib_none().0, @@ -69,13 +66,13 @@ impl DeviceImplExt for T { // Don't steal floating reference here but pass it further to the caller Option::<_>::from_glib_full(ptr).ok_or_else(|| { gst_loggable_error!( - ::CAT_RUST, + crate::CAT_RUST, "Failed to create element using the parent function" ) }) } else { Err(gst_loggable_error!( - ::CAT_RUST, + crate::CAT_RUST, "Parent function `create_element` is not defined" )) } @@ -89,10 +86,10 @@ impl DeviceImplExt for T { ) -> Result<(), LoggableError> { unsafe { let data = T::type_data(); - let parent_class = data.as_ref().get_parent_class() as *mut gst_sys::GstDeviceClass; + let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstDeviceClass; let f = (*parent_class).reconfigure_element.ok_or_else(|| { gst_loggable_error!( - ::CAT_RUST, + crate::CAT_RUST, "Parent function `reconfigure_element` is not defined" ) })?; @@ -101,7 +98,7 @@ impl DeviceImplExt for T { device.unsafe_cast_ref::().to_glib_none().0, element.to_glib_none().0 ), - ::CAT_RUST, + crate::CAT_RUST, "Failed to reconfigure the element using the parent function" ) } @@ -118,9 +115,9 @@ unsafe impl IsSubclassable for Device { } unsafe extern "C" fn device_create_element( - ptr: *mut gst_sys::GstDevice, + ptr: *mut ffi::GstDevice, name: *const libc::c_char, -) -> *mut gst_sys::GstElement { +) -> *mut ffi::GstElement { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); @@ -138,7 +135,9 @@ unsafe extern "C" fn device_create_element( let element_ptr = element.to_glib_full(); drop(element); // See https://gitlab.freedesktop.org/gstreamer/gstreamer/issues/444 - gobject_sys::g_object_force_floating(element_ptr as *mut gobject_sys::GObject); + glib::gobject_ffi::g_object_force_floating( + element_ptr as *mut glib::gobject_ffi::GObject, + ); element_ptr } Err(err) => { @@ -149,9 +148,9 @@ unsafe extern "C" fn device_create_element( } unsafe extern "C" fn device_reconfigure_element( - ptr: *mut gst_sys::GstDevice, - element: *mut gst_sys::GstElement, -) -> glib_sys::gboolean { + ptr: *mut ffi::GstDevice, + element: *mut ffi::GstElement, +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); diff --git a/gstreamer/src/subclass/device_provider.rs b/gstreamer/src/subclass/device_provider.rs index 9b2e86584..5f387c6ef 100644 --- a/gstreamer/src/subclass/device_provider.rs +++ b/gstreamer/src/subclass/device_provider.rs @@ -6,16 +6,13 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use glib_sys; -use gst_sys; - use glib::prelude::*; use glib::subclass::prelude::*; use glib::translate::*; -use Device; -use DeviceProvider; -use LoggableError; +use crate::Device; +use crate::DeviceProvider; +use crate::LoggableError; pub trait DeviceProviderImpl: DeviceProviderImplExt + ObjectImpl + Send + Sync { fn probe(&self, device_provider: &Self::Type) -> Vec { @@ -43,8 +40,7 @@ impl DeviceProviderImplExt for T { fn parent_probe(&self, device_provider: &Self::Type) -> Vec { unsafe { let data = T::type_data(); - let parent_class = - data.as_ref().get_parent_class() as *mut gst_sys::GstDeviceProviderClass; + let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstDeviceProviderClass; if let Some(f) = (*parent_class).probe { FromGlibPtrContainer::from_glib_full(f(device_provider .unsafe_cast_ref::() @@ -59,17 +55,16 @@ impl DeviceProviderImplExt for T { fn parent_start(&self, device_provider: &Self::Type) -> Result<(), LoggableError> { unsafe { let data = T::type_data(); - let parent_class = - data.as_ref().get_parent_class() as *mut gst_sys::GstDeviceProviderClass; + let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstDeviceProviderClass; let f = (*parent_class).start.ok_or_else(|| { - gst_loggable_error!(::CAT_RUST, "Parent function `start` is not defined") + gst_loggable_error!(crate::CAT_RUST, "Parent function `start` is not defined") })?; gst_result_from_gboolean!( f(device_provider .unsafe_cast_ref::() .to_glib_none() .0), - ::CAT_RUST, + crate::CAT_RUST, "Failed to start the device provider using the parent function" ) } @@ -78,8 +73,7 @@ impl DeviceProviderImplExt for T { fn parent_stop(&self, device_provider: &Self::Type) { unsafe { let data = T::type_data(); - let parent_class = - data.as_ref().get_parent_class() as *mut gst_sys::GstDeviceProviderClass; + let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstDeviceProviderClass; if let Some(f) = (*parent_class).stop { f(device_provider .unsafe_cast_ref::() @@ -99,8 +93,8 @@ pub unsafe trait DeviceProviderClassSubclassExt: Sized + 'static { author: &str, ) { unsafe { - gst_sys::gst_device_provider_class_set_metadata( - self as *mut Self as *mut gst_sys::GstDeviceProviderClass, + ffi::gst_device_provider_class_set_metadata( + self as *mut Self as *mut ffi::GstDeviceProviderClass, long_name.to_glib_none().0, classification.to_glib_none().0, description.to_glib_none().0, @@ -111,8 +105,8 @@ pub unsafe trait DeviceProviderClassSubclassExt: Sized + 'static { fn add_metadata(&mut self, key: &str, value: &str) { unsafe { - gst_sys::gst_device_provider_class_add_metadata( - self as *mut Self as *mut gst_sys::GstDeviceProviderClass, + ffi::gst_device_provider_class_add_metadata( + self as *mut Self as *mut ffi::GstDeviceProviderClass, key.to_glib_none().0, value.to_glib_none().0, ); @@ -133,8 +127,8 @@ unsafe impl IsSubclassable for DeviceProvider { } unsafe extern "C" fn device_provider_probe( - ptr: *mut gst_sys::GstDeviceProvider, -) -> *mut glib_sys::GList { + ptr: *mut ffi::GstDeviceProvider, +) -> *mut glib::ffi::GList { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); @@ -143,8 +137,8 @@ unsafe extern "C" fn device_provider_probe( } unsafe extern "C" fn device_provider_start( - ptr: *mut gst_sys::GstDeviceProvider, -) -> glib_sys::gboolean { + ptr: *mut ffi::GstDeviceProvider, +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); @@ -159,9 +153,7 @@ unsafe extern "C" fn device_provider_start( .to_glib() } -unsafe extern "C" fn device_provider_stop( - ptr: *mut gst_sys::GstDeviceProvider, -) { +unsafe extern "C" fn device_provider_stop(ptr: *mut ffi::GstDeviceProvider) { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); diff --git a/gstreamer/src/subclass/element.rs b/gstreamer/src/subclass/element.rs index 5ce19b3fb..020e510d2 100644 --- a/gstreamer/src/subclass/element.rs +++ b/gstreamer/src/subclass/element.rs @@ -6,26 +6,19 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use libc; - -use glib_sys; -use gst_sys; - use super::prelude::*; -use glib; -use glib::prelude::*; +use crate::prelude::*; use glib::subclass::prelude::*; use glib::translate::*; -use prelude::*; -use Element; -use Event; -use PadTemplate; -use QueryRef; -use StateChange; -use StateChangeError; -use StateChangeReturn; -use StateChangeSuccess; +use crate::Element; +use crate::Event; +use crate::PadTemplate; +use crate::QueryRef; +use crate::StateChange; +use crate::StateChangeError; +use crate::StateChangeReturn; +use crate::StateChangeSuccess; pub trait ElementImpl: ElementImplExt + ObjectImpl + Send + Sync { fn change_state( @@ -39,14 +32,14 @@ pub trait ElementImpl: ElementImplExt + ObjectImpl + Send + Sync { fn request_new_pad( &self, element: &Self::Type, - templ: &::PadTemplate, + templ: &crate::PadTemplate, name: Option, - caps: Option<&::Caps>, - ) -> Option<::Pad> { + caps: Option<&crate::Caps>, + ) -> Option { self.parent_request_new_pad(element, templ, name, caps) } - fn release_pad(&self, element: &Self::Type, pad: &::Pad) { + fn release_pad(&self, element: &Self::Type, pad: &crate::Pad) { self.parent_release_pad(element, pad) } @@ -58,19 +51,19 @@ pub trait ElementImpl: ElementImplExt + ObjectImpl + Send + Sync { self.parent_query(element, query) } - fn set_context(&self, element: &Self::Type, context: &::Context) { + fn set_context(&self, element: &Self::Type, context: &crate::Context) { self.parent_set_context(element, context) } - fn set_clock(&self, element: &Self::Type, clock: Option<&::Clock>) -> bool { + fn set_clock(&self, element: &Self::Type, clock: Option<&crate::Clock>) -> bool { self.parent_set_clock(element, clock) } - fn provide_clock(&self, element: &Self::Type) -> Option<::Clock> { + fn provide_clock(&self, element: &Self::Type) -> Option { self.parent_provide_clock(element) } - fn post_message(&self, element: &Self::Type, msg: ::Message) -> bool { + fn post_message(&self, element: &Self::Type, msg: crate::Message) -> bool { self.parent_post_message(element, msg) } } @@ -85,24 +78,24 @@ pub trait ElementImplExt: ObjectSubclass { fn parent_request_new_pad( &self, element: &Self::Type, - templ: &::PadTemplate, + templ: &crate::PadTemplate, name: Option, - caps: Option<&::Caps>, - ) -> Option<::Pad>; + caps: Option<&crate::Caps>, + ) -> Option; - fn parent_release_pad(&self, element: &Self::Type, pad: &::Pad); + fn parent_release_pad(&self, element: &Self::Type, pad: &crate::Pad); fn parent_send_event(&self, element: &Self::Type, event: Event) -> bool; fn parent_query(&self, element: &Self::Type, query: &mut QueryRef) -> bool; - fn parent_set_context(&self, element: &Self::Type, context: &::Context); + fn parent_set_context(&self, element: &Self::Type, context: &crate::Context); - fn parent_set_clock(&self, element: &Self::Type, clock: Option<&::Clock>) -> bool; + fn parent_set_clock(&self, element: &Self::Type, clock: Option<&crate::Clock>) -> bool; - fn parent_provide_clock(&self, element: &Self::Type) -> Option<::Clock>; + fn parent_provide_clock(&self, element: &Self::Type) -> Option; - fn parent_post_message(&self, element: &Self::Type, msg: ::Message) -> bool; + fn parent_post_message(&self, element: &Self::Type, msg: crate::Message) -> bool; fn catch_panic R, G: FnOnce() -> R, P: IsA>( &self, @@ -112,7 +105,7 @@ pub trait ElementImplExt: ObjectSubclass { ) -> R; fn catch_panic_pad_function R, G: FnOnce() -> R>( - parent: Option<&::Object>, + parent: Option<&crate::Object>, fallback: G, f: F, ) -> R; @@ -129,7 +122,7 @@ where ) -> Result { unsafe { let data = T::type_data(); - let parent_class = data.as_ref().get_parent_class() as *mut gst_sys::GstElementClass; + let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstElementClass; let f = (*parent_class) .change_state @@ -145,13 +138,13 @@ where fn parent_request_new_pad( &self, element: &Self::Type, - templ: &::PadTemplate, + templ: &crate::PadTemplate, name: Option, - caps: Option<&::Caps>, - ) -> Option<::Pad> { + caps: Option<&crate::Caps>, + ) -> Option { unsafe { let data = T::type_data(); - let parent_class = data.as_ref().get_parent_class() as *mut gst_sys::GstElementClass; + let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstElementClass; (*parent_class) .request_new_pad @@ -167,10 +160,10 @@ where } } - fn parent_release_pad(&self, element: &Self::Type, pad: &::Pad) { + fn parent_release_pad(&self, element: &Self::Type, pad: &crate::Pad) { unsafe { let data = T::type_data(); - let parent_class = data.as_ref().get_parent_class() as *mut gst_sys::GstElementClass; + let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstElementClass; (*parent_class) .release_pad @@ -187,7 +180,7 @@ where fn parent_send_event(&self, element: &Self::Type, event: Event) -> bool { unsafe { let data = T::type_data(); - let parent_class = data.as_ref().get_parent_class() as *mut gst_sys::GstElementClass; + let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstElementClass; (*parent_class) .send_event @@ -204,7 +197,7 @@ where fn parent_query(&self, element: &Self::Type, query: &mut QueryRef) -> bool { unsafe { let data = T::type_data(); - let parent_class = data.as_ref().get_parent_class() as *mut gst_sys::GstElementClass; + let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstElementClass; (*parent_class) .query @@ -218,10 +211,10 @@ where } } - fn parent_set_context(&self, element: &Self::Type, context: &::Context) { + fn parent_set_context(&self, element: &Self::Type, context: &crate::Context) { unsafe { let data = T::type_data(); - let parent_class = data.as_ref().get_parent_class() as *mut gst_sys::GstElementClass; + let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstElementClass; (*parent_class) .set_context @@ -235,10 +228,10 @@ where } } - fn parent_set_clock(&self, element: &Self::Type, clock: Option<&::Clock>) -> bool { + fn parent_set_clock(&self, element: &Self::Type, clock: Option<&crate::Clock>) -> bool { unsafe { let data = T::type_data(); - let parent_class = data.as_ref().get_parent_class() as *mut gst_sys::GstElementClass; + let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstElementClass; (*parent_class) .set_clock @@ -252,10 +245,10 @@ where } } - fn parent_provide_clock(&self, element: &Self::Type) -> Option<::Clock> { + fn parent_provide_clock(&self, element: &Self::Type) -> Option { unsafe { let data = T::type_data(); - let parent_class = data.as_ref().get_parent_class() as *mut gst_sys::GstElementClass; + let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstElementClass; (*parent_class) .provide_clock @@ -264,10 +257,10 @@ where } } - fn parent_post_message(&self, element: &Self::Type, msg: ::Message) -> bool { + fn parent_post_message(&self, element: &Self::Type, msg: crate::Message) -> bool { unsafe { let data = T::type_data(); - let parent_class = data.as_ref().get_parent_class() as *mut gst_sys::GstElementClass; + let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstElementClass; if let Some(f) = (*parent_class).post_message { from_glib(f( @@ -288,7 +281,7 @@ where ) -> R { unsafe { assert!(element.get_type().is_a(&T::get_type())); - let ptr: *mut gst_sys::GstElement = element.as_ptr() as *mut _; + let ptr: *mut ffi::GstElement = element.as_ptr() as *mut _; let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); @@ -297,14 +290,14 @@ where } fn catch_panic_pad_function R, G: FnOnce() -> R>( - parent: Option<&::Object>, + parent: Option<&crate::Object>, fallback: G, f: F, ) -> R { unsafe { let wrap = parent.as_ref().unwrap().downcast_ref::().unwrap(); assert!(wrap.get_type().is_a(&T::get_type())); - let ptr: *mut gst_sys::GstElement = wrap.to_glib_none().0; + let ptr: *mut ffi::GstElement = wrap.to_glib_none().0; let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); @@ -318,8 +311,8 @@ where pub unsafe trait ElementClassSubclassExt: Sized + 'static { fn add_pad_template(&mut self, pad_template: PadTemplate) { unsafe { - gst_sys::gst_element_class_add_pad_template( - self as *mut Self as *mut gst_sys::GstElementClass, + ffi::gst_element_class_add_pad_template( + self as *mut Self as *mut ffi::GstElementClass, pad_template.to_glib_none().0, ); } @@ -333,8 +326,8 @@ pub unsafe trait ElementClassSubclassExt: Sized + 'static { author: &str, ) { unsafe { - gst_sys::gst_element_class_set_metadata( - self as *mut Self as *mut gst_sys::GstElementClass, + ffi::gst_element_class_set_metadata( + self as *mut Self as *mut ffi::GstElementClass, long_name.to_glib_none().0, classification.to_glib_none().0, description.to_glib_none().0, @@ -345,8 +338,8 @@ pub unsafe trait ElementClassSubclassExt: Sized + 'static { fn add_metadata(&mut self, key: &str, value: &str) { unsafe { - gst_sys::gst_element_class_add_metadata( - self as *mut Self as *mut gst_sys::GstElementClass, + ffi::gst_element_class_add_metadata( + self as *mut Self as *mut ffi::GstElementClass, key.to_glib_none().0, value.to_glib_none().0, ); @@ -376,9 +369,9 @@ where } unsafe extern "C" fn element_change_state( - ptr: *mut gst_sys::GstElement, - transition: gst_sys::GstStateChange, -) -> gst_sys::GstStateChangeReturn + ptr: *mut ffi::GstElement, + transition: ffi::GstStateChange, +) -> ffi::GstStateChangeReturn where T::Instance: PanicPoison, { @@ -403,11 +396,11 @@ where } unsafe extern "C" fn element_request_new_pad( - ptr: *mut gst_sys::GstElement, - templ: *mut gst_sys::GstPadTemplate, + ptr: *mut ffi::GstElement, + templ: *mut ffi::GstPadTemplate, name: *const libc::c_char, - caps: *const gst_sys::GstCaps, -) -> *mut gst_sys::GstPad + caps: *const ffi::GstCaps, +) -> *mut ffi::GstPad where T::Instance: PanicPoison, { @@ -415,7 +408,7 @@ where let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - let caps = Option::<::Caps>::from_glib_borrow(caps); + let caps = Option::::from_glib_borrow(caps); // XXX: This is effectively unsafe but the best we can do // See https://bugzilla.gnome.org/show_bug.cgi?id=791193 @@ -432,7 +425,9 @@ where if let Some(ref pad) = pad { assert_eq!( pad.get_parent().as_ref(), - Some(&*::Object::from_glib_borrow(ptr as *mut gst_sys::GstObject)) + Some(&*crate::Object::from_glib_borrow( + ptr as *mut ffi::GstObject + )) ); } @@ -440,8 +435,8 @@ where } unsafe extern "C" fn element_release_pad( - ptr: *mut gst_sys::GstElement, - pad: *mut gst_sys::GstPad, + ptr: *mut ffi::GstElement, + pad: *mut ffi::GstPad, ) where T::Instance: PanicPoison, { @@ -451,7 +446,9 @@ unsafe extern "C" fn element_release_pad( // If we get a floating reference passed simply return here. It can't be stored inside this // element, and if we continued to use it we would take ownership of this floating reference. - if gobject_sys::g_object_is_floating(pad as *mut gobject_sys::GObject) != glib_sys::GFALSE { + if glib::gobject_ffi::g_object_is_floating(pad as *mut glib::gobject_ffi::GObject) + != glib::ffi::GFALSE + { return; } @@ -461,9 +458,9 @@ unsafe extern "C" fn element_release_pad( } unsafe extern "C" fn element_send_event( - ptr: *mut gst_sys::GstElement, - event: *mut gst_sys::GstEvent, -) -> glib_sys::gboolean + ptr: *mut ffi::GstElement, + event: *mut ffi::GstEvent, +) -> glib::ffi::gboolean where T::Instance: PanicPoison, { @@ -478,9 +475,9 @@ where } unsafe extern "C" fn element_query( - ptr: *mut gst_sys::GstElement, - query: *mut gst_sys::GstQuery, -) -> glib_sys::gboolean + ptr: *mut ffi::GstElement, + query: *mut ffi::GstQuery, +) -> glib::ffi::gboolean where T::Instance: PanicPoison, { @@ -496,8 +493,8 @@ where } unsafe extern "C" fn element_set_context( - ptr: *mut gst_sys::GstElement, - context: *mut gst_sys::GstContext, + ptr: *mut ffi::GstElement, + context: *mut ffi::GstContext, ) where T::Instance: PanicPoison, { @@ -511,9 +508,9 @@ unsafe extern "C" fn element_set_context( } unsafe extern "C" fn element_set_clock( - ptr: *mut gst_sys::GstElement, - clock: *mut gst_sys::GstClock, -) -> glib_sys::gboolean + ptr: *mut ffi::GstElement, + clock: *mut ffi::GstClock, +) -> glib::ffi::gboolean where T::Instance: PanicPoison, { @@ -521,7 +518,7 @@ where let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - let clock = Option::<::Clock>::from_glib_borrow(clock); + let clock = Option::::from_glib_borrow(clock); gst_panic_to_error!(&wrap, &instance.panicked(), false, { imp.set_clock(wrap.unsafe_cast_ref(), clock.as_ref().as_ref()) @@ -530,8 +527,8 @@ where } unsafe extern "C" fn element_provide_clock( - ptr: *mut gst_sys::GstElement, -) -> *mut gst_sys::GstClock + ptr: *mut ffi::GstElement, +) -> *mut ffi::GstClock where T::Instance: PanicPoison, { @@ -546,9 +543,9 @@ where } unsafe extern "C" fn element_post_message( - ptr: *mut gst_sys::GstElement, - msg: *mut gst_sys::GstMessage, -) -> glib_sys::gboolean + ptr: *mut ffi::GstElement, + msg: *mut ffi::GstMessage, +) -> glib::ffi::gboolean where T::Instance: PanicPoison, { @@ -565,18 +562,17 @@ where #[cfg(test)] mod tests { use super::*; - use glib; use glib::subclass; use std::sync::atomic; - use ElementFactory; + use crate::ElementFactory; pub mod imp { use super::*; pub struct TestElement { - pub(super) srcpad: ::Pad, - pub(super) sinkpad: ::Pad, + pub(super) srcpad: crate::Pad, + pub(super) sinkpad: crate::Pad, pub(super) n_buffers: atomic::AtomicU32, pub(super) reached_playing: atomic::AtomicBool, } @@ -584,46 +580,46 @@ mod tests { impl TestElement { fn sink_chain( &self, - _pad: &::Pad, + _pad: &crate::Pad, _element: &super::TestElement, - buffer: ::Buffer, - ) -> Result<::FlowSuccess, ::FlowError> { + buffer: crate::Buffer, + ) -> Result { self.n_buffers.fetch_add(1, atomic::Ordering::SeqCst); self.srcpad.push(buffer) } fn sink_event( &self, - _pad: &::Pad, + _pad: &crate::Pad, _element: &super::TestElement, - event: ::Event, + event: crate::Event, ) -> bool { self.srcpad.push_event(event) } fn sink_query( &self, - _pad: &::Pad, + _pad: &crate::Pad, _element: &super::TestElement, - query: &mut ::QueryRef, + query: &mut crate::QueryRef, ) -> bool { self.srcpad.peer_query(query) } fn src_event( &self, - _pad: &::Pad, + _pad: &crate::Pad, _element: &super::TestElement, - event: ::Event, + event: crate::Event, ) -> bool { self.sinkpad.push_event(event) } fn src_query( &self, - _pad: &::Pad, + _pad: &crate::Pad, _element: &super::TestElement, - query: &mut ::QueryRef, + query: &mut crate::QueryRef, ) -> bool { self.sinkpad.peer_query(query) } @@ -633,18 +629,18 @@ mod tests { const NAME: &'static str = "TestElement"; type Type = super::TestElement; type ParentType = Element; - type Instance = ::subclass::ElementInstanceStruct; + type Instance = crate::subclass::ElementInstanceStruct; type Class = subclass::simple::ClassStruct; - glib_object_subclass!(); + glib::glib_object_subclass!(); fn with_class(klass: &Self::Class) -> Self { let templ = klass.get_pad_template("sink").unwrap(); - let sinkpad = ::Pad::builder_with_template(&templ, Some("sink")) + let sinkpad = crate::Pad::builder_with_template(&templ, Some("sink")) .chain_function(|pad, parent, buffer| { TestElement::catch_panic_pad_function( parent, - || Err(::FlowError::Error), + || Err(crate::FlowError::Error), |identity, element| identity.sink_chain(pad, element, buffer), ) }) @@ -665,7 +661,7 @@ mod tests { .build(); let templ = klass.get_pad_template("src").unwrap(); - let srcpad = ::Pad::builder_with_template(&templ, Some("src")) + let srcpad = crate::Pad::builder_with_template(&templ, Some("src")) .event_function(|pad, parent, event| { TestElement::catch_panic_pad_function( parent, @@ -698,15 +694,23 @@ mod tests { "Sebastian Dröge ", ); - let caps = ::Caps::new_any(); - let src_pad_template = - ::PadTemplate::new("src", ::PadDirection::Src, ::PadPresence::Always, &caps) - .unwrap(); + let caps = crate::Caps::new_any(); + let src_pad_template = crate::PadTemplate::new( + "src", + crate::PadDirection::Src, + crate::PadPresence::Always, + &caps, + ) + .unwrap(); klass.add_pad_template(src_pad_template); - let sink_pad_template = - ::PadTemplate::new("sink", ::PadDirection::Sink, ::PadPresence::Always, &caps) - .unwrap(); + let sink_pad_template = crate::PadTemplate::new( + "sink", + crate::PadDirection::Sink, + crate::PadPresence::Always, + &caps, + ) + .unwrap(); klass.add_pad_template(sink_pad_template); } } @@ -724,11 +728,11 @@ mod tests { fn change_state( &self, element: &Self::Type, - transition: ::StateChange, - ) -> Result<::StateChangeSuccess, ::StateChangeError> { + transition: crate::StateChange, + ) -> Result { let res = self.parent_change_state(element, transition)?; - if transition == ::StateChange::PausedToPlaying { + if transition == crate::StateChange::PausedToPlaying { self.reached_playing.store(true, atomic::Ordering::SeqCst); } @@ -737,8 +741,8 @@ mod tests { } } - glib_wrapper! { - pub struct TestElement(ObjectSubclass) @extends Element, ::Object; + glib::glib_wrapper! { + pub struct TestElement(ObjectSubclass) @extends Element, crate::Object; } unsafe impl Send for TestElement {} @@ -755,18 +759,18 @@ mod tests { #[test] fn test_element_subclass() { - ::init().unwrap(); + crate::init().unwrap(); let element = TestElement::new(Some("test")); assert_eq!(element.get_name(), "test"); assert_eq!( - element.get_metadata(&::ELEMENT_METADATA_LONGNAME), + element.get_metadata(&crate::ELEMENT_METADATA_LONGNAME), Some("Test Element") ); - let pipeline = ::Pipeline::new(None); + let pipeline = crate::Pipeline::new(None); let src = ElementFactory::make("fakesrc", None).unwrap(); let sink = ElementFactory::make("fakesink", None).unwrap(); @@ -777,13 +781,13 @@ mod tests { .unwrap(); Element::link_many(&[&src, &element.upcast_ref(), &sink]).unwrap(); - pipeline.set_state(::State::Playing).unwrap(); + pipeline.set_state(crate::State::Playing).unwrap(); let bus = pipeline.get_bus().unwrap(); - let eos = bus.timed_pop_filtered(::CLOCK_TIME_NONE, &[::MessageType::Eos]); + let eos = bus.timed_pop_filtered(crate::CLOCK_TIME_NONE, &[crate::MessageType::Eos]); assert!(eos.is_some()); - pipeline.set_state(::State::Null).unwrap(); + pipeline.set_state(crate::State::Null).unwrap(); let imp = imp::TestElement::from_instance(&element); assert_eq!(imp.n_buffers.load(atomic::Ordering::SeqCst), 100); diff --git a/gstreamer/src/subclass/error.rs b/gstreamer/src/subclass/error.rs index 6b17c6057..05a65b10b 100644 --- a/gstreamer/src/subclass/error.rs +++ b/gstreamer/src/subclass/error.rs @@ -8,8 +8,8 @@ use thiserror::Error; -use ErrorMessage; -use FlowReturn; +use crate::ErrorMessage; +use crate::FlowReturn; #[macro_export] macro_rules! gst_panic_to_error( diff --git a/gstreamer/src/subclass/ghost_pad.rs b/gstreamer/src/subclass/ghost_pad.rs index 1f9dcb26a..ab1216ba3 100644 --- a/gstreamer/src/subclass/ghost_pad.rs +++ b/gstreamer/src/subclass/ghost_pad.rs @@ -9,13 +9,13 @@ use super::prelude::*; use glib::subclass::prelude::*; -use GhostPad; +use crate::GhostPad; pub trait GhostPadImpl: PadImpl {} unsafe impl IsSubclassable for GhostPad { fn override_vfuncs(klass: &mut glib::Class) { - <::Pad as IsSubclassable>::override_vfuncs(klass); + >::override_vfuncs(klass); let _klass = klass.as_mut(); // Nothing to do here } diff --git a/gstreamer/src/subclass/mod.rs b/gstreamer/src/subclass/mod.rs index f7e3a131b..c30aad6aa 100644 --- a/gstreamer/src/subclass/mod.rs +++ b/gstreamer/src/subclass/mod.rs @@ -62,7 +62,6 @@ pub mod prelude { } use self::prelude::*; -use glib; use std::sync::atomic::AtomicBool; #[repr(C)] diff --git a/gstreamer/src/subclass/pad.rs b/gstreamer/src/subclass/pad.rs index 133659407..d5c85acaf 100644 --- a/gstreamer/src/subclass/pad.rs +++ b/gstreamer/src/subclass/pad.rs @@ -6,14 +6,11 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use gst_sys; - -use glib; use glib::prelude::*; use glib::subclass::prelude::*; use glib::translate::*; -use Pad; +use crate::Pad; pub trait PadImpl: PadImplExt + ObjectImpl + Send + Sync { fn linked(&self, pad: &Self::Type, peer: &Pad) { @@ -35,7 +32,7 @@ impl PadImplExt for T { fn parent_linked(&self, pad: &Self::Type, peer: &Pad) { unsafe { let data = T::type_data(); - let parent_class = data.as_ref().get_parent_class() as *mut gst_sys::GstPadClass; + let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstPadClass; (*parent_class) .linked @@ -52,7 +49,7 @@ impl PadImplExt for T { fn parent_unlinked(&self, pad: &Self::Type, peer: &Pad) { unsafe { let data = T::type_data(); - let parent_class = data.as_ref().get_parent_class() as *mut gst_sys::GstPadClass; + let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstPadClass; (*parent_class) .unlinked @@ -76,7 +73,7 @@ unsafe impl IsSubclassable for Pad { } } -unsafe extern "C" fn pad_linked(ptr: *mut gst_sys::GstPad, peer: *mut gst_sys::GstPad) { +unsafe extern "C" fn pad_linked(ptr: *mut ffi::GstPad, peer: *mut ffi::GstPad) { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); @@ -84,10 +81,7 @@ unsafe extern "C" fn pad_linked(ptr: *mut gst_sys::GstPad, peer: *mu imp.linked(wrap.unsafe_cast_ref(), &from_glib_borrow(peer)) } -unsafe extern "C" fn pad_unlinked( - ptr: *mut gst_sys::GstPad, - peer: *mut gst_sys::GstPad, -) { +unsafe extern "C" fn pad_unlinked(ptr: *mut ffi::GstPad, peer: *mut ffi::GstPad) { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); @@ -99,11 +93,10 @@ unsafe extern "C" fn pad_unlinked( mod tests { use super::*; use crate::prelude::*; - use glib; use glib::subclass; use std::sync::atomic; - use PadDirection; + use crate::PadDirection; pub mod imp { use super::*; @@ -120,7 +113,7 @@ mod tests { type Instance = subclass::simple::InstanceStruct; type Class = subclass::simple::ClassStruct; - glib_object_subclass!(); + glib::glib_object_subclass!(); fn new() -> Self { Self { @@ -145,8 +138,8 @@ mod tests { } } - glib_wrapper! { - pub struct TestPad(ObjectSubclass) @extends Pad, ::Object; + glib::glib_wrapper! { + pub struct TestPad(ObjectSubclass) @extends Pad, crate::Object; } unsafe impl Send for TestPad {} @@ -166,7 +159,7 @@ mod tests { #[test] fn test_pad_subclass() { - ::init().unwrap(); + crate::init().unwrap(); let pad = TestPad::new("test", PadDirection::Src); diff --git a/gstreamer/src/subclass/pipeline.rs b/gstreamer/src/subclass/pipeline.rs index 348c9042b..e30701e58 100644 --- a/gstreamer/src/subclass/pipeline.rs +++ b/gstreamer/src/subclass/pipeline.rs @@ -9,7 +9,7 @@ use super::prelude::*; use glib::subclass::prelude::*; -use Pipeline; +use crate::Pipeline; pub trait PipelineImpl: BinImpl {} @@ -18,7 +18,7 @@ where ::Instance: PanicPoison, { fn override_vfuncs(klass: &mut glib::Class) { - <::Bin as IsSubclassable>::override_vfuncs(klass); + >::override_vfuncs(klass); let _klass = klass.as_mut(); // Nothing to do here } diff --git a/gstreamer/src/subclass/plugin_1_12.rs b/gstreamer/src/subclass/plugin_1_12.rs index 5e9c9a9c5..c79be8401 100644 --- a/gstreamer/src/subclass/plugin_1_12.rs +++ b/gstreamer/src/subclass/plugin_1_12.rs @@ -24,13 +24,13 @@ macro_rules! gst_plugin_define( use $crate::glib::translate::{from_glib_borrow, ToGlib, from_glib}; #[repr(transparent)] - pub struct GstPluginDesc($crate::gst_sys::GstPluginDesc); + pub struct GstPluginDesc($crate::ffi::GstPluginDesc); unsafe impl Send for GstPluginDesc {} unsafe impl Sync for GstPluginDesc {} #[no_mangle] #[allow(non_upper_case_globals)] - pub static gst_plugin_desc: GstPluginDesc = GstPluginDesc($crate::gst_sys::GstPluginDesc { + pub static gst_plugin_desc: GstPluginDesc = GstPluginDesc($crate::ffi::GstPluginDesc { major_version: $crate::subclass::MAJOR_VERSION, minor_version: $crate::subclass::MINOR_VERSION, name: concat!(stringify!($name), "\0") as *const str as *const _, @@ -42,13 +42,13 @@ macro_rules! gst_plugin_define( package: concat!($package, "\0") as *const str as *const _, origin: concat!($origin, "\0") as *const str as *const _, release_datetime: concat!($release_datetime, "\0") as *const str as *const _, - _gst_reserved: [0 as $crate::glib_sys::gpointer; 4], + _gst_reserved: [0 as $crate::glib::ffi::gpointer; 4], }); pub fn plugin_register_static() -> Result<(), $crate::glib::BoolError> { unsafe { $crate::glib::glib_result_from_gboolean!( - $crate::gst_sys::gst_plugin_register_static( + $crate::ffi::gst_plugin_register_static( $crate::subclass::MAJOR_VERSION, $crate::subclass::MINOR_VERSION, concat!(stringify!($name), "\0") as *const str as *const _, @@ -66,17 +66,17 @@ macro_rules! gst_plugin_define( } #[allow(clippy::missing_safety_doc)] - unsafe extern "C" fn plugin_init_trampoline(plugin: *mut $crate::gst_sys::GstPlugin) -> $crate::glib_sys::gboolean { + unsafe extern "C" fn plugin_init_trampoline(plugin: *mut $crate::ffi::GstPlugin) -> $crate::glib::ffi::gboolean { use std::panic::{self, AssertUnwindSafe}; let panic_result = panic::catch_unwind(AssertUnwindSafe(|| super::$plugin_init(&from_glib_borrow(plugin)))); match panic_result { Ok(register_result) => match register_result { - Ok(_) => $crate::glib_sys::GTRUE, + Ok(_) => $crate::glib::ffi::GTRUE, Err(err) => { let cat = $crate::DebugCategory::get("GST_PLUGIN_LOADING").unwrap(); $crate::gst_error!(cat, "Failed to register plugin: {}", err); - $crate::glib_sys::GFALSE + $crate::glib::ffi::GFALSE } } Err(err) => { @@ -89,7 +89,7 @@ macro_rules! gst_plugin_define( $crate::gst_error!(cat, "Failed to initialize plugin due to panic"); } - $crate::glib_sys::GFALSE + $crate::glib::ffi::GFALSE } } } diff --git a/gstreamer/src/subclass/plugin_1_14.rs b/gstreamer/src/subclass/plugin_1_14.rs index e0967b931..3e6d94071 100644 --- a/gstreamer/src/subclass/plugin_1_14.rs +++ b/gstreamer/src/subclass/plugin_1_14.rs @@ -24,11 +24,11 @@ macro_rules! gst_plugin_define( use $crate::glib::translate::{from_glib_borrow, ToGlib, from_glib}; #[repr(transparent)] - pub struct GstPluginDesc($crate::gst_sys::GstPluginDesc); + pub struct GstPluginDesc($crate::ffi::GstPluginDesc); unsafe impl Send for GstPluginDesc {} unsafe impl Sync for GstPluginDesc {} - static GST_PLUGIN_DESC: GstPluginDesc = GstPluginDesc($crate::gst_sys::GstPluginDesc { + static GST_PLUGIN_DESC: GstPluginDesc = GstPluginDesc($crate::ffi::GstPluginDesc { major_version: $crate::subclass::MAJOR_VERSION, minor_version: $crate::subclass::MINOR_VERSION, name: concat!(stringify!($name), "\0") as *const str as *const _, @@ -40,13 +40,13 @@ macro_rules! gst_plugin_define( package: concat!($package, "\0") as *const str as *const _, origin: concat!($origin, "\0") as *const str as *const _, release_datetime: concat!($release_datetime, "\0") as *const str as *const _, - _gst_reserved: [0 as $crate::glib_sys::gpointer; 4], + _gst_reserved: [0 as $crate::glib::ffi::gpointer; 4], }); pub fn plugin_register_static() -> Result<(), $crate::glib::BoolError> { unsafe { $crate::glib::glib_result_from_gboolean!( - $crate::gst_sys::gst_plugin_register_static( + $crate::ffi::gst_plugin_register_static( $crate::subclass::MAJOR_VERSION, $crate::subclass::MINOR_VERSION, concat!(stringify!($name), "\0") as *const str as *const _, @@ -72,23 +72,23 @@ macro_rules! gst_plugin_define( #[no_mangle] #[allow(clippy::missing_safety_doc)] - pub unsafe extern "C" fn [] () -> *const $crate::gst_sys::GstPluginDesc { + pub unsafe extern "C" fn [] () -> *const $crate::ffi::GstPluginDesc { &GST_PLUGIN_DESC.0 } } #[allow(clippy::missing_safety_doc)] - unsafe extern "C" fn plugin_init_trampoline(plugin: *mut $crate::gst_sys::GstPlugin) -> $crate::glib_sys::gboolean { + unsafe extern "C" fn plugin_init_trampoline(plugin: *mut $crate::ffi::GstPlugin) -> $crate::glib::ffi::gboolean { use std::panic::{self, AssertUnwindSafe}; let panic_result = panic::catch_unwind(AssertUnwindSafe(|| super::$plugin_init(&from_glib_borrow(plugin)))); match panic_result { Ok(register_result) => match register_result { - Ok(_) => $crate::glib_sys::GTRUE, + Ok(_) => $crate::glib::ffi::GTRUE, Err(err) => { let cat = $crate::DebugCategory::get("GST_PLUGIN_LOADING").unwrap(); $crate::gst_error!(cat, "Failed to register plugin: {}", err); - $crate::glib_sys::GFALSE + $crate::glib::ffi::GFALSE } } Err(err) => { @@ -101,7 +101,7 @@ macro_rules! gst_plugin_define( $crate::gst_error!(cat, "Failed to initialize plugin due to panic"); } - $crate::glib_sys::GFALSE + $crate::glib::ffi::GFALSE } } } diff --git a/gstreamer/src/subclass/preset.rs b/gstreamer/src/subclass/preset.rs index ee3a54bf5..0902578df 100644 --- a/gstreamer/src/subclass/preset.rs +++ b/gstreamer/src/subclass/preset.rs @@ -6,18 +6,16 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use glib_sys; - use glib::subclass::prelude::*; -use Preset; +use crate::Preset; pub trait PresetImpl: super::element::ElementImpl {} unsafe impl IsImplementable for Preset { unsafe extern "C" fn interface_init( - _iface: glib_sys::gpointer, - _iface_data: glib_sys::gpointer, + _iface: glib::ffi::gpointer, + _iface_data: glib::ffi::gpointer, ) { } } diff --git a/gstreamer/src/subclass/system_clock.rs b/gstreamer/src/subclass/system_clock.rs index 44e404e3f..67bf6a0c4 100644 --- a/gstreamer/src/subclass/system_clock.rs +++ b/gstreamer/src/subclass/system_clock.rs @@ -9,13 +9,13 @@ use super::prelude::*; use glib::subclass::prelude::*; -use SystemClock; +use crate::SystemClock; pub trait SystemClockImpl: ClockImpl {} unsafe impl IsSubclassable for SystemClock { fn override_vfuncs(klass: &mut glib::Class) { - <::Clock as IsSubclassable>::override_vfuncs(klass); + >::override_vfuncs(klass); let _klass = klass.as_mut(); // Nothing to do here } diff --git a/gstreamer/src/subclass/tag_setter.rs b/gstreamer/src/subclass/tag_setter.rs index 8f8cb0757..c2ed18fb2 100644 --- a/gstreamer/src/subclass/tag_setter.rs +++ b/gstreamer/src/subclass/tag_setter.rs @@ -6,18 +6,16 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use glib_sys; - use glib::subclass::prelude::*; -use TagSetter; +use crate::TagSetter; pub trait TagSetterImpl: super::element::ElementImpl {} unsafe impl IsImplementable for TagSetter { unsafe extern "C" fn interface_init( - _iface: glib_sys::gpointer, - _iface_data: glib_sys::gpointer, + _iface: glib::ffi::gpointer, + _iface_data: glib::ffi::gpointer, ) { } } diff --git a/gstreamer/src/subclass/uri_handler.rs b/gstreamer/src/subclass/uri_handler.rs index 27620e9a3..6dc3eae39 100644 --- a/gstreamer/src/subclass/uri_handler.rs +++ b/gstreamer/src/subclass/uri_handler.rs @@ -6,19 +6,13 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use glib_sys; -use gst_sys; - -use glib; use glib::prelude::*; use glib::translate::*; use glib::subclass::prelude::*; -use libc; - -use URIHandler; -use URIType; +use crate::URIHandler; +use crate::URIType; pub trait URIHandlerImpl: super::element::ElementImpl { fn get_uri(&self, element: &Self::Type) -> Option; @@ -29,10 +23,10 @@ pub trait URIHandlerImpl: super::element::ElementImpl { unsafe impl IsImplementable for URIHandler { unsafe extern "C" fn interface_init( - iface: glib_sys::gpointer, - _iface_data: glib_sys::gpointer, + iface: glib::ffi::gpointer, + _iface_data: glib::ffi::gpointer, ) { - let uri_handler_iface = &mut *(iface as *mut gst_sys::GstURIHandlerInterface); + let uri_handler_iface = &mut *(iface as *mut ffi::GstURIHandlerInterface); // Store the protocols in the interface data for later use let mut data = T::type_data(); @@ -42,7 +36,7 @@ unsafe impl IsImplementable for URIHandler { if data.interface_data.is_null() { data.interface_data = Box::into_raw(Box::new(Vec::new())); } - (*(data.interface_data as *mut Vec<(glib_sys::GType, glib_sys::gpointer)>)) + (*(data.interface_data as *mut Vec<(glib::ffi::GType, glib::ffi::gpointer)>)) .push((URIHandler::static_type().to_glib(), protocols as *mut _)); uri_handler_iface.get_type = Some(uri_handler_get_type::); @@ -53,13 +47,13 @@ unsafe impl IsImplementable for URIHandler { } unsafe extern "C" fn uri_handler_get_type( - _type_: glib_sys::GType, -) -> gst_sys::GstURIType { + _type_: glib::ffi::GType, +) -> ffi::GstURIType { ::get_uri_type().to_glib() } unsafe extern "C" fn uri_handler_get_protocols( - _type_: glib_sys::GType, + _type_: glib::ffi::GType, ) -> *const *const libc::c_char { let data = ::type_data(); data.as_ref() @@ -67,7 +61,7 @@ unsafe extern "C" fn uri_handler_get_protocols( } unsafe extern "C" fn uri_handler_get_uri( - uri_handler: *mut gst_sys::GstURIHandler, + uri_handler: *mut ffi::GstURIHandler, ) -> *mut libc::c_char { let instance = &*(uri_handler as *mut T::Instance); let imp = instance.get_impl(); @@ -77,10 +71,10 @@ unsafe extern "C" fn uri_handler_get_uri( } unsafe extern "C" fn uri_handler_set_uri( - uri_handler: *mut gst_sys::GstURIHandler, + uri_handler: *mut ffi::GstURIHandler, uri: *const libc::c_char, - err: *mut *mut glib_sys::GError, -) -> glib_sys::gboolean { + err: *mut *mut glib::ffi::GError, +) -> glib::ffi::gboolean { let instance = &*(uri_handler as *mut T::Instance); let imp = instance.get_impl(); diff --git a/gstreamer/src/tag_setter.rs b/gstreamer/src/tag_setter.rs index 1713ee882..cf2abb1fc 100644 --- a/gstreamer/src/tag_setter.rs +++ b/gstreamer/src/tag_setter.rs @@ -6,13 +6,12 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use crate::tags::*; +use crate::TagMergeMode; +use crate::TagSetter; use glib::object::IsA; use glib::translate::*; use glib::value::ToSendValue; -use gst_sys; -use tags::*; -use TagMergeMode; -use TagSetter; pub trait TagSetterExtManual: 'static { fn add<'a, T: Tag<'a>>(&self, value: T::TagType, mode: TagMergeMode) @@ -28,7 +27,7 @@ impl> TagSetterExtManual for O { unsafe { let v = value.to_send_value(); - gst_sys::gst_tag_setter_add_tag_value( + ffi::gst_tag_setter_add_tag_value( self.as_ref().to_glib_none().0, mode.to_glib(), T::tag_name().to_glib_none().0, diff --git a/gstreamer/src/tags.rs b/gstreamer/src/tags.rs index 2e6131cf0..b64e576b7 100644 --- a/gstreamer/src/tags.rs +++ b/gstreamer/src/tags.rs @@ -13,19 +13,16 @@ use std::mem; use once_cell::sync::Lazy; -use glib; use glib::translate::{ from_glib, from_glib_full, FromGlibPtrFull, ToGlib, ToGlibPtr, ToGlibPtrMut, }; use glib::value::{FromValueOptional, SendValue, SetValue, ToSendValue, TypedValue, Value}; use glib::StaticType; -use gobject_sys; -use gst_sys; -use Sample; -use TagError; -use TagMergeMode; -use TagScope; +use crate::Sample; +use crate::TagError; +use crate::TagMergeMode; +use crate::TagScope; pub trait Tag<'a> { type TagType: FromValueOptional<'a> + SetValue + Send; @@ -43,7 +40,7 @@ macro_rules! impl_tag( } pub(crate) static $rust_tag: Lazy<&'static str> = Lazy::new(|| - unsafe { CStr::from_ptr(gst_sys::$gst_tag).to_str().unwrap() }); + unsafe { CStr::from_ptr(ffi::$gst_tag).to_str().unwrap() }); }; ); @@ -76,7 +73,12 @@ impl_tag!( GST_TAG_ALBUM_ARTIST_SORTNAME ); impl_tag!(Date, glib::Date, TAG_DATE, GST_TAG_DATE); -impl_tag!(DateTime, ::auto::DateTime, TAG_DATE_TIME, GST_TAG_DATE_TIME); +impl_tag!( + DateTime, + crate::auto::DateTime, + TAG_DATE_TIME, + GST_TAG_DATE_TIME +); impl_tag!(Genre, &'a str, TAG_GENRE, GST_TAG_GENRE); impl_tag!(Comment, &'a str, TAG_COMMENT, GST_TAG_COMMENT); impl_tag!( @@ -124,7 +126,7 @@ impl_tag!(Contact, &'a str, TAG_CONTACT, GST_TAG_CONTACT); impl_tag!(License, &'a str, TAG_LICENSE, GST_TAG_LICENSE); impl_tag!(LicenseUri, &'a str, TAG_LICENSE_URI, GST_TAG_LICENSE_URI); impl_tag!(Performer, &'a str, TAG_PERFORMER, GST_TAG_PERFORMER); -impl_tag!(Duration, ::ClockTime, TAG_DURATION, GST_TAG_DURATION); +impl_tag!(Duration, crate::ClockTime, TAG_DURATION, GST_TAG_DURATION); impl_tag!(Codec, &'a str, TAG_CODEC, GST_TAG_CODEC); impl_tag!(VideoCodec, &'a str, TAG_VIDEO_CODEC, GST_TAG_VIDEO_CODEC); impl_tag!(AudioCodec, &'a str, TAG_AUDIO_CODEC, GST_TAG_AUDIO_CODEC); @@ -339,14 +341,14 @@ impl_tag!( ); impl_tag!(PrivateData, Sample, TAG_PRIVATE_DATA, GST_TAG_PRIVATE_DATA); -gst_define_mini_object_wrapper!(TagList, TagListRef, gst_sys::GstTagList, || { - gst_sys::gst_tag_list_get_type() +gst_define_mini_object_wrapper!(TagList, TagListRef, ffi::GstTagList, || { + ffi::gst_tag_list_get_type() }); impl TagList { pub fn new() -> Self { assert_initialized_main_thread!(); - unsafe { from_glib_full(gst_sys::gst_tag_list_new_empty()) } + unsafe { from_glib_full(ffi::gst_tag_list_new_empty()) } } } @@ -387,12 +389,12 @@ impl TagListRef { unsafe { let tag_name = tag_name.to_glib_none(); - let tag_type: glib::Type = from_glib(gst_sys::gst_tag_get_type(tag_name.0)); + let tag_type: glib::Type = from_glib(ffi::gst_tag_get_type(tag_name.0)); if tag_type != value.type_() { return Err(TagError::TypeMismatch); } - gst_sys::gst_tag_list_add_value( + ffi::gst_tag_list_add_value( self.as_mut_ptr(), mode.to_glib(), tag_name.0, @@ -415,7 +417,7 @@ impl TagListRef { unsafe { let mut value: mem::MaybeUninit = mem::MaybeUninit::zeroed(); - let found: bool = from_glib(gst_sys::gst_tag_list_copy_value( + let found: bool = from_glib(ffi::gst_tag_list_copy_value( (*value.as_mut_ptr()).to_glib_none_mut().0, self.as_ptr(), tag_name.to_glib_none().0, @@ -430,12 +432,12 @@ impl TagListRef { } pub fn n_tags(&self) -> i32 { - unsafe { gst_sys::gst_tag_list_n_tags(self.as_ptr()) } + unsafe { ffi::gst_tag_list_n_tags(self.as_ptr()) } } pub fn nth_tag_name(&self, idx: u32) -> &str { unsafe { - CStr::from_ptr(gst_sys::gst_tag_list_nth_tag_name(self.as_ptr(), idx)) + CStr::from_ptr(ffi::gst_tag_list_nth_tag_name(self.as_ptr(), idx)) .to_str() .unwrap() } @@ -448,11 +450,8 @@ impl TagListRef { pub fn get_index_generic<'a>(&'a self, tag_name: &str, idx: u32) -> Option<&'a SendValue> { unsafe { - let value = gst_sys::gst_tag_list_get_value_index( - self.as_ptr(), - tag_name.to_glib_none().0, - idx, - ); + let value = + ffi::gst_tag_list_get_value_index(self.as_ptr(), tag_name.to_glib_none().0, idx); if value.is_null() { return None; @@ -467,7 +466,7 @@ impl TagListRef { } pub fn get_size_by_name(&self, tag_name: &str) -> u32 { - unsafe { gst_sys::gst_tag_list_get_tag_size(self.as_ptr(), tag_name.to_glib_none().0) } + unsafe { ffi::gst_tag_list_get_tag_size(self.as_ptr(), tag_name.to_glib_none().0) } } pub fn iter_tag<'a, T: Tag<'a>>(&'a self) -> TagIter<'a, T> { @@ -487,12 +486,12 @@ impl TagListRef { } pub fn insert(&mut self, other: &TagListRef, mode: TagMergeMode) { - unsafe { gst_sys::gst_tag_list_insert(self.as_mut_ptr(), other.as_ptr(), mode.to_glib()) } + unsafe { ffi::gst_tag_list_insert(self.as_mut_ptr(), other.as_ptr(), mode.to_glib()) } } pub fn merge(&self, other: &TagListRef, mode: TagMergeMode) -> TagList { unsafe { - from_glib_full(gst_sys::gst_tag_list_merge( + from_glib_full(ffi::gst_tag_list_merge( self.as_ptr(), other.as_ptr(), mode.to_glib(), @@ -501,11 +500,11 @@ impl TagListRef { } pub fn get_scope(&self) -> TagScope { - unsafe { from_glib(gst_sys::gst_tag_list_get_scope(self.as_ptr())) } + unsafe { from_glib(ffi::gst_tag_list_get_scope(self.as_ptr())) } } pub fn set_scope(&mut self, scope: TagScope) { - unsafe { gst_sys::gst_tag_list_set_scope(self.as_mut_ptr(), scope.to_glib()) } + unsafe { ffi::gst_tag_list_set_scope(self.as_mut_ptr(), scope.to_glib()) } } } @@ -537,21 +536,15 @@ impl fmt::Debug for TagListRef { impl fmt::Display for TagListRef { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - let s = unsafe { - glib::GString::from_glib_full(gst_sys::gst_tag_list_to_string(self.as_ptr())) - }; + let s = + unsafe { glib::GString::from_glib_full(ffi::gst_tag_list_to_string(self.as_ptr())) }; f.write_str(&s) } } impl PartialEq for TagListRef { fn eq(&self, other: &TagListRef) -> bool { - unsafe { - from_glib(gst_sys::gst_tag_list_is_equal( - self.as_ptr(), - other.as_ptr(), - )) - } + unsafe { from_glib(ffi::gst_tag_list_is_equal(self.as_ptr(), other.as_ptr())) } } } @@ -806,18 +799,18 @@ impl<'a> ExactSizeIterator for Iter<'a> {} pub fn tag_exists(name: &str) -> bool { skip_assert_initialized!(); - unsafe { from_glib(gst_sys::gst_tag_exists(name.to_glib_none().0)) } + unsafe { from_glib(ffi::gst_tag_exists(name.to_glib_none().0)) } } pub fn tag_get_type(name: &str) -> glib::Type { skip_assert_initialized!(); - unsafe { from_glib(gst_sys::gst_tag_get_type(name.to_glib_none().0)) } + unsafe { from_glib(ffi::gst_tag_get_type(name.to_glib_none().0)) } } pub fn tag_get_nick<'b>(name: &str) -> Option<&'b str> { skip_assert_initialized!(); unsafe { - let ptr = gst_sys::gst_tag_get_nick(name.to_glib_none().0); + let ptr = ffi::gst_tag_get_nick(name.to_glib_none().0); if ptr.is_null() { None @@ -830,7 +823,7 @@ pub fn tag_get_nick<'b>(name: &str) -> Option<&'b str> { pub fn tag_get_description<'b>(name: &str) -> Option<&'b str> { skip_assert_initialized!(); unsafe { - let ptr = gst_sys::gst_tag_get_description(name.to_glib_none().0); + let ptr = ffi::gst_tag_get_description(name.to_glib_none().0); if ptr.is_null() { None @@ -840,13 +833,13 @@ pub fn tag_get_description<'b>(name: &str) -> Option<&'b str> { } } -pub fn tag_get_flag(name: &str) -> ::TagFlag { +pub fn tag_get_flag(name: &str) -> crate::TagFlag { skip_assert_initialized!(); - unsafe { from_glib(gst_sys::gst_tag_get_flag(name.to_glib_none().0)) } + unsafe { from_glib(ffi::gst_tag_get_flag(name.to_glib_none().0)) } } pub trait CustomTag<'a>: Tag<'a> { - const FLAG: ::TagFlag; + const FLAG: crate::TagFlag; const NICK: &'static str; const DESCRIPTION: &'static str; @@ -860,14 +853,14 @@ pub fn register CustomTag<'a>>() { assert!(!tag_exists(T::tag_name())); unsafe extern "C" fn merge_func_trampoline CustomTag<'a>>( - dest: *mut gobject_sys::GValue, - src: *const gobject_sys::GValue, + dest: *mut glib::gobject_ffi::GValue, + src: *const glib::gobject_ffi::GValue, ) { *dest = T::merge_func(&*(src as *const Value)).into_raw(); } unsafe { - gst_sys::gst_tag_register( + ffi::gst_tag_register( T::tag_name().to_glib_none().0, T::FLAG.to_glib(), T::TagType::static_type().to_glib(), @@ -880,26 +873,26 @@ pub fn register CustomTag<'a>>() { pub fn merge_use_first(src: &Value) -> Value { skip_assert_initialized!(); - assert_eq!(src.type_(), ::List::static_type()); + assert_eq!(src.type_(), crate::List::static_type()); unsafe { use glib::translate::Uninitialized; let mut res = Value::uninitialized(); - gst_sys::gst_tag_merge_use_first(res.to_glib_none_mut().0, src.to_glib_none().0); + ffi::gst_tag_merge_use_first(res.to_glib_none_mut().0, src.to_glib_none().0); res } } pub fn merge_strings_with_comma(src: &Value) -> Value { skip_assert_initialized!(); - assert_eq!(src.type_(), ::List::static_type()); + assert_eq!(src.type_(), crate::List::static_type()); unsafe { use glib::translate::Uninitialized; let mut res = Value::uninitialized(); - gst_sys::gst_tag_merge_strings_with_comma(res.to_glib_none_mut().0, src.to_glib_none().0); + ffi::gst_tag_merge_strings_with_comma(res.to_glib_none_mut().0, src.to_glib_none().0); res } } @@ -910,14 +903,14 @@ mod tests { #[test] fn test_add() { - ::init().unwrap(); + crate::init().unwrap(); let mut tags = TagList::new(); assert_eq!(tags.to_string(), "taglist;"); { let tags = tags.get_mut().unwrap(); tags.add::(&"some title", TagMergeMode::Append); - tags.add::<Duration>(&(::SECOND * 120), TagMergeMode::Append); + tags.add::<Duration>(&(crate::SECOND * 120), TagMergeMode::Append); } assert_eq!( tags.to_string(), @@ -927,31 +920,34 @@ mod tests { #[test] fn test_get() { - ::init().unwrap(); + crate::init().unwrap(); let mut tags = TagList::new(); assert_eq!(tags.to_string(), "taglist;"); { let tags = tags.get_mut().unwrap(); tags.add::<Title>(&"some title", TagMergeMode::Append); - tags.add::<Duration>(&(::SECOND * 120), TagMergeMode::Append); + tags.add::<Duration>(&(crate::SECOND * 120), TagMergeMode::Append); } assert_eq!(tags.get::<Title>().unwrap().get(), Some("some title")); - assert_eq!(tags.get::<Duration>().unwrap().get_some(), (::SECOND * 120)); + assert_eq!( + tags.get::<Duration>().unwrap().get_some(), + (crate::SECOND * 120) + ); assert_eq!( tags.get_index::<Title>(0).unwrap().get(), Some("some title") ); assert_eq!( tags.get_index::<Duration>(0).unwrap().get_some(), - (::SECOND * 120) + (crate::SECOND * 120) ); } #[test] fn test_scope() { - ::init().unwrap(); + crate::init().unwrap(); let mut tags = TagList::new(); assert_eq!(tags.get_scope(), TagScope::Stream); @@ -965,7 +961,7 @@ mod tests { #[test] #[allow(clippy::cognitive_complexity)] fn test_generic() { - ::init().unwrap(); + crate::init().unwrap(); let mut tags = TagList::new(); { @@ -977,7 +973,7 @@ mod tests { .add_generic(&TAG_TITLE, &"second title", TagMergeMode::Append) .is_ok()); assert!(tags - .add_generic(&TAG_DURATION, &(::SECOND * 120), TagMergeMode::Append) + .add_generic(&TAG_DURATION, &(crate::SECOND * 120), TagMergeMode::Append) .is_ok()); assert!(tags .add_generic(&TAG_TITLE, &"third title", TagMergeMode::Append) @@ -1003,7 +999,7 @@ mod tests { ); assert_eq!( tags.get_index_generic(&TAG_DURATION, 0).unwrap().get(), - Ok(Some(::SECOND * 120)) + Ok(Some(crate::SECOND * 120)) ); assert_eq!( tags.get_index_generic(&TAG_TITLE, 2).unwrap().get(), @@ -1049,7 +1045,7 @@ mod tests { let (tag_name, mut tag_iter) = tag_list_iter.next().unwrap(); assert_eq!(tag_name, *TAG_DURATION); let first_duration = tag_iter.next().unwrap(); - assert_eq!(first_duration.get_some(), Ok(::SECOND * 120)); + assert_eq!(first_duration.get_some(), Ok(crate::SECOND * 120)); assert!(tag_iter.next().is_none()); // Iter @@ -1065,13 +1061,13 @@ mod tests { let (tag_name, tag_value) = tag_list_iter.next().unwrap(); assert_eq!(tag_name, *TAG_DURATION); - assert_eq!(tag_value.get_some(), Ok(::SECOND * 120)); + assert_eq!(tag_value.get_some(), Ok(crate::SECOND * 120)); assert!(tag_iter.next().is_none()); } #[test] fn test_custom_tags() { - ::init().unwrap(); + crate::init().unwrap(); enum MyCustomTag {}; @@ -1083,7 +1079,7 @@ mod tests { } impl<'a> CustomTag<'a> for MyCustomTag { - const FLAG: ::TagFlag = ::TagFlag::Meta; + const FLAG: crate::TagFlag = crate::TagFlag::Meta; const NICK: &'static str = "my custom tag"; const DESCRIPTION: &'static str = "My own custom tag type for testing"; @@ -1131,7 +1127,7 @@ mod tests { #[test] fn test_display() { - ::init().unwrap(); + crate::init().unwrap(); format!("{}", TagList::new()); } diff --git a/gstreamer/src/tags_serde.rs b/gstreamer/src/tags_serde.rs index 00cc6708e..0b4afa652 100644 --- a/gstreamer/src/tags_serde.rs +++ b/gstreamer/src/tags_serde.rs @@ -6,10 +6,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use glib; use glib::translate::{from_glib, ToGlibPtr}; use glib::{Date, SendValue, ToValue}; -use gst_sys; use serde::de; use serde::de::{Deserialize, DeserializeSeed, Deserializer, SeqAccess, Visitor}; @@ -21,13 +19,13 @@ use std::cmp; use std::fmt; use std::rc::Rc; -use date_time_serde; -use tags::{GenericTagIter, TagList, TagListRef}; -use value_serde::{DATE_OTHER_TYPE_ID, DATE_TIME_OTHER_TYPE_ID, SAMPLE_OTHER_TYPE_ID}; -use DateTime; -use Sample; -use TagMergeMode; -use TagScope; +use crate::date_time_serde; +use crate::tags::{GenericTagIter, TagList, TagListRef}; +use crate::value_serde::{DATE_OTHER_TYPE_ID, DATE_TIME_OTHER_TYPE_ID, SAMPLE_OTHER_TYPE_ID}; +use crate::DateTime; +use crate::Sample; +use crate::TagMergeMode; +use crate::TagScope; macro_rules! ser_some_tag ( ($value:ident, $seq:ident, $t:ty) => ( @@ -183,7 +181,7 @@ impl<'de, 'a> Visitor<'de> for TagValuesVisitor<'a> { fn visit_seq<A: SeqAccess<'de>>(self, mut seq: A) -> Result<(), A::Error> { let tag_type: glib::Type = unsafe { let tag_name = self.0.to_glib_none(); - from_glib(gst_sys::gst_tag_get_type(tag_name.0)) + from_glib(ffi::gst_tag_get_type(tag_name.0)) }; loop { @@ -304,7 +302,7 @@ impl<'de> Deserialize<'de> for TagsDe { } } -#[derive(Deserialize)] +#[derive(serde::Deserialize)] struct TagListDe { scope: TagScope, tags: TagsDe, @@ -329,17 +327,15 @@ impl<'de> Deserialize<'de> for TagList { #[cfg(test)] mod tests { - extern crate ron; - - use tags::*; - use Buffer; - use Sample; - use TagMergeMode; - use TagScope; + use crate::tags::*; + use crate::Buffer; + use crate::Sample; + use crate::TagMergeMode; + use crate::TagScope; #[test] fn test_serialize() { - ::init().unwrap(); + crate::init().unwrap(); let mut tags = TagList::new(); assert_eq!(tags.to_string(), "taglist;"); @@ -347,7 +343,7 @@ mod tests { let tags = tags.get_mut().unwrap(); tags.add::<Title>(&"a title", TagMergeMode::Append); // String tags.add::<Title>(&"another title", TagMergeMode::Append); // String - tags.add::<Duration>(&(::SECOND * 120), TagMergeMode::Append); // u64 + tags.add::<Duration>(&(crate::SECOND * 120), TagMergeMode::Append); // u64 tags.add::<Bitrate>(&96_000, TagMergeMode::Append); // u32 tags.add::<TrackGain>(&1f64, TagMergeMode::Append); // f64 tags.add::<Date>( @@ -355,7 +351,7 @@ mod tests { TagMergeMode::Append, ); tags.add::<DateTime>( - &::DateTime::new_ymd(2018, 5, 28).unwrap(), + &crate::DateTime::new_ymd(2018, 5, 28).unwrap(), TagMergeMode::Append, ); @@ -442,9 +438,7 @@ mod tests { #[test] fn test_deserialize() { - extern crate serde_json; - - ::init().unwrap(); + crate::init().unwrap(); let tag_list_ron = r#" ( @@ -495,7 +489,7 @@ mod tests { ); assert_eq!( tags.get_index::<Duration>(0).unwrap().get_some(), - ::SECOND * 120 + crate::SECOND * 120 ); assert_eq!(tags.get_index::<Bitrate>(0).unwrap().get_some(), 96_000); assert!( @@ -507,7 +501,7 @@ mod tests { ); assert_eq!( tags.get_index::<DateTime>(0).unwrap().get().unwrap(), - ::DateTime::new_ymd(2018, 5, 28).unwrap() + crate::DateTime::new_ymd(2018, 5, 28).unwrap() ); let sample = tags.get_index::<Image>(0).unwrap().get().unwrap(); let buffer = sample.get_buffer().unwrap(); @@ -548,7 +542,7 @@ mod tests { ); assert_eq!( tags.get_index::<DateTime>(0).unwrap().get().unwrap(), - ::DateTime::new_ymd(2018, 5, 28).unwrap() + crate::DateTime::new_ymd(2018, 5, 28).unwrap() ); let sample = tags.get_index::<Image>(0).unwrap().get().unwrap(); let buffer = sample.get_buffer().unwrap(); @@ -560,7 +554,7 @@ mod tests { #[test] fn test_serde_roundtrip() { - ::init().unwrap(); + crate::init().unwrap(); let mut tags = TagList::new(); assert_eq!(tags.to_string(), "taglist;"); @@ -569,7 +563,7 @@ mod tests { tags.set_scope(TagScope::Global); tags.add::<Title>(&"a title", TagMergeMode::Append); // String tags.add::<Title>(&"another title", TagMergeMode::Append); // String - tags.add::<Duration>(&(::SECOND * 120), TagMergeMode::Append); // u64 + tags.add::<Duration>(&(crate::SECOND * 120), TagMergeMode::Append); // u64 tags.add::<Bitrate>(&96_000, TagMergeMode::Append); // u32 tags.add::<TrackGain>(&1f64, TagMergeMode::Append); // f64 tags.add::<Date>( @@ -577,7 +571,7 @@ mod tests { TagMergeMode::Append, ); tags.add::<DateTime>( - &::DateTime::new_ymd(2018, 5, 28).unwrap(), + &crate::DateTime::new_ymd(2018, 5, 28).unwrap(), TagMergeMode::Append, ); @@ -625,7 +619,7 @@ mod tests { ); assert_eq!( tags.get_index::<DateTime>(0).unwrap().get().unwrap(), - ::DateTime::new_ymd(2018, 5, 28).unwrap() + crate::DateTime::new_ymd(2018, 5, 28).unwrap() ); let sample = tags.get_index::<Image>(0).unwrap().get().unwrap(); let buffer = sample.get_buffer().unwrap(); diff --git a/gstreamer/src/toc.rs b/gstreamer/src/toc.rs index 0a81b3c16..117ea09c5 100644 --- a/gstreamer/src/toc.rs +++ b/gstreamer/src/toc.rs @@ -10,73 +10,63 @@ use std::ffi::CStr; use std::fmt; use std::mem; -use gst_sys; - -use glib; use glib::translate::{ from_glib, from_glib_full, from_glib_none, FromGlibPtrContainer, ToGlib, ToGlibPtr, }; -use TagList; -use TagMergeMode; -use TocEntryType; -use TocLoopType; -use TocScope; +use crate::TagList; +use crate::TagMergeMode; +use crate::TocEntryType; +use crate::TocLoopType; +use crate::TocScope; -gst_define_mini_object_wrapper!(Toc, TocRef, gst_sys::GstToc, || { - gst_sys::gst_toc_get_type() -}); +gst_define_mini_object_wrapper!(Toc, TocRef, ffi::GstToc, || { ffi::gst_toc_get_type() }); impl Toc { pub fn new(scope: TocScope) -> Self { assert_initialized_main_thread!(); - unsafe { from_glib_full(gst_sys::gst_toc_new(scope.to_glib())) } + unsafe { from_glib_full(ffi::gst_toc_new(scope.to_glib())) } } } impl TocRef { pub fn get_scope(&self) -> TocScope { - unsafe { from_glib(gst_sys::gst_toc_get_scope(self.as_ptr())) } + unsafe { from_glib(ffi::gst_toc_get_scope(self.as_ptr())) } } pub fn find_entry(&self, uid: &str) -> Option<TocEntry> { - unsafe { - from_glib_none(gst_sys::gst_toc_find_entry( - self.as_ptr(), - uid.to_glib_none().0, - )) - } + unsafe { from_glib_none(ffi::gst_toc_find_entry(self.as_ptr(), uid.to_glib_none().0)) } } pub fn get_entries(&self) -> Vec<TocEntry> { - unsafe { FromGlibPtrContainer::from_glib_none(gst_sys::gst_toc_get_entries(self.as_ptr())) } + unsafe { FromGlibPtrContainer::from_glib_none(ffi::gst_toc_get_entries(self.as_ptr())) } } pub fn append_entry(&mut self, entry: TocEntry) { unsafe { - gst_sys::gst_toc_append_entry(self.as_mut_ptr(), entry.into_ptr()); + ffi::gst_toc_append_entry(self.as_mut_ptr(), entry.into_ptr()); } } pub fn get_tags(&self) -> Option<TagList> { - unsafe { from_glib_none(gst_sys::gst_toc_get_tags(self.as_ptr())) } + unsafe { from_glib_none(ffi::gst_toc_get_tags(self.as_ptr())) } } pub fn set_tags(&mut self, tag_list: TagList) { unsafe { - gst_sys::gst_toc_set_tags(self.as_mut_ptr(), tag_list.into_ptr()); + ffi::gst_toc_set_tags(self.as_mut_ptr(), tag_list.into_ptr()); } } pub fn merge_tags(&mut self, tag_list: &TagList, mode: TagMergeMode) { unsafe { - gst_sys::gst_toc_merge_tags(self.as_mut_ptr(), tag_list.as_mut_ptr(), mode.to_glib()); + ffi::gst_toc_merge_tags(self.as_mut_ptr(), tag_list.as_mut_ptr(), mode.to_glib()); } } pub fn dump(&self) { unsafe { - gst_sys::gst_toc_dump(self.as_mut_ptr()); + ffi::gst_toc_dump(self.as_mut_ptr()); } } } @@ -97,15 +87,15 @@ impl fmt::Debug for TocRef { } } -gst_define_mini_object_wrapper!(TocEntry, TocEntryRef, gst_sys::GstTocEntry, || { - gst_sys::gst_toc_entry_get_type() +gst_define_mini_object_wrapper!(TocEntry, TocEntryRef, ffi::GstTocEntry, || { + ffi::gst_toc_entry_get_type() }); impl TocEntry { pub fn new(type_: TocEntryType, uid: &str) -> Self { assert_initialized_main_thread!(); unsafe { - from_glib_full(gst_sys::gst_toc_entry_new( + from_glib_full(ffi::gst_toc_entry_new( type_.to_glib(), uid.to_glib_none().0, )) @@ -115,12 +105,12 @@ impl TocEntry { impl TocEntryRef { pub fn get_entry_type(&self) -> TocEntryType { - unsafe { from_glib(gst_sys::gst_toc_entry_get_entry_type(self.as_ptr())) } + unsafe { from_glib(ffi::gst_toc_entry_get_entry_type(self.as_ptr())) } } pub fn get_uid(&self) -> &str { unsafe { - CStr::from_ptr(gst_sys::gst_toc_entry_get_uid(self.as_ptr())) + CStr::from_ptr(ffi::gst_toc_entry_get_uid(self.as_ptr())) .to_str() .unwrap() } @@ -128,20 +118,18 @@ impl TocEntryRef { pub fn append_sub_entry(&mut self, subentry: TocEntry) { unsafe { - gst_sys::gst_toc_entry_append_sub_entry(self.as_mut_ptr(), subentry.into_ptr()); + ffi::gst_toc_entry_append_sub_entry(self.as_mut_ptr(), subentry.into_ptr()); } } pub fn get_sub_entries(&self) -> Vec<TocEntry> { unsafe { - FromGlibPtrContainer::from_glib_none(gst_sys::gst_toc_entry_get_sub_entries( - self.as_ptr(), - )) + FromGlibPtrContainer::from_glib_none(ffi::gst_toc_entry_get_sub_entries(self.as_ptr())) } } pub fn get_parent(&self) -> Option<TocEntry> { - unsafe { from_glib_none(gst_sys::gst_toc_entry_get_parent(self.as_mut_ptr())) } + unsafe { from_glib_none(ffi::gst_toc_entry_get_parent(self.as_mut_ptr())) } } pub fn get_start_stop_times(&self) -> Option<(i64, i64)> { @@ -149,7 +137,7 @@ impl TocEntryRef { let mut start = mem::MaybeUninit::uninit(); let mut stop = mem::MaybeUninit::uninit(); - if from_glib(gst_sys::gst_toc_entry_get_start_stop_times( + if from_glib(ffi::gst_toc_entry_get_start_stop_times( self.as_ptr(), start.as_mut_ptr(), stop.as_mut_ptr(), @@ -163,43 +151,39 @@ impl TocEntryRef { pub fn set_start_stop_times(&mut self, start: i64, stop: i64) { unsafe { - gst_sys::gst_toc_entry_set_start_stop_times(self.as_mut_ptr(), start, stop); + ffi::gst_toc_entry_set_start_stop_times(self.as_mut_ptr(), start, stop); } } pub fn get_tags(&self) -> Option<TagList> { - unsafe { from_glib_none(gst_sys::gst_toc_entry_get_tags(self.as_ptr())) } + unsafe { from_glib_none(ffi::gst_toc_entry_get_tags(self.as_ptr())) } } pub fn set_tags(&mut self, tag_list: TagList) { unsafe { - gst_sys::gst_toc_entry_set_tags(self.as_mut_ptr(), tag_list.into_ptr()); + ffi::gst_toc_entry_set_tags(self.as_mut_ptr(), tag_list.into_ptr()); } } pub fn merge_tags(&mut self, tag_list: &TagList, mode: TagMergeMode) { unsafe { - gst_sys::gst_toc_entry_merge_tags( - self.as_mut_ptr(), - tag_list.as_mut_ptr(), - mode.to_glib(), - ); + ffi::gst_toc_entry_merge_tags(self.as_mut_ptr(), tag_list.as_mut_ptr(), mode.to_glib()); } } pub fn is_alternative(&self) -> bool { - unsafe { from_glib(gst_sys::gst_toc_entry_is_alternative(self.as_ptr())) } + unsafe { from_glib(ffi::gst_toc_entry_is_alternative(self.as_ptr())) } } pub fn is_sequence(&self) -> bool { - unsafe { from_glib(gst_sys::gst_toc_entry_is_sequence(self.as_ptr())) } + unsafe { from_glib(ffi::gst_toc_entry_is_sequence(self.as_ptr())) } } pub fn get_loop(&self) -> Option<(TocLoopType, i32)> { unsafe { let mut loop_type = mem::MaybeUninit::uninit(); let mut repeat_count = mem::MaybeUninit::uninit(); - if from_glib(gst_sys::gst_toc_entry_get_loop( + if from_glib(ffi::gst_toc_entry_get_loop( self.as_ptr(), loop_type.as_mut_ptr(), repeat_count.as_mut_ptr(), @@ -216,7 +200,7 @@ impl TocEntryRef { pub fn set_loop(&mut self, loop_type: TocLoopType, repeat_count: i32) { unsafe { - gst_sys::gst_toc_entry_set_loop(self.as_mut_ptr(), loop_type.to_glib(), repeat_count); + ffi::gst_toc_entry_set_loop(self.as_mut_ptr(), loop_type.to_glib(), repeat_count); } } } @@ -248,7 +232,7 @@ mod tests { #[test] fn test_simple() { - ::init().unwrap(); + crate::init().unwrap(); // Top level toc entry let mut toc_entry = TocEntry::new(TocEntryType::Chapter, "chapter"); diff --git a/gstreamer/src/toc_serde.rs b/gstreamer/src/toc_serde.rs index 73bcbea79..dedcac69f 100644 --- a/gstreamer/src/toc_serde.rs +++ b/gstreamer/src/toc_serde.rs @@ -9,11 +9,11 @@ use serde::de::{Deserialize, Deserializer}; use serde::ser::{Serialize, SerializeStruct, Serializer}; -use toc::*; -use TagList; -use TocEntryType; -use TocLoopType; -use TocScope; +use crate::toc::*; +use crate::TagList; +use crate::TocEntryType; +use crate::TocLoopType; +use crate::TocScope; impl Serialize for TocRef { fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> { @@ -50,7 +50,7 @@ impl Serialize for TocEntry { } } -#[derive(Deserialize)] +#[derive(serde::Deserialize)] struct TocDe { scope: TocScope, tags: Option<TagList>, @@ -82,7 +82,7 @@ impl<'de> Deserialize<'de> for Toc { } } -#[derive(Deserialize)] +#[derive(serde::Deserialize)] struct TocEntryDe { entry_type: TocEntryType, uid: String, @@ -127,18 +127,16 @@ impl<'de> Deserialize<'de> for TocEntry { #[cfg(test)] mod tests { - extern crate ron; - - use tags::Title; - use toc::*; - use TagList; - use TagMergeMode; - use TocEntryType; - use TocScope; + use crate::tags::Title; + use crate::toc::*; + use crate::TagList; + use crate::TagMergeMode; + use crate::TocEntryType; + use crate::TocScope; #[test] fn test_serialize() { - ::init().unwrap(); + crate::init().unwrap(); let mut toc = Toc::new(TocScope::Global); { @@ -290,9 +288,9 @@ mod tests { #[allow(clippy::cognitive_complexity)] #[test] fn test_deserialize() { - use tags::Title; + use crate::tags::Title; - ::init().unwrap(); + crate::init().unwrap(); let toc_ron = r#" ( @@ -425,7 +423,7 @@ mod tests { #[allow(clippy::cognitive_complexity)] #[test] fn test_serde_roundtrip() { - ::init().unwrap(); + crate::init().unwrap(); let mut toc = Toc::new(TocScope::Global); { diff --git a/gstreamer/src/typefind.rs b/gstreamer/src/typefind.rs index 28028851b..043367121 100644 --- a/gstreamer/src/typefind.rs +++ b/gstreamer/src/typefind.rs @@ -6,22 +6,19 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use gst_sys; -use Caps; -use Plugin; -use Rank; -use TypeFindFactory; -use TypeFindProbability; +use crate::Caps; +use crate::Plugin; +use crate::Rank; +use crate::TypeFindFactory; +use crate::TypeFindProbability; -use glib; use glib::translate::*; -use glib_sys; use std::ptr; use std::slice; #[repr(transparent)] #[derive(Debug)] -pub struct TypeFind(gst_sys::GstTypeFind); +pub struct TypeFind(ffi::GstTypeFind); pub trait TypeFindImpl { fn peek(&mut self, offset: i64, size: u32) -> Option<&[u8]>; @@ -48,7 +45,7 @@ impl TypeFind { let func: Box<F> = Box::new(func); let func = Box::into_raw(func); - let res = gst_sys::gst_type_find_register( + let res = ffi::gst_type_find_register( plugin.to_glib_none().0, name.to_glib_none().0, rank.to_glib() as u32, @@ -59,13 +56,13 @@ impl TypeFind { Some(type_find_closure_drop::<F>), ); - glib_result_from_gboolean!(res, "Failed to register typefind factory") + glib::glib_result_from_gboolean!(res, "Failed to register typefind factory") } } pub fn peek(&mut self, offset: i64, size: u32) -> Option<&[u8]> { unsafe { - let data = gst_sys::gst_type_find_peek(&mut self.0, offset, size); + let data = ffi::gst_type_find_peek(&mut self.0, offset, size); if data.is_null() { None } else { @@ -76,7 +73,7 @@ impl TypeFind { pub fn suggest(&mut self, probability: TypeFindProbability, caps: &Caps) { unsafe { - gst_sys::gst_type_find_suggest( + ffi::gst_type_find_suggest( &mut self.0, probability.to_glib() as u32, caps.to_glib_none().0, @@ -86,7 +83,7 @@ impl TypeFind { pub fn get_length(&mut self) -> Option<u64> { unsafe { - let len = gst_sys::gst_type_find_get_length(&mut self.0); + let len = ffi::gst_type_find_get_length(&mut self.0); if len == 0 { None } else { @@ -99,8 +96,8 @@ impl TypeFind { impl TypeFindFactory { pub fn call_function(&self, find: &mut dyn TypeFindImpl) { unsafe { - let find_ptr = &find as *const &mut dyn TypeFindImpl as glib_sys::gpointer; - let mut find = gst_sys::GstTypeFind { + let find_ptr = &find as *const &mut dyn TypeFindImpl as glib::ffi::gpointer; + let mut find = ffi::GstTypeFind { peek: Some(type_find_peek), suggest: Some(type_find_suggest), data: find_ptr, @@ -108,26 +105,30 @@ impl TypeFindFactory { _gst_reserved: [ptr::null_mut(); 4], }; - gst_sys::gst_type_find_factory_call_function(self.to_glib_none().0, &mut find) + ffi::gst_type_find_factory_call_function(self.to_glib_none().0, &mut find) } } } unsafe extern "C" fn type_find_trampoline<F: Fn(&mut TypeFind) + Send + Sync + 'static>( - find: *mut gst_sys::GstTypeFind, - user_data: glib_sys::gpointer, + find: *mut ffi::GstTypeFind, + user_data: glib::ffi::gpointer, ) { let func: &F = &*(user_data as *const F); func(&mut *(find as *mut TypeFind)); } unsafe extern "C" fn type_find_closure_drop<F: Fn(&mut TypeFind) + Send + Sync + 'static>( - data: glib_sys::gpointer, + data: glib::ffi::gpointer, ) { Box::<F>::from_raw(data as *mut _); } -unsafe extern "C" fn type_find_peek(data: glib_sys::gpointer, offset: i64, size: u32) -> *const u8 { +unsafe extern "C" fn type_find_peek( + data: glib::ffi::gpointer, + offset: i64, + size: u32, +) -> *const u8 { let find: &mut &mut dyn TypeFindImpl = &mut *(data as *mut &mut dyn TypeFindImpl); match find.peek(offset, size) { None => ptr::null(), @@ -136,15 +137,15 @@ unsafe extern "C" fn type_find_peek(data: glib_sys::gpointer, offset: i64, size: } unsafe extern "C" fn type_find_suggest( - data: glib_sys::gpointer, + data: glib::ffi::gpointer, probability: u32, - caps: *mut gst_sys::GstCaps, + caps: *mut ffi::GstCaps, ) { let find: &mut &mut dyn TypeFindImpl = &mut *(data as *mut &mut dyn TypeFindImpl); find.suggest(from_glib(probability as i32), &from_glib_borrow(caps)); } -unsafe extern "C" fn type_find_get_length(data: glib_sys::gpointer) -> u64 { +unsafe extern "C" fn type_find_get_length(data: glib::ffi::gpointer) -> u64 { use std::u64; let find: &mut &mut dyn TypeFindImpl = &mut *(data as *mut &mut dyn TypeFindImpl); @@ -242,7 +243,7 @@ mod tests { #[test] fn test_typefind_call_function() { - ::init().unwrap(); + crate::init().unwrap(); let xml_factory = TypeFindFactory::get_list() .iter() @@ -272,12 +273,12 @@ mod tests { #[test] fn test_typefind_register() { - ::init().unwrap(); + crate::init().unwrap(); TypeFind::register( None, "test_typefind", - ::Rank::Primary, + crate::Rank::Primary, None, Some(&Caps::new_simple("test/test", &[])), |typefind| { diff --git a/gstreamer/src/utils.rs b/gstreamer/src/utils.rs index d4308fb51..519d6c59b 100644 --- a/gstreamer/src/utils.rs +++ b/gstreamer/src/utils.rs @@ -7,17 +7,16 @@ // except according to those terms. use glib::translate::mut_override; -use glib_sys; #[must_use = "if unused the Mutex will immediately unlock"] -pub struct MutexGuard<'a>(&'a glib_sys::GMutex); +pub struct MutexGuard<'a>(&'a glib::ffi::GMutex); impl<'a> MutexGuard<'a> { #[allow(clippy::trivially_copy_pass_by_ref)] - pub fn lock(mutex: &'a glib_sys::GMutex) -> Self { + pub fn lock(mutex: &'a glib::ffi::GMutex) -> Self { skip_assert_initialized!(); unsafe { - glib_sys::g_mutex_lock(mut_override(mutex)); + glib::ffi::g_mutex_lock(mut_override(mutex)); } MutexGuard(mutex) } @@ -26,7 +25,7 @@ impl<'a> MutexGuard<'a> { impl<'a> Drop for MutexGuard<'a> { fn drop(&mut self) { unsafe { - glib_sys::g_mutex_unlock(mut_override(self.0)); + glib::ffi::g_mutex_unlock(mut_override(self.0)); } } } diff --git a/gstreamer/src/value.rs b/gstreamer/src/value.rs index 55d6fc094..d30fd4024 100644 --- a/gstreamer/src/value.rs +++ b/gstreamer/src/value.rs @@ -13,13 +13,9 @@ use std::fmt; use std::ops; use std::slice; -use glib; use glib::translate::{from_glib, FromGlibPtrFull, ToGlibPtr, ToGlibPtrMut, Uninitialized}; use glib::value::{FromValue, FromValueOptional, SetValue, ToSendValue, Value}; -use glib_sys; -use gst_sys; - #[derive(Copy, Clone, Debug, Ord, PartialOrd, Eq, PartialEq, Hash)] pub struct Fraction(pub Rational32); @@ -248,14 +244,14 @@ impl From<Fraction> for Rational32 { impl glib::types::StaticType for Fraction { fn static_type() -> glib::types::Type { - unsafe { from_glib(gst_sys::gst_fraction_get_type()) } + unsafe { from_glib(ffi::gst_fraction_get_type()) } } } impl<'a> FromValue<'a> for Fraction { unsafe fn from_value(v: &'a Value) -> Fraction { - let n = gst_sys::gst_value_get_fraction_numerator(v.to_glib_none().0); - let d = gst_sys::gst_value_get_fraction_denominator(v.to_glib_none().0); + let n = ffi::gst_value_get_fraction_numerator(v.to_glib_none().0); + let d = ffi::gst_value_get_fraction_denominator(v.to_glib_none().0); Fraction::new(n, d) } @@ -269,12 +265,12 @@ impl<'a> FromValueOptional<'a> for Fraction { impl SetValue for Fraction { unsafe fn set_value(v: &mut Value, f: &Self) { - gst_sys::gst_value_set_fraction(v.to_glib_none_mut().0, *f.numer(), *f.denom()); + ffi::gst_value_set_fraction(v.to_glib_none_mut().0, *f.numer(), *f.denom()); } } #[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)] -#[cfg_attr(feature = "ser_de", derive(Serialize, Deserialize))] +#[cfg_attr(feature = "ser_de", derive(serde::Serialize, serde::Deserialize))] pub struct IntRange<T> { min: T, max: T, @@ -357,15 +353,15 @@ impl From<(i64, i64, i64)> for IntRange<i64> { impl glib::types::StaticType for IntRange<i32> { fn static_type() -> glib::types::Type { - unsafe { from_glib(gst_sys::gst_int_range_get_type()) } + unsafe { from_glib(ffi::gst_int_range_get_type()) } } } impl<'a> FromValue<'a> for IntRange<i32> { unsafe fn from_value(v: &'a Value) -> Self { - let min = gst_sys::gst_value_get_int_range_min(v.to_glib_none().0); - let max = gst_sys::gst_value_get_int_range_max(v.to_glib_none().0); - let step = gst_sys::gst_value_get_int_range_step(v.to_glib_none().0); + let min = ffi::gst_value_get_int_range_min(v.to_glib_none().0); + let max = ffi::gst_value_get_int_range_max(v.to_glib_none().0); + let step = ffi::gst_value_get_int_range_step(v.to_glib_none().0); Self::with_step(min, max, step) } @@ -379,21 +375,21 @@ impl<'a> FromValueOptional<'a> for IntRange<i32> { impl SetValue for IntRange<i32> { unsafe fn set_value(v: &mut Value, r: &Self) { - gst_sys::gst_value_set_int_range_step(v.to_glib_none_mut().0, r.min(), r.max(), r.step()); + ffi::gst_value_set_int_range_step(v.to_glib_none_mut().0, r.min(), r.max(), r.step()); } } impl glib::types::StaticType for IntRange<i64> { fn static_type() -> glib::types::Type { - unsafe { from_glib(gst_sys::gst_int64_range_get_type()) } + unsafe { from_glib(ffi::gst_int64_range_get_type()) } } } impl<'a> FromValue<'a> for IntRange<i64> { unsafe fn from_value(v: &'a Value) -> Self { - let min = gst_sys::gst_value_get_int64_range_min(v.to_glib_none().0); - let max = gst_sys::gst_value_get_int64_range_max(v.to_glib_none().0); - let step = gst_sys::gst_value_get_int64_range_step(v.to_glib_none().0); + let min = ffi::gst_value_get_int64_range_min(v.to_glib_none().0); + let max = ffi::gst_value_get_int64_range_max(v.to_glib_none().0); + let step = ffi::gst_value_get_int64_range_step(v.to_glib_none().0); Self::with_step(min, max, step) } @@ -407,12 +403,12 @@ impl<'a> FromValueOptional<'a> for IntRange<i64> { impl SetValue for IntRange<i64> { unsafe fn set_value(v: &mut Value, r: &Self) { - gst_sys::gst_value_set_int64_range_step(v.to_glib_none_mut().0, r.min(), r.max(), r.step()); + ffi::gst_value_set_int64_range_step(v.to_glib_none_mut().0, r.min(), r.max(), r.step()); } } #[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)] -#[cfg_attr(feature = "ser_de", derive(Serialize, Deserialize))] +#[cfg_attr(feature = "ser_de", derive(serde::Serialize, serde::Deserialize))] pub struct FractionRange { min: Fraction, max: Fraction, @@ -449,19 +445,19 @@ impl From<(Fraction, Fraction)> for FractionRange { impl glib::types::StaticType for FractionRange { fn static_type() -> glib::types::Type { - unsafe { from_glib(gst_sys::gst_fraction_range_get_type()) } + unsafe { from_glib(ffi::gst_fraction_range_get_type()) } } } impl<'a> FromValue<'a> for FractionRange { unsafe fn from_value(v: &'a Value) -> Self { - let min = gst_sys::gst_value_get_fraction_range_min(v.to_glib_none().0); - let max = gst_sys::gst_value_get_fraction_range_max(v.to_glib_none().0); + let min = ffi::gst_value_get_fraction_range_min(v.to_glib_none().0); + let max = ffi::gst_value_get_fraction_range_max(v.to_glib_none().0); - let min_n = gst_sys::gst_value_get_fraction_numerator(min); - let min_d = gst_sys::gst_value_get_fraction_denominator(min); - let max_n = gst_sys::gst_value_get_fraction_numerator(max); - let max_d = gst_sys::gst_value_get_fraction_denominator(max); + let min_n = ffi::gst_value_get_fraction_numerator(min); + let min_d = ffi::gst_value_get_fraction_denominator(min); + let max_n = ffi::gst_value_get_fraction_numerator(max); + let max_d = ffi::gst_value_get_fraction_denominator(max); Self::new((min_n, min_d), (max_n, max_d)) } @@ -475,7 +471,7 @@ impl<'a> FromValueOptional<'a> for FractionRange { impl SetValue for FractionRange { unsafe fn set_value(v: &mut Value, r: &Self) { - gst_sys::gst_value_set_fraction_range_full( + ffi::gst_value_set_fraction_range_full( v.to_glib_none_mut().0, *r.min().numer(), *r.min().denom(), @@ -486,7 +482,7 @@ impl SetValue for FractionRange { } #[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)] -#[cfg_attr(feature = "ser_de", derive(Serialize, Deserialize))] +#[cfg_attr(feature = "ser_de", derive(serde::Serialize, serde::Deserialize))] pub struct Bitmask(pub u64); impl Bitmask { @@ -551,13 +547,13 @@ impl From<u64> for Bitmask { impl glib::types::StaticType for Bitmask { fn static_type() -> glib::types::Type { - unsafe { from_glib(gst_sys::gst_bitmask_get_type()) } + unsafe { from_glib(ffi::gst_bitmask_get_type()) } } } impl<'a> FromValue<'a> for Bitmask { unsafe fn from_value(v: &'a Value) -> Self { - let v = gst_sys::gst_value_get_bitmask(v.to_glib_none().0); + let v = ffi::gst_value_get_bitmask(v.to_glib_none().0); Self::new(v) } } @@ -570,7 +566,7 @@ impl<'a> FromValueOptional<'a> for Bitmask { impl SetValue for Bitmask { unsafe fn set_value(v: &mut Value, r: &Self) { - gst_sys::gst_value_set_bitmask(v.to_glib_none_mut().0, r.0); + ffi::gst_value_set_bitmask(v.to_glib_none_mut().0, r.0); } } @@ -625,7 +621,7 @@ impl<'a> From<&'a [glib::SendValue]> for Array<'a> { impl<'a> FromValue<'a> for Array<'a> { unsafe fn from_value(v: &'a Value) -> Self { - let arr = (*v.to_glib_none().0).data[0].v_pointer as *const glib_sys::GArray; + let arr = (*v.to_glib_none().0).data[0].v_pointer as *const glib::ffi::GArray; if arr.is_null() { Array(Cow::Borrowed(&[])) } else { @@ -647,14 +643,14 @@ impl<'a> FromValueOptional<'a> for Array<'a> { impl<'a> SetValue for Array<'a> { unsafe fn set_value(v: &mut Value, a: &Self) { for value in a.as_slice() { - gst_sys::gst_value_array_append_value(v.to_glib_none_mut().0, value.to_glib_none().0); + ffi::gst_value_array_append_value(v.to_glib_none_mut().0, value.to_glib_none().0); } } } impl<'a> glib::types::StaticType for Array<'a> { fn static_type() -> glib::types::Type { - unsafe { from_glib(gst_sys::gst_value_array_get_type()) } + unsafe { from_glib(ffi::gst_value_array_get_type()) } } } @@ -709,7 +705,7 @@ impl<'a> From<&'a [glib::SendValue]> for List<'a> { impl<'a> FromValue<'a> for List<'a> { unsafe fn from_value(v: &'a Value) -> Self { - let arr = (*v.to_glib_none().0).data[0].v_pointer as *const glib_sys::GArray; + let arr = (*v.to_glib_none().0).data[0].v_pointer as *const glib::ffi::GArray; if arr.is_null() { List(Cow::Borrowed(&[])) } else { @@ -731,14 +727,14 @@ impl<'a> FromValueOptional<'a> for List<'a> { impl<'a> SetValue for List<'a> { unsafe fn set_value(v: &mut Value, a: &Self) { for value in a.as_slice() { - gst_sys::gst_value_list_append_value(v.to_glib_none_mut().0, value.to_glib_none().0); + ffi::gst_value_list_append_value(v.to_glib_none_mut().0, value.to_glib_none().0); } } } impl<'a> glib::types::StaticType for List<'a> { fn static_type() -> glib::types::Type { - unsafe { from_glib(gst_sys::gst_value_list_get_type()) } + unsafe { from_glib(ffi::gst_value_list_get_type()) } } } @@ -762,7 +758,7 @@ pub trait GstValueExt: Sized { impl GstValueExt for glib::Value { fn can_compare(&self, other: &Self) -> bool { unsafe { - from_glib(gst_sys::gst_value_can_compare( + from_glib(ffi::gst_value_can_compare( self.to_glib_none().0, other.to_glib_none().0, )) @@ -771,12 +767,12 @@ impl GstValueExt for glib::Value { fn compare(&self, other: &Self) -> Option<cmp::Ordering> { unsafe { - let val = gst_sys::gst_value_compare(self.to_glib_none().0, other.to_glib_none().0); + let val = ffi::gst_value_compare(self.to_glib_none().0, other.to_glib_none().0); match val { - gst_sys::GST_VALUE_LESS_THAN => Some(cmp::Ordering::Less), - gst_sys::GST_VALUE_EQUAL => Some(cmp::Ordering::Equal), - gst_sys::GST_VALUE_GREATER_THAN => Some(cmp::Ordering::Greater), + ffi::GST_VALUE_LESS_THAN => Some(cmp::Ordering::Less), + ffi::GST_VALUE_EQUAL => Some(cmp::Ordering::Equal), + ffi::GST_VALUE_GREATER_THAN => Some(cmp::Ordering::Greater), _ => None, } } @@ -788,7 +784,7 @@ impl GstValueExt for glib::Value { fn can_intersect(&self, other: &Self) -> bool { unsafe { - from_glib(gst_sys::gst_value_can_intersect( + from_glib(ffi::gst_value_can_intersect( self.to_glib_none().0, other.to_glib_none().0, )) @@ -798,7 +794,7 @@ impl GstValueExt for glib::Value { fn intersect(&self, other: &Self) -> Option<Self> { unsafe { let mut value = glib::Value::uninitialized(); - let ret: bool = from_glib(gst_sys::gst_value_intersect( + let ret: bool = from_glib(ffi::gst_value_intersect( value.to_glib_none_mut().0, self.to_glib_none().0, other.to_glib_none().0, @@ -813,7 +809,7 @@ impl GstValueExt for glib::Value { fn can_subtract(&self, other: &Self) -> bool { unsafe { - from_glib(gst_sys::gst_value_can_subtract( + from_glib(ffi::gst_value_can_subtract( self.to_glib_none().0, other.to_glib_none().0, )) @@ -823,7 +819,7 @@ impl GstValueExt for glib::Value { fn subtract(&self, other: &Self) -> Option<Self> { unsafe { let mut value = glib::Value::uninitialized(); - let ret: bool = from_glib(gst_sys::gst_value_subtract( + let ret: bool = from_glib(ffi::gst_value_subtract( value.to_glib_none_mut().0, self.to_glib_none().0, other.to_glib_none().0, @@ -838,7 +834,7 @@ impl GstValueExt for glib::Value { fn can_union(&self, other: &Self) -> bool { unsafe { - from_glib(gst_sys::gst_value_can_union( + from_glib(ffi::gst_value_can_union( self.to_glib_none().0, other.to_glib_none().0, )) @@ -848,7 +844,7 @@ impl GstValueExt for glib::Value { fn union(&self, other: &Self) -> Option<Self> { unsafe { let mut value = glib::Value::uninitialized(); - let ret: bool = from_glib(gst_sys::gst_value_union( + let ret: bool = from_glib(ffi::gst_value_union( value.to_glib_none_mut().0, self.to_glib_none().0, other.to_glib_none().0, @@ -864,7 +860,7 @@ impl GstValueExt for glib::Value { fn fixate(&self) -> Option<Self> { unsafe { let mut value = glib::Value::uninitialized(); - let ret: bool = from_glib(gst_sys::gst_value_fixate( + let ret: bool = from_glib(ffi::gst_value_fixate( value.to_glib_none_mut().0, self.to_glib_none().0, )); @@ -877,12 +873,12 @@ impl GstValueExt for glib::Value { } fn is_fixed(&self) -> bool { - unsafe { from_glib(gst_sys::gst_value_is_fixed(self.to_glib_none().0)) } + unsafe { from_glib(ffi::gst_value_is_fixed(self.to_glib_none().0)) } } fn is_subset(&self, superset: &Self) -> bool { unsafe { - from_glib(gst_sys::gst_value_is_subset( + from_glib(ffi::gst_value_is_subset( self.to_glib_none().0, superset.to_glib_none().0, )) @@ -891,8 +887,8 @@ impl GstValueExt for glib::Value { fn serialize(&self) -> Result<glib::GString, glib::BoolError> { unsafe { - Option::<_>::from_glib_full(gst_sys::gst_value_serialize(self.to_glib_none().0)) - .ok_or_else(|| glib_bool_error!("Failed to serialize value")) + Option::<_>::from_glib_full(ffi::gst_value_serialize(self.to_glib_none().0)) + .ok_or_else(|| glib::glib_bool_error!("Failed to serialize value")) } } @@ -903,14 +899,14 @@ impl GstValueExt for glib::Value { unsafe { let mut value = glib::Value::uninitialized(); - let ret: bool = from_glib(gst_sys::gst_value_deserialize( + let ret: bool = from_glib(ffi::gst_value_deserialize( value.to_glib_none_mut().0, s.to_glib_none().0, )); if ret { Ok(value) } else { - Err(glib_bool_error!("Failed to deserialize value")) + Err(glib::glib_bool_error!("Failed to deserialize value")) } } } @@ -920,15 +916,15 @@ impl GstValueExt for glib::Value { mod tests { #[test] fn test_fraction() { - ::init().unwrap(); + crate::init().unwrap(); - let f1 = ::Fraction::new(1, 2); - let f2 = ::Fraction::new(2, 3); + let f1 = crate::Fraction::new(1, 2); + let f2 = crate::Fraction::new(2, 3); let mut f3 = f1 * f2; let f4 = f1 * f2; f3 *= f2; f3 *= f4; - assert_eq!(f3, ::Fraction::new(2, 27)); + assert_eq!(f3, crate::Fraction::new(2, 27)); } } diff --git a/gstreamer/src/value_serde.rs b/gstreamer/src/value_serde.rs index 67f8313be..7a0824779 100644 --- a/gstreamer/src/value_serde.rs +++ b/gstreamer/src/value_serde.rs @@ -6,7 +6,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use glib; use glib::{Date, StaticType, ToValue}; use num_rational::Rational32; @@ -20,12 +19,12 @@ use std::{fmt, mem}; use once_cell::sync::Lazy; -use Buffer; -use DateTime; -use Sample; +use crate::Buffer; +use crate::DateTime; +use crate::Sample; -use date_time_serde; -use value::*; +use crate::date_time_serde; +use crate::value::*; fn get_other_type_id<T: StaticType>() -> usize { match T::static_type() { @@ -306,22 +305,19 @@ impl_de_send_value_collection!(List); #[cfg(test)] mod tests { - extern crate ron; - extern crate serde_json; - - use Array; - use Bitmask; - use DateTime; - use Fraction; - use FractionRange; - use IntRange; - use List; + use crate::Array; + use crate::Bitmask; + use crate::DateTime; + use crate::Fraction; + use crate::FractionRange; + use crate::IntRange; + use crate::List; use glib::{Date, DateMonth}; #[test] fn test_serialize_simple() { - ::init().unwrap(); + crate::init().unwrap(); let mut pretty_config = ron::ser::PrettyConfig::default(); pretty_config.new_line = "".to_string(); @@ -364,10 +360,7 @@ mod tests { #[test] fn test_serialize_collections() { - use Fraction; - use List; - - ::init().unwrap(); + crate::init().unwrap(); let mut pretty_config = ron::ser::PrettyConfig::default(); pretty_config.new_line = "".to_string(); @@ -445,7 +438,7 @@ mod tests { #[test] fn test_deserialize_simple() { - ::init().unwrap(); + crate::init().unwrap(); // Fraction let fraction_ron = "(1, 3)"; @@ -496,7 +489,7 @@ mod tests { #[test] fn test_serde_roundtrip_simple() { - ::init().unwrap(); + crate::init().unwrap(); // Fraction let fraction = Fraction::new(1, 3); @@ -537,7 +530,7 @@ mod tests { #[allow(clippy::cognitive_complexity)] #[test] fn test_deserialize_collections() { - ::init().unwrap(); + crate::init().unwrap(); // Array let array_ron = r#"[ @@ -634,7 +627,7 @@ mod tests { #[test] fn test_serde_roundtrip_collection() { - ::init().unwrap(); + crate::init().unwrap(); // Array let value_13 = Fraction::new(1, 3);