Run everything through latest rustfmt-nightly

This commit is contained in:
Sebastian Dröge 2017-10-17 12:06:51 +03:00
parent 9a6713b901
commit e1d134c4be
31 changed files with 184 additions and 150 deletions

View file

@ -11,10 +11,10 @@ extern crate libc;
extern crate glib_sys as glib_ffi; extern crate glib_sys as glib_ffi;
extern crate gobject_sys as gobject_ffi; extern crate gobject_sys as gobject_ffi;
extern crate gstreamer as gst; extern crate gstreamer as gst;
extern crate gstreamer_base as gst_base;
extern crate gstreamer_app_sys as ffi; extern crate gstreamer_app_sys as ffi;
extern crate gstreamer_sys as gst_ffi; extern crate gstreamer_base as gst_base;
extern crate gstreamer_base_sys as gst_base_ffi; extern crate gstreamer_base_sys as gst_base_ffi;
extern crate gstreamer_sys as gst_ffi;
#[macro_use] #[macro_use]
extern crate glib; extern crate glib;

View file

@ -264,8 +264,8 @@ impl glib::value::SetValue for AudioFormatInfo {
unsafe fn set_value(value: &mut glib::Value, this: &Self) { unsafe fn set_value(value: &mut glib::Value, this: &Self) {
gobject_ffi::g_value_set_boxed( gobject_ffi::g_value_set_boxed(
value.to_glib_none_mut().0, value.to_glib_none_mut().0,
glib::translate::ToGlibPtr::<*const ffi::GstAudioFormatInfo>::to_glib_none(this).0 as glib::translate::ToGlibPtr::<*const ffi::GstAudioFormatInfo>::to_glib_none(this).0
glib_ffi::gpointer, as glib_ffi::gpointer,
) )
} }
} }
@ -275,8 +275,8 @@ impl glib::value::SetValueOptional for AudioFormatInfo {
unsafe fn set_value_optional(value: &mut glib::Value, this: Option<&Self>) { unsafe fn set_value_optional(value: &mut glib::Value, this: Option<&Self>) {
gobject_ffi::g_value_set_boxed( gobject_ffi::g_value_set_boxed(
value.to_glib_none_mut().0, value.to_glib_none_mut().0,
glib::translate::ToGlibPtr::<*const ffi::GstAudioFormatInfo>::to_glib_none(&this).0 as glib::translate::ToGlibPtr::<*const ffi::GstAudioFormatInfo>::to_glib_none(&this).0
glib_ffi::gpointer, as glib_ffi::gpointer,
) )
} }
} }

View file

@ -281,9 +281,8 @@ impl glib::types::StaticType for AudioInfo {
#[doc(hidden)] #[doc(hidden)]
impl<'a> glib::value::FromValueOptional<'a> for AudioInfo { impl<'a> glib::value::FromValueOptional<'a> for AudioInfo {
unsafe fn from_value_optional(value: &glib::Value) -> Option<Self> { unsafe fn from_value_optional(value: &glib::Value) -> Option<Self> {
Option::<AudioInfo>::from_glib_none( Option::<AudioInfo>::from_glib_none(gobject_ffi::g_value_get_boxed(value.to_glib_none().0)
gobject_ffi::g_value_get_boxed(value.to_glib_none().0) as *mut ffi::GstAudioInfo, as *mut ffi::GstAudioInfo)
)
} }
} }
@ -292,8 +291,8 @@ impl glib::value::SetValue for AudioInfo {
unsafe fn set_value(value: &mut glib::Value, this: &Self) { unsafe fn set_value(value: &mut glib::Value, this: &Self) {
gobject_ffi::g_value_set_boxed( gobject_ffi::g_value_set_boxed(
value.to_glib_none_mut().0, value.to_glib_none_mut().0,
glib::translate::ToGlibPtr::<*const ffi::GstAudioInfo>::to_glib_none(this).0 as glib::translate::ToGlibPtr::<*const ffi::GstAudioInfo>::to_glib_none(this).0
glib_ffi::gpointer, as glib_ffi::gpointer,
) )
} }
} }
@ -303,8 +302,8 @@ impl glib::value::SetValueOptional for AudioInfo {
unsafe fn set_value_optional(value: &mut glib::Value, this: Option<&Self>) { unsafe fn set_value_optional(value: &mut glib::Value, this: Option<&Self>) {
gobject_ffi::g_value_set_boxed( gobject_ffi::g_value_set_boxed(
value.to_glib_none_mut().0, value.to_glib_none_mut().0,
glib::translate::ToGlibPtr::<*const ffi::GstAudioInfo>::to_glib_none(&this).0 as glib::translate::ToGlibPtr::<*const ffi::GstAudioInfo>::to_glib_none(&this).0
glib_ffi::gpointer, as glib_ffi::gpointer,
) )
} }
} }

View file

@ -32,9 +32,7 @@ glib_wrapper! {
impl FlowCombiner { impl FlowCombiner {
pub fn new() -> FlowCombiner { pub fn new() -> FlowCombiner {
assert_initialized_main_thread!(); assert_initialized_main_thread!();
unsafe { unsafe { from_glib_full(ffi::gst_flow_combiner_new()) }
from_glib_full(ffi::gst_flow_combiner_new())
}
} }
pub fn add_pad<P: IsA<gst::Pad>>(&self, pad: &P) { pub fn add_pad<P: IsA<gst::Pad>>(&self, pad: &P) {
@ -63,13 +61,24 @@ impl FlowCombiner {
pub fn update_flow(&self, fret: gst::FlowReturn) -> gst::FlowReturn { pub fn update_flow(&self, fret: gst::FlowReturn) -> gst::FlowReturn {
unsafe { unsafe {
from_glib(ffi::gst_flow_combiner_update_flow(self.to_glib_none().0, fret.to_glib())) from_glib(ffi::gst_flow_combiner_update_flow(
self.to_glib_none().0,
fret.to_glib(),
))
} }
} }
pub fn update_pad_flow<P: IsA<gst::Pad>>(&self, pad: &P, fret: gst::FlowReturn) -> gst::FlowReturn { pub fn update_pad_flow<P: IsA<gst::Pad>>(
&self,
pad: &P,
fret: gst::FlowReturn,
) -> gst::FlowReturn {
unsafe { unsafe {
from_glib(ffi::gst_flow_combiner_update_pad_flow(self.to_glib_none().0, pad.to_glib_none().0, fret.to_glib())) from_glib(ffi::gst_flow_combiner_update_pad_flow(
self.to_glib_none().0,
pad.to_glib_none().0,
fret.to_glib(),
))
} }
} }
} }

View file

@ -20,8 +20,8 @@ impl PlayerGMainContextSignalDispatcher {
let application_context = application_context.to_glib_none(); let application_context = application_context.to_glib_none();
unsafe { unsafe {
from_glib_full( from_glib_full(
ffi::gst_player_g_main_context_signal_dispatcher_new(application_context.0) as ffi::gst_player_g_main_context_signal_dispatcher_new(application_context.0)
*mut ffi::GstPlayerGMainContextSignalDispatcher, as *mut ffi::GstPlayerGMainContextSignalDispatcher,
) )
} }
} }

View file

@ -60,8 +60,8 @@ impl<
O: IsA<PlayerVideoOverlayVideoRenderer> + IsA<glib::object::Object>, O: IsA<PlayerVideoOverlayVideoRenderer> + IsA<glib::object::Object>,
> PlayerVideoOverlayVideoRendererExtManual for O { > PlayerVideoOverlayVideoRendererExtManual for O {
unsafe fn get_window_handle(&self) -> uintptr_t { unsafe fn get_window_handle(&self) -> uintptr_t {
ffi::gst_player_video_overlay_video_renderer_get_window_handle(self.to_glib_none().0) as ffi::gst_player_video_overlay_video_renderer_get_window_handle(self.to_glib_none().0)
uintptr_t as uintptr_t
} }
unsafe fn set_window_handle(&self, window_handle: uintptr_t) { unsafe fn set_window_handle(&self, window_handle: uintptr_t) {

View file

@ -248,8 +248,8 @@ impl VideoFrame<Writable> {
info.to_glib_none().0 as *mut _, info.to_glib_none().0 as *mut _,
buffer.to_glib_none().0, buffer.to_glib_none().0,
mem::transmute( mem::transmute(
ffi::GST_VIDEO_FRAME_MAP_FLAG_NO_REF.bits() | gst_ffi::GST_MAP_READ.bits() | ffi::GST_VIDEO_FRAME_MAP_FLAG_NO_REF.bits() | gst_ffi::GST_MAP_READ.bits()
gst_ffi::GST_MAP_WRITE.bits(), | gst_ffi::GST_MAP_WRITE.bits(),
), ),
)); ));
@ -277,8 +277,8 @@ impl VideoFrame<Writable> {
buffer.to_glib_none().0, buffer.to_glib_none().0,
id, id,
mem::transmute( mem::transmute(
ffi::GST_VIDEO_FRAME_MAP_FLAG_NO_REF.bits() | gst_ffi::GST_MAP_READ.bits() | ffi::GST_VIDEO_FRAME_MAP_FLAG_NO_REF.bits() | gst_ffi::GST_MAP_READ.bits()
gst_ffi::GST_MAP_WRITE.bits(), | gst_ffi::GST_MAP_WRITE.bits(),
), ),
)); ));

View file

@ -596,9 +596,8 @@ impl glib::types::StaticType for VideoInfo {
#[doc(hidden)] #[doc(hidden)]
impl<'a> glib::value::FromValueOptional<'a> for VideoInfo { impl<'a> glib::value::FromValueOptional<'a> for VideoInfo {
unsafe fn from_value_optional(value: &glib::Value) -> Option<Self> { unsafe fn from_value_optional(value: &glib::Value) -> Option<Self> {
Option::<VideoInfo>::from_glib_none( Option::<VideoInfo>::from_glib_none(gobject_ffi::g_value_get_boxed(value.to_glib_none().0)
gobject_ffi::g_value_get_boxed(value.to_glib_none().0) as *mut ffi::GstVideoInfo, as *mut ffi::GstVideoInfo)
)
} }
} }
@ -607,8 +606,8 @@ impl glib::value::SetValue for VideoInfo {
unsafe fn set_value(value: &mut glib::Value, this: &Self) { unsafe fn set_value(value: &mut glib::Value, this: &Self) {
gobject_ffi::g_value_set_boxed( gobject_ffi::g_value_set_boxed(
value.to_glib_none_mut().0, value.to_glib_none_mut().0,
glib::translate::ToGlibPtr::<*const ffi::GstVideoInfo>::to_glib_none(this).0 as glib::translate::ToGlibPtr::<*const ffi::GstVideoInfo>::to_glib_none(this).0
glib_ffi::gpointer, as glib_ffi::gpointer,
) )
} }
} }
@ -618,8 +617,8 @@ impl glib::value::SetValueOptional for VideoInfo {
unsafe fn set_value_optional(value: &mut glib::Value, this: Option<&Self>) { unsafe fn set_value_optional(value: &mut glib::Value, this: Option<&Self>) {
gobject_ffi::g_value_set_boxed( gobject_ffi::g_value_set_boxed(
value.to_glib_none_mut().0, value.to_glib_none_mut().0,
glib::translate::ToGlibPtr::<*const ffi::GstVideoInfo>::to_glib_none(&this).0 as glib::translate::ToGlibPtr::<*const ffi::GstVideoInfo>::to_glib_none(&this).0
glib_ffi::gpointer, as glib_ffi::gpointer,
) )
} }
} }

View file

@ -11,7 +11,7 @@ use Element;
use glib; use glib;
use glib::IsA; use glib::IsA;
use glib::translate::{from_glib, from_glib_full, ToGlibPtr, ToGlib}; use glib::translate::{from_glib, from_glib_full, ToGlib, ToGlibPtr};
use ffi; use ffi;
@ -60,37 +60,30 @@ impl<O: IsA<Bin>> BinExtManual for O {
fn iterate_all_by_interface(&self, iface: glib::types::Type) -> ::Iterator<Element> { fn iterate_all_by_interface(&self, iface: glib::types::Type) -> ::Iterator<Element> {
unsafe { unsafe {
from_glib_full(ffi::gst_bin_iterate_all_by_interface(self.to_glib_none().0, iface.to_glib())) from_glib_full(ffi::gst_bin_iterate_all_by_interface(
self.to_glib_none().0,
iface.to_glib(),
))
} }
} }
fn iterate_elements(&self) -> ::Iterator<Element> { fn iterate_elements(&self) -> ::Iterator<Element> {
unsafe { unsafe { from_glib_full(ffi::gst_bin_iterate_elements(self.to_glib_none().0)) }
from_glib_full(ffi::gst_bin_iterate_elements(self.to_glib_none().0))
}
} }
fn iterate_recurse(&self) -> ::Iterator<Element> { fn iterate_recurse(&self) -> ::Iterator<Element> {
unsafe { unsafe { from_glib_full(ffi::gst_bin_iterate_recurse(self.to_glib_none().0)) }
from_glib_full(ffi::gst_bin_iterate_recurse(self.to_glib_none().0))
}
} }
fn iterate_sinks(&self) -> ::Iterator<Element> { fn iterate_sinks(&self) -> ::Iterator<Element> {
unsafe { unsafe { from_glib_full(ffi::gst_bin_iterate_sinks(self.to_glib_none().0)) }
from_glib_full(ffi::gst_bin_iterate_sinks(self.to_glib_none().0))
}
} }
fn iterate_sorted(&self) -> ::Iterator<Element> { fn iterate_sorted(&self) -> ::Iterator<Element> {
unsafe { unsafe { from_glib_full(ffi::gst_bin_iterate_sorted(self.to_glib_none().0)) }
from_glib_full(ffi::gst_bin_iterate_sorted(self.to_glib_none().0))
}
} }
fn iterate_sources(&self) -> ::Iterator<Element> { fn iterate_sources(&self) -> ::Iterator<Element> {
unsafe { unsafe { from_glib_full(ffi::gst_bin_iterate_sources(self.to_glib_none().0)) }
from_glib_full(ffi::gst_bin_iterate_sources(self.to_glib_none().0))
}
} }
} }

View file

@ -334,8 +334,8 @@ impl ToOwned for BufferRef {
fn to_owned(&self) -> GstRc<BufferRef> { fn to_owned(&self) -> GstRc<BufferRef> {
unsafe { unsafe {
from_glib_full(ffi::gst_mini_object_copy(self.as_ptr() as *const _) as from_glib_full(ffi::gst_mini_object_copy(self.as_ptr() as *const _)
*mut _) as *mut _)
} }
} }
} }

View file

@ -88,8 +88,8 @@ impl ToOwned for BufferListRef {
fn to_owned(&self) -> GstRc<BufferListRef> { fn to_owned(&self) -> GstRc<BufferListRef> {
unsafe { unsafe {
from_glib_full(ffi::gst_mini_object_copy(self.as_ptr() as *const _) as from_glib_full(ffi::gst_mini_object_copy(self.as_ptr() as *const _)
*mut _) as *mut _)
} }
} }
} }

View file

@ -357,8 +357,8 @@ impl ToOwned for CapsRef {
fn to_owned(&self) -> GstRc<CapsRef> { fn to_owned(&self) -> GstRc<CapsRef> {
unsafe { unsafe {
from_glib_full(ffi::gst_mini_object_copy(self.as_ptr() as *const _) as from_glib_full(ffi::gst_mini_object_copy(self.as_ptr() as *const _)
*mut _) as *mut _)
} }
} }
} }

View file

@ -81,8 +81,8 @@ impl ToOwned for ContextRef {
fn to_owned(&self) -> GstRc<ContextRef> { fn to_owned(&self) -> GstRc<ContextRef> {
unsafe { unsafe {
from_glib_full(ffi::gst_mini_object_copy(self.as_ptr() as *const _) as from_glib_full(ffi::gst_mini_object_copy(self.as_ptr() as *const _)
*mut _) as *mut _)
} }
} }
} }

View file

@ -23,8 +23,8 @@ pub trait DeviceProviderExtManual {
impl<O: IsA<DeviceProvider>> DeviceProviderExtManual for O { impl<O: IsA<DeviceProvider>> DeviceProviderExtManual for O {
fn get_metadata<'a>(&self, key: &str) -> Option<&'a str> { fn get_metadata<'a>(&self, key: &str) -> Option<&'a str> {
unsafe { unsafe {
let klass = (*(self.to_glib_none().0 as *mut gobject_ffi::GTypeInstance)).g_class as let klass = (*(self.to_glib_none().0 as *mut gobject_ffi::GTypeInstance)).g_class
*mut ffi::GstDeviceProviderClass; as *mut ffi::GstDeviceProviderClass;
let ptr = ffi::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);

View file

@ -10,7 +10,7 @@ use Element;
use glib; use glib;
use glib::IsA; use glib::IsA;
use glib::translate::{from_glib, from_glib_none, from_glib_full, FromGlibPtrContainer, ToGlibPtr}; use glib::translate::{from_glib, from_glib_full, from_glib_none, FromGlibPtrContainer, ToGlibPtr};
use QueryRef; use QueryRef;
use Event; use Event;
use Pad; use Pad;
@ -115,8 +115,8 @@ impl<O: IsA<Element>> ElementExtManual for O {
fn get_metadata<'a>(&self, key: &str) -> Option<&'a str> { fn get_metadata<'a>(&self, key: &str) -> Option<&'a str> {
unsafe { unsafe {
let klass = (*(self.to_glib_none().0 as *mut gobject_ffi::GTypeInstance)).g_class as let klass = (*(self.to_glib_none().0 as *mut gobject_ffi::GTypeInstance)).g_class
*mut ffi::GstElementClass; as *mut ffi::GstElementClass;
let ptr = ffi::gst_element_class_get_metadata(klass, key.to_glib_none().0); let ptr = ffi::gst_element_class_get_metadata(klass, key.to_glib_none().0);
@ -130,8 +130,8 @@ impl<O: IsA<Element>> ElementExtManual for O {
fn get_pad_template(&self, name: &str) -> Option<PadTemplate> { fn get_pad_template(&self, name: &str) -> Option<PadTemplate> {
unsafe { unsafe {
let klass = (*(self.to_glib_none().0 as *mut gobject_ffi::GTypeInstance)).g_class as let klass = (*(self.to_glib_none().0 as *mut gobject_ffi::GTypeInstance)).g_class
*mut ffi::GstElementClass; as *mut ffi::GstElementClass;
from_glib_none(ffi::gst_element_class_get_pad_template( from_glib_none(ffi::gst_element_class_get_pad_template(
klass, klass,
@ -142,8 +142,8 @@ impl<O: IsA<Element>> ElementExtManual for O {
fn get_pad_template_list(&self) -> Vec<PadTemplate> { fn get_pad_template_list(&self) -> Vec<PadTemplate> {
unsafe { unsafe {
let klass = (*(self.to_glib_none().0 as *mut gobject_ffi::GTypeInstance)).g_class as let klass = (*(self.to_glib_none().0 as *mut gobject_ffi::GTypeInstance)).g_class
*mut ffi::GstElementClass; as *mut ffi::GstElementClass;
FromGlibPtrContainer::from_glib_none( FromGlibPtrContainer::from_glib_none(
ffi::gst_element_class_get_pad_template_list(klass), ffi::gst_element_class_get_pad_template_list(klass),
@ -217,21 +217,15 @@ impl<O: IsA<Element>> ElementExtManual for O {
} }
fn iterate_pads(&self) -> ::Iterator<Pad> { fn iterate_pads(&self) -> ::Iterator<Pad> {
unsafe { unsafe { from_glib_full(ffi::gst_element_iterate_pads(self.to_glib_none().0)) }
from_glib_full(ffi::gst_element_iterate_pads(self.to_glib_none().0))
}
} }
fn iterate_sink_pads(&self) -> ::Iterator<Pad> { fn iterate_sink_pads(&self) -> ::Iterator<Pad> {
unsafe { unsafe { from_glib_full(ffi::gst_element_iterate_sink_pads(self.to_glib_none().0)) }
from_glib_full(ffi::gst_element_iterate_sink_pads(self.to_glib_none().0))
}
} }
fn iterate_src_pads(&self) -> ::Iterator<Pad> { fn iterate_src_pads(&self) -> ::Iterator<Pad> {
unsafe { unsafe { from_glib_full(ffi::gst_element_iterate_src_pads(self.to_glib_none().0)) }
from_glib_full(ffi::gst_element_iterate_src_pads(self.to_glib_none().0))
}
} }
} }

View file

@ -498,8 +498,8 @@ impl<T: 'static> glib::value::SetValue for Iterator<T> {
unsafe fn set_value(value: &mut glib::Value, this: &Self) { unsafe fn set_value(value: &mut glib::Value, this: &Self) {
gobject_ffi::g_value_set_boxed( gobject_ffi::g_value_set_boxed(
value.to_glib_none_mut().0, value.to_glib_none_mut().0,
glib::translate::ToGlibPtr::<*const ffi::GstIterator>::to_glib_none(this).0 as glib::translate::ToGlibPtr::<*const ffi::GstIterator>::to_glib_none(this).0
glib_ffi::gpointer, as glib_ffi::gpointer,
) )
} }
} }
@ -509,8 +509,8 @@ impl<T: 'static> glib::value::SetValueOptional for Iterator<T> {
unsafe fn set_value_optional(value: &mut glib::Value, this: Option<&Self>) { unsafe fn set_value_optional(value: &mut glib::Value, this: Option<&Self>) {
gobject_ffi::g_value_set_boxed( gobject_ffi::g_value_set_boxed(
value.to_glib_none_mut().0, value.to_glib_none_mut().0,
glib::translate::ToGlibPtr::<*const ffi::GstIterator>::to_glib_none(&this).0 as glib::translate::ToGlibPtr::<*const ffi::GstIterator>::to_glib_none(&this).0
glib_ffi::gpointer, as glib_ffi::gpointer,
) )
} }
} }

View file

@ -2315,8 +2315,7 @@ pub struct RedirectBuilder<'a> {
tag_list: Option<&'a TagList>, tag_list: Option<&'a TagList>,
entry_struct: Option<Structure>, entry_struct: Option<Structure>,
#[cfg_attr(feature = "cargo-clippy", allow(type_complexity))] #[cfg_attr(feature = "cargo-clippy", allow(type_complexity))]
entries: entries: Option<&'a [(&'a str, Option<&'a TagList>, Option<&'a Structure>)]>,
Option<&'a [(&'a str, Option<&'a TagList>, Option<&'a Structure>)]>,
} }
#[cfg(feature = "v1_10")] #[cfg(feature = "v1_10")]
impl<'a> RedirectBuilder<'a> { impl<'a> RedirectBuilder<'a> {

View file

@ -67,8 +67,8 @@ impl<T: MiniObject> GstRc<T> {
} }
self.obj = T::from_mut_ptr( self.obj = T::from_mut_ptr(
ffi::gst_mini_object_make_writable(self.as_mut_ptr() as *mut ffi::GstMiniObject) as ffi::gst_mini_object_make_writable(self.as_mut_ptr() as *mut ffi::GstMiniObject)
*mut T::GstType, as *mut T::GstType,
); );
assert!(self.is_writable()); assert!(self.is_writable());
@ -194,8 +194,8 @@ where
fn copy(&self) -> GstRc<Self> { fn copy(&self) -> GstRc<Self> {
unsafe { unsafe {
GstRc::from_glib_full( GstRc::from_glib_full(
ffi::gst_mini_object_copy(self.as_ptr() as *const ffi::GstMiniObject) as ffi::gst_mini_object_copy(self.as_ptr() as *const ffi::GstMiniObject)
*const Self::GstType, as *const Self::GstType,
) )
} }
} }
@ -261,8 +261,8 @@ impl<'a, T: MiniObject + 'static> ToGlibContainerFromSlice<'a, *mut *mut T::GstT
let v: Vec<_> = t.iter().map(|s| s.to_glib_none()).collect(); let v: Vec<_> = t.iter().map(|s| s.to_glib_none()).collect();
let v_ptr = unsafe { let v_ptr = unsafe {
let v_ptr = glib_ffi::g_malloc0(mem::size_of::<*mut T::GstType>() * t.len() + 1) as let v_ptr = glib_ffi::g_malloc0(mem::size_of::<*mut T::GstType>() * t.len() + 1)
*mut *mut T::GstType; as *mut *mut T::GstType;
for (i, s) in v.iter().enumerate() { for (i, s) in v.iter().enumerate() {
ptr::write(v_ptr.offset(i as isize), s.0); ptr::write(v_ptr.offset(i as isize), s.0);
@ -277,8 +277,8 @@ impl<'a, T: MiniObject + 'static> ToGlibContainerFromSlice<'a, *mut *mut T::GstT
fn to_glib_full_from_slice(t: &[GstRc<T>]) -> *mut *mut T::GstType { fn to_glib_full_from_slice(t: &[GstRc<T>]) -> *mut *mut T::GstType {
skip_assert_initialized!(); skip_assert_initialized!();
unsafe { unsafe {
let v_ptr = glib_ffi::g_malloc0(mem::size_of::<*mut T::GstType>() * t.len() + 1) as let v_ptr = glib_ffi::g_malloc0(mem::size_of::<*mut T::GstType>() * t.len() + 1)
*mut *mut T::GstType; as *mut *mut T::GstType;
for (i, s) in t.iter().enumerate() { for (i, s) in t.iter().enumerate() {
ptr::write(v_ptr.offset(i as isize), s.to_glib_full()); ptr::write(v_ptr.offset(i as isize), s.to_glib_full());

View file

@ -25,7 +25,7 @@ use std::cell::RefCell;
use glib; use glib;
use glib::{IsA, StaticType}; use glib::{IsA, StaticType};
use glib::translate::{mut_override, from_glib, from_glib_borrow, from_glib_full, from_glib_none, use glib::translate::{from_glib, from_glib_borrow, from_glib_full, from_glib_none, mut_override,
FromGlib, ToGlib, ToGlibPtr}; FromGlib, ToGlib, ToGlibPtr};
use glib::source::CallbackGuard; use glib::source::CallbackGuard;
use glib_ffi; use glib_ffi;
@ -40,7 +40,10 @@ impl Pad {
pub fn new_from_static_template(templ: &StaticPadTemplate, name: &str) -> Pad { pub fn new_from_static_template(templ: &StaticPadTemplate, name: &str) -> Pad {
assert_initialized_main_thread!(); assert_initialized_main_thread!();
unsafe { unsafe {
from_glib_none(ffi::gst_pad_new_from_static_template(mut_override(templ.to_glib_none().0), name.to_glib_none().0)) from_glib_none(ffi::gst_pad_new_from_static_template(
mut_override(templ.to_glib_none().0),
name.to_glib_none().0,
))
} }
} }
} }

View file

@ -78,12 +78,23 @@ impl ProxyPad {
} }
} }
pub fn iterate_internal_links_default<'a, P: IsA<Pad>, Q: IsA<Object> + 'a, R: Into<Option<&'a Q>>>(pad: &P, parent: R) -> Option<::Iterator<Pad>> { pub fn iterate_internal_links_default<
'a,
P: IsA<Pad>,
Q: IsA<Object> + 'a,
R: Into<Option<&'a Q>>,
>(
pad: &P,
parent: R,
) -> Option<::Iterator<Pad>> {
skip_assert_initialized!(); skip_assert_initialized!();
let parent = parent.into(); let parent = parent.into();
let parent = parent.to_glib_none(); let parent = parent.to_glib_none();
unsafe { unsafe {
from_glib_full(ffi::gst_proxy_pad_iterate_internal_links_default(pad.to_glib_none().0, parent.0)) from_glib_full(ffi::gst_proxy_pad_iterate_internal_links_default(
pad.to_glib_none().0,
parent.0,
))
} }
} }
} }

View file

@ -89,8 +89,8 @@ impl ToOwned for SampleRef {
fn to_owned(&self) -> GstRc<SampleRef> { fn to_owned(&self) -> GstRc<SampleRef> {
unsafe { unsafe {
from_glib_full(ffi::gst_mini_object_copy(self.as_ptr() as *const _) as from_glib_full(ffi::gst_mini_object_copy(self.as_ptr() as *const _)
*mut _) as *mut _)
} }
} }
} }

View file

@ -330,8 +330,8 @@ impl Default for Segment {
#[doc(hidden)] #[doc(hidden)]
impl<'a> glib::value::FromValueOptional<'a> for Segment { impl<'a> glib::value::FromValueOptional<'a> for Segment {
unsafe fn from_value_optional(value: &glib::Value) -> Option<Self> { unsafe fn from_value_optional(value: &glib::Value) -> Option<Self> {
Option::<Segment>::from_glib_none(gobject_ffi::g_value_get_boxed(value.to_glib_none().0) as Option::<Segment>::from_glib_none(gobject_ffi::g_value_get_boxed(value.to_glib_none().0)
*mut ffi::GstSegment) as *mut ffi::GstSegment)
} }
} }
@ -340,8 +340,8 @@ impl glib::value::SetValue for Segment {
unsafe fn set_value(value: &mut glib::Value, this: &Self) { unsafe fn set_value(value: &mut glib::Value, this: &Self) {
gobject_ffi::g_value_set_boxed( gobject_ffi::g_value_set_boxed(
value.to_glib_none_mut().0, value.to_glib_none_mut().0,
glib::translate::ToGlibPtr::<*const ffi::GstSegment>::to_glib_none(this).0 as glib::translate::ToGlibPtr::<*const ffi::GstSegment>::to_glib_none(this).0
glib_ffi::gpointer, as glib_ffi::gpointer,
) )
} }
} }
@ -351,8 +351,8 @@ impl glib::value::SetValueOptional for Segment {
unsafe fn set_value_optional(value: &mut glib::Value, this: Option<&Self>) { unsafe fn set_value_optional(value: &mut glib::Value, this: Option<&Self>) {
gobject_ffi::g_value_set_boxed( gobject_ffi::g_value_set_boxed(
value.to_glib_none_mut().0, value.to_glib_none_mut().0,
glib::translate::ToGlibPtr::<*const ffi::GstSegment>::to_glib_none(&this).0 as glib::translate::ToGlibPtr::<*const ffi::GstSegment>::to_glib_none(&this).0
glib_ffi::gpointer, as glib_ffi::gpointer,
) )
} }
} }

View file

@ -36,9 +36,8 @@ impl glib::types::StaticType for StaticCaps {
#[doc(hidden)] #[doc(hidden)]
impl<'a> glib::value::FromValueOptional<'a> for StaticCaps { impl<'a> glib::value::FromValueOptional<'a> for StaticCaps {
unsafe fn from_value_optional(value: &glib::Value) -> Option<Self> { unsafe fn from_value_optional(value: &glib::Value) -> Option<Self> {
Option::<StaticCaps>::from_glib_none( Option::<StaticCaps>::from_glib_none(gobject_ffi::g_value_get_boxed(value.to_glib_none().0)
gobject_ffi::g_value_get_boxed(value.to_glib_none().0) as *mut ffi::GstStaticCaps, as *mut ffi::GstStaticCaps)
)
} }
} }
@ -47,8 +46,8 @@ impl glib::value::SetValue for StaticCaps {
unsafe fn set_value(value: &mut glib::Value, this: &Self) { unsafe fn set_value(value: &mut glib::Value, this: &Self) {
gobject_ffi::g_value_set_boxed( gobject_ffi::g_value_set_boxed(
value.to_glib_none_mut().0, value.to_glib_none_mut().0,
glib::translate::ToGlibPtr::<*const ffi::GstStaticCaps>::to_glib_none(this).0 as glib::translate::ToGlibPtr::<*const ffi::GstStaticCaps>::to_glib_none(this).0
glib_ffi::gpointer, as glib_ffi::gpointer,
) )
} }
} }
@ -58,8 +57,8 @@ impl glib::value::SetValueOptional for StaticCaps {
unsafe fn set_value_optional(value: &mut glib::Value, this: Option<&Self>) { unsafe fn set_value_optional(value: &mut glib::Value, this: Option<&Self>) {
gobject_ffi::g_value_set_boxed( gobject_ffi::g_value_set_boxed(
value.to_glib_none_mut().0, value.to_glib_none_mut().0,
glib::translate::ToGlibPtr::<*const ffi::GstStaticCaps>::to_glib_none(&this).0 as glib::translate::ToGlibPtr::<*const ffi::GstStaticCaps>::to_glib_none(&this).0
glib_ffi::gpointer, as glib_ffi::gpointer,
) )
} }
} }

View file

@ -55,8 +55,8 @@ impl glib::types::StaticType for StaticPadTemplate {
impl<'a> glib::value::FromValueOptional<'a> for StaticPadTemplate { impl<'a> glib::value::FromValueOptional<'a> for StaticPadTemplate {
unsafe fn from_value_optional(value: &glib::Value) -> Option<Self> { unsafe fn from_value_optional(value: &glib::Value) -> Option<Self> {
Option::<StaticPadTemplate>::from_glib_none( Option::<StaticPadTemplate>::from_glib_none(
gobject_ffi::g_value_get_boxed(value.to_glib_none().0) as gobject_ffi::g_value_get_boxed(value.to_glib_none().0)
*mut ffi::GstStaticPadTemplate, as *mut ffi::GstStaticPadTemplate,
) )
} }
} }
@ -66,8 +66,8 @@ impl glib::value::SetValue for StaticPadTemplate {
unsafe fn set_value(value: &mut glib::Value, this: &Self) { unsafe fn set_value(value: &mut glib::Value, this: &Self) {
gobject_ffi::g_value_set_boxed( gobject_ffi::g_value_set_boxed(
value.to_glib_none_mut().0, value.to_glib_none_mut().0,
glib::translate::ToGlibPtr::<*const ffi::GstStaticPadTemplate>::to_glib_none(this).0 as glib::translate::ToGlibPtr::<*const ffi::GstStaticPadTemplate>::to_glib_none(this).0
glib_ffi::gpointer, as glib_ffi::gpointer,
) )
} }
} }
@ -77,8 +77,8 @@ impl glib::value::SetValueOptional for StaticPadTemplate {
unsafe fn set_value_optional(value: &mut glib::Value, this: Option<&Self>) { unsafe fn set_value_optional(value: &mut glib::Value, this: Option<&Self>) {
gobject_ffi::g_value_set_boxed( gobject_ffi::g_value_set_boxed(
value.to_glib_none_mut().0, value.to_glib_none_mut().0,
glib::translate::ToGlibPtr::<*const ffi::GstStaticPadTemplate>::to_glib_none(&this).0 as glib::translate::ToGlibPtr::<*const ffi::GstStaticPadTemplate>::to_glib_none(&this).0
glib_ffi::gpointer, as glib_ffi::gpointer,
) )
} }
} }

View file

@ -103,7 +103,11 @@ impl_tag!(GeoLocationLongitute, f64, *TAG_GEO_LOCATION_LONGITUDE);
impl_tag!(GeoLocationElevation, f64, *TAG_GEO_LOCATION_ELEVATION); impl_tag!(GeoLocationElevation, f64, *TAG_GEO_LOCATION_ELEVATION);
impl_tag!(GeoLocationCity, &'a str, *TAG_GEO_LOCATION_CITY); impl_tag!(GeoLocationCity, &'a str, *TAG_GEO_LOCATION_CITY);
impl_tag!(GeoLocationCountry, &'a str, *TAG_GEO_LOCATION_COUNTRY); impl_tag!(GeoLocationCountry, &'a str, *TAG_GEO_LOCATION_COUNTRY);
impl_tag!(GeoLocationSublocation, &'a str, *TAG_GEO_LOCATION_SUBLOCATION); impl_tag!(
GeoLocationSublocation,
&'a str,
*TAG_GEO_LOCATION_SUBLOCATION
);
impl_tag!( impl_tag!(
GeoLocationHorizontalError, GeoLocationHorizontalError,
f64, f64,
@ -333,8 +337,8 @@ impl ToOwned for TagListRef {
fn to_owned(&self) -> GstRc<TagListRef> { fn to_owned(&self) -> GstRc<TagListRef> {
unsafe { unsafe {
from_glib_full(ffi::gst_mini_object_copy(self.as_ptr() as *const _) as from_glib_full(ffi::gst_mini_object_copy(self.as_ptr() as *const _)
*mut _) as *mut _)
} }
} }
} }

View file

@ -104,8 +104,8 @@ impl ToOwned for TocRef {
fn to_owned(&self) -> GstRc<TocRef> { fn to_owned(&self) -> GstRc<TocRef> {
unsafe { unsafe {
from_glib_full(ffi::gst_mini_object_copy(self.as_ptr() as *const _) as from_glib_full(ffi::gst_mini_object_copy(self.as_ptr() as *const _)
*mut _) as *mut _)
} }
} }
} }
@ -256,8 +256,8 @@ impl ToOwned for TocEntryRef {
fn to_owned(&self) -> GstRc<TocEntryRef> { fn to_owned(&self) -> GstRc<TocEntryRef> {
unsafe { unsafe {
from_glib_full(ffi::gst_mini_object_copy(self.as_ptr() as *const _) as from_glib_full(ffi::gst_mini_object_copy(self.as_ptr() as *const _)
*mut _) as *mut _)
} }
} }
} }

View file

@ -6,7 +6,8 @@ fn main() {
gst::init().unwrap(); gst::init().unwrap();
// Build the pipeline // Build the pipeline
let uri = "https://www.freedesktop.org/software/gstreamer-sdk/data/media/sintel_trailer-480p.webm"; let uri =
"https://www.freedesktop.org/software/gstreamer-sdk/data/media/sintel_trailer-480p.webm";
let pipeline = gst::parse_launch(&format!("playbin uri={}", uri)).unwrap(); let pipeline = gst::parse_launch(&format!("playbin uri={}", uri)).unwrap();
// Start playing // Start playing

View file

@ -23,7 +23,8 @@ fn main() {
convert.link(&sink).expect("Elements could not be linked."); convert.link(&sink).expect("Elements could not be linked.");
// Set the URI to play // Set the URI to play
let uri = "https://www.freedesktop.org/software/gstreamer-sdk/data/media/sintel_trailer-480p.webm"; let uri =
"https://www.freedesktop.org/software/gstreamer-sdk/data/media/sintel_trailer-480p.webm";
source source
.set_property("uri", &uri) .set_property("uri", &uri)
.expect("Can't set uri property on uridecodebin"); .expect("Can't set uri property on uridecodebin");

View file

@ -22,7 +22,8 @@ fn main() {
gst::ElementFactory::make("playbin", "playbin").expect("Failed to create playbin element"); gst::ElementFactory::make("playbin", "playbin").expect("Failed to create playbin element");
// Set the URI to play // Set the URI to play
let uri = "https://www.freedesktop.org/software/gstreamer-sdk/data/media/sintel_trailer-480p.webm"; let uri =
"https://www.freedesktop.org/software/gstreamer-sdk/data/media/sintel_trailer-480p.webm";
playbin playbin
.set_property("uri", &uri) .set_property("uri", &uri)
.expect("Can't set uri property on playbin"); .expect("Can't set uri property on playbin");
@ -62,16 +63,16 @@ fn main() {
custom_data.duration = custom_data custom_data.duration = custom_data
.playbin .playbin
.query_duration(gst::Format::Time) .query_duration(gst::Format::Time)
.expect("Could not query current duration.") as .expect("Could not query current duration.")
gst::ClockTime; as gst::ClockTime;
} }
// Print current position and total duration // Print current position and total duration
print!("\rPosition {} / {}", position, custom_data.duration); print!("\rPosition {} / {}", position, custom_data.duration);
io::stdout().flush().unwrap(); io::stdout().flush().unwrap();
if custom_data.seek_enabled && !custom_data.seek_done && if custom_data.seek_enabled && !custom_data.seek_done
position > 10 * gst::SECOND && position > 10 * gst::SECOND
{ {
println!("\nReached 10s, performing seek..."); println!("\nReached 10s, performing seek...");
custom_data custom_data

View file

@ -122,8 +122,7 @@ mod tutorial5 {
1.0 as f64, 1.0 as f64,
); );
let pipeline = playbin.clone(); let pipeline = playbin.clone();
let slider_update_signal_id = slider let slider_update_signal_id = slider.connect_value_changed(move |slider| {
.connect_value_changed(move |slider| {
let pipeline = &pipeline; let pipeline = &pipeline;
let value = slider.get_value() as u64; let value = slider.get_value() as u64;
if let Err(_) = pipeline.seek_simple( if let Err(_) = pipeline.seek_simple(

View file

@ -25,21 +25,43 @@ fn main() {
visual.set_property_from_str("shader", "none"); visual.set_property_from_str("shader", "none");
visual.set_property_from_str("style", "lines"); visual.set_property_from_str("style", "lines");
pipeline.add_many(&[&audio_source, &tee, &audio_queue, &audio_convert, pipeline
&audio_resample, &audio_sink, &video_queue, &visual, .add_many(&[
&video_convert, &video_sink]).unwrap(); &audio_source,
&tee,
&audio_queue,
&audio_convert,
&audio_resample,
&audio_sink,
&video_queue,
&visual,
&video_convert,
&video_sink,
])
.unwrap();
gst::Element::link_many(&[&audio_source, &tee]).unwrap(); gst::Element::link_many(&[&audio_source, &tee]).unwrap();
gst::Element::link_many(&[&audio_queue, &audio_convert, &audio_resample, &audio_sink]).unwrap(); gst::Element::link_many(&[
&audio_queue,
&audio_convert,
&audio_resample,
&audio_sink,
]).unwrap();
gst::Element::link_many(&[&video_queue, &visual, &video_convert, &video_sink]).unwrap(); gst::Element::link_many(&[&video_queue, &visual, &video_convert, &video_sink]).unwrap();
let tee_audio_pad = tee.get_request_pad("src_%u").unwrap(); let tee_audio_pad = tee.get_request_pad("src_%u").unwrap();
println!("Obtained request pad {} for audio branch", tee_audio_pad.get_name()); println!(
"Obtained request pad {} for audio branch",
tee_audio_pad.get_name()
);
let queue_audio_pad = audio_queue.get_static_pad("sink").unwrap(); let queue_audio_pad = audio_queue.get_static_pad("sink").unwrap();
tee_audio_pad.link(&queue_audio_pad); tee_audio_pad.link(&queue_audio_pad);
let tee_video_pad = tee.get_request_pad("src_%u").unwrap(); let tee_video_pad = tee.get_request_pad("src_%u").unwrap();
println!("Obtained request pad {} for video branch", tee_video_pad.get_name()); println!(
"Obtained request pad {} for video branch",
tee_video_pad.get_name()
);
let queue_video_pad = video_queue.get_static_pad("sink").unwrap(); let queue_video_pad = video_queue.get_static_pad("sink").unwrap();
tee_video_pad.link(&queue_video_pad); tee_video_pad.link(&queue_video_pad);