diff --git a/gst-plugin/Cargo.toml b/gst-plugin/Cargo.toml index 0458eca0..f92a30f4 100644 --- a/gst-plugin/Cargo.toml +++ b/gst-plugin/Cargo.toml @@ -14,11 +14,13 @@ slog = { version = "2.0", features = ["max_level_trace"] } lazy_static = "0.2" byteorder = "1.0" num-rational = { version = "0.1", default-features = false, features = [] } -glib-sys = "0.3.4" -gobject-sys = "0.3.4" -gstreamer-sys = { version = "0.1.1", features = ["v1_10"] } -gstreamer-base-sys = { version = "0.1.1", features = ["v1_10"] } derivative = "1.0" +glib-sys = { version = "0.3.4", git = "https://github.com/gtk-rs/sys" } +gobject-sys = { version = "0.3.4", git = "https://github.com/gtk-rs/sys" } +gstreamer-sys = { version = "0.1.1", git = "https://github.com/sdroege/gstreamer-sys", features = ["v1_10"] } +gstreamer-base-sys = { version = "0.1.1", git = "https://github.com/sdroege/gstreamer-sys", features = ["v1_10"] } +glib = { version = "0.1.3", git = "https://github.com/gtk-rs/glib" } +gstreamer = { version = "0.1.0", git = "https://github.com/sdroege/gstreamer-rs", features = ["v1_10"] } [build-dependencies] gcc = "0.3" diff --git a/gst-plugin/src/adapter.rs b/gst-plugin/src/adapter.rs index 7baab7a2..dea80178 100644 --- a/gst-plugin/src/adapter.rs +++ b/gst-plugin/src/adapter.rs @@ -256,11 +256,11 @@ impl Adapter { mod tests { use super::*; use std::ptr; - use gst; + use gst_ffi; fn init() { unsafe { - gst::gst_init(ptr::null_mut(), ptr::null_mut()); + gst_ffi::gst_init(ptr::null_mut(), ptr::null_mut()); } } diff --git a/gst-plugin/src/buffer.rs b/gst-plugin/src/buffer.rs index 1c58d2aa..55e9aef3 100644 --- a/gst-plugin/src/buffer.rs +++ b/gst-plugin/src/buffer.rs @@ -15,17 +15,17 @@ use std::usize; use miniobject::*; -use glib; -use gst; +use glib_ffi; +use gst_ffi; -pub struct Buffer(gst::GstBuffer); +pub struct Buffer(gst_ffi::GstBuffer); #[derive(Derivative)] #[derivative(Debug)] pub struct ReadBufferMap<'a> { buffer: &'a Buffer, #[derivative(Debug = "ignore")] - map_info: gst::GstMapInfo, + map_info: gst_ffi::GstMapInfo, } #[derive(Derivative)] @@ -33,7 +33,7 @@ pub struct ReadBufferMap<'a> { pub struct ReadWriteBufferMap<'a> { buffer: &'a Buffer, #[derivative(Debug = "ignore")] - map_info: gst::GstMapInfo, + map_info: gst_ffi::GstMapInfo, } #[derive(Derivative)] @@ -41,7 +41,7 @@ pub struct ReadWriteBufferMap<'a> { pub struct ReadMappedBuffer { buffer: GstRc, #[derivative(Debug = "ignore")] - map_info: gst::GstMapInfo, + map_info: gst_ffi::GstMapInfo, } #[derive(Derivative)] @@ -49,20 +49,20 @@ pub struct ReadMappedBuffer { pub struct ReadWriteMappedBuffer { buffer: GstRc, #[derivative(Debug = "ignore")] - map_info: gst::GstMapInfo, + map_info: gst_ffi::GstMapInfo, } unsafe impl MiniObject for Buffer { - type PtrType = gst::GstBuffer; + type PtrType = gst_ffi::GstBuffer; } impl Buffer { pub fn new() -> GstRc { - unsafe { GstRc::from_owned_ptr(gst::gst_buffer_new()) } + unsafe { GstRc::from_owned_ptr(gst_ffi::gst_buffer_new()) } } pub fn new_with_size(size: usize) -> Option> { - let raw = unsafe { gst::gst_buffer_new_allocate(ptr::null_mut(), size, ptr::null_mut()) }; + let raw = unsafe { gst_ffi::gst_buffer_new_allocate(ptr::null_mut(), size, ptr::null_mut()) }; if raw.is_null() { None } else { @@ -70,7 +70,7 @@ impl Buffer { } } - unsafe extern "C" fn vec_drop(vec: glib::gpointer) { + unsafe extern "C" fn vec_drop(vec: glib_ffi::gpointer) { let vec: Box> = Box::from_raw(vec as *mut Vec); drop(vec); } @@ -82,13 +82,13 @@ impl Buffer { let size = vec.len(); let data = vec.as_mut_ptr(); let user_data = Box::into_raw(vec); - gst::gst_buffer_new_wrapped_full( - gst::GstMemoryFlags::empty(), - data as glib::gpointer, + gst_ffi::gst_buffer_new_wrapped_full( + gst_ffi::GstMemoryFlags::empty(), + data as glib_ffi::gpointer, maxsize, 0, size, - user_data as glib::gpointer, + user_data as glib_ffi::gpointer, Some(Buffer::vec_drop), ) }; @@ -101,15 +101,15 @@ impl Buffer { } pub fn map_read(&self) -> Option { - let mut map_info: gst::GstMapInfo = unsafe { mem::zeroed() }; + let mut map_info: gst_ffi::GstMapInfo = unsafe { mem::zeroed() }; let res = unsafe { - gst::gst_buffer_map( - self.as_mut_ptr() as *mut gst::GstBuffer, + gst_ffi::gst_buffer_map( + self.as_mut_ptr() as *mut gst_ffi::GstBuffer, &mut map_info, - gst::GST_MAP_READ, + gst_ffi::GST_MAP_READ, ) }; - if res == glib::GTRUE { + if res == glib_ffi::GTRUE { Some(ReadBufferMap { buffer: self, map_info: map_info, @@ -120,11 +120,11 @@ impl Buffer { } pub fn map_readwrite(&mut self) -> Option { - let mut map_info: gst::GstMapInfo = unsafe { mem::zeroed() }; + let mut map_info: gst_ffi::GstMapInfo = unsafe { mem::zeroed() }; let res = unsafe { - gst::gst_buffer_map(self.as_mut_ptr(), &mut map_info, gst::GST_MAP_READWRITE) + gst_ffi::gst_buffer_map(self.as_mut_ptr(), &mut map_info, gst_ffi::GST_MAP_READWRITE) }; - if res == glib::GTRUE { + if res == glib_ffi::GTRUE { Some(ReadWriteBufferMap { buffer: self, map_info: map_info, @@ -135,10 +135,10 @@ impl Buffer { } pub fn into_read_mapped_buffer(buffer: GstRc) -> Option { - let mut map_info: gst::GstMapInfo = unsafe { mem::zeroed() }; + let mut map_info: gst_ffi::GstMapInfo = unsafe { mem::zeroed() }; let res = - unsafe { gst::gst_buffer_map(buffer.as_mut_ptr(), &mut map_info, gst::GST_MAP_READ) }; - if res == glib::GTRUE { + unsafe { gst_ffi::gst_buffer_map(buffer.as_mut_ptr(), &mut map_info, gst_ffi::GST_MAP_READ) }; + if res == glib_ffi::GTRUE { Some(ReadMappedBuffer { buffer: buffer, map_info: map_info, @@ -149,11 +149,11 @@ impl Buffer { } pub fn into_readwrite_mapped_buffer(buffer: GstRc) -> Option { - let mut map_info: gst::GstMapInfo = unsafe { mem::zeroed() }; + let mut map_info: gst_ffi::GstMapInfo = unsafe { mem::zeroed() }; let res = unsafe { - gst::gst_buffer_map(buffer.as_mut_ptr(), &mut map_info, gst::GST_MAP_READWRITE) + gst_ffi::gst_buffer_map(buffer.as_mut_ptr(), &mut map_info, gst_ffi::GST_MAP_READWRITE) }; - if res == glib::GTRUE { + if res == glib_ffi::GTRUE { Some(ReadWriteMappedBuffer { buffer: buffer, map_info: map_info, @@ -165,9 +165,9 @@ impl Buffer { pub fn append(buffer: GstRc, other: GstRc) -> GstRc { unsafe { - GstRc::from_owned_ptr(gst::gst_buffer_append( - buffer.into_ptr() as *mut gst::GstBuffer, - other.into_ptr() as *mut gst::GstBuffer, + GstRc::from_owned_ptr(gst_ffi::gst_buffer_append( + buffer.into_ptr() as *mut gst_ffi::GstBuffer, + other.into_ptr() as *mut gst_ffi::GstBuffer, )) } } @@ -176,9 +176,9 @@ impl Buffer { let size_real = size.unwrap_or(usize::MAX); let raw = unsafe { - gst::gst_buffer_copy_region( + gst_ffi::gst_buffer_copy_region( self.as_mut_ptr(), - gst::GST_BUFFER_COPY_ALL, + gst_ffi::GST_BUFFER_COPY_ALL, offset, size_real, ) @@ -199,7 +199,7 @@ impl Buffer { let copied = unsafe { let src = slice.as_ptr(); - gst::gst_buffer_fill(self.as_mut_ptr(), offset, src as glib::gconstpointer, size) + gst_ffi::gst_buffer_fill(self.as_mut_ptr(), offset, src as glib_ffi::gconstpointer, size) }; if copied == size { @@ -217,7 +217,7 @@ impl Buffer { let copied = unsafe { let dest = slice.as_mut_ptr(); - gst::gst_buffer_extract(self.as_mut_ptr(), offset, dest as glib::gpointer, size) + gst_ffi::gst_buffer_extract(self.as_mut_ptr(), offset, dest as glib_ffi::gpointer, size) }; if copied == size { @@ -228,14 +228,14 @@ impl Buffer { } pub fn get_size(&self) -> usize { - unsafe { gst::gst_buffer_get_size(self.as_mut_ptr()) } + unsafe { gst_ffi::gst_buffer_get_size(self.as_mut_ptr()) } } pub fn get_maxsize(&self) -> usize { let mut maxsize: usize = 0; unsafe { - gst::gst_buffer_get_sizes_range( + gst_ffi::gst_buffer_get_sizes_range( self.as_mut_ptr(), 0, -1, @@ -251,7 +251,7 @@ impl Buffer { assert!(self.get_maxsize() >= size); unsafe { - gst::gst_buffer_set_size(self.as_mut_ptr(), size as isize); + gst_ffi::gst_buffer_set_size(self.as_mut_ptr(), size as isize); } } @@ -391,7 +391,7 @@ impl<'a> ReadBufferMap<'a> { impl<'a> Drop for ReadBufferMap<'a> { fn drop(&mut self) { unsafe { - gst::gst_buffer_unmap(self.buffer.as_mut_ptr(), &mut self.map_info); + gst_ffi::gst_buffer_unmap(self.buffer.as_mut_ptr(), &mut self.map_info); } } } @@ -417,7 +417,7 @@ impl<'a> ReadWriteBufferMap<'a> { impl<'a> Drop for ReadWriteBufferMap<'a> { fn drop(&mut self) { unsafe { - gst::gst_buffer_unmap(self.buffer.as_mut_ptr(), &mut self.map_info); + gst_ffi::gst_buffer_unmap(self.buffer.as_mut_ptr(), &mut self.map_info); } } } @@ -439,7 +439,7 @@ impl ReadMappedBuffer { impl Drop for ReadMappedBuffer { fn drop(&mut self) { unsafe { - gst::gst_buffer_unmap(self.buffer.as_mut_ptr(), &mut self.map_info); + gst_ffi::gst_buffer_unmap(self.buffer.as_mut_ptr(), &mut self.map_info); } } } @@ -468,7 +468,7 @@ impl ReadWriteMappedBuffer { impl Drop for ReadWriteMappedBuffer { fn drop(&mut self) { unsafe { - gst::gst_buffer_unmap(self.buffer.as_mut_ptr(), &mut self.map_info); + gst_ffi::gst_buffer_unmap(self.buffer.as_mut_ptr(), &mut self.map_info); } } } @@ -476,7 +476,7 @@ impl Drop for ReadWriteMappedBuffer { unsafe impl Sync for ReadWriteMappedBuffer {} unsafe impl Send for ReadWriteMappedBuffer {} -// FIXME: Duplicate of gst::GstBufferFlags with nicer naming +// FIXME: Duplicate of gst_ffi::GstBufferFlags with nicer naming bitflags! { #[repr(C)] pub struct BufferFlags: u32 { @@ -502,7 +502,7 @@ mod tests { fn init() { unsafe { - gst::gst_init(ptr::null_mut(), ptr::null_mut()); + gst_ffi::gst_init(ptr::null_mut(), ptr::null_mut()); } } diff --git a/gst-plugin/src/caps.rs b/gst-plugin/src/caps.rs index 2630afc3..eae49bab 100644 --- a/gst-plugin/src/caps.rs +++ b/gst-plugin/src/caps.rs @@ -13,33 +13,33 @@ use value::*; use miniobject::*; use structure::*; -use glib; -use gst; +use glib_ffi; +use gst_ffi; #[repr(C)] -pub struct Caps(gst::GstCaps); +pub struct Caps(gst_ffi::GstCaps); unsafe impl MiniObject for Caps { - type PtrType = gst::GstCaps; + type PtrType = gst_ffi::GstCaps; } impl Caps { pub fn new_empty() -> GstRc { - unsafe { GstRc::from_owned_ptr(gst::gst_caps_new_empty()) } + unsafe { GstRc::from_owned_ptr(gst_ffi::gst_caps_new_empty()) } } pub fn new_any() -> GstRc { - unsafe { GstRc::from_owned_ptr(gst::gst_caps_new_any()) } + unsafe { GstRc::from_owned_ptr(gst_ffi::gst_caps_new_any()) } } pub fn new_simple(name: &str, values: &[(&str, Value)]) -> GstRc { let mut caps = Caps::new_empty(); let name_cstr = CString::new(name).unwrap(); - let structure = unsafe { gst::gst_structure_new_empty(name_cstr.as_ptr()) }; + let structure = unsafe { gst_ffi::gst_structure_new_empty(name_cstr.as_ptr()) }; unsafe { - gst::gst_caps_append_structure(caps.as_mut_ptr(), structure); + gst_ffi::gst_caps_append_structure(caps.as_mut_ptr(), structure); } caps.get_mut().unwrap().set_simple(values); @@ -51,7 +51,7 @@ impl Caps { let value_cstr = CString::new(value).unwrap(); unsafe { - let caps_ptr = gst::gst_caps_from_string(value_cstr.as_ptr()); + let caps_ptr = gst_ffi::gst_caps_from_string(value_cstr.as_ptr()); if caps_ptr.is_null() { None @@ -66,16 +66,16 @@ impl Caps { let name_cstr = CString::new(value.0).unwrap(); unsafe { let gvalue = value.1.as_ptr(); - gst::gst_caps_set_value(self.as_mut_ptr(), name_cstr.as_ptr(), gvalue); + gst_ffi::gst_caps_set_value(self.as_mut_ptr(), name_cstr.as_ptr(), gvalue); } } } pub fn to_string(&self) -> String { unsafe { - let ptr = gst::gst_caps_to_string(self.as_ptr()); + let ptr = gst_ffi::gst_caps_to_string(self.as_ptr()); let s = CStr::from_ptr(ptr).to_str().unwrap().into(); - glib::g_free(ptr as glib::gpointer); + glib_ffi::g_free(ptr as glib_ffi::gpointer); s } @@ -83,26 +83,26 @@ impl Caps { pub fn get_structure(&self, idx: u32) -> Option<&Structure> { unsafe { - let structure = gst::gst_caps_get_structure(self.as_ptr(), idx); + let structure = gst_ffi::gst_caps_get_structure(self.as_ptr(), idx); if structure.is_null() { return None; } Some(Structure::from_borrowed_ptr( - structure as *const gst::GstStructure, + structure as *const gst_ffi::GstStructure, )) } } pub fn get_mut_structure(&mut self, idx: u32) -> Option<&mut Structure> { unsafe { - let structure = gst::gst_caps_get_structure(self.as_ptr(), idx); + let structure = gst_ffi::gst_caps_get_structure(self.as_ptr(), idx); if structure.is_null() { return None; } Some(Structure::from_borrowed_mut_ptr( - structure as *mut gst::GstStructure, + structure as *mut gst_ffi::GstStructure, )) } } @@ -118,7 +118,7 @@ impl fmt::Debug for Caps { impl PartialEq for Caps { fn eq(&self, other: &Caps) -> bool { - (unsafe { gst::gst_caps_is_equal(self.as_ptr(), other.as_ptr()) } == glib::GTRUE) + (unsafe { gst_ffi::gst_caps_is_equal(self.as_ptr(), other.as_ptr()) } == glib_ffi::GTRUE) } } @@ -142,7 +142,7 @@ mod tests { fn init() { unsafe { - gst::gst_init(ptr::null_mut(), ptr::null_mut()); + gst_ffi::gst_init(ptr::null_mut(), ptr::null_mut()); } } diff --git a/gst-plugin/src/demuxer.rs b/gst-plugin/src/demuxer.rs index 86992978..6bce1231 100644 --- a/gst-plugin/src/demuxer.rs +++ b/gst-plugin/src/demuxer.rs @@ -28,8 +28,8 @@ use log::*; use caps::Caps; use plugin::Plugin; -use glib; -use gst; +use glib_ffi; +use gst_ffi; pub type StreamIndex = u32; @@ -94,14 +94,14 @@ impl Stream { } pub struct DemuxerWrapper { - raw: *mut gst::GstElement, + raw: *mut gst_ffi::GstElement, logger: Logger, demuxer: Mutex>, panicked: AtomicBool, } impl DemuxerWrapper { - fn new(raw: *mut gst::GstElement, demuxer: Box) -> DemuxerWrapper { + fn new(raw: *mut gst_ffi::GstElement, demuxer: Box) -> DemuxerWrapper { DemuxerWrapper { raw: raw, logger: Logger::root( @@ -175,44 +175,44 @@ impl DemuxerWrapper { } - fn get_position(&self, position: &mut u64) -> glib::gboolean { + fn get_position(&self, position: &mut u64) -> glib_ffi::gboolean { let demuxer = &self.demuxer.lock().unwrap(); match demuxer.get_position() { None => { trace!(self.logger, "Got no position"); *position = u64::MAX; - glib::GFALSE + glib_ffi::GFALSE } Some(pos) => { trace!(self.logger, "Returning position {}", pos); *position = pos; - glib::GTRUE + glib_ffi::GTRUE } } } - fn get_duration(&self, duration: &mut u64) -> glib::gboolean { + fn get_duration(&self, duration: &mut u64) -> glib_ffi::gboolean { let demuxer = &self.demuxer.lock().unwrap(); match demuxer.get_duration() { None => { trace!(self.logger, "Got no duration"); *duration = u64::MAX; - glib::GFALSE + glib_ffi::GFALSE } Some(dur) => { trace!(self.logger, "Returning duration {}", dur); *duration = dur; - glib::GTRUE + glib_ffi::GTRUE } } } fn seek(&self, start: u64, stop: u64, offset: &mut u64) -> bool { extern "C" { - fn gst_rs_demuxer_stream_eos(raw: *mut gst::GstElement, index: u32); + fn gst_rs_demuxer_stream_eos(raw: *mut gst_ffi::GstElement, index: u32); }; let stop = if stop == u64::MAX { None } else { Some(stop) }; @@ -255,27 +255,27 @@ impl DemuxerWrapper { } } - fn handle_buffer(&self, buffer: GstRc) -> gst::GstFlowReturn { + fn handle_buffer(&self, buffer: GstRc) -> gst_ffi::GstFlowReturn { extern "C" { - fn gst_rs_demuxer_stream_eos(raw: *mut gst::GstElement, index: u32); + fn gst_rs_demuxer_stream_eos(raw: *mut gst_ffi::GstElement, index: u32); fn gst_rs_demuxer_add_stream( - raw: *mut gst::GstElement, + raw: *mut gst_ffi::GstElement, index: u32, - caps: *const gst::GstCaps, + caps: *const gst_ffi::GstCaps, stream_id: *const c_char, ); - fn gst_rs_demuxer_added_all_streams(raw: *mut gst::GstElement); - // fn gst_rs_demuxer_remove_all_streams(raw: *mut gst::GstElement); + fn gst_rs_demuxer_added_all_streams(raw: *mut gst_ffi::GstElement); + // fn gst_rs_demuxer_remove_all_streams(raw: *mut gst_ffi::GstElement); fn gst_rs_demuxer_stream_format_changed( - raw: *mut gst::GstElement, + raw: *mut gst_ffi::GstElement, index: u32, - caps: *const gst::GstCaps, + caps: *const gst_ffi::GstCaps, ); fn gst_rs_demuxer_stream_push_buffer( - raw: *mut gst::GstElement, + raw: *mut gst_ffi::GstElement, index: u32, - buffer: *mut gst::GstBuffer, - ) -> gst::GstFlowReturn; + buffer: *mut gst_ffi::GstBuffer, + ) -> gst_ffi::GstFlowReturn; }; let mut res = { @@ -304,7 +304,7 @@ impl DemuxerWrapper { match res { HandleBufferResult::NeedMoreData => { - return gst::GST_FLOW_OK; + return gst_ffi::GST_FLOW_OK; } HandleBufferResult::StreamAdded(stream) => { let stream_id_cstr = CString::new(stream.stream_id.as_bytes()).unwrap(); @@ -342,10 +342,10 @@ impl DemuxerWrapper { gst_rs_demuxer_stream_push_buffer( self.raw, index, - buffer.into_ptr() as *mut gst::GstBuffer, + buffer.into_ptr() as *mut gst_ffi::GstBuffer, ) }; - if flow_ret != gst::GST_FLOW_OK { + if flow_ret != gst_ffi::GST_FLOW_OK { return flow_ret; } } @@ -356,7 +356,7 @@ impl DemuxerWrapper { gst_rs_demuxer_stream_eos(self.raw, index); } - return gst::GST_FLOW_EOS; + return gst_ffi::GST_FLOW_EOS; } HandleBufferResult::Again => { // nothing, just call again @@ -406,7 +406,7 @@ impl DemuxerWrapper { #[no_mangle] pub unsafe extern "C" fn demuxer_new( - demuxer: *mut gst::GstElement, + demuxer: *mut gst_ffi::GstElement, create_instance: fn(Element) -> Box, ) -> *mut DemuxerWrapper { let instance = create_instance(Element::new(demuxer)); @@ -422,41 +422,41 @@ pub unsafe extern "C" fn demuxer_drop(ptr: *mut DemuxerWrapper) { pub unsafe extern "C" fn demuxer_start( ptr: *const DemuxerWrapper, upstream_size: u64, - random_access: glib::gboolean, -) -> glib::gboolean { + random_access: glib_ffi::gboolean, +) -> glib_ffi::gboolean { let wrap: &DemuxerWrapper = &*ptr; - panic_to_error!(wrap, glib::GFALSE, { - if wrap.start(upstream_size, random_access != glib::GFALSE) { - glib::GTRUE + panic_to_error!(wrap, glib_ffi::GFALSE, { + if wrap.start(upstream_size, random_access != glib_ffi::GFALSE) { + glib_ffi::GTRUE } else { - glib::GFALSE + glib_ffi::GFALSE } }) } #[no_mangle] -pub unsafe extern "C" fn demuxer_stop(ptr: *const DemuxerWrapper) -> glib::gboolean { +pub unsafe extern "C" fn demuxer_stop(ptr: *const DemuxerWrapper) -> glib_ffi::gboolean { let wrap: &DemuxerWrapper = &*ptr; - panic_to_error!(wrap, glib::GTRUE, { + panic_to_error!(wrap, glib_ffi::GTRUE, { if wrap.stop() { - glib::GTRUE + glib_ffi::GTRUE } else { - glib::GFALSE + glib_ffi::GFALSE } }) } #[no_mangle] -pub unsafe extern "C" fn demuxer_is_seekable(ptr: *const DemuxerWrapper) -> glib::gboolean { +pub unsafe extern "C" fn demuxer_is_seekable(ptr: *const DemuxerWrapper) -> glib_ffi::gboolean { let wrap: &DemuxerWrapper = &*ptr; - panic_to_error!(wrap, glib::GFALSE, { + panic_to_error!(wrap, glib_ffi::GFALSE, { if wrap.is_seekable() { - glib::GTRUE + glib_ffi::GTRUE } else { - glib::GFALSE + glib_ffi::GFALSE } }) } @@ -465,10 +465,10 @@ pub unsafe extern "C" fn demuxer_is_seekable(ptr: *const DemuxerWrapper) -> glib pub unsafe extern "C" fn demuxer_get_position( ptr: *const DemuxerWrapper, position: *mut u64, -) -> glib::gboolean { +) -> glib_ffi::gboolean { let wrap: &DemuxerWrapper = &*ptr; - panic_to_error!(wrap, glib::GFALSE, { + panic_to_error!(wrap, glib_ffi::GFALSE, { let position = &mut *position; wrap.get_position(position) }) @@ -478,10 +478,10 @@ pub unsafe extern "C" fn demuxer_get_position( pub unsafe extern "C" fn demuxer_get_duration( ptr: *const DemuxerWrapper, duration: *mut u64, -) -> glib::gboolean { +) -> glib_ffi::gboolean { let wrap: &DemuxerWrapper = &*ptr; - panic_to_error!(wrap, glib::GFALSE, { + panic_to_error!(wrap, glib_ffi::GFALSE, { let duration = &mut *duration; wrap.get_duration(duration) }) @@ -493,17 +493,17 @@ pub unsafe extern "C" fn demuxer_seek( start: u64, stop: u64, offset: *mut u64, -) -> glib::gboolean { +) -> glib_ffi::gboolean { let wrap: &mut DemuxerWrapper = &mut *ptr; - panic_to_error!(wrap, glib::GFALSE, { + panic_to_error!(wrap, glib_ffi::GFALSE, { let offset = &mut *offset; if wrap.seek(start, stop, offset) { - glib::GTRUE + glib_ffi::GTRUE } else { - glib::GFALSE + glib_ffi::GFALSE } }) } @@ -511,11 +511,11 @@ pub unsafe extern "C" fn demuxer_seek( #[no_mangle] pub unsafe extern "C" fn demuxer_handle_buffer( ptr: *mut DemuxerWrapper, - buffer: *mut gst::GstBuffer, -) -> gst::GstFlowReturn { + buffer: *mut gst_ffi::GstBuffer, +) -> gst_ffi::GstFlowReturn { let wrap: &mut DemuxerWrapper = &mut *ptr; - panic_to_error!(wrap, gst::GST_FLOW_ERROR, { + panic_to_error!(wrap, gst_ffi::GST_FLOW_ERROR, { let buffer = GstRc::from_owned_ptr(buffer); wrap.handle_buffer(buffer) }) @@ -545,7 +545,7 @@ pub struct DemuxerInfo<'a> { pub fn demuxer_register(plugin: &Plugin, demuxer_info: &DemuxerInfo) { extern "C" { fn gst_rs_demuxer_register( - plugin: *const gst::GstPlugin, + plugin: *const gst_ffi::GstPlugin, name: *const c_char, long_name: *const c_char, description: *const c_char, @@ -553,9 +553,9 @@ pub fn demuxer_register(plugin: &Plugin, demuxer_info: &DemuxerInfo) { author: *const c_char, rank: i32, create_instance: *const c_void, - input_caps: *const gst::GstCaps, - output_caps: *const gst::GstCaps, - ) -> glib::gboolean; + input_caps: *const gst_ffi::GstCaps, + output_caps: *const gst_ffi::GstCaps, + ) -> glib_ffi::gboolean; } let cname = CString::new(demuxer_info.name).unwrap(); diff --git a/gst-plugin/src/error.rs b/gst-plugin/src/error.rs index cef7ccb9..0fb5b9ec 100644 --- a/gst-plugin/src/error.rs +++ b/gst-plugin/src/error.rs @@ -16,8 +16,8 @@ use std::borrow::Cow; use url::Url; -use glib; -use gst; +use glib_ffi; +use gst_ffi; #[macro_export] macro_rules! error_msg( @@ -61,12 +61,12 @@ pub trait ToGError { fn to_gerror(&self) -> (u32, i32); } -pub fn gst_library_error_domain() -> glib::GQuark { - unsafe { gst::gst_library_error_quark() } +pub fn gst_library_error_domain() -> glib_ffi::GQuark { + unsafe { gst_ffi::gst_library_error_quark() } } -pub fn gst_resource_error_domain() -> glib::GQuark { - unsafe { gst::gst_resource_error_quark() } +pub fn gst_resource_error_domain() -> glib_ffi::GQuark { + unsafe { gst_ffi::gst_resource_error_quark() } } #[derive(Debug)] @@ -103,7 +103,7 @@ impl ErrorMessage { } - pub unsafe fn post(&self, element: *mut gst::GstElement) { + pub unsafe fn post(&self, element: *mut gst_ffi::GstElement) { let ErrorMessage { error_domain, error_code, @@ -126,13 +126,13 @@ impl ErrorMessage { let function_cstr = CString::new(function.as_bytes()).unwrap(); let function_ptr = function_cstr.as_ptr(); - gst::gst_element_message_full( + gst_ffi::gst_element_message_full( element, - gst::GST_MESSAGE_ERROR, + gst_ffi::GST_MESSAGE_ERROR, error_domain, error_code, - glib::g_strndup(message_ptr, message_len), - glib::g_strndup(debug_ptr, debug_len), + glib_ffi::g_strndup(message_ptr, message_len), + glib_ffi::g_strndup(debug_ptr, debug_len), file_ptr, function_ptr, line as i32, @@ -149,12 +149,12 @@ pub enum FlowError { } impl FlowError { - pub fn to_native(&self) -> gst::GstFlowReturn { + pub fn to_native(&self) -> gst_ffi::GstFlowReturn { match *self { - FlowError::Flushing => gst::GST_FLOW_FLUSHING, - FlowError::Eos => gst::GST_FLOW_EOS, - FlowError::NotNegotiated(..) => gst::GST_FLOW_NOT_NEGOTIATED, - FlowError::Error(..) => gst::GST_FLOW_ERROR, + FlowError::Flushing => gst_ffi::GST_FLOW_FLUSHING, + FlowError::Eos => gst_ffi::GST_FLOW_EOS, + FlowError::NotNegotiated(..) => gst_ffi::GST_FLOW_NOT_NEGOTIATED, + FlowError::Error(..) => gst_ffi::GST_FLOW_ERROR, } } } @@ -220,19 +220,19 @@ impl UriError { &self.error_kind } - pub unsafe fn into_gerror(self, err: *mut *mut glib::GError) { + pub unsafe fn into_gerror(self, err: *mut *mut glib_ffi::GError) { if let Some(msg) = self.message { let cmsg = CString::new(msg.as_str()).unwrap(); - glib::g_set_error_literal( + glib_ffi::g_set_error_literal( err, - gst::gst_uri_error_quark(), + gst_ffi::gst_uri_error_quark(), self.error_kind as i32, cmsg.as_ptr(), ); } else { - glib::g_set_error_literal( + glib_ffi::g_set_error_literal( err, - gst::gst_uri_error_quark(), + gst_ffi::gst_uri_error_quark(), self.error_kind as i32, ptr::null(), ); diff --git a/gst-plugin/src/lib.rs b/gst-plugin/src/lib.rs index 1d5f41b0..28259079 100644 --- a/gst-plugin/src/lib.rs +++ b/gst-plugin/src/lib.rs @@ -19,10 +19,12 @@ extern crate byteorder; extern crate num_rational; #[macro_use] extern crate derivative; -pub extern crate gobject_sys as gobject; -pub extern crate glib_sys as glib; -pub extern crate gstreamer_sys as gst; -pub extern crate gstreamer_base_sys as gst_base; +pub extern crate gobject_sys as gobject_ffi; +pub extern crate glib_sys as glib_ffi; +pub extern crate gstreamer_sys as gst_ffi; +pub extern crate gstreamer_base_sys as gst_base_ffi; + +pub extern crate gstreamer as gst; #[macro_use] pub mod utils; @@ -45,7 +47,7 @@ pub mod miniobject; pub mod structure; pub mod ffi { - pub use glib; - pub use gobject; - pub use gst; + pub use glib_ffi as glib; + pub use gobject_ffi as gobject; + pub use gst_ffi as gst; } diff --git a/gst-plugin/src/log.rs b/gst-plugin/src/log.rs index ff31b1a5..3be274ac 100644 --- a/gst-plugin/src/log.rs +++ b/gst-plugin/src/log.rs @@ -15,12 +15,12 @@ use std::mem; use utils::Element; -use gobject; -use gst; +use gobject_ffi; +use gst_ffi; pub struct GstDebugDrain { - category: *mut gst::GstDebugCategory, - element: Box, + category: *mut gst_ffi::GstDebugCategory, + element: Box, } impl GstDebugDrain { @@ -35,7 +35,7 @@ impl GstDebugDrain { name: *const c_char, color: u32, description: *const c_char, - ) -> *mut gst::GstDebugCategory; + ) -> *mut gst_ffi::GstDebugCategory; } let name_cstr = CString::new(name.as_bytes()).unwrap(); @@ -58,7 +58,7 @@ impl GstDebugDrain { if !element.is_null() { unsafe { - gobject::g_weak_ref_set(&mut *drain.element, element as *mut gobject::GObject); + gobject_ffi::g_weak_ref_set(&mut *drain.element, element as *mut gobject_ffi::GObject); } } @@ -69,7 +69,7 @@ impl GstDebugDrain { impl Drop for GstDebugDrain { fn drop(&mut self) { unsafe { - gobject::g_weak_ref_clear(&mut *self.element); + gobject_ffi::g_weak_ref_clear(&mut *self.element); } } } @@ -80,14 +80,14 @@ impl Drain for GstDebugDrain { fn log(&self, record: &Record, _: &OwnedKVList) -> Result<(), Never> { let level = match record.level() { - Level::Critical | Level::Error => gst::GST_LEVEL_ERROR, - Level::Warning => gst::GST_LEVEL_WARNING, - Level::Info => gst::GST_LEVEL_INFO, - Level::Debug => gst::GST_LEVEL_DEBUG, - Level::Trace => gst::GST_LEVEL_TRACE, + Level::Critical | Level::Error => gst_ffi::GST_LEVEL_ERROR, + Level::Warning => gst_ffi::GST_LEVEL_WARNING, + Level::Info => gst_ffi::GST_LEVEL_INFO, + Level::Debug => gst_ffi::GST_LEVEL_DEBUG, + Level::Trace => gst_ffi::GST_LEVEL_TRACE, }; - let threshold = unsafe { gst::gst_debug_category_get_threshold(self.category) }; + let threshold = unsafe { gst_ffi::gst_debug_category_get_threshold(self.category) }; if level as u32 > threshold as u32 { return Ok(()); @@ -101,22 +101,22 @@ impl Drain for GstDebugDrain { let message_cstr = CString::new(fmt::format(*record.msg()).as_bytes()).unwrap(); unsafe { - let element = gobject::g_weak_ref_get( - &*self.element as *const gobject::GWeakRef as *mut gobject::GWeakRef, + let element = gobject_ffi::g_weak_ref_get( + &*self.element as *const gobject_ffi::GWeakRef as *mut gobject_ffi::GWeakRef, ); - gst::gst_debug_log( + gst_ffi::gst_debug_log( self.category, level, file_cstr.as_ptr(), function_cstr.as_ptr(), record.line() as i32, - element as *mut gobject::GObject, + element as *mut gobject_ffi::GObject, message_cstr.as_ptr(), ); if !element.is_null() { - gst::gst_object_unref(element as *mut gst::GstObject); + gst_ffi::gst_object_unref(element as *mut gst_ffi::GstObject); } } diff --git a/gst-plugin/src/miniobject.rs b/gst-plugin/src/miniobject.rs index 473edcc3..230fc71a 100644 --- a/gst-plugin/src/miniobject.rs +++ b/gst-plugin/src/miniobject.rs @@ -10,8 +10,8 @@ use std::{borrow, fmt, ops}; use std::mem; use std::marker::PhantomData; -use glib; -use gst; +use glib_ffi; +use gst_ffi; #[derive(Hash, Debug, PartialEq, Eq, PartialOrd, Ord)] pub struct GstRc(*mut T, PhantomData); @@ -21,7 +21,7 @@ impl GstRc { assert!(!obj.is_null()); if !owned { - gst::gst_mini_object_ref((&*obj).as_ptr() as *mut gst::GstMiniObject); + gst_ffi::gst_mini_object_ref((&*obj).as_ptr() as *mut gst_ffi::GstMiniObject); } GstRc(obj as *mut T, PhantomData) @@ -42,7 +42,7 @@ impl GstRc { } self.0 = T::from_mut_ptr( - gst::gst_mini_object_make_writable(self.as_mut_ptr() as *mut gst::GstMiniObject) as + gst_ffi::gst_mini_object_make_writable(self.as_mut_ptr() as *mut gst_ffi::GstMiniObject) as *mut T::PtrType, ); assert!(self.is_writable()); @@ -62,15 +62,15 @@ impl GstRc { pub fn copy(&self) -> Self { unsafe { GstRc::from_owned_ptr( - gst::gst_mini_object_copy(self.as_ptr() as *const gst::GstMiniObject) as + gst_ffi::gst_mini_object_copy(self.as_ptr() as *const gst_ffi::GstMiniObject) as *const T::PtrType, ) } } fn is_writable(&self) -> bool { - (unsafe { gst::gst_mini_object_is_writable(self.as_ptr() as *const gst::GstMiniObject) } == - glib::GTRUE) + (unsafe { gst_ffi::gst_mini_object_is_writable(self.as_ptr() as *const gst_ffi::GstMiniObject) } == + glib_ffi::GTRUE) } pub unsafe fn into_ptr(self) -> *mut T::PtrType { @@ -118,7 +118,7 @@ impl Clone for GstRc { impl Drop for GstRc { fn drop(&mut self) { unsafe { - gst::gst_mini_object_unref(self.as_ptr() as *mut gst::GstMiniObject); + gst_ffi::gst_mini_object_unref(self.as_ptr() as *mut gst_ffi::GstMiniObject); } } } diff --git a/gst-plugin/src/plugin.rs b/gst-plugin/src/plugin.rs index 15688d31..8a7fe59a 100644 --- a/gst-plugin/src/plugin.rs +++ b/gst-plugin/src/plugin.rs @@ -6,16 +6,16 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use gst; +use gst_ffi; -pub struct Plugin(*mut gst::GstPlugin); +pub struct Plugin(*mut gst_ffi::GstPlugin); impl Plugin { - pub unsafe fn new(plugin: *mut gst::GstPlugin) -> Plugin { + pub unsafe fn new(plugin: *mut gst_ffi::GstPlugin) -> Plugin { Plugin(plugin) } - pub unsafe fn as_ptr(&self) -> *mut gst::GstPlugin { + pub unsafe fn as_ptr(&self) -> *mut gst_ffi::GstPlugin { self.0 } } @@ -27,20 +27,18 @@ macro_rules! plugin_define( $package:expr, $origin:expr, $release_datetime:expr) => { pub mod plugin_desc { use $crate::plugin::Plugin; - use $crate::ffi::gst; - use $crate::ffi::glib; // Not using c_char here because it requires the libc crate #[allow(non_camel_case_types)] type c_char = i8; #[repr(C)] - pub struct GstPluginDesc(gst::GstPluginDesc); + pub struct GstPluginDesc($crate::ffi::gst::GstPluginDesc); unsafe impl Sync for GstPluginDesc {} #[no_mangle] #[allow(non_upper_case_globals)] - pub static gst_plugin_desc: GstPluginDesc = GstPluginDesc(gst::GstPluginDesc { + pub static gst_plugin_desc: GstPluginDesc = GstPluginDesc($crate::ffi::gst::GstPluginDesc { major_version: 1, minor_version: 10, name: $name as *const u8 as *const c_char, @@ -52,14 +50,14 @@ macro_rules! plugin_define( package: $package as *const u8 as *const c_char, origin: $origin as *const u8 as *const c_char, release_datetime: $release_datetime as *const u8 as *const c_char, - _gst_reserved: [0 as glib::gpointer; 4], + _gst_reserved: [0 as $crate::ffi::glib::gpointer; 4], }); - unsafe extern "C" fn plugin_init_trampoline(plugin: *mut gst::GstPlugin) -> glib::gboolean { + unsafe extern "C" fn plugin_init_trampoline(plugin: *mut $crate::ffi::gst::GstPlugin) -> $crate::ffi::glib::gboolean { if super::$plugin_init(&Plugin::new(plugin)) { - glib::GTRUE + $crate::ffi::glib::GTRUE } else { - glib::GFALSE + $crate::ffi::glib::GFALSE } } } diff --git a/gst-plugin/src/sink.rs b/gst-plugin/src/sink.rs index 6759a006..744bb611 100644 --- a/gst-plugin/src/sink.rs +++ b/gst-plugin/src/sink.rs @@ -29,10 +29,10 @@ use log::*; use plugin::Plugin; use caps::*; -use glib; -use gobject; -use gst; -use gst_base; +use glib_ffi; +use gobject_ffi; +use gst_ffi; +use gst_base_ffi; #[derive(Debug)] pub enum SinkError { @@ -56,7 +56,7 @@ impl ToGError for SinkError { } pub struct SinkWrapper { - raw: *mut gst::GstElement, + raw: *mut gst_ffi::GstElement, logger: Logger, uri: Mutex<(Option, bool)>, uri_validator: Box, @@ -74,7 +74,7 @@ pub trait Sink { } impl SinkWrapper { - fn new(raw: *mut gst::GstElement, sink: Box) -> SinkWrapper { + fn new(raw: *mut gst_ffi::GstElement, sink: Box) -> SinkWrapper { SinkWrapper { raw: raw, logger: Logger::root( @@ -181,13 +181,13 @@ impl SinkWrapper { } } - fn render(&self, buffer: &Buffer) -> gst::GstFlowReturn { + fn render(&self, buffer: &Buffer) -> gst_ffi::GstFlowReturn { let sink = &mut self.sink.lock().unwrap(); trace!(self.logger, "Rendering buffer {:?}", buffer); match sink.render(buffer) { - Ok(..) => gst::GST_FLOW_OK, + Ok(..) => gst_ffi::GST_FLOW_OK, Err(flow_error) => { error!(self.logger, "Failed to render: {:?}", flow_error); match flow_error { @@ -211,12 +211,12 @@ impl SinkWrapper { unsafe fn sink_set_uri( ptr: *const RsSink, uri_ptr: *const c_char, - cerr: *mut *mut glib::GError, -) -> glib::gboolean { + cerr: *mut *mut glib_ffi::GError, +) -> glib_ffi::gboolean { let sink = &*(ptr as *const RsSink); let wrap: &SinkWrapper = &*sink.wrap; - panic_to_error!(wrap, glib::GFALSE, { + panic_to_error!(wrap, glib_ffi::GFALSE, { let uri_str = if uri_ptr.is_null() { None } else { @@ -227,9 +227,9 @@ unsafe fn sink_set_uri( Err(err) => { error!(wrap.logger, "Failed to set URI {:?}", err); err.into_gerror(cerr); - glib::GFALSE + glib_ffi::GFALSE } - Ok(_) => glib::GTRUE, + Ok(_) => glib_ffi::GTRUE, } }) } @@ -240,47 +240,47 @@ unsafe fn sink_get_uri(ptr: *const RsSink) -> *mut c_char { panic_to_error!(wrap, ptr::null_mut(), { match wrap.get_uri() { - Some(uri_str) => glib::g_strndup(uri_str.as_ptr() as *const c_char, uri_str.len()), + Some(uri_str) => glib_ffi::g_strndup(uri_str.as_ptr() as *const c_char, uri_str.len()), None => ptr::null_mut(), } }) } -unsafe extern "C" fn sink_start(ptr: *mut gst_base::GstBaseSink) -> glib::gboolean { +unsafe extern "C" fn sink_start(ptr: *mut gst_base_ffi::GstBaseSink) -> glib_ffi::gboolean { let sink = &*(ptr as *const RsSink); let wrap: &SinkWrapper = &*sink.wrap; - panic_to_error!(wrap, glib::GFALSE, { + panic_to_error!(wrap, glib_ffi::GFALSE, { if wrap.start() { - glib::GTRUE + glib_ffi::GTRUE } else { - glib::GFALSE + glib_ffi::GFALSE } }) } -unsafe extern "C" fn sink_stop(ptr: *mut gst_base::GstBaseSink) -> glib::gboolean { +unsafe extern "C" fn sink_stop(ptr: *mut gst_base_ffi::GstBaseSink) -> glib_ffi::gboolean { let sink = &*(ptr as *const RsSink); let wrap: &SinkWrapper = &*sink.wrap; - panic_to_error!(wrap, glib::GTRUE, { + panic_to_error!(wrap, glib_ffi::GTRUE, { if wrap.stop() { - glib::GTRUE + glib_ffi::GTRUE } else { - glib::GFALSE + glib_ffi::GFALSE } }) } unsafe extern "C" fn sink_render( - ptr: *mut gst_base::GstBaseSink, - buffer: *mut gst::GstBuffer, -) -> gst::GstFlowReturn { + ptr: *mut gst_base_ffi::GstBaseSink, + buffer: *mut gst_ffi::GstBuffer, +) -> gst_ffi::GstFlowReturn { let sink = &*(ptr as *const RsSink); let wrap: &SinkWrapper = &*sink.wrap; let buffer: &Buffer = Buffer::from_ptr(buffer); - panic_to_error!(wrap, gst::GST_FLOW_ERROR, { wrap.render(buffer) }) + panic_to_error!(wrap, gst_ffi::GST_FLOW_ERROR, { wrap.render(buffer) }) } pub struct SinkInfo { @@ -296,40 +296,40 @@ pub struct SinkInfo { #[repr(C)] struct RsSink { - parent: gst_base::GstBaseSink, + parent: gst_base_ffi::GstBaseSink, wrap: *mut SinkWrapper, sink_info: *const SinkInfo, } #[repr(C)] struct RsSinkClass { - parent_class: gst_base::GstBaseSinkClass, + parent_class: gst_base_ffi::GstBaseSinkClass, sink_info: *const SinkInfo, protocols: *const Vec<*const c_char>, - parent_vtable: glib::gconstpointer, + parent_vtable: glib_ffi::gconstpointer, } -unsafe extern "C" fn sink_finalize(obj: *mut gobject::GObject) { +unsafe extern "C" fn sink_finalize(obj: *mut gobject_ffi::GObject) { let sink = &mut *(obj as *mut RsSink); drop(Box::from_raw(sink.wrap)); let sink_klass = &**(obj as *const *const RsSinkClass); - let parent_klass = &*(sink_klass.parent_vtable as *const gobject::GObjectClass); + let parent_klass = &*(sink_klass.parent_vtable as *const gobject_ffi::GObjectClass); parent_klass.finalize.map(|f| f(obj)); } unsafe extern "C" fn sink_set_property( - obj: *mut gobject::GObject, + obj: *mut gobject_ffi::GObject, id: u32, - value: *mut gobject::GValue, - _pspec: *mut gobject::GParamSpec, + value: *mut gobject_ffi::GValue, + _pspec: *mut gobject_ffi::GParamSpec, ) { let sink = &*(obj as *const RsSink); match id { 1 => { - let uri_ptr = gobject::g_value_get_string(value); + let uri_ptr = gobject_ffi::g_value_get_string(value); sink_set_uri(sink, uri_ptr, ptr::null_mut()); } _ => unreachable!(), @@ -337,23 +337,23 @@ unsafe extern "C" fn sink_set_property( } unsafe extern "C" fn sink_get_property( - obj: *mut gobject::GObject, + obj: *mut gobject_ffi::GObject, id: u32, - value: *mut gobject::GValue, - _pspec: *mut gobject::GParamSpec, + value: *mut gobject_ffi::GValue, + _pspec: *mut gobject_ffi::GParamSpec, ) { let sink = &*(obj as *const RsSink); match id { 1 => { let uri_ptr = sink_get_uri(sink); - gobject::g_value_take_string(value, uri_ptr); + gobject_ffi::g_value_take_string(value, uri_ptr); } _ => unreachable!(), } } -unsafe extern "C" fn sink_class_init(klass: glib::gpointer, klass_data: glib::gpointer) { +unsafe extern "C" fn sink_class_init(klass: glib_ffi::gpointer, klass_data: glib_ffi::gpointer) { let sink_klass = &mut *(klass as *mut RsSinkClass); let sink_info = &*(klass_data as *const SinkInfo); @@ -371,15 +371,15 @@ unsafe extern "C" fn sink_class_init(klass: glib::gpointer, klass_data: glib::gp let nick_cstr = CString::new("URI").unwrap(); let blurb_cstr = CString::new("URI to read from").unwrap(); - gobject::g_object_class_install_property( - klass as *mut gobject::GObjectClass, + gobject_ffi::g_object_class_install_property( + klass as *mut gobject_ffi::GObjectClass, 1, - gobject::g_param_spec_string( + gobject_ffi::g_param_spec_string( name_cstr.as_ptr(), nick_cstr.as_ptr(), blurb_cstr.as_ptr(), ptr::null_mut(), - gobject::G_PARAM_READWRITE, + gobject_ffi::G_PARAM_READWRITE, ), ); } @@ -392,7 +392,7 @@ unsafe extern "C" fn sink_class_init(klass: glib::gpointer, klass_data: glib::gp let description_cstr = CString::new(sink_info.classification.clone()).unwrap(); let author_cstr = CString::new(sink_info.author.clone()).unwrap(); - gst::gst_element_class_set_static_metadata( + gst_ffi::gst_element_class_set_static_metadata( element_klass, longname_cstr.into_raw(), classification_cstr.into_raw(), @@ -402,13 +402,13 @@ unsafe extern "C" fn sink_class_init(klass: glib::gpointer, klass_data: glib::gp let caps = Caps::new_any(); let templ_name = CString::new("sink").unwrap(); - let pad_template = gst::gst_pad_template_new( + let pad_template = gst_ffi::gst_pad_template_new( templ_name.into_raw(), - gst::GST_PAD_SINK, - gst::GST_PAD_ALWAYS, - caps.as_ptr() as *mut gst::GstCaps, + gst_ffi::GST_PAD_SINK, + gst_ffi::GST_PAD_ALWAYS, + caps.as_ptr() as *mut gst_ffi::GstCaps, ); - gst::gst_element_class_add_pad_template(element_klass, pad_template); + gst_ffi::gst_element_class_add_pad_template(element_klass, pad_template); } { @@ -426,10 +426,10 @@ unsafe extern "C" fn sink_class_init(klass: glib::gpointer, klass_data: glib::gp } protocols.push(ptr::null()); sink_klass.protocols = Box::into_raw(protocols) as *const Vec<*const c_char>; - sink_klass.parent_vtable = gobject::g_type_class_peek_parent(klass); + sink_klass.parent_vtable = gobject_ffi::g_type_class_peek_parent(klass); } -unsafe extern "C" fn sink_init(instance: *mut gobject::GTypeInstance, klass: glib::gpointer) { +unsafe extern "C" fn sink_init(instance: *mut gobject_ffi::GTypeInstance, klass: glib_ffi::gpointer) { let sink = &mut *(instance as *mut RsSink); let sink_klass = &*(klass as *const RsSinkClass); let sink_info = &*sink_klass.sink_info; @@ -442,33 +442,33 @@ unsafe extern "C" fn sink_init(instance: *mut gobject::GTypeInstance, klass: gli )); sink.wrap = Box::into_raw(wrap); - gst_base::gst_base_sink_set_sync(&mut sink.parent, glib::GFALSE); + gst_base_ffi::gst_base_sink_set_sync(&mut sink.parent, glib_ffi::GFALSE); } -unsafe extern "C" fn sink_uri_handler_get_type(_type: glib::GType) -> gst::GstURIType { - gst::GST_URI_SINK +unsafe extern "C" fn sink_uri_handler_get_type(_type: glib_ffi::GType) -> gst_ffi::GstURIType { + gst_ffi::GST_URI_SINK } -unsafe extern "C" fn sink_uri_handler_get_protocols(type_: glib::GType) -> *const *const c_char { - let klass = gobject::g_type_class_peek(type_); +unsafe extern "C" fn sink_uri_handler_get_protocols(type_: glib_ffi::GType) -> *const *const c_char { + let klass = gobject_ffi::g_type_class_peek(type_); let sink_klass = &*(klass as *const RsSinkClass); (*sink_klass.protocols).as_ptr() } -unsafe extern "C" fn sink_uri_handler_get_uri(uri_handler: *mut gst::GstURIHandler) -> *mut c_char { +unsafe extern "C" fn sink_uri_handler_get_uri(uri_handler: *mut gst_ffi::GstURIHandler) -> *mut c_char { sink_get_uri(uri_handler as *const RsSink) } unsafe extern "C" fn sink_uri_handler_set_uri( - uri_handler: *mut gst::GstURIHandler, + uri_handler: *mut gst_ffi::GstURIHandler, uri: *const c_char, - err: *mut *mut glib::GError, -) -> glib::gboolean { + err: *mut *mut glib_ffi::GError, +) -> glib_ffi::gboolean { sink_set_uri(uri_handler as *const RsSink, uri, err) } -unsafe extern "C" fn sink_uri_handler_init(iface: glib::gpointer, _iface_data: glib::gpointer) { - let uri_handler_iface = &mut *(iface as *mut gst::GstURIHandlerInterface); +unsafe extern "C" fn sink_uri_handler_init(iface: glib_ffi::gpointer, _iface_data: glib_ffi::gpointer) { + let uri_handler_iface = &mut *(iface as *mut gst_ffi::GstURIHandlerInterface); uri_handler_iface.get_type = Some(sink_uri_handler_get_type); uri_handler_iface.get_protocols = Some(sink_uri_handler_get_protocols); @@ -478,7 +478,7 @@ unsafe extern "C" fn sink_uri_handler_init(iface: glib::gpointer, _iface_data: g pub fn sink_register(plugin: &Plugin, sink_info: SinkInfo) { unsafe { - let parent_type = gst_base::gst_base_sink_get_type(); + let parent_type = gst_base_ffi::gst_base_sink_get_type(); let mut type_name = String::from("RsSink-"); type_name.push_str(&sink_info.name); let type_name_cstr = CString::new(type_name.into_bytes()).unwrap(); @@ -487,9 +487,9 @@ pub fn sink_register(plugin: &Plugin, sink_info: SinkInfo) { let rank = sink_info.rank; let sink_info = Box::new(sink_info); - let sink_info_ptr = Box::into_raw(sink_info) as glib::gpointer; + let sink_info_ptr = Box::into_raw(sink_info) as glib_ffi::gpointer; - let type_info = gobject::GTypeInfo { + let type_info = gobject_ffi::GTypeInfo { class_size: mem::size_of::() as u16, base_init: None, base_finalize: None, @@ -502,20 +502,20 @@ pub fn sink_register(plugin: &Plugin, sink_info: SinkInfo) { value_table: ptr::null(), }; - let type_ = gobject::g_type_register_static( + let type_ = gobject_ffi::g_type_register_static( parent_type, type_name_cstr.as_ptr(), &type_info, - gobject::GTypeFlags::empty(), + gobject_ffi::GTypeFlags::empty(), ); - let iface_info = gobject::GInterfaceInfo { + let iface_info = gobject_ffi::GInterfaceInfo { interface_init: Some(sink_uri_handler_init), interface_finalize: None, interface_data: ptr::null_mut(), }; - gobject::g_type_add_interface_static(type_, gst::gst_uri_handler_get_type(), &iface_info); + gobject_ffi::g_type_add_interface_static(type_, gst_ffi::gst_uri_handler_get_type(), &iface_info); - gst::gst_element_register(plugin.as_ptr(), name_cstr.as_ptr(), rank, type_); + gst_ffi::gst_element_register(plugin.as_ptr(), name_cstr.as_ptr(), rank, type_); } } diff --git a/gst-plugin/src/source.rs b/gst-plugin/src/source.rs index bfc80d2e..c694a7be 100644 --- a/gst-plugin/src/source.rs +++ b/gst-plugin/src/source.rs @@ -29,10 +29,10 @@ use miniobject::*; use log::*; use caps::*; -use glib; -use gobject; -use gst; -use gst_base; +use glib_ffi; +use gobject_ffi; +use gst_ffi; +use gst_base_ffi; #[derive(Debug)] pub enum SourceError { @@ -56,7 +56,7 @@ impl ToGError for SourceError { } pub struct SourceWrapper { - raw: *mut gst::GstElement, + raw: *mut gst_ffi::GstElement, logger: Logger, uri: Mutex<(Option, bool)>, uri_validator: Box, @@ -77,7 +77,7 @@ pub trait Source { } impl SourceWrapper { - fn new(raw: *mut gst::GstElement, source: Box) -> SourceWrapper { + fn new(raw: *mut gst_ffi::GstElement, source: Box) -> SourceWrapper { SourceWrapper { raw: raw, logger: Logger::root( @@ -194,7 +194,7 @@ impl SourceWrapper { } } - fn fill(&self, offset: u64, length: u32, buffer: &mut Buffer) -> gst::GstFlowReturn { + fn fill(&self, offset: u64, length: u32, buffer: &mut Buffer) -> gst_ffi::GstFlowReturn { let source = &mut self.source.lock().unwrap(); trace!( @@ -206,7 +206,7 @@ impl SourceWrapper { ); match source.fill(offset, length, buffer) { - Ok(()) => gst::GST_FLOW_OK, + Ok(()) => gst_ffi::GST_FLOW_OK, Err(flow_error) => { error!(self.logger, "Failed to fill: {:?}", flow_error); match flow_error { @@ -245,12 +245,12 @@ impl SourceWrapper { unsafe fn source_set_uri( ptr: *const RsSrc, uri_ptr: *const c_char, - cerr: *mut *mut glib::GError, -) -> glib::gboolean { + cerr: *mut *mut glib_ffi::GError, +) -> glib_ffi::gboolean { let src = &*(ptr as *const RsSrc); let wrap: &SourceWrapper = &*src.wrap; - panic_to_error!(wrap, glib::GFALSE, { + panic_to_error!(wrap, glib_ffi::GFALSE, { let uri_str = if uri_ptr.is_null() { None } else { @@ -261,9 +261,9 @@ unsafe fn source_set_uri( Err(err) => { error!(wrap.logger, "Failed to set URI {:?}", err); err.into_gerror(cerr); - glib::GFALSE + glib_ffi::GFALSE } - Ok(_) => glib::GTRUE, + Ok(_) => glib_ffi::GTRUE, } }) } @@ -274,96 +274,96 @@ unsafe fn source_get_uri(ptr: *const RsSrc) -> *mut c_char { panic_to_error!(wrap, ptr::null_mut(), { match wrap.get_uri() { - Some(uri_str) => glib::g_strndup(uri_str.as_ptr() as *const c_char, uri_str.len()), + Some(uri_str) => glib_ffi::g_strndup(uri_str.as_ptr() as *const c_char, uri_str.len()), None => ptr::null_mut(), } }) } -unsafe extern "C" fn source_is_seekable(ptr: *mut gst_base::GstBaseSrc) -> glib::gboolean { +unsafe extern "C" fn source_is_seekable(ptr: *mut gst_base_ffi::GstBaseSrc) -> glib_ffi::gboolean { let src = &*(ptr as *const RsSrc); let wrap: &SourceWrapper = &*src.wrap; - panic_to_error!(wrap, glib::GFALSE, { + panic_to_error!(wrap, glib_ffi::GFALSE, { if wrap.is_seekable() { - glib::GTRUE + glib_ffi::GTRUE } else { - glib::GFALSE + glib_ffi::GFALSE } }) } unsafe extern "C" fn source_get_size( - ptr: *mut gst_base::GstBaseSrc, + ptr: *mut gst_base_ffi::GstBaseSrc, size: *mut u64, -) -> glib::gboolean { +) -> glib_ffi::gboolean { let src = &*(ptr as *const RsSrc); let wrap: &SourceWrapper = &*src.wrap; - panic_to_error!(wrap, glib::GFALSE, { + panic_to_error!(wrap, glib_ffi::GFALSE, { *size = wrap.get_size(); - glib::GTRUE + glib_ffi::GTRUE }) } -unsafe extern "C" fn source_start(ptr: *mut gst_base::GstBaseSrc) -> glib::gboolean { +unsafe extern "C" fn source_start(ptr: *mut gst_base_ffi::GstBaseSrc) -> glib_ffi::gboolean { let src = &*(ptr as *const RsSrc); let wrap: &SourceWrapper = &*src.wrap; - panic_to_error!(wrap, glib::GFALSE, { + panic_to_error!(wrap, glib_ffi::GFALSE, { if wrap.start() { - glib::GTRUE + glib_ffi::GTRUE } else { - glib::GFALSE + glib_ffi::GFALSE } }) } -unsafe extern "C" fn source_stop(ptr: *mut gst_base::GstBaseSrc) -> glib::gboolean { +unsafe extern "C" fn source_stop(ptr: *mut gst_base_ffi::GstBaseSrc) -> glib_ffi::gboolean { let src = &*(ptr as *const RsSrc); let wrap: &SourceWrapper = &*src.wrap; - panic_to_error!(wrap, glib::GTRUE, { + panic_to_error!(wrap, glib_ffi::GTRUE, { if wrap.stop() { - glib::GTRUE + glib_ffi::GTRUE } else { - glib::GFALSE + glib_ffi::GFALSE } }) } unsafe extern "C" fn source_fill( - ptr: *mut gst_base::GstBaseSrc, + ptr: *mut gst_base_ffi::GstBaseSrc, offset: u64, length: u32, - buffer: *mut gst::GstBuffer, -) -> gst::GstFlowReturn { + buffer: *mut gst_ffi::GstBuffer, +) -> gst_ffi::GstFlowReturn { let src = &*(ptr as *const RsSrc); let wrap: &SourceWrapper = &*src.wrap; let buffer: &mut Buffer = ::from_mut_ptr(buffer); panic_to_error!( wrap, - gst::GST_FLOW_ERROR, + gst_ffi::GST_FLOW_ERROR, { wrap.fill(offset, length, buffer) } ) } unsafe extern "C" fn source_seek( - ptr: *mut gst_base::GstBaseSrc, - segment: *mut gst::GstSegment, -) -> glib::gboolean { + ptr: *mut gst_base_ffi::GstBaseSrc, + segment: *mut gst_ffi::GstSegment, +) -> glib_ffi::gboolean { let src = &*(ptr as *const RsSrc); let wrap: &SourceWrapper = &*src.wrap; let start = (*segment).start; let stop = (*segment).stop; - panic_to_error!(wrap, glib::GFALSE, { + panic_to_error!(wrap, glib_ffi::GFALSE, { if wrap.seek(start, if stop == u64::MAX { None } else { Some(stop) }) { - glib::GTRUE + glib_ffi::GTRUE } else { - glib::GFALSE + glib_ffi::GFALSE } }) } @@ -382,40 +382,40 @@ pub struct SourceInfo { #[repr(C)] struct RsSrc { - parent: gst_base::GstPushSrc, + parent: gst_base_ffi::GstPushSrc, wrap: *mut SourceWrapper, source_info: *const SourceInfo, } #[repr(C)] struct RsSrcClass { - parent_class: gst_base::GstPushSrcClass, + parent_class: gst_base_ffi::GstPushSrcClass, source_info: *const SourceInfo, protocols: *const Vec<*const c_char>, - parent_vtable: glib::gconstpointer, + parent_vtable: glib_ffi::gconstpointer, } -unsafe extern "C" fn source_finalize(obj: *mut gobject::GObject) { +unsafe extern "C" fn source_finalize(obj: *mut gobject_ffi::GObject) { let src = &mut *(obj as *mut RsSrc); drop(Box::from_raw(src.wrap)); let src_klass = &**(obj as *const *const RsSrcClass); - let parent_klass = &*(src_klass.parent_vtable as *const gobject::GObjectClass); + let parent_klass = &*(src_klass.parent_vtable as *const gobject_ffi::GObjectClass); parent_klass.finalize.map(|f| f(obj)); } unsafe extern "C" fn source_set_property( - obj: *mut gobject::GObject, + obj: *mut gobject_ffi::GObject, id: u32, - value: *mut gobject::GValue, - _pspec: *mut gobject::GParamSpec, + value: *mut gobject_ffi::GValue, + _pspec: *mut gobject_ffi::GParamSpec, ) { let src = &*(obj as *const RsSrc); match id { 1 => { - let uri_ptr = gobject::g_value_get_string(value); + let uri_ptr = gobject_ffi::g_value_get_string(value); source_set_uri(src, uri_ptr, ptr::null_mut()); } _ => unreachable!(), @@ -423,23 +423,23 @@ unsafe extern "C" fn source_set_property( } unsafe extern "C" fn source_get_property( - obj: *mut gobject::GObject, + obj: *mut gobject_ffi::GObject, id: u32, - value: *mut gobject::GValue, - _pspec: *mut gobject::GParamSpec, + value: *mut gobject_ffi::GValue, + _pspec: *mut gobject_ffi::GParamSpec, ) { let src = &*(obj as *const RsSrc); match id { 1 => { let uri_ptr = source_get_uri(src); - gobject::g_value_take_string(value, uri_ptr); + gobject_ffi::g_value_take_string(value, uri_ptr); } _ => unreachable!(), } } -unsafe extern "C" fn source_class_init(klass: glib::gpointer, klass_data: glib::gpointer) { +unsafe extern "C" fn source_class_init(klass: glib_ffi::gpointer, klass_data: glib_ffi::gpointer) { let src_klass = &mut *(klass as *mut RsSrcClass); let source_info = &*(klass_data as *const SourceInfo); @@ -458,15 +458,15 @@ unsafe extern "C" fn source_class_init(klass: glib::gpointer, klass_data: glib:: let nick_cstr = CString::new("URI").unwrap(); let blurb_cstr = CString::new("URI to read from").unwrap(); - gobject::g_object_class_install_property( - klass as *mut gobject::GObjectClass, + gobject_ffi::g_object_class_install_property( + klass as *mut gobject_ffi::GObjectClass, 1, - gobject::g_param_spec_string( + gobject_ffi::g_param_spec_string( name_cstr.as_ptr(), nick_cstr.as_ptr(), blurb_cstr.as_ptr(), ptr::null_mut(), - gobject::G_PARAM_READWRITE, + gobject_ffi::G_PARAM_READWRITE, ), ); } @@ -479,7 +479,7 @@ unsafe extern "C" fn source_class_init(klass: glib::gpointer, klass_data: glib:: let description_cstr = CString::new(source_info.classification.clone()).unwrap(); let author_cstr = CString::new(source_info.author.clone()).unwrap(); - gst::gst_element_class_set_static_metadata( + gst_ffi::gst_element_class_set_static_metadata( element_klass, longname_cstr.into_raw(), classification_cstr.into_raw(), @@ -489,13 +489,13 @@ unsafe extern "C" fn source_class_init(klass: glib::gpointer, klass_data: glib:: let caps = Caps::new_any(); let templ_name = CString::new("src").unwrap(); - let pad_template = gst::gst_pad_template_new( + let pad_template = gst_ffi::gst_pad_template_new( templ_name.into_raw(), - gst::GST_PAD_SRC, - gst::GST_PAD_ALWAYS, - caps.as_ptr() as *mut gst::GstCaps, + gst_ffi::GST_PAD_SRC, + gst_ffi::GST_PAD_ALWAYS, + caps.as_ptr() as *mut gst_ffi::GstCaps, ); - gst::gst_element_class_add_pad_template(element_klass, pad_template); + gst_ffi::gst_element_class_add_pad_template(element_klass, pad_template); } { @@ -516,10 +516,10 @@ unsafe extern "C" fn source_class_init(klass: glib::gpointer, klass_data: glib:: } protocols.push(ptr::null()); src_klass.protocols = Box::into_raw(protocols) as *const Vec<*const c_char>; - src_klass.parent_vtable = gobject::g_type_class_peek_parent(klass); + src_klass.parent_vtable = gobject_ffi::g_type_class_peek_parent(klass); } -unsafe extern "C" fn source_init(instance: *mut gobject::GTypeInstance, klass: glib::gpointer) { +unsafe extern "C" fn source_init(instance: *mut gobject_ffi::GTypeInstance, klass: glib_ffi::gpointer) { let src = &mut *(instance as *mut RsSrc); let src_klass = &*(klass as *const RsSrcClass); let source_info = &*src_klass.source_info; @@ -532,35 +532,35 @@ unsafe extern "C" fn source_init(instance: *mut gobject::GTypeInstance, klass: g )); src.wrap = Box::into_raw(wrap); - gst_base::gst_base_src_set_blocksize(&mut src.parent.parent, 4096); + gst_base_ffi::gst_base_src_set_blocksize(&mut src.parent.parent, 4096); } -unsafe extern "C" fn source_uri_handler_get_type(_type: glib::GType) -> gst::GstURIType { - gst::GST_URI_SRC +unsafe extern "C" fn source_uri_handler_get_type(_type: glib_ffi::GType) -> gst_ffi::GstURIType { + gst_ffi::GST_URI_SRC } -unsafe extern "C" fn source_uri_handler_get_protocols(type_: glib::GType) -> *const *const c_char { - let klass = gobject::g_type_class_peek(type_); +unsafe extern "C" fn source_uri_handler_get_protocols(type_: glib_ffi::GType) -> *const *const c_char { + let klass = gobject_ffi::g_type_class_peek(type_); let src_klass = &*(klass as *const RsSrcClass); (*src_klass.protocols).as_ptr() } unsafe extern "C" fn source_uri_handler_get_uri( - uri_handler: *mut gst::GstURIHandler, + uri_handler: *mut gst_ffi::GstURIHandler, ) -> *mut c_char { source_get_uri(uri_handler as *const RsSrc) } unsafe extern "C" fn source_uri_handler_set_uri( - uri_handler: *mut gst::GstURIHandler, + uri_handler: *mut gst_ffi::GstURIHandler, uri: *const c_char, - err: *mut *mut glib::GError, -) -> glib::gboolean { + err: *mut *mut glib_ffi::GError, +) -> glib_ffi::gboolean { source_set_uri(uri_handler as *const RsSrc, uri, err) } -unsafe extern "C" fn source_uri_handler_init(iface: glib::gpointer, _iface_data: glib::gpointer) { - let uri_handler_iface = &mut *(iface as *mut gst::GstURIHandlerInterface); +unsafe extern "C" fn source_uri_handler_init(iface: glib_ffi::gpointer, _iface_data: glib_ffi::gpointer) { + let uri_handler_iface = &mut *(iface as *mut gst_ffi::GstURIHandlerInterface); uri_handler_iface.get_type = Some(source_uri_handler_get_type); uri_handler_iface.get_protocols = Some(source_uri_handler_get_protocols); @@ -571,9 +571,9 @@ unsafe extern "C" fn source_uri_handler_init(iface: glib::gpointer, _iface_data: pub fn source_register(plugin: &Plugin, source_info: SourceInfo) { unsafe { let parent_type = if source_info.push_only { - gst_base::gst_push_src_get_type() + gst_base_ffi::gst_push_src_get_type() } else { - gst_base::gst_base_src_get_type() + gst_base_ffi::gst_base_src_get_type() }; let mut type_name = String::from("RsSrc-"); type_name.push_str(&source_info.name); @@ -583,9 +583,9 @@ pub fn source_register(plugin: &Plugin, source_info: SourceInfo) { let rank = source_info.rank; let source_info = Box::new(source_info); - let source_info_ptr = Box::into_raw(source_info) as glib::gpointer; + let source_info_ptr = Box::into_raw(source_info) as glib_ffi::gpointer; - let type_info = gobject::GTypeInfo { + let type_info = gobject_ffi::GTypeInfo { class_size: mem::size_of::() as u16, base_init: None, base_finalize: None, @@ -598,20 +598,20 @@ pub fn source_register(plugin: &Plugin, source_info: SourceInfo) { value_table: ptr::null(), }; - let type_ = gobject::g_type_register_static( + let type_ = gobject_ffi::g_type_register_static( parent_type, type_name_cstr.as_ptr(), &type_info, - gobject::GTypeFlags::empty(), + gobject_ffi::GTypeFlags::empty(), ); - let iface_info = gobject::GInterfaceInfo { + let iface_info = gobject_ffi::GInterfaceInfo { interface_init: Some(source_uri_handler_init), interface_finalize: None, interface_data: ptr::null_mut(), }; - gobject::g_type_add_interface_static(type_, gst::gst_uri_handler_get_type(), &iface_info); + gobject_ffi::g_type_add_interface_static(type_, gst_ffi::gst_uri_handler_get_type(), &iface_info); - gst::gst_element_register(plugin.as_ptr(), name_cstr.as_ptr(), rank, type_); + gst_ffi::gst_element_register(plugin.as_ptr(), name_cstr.as_ptr(), rank, type_); } } diff --git a/gst-plugin/src/streams.rs b/gst-plugin/src/streams.rs index 896712be..f0b28628 100644 --- a/gst-plugin/src/streams.rs +++ b/gst-plugin/src/streams.rs @@ -13,10 +13,10 @@ use caps::Caps; use miniobject::*; use tags::TagList; -use gst; +use gst_ffi; -pub struct Stream(*mut gst::GstStream); -pub struct StreamCollection(*mut gst::GstStreamCollection); +pub struct Stream(*mut gst_ffi::GstStream); +pub struct StreamCollection(*mut gst_ffi::GstStreamCollection); bitflags! { #[repr(C)] @@ -50,7 +50,7 @@ impl Stream { .unwrap_or(ptr::null_mut()); Stream(unsafe { - gst::gst_stream_new( + gst_ffi::gst_stream_new( stream_id_cstr.as_ptr(), caps, mem::transmute(t.bits()), @@ -59,12 +59,12 @@ impl Stream { }) } - pub unsafe fn as_ptr(&self) -> *const gst::GstStream { + pub unsafe fn as_ptr(&self) -> *const gst_ffi::GstStream { self.0 } pub fn get_caps(&self) -> Option<&Caps> { - let ptr = unsafe { gst::gst_stream_get_caps(self.0) }; + let ptr = unsafe { gst_ffi::gst_stream_get_caps(self.0) }; if ptr.is_null() { return None; @@ -74,20 +74,20 @@ impl Stream { } pub fn get_stream_flags(&self) -> StreamFlags { - StreamFlags::from_bits_truncate(unsafe { gst::gst_stream_get_stream_flags(self.0).bits() }) + StreamFlags::from_bits_truncate(unsafe { gst_ffi::gst_stream_get_stream_flags(self.0).bits() }) } pub fn get_stream_type(&self) -> StreamType { - StreamType::from_bits_truncate(unsafe { gst::gst_stream_get_stream_type(self.0).bits() }) + StreamType::from_bits_truncate(unsafe { gst_ffi::gst_stream_get_stream_type(self.0).bits() }) } pub fn get_stream_id(&self) -> &str { - let cstr = unsafe { CStr::from_ptr(gst::gst_stream_get_stream_id(self.0)) }; + let cstr = unsafe { CStr::from_ptr(gst_ffi::gst_stream_get_stream_id(self.0)) }; cstr.to_str().unwrap() } pub fn get_tags(&self) -> Option<&TagList> { - let ptr = unsafe { gst::gst_stream_get_tags(self.0) }; + let ptr = unsafe { gst_ffi::gst_stream_get_tags(self.0) }; if ptr.is_null() { return None; @@ -100,37 +100,37 @@ impl Stream { let ptr = caps.map(|caps| unsafe { caps.as_mut_ptr() }) .unwrap_or(ptr::null_mut()); - unsafe { gst::gst_stream_set_caps(self.0, ptr) } + unsafe { gst_ffi::gst_stream_set_caps(self.0, ptr) } } pub fn set_stream_flags(&self, flags: StreamFlags) { - unsafe { gst::gst_stream_set_stream_flags(self.0, mem::transmute(flags.bits())) } + unsafe { gst_ffi::gst_stream_set_stream_flags(self.0, mem::transmute(flags.bits())) } } pub fn set_stream_type(&self, t: StreamType) { - unsafe { gst::gst_stream_set_stream_type(self.0, mem::transmute(t.bits())) } + unsafe { gst_ffi::gst_stream_set_stream_type(self.0, mem::transmute(t.bits())) } } pub fn set_tags(&self, tags: Option) { let ptr = tags.map(|tags| unsafe { tags.as_mut_ptr() }) .unwrap_or(ptr::null_mut()); - unsafe { gst::gst_stream_set_tags(self.0, ptr) } + unsafe { gst_ffi::gst_stream_set_tags(self.0, ptr) } } } impl Clone for Stream { fn clone(&self) -> Self { unsafe { - Stream(gst::gst_object_ref(self.0 as *mut gst::GstObject) as - *mut gst::GstStream) + Stream(gst_ffi::gst_object_ref(self.0 as *mut gst_ffi::GstObject) as + *mut gst_ffi::GstStream) } } } impl Drop for Stream { fn drop(&mut self) { - unsafe { gst::gst_object_unref(self.0 as *mut gst::GstObject) } + unsafe { gst_ffi::gst_object_unref(self.0 as *mut gst_ffi::GstObject) } } } @@ -138,11 +138,11 @@ impl StreamCollection { pub fn new(upstream_id: &str, streams: &[Stream]) -> Self { let upstream_id_cstr = CString::new(upstream_id).unwrap(); let collection = StreamCollection(unsafe { - gst::gst_stream_collection_new(upstream_id_cstr.as_ptr()) + gst_ffi::gst_stream_collection_new(upstream_id_cstr.as_ptr()) }); for stream in streams { - unsafe { gst::gst_stream_collection_add_stream(collection.0, stream.clone().0) }; + unsafe { gst_ffi::gst_stream_collection_add_stream(collection.0, stream.clone().0) }; } collection @@ -153,7 +153,7 @@ impl StreamCollection { } pub fn len(&self) -> u32 { - unsafe { gst::gst_stream_collection_get_size(self.0) } + unsafe { gst_ffi::gst_stream_collection_get_size(self.0) } } pub fn empty(&self) -> bool { @@ -161,11 +161,11 @@ impl StreamCollection { } pub fn get_upstream_id(&self) -> &str { - let cstr = unsafe { CStr::from_ptr(gst::gst_stream_collection_get_upstream_id(self.0)) }; + let cstr = unsafe { CStr::from_ptr(gst_ffi::gst_stream_collection_get_upstream_id(self.0)) }; cstr.to_str().unwrap() } - pub unsafe fn as_ptr(&self) -> *const gst::GstStreamCollection { + pub unsafe fn as_ptr(&self) -> *const gst_ffi::GstStreamCollection { self.0 } } @@ -195,7 +195,7 @@ impl<'a> Iterator for StreamCollectionIterator<'a> { } let stream = - unsafe { gst::gst_stream_collection_get_stream(self.collection.0, self.position) }; + unsafe { gst_ffi::gst_stream_collection_get_stream(self.collection.0, self.position) }; if stream.is_null() { self.position = self.length; return None; @@ -203,8 +203,8 @@ impl<'a> Iterator for StreamCollectionIterator<'a> { self.position += 1; Some(unsafe { - Stream(gst::gst_object_ref(stream as *mut gst::GstObject) as - *mut gst::GstStream) + Stream(gst_ffi::gst_object_ref(stream as *mut gst_ffi::GstObject) as + *mut gst_ffi::GstStream) }) } @@ -228,15 +228,15 @@ impl<'a> DoubleEndedIterator for StreamCollectionIterator<'a> { self.length -= 1; let stream = - unsafe { gst::gst_stream_collection_get_stream(self.collection.0, self.length) }; + unsafe { gst_ffi::gst_stream_collection_get_stream(self.collection.0, self.length) }; if stream.is_null() { self.position = self.length; return None; } Some(unsafe { - Stream(gst::gst_object_ref(stream as *mut gst::GstObject) as - *mut gst::GstStream) + Stream(gst_ffi::gst_object_ref(stream as *mut gst_ffi::GstObject) as + *mut gst_ffi::GstStream) }) } } @@ -246,14 +246,14 @@ impl<'a> ExactSizeIterator for StreamCollectionIterator<'a> {} impl Clone for StreamCollection { fn clone(&self) -> Self { unsafe { - StreamCollection(gst::gst_object_ref(self.0 as *mut gst::GstObject) as - *mut gst::GstStreamCollection) + StreamCollection(gst_ffi::gst_object_ref(self.0 as *mut gst_ffi::GstObject) as + *mut gst_ffi::GstStreamCollection) } } } impl Drop for StreamCollection { fn drop(&mut self) { - unsafe { gst::gst_object_unref(self.0 as *mut gst::GstObject) } + unsafe { gst_ffi::gst_object_unref(self.0 as *mut gst_ffi::GstObject) } } } diff --git a/gst-plugin/src/structure.rs b/gst-plugin/src/structure.rs index d431383d..21ff3542 100644 --- a/gst-plugin/src/structure.rs +++ b/gst-plugin/src/structure.rs @@ -16,8 +16,8 @@ use std::marker::PhantomData; use value::*; -use glib; -use gst; +use glib_ffi; +use gst_ffi; pub struct OwnedStructure(*mut Structure, PhantomData); @@ -25,7 +25,7 @@ impl OwnedStructure { pub fn new_empty(name: &str) -> OwnedStructure { let name_cstr = CString::new(name).unwrap(); OwnedStructure( - unsafe { gst::gst_structure_new_empty(name_cstr.as_ptr()) as *mut Structure }, + unsafe { gst_ffi::gst_structure_new_empty(name_cstr.as_ptr()) as *mut Structure }, PhantomData, ) } @@ -43,7 +43,7 @@ impl OwnedStructure { pub fn from_string(s: &str) -> Option { unsafe { let cstr = CString::new(s).unwrap(); - let structure = gst::gst_structure_from_string(cstr.as_ptr(), ptr::null_mut()); + let structure = gst_ffi::gst_structure_from_string(cstr.as_ptr(), ptr::null_mut()); if structure.is_null() { None } else { @@ -52,8 +52,8 @@ impl OwnedStructure { } } - pub unsafe fn into_ptr(self) -> *mut gst::GstStructure { - let ptr = self.0 as *mut Structure as *mut gst::GstStructure; + pub unsafe fn into_ptr(self) -> *mut gst_ffi::GstStructure { + let ptr = self.0 as *mut Structure as *mut gst_ffi::GstStructure; mem::forget(self); ptr @@ -89,7 +89,7 @@ impl AsMut for OwnedStructure { impl Clone for OwnedStructure { fn clone(&self) -> Self { OwnedStructure( - unsafe { gst::gst_structure_copy(&(*self.0).0) as *mut Structure }, + unsafe { gst_ffi::gst_structure_copy(&(*self.0).0) as *mut Structure }, PhantomData, ) } @@ -97,7 +97,7 @@ impl Clone for OwnedStructure { impl Drop for OwnedStructure { fn drop(&mut self) { - unsafe { gst::gst_structure_free(&mut (*self.0).0) } + unsafe { gst_ffi::gst_structure_free(&mut (*self.0).0) } } } @@ -138,23 +138,23 @@ impl ToOwned for Structure { fn to_owned(&self) -> OwnedStructure { OwnedStructure( - unsafe { gst::gst_structure_copy(&self.0) as *mut Structure }, + unsafe { gst_ffi::gst_structure_copy(&self.0) as *mut Structure }, PhantomData, ) } } #[repr(C)] -pub struct Structure(gst::GstStructure); +pub struct Structure(gst_ffi::GstStructure); impl Structure { - pub unsafe fn from_borrowed_ptr<'a>(ptr: *const gst::GstStructure) -> &'a Structure { + pub unsafe fn from_borrowed_ptr<'a>(ptr: *const gst_ffi::GstStructure) -> &'a Structure { assert!(!ptr.is_null()); &*(ptr as *mut Structure) } - pub unsafe fn from_borrowed_mut_ptr<'a>(ptr: *mut gst::GstStructure) -> &'a mut Structure { + pub unsafe fn from_borrowed_mut_ptr<'a>(ptr: *mut gst_ffi::GstStructure) -> &'a mut Structure { assert!(!ptr.is_null()); &mut *(ptr as *mut Structure) @@ -162,9 +162,9 @@ impl Structure { pub fn to_string(&self) -> String { unsafe { - let ptr = gst::gst_structure_to_string(&self.0); + let ptr = gst_ffi::gst_structure_to_string(&self.0); let s = CStr::from_ptr(ptr).to_str().unwrap().into(); - glib::g_free(ptr as glib::gpointer); + glib_ffi::g_free(ptr as glib_ffi::gpointer); s } @@ -178,7 +178,7 @@ impl Structure { unsafe { let name_cstr = CString::new(name).unwrap(); - let value = gst::gst_structure_get_value(&self.0, name_cstr.as_ptr()); + let value = gst_ffi::gst_structure_get_value(&self.0, name_cstr.as_ptr()); if value.is_null() { return None; @@ -193,14 +193,14 @@ impl Structure { let name_cstr = CString::new(name).unwrap(); let mut gvalue = value.into().into_raw(); - gst::gst_structure_take_value(&mut self.0, name_cstr.as_ptr(), &mut gvalue); + gst_ffi::gst_structure_take_value(&mut self.0, name_cstr.as_ptr(), &mut gvalue); mem::forget(gvalue); } } pub fn get_name(&self) -> &str { unsafe { - let cstr = CStr::from_ptr(gst::gst_structure_get_name(&self.0)); + let cstr = CStr::from_ptr(gst_ffi::gst_structure_get_name(&self.0)); cstr.to_str().unwrap() } } @@ -208,20 +208,20 @@ impl Structure { pub fn has_field(&self, field: &str) -> bool { unsafe { let cstr = CString::new(field).unwrap(); - gst::gst_structure_has_field(&self.0, cstr.as_ptr()) == glib::GTRUE + gst_ffi::gst_structure_has_field(&self.0, cstr.as_ptr()) == glib_ffi::GTRUE } } pub fn remove_field(&mut self, field: &str) { unsafe { let cstr = CString::new(field).unwrap(); - gst::gst_structure_remove_field(&mut self.0, cstr.as_ptr()); + gst_ffi::gst_structure_remove_field(&mut self.0, cstr.as_ptr()); } } pub fn remove_all_fields(&mut self) { unsafe { - gst::gst_structure_remove_all_fields(&mut self.0); + gst_ffi::gst_structure_remove_all_fields(&mut self.0); } } @@ -235,7 +235,7 @@ impl Structure { fn get_nth_field_name(&self, idx: u32) -> Option<&str> { unsafe { - let field_name = gst::gst_structure_nth_field_name(&self.0, idx); + let field_name = gst_ffi::gst_structure_nth_field_name(&self.0, idx); if field_name.is_null() { return None; } @@ -246,7 +246,7 @@ impl Structure { } fn n_fields(&self) -> u32 { - unsafe { gst::gst_structure_n_fields(&self.0) as u32 } + unsafe { gst_ffi::gst_structure_n_fields(&self.0) as u32 } } // TODO: Various operations @@ -260,7 +260,7 @@ impl fmt::Debug for Structure { impl PartialEq for Structure { fn eq(&self, other: &Structure) -> bool { - (unsafe { gst::gst_structure_is_equal(&self.0, &other.0) } == glib::GTRUE) + (unsafe { gst_ffi::gst_structure_is_equal(&self.0, &other.0) } == glib_ffi::GTRUE) } } @@ -377,7 +377,7 @@ mod tests { #[test] fn new_set_get() { - unsafe { gst::gst_init(ptr::null_mut(), ptr::null_mut()) }; + unsafe { gst_ffi::gst_init(ptr::null_mut(), ptr::null_mut()) }; let mut s = OwnedStructure::new_empty("test"); assert_eq!(s.get_name(), "test"); diff --git a/gst-plugin/src/tags.rs b/gst-plugin/src/tags.rs index 4cefaeff..56e7ca25 100644 --- a/gst-plugin/src/tags.rs +++ b/gst-plugin/src/tags.rs @@ -13,9 +13,9 @@ use std::marker::PhantomData; use value::*; use miniobject::*; -use glib; -use gobject; -use gst; +use glib_ffi; +use gobject_ffi; +use gst_ffi; pub trait Tag<'a> { type TagType: ValueType<'a>; @@ -57,27 +57,27 @@ pub enum MergeMode { } impl MergeMode { - fn to_ffi(&self) -> gst::GstTagMergeMode { + fn to_ffi(&self) -> gst_ffi::GstTagMergeMode { match *self { - MergeMode::ReplaceAll => gst::GST_TAG_MERGE_REPLACE_ALL, - MergeMode::Replace => gst::GST_TAG_MERGE_REPLACE, - MergeMode::Append => gst::GST_TAG_MERGE_APPEND, - MergeMode::Prepend => gst::GST_TAG_MERGE_PREPEND, - MergeMode::Keep => gst::GST_TAG_MERGE_KEEP, - MergeMode::KeepAll => gst::GST_TAG_MERGE_KEEP_ALL, + MergeMode::ReplaceAll => gst_ffi::GST_TAG_MERGE_REPLACE_ALL, + MergeMode::Replace => gst_ffi::GST_TAG_MERGE_REPLACE, + MergeMode::Append => gst_ffi::GST_TAG_MERGE_APPEND, + MergeMode::Prepend => gst_ffi::GST_TAG_MERGE_PREPEND, + MergeMode::Keep => gst_ffi::GST_TAG_MERGE_KEEP, + MergeMode::KeepAll => gst_ffi::GST_TAG_MERGE_KEEP_ALL, } } } -pub struct TagList(gst::GstTagList); +pub struct TagList(gst_ffi::GstTagList); unsafe impl MiniObject for TagList { - type PtrType = gst::GstTagList; + type PtrType = gst_ffi::GstTagList; } impl TagList { pub fn new() -> GstRc { - unsafe { GstRc::from_owned_ptr(gst::gst_tag_list_new_empty()) } + unsafe { GstRc::from_owned_ptr(gst_ffi::gst_tag_list_new_empty()) } } pub fn add<'a, T: Tag<'a>>(&mut self, value: T::TagType, mode: MergeMode) @@ -89,14 +89,14 @@ impl TagList { let mut gvalue = v.into_raw(); let tag_name = CString::new(T::tag_name()).unwrap(); - gst::gst_tag_list_add_value( + gst_ffi::gst_tag_list_add_value( self.as_mut_ptr(), mode.to_ffi(), tag_name.as_ptr(), &gvalue, ); - gobject::g_value_unset(&mut gvalue); + gobject_ffi::g_value_unset(&mut gvalue); } } @@ -105,9 +105,9 @@ impl TagList { let mut gvalue = mem::zeroed(); let tag_name = CString::new(T::tag_name()).unwrap(); - let found = gst::gst_tag_list_copy_value(&mut gvalue, self.as_ptr(), tag_name.as_ptr()); + let found = gst_ffi::gst_tag_list_copy_value(&mut gvalue, self.as_ptr(), tag_name.as_ptr()); - if found == glib::GFALSE { + if found == glib_ffi::GFALSE { return None; } @@ -119,7 +119,7 @@ impl TagList { unsafe { let tag_name = CString::new(T::tag_name()).unwrap(); - let value = gst::gst_tag_list_get_value_index(self.as_ptr(), tag_name.as_ptr(), idx); + let value = gst_ffi::gst_tag_list_get_value_index(self.as_ptr(), tag_name.as_ptr(), idx); if value.is_null() { return None; @@ -133,7 +133,7 @@ impl TagList { unsafe { let tag_name = CString::new(T::tag_name()).unwrap(); - gst::gst_tag_list_get_tag_size(self.as_ptr(), tag_name.as_ptr()) + gst_ffi::gst_tag_list_get_tag_size(self.as_ptr(), tag_name.as_ptr()) } } @@ -143,9 +143,9 @@ impl TagList { pub fn to_string(&self) -> String { unsafe { - let ptr = gst::gst_tag_list_to_string(self.as_ptr()); + let ptr = gst_ffi::gst_tag_list_to_string(self.as_ptr()); let s = CStr::from_ptr(ptr).to_str().unwrap().into(); - glib::g_free(ptr as glib::gpointer); + glib_ffi::g_free(ptr as glib_ffi::gpointer); s } @@ -160,7 +160,7 @@ impl fmt::Debug for TagList { impl PartialEq for TagList { fn eq(&self, other: &TagList) -> bool { - (unsafe { gst::gst_tag_list_is_equal(self.as_ptr(), other.as_ptr()) } == glib::GTRUE) + (unsafe { gst_ffi::gst_tag_list_is_equal(self.as_ptr(), other.as_ptr()) } == glib_ffi::GTRUE) } } @@ -240,7 +240,7 @@ mod tests { fn init() { unsafe { - gst::gst_init(ptr::null_mut(), ptr::null_mut()); + gst_ffi::gst_init(ptr::null_mut(), ptr::null_mut()); } } diff --git a/gst-plugin/src/utils.rs b/gst-plugin/src/utils.rs index 5e989005..e247f30b 100644 --- a/gst-plugin/src/utils.rs +++ b/gst-plugin/src/utils.rs @@ -11,22 +11,22 @@ use std::ffi::CString; use std::i32; use num_rational::Rational32; -use gst; +use gst_ffi; -pub struct Element(*mut gst::GstElement); +pub struct Element(*mut gst_ffi::GstElement); impl Element { - pub unsafe fn new(element: *mut gst::GstElement) -> Element { + pub unsafe fn new(element: *mut gst_ffi::GstElement) -> Element { if element.is_null() { panic!("NULL not allowed"); } - gst::gst_object_ref(element as *mut gst::GstObject); + gst_ffi::gst_object_ref(element as *mut gst_ffi::GstObject); Element(element) } - pub unsafe fn as_ptr(&self) -> *mut gst::GstElement { + pub unsafe fn as_ptr(&self) -> *mut gst_ffi::GstElement { self.0 } } @@ -34,7 +34,7 @@ impl Element { impl Drop for Element { fn drop(&mut self) { unsafe { - gst::gst_object_unref(self.0 as *mut gst::GstObject); + gst_ffi::gst_object_unref(self.0 as *mut gst_ffi::GstObject); } } } diff --git a/gst-plugin/src/value.rs b/gst-plugin/src/value.rs index 09088836..f8df278f 100644 --- a/gst-plugin/src/value.rs +++ b/gst-plugin/src/value.rs @@ -19,12 +19,12 @@ pub use num_rational::Rational32; use buffer::*; use miniobject::*; -use glib; -use gobject; -use gst; +use glib_ffi; +use gobject_ffi; +use gst_ffi; #[repr(C)] -pub struct Value(gobject::GValue); +pub struct Value(gobject_ffi::GValue); #[derive(Clone, PartialEq, Eq, Debug)] pub enum ValueView<'a> { @@ -49,31 +49,31 @@ pub trait ValueType<'a> where Self: Sized, { - fn g_type() -> glib::GType; + fn g_type() -> glib_ffi::GType; - fn from_value(v: &'a gobject::GValue) -> Option; + fn from_value(v: &'a gobject_ffi::GValue) -> Option; fn from_value_view(v: &'a ValueView<'a>) -> Option; } lazy_static! { - static ref TYPE_BUFFER: glib::GType = unsafe { gst::gst_buffer_get_type() }; - static ref TYPE_FRACTION: glib::GType = unsafe { gst::gst_fraction_get_type() }; - static ref TYPE_GST_VALUE_ARRAY: glib::GType = unsafe { gst::gst_value_array_get_type() }; + static ref TYPE_BUFFER: glib_ffi::GType = unsafe { gst_ffi::gst_buffer_get_type() }; + static ref TYPE_FRACTION: glib_ffi::GType = unsafe { gst_ffi::gst_fraction_get_type() }; + static ref TYPE_GST_VALUE_ARRAY: glib_ffi::GType = unsafe { gst_ffi::gst_value_array_get_type() }; } impl Value { - pub unsafe fn as_ptr(&self) -> *const gobject::GValue { + pub unsafe fn as_ptr(&self) -> *const gobject_ffi::GValue { &self.0 } - pub unsafe fn from_ptr(ptr: *const gobject::GValue) -> Option { + pub unsafe fn from_ptr(ptr: *const gobject_ffi::GValue) -> Option { if ptr.is_null() || !Value::is_supported_type((*ptr).g_type) { return None; } let mut value = Value(mem::zeroed()); - gobject::g_value_init(&mut value.0, (*ptr).g_type); - gobject::g_value_copy(ptr, &mut value.0); + gobject_ffi::g_value_init(&mut value.0, (*ptr).g_type); + gobject_ffi::g_value_copy(ptr, &mut value.0); Some(value) } @@ -82,28 +82,28 @@ impl Value { unsafe { Value::from_ptr(v.0) }.unwrap() } - pub unsafe fn from_raw(value: gobject::GValue) -> Option { + pub unsafe fn from_raw(value: gobject_ffi::GValue) -> Option { if !Value::is_supported_type(value.g_type) { return None; } Some(Value(value)) } - pub unsafe fn into_raw(mut self) -> gobject::GValue { + pub unsafe fn into_raw(mut self) -> gobject_ffi::GValue { let v = mem::replace(&mut self.0, mem::zeroed()); mem::forget(self); v } - fn is_supported_type(typ: glib::GType) -> bool { + fn is_supported_type(typ: glib_ffi::GType) -> bool { match typ { - gobject::G_TYPE_BOOLEAN | - gobject::G_TYPE_INT | - gobject::G_TYPE_UINT | - gobject::G_TYPE_INT64 | - gobject::G_TYPE_UINT64 | - gobject::G_TYPE_STRING => true, + gobject_ffi::G_TYPE_BOOLEAN | + gobject_ffi::G_TYPE_INT | + gobject_ffi::G_TYPE_UINT | + gobject_ffi::G_TYPE_INT64 | + gobject_ffi::G_TYPE_UINT64 | + gobject_ffi::G_TYPE_STRING => true, typ if typ == *TYPE_FRACTION => true, //typ if typ == *TYPE_BUFFER => true typ if typ == *TYPE_GST_VALUE_ARRAY => true, @@ -131,15 +131,15 @@ impl Value { pub fn get(&self) -> ValueView { match self.0.g_type { - gobject::G_TYPE_BOOLEAN => ValueView::Bool(bool::from_value(&self.0).unwrap()), - gobject::G_TYPE_INT => ValueView::Int(i32::from_value(&self.0).unwrap()), - gobject::G_TYPE_UINT => ValueView::UInt(u32::from_value(&self.0).unwrap()), - gobject::G_TYPE_INT64 => ValueView::Int64(i64::from_value(&self.0).unwrap()), - gobject::G_TYPE_UINT64 => ValueView::UInt64(u64::from_value(&self.0).unwrap()), + gobject_ffi::G_TYPE_BOOLEAN => ValueView::Bool(bool::from_value(&self.0).unwrap()), + gobject_ffi::G_TYPE_INT => ValueView::Int(i32::from_value(&self.0).unwrap()), + gobject_ffi::G_TYPE_UINT => ValueView::UInt(u32::from_value(&self.0).unwrap()), + gobject_ffi::G_TYPE_INT64 => ValueView::Int64(i64::from_value(&self.0).unwrap()), + gobject_ffi::G_TYPE_UINT64 => ValueView::UInt64(u64::from_value(&self.0).unwrap()), typ if typ == *TYPE_FRACTION => { ValueView::Fraction(Rational32::from_value(&self.0).unwrap()) } - gobject::G_TYPE_STRING => ValueView::String(Cow::Borrowed( + gobject_ffi::G_TYPE_STRING => ValueView::String(Cow::Borrowed( <&str as ValueType>::from_value(&self.0).unwrap(), )), typ if typ == *TYPE_GST_VALUE_ARRAY => ValueView::Array(Cow::Borrowed( @@ -161,8 +161,8 @@ impl Clone for Value { fn clone(&self) -> Self { unsafe { let mut new_value = Value(mem::zeroed()); - gobject::g_value_init(&mut new_value.0, self.0.g_type); - gobject::g_value_copy(&self.0, &mut new_value.0); + gobject_ffi::g_value_init(&mut new_value.0, self.0.g_type); + gobject_ffi::g_value_copy(&self.0, &mut new_value.0); new_value } @@ -191,18 +191,18 @@ impl fmt::Debug for Value { impl Drop for Value { fn drop(&mut self) { unsafe { - if self.0.g_type != gobject::G_TYPE_NONE { - gobject::g_value_unset(&mut self.0); + if self.0.g_type != gobject_ffi::G_TYPE_NONE { + gobject_ffi::g_value_unset(&mut self.0); } } } } #[derive(Clone)] -pub struct ValueRef<'a>(&'a gobject::GValue); +pub struct ValueRef<'a>(&'a gobject_ffi::GValue); impl<'a> ValueRef<'a> { - pub unsafe fn as_ptr(&self) -> *const gobject::GValue { + pub unsafe fn as_ptr(&self) -> *const gobject_ffi::GValue { self.0 } @@ -210,7 +210,7 @@ impl<'a> ValueRef<'a> { ValueRef(&v.0) } - pub unsafe fn from_ptr(ptr: *const gobject::GValue) -> Option> { + pub unsafe fn from_ptr(ptr: *const gobject_ffi::GValue) -> Option> { if ptr.is_null() || !Value::is_supported_type((*ptr).g_type) { return None; } @@ -220,15 +220,15 @@ impl<'a> ValueRef<'a> { pub fn get(&self) -> ValueView { match self.0.g_type { - gobject::G_TYPE_BOOLEAN => ValueView::Bool(bool::from_value(self.0).unwrap()), - gobject::G_TYPE_INT => ValueView::Int(i32::from_value(self.0).unwrap()), - gobject::G_TYPE_UINT => ValueView::UInt(u32::from_value(self.0).unwrap()), - gobject::G_TYPE_INT64 => ValueView::Int64(i64::from_value(self.0).unwrap()), - gobject::G_TYPE_UINT64 => ValueView::UInt64(u64::from_value(self.0).unwrap()), + gobject_ffi::G_TYPE_BOOLEAN => ValueView::Bool(bool::from_value(self.0).unwrap()), + gobject_ffi::G_TYPE_INT => ValueView::Int(i32::from_value(self.0).unwrap()), + gobject_ffi::G_TYPE_UINT => ValueView::UInt(u32::from_value(self.0).unwrap()), + gobject_ffi::G_TYPE_INT64 => ValueView::Int64(i64::from_value(self.0).unwrap()), + gobject_ffi::G_TYPE_UINT64 => ValueView::UInt64(u64::from_value(self.0).unwrap()), typ if typ == *TYPE_FRACTION => { ValueView::Fraction(Rational32::from_value(self.0).unwrap()) } - gobject::G_TYPE_STRING => ValueView::String(Cow::Borrowed( + gobject_ffi::G_TYPE_STRING => ValueView::String(Cow::Borrowed( <&str as ValueType>::from_value(self.0).unwrap(), )), typ if typ == *TYPE_GST_VALUE_ARRAY => ValueView::Array(Cow::Borrowed( @@ -268,11 +268,11 @@ impl<'a> fmt::Debug for ValueRef<'a> { macro_rules! impl_value_type_simple( ($typ:ty, $variant:ident, $g_type:expr, $getter:expr, $setter:expr) => { impl<'a> ValueType<'a> for $typ { - fn g_type() -> glib::GType { + fn g_type() -> glib_ffi::GType { $g_type } - fn from_value(value: &'a gobject::GValue) -> Option { + fn from_value(value: &'a gobject_ffi::GValue) -> Option { if value.g_type != Self::g_type() { return None; } @@ -296,7 +296,7 @@ macro_rules! impl_value_type_simple( unsafe { let mut value = Value(mem::zeroed()); - gobject::g_value_init(&mut value.0, <$typ as ValueType>::g_type()); + gobject_ffi::g_value_init(&mut value.0, <$typ as ValueType>::g_type()); $setter(&mut value.0, v); value @@ -308,59 +308,59 @@ macro_rules! impl_value_type_simple( impl_value_type_simple!(bool, Bool, - gobject::G_TYPE_BOOLEAN, - |value: &gobject::GValue| !(gobject::g_value_get_boolean(value) == 0), - |value: &mut gobject::GValue, v| { - gobject::g_value_set_boolean(value, - if v { glib::GTRUE } else { glib::GFALSE }) + gobject_ffi::G_TYPE_BOOLEAN, + |value: &gobject_ffi::GValue| !(gobject_ffi::g_value_get_boolean(value) == 0), + |value: &mut gobject_ffi::GValue, v| { + gobject_ffi::g_value_set_boolean(value, + if v { glib_ffi::GTRUE } else { glib_ffi::GFALSE }) }); impl_value_type_simple!(i32, Int, - gobject::G_TYPE_INT, - |value: &gobject::GValue| gobject::g_value_get_int(value), - |value: &mut gobject::GValue, v| gobject::g_value_set_int(value, v)); + gobject_ffi::G_TYPE_INT, + |value: &gobject_ffi::GValue| gobject_ffi::g_value_get_int(value), + |value: &mut gobject_ffi::GValue, v| gobject_ffi::g_value_set_int(value, v)); impl_value_type_simple!(u32, UInt, - gobject::G_TYPE_UINT, - |value: &gobject::GValue| gobject::g_value_get_uint(value), - |value: &mut gobject::GValue, v| gobject::g_value_set_uint(value, v)); + gobject_ffi::G_TYPE_UINT, + |value: &gobject_ffi::GValue| gobject_ffi::g_value_get_uint(value), + |value: &mut gobject_ffi::GValue, v| gobject_ffi::g_value_set_uint(value, v)); impl_value_type_simple!(i64, Int64, - gobject::G_TYPE_INT64, - |value: &gobject::GValue| gobject::g_value_get_int64(value), - |value: &mut gobject::GValue, v| gobject::g_value_set_int64(value, v)); + gobject_ffi::G_TYPE_INT64, + |value: &gobject_ffi::GValue| gobject_ffi::g_value_get_int64(value), + |value: &mut gobject_ffi::GValue, v| gobject_ffi::g_value_set_int64(value, v)); impl_value_type_simple!(u64, UInt64, - gobject::G_TYPE_UINT64, - |value: &gobject::GValue| gobject::g_value_get_uint64(value), - |value: &mut gobject::GValue, v| gobject::g_value_set_uint64(value, v)); + gobject_ffi::G_TYPE_UINT64, + |value: &gobject_ffi::GValue| gobject_ffi::g_value_get_uint64(value), + |value: &mut gobject_ffi::GValue, v| gobject_ffi::g_value_set_uint64(value, v)); impl_value_type_simple!( Rational32, Fraction, *TYPE_FRACTION, - |value: &gobject::GValue| { + |value: &gobject_ffi::GValue| { Rational32::new( - gst::gst_value_get_fraction_numerator(value), - gst::gst_value_get_fraction_denominator(value), + gst_ffi::gst_value_get_fraction_numerator(value), + gst_ffi::gst_value_get_fraction_denominator(value), ) }, - |value: &mut gobject::GValue, v: Rational32| { - gst::gst_value_set_fraction(value, *v.numer(), *v.denom()) + |value: &mut gobject_ffi::GValue, v: Rational32| { + gst_ffi::gst_value_set_fraction(value, *v.numer(), *v.denom()) } ); impl<'a> ValueType<'a> for &'a str { - fn g_type() -> glib::GType { - gobject::G_TYPE_STRING + fn g_type() -> glib_ffi::GType { + gobject_ffi::G_TYPE_STRING } - fn from_value(value: &'a gobject::GValue) -> Option { + fn from_value(value: &'a gobject_ffi::GValue) -> Option { if value.g_type != Self::g_type() { return None; } unsafe { - let s = gobject::g_value_get_string(value); + let s = gobject_ffi::g_value_get_string(value); if s.is_null() { return Some(""); } @@ -384,9 +384,9 @@ impl<'a> From> for Value { unsafe { let mut value = Value(mem::zeroed()); - gobject::g_value_init(&mut value.0, <&str as ValueType>::g_type()); - let v_cstr = glib::g_strndup(v.as_ptr() as *const c_char, v.len()); - gobject::g_value_take_string(&mut value.0, v_cstr); + gobject_ffi::g_value_init(&mut value.0, <&str as ValueType>::g_type()); + let v_cstr = glib_ffi::g_strndup(v.as_ptr() as *const c_char, v.len()); + gobject_ffi::g_value_take_string(&mut value.0, v_cstr); value } @@ -406,17 +406,17 @@ impl<'a> From<&'a str> for Value { } impl<'a> ValueType<'a> for GstRc { - fn g_type() -> glib::GType { + fn g_type() -> glib_ffi::GType { *TYPE_BUFFER } - fn from_value(value: &'a gobject::GValue) -> Option { + fn from_value(value: &'a gobject_ffi::GValue) -> Option { if value.g_type != Self::g_type() { return None; } unsafe { - let buffer = gobject::g_value_get_boxed(value) as *mut gst::GstBuffer; + let buffer = gobject_ffi::g_value_get_boxed(value) as *mut gst_ffi::GstBuffer; Some(GstRc::from_unowned_ptr(buffer)) } } @@ -447,8 +447,8 @@ impl<'a> From<&'a Buffer> for Value { unsafe { let mut value = Value(mem::zeroed()); - gobject::g_value_init(&mut value.0, as ValueType>::g_type()); - gobject::g_value_set_boxed(&mut value.0, v.as_ptr() as glib::gpointer); + gobject_ffi::g_value_init(&mut value.0, as ValueType>::g_type()); + gobject_ffi::g_value_set_boxed(&mut value.0, v.as_ptr() as glib_ffi::gpointer); value } @@ -456,17 +456,17 @@ impl<'a> From<&'a Buffer> for Value { } impl<'a> ValueType<'a> for &'a [Value] { - fn g_type() -> glib::GType { + fn g_type() -> glib_ffi::GType { *TYPE_GST_VALUE_ARRAY } - fn from_value(value: &'a gobject::GValue) -> Option { + fn from_value(value: &'a gobject_ffi::GValue) -> Option { if value.g_type != Self::g_type() { return None; } unsafe { - let arr = value.data[0] as *const glib::GArray; + let arr = value.data[0] as *const glib_ffi::GArray; if arr.is_null() { Some(&[]) @@ -494,19 +494,19 @@ impl<'a> From> for Value { unsafe { let mut value = Value(mem::zeroed()); - gobject::g_value_init(&mut value.0, <&[Value] as ValueType>::g_type()); + gobject_ffi::g_value_init(&mut value.0, <&[Value] as ValueType>::g_type()); match v { Cow::Borrowed(array) => for e in array { - gst::gst_value_array_append_value( + gst_ffi::gst_value_array_append_value( &mut value.0, - e.as_ptr() as *mut gobject::GValue, + e.as_ptr() as *mut gobject_ffi::GValue, ); }, Cow::Owned(array) => for e in array { - gst::gst_value_array_append_and_take_value( + gst_ffi::gst_value_array_append_and_take_value( &mut value.0, - e.as_ptr() as *mut gobject::GValue, + e.as_ptr() as *mut gobject_ffi::GValue, ); mem::forget(e); }, @@ -593,25 +593,25 @@ where self.value } - pub unsafe fn as_ptr(&self) -> *const gobject::GValue { + pub unsafe fn as_ptr(&self) -> *const gobject_ffi::GValue { &self.value.0 } - pub unsafe fn from_ptr(ptr: *const gobject::GValue) -> Option> { + pub unsafe fn from_ptr(ptr: *const gobject_ffi::GValue) -> Option> { if let Some(value) = Value::from_ptr(ptr) { return TypedValue::from_value(value); } None } - pub unsafe fn from_raw(value: gobject::GValue) -> Option> { + pub unsafe fn from_raw(value: gobject_ffi::GValue) -> Option> { if let Some(value) = Value::from_raw(value) { return TypedValue::from_value(value); } None } - pub unsafe fn into_raw(mut self) -> gobject::GValue { + pub unsafe fn into_raw(mut self) -> gobject_ffi::GValue { mem::replace(&mut self.value.0, mem::zeroed()) } } @@ -703,11 +703,11 @@ where self.value } - pub unsafe fn as_ptr(&self) -> *const gobject::GValue { + pub unsafe fn as_ptr(&self) -> *const gobject_ffi::GValue { self.value.0 } - pub unsafe fn from_ptr(ptr: *const gobject::GValue) -> Option> { + pub unsafe fn from_ptr(ptr: *const gobject_ffi::GValue) -> Option> { if let Some(value) = ValueRef::from_ptr(ptr) { return TypedValueRef::from_value_ref(value); } @@ -724,7 +724,7 @@ mod tests { ($name: ident, $typ:ty, $value:expr, $variant:ident) => { #[test] fn $name() { - unsafe { gst::gst_init(ptr::null_mut(), ptr::null_mut()) }; + unsafe { gst_ffi::gst_init(ptr::null_mut(), ptr::null_mut()) }; let value = Value::new($value); if let ValueView::$variant(v) = value.get() { @@ -770,7 +770,7 @@ mod tests { #[test] fn string_owned() { - unsafe { gst::gst_init(ptr::null_mut(), ptr::null_mut()) }; + unsafe { gst_ffi::gst_init(ptr::null_mut(), ptr::null_mut()) }; let orig_v = String::from("foo"); @@ -813,7 +813,7 @@ mod tests { #[test] fn string_borrowed() { - unsafe { gst::gst_init(ptr::null_mut(), ptr::null_mut()) }; + unsafe { gst_ffi::gst_init(ptr::null_mut(), ptr::null_mut()) }; let orig_v = "foo"; @@ -852,7 +852,7 @@ mod tests { #[test] fn array_owned() { - unsafe { gst::gst_init(ptr::null_mut(), ptr::null_mut()) }; + unsafe { gst_ffi::gst_init(ptr::null_mut(), ptr::null_mut()) }; let orig_v = vec![Value::new("a"), Value::new("b")]; @@ -887,7 +887,7 @@ mod tests { #[test] fn array_borrowed() { - unsafe { gst::gst_init(ptr::null_mut(), ptr::null_mut()) }; + unsafe { gst_ffi::gst_init(ptr::null_mut(), ptr::null_mut()) }; let orig_v = vec![Value::new("a"), Value::new("b")]; @@ -919,7 +919,7 @@ mod tests { #[test] fn buffer() { - unsafe { gst::gst_init(ptr::null_mut(), ptr::null_mut()) }; + unsafe { gst_ffi::gst_init(ptr::null_mut(), ptr::null_mut()) }; let orig_v = Buffer::from_vec(vec![1, 2, 3, 4]).unwrap();