Run everything through rustfmt again

This commit is contained in:
Sebastian Dröge 2017-12-20 19:30:14 +02:00
parent f439f14ec3
commit e0dc84c10a
33 changed files with 291 additions and 303 deletions

View file

@ -173,16 +173,14 @@ fn example_main() -> Result<(), Error> {
}) })
.map(Result::Err) .map(Result::Err)
.expect("error-details message without actual error"), .expect("error-details message without actual error"),
_ => Err( _ => Err(ErrorMessage {
ErrorMessage {
src: msg.get_src() src: msg.get_src()
.map(|s| s.get_path_string()) .map(|s| s.get_path_string())
.unwrap_or_else(|| String::from("None")), .unwrap_or_else(|| String::from("None")),
error: err.get_error().description().into(), error: err.get_error().description().into(),
debug: err.get_debug(), debug: err.get_debug(),
cause: err.get_error(), cause: err.get_error(),
}.into(), }.into()),
),
}?; }?;
} }
#[cfg(not(feature = "v1_10"))] #[cfg(not(feature = "v1_10"))]

View file

@ -186,7 +186,6 @@ impl AppSrc {
} }
} }
pub fn get_latency(&self) -> (gst::ClockTime, gst::ClockTime) { pub fn get_latency(&self) -> (gst::ClockTime, gst::ClockTime) {
unsafe { unsafe {
let mut min = mem::uninitialized(); let mut min = mem::uninitialized();

View file

@ -101,13 +101,14 @@ impl AudioChannelPosition {
} }
let len = positions.len(); let len = positions.len();
let mut positions_raw: [ffi::GstAudioChannelPosition; 64] = array_init::array_init_copy( let mut positions_raw: [ffi::GstAudioChannelPosition; 64] =
|i| if i >= len as usize { array_init::array_init_copy(|i| {
if i >= len as usize {
ffi::GST_AUDIO_CHANNEL_POSITION_INVALID ffi::GST_AUDIO_CHANNEL_POSITION_INVALID
} else { } else {
positions[i].to_glib() positions[i].to_glib()
}, }
); });
let valid: bool = unsafe { let valid: bool = unsafe {
from_glib(ffi::gst_audio_channel_positions_to_valid_order( from_glib(ffi::gst_audio_channel_positions_to_valid_order(

View file

@ -194,7 +194,6 @@ impl AudioFormatInfo {
self.flags().contains(::AudioFormatFlags::SIGNED) self.flags().contains(::AudioFormatFlags::SIGNED)
} }
pub fn is_little_endian(&self) -> bool { pub fn is_little_endian(&self) -> bool {
self.endianness() == AudioEndianness::LittleEndian self.endianness() == AudioEndianness::LittleEndian
} }
@ -253,9 +252,9 @@ impl glib::types::StaticType for AudioFormatInfo {
#[doc(hidden)] #[doc(hidden)]
impl<'a> glib::value::FromValueOptional<'a> for AudioFormatInfo { impl<'a> glib::value::FromValueOptional<'a> for AudioFormatInfo {
unsafe fn from_value_optional(value: &glib::Value) -> Option<Self> { unsafe fn from_value_optional(value: &glib::Value) -> Option<Self> {
Option::<AudioFormatInfo>::from_glib_none( Option::<AudioFormatInfo>::from_glib_none(gobject_ffi::g_value_get_boxed(
gobject_ffi::g_value_get_boxed(value.to_glib_none().0) as *mut ffi::GstAudioFormatInfo, value.to_glib_none().0,
) ) as *mut ffi::GstAudioFormatInfo)
} }
} }

View file

@ -42,13 +42,14 @@ impl<'a> AudioInfoBuilder<'a> {
return None; return None;
} }
let positions: [ffi::GstAudioChannelPosition; 64] = array_init::array_init_copy( let positions: [ffi::GstAudioChannelPosition; 64] =
|i| if i >= self.channels as usize { array_init::array_init_copy(|i| {
if i >= self.channels as usize {
ffi::GST_AUDIO_CHANNEL_POSITION_INVALID ffi::GST_AUDIO_CHANNEL_POSITION_INVALID
} else { } else {
p[i].to_glib() p[i].to_glib()
}, }
); });
let valid: bool = from_glib(ffi::gst_audio_check_valid_channel_positions( let valid: bool = from_glib(ffi::gst_audio_check_valid_channel_positions(
positions.as_ptr() as *mut _, positions.as_ptr() as *mut _,

View file

@ -46,7 +46,9 @@ impl AsMut<gst::StructureRef> for PlayerConfig {
impl PlayerConfig { impl PlayerConfig {
pub fn get_position_update_interval(&self) -> u32 { pub fn get_position_update_interval(&self) -> u32 {
assert_initialized_main_thread!(); assert_initialized_main_thread!();
unsafe { ffi::gst_player_config_get_position_update_interval(self.0.to_glib_none().0) } unsafe {
ffi::gst_player_config_get_position_update_interval(self.0.to_glib_none().0)
}
} }
pub fn get_seek_accurate(&self) -> bool { pub fn get_seek_accurate(&self) -> bool {

View file

@ -83,7 +83,6 @@ impl Player {
} }
} }
pub fn connect_seek_done<F: Fn(&Player, gst::ClockTime) + Send + 'static>( pub fn connect_seek_done<F: Fn(&Player, gst::ClockTime) + Send + 'static>(
&self, &self,
f: F, f: F,

View file

@ -19,10 +19,10 @@ impl PlayerGMainContextSignalDispatcher {
let application_context = application_context.into(); let application_context = application_context.into();
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(
ffi::gst_player_g_main_context_signal_dispatcher_new(application_context.0) application_context.0,
as *mut ffi::GstPlayerGMainContextSignalDispatcher,
) )
as *mut ffi::GstPlayerGMainContextSignalDispatcher)
} }
} }
} }

View file

@ -237,13 +237,13 @@ impl<'a> UpstreamForceKeyUnitEventBuilder<'a> {
} }
} }
event_builder_generic_impl!(|s: &mut Self| { event_builder_generic_impl!(
ffi::gst_video_event_new_upstream_force_key_unit( |s: &mut Self| ffi::gst_video_event_new_upstream_force_key_unit(
s.running_time.to_glib(), s.running_time.to_glib(),
s.all_headers.to_glib(), s.all_headers.to_glib(),
s.count, s.count,
) )
}); );
} }
#[derive(Clone, PartialEq, Eq, Debug)] #[derive(Clone, PartialEq, Eq, Debug)]
@ -315,9 +315,9 @@ impl<'a> StillFrameEventBuilder<'a> {
} }
} }
event_builder_generic_impl!(|s: &mut Self| { event_builder_generic_impl!(|s: &mut Self| ffi::gst_video_event_new_still_frame(
ffi::gst_video_event_new_still_frame(s.in_still.to_glib()) s.in_still.to_glib()
}); ));
} }
#[derive(Clone, PartialEq, Eq, Debug)] #[derive(Clone, PartialEq, Eq, Debug)]

View file

@ -334,7 +334,6 @@ mod tests {
assert!(frame.info() == &info); assert!(frame.info() == &info);
} }
#[test] #[test]
fn test_map_write() { fn test_map_write() {
gst::init().unwrap(); gst::init().unwrap();

View file

@ -521,9 +521,9 @@ impl VideoInfo {
pub fn multiview_flags(&self) -> ::VideoMultiviewFlags { pub fn multiview_flags(&self) -> ::VideoMultiviewFlags {
unsafe { unsafe {
let ptr = &self.0._gst_reserved as *const _ as *const u32; let ptr = &self.0._gst_reserved as *const _ as *const u32;
from_glib(ffi::GstVideoMultiviewFlags::from_bits_truncate( from_glib(ffi::GstVideoMultiviewFlags::from_bits_truncate(ptr::read(
ptr::read(ptr.offset(1)), ptr.offset(1),
)) )))
} }
} }

View file

@ -157,7 +157,9 @@ impl GstRc<BufferRef> {
pub fn append(buffer: Self, other: Self) -> Self { pub fn append(buffer: Self, other: Self) -> Self {
skip_assert_initialized!(); skip_assert_initialized!();
unsafe { from_glib_full(ffi::gst_buffer_append(buffer.into_ptr(), other.into_ptr())) } unsafe {
from_glib_full(ffi::gst_buffer_append(buffer.into_ptr(), other.into_ptr()))
}
} }
} }
@ -170,8 +172,9 @@ impl Default for GstRc<BufferRef> {
impl BufferRef { impl BufferRef {
pub fn map_readable(&self) -> Option<BufferMap<Readable>> { pub fn map_readable(&self) -> Option<BufferMap<Readable>> {
let mut map_info: ffi::GstMapInfo = unsafe { mem::zeroed() }; let mut map_info: ffi::GstMapInfo = unsafe { mem::zeroed() };
let res = let res = unsafe {
unsafe { ffi::gst_buffer_map(self.as_mut_ptr(), &mut map_info, ffi::GST_MAP_READ) }; ffi::gst_buffer_map(self.as_mut_ptr(), &mut map_info, ffi::GST_MAP_READ)
};
if res == glib_ffi::GTRUE { if res == glib_ffi::GTRUE {
Some(BufferMap { Some(BufferMap {
buffer: self, buffer: self,
@ -437,7 +440,9 @@ impl<'a, T> BufferMap<'a, T> {
impl<'a> BufferMap<'a, Writable> { impl<'a> BufferMap<'a, Writable> {
pub fn as_mut_slice(&mut self) -> &mut [u8] { pub fn as_mut_slice(&mut self) -> &mut [u8] {
unsafe { slice::from_raw_parts_mut(self.map_info.data as *mut u8, self.map_info.size) } unsafe {
slice::from_raw_parts_mut(self.map_info.data as *mut u8, self.map_info.size)
}
} }
} }
@ -516,7 +521,9 @@ impl<T> MappedBuffer<T> {
impl MappedBuffer<Writable> { impl MappedBuffer<Writable> {
pub fn as_mut_slice(&mut self) -> &mut [u8] { pub fn as_mut_slice(&mut self) -> &mut [u8] {
unsafe { slice::from_raw_parts_mut(self.map_info.data as *mut u8, self.map_info.size) } unsafe {
slice::from_raw_parts_mut(self.map_info.data as *mut u8, self.map_info.size)
}
} }
} }

View file

@ -136,7 +136,9 @@ impl Bus {
} }
pub fn unset_sync_handler(&self) { pub fn unset_sync_handler(&self) {
unsafe { ffi::gst_bus_set_sync_handler(self.to_glib_none().0, None, ptr::null_mut(), None) } unsafe {
ffi::gst_bus_set_sync_handler(self.to_glib_none().0, None, ptr::null_mut(), None)
}
} }
} }

View file

@ -59,14 +59,16 @@ impl ContextRef {
} }
pub fn get_structure(&self) -> &StructureRef { pub fn get_structure(&self) -> &StructureRef {
unsafe { StructureRef::from_glib_borrow(ffi::gst_context_get_structure(self.as_mut_ptr())) } unsafe {
StructureRef::from_glib_borrow(ffi::gst_context_get_structure(self.as_mut_ptr()))
}
} }
pub fn get_mut_structure(&mut self) -> &mut StructureRef { pub fn get_mut_structure(&mut self) -> &mut StructureRef {
unsafe { unsafe {
StructureRef::from_glib_borrow_mut( StructureRef::from_glib_borrow_mut(ffi::gst_context_writable_structure(
ffi::gst_context_writable_structure(self.as_mut_ptr()), self.as_mut_ptr(),
) ))
} }
} }
} }

View file

@ -224,9 +224,9 @@ impl<O: IsA<Element>> ElementExtManual for O {
let klass = (*(self.to_glib_none().0 as *mut gobject_ffi::GTypeInstance)).g_class let klass = (*(self.to_glib_none().0 as *mut gobject_ffi::GTypeInstance)).g_class
as *mut ffi::GstElementClass; as *mut ffi::GstElementClass;
FromGlibPtrContainer::from_glib_none( FromGlibPtrContainer::from_glib_none(ffi::gst_element_class_get_pad_template_list(
ffi::gst_element_class_get_pad_template_list(klass), klass,
) ))
} }
} }

View file

@ -218,7 +218,6 @@ impl Error for PadLinkError {
} }
} }
impl ClockReturn { impl ClockReturn {
pub fn into_result(self) -> Result<ClockSuccess, ClockError> { pub fn into_result(self) -> Result<ClockSuccess, ClockError> {
match self { match self {
@ -299,7 +298,6 @@ impl Ord for ::TypeFindProbability {
fn cmp(&self, other: &Self) -> cmp::Ordering { fn cmp(&self, other: &Self) -> cmp::Ordering {
self.to_glib().cmp(&other.to_glib()) self.to_glib().cmp(&other.to_glib())
} }
} }
impl PartialOrd for ::Rank { impl PartialOrd for ::Rank {
@ -312,5 +310,4 @@ impl Ord for ::Rank {
fn cmp(&self, other: &Self) -> cmp::Ordering { fn cmp(&self, other: &Self) -> cmp::Ordering {
self.to_glib().cmp(&other.to_glib()) self.to_glib().cmp(&other.to_glib())
} }
} }

View file

@ -734,7 +734,6 @@ impl<'a> Qos<'a> {
} }
} }
pub struct Seek<'a>(&'a EventRef); pub struct Seek<'a>(&'a EventRef);
impl<'a> Seek<'a> { impl<'a> Seek<'a> {
pub fn get( pub fn get(
@ -947,9 +946,7 @@ impl<'a> FlushStopBuilder<'a> {
} }
} }
event_builder_generic_impl!(|s: &Self| { event_builder_generic_impl!(|s: &Self| ffi::gst_event_new_flush_stop(s.reset_time.to_glib()));
ffi::gst_event_new_flush_stop(s.reset_time.to_glib())
});
} }
pub struct StreamStartBuilder<'a> { pub struct StreamStartBuilder<'a> {
@ -1036,9 +1033,7 @@ impl<'a> SegmentBuilder<'a> {
} }
} }
event_builder_generic_impl!(|s: &Self| { event_builder_generic_impl!(|s: &Self| ffi::gst_event_new_segment(s.segment.to_glib_none().0));
ffi::gst_event_new_segment(s.segment.to_glib_none().0)
});
} }
#[cfg(any(feature = "v1_10", feature = "dox"))] #[cfg(any(feature = "v1_10", feature = "dox"))]
@ -1060,9 +1055,9 @@ impl<'a> StreamCollectionBuilder<'a> {
} }
} }
event_builder_generic_impl!(|s: &Self| { event_builder_generic_impl!(|s: &Self| ffi::gst_event_new_stream_collection(
ffi::gst_event_new_stream_collection(s.stream_collection.to_glib_none().0) s.stream_collection.to_glib_none().0
}); ));
} }
pub struct TagBuilder<'a> { pub struct TagBuilder<'a> {
@ -1109,14 +1104,12 @@ impl<'a> BufferSizeBuilder<'a> {
} }
} }
event_builder_generic_impl!(|s: &Self| { event_builder_generic_impl!(|s: &Self| ffi::gst_event_new_buffer_size(
ffi::gst_event_new_buffer_size(
s.minsize.get_format().to_glib(), s.minsize.get_format().to_glib(),
s.minsize.get_value(), s.minsize.get_value(),
s.maxsize.get_value(), s.maxsize.get_value(),
s.async.to_glib(), s.async.to_glib(),
) ));
});
} }
pub struct SinkMessageBuilder<'a> { pub struct SinkMessageBuilder<'a> {
@ -1138,9 +1131,10 @@ impl<'a> SinkMessageBuilder<'a> {
} }
} }
event_builder_generic_impl!(|s: &Self| { event_builder_generic_impl!(|s: &Self| ffi::gst_event_new_sink_message(
ffi::gst_event_new_sink_message(s.name.to_glib_none().0, s.msg.as_mut_ptr()) s.name.to_glib_none().0,
}); s.msg.as_mut_ptr()
));
} }
#[cfg(any(feature = "v1_10", feature = "dox"))] #[cfg(any(feature = "v1_10", feature = "dox"))]
@ -1162,9 +1156,9 @@ impl<'a> StreamGroupDoneBuilder<'a> {
} }
} }
event_builder_generic_impl!(|s: &Self| { event_builder_generic_impl!(|s: &Self| ffi::gst_event_new_stream_group_done(
ffi::gst_event_new_stream_group_done(s.group_id.to_glib()) s.group_id.to_glib()
}); ));
} }
pub struct EosBuilder<'a> { pub struct EosBuilder<'a> {
@ -1204,9 +1198,10 @@ impl<'a> TocBuilder<'a> {
} }
} }
event_builder_generic_impl!(|s: &Self| { event_builder_generic_impl!(|s: &Self| ffi::gst_event_new_toc(
ffi::gst_event_new_toc(s.toc.to_glib_none().0, s.updated.to_glib()) s.toc.to_glib_none().0,
}); s.updated.to_glib()
));
} }
pub struct ProtectionBuilder<'a> { pub struct ProtectionBuilder<'a> {
@ -1237,13 +1232,11 @@ impl<'a> ProtectionBuilder<'a> {
} }
} }
event_builder_generic_impl!(|s: &Self| { event_builder_generic_impl!(|s: &Self| ffi::gst_event_new_protection(
ffi::gst_event_new_protection(
s.system_id.to_glib_none().0, s.system_id.to_glib_none().0,
s.data.as_mut_ptr(), s.data.as_mut_ptr(),
s.origin.to_glib_none().0, s.origin.to_glib_none().0,
) ));
});
} }
pub struct SegmentDoneBuilder<'a> { pub struct SegmentDoneBuilder<'a> {
@ -1263,9 +1256,10 @@ impl<'a> SegmentDoneBuilder<'a> {
} }
} }
event_builder_generic_impl!(|s: &Self| { event_builder_generic_impl!(|s: &Self| ffi::gst_event_new_segment_done(
ffi::gst_event_new_segment_done(s.position.get_format().to_glib(), s.position.get_value()) s.position.get_format().to_glib(),
}); s.position.get_value()
));
} }
pub struct GapBuilder<'a> { pub struct GapBuilder<'a> {
@ -1287,9 +1281,10 @@ impl<'a> GapBuilder<'a> {
} }
} }
event_builder_generic_impl!(|s: &Self| { event_builder_generic_impl!(|s: &Self| ffi::gst_event_new_gap(
ffi::gst_event_new_gap(s.timestamp.to_glib(), s.duration.to_glib()) s.timestamp.to_glib(),
}); s.duration.to_glib()
));
} }
pub struct QosBuilder<'a> { pub struct QosBuilder<'a> {
@ -1315,14 +1310,12 @@ impl<'a> QosBuilder<'a> {
} }
} }
event_builder_generic_impl!(|s: &Self| { event_builder_generic_impl!(|s: &Self| ffi::gst_event_new_qos(
ffi::gst_event_new_qos(
s.type_.to_glib(), s.type_.to_glib(),
s.proportion, s.proportion,
s.diff, s.diff,
s.timestamp.to_glib(), s.timestamp.to_glib(),
) ));
});
} }
pub struct SeekBuilder<'a> { pub struct SeekBuilder<'a> {
@ -1359,8 +1352,7 @@ impl<'a> SeekBuilder<'a> {
} }
} }
event_builder_generic_impl!(|s: &Self| { event_builder_generic_impl!(|s: &Self| ffi::gst_event_new_seek(
ffi::gst_event_new_seek(
s.rate, s.rate,
s.start.get_format().to_glib(), s.start.get_format().to_glib(),
s.flags.to_glib(), s.flags.to_glib(),
@ -1368,8 +1360,7 @@ impl<'a> SeekBuilder<'a> {
s.start.get_value(), s.start.get_value(),
s.stop_type.to_glib(), s.stop_type.to_glib(),
s.stop.get_value(), s.stop.get_value(),
) ));
});
} }
pub struct NavigationBuilder<'a> { pub struct NavigationBuilder<'a> {
@ -1441,15 +1432,13 @@ impl<'a> StepBuilder<'a> {
} }
} }
event_builder_generic_impl!(|s: &Self| { event_builder_generic_impl!(|s: &Self| ffi::gst_event_new_step(
ffi::gst_event_new_step(
s.amount.get_format().to_glib(), s.amount.get_format().to_glib(),
s.amount.get_value() as u64, s.amount.get_value() as u64,
s.rate, s.rate,
s.flush.to_glib(), s.flush.to_glib(),
s.intermediate.to_glib(), s.intermediate.to_glib(),
) ));
});
} }
pub struct ReconfigureBuilder<'a> { pub struct ReconfigureBuilder<'a> {
@ -1487,9 +1476,7 @@ impl<'a> TocSelectBuilder<'a> {
} }
} }
event_builder_generic_impl!(|s: &Self| { event_builder_generic_impl!(|s: &Self| ffi::gst_event_new_toc_select(s.uid.to_glib_none().0));
ffi::gst_event_new_toc_select(s.uid.to_glib_none().0)
});
} }
#[cfg(any(feature = "v1_10", feature = "dox"))] #[cfg(any(feature = "v1_10", feature = "dox"))]
@ -1511,9 +1498,9 @@ impl<'a> SelectStreamsBuilder<'a> {
} }
} }
event_builder_generic_impl!(|s: &Self| { event_builder_generic_impl!(|s: &Self| ffi::gst_event_new_select_streams(
ffi::gst_event_new_select_streams(s.streams.to_glib_full()) s.streams.to_glib_full()
}); ));
} }
pub struct CustomUpstreamBuilder<'a> { pub struct CustomUpstreamBuilder<'a> {

View file

@ -153,9 +153,7 @@ impl GenericFormattedValue {
if F::get_default_format() == self.get_format() if F::get_default_format() == self.get_format()
|| F::get_default_format() == Format::Undefined || F::get_default_format() == Format::Undefined
{ {
Ok(unsafe { Ok(unsafe { F::from_raw(self.get_format(), self.to_raw_value()) })
F::from_raw(self.get_format(), self.to_raw_value())
})
} else { } else {
Err(self) Err(self)
} }

View file

@ -74,7 +74,7 @@ pub use caps::{Caps, CapsRef};
pub mod tags; pub mod tags;
pub use tags::{Tag, TagList, TagListRef}; pub use tags::{Tag, TagList, TagListRef};
pub mod buffer; pub mod buffer;
pub use buffer::{Buffer, BufferMap, BufferRef, MappedBuffer, BUFFER_COPY_METADATA, BUFFER_COPY_ALL}; pub use buffer::{Buffer, BufferMap, BufferRef, MappedBuffer, BUFFER_COPY_ALL, BUFFER_COPY_METADATA};
pub mod sample; pub mod sample;
pub use sample::{Sample, SampleRef}; pub use sample::{Sample, SampleRef};
pub mod bufferlist; pub mod bufferlist;

View file

@ -671,7 +671,6 @@ impl<'a> StepDone<'a> {
} }
} }
pub struct ClockProvide<'a>(&'a MessageRef); pub struct ClockProvide<'a>(&'a MessageRef);
impl<'a> ClockProvide<'a> { impl<'a> ClockProvide<'a> {
pub fn get_clock(&self) -> Option<::Clock> { pub fn get_clock(&self) -> Option<::Clock> {
@ -1446,9 +1445,10 @@ impl<'a> TagBuilder<'a> {
} }
} }
message_builder_generic_impl!(|s: &Self, src| { message_builder_generic_impl!(|s: &Self, src| ffi::gst_message_new_tag(
ffi::gst_message_new_tag(src, s.tags.to_glib_full()) src,
}); s.tags.to_glib_full()
));
} }
pub struct BufferingBuilder<'a> { pub struct BufferingBuilder<'a> {
@ -1522,14 +1522,12 @@ impl<'a> StateChangedBuilder<'a> {
} }
} }
message_builder_generic_impl!(|s: &mut Self, src| { message_builder_generic_impl!(|s: &mut Self, src| ffi::gst_message_new_state_changed(
ffi::gst_message_new_state_changed(
src, src,
s.old.to_glib(), s.old.to_glib(),
s.new.to_glib(), s.new.to_glib(),
s.pending.to_glib(), s.pending.to_glib(),
) ));
});
} }
pub struct StateDirtyBuilder<'a> { pub struct StateDirtyBuilder<'a> {
@ -1585,8 +1583,7 @@ impl<'a> StepDoneBuilder<'a> {
} }
} }
message_builder_generic_impl!(|s: &mut Self, src| { message_builder_generic_impl!(|s: &mut Self, src| ffi::gst_message_new_step_done(
ffi::gst_message_new_step_done(
src, src,
s.amount.get_format().to_glib(), s.amount.get_format().to_glib(),
s.amount.get_value() as u64, s.amount.get_value() as u64,
@ -1595,8 +1592,7 @@ impl<'a> StepDoneBuilder<'a> {
s.intermediate.to_glib(), s.intermediate.to_glib(),
s.duration.get_value() as u64, s.duration.get_value() as u64,
s.eos.to_glib(), s.eos.to_glib(),
) ));
});
} }
pub struct ClockProvideBuilder<'a> { pub struct ClockProvideBuilder<'a> {
@ -1618,9 +1614,11 @@ impl<'a> ClockProvideBuilder<'a> {
} }
} }
message_builder_generic_impl!(|s: &mut Self, src| { message_builder_generic_impl!(|s: &mut Self, src| ffi::gst_message_new_clock_provide(
ffi::gst_message_new_clock_provide(src, s.clock.to_glib_none().0, s.ready.to_glib()) src,
}); s.clock.to_glib_none().0,
s.ready.to_glib()
));
} }
pub struct ClockLostBuilder<'a> { pub struct ClockLostBuilder<'a> {
@ -1640,9 +1638,10 @@ impl<'a> ClockLostBuilder<'a> {
} }
} }
message_builder_generic_impl!(|s: &mut Self, src| { message_builder_generic_impl!(|s: &mut Self, src| ffi::gst_message_new_clock_lost(
ffi::gst_message_new_clock_lost(src, s.clock.to_glib_none().0) src,
}); s.clock.to_glib_none().0
));
} }
pub struct NewClockBuilder<'a> { pub struct NewClockBuilder<'a> {
@ -1662,9 +1661,10 @@ impl<'a> NewClockBuilder<'a> {
} }
} }
message_builder_generic_impl!(|s: &mut Self, src| { message_builder_generic_impl!(|s: &mut Self, src| ffi::gst_message_new_new_clock(
ffi::gst_message_new_new_clock(src, s.clock.to_glib_none().0) src,
}); s.clock.to_glib_none().0
));
} }
pub struct StructureChangeBuilder<'a> { pub struct StructureChangeBuilder<'a> {
@ -1688,14 +1688,12 @@ impl<'a> StructureChangeBuilder<'a> {
} }
} }
message_builder_generic_impl!(|s: &mut Self, src| { message_builder_generic_impl!(|s: &mut Self, src| ffi::gst_message_new_structure_change(
ffi::gst_message_new_structure_change(
src, src,
s.type_.to_glib(), s.type_.to_glib(),
s.owner.to_glib_none().0, s.owner.to_glib_none().0,
s.busy.to_glib(), s.busy.to_glib(),
) ));
});
} }
pub struct StreamStatusBuilder<'a> { pub struct StreamStatusBuilder<'a> {
@ -1756,9 +1754,10 @@ impl<'a> ApplicationBuilder<'a> {
} }
} }
message_builder_generic_impl!(|s: &mut Self, src| { message_builder_generic_impl!(|s: &mut Self, src| ffi::gst_message_new_application(
ffi::gst_message_new_application(src, s.structure.take().unwrap().into_ptr()) src,
}); s.structure.take().unwrap().into_ptr()
));
} }
pub struct ElementBuilder<'a> { pub struct ElementBuilder<'a> {
@ -1778,9 +1777,10 @@ impl<'a> ElementBuilder<'a> {
} }
} }
message_builder_generic_impl!(|s: &mut Self, src| { message_builder_generic_impl!(|s: &mut Self, src| ffi::gst_message_new_element(
ffi::gst_message_new_element(src, s.structure.take().unwrap().into_ptr()) src,
}); s.structure.take().unwrap().into_ptr()
));
} }
pub struct SegmentStartBuilder<'a> { pub struct SegmentStartBuilder<'a> {
@ -1800,13 +1800,11 @@ impl<'a> SegmentStartBuilder<'a> {
} }
} }
message_builder_generic_impl!(|s: &mut Self, src| { message_builder_generic_impl!(|s: &mut Self, src| ffi::gst_message_new_segment_start(
ffi::gst_message_new_segment_start(
src, src,
s.position.get_format().to_glib(), s.position.get_format().to_glib(),
s.position.get_value(), s.position.get_value(),
) ));
});
} }
pub struct SegmentDoneBuilder<'a> { pub struct SegmentDoneBuilder<'a> {
@ -1826,13 +1824,11 @@ impl<'a> SegmentDoneBuilder<'a> {
} }
} }
message_builder_generic_impl!(|s: &mut Self, src| { message_builder_generic_impl!(|s: &mut Self, src| ffi::gst_message_new_segment_done(
ffi::gst_message_new_segment_done(
src, src,
s.position.get_format().to_glib(), s.position.get_format().to_glib(),
s.position.get_value(), s.position.get_value(),
) ));
});
} }
pub struct DurationChangedBuilder<'a> { pub struct DurationChangedBuilder<'a> {
@ -1906,9 +1902,10 @@ impl<'a> AsyncDoneBuilder<'a> {
} }
} }
message_builder_generic_impl!(|s: &mut Self, src| { message_builder_generic_impl!(|s: &mut Self, src| ffi::gst_message_new_async_done(
ffi::gst_message_new_async_done(src, s.running_time.to_glib()) src,
}); s.running_time.to_glib()
));
} }
pub struct RequestStateBuilder<'a> { pub struct RequestStateBuilder<'a> {
@ -1928,9 +1925,10 @@ impl<'a> RequestStateBuilder<'a> {
} }
} }
message_builder_generic_impl!(|s: &mut Self, src| { message_builder_generic_impl!(|s: &mut Self, src| ffi::gst_message_new_request_state(
ffi::gst_message_new_request_state(src, s.state.to_glib()) src,
}); s.state.to_glib()
));
} }
pub struct StepStartBuilder<'a> { pub struct StepStartBuilder<'a> {
@ -1964,8 +1962,7 @@ impl<'a> StepStartBuilder<'a> {
} }
} }
message_builder_generic_impl!(|s: &mut Self, src| { message_builder_generic_impl!(|s: &mut Self, src| ffi::gst_message_new_step_start(
ffi::gst_message_new_step_start(
src, src,
s.active.to_glib(), s.active.to_glib(),
s.amount.get_format().to_glib(), s.amount.get_format().to_glib(),
@ -1973,8 +1970,7 @@ impl<'a> StepStartBuilder<'a> {
s.rate, s.rate,
s.flush.to_glib(), s.flush.to_glib(),
s.intermediate.to_glib(), s.intermediate.to_glib(),
) ));
});
} }
pub struct QosBuilder<'a> { pub struct QosBuilder<'a> {
@ -2074,14 +2070,12 @@ impl<'a> ProgressBuilder<'a> {
} }
} }
message_builder_generic_impl!(|s: &mut Self, src| { message_builder_generic_impl!(|s: &mut Self, src| ffi::gst_message_new_progress(
ffi::gst_message_new_progress(
src, src,
s.type_.to_glib(), s.type_.to_glib(),
s.code.to_glib_none().0, s.code.to_glib_none().0,
s.text.to_glib_none().0, s.text.to_glib_none().0,
) ));
});
} }
pub struct TocBuilder<'a> { pub struct TocBuilder<'a> {
@ -2103,9 +2097,11 @@ impl<'a> TocBuilder<'a> {
} }
} }
message_builder_generic_impl!(|s: &Self, src| { message_builder_generic_impl!(|s: &Self, src| ffi::gst_message_new_toc(
ffi::gst_message_new_toc(src, s.toc.to_glib_none().0, s.updated.to_glib()) src,
}); s.toc.to_glib_none().0,
s.updated.to_glib()
));
} }
pub struct ResetTimeBuilder<'a> { pub struct ResetTimeBuilder<'a> {
@ -2125,9 +2121,10 @@ impl<'a> ResetTimeBuilder<'a> {
} }
} }
message_builder_generic_impl!(|s: &mut Self, src| { message_builder_generic_impl!(|s: &mut Self, src| ffi::gst_message_new_reset_time(
ffi::gst_message_new_reset_time(src, s.running_time.to_glib()) src,
}); s.running_time.to_glib()
));
} }
pub struct StreamStartBuilder<'a> { pub struct StreamStartBuilder<'a> {
@ -2180,9 +2177,10 @@ impl<'a> NeedContextBuilder<'a> {
} }
} }
message_builder_generic_impl!(|s: &mut Self, src| { message_builder_generic_impl!(|s: &mut Self, src| ffi::gst_message_new_need_context(
ffi::gst_message_new_need_context(src, s.context_type.to_glib_none().0) src,
}); s.context_type.to_glib_none().0
));
} }
pub struct HaveContextBuilder<'a> { pub struct HaveContextBuilder<'a> {
@ -2225,9 +2223,10 @@ impl<'a> DeviceAddedBuilder<'a> {
} }
} }
message_builder_generic_impl!(|s: &mut Self, src| { message_builder_generic_impl!(|s: &mut Self, src| ffi::gst_message_new_device_added(
ffi::gst_message_new_device_added(src, s.device.to_glib_none().0) src,
}); s.device.to_glib_none().0
));
} }
pub struct DeviceRemovedBuilder<'a> { pub struct DeviceRemovedBuilder<'a> {
@ -2247,9 +2246,10 @@ impl<'a> DeviceRemovedBuilder<'a> {
} }
} }
message_builder_generic_impl!(|s: &mut Self, src| { message_builder_generic_impl!(|s: &mut Self, src| ffi::gst_message_new_device_removed(
ffi::gst_message_new_device_removed(src, s.device.to_glib_none().0) src,
}); s.device.to_glib_none().0
));
} }
#[cfg(any(feature = "v1_10", feature = "dox"))] #[cfg(any(feature = "v1_10", feature = "dox"))]
@ -2313,9 +2313,10 @@ impl<'a> StreamCollectionBuilder<'a> {
} }
} }
message_builder_generic_impl!(|s: &mut Self, src| { message_builder_generic_impl!(|s: &mut Self, src| ffi::gst_message_new_stream_collection(
ffi::gst_message_new_stream_collection(src, s.collection.to_glib_none().0) src,
}); s.collection.to_glib_none().0
));
} }
#[cfg(any(feature = "v1_10", feature = "dox"))] #[cfg(any(feature = "v1_10", feature = "dox"))]

View file

@ -66,10 +66,9 @@ impl<T: MiniObject> GstRc<T> {
return &mut *self.obj; return &mut *self.obj;
} }
self.obj = T::from_mut_ptr( self.obj = T::from_mut_ptr(ffi::gst_mini_object_make_writable(self.as_mut_ptr()
ffi::gst_mini_object_make_writable(self.as_mut_ptr() as *mut ffi::GstMiniObject) as *mut ffi::GstMiniObject)
as *mut T::GstType, as *mut T::GstType);
);
assert!(self.is_writable()); assert!(self.is_writable());
&mut *self.obj &mut *self.obj
@ -86,9 +85,8 @@ impl<T: MiniObject> GstRc<T> {
pub fn is_writable(&self) -> bool { pub fn is_writable(&self) -> bool {
unsafe { unsafe {
from_glib(ffi::gst_mini_object_is_writable( from_glib(ffi::gst_mini_object_is_writable(self.as_ptr()
self.as_ptr() as *const ffi::GstMiniObject, as *const ffi::GstMiniObject))
))
} }
} }
@ -193,10 +191,9 @@ 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()
ffi::gst_mini_object_copy(self.as_ptr() as *const ffi::GstMiniObject) as *const ffi::GstMiniObject)
as *const Self::GstType, as *const Self::GstType)
)
} }
} }
} }

View file

@ -874,24 +874,24 @@ unsafe extern "C" fn trampoline_pad_probe(
let data = (*info).data as *const ffi::GstMiniObject; let data = (*info).data as *const ffi::GstMiniObject;
if (*data).type_ == Buffer::static_type().to_glib() { if (*data).type_ == Buffer::static_type().to_glib() {
data_type = Some(Buffer::static_type()); data_type = Some(Buffer::static_type());
Some(PadProbeData::Buffer( Some(PadProbeData::Buffer(from_glib_none(
from_glib_none(data as *const ffi::GstBuffer), data as *const ffi::GstBuffer,
)) )))
} else if (*data).type_ == BufferList::static_type().to_glib() { } else if (*data).type_ == BufferList::static_type().to_glib() {
data_type = Some(BufferList::static_type()); data_type = Some(BufferList::static_type());
Some(PadProbeData::BufferList( Some(PadProbeData::BufferList(from_glib_none(
from_glib_none(data as *const ffi::GstBufferList), data as *const ffi::GstBufferList,
)) )))
} else if (*data).type_ == Query::static_type().to_glib() { } else if (*data).type_ == Query::static_type().to_glib() {
data_type = Some(Query::static_type()); data_type = Some(Query::static_type());
Some(PadProbeData::Query( Some(PadProbeData::Query(QueryRef::from_mut_ptr(
QueryRef::from_mut_ptr(data as *mut ffi::GstQuery), data as *mut ffi::GstQuery,
)) )))
} else if (*data).type_ == Event::static_type().to_glib() { } else if (*data).type_ == Event::static_type().to_glib() {
data_type = Some(Event::static_type()); data_type = Some(Event::static_type());
Some(PadProbeData::Event( Some(PadProbeData::Event(from_glib_none(
from_glib_none(data as *const ffi::GstEvent), data as *const ffi::GstEvent,
)) )))
} else { } else {
Some(PadProbeData::Unknown) Some(PadProbeData::Unknown)
} }
@ -1195,9 +1195,7 @@ mod tests {
assert!(pad.send_event(::Event::new_stream_start("test").build())); assert!(pad.send_event(::Event::new_stream_start("test").build()));
let segment = ::FormattedSegment::<::ClockTime>::new(); let segment = ::FormattedSegment::<::ClockTime>::new();
assert!(pad.send_event( assert!(pad.send_event(::Event::new_segment(segment.as_ref()).build()));
::Event::new_segment(segment.as_ref()).build()
));
assert_eq!(pad.chain(::Buffer::new()), ::FlowReturn::Ok); assert_eq!(pad.chain(::Buffer::new()), ::FlowReturn::Ok);

View file

@ -142,15 +142,21 @@ impl QueryRef {
} }
pub fn is_downstream(&self) -> bool { pub fn is_downstream(&self) -> bool {
unsafe { ((*self.as_ptr()).type_ as u32) & (ffi::GST_QUERY_TYPE_DOWNSTREAM.bits()) != 0 } unsafe {
((*self.as_ptr()).type_ as u32) & (ffi::GST_QUERY_TYPE_DOWNSTREAM.bits()) != 0
}
} }
pub fn is_upstream(&self) -> bool { pub fn is_upstream(&self) -> bool {
unsafe { ((*self.as_ptr()).type_ as u32) & (ffi::GST_QUERY_TYPE_UPSTREAM.bits()) != 0 } unsafe {
((*self.as_ptr()).type_ as u32) & (ffi::GST_QUERY_TYPE_UPSTREAM.bits()) != 0
}
} }
pub fn is_serialized(&self) -> bool { pub fn is_serialized(&self) -> bool {
unsafe { ((*self.as_ptr()).type_ as u32) & (ffi::GST_QUERY_TYPE_SERIALIZED.bits()) != 0 } unsafe {
((*self.as_ptr()).type_ as u32) & (ffi::GST_QUERY_TYPE_SERIALIZED.bits()) != 0
}
} }
pub fn view(&self) -> QueryView<&Self> { pub fn view(&self) -> QueryView<&Self> {

View file

@ -54,10 +54,9 @@ impl glib::types::StaticType for StaticPadTemplate {
#[doc(hidden)] #[doc(hidden)]
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(
gobject_ffi::g_value_get_boxed(value.to_glib_none().0) value.to_glib_none().0,
as *mut ffi::GstStaticPadTemplate, ) as *mut ffi::GstStaticPadTemplate)
)
} }
} }

View file

@ -37,7 +37,9 @@ impl Structure {
pub fn new_empty(name: &str) -> Structure { pub fn new_empty(name: &str) -> Structure {
assert_initialized_main_thread!(); assert_initialized_main_thread!();
Structure( Structure(
unsafe { ffi::gst_structure_new_empty(name.to_glib_none().0) as *mut StructureRef }, unsafe {
ffi::gst_structure_new_empty(name.to_glib_none().0) as *mut StructureRef
},
PhantomData, PhantomData,
) )
} }

View file

@ -306,7 +306,9 @@ impl TagListRef {
} }
pub fn get_size<'a, T: Tag<'a>>(&'a self) -> u32 { pub fn get_size<'a, T: Tag<'a>>(&'a self) -> u32 {
unsafe { ffi::gst_tag_list_get_tag_size(self.as_ptr(), T::tag_name().to_glib_none().0) } unsafe {
ffi::gst_tag_list_get_tag_size(self.as_ptr(), T::tag_name().to_glib_none().0)
}
} }
pub fn iter_tag<'a, T: Tag<'a>>(&'a self) -> TagIterator<'a, T> { pub fn iter_tag<'a, T: Tag<'a>>(&'a self) -> TagIterator<'a, T> {
@ -318,7 +320,9 @@ impl TagListRef {
} }
pub fn insert(&mut self, other: &TagListRef, mode: TagMergeMode) { pub fn insert(&mut self, other: &TagListRef, mode: TagMergeMode) {
unsafe { ffi::gst_tag_list_insert(self.as_mut_ptr(), other.as_ptr(), mode.to_glib()) } unsafe {
ffi::gst_tag_list_insert(self.as_mut_ptr(), other.as_ptr(), mode.to_glib())
}
} }
pub fn merge(&self, other: &TagListRef, mode: TagMergeMode) -> TagList { pub fn merge(&self, other: &TagListRef, mode: TagMergeMode) -> TagList {

View file

@ -42,11 +42,15 @@ impl TocRef {
} }
pub fn find_entry(&self, uid: &str) -> Option<TocEntry> { pub fn find_entry(&self, uid: &str) -> Option<TocEntry> {
unsafe { from_glib_none(ffi::gst_toc_find_entry(self.as_ptr(), uid.to_glib_none().0)) } unsafe {
from_glib_none(ffi::gst_toc_find_entry(self.as_ptr(), uid.to_glib_none().0))
}
} }
pub fn get_entries(&self) -> Vec<TocEntry> { pub fn get_entries(&self) -> Vec<TocEntry> {
unsafe { FromGlibPtrContainer::from_glib_none(ffi::gst_toc_get_entries(self.as_ptr())) } unsafe {
FromGlibPtrContainer::from_glib_none(ffi::gst_toc_get_entries(self.as_ptr()))
}
} }
pub fn append_entry(&mut self, entry: TocEntry) { pub fn append_entry(&mut self, entry: TocEntry) {

View file

@ -248,9 +248,7 @@ mod tests {
.cloned() .cloned()
.find(|f| { .find(|f| {
f.get_caps() f.get_caps()
.map(|c| { .map(|c| c.get_structure(0).unwrap().get_name() == "application/xml")
c.get_structure(0).unwrap().get_name() == "application/xml"
})
.unwrap_or(false) .unwrap_or(false)
}) })
.unwrap(); .unwrap();

View file

@ -59,7 +59,6 @@ fn tutorial_main() {
); );
} }
fn main() { fn main() {
// tutorials_common::run is only required to set up the application environment on macOS // tutorials_common::run is only required to set up the application environment on macOS
// (but not necessary in normal Cocoa applications where this is set up automatically) // (but not necessary in normal Cocoa applications where this is set up automatically)

View file

@ -123,8 +123,7 @@ fn handle_message(custom_data: &mut CustomData, msg: &gst::GstRc<gst::MessageRef
println!( println!(
"Pipeline state changed from {:?} to {:?}", "Pipeline state changed from {:?} to {:?}",
old_state, old_state, new_state
new_state
); );
custom_data.playing = new_state == gst::State::Playing; custom_data.playing = new_state == gst::State::Playing;

View file

@ -53,9 +53,10 @@ mod tutorial5 {
} }
if let Some(bitrate) = tags.get::<gst::tags::Bitrate>() { if let Some(bitrate) = tags.get::<gst::tags::Bitrate>() {
textbuf.insert_at_cursor( textbuf.insert_at_cursor(&format!(
&format!(" bitrate: {} \n", bitrate.get().unwrap()), " bitrate: {} \n",
); bitrate.get().unwrap()
));
} }
} }
}, },

View file

@ -44,12 +44,7 @@ fn tutorial_main() {
.unwrap(); .unwrap();
gst::Element::link_many(&[&audio_source, &tee]).unwrap(); gst::Element::link_many(&[&audio_source, &tee]).unwrap();
gst::Element::link_many(&[ gst::Element::link_many(&[&audio_queue, &audio_convert, &audio_resample, &audio_sink]).unwrap();
&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();

View file

@ -90,12 +90,8 @@ fn main() {
.unwrap(); .unwrap();
gst::Element::link_many(&[&appsrc, &tee]).unwrap(); gst::Element::link_many(&[&appsrc, &tee]).unwrap();
gst::Element::link_many(&[ gst::Element::link_many(&[&audio_queue, &audio_convert1, &audio_resample, &audio_sink])
&audio_queue, .unwrap();
&audio_convert1,
&audio_resample,
&audio_sink,
]).unwrap();
gst::Element::link_many(&[ gst::Element::link_many(&[
&video_queue, &video_queue,
&audio_convert2, &audio_convert2,
@ -234,8 +230,6 @@ fn main() {
gst::FlowReturn::Ok gst::FlowReturn::Ok
}); });
pipeline pipeline
.set_state(gst::State::Playing) .set_state(gst::State::Playing)
.into_result() .into_result()