Run everything through latest rustfmt-nightly

This commit is contained in:
Sebastian Dröge 2017-07-31 12:16:42 +01:00
parent d0ac8b7fd3
commit 03285a6311
25 changed files with 708 additions and 299 deletions

View file

@ -17,7 +17,9 @@ fn main() {
let src = ElementFactory::make("videotestsrc", None).unwrap();
let (sink, widget) = if let Some(gtkglsink) = ElementFactory::make("gtkglsink", None) {
let glsinkbin = ElementFactory::make("glsinkbin", None).unwrap();
glsinkbin.set_property("sink", &gtkglsink.to_value()).unwrap();
glsinkbin
.set_property("sink", &gtkglsink.to_value())
.unwrap();
let widget = gtkglsink.get_property("widget").unwrap();
(glsinkbin, widget.get::<gtk::Widget>().unwrap())
@ -52,7 +54,12 @@ fn main() {
seconds -= hours * 60 * 60 + minutes * 60;
minutes -= hours * 60;
label.set_text(&format!("Position: {:02}:{:02}:{:02}", hours, minutes, seconds));
label.set_text(&format!(
"Position: {:02}:{:02}:{:02}",
hours,
minutes,
seconds
));
} else {
label.set_text("Position: 00:00:00");
}

View file

@ -7,24 +7,33 @@ use std::i16;
fn main() {
gst::init().unwrap();
let pipeline = gst::parse_launch("audiotestsrc name=src ! audio/x-raw,format=S16BE,channels=1 ! fakesink").unwrap();
let pipeline = gst::parse_launch(
"audiotestsrc name=src ! audio/x-raw,format=S16BE,channels=1 ! fakesink",
).unwrap();
let bus = pipeline.get_bus().unwrap();
let src = pipeline.clone().dynamic_cast::<Bin>().unwrap().get_by_name("src").unwrap();
let src = pipeline
.clone()
.dynamic_cast::<Bin>()
.unwrap()
.get_by_name("src")
.unwrap();
let src_pad = src.get_static_pad("src").unwrap();
src_pad.add_probe(PAD_PROBE_TYPE_BUFFER, |_, probe_info| {
match probe_info.data {
Some(PadProbeData::Buffer(ref buffer)) => {
let map = buffer.map_read().unwrap();
let data = map.as_slice();
let sum: f64 = data.chunks(2).map(|sample| {
let u: u16 = ((sample[0] as u16) << 8) | (sample[1] as u16);
let f = (u as i16 as f64) / (i16::MAX as f64);
f * f
}).sum();
let sum: f64 = data.chunks(2)
.map(|sample| {
let u: u16 = ((sample[0] as u16) << 8) | (sample[1] as u16);
let f = (u as i16 as f64) / (i16::MAX as f64);
f * f
})
.sum();
let rms = (sum / ((data.len() / 2) as f64)).sqrt();
println!("rms: {}", rms);
},
}
_ => (),
}

View file

@ -31,9 +31,7 @@ fn main() {
let mut q = Query::new_position(Format::Time);
pipeline.query(q.get_mut().unwrap());
match q.view() {
QueryView::Position(ref p) => {
p.get().1
},
QueryView::Position(ref p) => p.get().1,
_ => unreachable!(),
}
};
@ -42,9 +40,7 @@ fn main() {
let mut q = Query::new_duration(Format::Time);
pipeline.query(q.get_mut().unwrap());
match q.view() {
QueryView::Duration(ref p) => {
p.get().1
},
QueryView::Duration(ref p) => p.get().1,
_ => unreachable!(),
}
};

View file

@ -11,7 +11,7 @@ use Element;
use glib;
use glib::IsA;
use glib::translate::{ToGlibPtr, from_glib};
use glib::translate::{from_glib, ToGlibPtr};
use ffi;

View file

@ -241,9 +241,7 @@ impl BufferRef {
}
pub fn copy_deep(&self) -> Buffer {
unsafe {
from_glib_full(ffi::gst_buffer_copy_deep(self.as_ptr()))
}
unsafe { from_glib_full(ffi::gst_buffer_copy_deep(self.as_ptr())) }
}
pub fn get_size(&self) -> usize {

View file

@ -9,7 +9,7 @@
use ffi;
use glib;
use glib::StaticType;
use glib::translate::{from_glib, from_glib_none, from_glib_full};
use glib::translate::{from_glib, from_glib_full, from_glib_none};
use miniobject::*;
use Buffer;
@ -46,15 +46,11 @@ impl BufferListRef {
}
pub fn copy_deep(&self) -> BufferList {
unsafe {
from_glib_full(ffi::gst_buffer_list_copy_deep(self.as_ptr()))
}
unsafe { from_glib_full(ffi::gst_buffer_list_copy_deep(self.as_ptr())) }
}
pub fn remove(&mut self, idx: u32, len: u32) {
unsafe {
ffi::gst_buffer_list_remove(self.as_mut_ptr(), idx, len)
}
unsafe { ffi::gst_buffer_list_remove(self.as_mut_ptr(), idx, len) }
}
pub fn get(&self, idx: u32) -> Option<&BufferRef> {
@ -69,9 +65,7 @@ impl BufferListRef {
}
pub fn len(&self) -> usize {
unsafe {
ffi::gst_buffer_list_length(self.as_mut_ptr()) as usize
}
unsafe { ffi::gst_buffer_list_length(self.as_mut_ptr()) as usize }
}
pub fn iter<'a>(&'a self) -> Iter<'a> {
@ -89,9 +83,7 @@ impl ToOwned for BufferListRef {
impl StaticType for BufferListRef {
fn static_type() -> glib::Type {
unsafe {
from_glib(ffi::gst_buffer_list_get_type())
}
unsafe { from_glib(ffi::gst_buffer_list_get_type()) }
}
}
@ -114,8 +106,7 @@ impl<'a> Iter<'a> {
}
}
impl<'a> Iterator for Iter<'a>
{
impl<'a> Iterator for Iter<'a> {
type Item = &'a BufferRef;
fn next(&mut self) -> Option<Self::Item> {
@ -140,8 +131,7 @@ impl<'a> Iterator for Iter<'a>
}
}
impl<'a> DoubleEndedIterator for Iter<'a>
{
impl<'a> DoubleEndedIterator for Iter<'a> {
fn next_back(&mut self) -> Option<Self::Item> {
if self.idx == self.size {
return None;
@ -152,6 +142,4 @@ impl<'a> DoubleEndedIterator for Iter<'a>
}
}
impl<'a> ExactSizeIterator for Iter<'a>
{
}
impl<'a> ExactSizeIterator for Iter<'a> {}

View file

@ -11,7 +11,7 @@ use std::mem::transmute;
use ffi;
use glib;
use glib::translate::*;
use glib::source::{Continue, CallbackGuard, SourceId, Priority};
use glib::source::{CallbackGuard, Continue, Priority, SourceId};
use glib_ffi;
use glib_ffi::{gboolean, gpointer};

View file

@ -15,7 +15,7 @@ use CapsIntersectMode;
use glib;
use ffi;
use glib::translate::{from_glib, from_glib_none, from_glib_full, ToGlibPtr, ToGlib};
use glib::translate::{from_glib, from_glib_full, from_glib_none, ToGlib, ToGlibPtr};
use glib::value::ToValue;
#[repr(C)]
@ -390,7 +390,7 @@ mod tests {
("bool", &true),
("string", &"bla"),
("fraction", &Fraction::new(1, 2)),
("array", &Array::new(&[&1, &2])),
("array", &Array::new(&[&1, &2]))
],
).as_ref()
);

View file

@ -21,25 +21,43 @@ pub trait ChildProxyExtManual {
impl<O: IsA<ChildProxy>> ChildProxyExtManual for O {
fn get_property(&self, name: &str) -> Option<glib::Value> {
unsafe {
let found: bool = from_glib(ffi::gst_child_proxy_lookup(self.to_glib_none().0, name.to_glib_none().0, ptr::null_mut(), ptr::null_mut()));
let found: bool = from_glib(ffi::gst_child_proxy_lookup(
self.to_glib_none().0,
name.to_glib_none().0,
ptr::null_mut(),
ptr::null_mut(),
));
if !found {
return None;
}
let mut value = glib::Value::uninitialized();
ffi::gst_child_proxy_get_property(self.to_glib_none().0, name.to_glib_none().0, value.to_glib_none_mut().0);
ffi::gst_child_proxy_get_property(
self.to_glib_none().0,
name.to_glib_none().0,
value.to_glib_none_mut().0,
);
Some(value)
}
}
fn set_property(&self, name: &str, value: &glib::Value) -> Result<(), glib::BoolError> {
unsafe {
let found: bool = from_glib(ffi::gst_child_proxy_lookup(self.to_glib_none().0, name.to_glib_none().0, ptr::null_mut(), ptr::null_mut()));
let found: bool = from_glib(ffi::gst_child_proxy_lookup(
self.to_glib_none().0,
name.to_glib_none().0,
ptr::null_mut(),
ptr::null_mut(),
));
if !found {
return Err(glib::BoolError("Child property not found"));
}
ffi::gst_child_proxy_set_property(self.to_glib_none().0, name.to_glib_none().0, value.to_glib_none().0);
ffi::gst_child_proxy_set_property(
self.to_glib_none().0,
name.to_glib_none().0,
value.to_glib_none().0,
);
Ok(())
}

View file

@ -10,7 +10,7 @@ use Element;
use glib;
use glib::IsA;
use glib::translate::{ToGlibPtr, from_glib};
use glib::translate::{from_glib, ToGlibPtr};
use QueryRef;
use miniobject::MiniObject;
@ -49,7 +49,10 @@ pub trait ElementExtManual {
impl<O: IsA<Element>> ElementExtManual for O {
fn query(&self, query: &mut QueryRef) -> bool {
unsafe {
from_glib(ffi::gst_element_query(self.to_glib_none().0, query.as_mut_ptr()))
from_glib(ffi::gst_element_query(
self.to_glib_none().0,
query.as_mut_ptr(),
))
}
}
}

View file

@ -15,7 +15,8 @@ use std::mem;
use std::ffi::CStr;
use glib;
use glib::translate::{from_glib, from_glib_none, from_glib_full, FromGlibPtrContainer, ToGlibPtr, ToGlib};
use glib::translate::{from_glib, from_glib_full, from_glib_none, FromGlibPtrContainer, ToGlib,
ToGlibPtr};
#[repr(C)]
pub struct EventRef(ffi::GstEvent);
@ -44,33 +45,23 @@ impl EventRef {
}
pub fn is_upstream(&self) -> bool {
unsafe {
((*self.as_ptr()).type_ as u32) & (ffi::GST_EVENT_TYPE_UPSTREAM.bits()) != 0
}
unsafe { ((*self.as_ptr()).type_ as u32) & (ffi::GST_EVENT_TYPE_UPSTREAM.bits()) != 0 }
}
pub fn is_downstream(&self) -> bool {
unsafe {
((*self.as_ptr()).type_ as u32) & (ffi::GST_EVENT_TYPE_DOWNSTREAM.bits()) != 0
}
unsafe { ((*self.as_ptr()).type_ as u32) & (ffi::GST_EVENT_TYPE_DOWNSTREAM.bits()) != 0 }
}
pub fn is_serialized(&self) -> bool {
unsafe {
((*self.as_ptr()).type_ as u32) & (ffi::GST_EVENT_TYPE_SERIALIZED.bits()) != 0
}
unsafe { ((*self.as_ptr()).type_ as u32) & (ffi::GST_EVENT_TYPE_SERIALIZED.bits()) != 0 }
}
pub fn is_sticky(&self) -> bool {
unsafe {
((*self.as_ptr()).type_ as u32) & (ffi::GST_EVENT_TYPE_STICKY.bits()) != 0
}
unsafe { ((*self.as_ptr()).type_ as u32) & (ffi::GST_EVENT_TYPE_STICKY.bits()) != 0 }
}
pub fn is_sticky_multi(&self) -> bool {
unsafe {
((*self.as_ptr()).type_ as u32) & (ffi::GST_EVENT_TYPE_STICKY_MULTI.bits()) != 0
}
unsafe { ((*self.as_ptr()).type_ as u32) & (ffi::GST_EVENT_TYPE_STICKY_MULTI.bits()) != 0 }
}
pub fn view(&self) -> EventView {
@ -162,7 +153,9 @@ impl Event {
}
#[cfg(feature = "v1_10")]
pub fn new_stream_collection(stream_collection: &::StreamCollection) -> StreamCollectionBuilder {
pub fn new_stream_collection(
stream_collection: &::StreamCollection,
) -> StreamCollectionBuilder {
StreamCollectionBuilder::new(stream_collection)
}
@ -170,7 +163,12 @@ impl Event {
TagBuilder::new(tags)
}
pub fn new_buffer_size(format: ::Format, minsize: i64, maxsize: i64, async: bool) -> BufferSizeBuilder {
pub fn new_buffer_size(
format: ::Format,
minsize: i64,
maxsize: i64,
async: bool,
) -> BufferSizeBuilder {
BufferSizeBuilder::new(format, minsize, maxsize, async)
}
@ -191,7 +189,11 @@ impl Event {
TocBuilder::new(toc, updated)
}
pub fn new_protection<'a>(system_id: &'a str, data: &'a ::Buffer, origin: &'a str) -> ProtectionBuilder<'a> {
pub fn new_protection<'a>(
system_id: &'a str,
data: &'a ::Buffer,
origin: &'a str,
) -> ProtectionBuilder<'a> {
ProtectionBuilder::new(system_id, data, origin)
}
@ -207,7 +209,15 @@ impl Event {
QosBuilder::new(type_, proportion, diff, timestamp)
}
pub fn new_seek(rate: f64, format: ::Format, flags: ::SeekFlags, start_type: ::SeekType, start: i64, stop_type: ::SeekType, stop: i64) -> SeekBuilder {
pub fn new_seek(
rate: f64,
format: ::Format,
flags: ::SeekFlags,
start_type: ::SeekType,
start: i64,
stop_type: ::SeekType,
stop: i64,
) -> SeekBuilder {
SeekBuilder::new(rate, format, flags, start_type, start, stop_type, stop)
}
@ -219,7 +229,13 @@ impl Event {
LatencyBuilder::new(latency)
}
pub fn new_step(format: ::Format, amount: u64, rate: f64, flush: bool, intermediate: bool) -> StepBuilder {
pub fn new_step(
format: ::Format,
amount: u64,
rate: f64,
flush: bool,
intermediate: bool,
) -> StepBuilder {
StepBuilder::new(format, amount, rate, flush, intermediate)
}
@ -410,7 +426,13 @@ impl<'a> BufferSize<'a> {
let mut maxsize = mem::uninitialized();
let mut async = mem::uninitialized();
ffi::gst_event_parse_buffer_size(self.0.as_mut_ptr(), &mut fmt, &mut minsize, &mut maxsize, &mut async);
ffi::gst_event_parse_buffer_size(
self.0.as_mut_ptr(),
&mut fmt,
&mut minsize,
&mut maxsize,
&mut async,
);
(from_glib(fmt), minsize, maxsize, from_glib(async))
}
}
@ -455,9 +477,18 @@ impl<'a> Protection<'a> {
let mut buffer = ptr::null_mut();
let mut origin = ptr::null();
ffi::gst_event_parse_protection(self.0.as_mut_ptr(), &mut system_id, &mut buffer, &mut origin);
ffi::gst_event_parse_protection(
self.0.as_mut_ptr(),
&mut system_id,
&mut buffer,
&mut origin,
);
(CStr::from_ptr(system_id).to_str().unwrap(), ::BufferRef::from_ptr(buffer), CStr::from_ptr(origin).to_str().unwrap())
(
CStr::from_ptr(system_id).to_str().unwrap(),
::BufferRef::from_ptr(buffer),
CStr::from_ptr(origin).to_str().unwrap(),
)
}
}
}
@ -499,7 +530,13 @@ impl<'a> Qos<'a> {
let mut diff = mem::uninitialized();
let mut timestamp = mem::uninitialized();
ffi::gst_event_parse_qos(self.0.as_mut_ptr(), &mut type_, &mut proportion, &mut diff, &mut timestamp);
ffi::gst_event_parse_qos(
self.0.as_mut_ptr(),
&mut type_,
&mut proportion,
&mut diff,
&mut timestamp,
);
(from_glib(type_), proportion, diff, timestamp)
}
@ -519,9 +556,26 @@ impl<'a> Seek<'a> {
let mut stop_type = mem::uninitialized();
let mut stop = mem::uninitialized();
ffi::gst_event_parse_seek(self.0.as_mut_ptr(), &mut rate, &mut fmt, &mut flags, &mut start_type, &mut start, &mut stop_type, &mut stop);
ffi::gst_event_parse_seek(
self.0.as_mut_ptr(),
&mut rate,
&mut fmt,
&mut flags,
&mut start_type,
&mut start,
&mut stop_type,
&mut stop,
);
(rate, from_glib(fmt), from_glib(flags), from_glib(start_type), start, from_glib(stop_type), stop)
(
rate,
from_glib(fmt),
from_glib(flags),
from_glib(start_type),
start,
from_glib(stop_type),
stop,
)
}
}
}
@ -551,9 +605,22 @@ impl<'a> Step<'a> {
let mut flush = mem::uninitialized();
let mut intermediate = mem::uninitialized();
ffi::gst_event_parse_step(self.0.as_mut_ptr(), &mut fmt, &mut amount, &mut rate, &mut flush, &mut intermediate);
ffi::gst_event_parse_step(
self.0.as_mut_ptr(),
&mut fmt,
&mut amount,
&mut rate,
&mut flush,
&mut intermediate,
);
(from_glib(fmt), amount, rate, from_glib(flush), from_glib(intermediate))
(
from_glib(fmt),
amount,
rate,
from_glib(flush),
from_glib(intermediate),
)
}
}
}
@ -646,7 +713,7 @@ impl FlushStartBuilder {
pub struct FlushStopBuilder {
seqnum: Option<u32>,
running_time_offset: Option<i64>,
reset_time: bool
reset_time: bool,
}
impl FlushStopBuilder {
pub fn new(reset_time: bool) -> Self {
@ -657,7 +724,9 @@ impl FlushStopBuilder {
}
}
event_builder_generic_impl!(|s: &Self| ffi::gst_event_new_flush_stop(s.reset_time.to_glib()));
event_builder_generic_impl!(|s: &Self| {
ffi::gst_event_new_flush_stop(s.reset_time.to_glib())
});
}
pub struct StreamStartBuilder<'a> {
@ -681,14 +750,14 @@ impl<'a> StreamStartBuilder<'a> {
pub fn flags(self, flags: ::StreamFlags) -> Self {
Self {
flags: Some(flags),
.. self
..self
}
}
pub fn group_id(self, group_id: u32) -> Self {
Self {
group_id: Some(group_id),
.. self
..self
}
}
@ -735,7 +804,9 @@ impl<'a> SegmentBuilder<'a> {
}
}
event_builder_generic_impl!(|s: &Self| ffi::gst_event_new_segment(s.segment.to_glib_none().0));
event_builder_generic_impl!(|s: &Self| {
ffi::gst_event_new_segment(s.segment.to_glib_none().0)
});
}
#[cfg(feature = "v1_10")]
@ -754,7 +825,9 @@ impl<'a> StreamCollectionBuilder<'a> {
}
}
event_builder_generic_impl!(|s: &Self| ffi::gst_event_new_stream_collection(s.stream_collection.to_glib_none().0));
event_builder_generic_impl!(|s: &Self| {
ffi::gst_event_new_stream_collection(s.stream_collection.to_glib_none().0)
});
}
pub struct TagBuilder {
@ -797,7 +870,9 @@ impl BufferSizeBuilder {
}
}
event_builder_generic_impl!(|s: &Self| ffi::gst_event_new_buffer_size(s.fmt.to_glib(), s.minsize, s.maxsize, s.async.to_glib()));
event_builder_generic_impl!(|s: &Self| {
ffi::gst_event_new_buffer_size(s.fmt.to_glib(), s.minsize, s.maxsize, s.async.to_glib())
});
}
pub struct SinkMessageBuilder<'a> {
@ -816,7 +891,9 @@ impl<'a> SinkMessageBuilder<'a> {
}
}
event_builder_generic_impl!(|s: &Self| ffi::gst_event_new_sink_message(s.name.to_glib_none().0, s.msg.as_mut_ptr()));
event_builder_generic_impl!(|s: &Self| {
ffi::gst_event_new_sink_message(s.name.to_glib_none().0, s.msg.as_mut_ptr())
});
}
#[cfg(feature = "v1_10")]
@ -869,7 +946,9 @@ impl TocBuilder {
}
}
event_builder_generic_impl!(|s: &Self| ffi::gst_event_new_toc(ptr::null_mut(), s.updated.to_glib()));
event_builder_generic_impl!(|s: &Self| {
ffi::gst_event_new_toc(ptr::null_mut(), s.updated.to_glib())
});
}
pub struct ProtectionBuilder<'a> {
@ -890,7 +969,13 @@ impl<'a> ProtectionBuilder<'a> {
}
}
event_builder_generic_impl!(|s: &Self| ffi::gst_event_new_protection(s.system_id.to_glib_none().0, s.data.as_mut_ptr(), s.origin.to_glib_none().0));
event_builder_generic_impl!(|s: &Self| {
ffi::gst_event_new_protection(
s.system_id.to_glib_none().0,
s.data.as_mut_ptr(),
s.origin.to_glib_none().0,
)
});
}
pub struct SegmentDoneBuilder {
@ -909,7 +994,9 @@ impl SegmentDoneBuilder {
}
}
event_builder_generic_impl!(|s: &Self| ffi::gst_event_new_segment_done(s.fmt.to_glib(), s.position));
event_builder_generic_impl!(|s: &Self| {
ffi::gst_event_new_segment_done(s.fmt.to_glib(), s.position)
});
}
pub struct GapBuilder {
@ -951,7 +1038,9 @@ impl QosBuilder {
}
}
event_builder_generic_impl!(|s: &Self| ffi::gst_event_new_qos(s.type_.to_glib(), s.proportion, s.diff, s.timestamp));
event_builder_generic_impl!(|s: &Self| {
ffi::gst_event_new_qos(s.type_.to_glib(), s.proportion, s.diff, s.timestamp)
});
}
pub struct SeekBuilder {
@ -966,7 +1055,15 @@ pub struct SeekBuilder {
stop: i64,
}
impl SeekBuilder {
pub fn new(rate: f64, fmt: ::Format, flags: ::SeekFlags, start_type: ::SeekType, start: i64, stop_type: ::SeekType, stop: i64) -> Self {
pub fn new(
rate: f64,
fmt: ::Format,
flags: ::SeekFlags,
start_type: ::SeekType,
start: i64,
stop_type: ::SeekType,
stop: i64,
) -> Self {
Self {
seqnum: None,
running_time_offset: None,
@ -980,7 +1077,17 @@ impl SeekBuilder {
}
}
event_builder_generic_impl!(|s: &Self| ffi::gst_event_new_seek(s.rate, s.fmt.to_glib(), s.flags.to_glib(), s.start_type.to_glib(), s.start, s.stop_type.to_glib(), s.stop));
event_builder_generic_impl!(|s: &Self| {
ffi::gst_event_new_seek(
s.rate,
s.fmt.to_glib(),
s.flags.to_glib(),
s.start_type.to_glib(),
s.start,
s.stop_type.to_glib(),
s.stop,
)
});
}
pub struct NavigationBuilder {
@ -1045,7 +1152,15 @@ impl StepBuilder {
}
}
event_builder_generic_impl!(|s: &Self| ffi::gst_event_new_step(s.fmt.to_glib(), s.amount, s.rate, s.flush.to_glib(), s.intermediate.to_glib()));
event_builder_generic_impl!(|s: &Self| {
ffi::gst_event_new_step(
s.fmt.to_glib(),
s.amount,
s.rate,
s.flush.to_glib(),
s.intermediate.to_glib(),
)
});
}
pub struct ReconfigureBuilder {
@ -1077,7 +1192,9 @@ impl<'a> TocSelectBuilder<'a> {
}
}
event_builder_generic_impl!(|s: &Self| ffi::gst_event_new_toc_select(s.uid.to_glib_none().0));
event_builder_generic_impl!(|s: &Self| {
ffi::gst_event_new_toc_select(s.uid.to_glib_none().0)
});
}
#[cfg(feature = "v1_10")]
@ -1096,7 +1213,9 @@ impl<'a> SelectStreamsBuilder<'a> {
}
}
event_builder_generic_impl!(|s: &Self| ffi::gst_event_new_select_streams(s.streams.to_glib_full()));
event_builder_generic_impl!(|s: &Self| {
ffi::gst_event_new_select_streams(s.streams.to_glib_full())
});
}
pub struct CustomUpstreamBuilder {
@ -1115,7 +1234,8 @@ impl CustomUpstreamBuilder {
event_builder_generic_impl!(|s: &mut Self| {
let structure = s.structure.take();
let ev = ffi::gst_event_new_custom(ffi::GST_EVENT_CUSTOM_UPSTREAM, structure.to_glib_none().0);
let ev =
ffi::gst_event_new_custom(ffi::GST_EVENT_CUSTOM_UPSTREAM, structure.to_glib_none().0);
mem::forget(structure);
ev
@ -1138,7 +1258,8 @@ impl CustomDownstreamBuilder {
event_builder_generic_impl!(|s: &mut Self| {
let structure = s.structure.take();
let ev = ffi::gst_event_new_custom(ffi::GST_EVENT_CUSTOM_DOWNSTREAM, structure.to_glib_none().0);
let ev =
ffi::gst_event_new_custom(ffi::GST_EVENT_CUSTOM_DOWNSTREAM, structure.to_glib_none().0);
mem::forget(structure);
ev
@ -1161,7 +1282,10 @@ impl CustomDownstreamOobBuilder {
event_builder_generic_impl!(|s: &mut Self| {
let structure = s.structure.take();
let ev = ffi::gst_event_new_custom(ffi::GST_EVENT_CUSTOM_DOWNSTREAM_OOB, structure.to_glib_none().0);
let ev = ffi::gst_event_new_custom(
ffi::GST_EVENT_CUSTOM_DOWNSTREAM_OOB,
structure.to_glib_none().0,
);
mem::forget(structure);
ev
@ -1184,7 +1308,10 @@ impl CustomDownstreamStickyBuilder {
event_builder_generic_impl!(|s: &mut Self| {
let structure = s.structure.take();
let ev = ffi::gst_event_new_custom(ffi::GST_EVENT_CUSTOM_DOWNSTREAM_STICKY, structure.to_glib_none().0);
let ev = ffi::gst_event_new_custom(
ffi::GST_EVENT_CUSTOM_DOWNSTREAM_STICKY,
structure.to_glib_none().0,
);
mem::forget(structure);
ev
@ -1230,7 +1357,8 @@ impl CustomBothOobBuilder {
event_builder_generic_impl!(|s: &mut Self| {
let structure = s.structure.take();
let ev = ffi::gst_event_new_custom(ffi::GST_EVENT_CUSTOM_BOTH_OOB, structure.to_glib_none().0);
let ev =
ffi::gst_event_new_custom(ffi::GST_EVENT_CUSTOM_BOTH_OOB, structure.to_glib_none().0);
mem::forget(structure);
ev

View file

@ -20,16 +20,25 @@ impl GhostPad {
let name = name.into();
let name = name.to_glib_none();
unsafe {
Option::<Pad>::from_glib_none(ffi::gst_ghost_pad_new(name.0, target.to_glib_none().0)).map(|o| Downcast::downcast_unchecked(o))
Option::<Pad>::from_glib_none(ffi::gst_ghost_pad_new(name.0, target.to_glib_none().0))
.map(|o| Downcast::downcast_unchecked(o))
}
}
pub fn new_from_template<'a, P: Into<Option<&'a str>>, Q: IsA<Pad>>(name: P, target: &Q, templ: &PadTemplate) -> Option<GhostPad> {
pub fn new_from_template<'a, P: Into<Option<&'a str>>, Q: IsA<Pad>>(
name: P,
target: &Q,
templ: &PadTemplate,
) -> Option<GhostPad> {
skip_assert_initialized!();
let name = name.into();
let name = name.to_glib_none();
unsafe {
Option::<Pad>::from_glib_none(ffi::gst_ghost_pad_new_from_template(name.0, target.to_glib_none().0, templ.to_glib_none().0)).map(|o| Downcast::downcast_unchecked(o))
Option::<Pad>::from_glib_none(ffi::gst_ghost_pad_new_from_template(
name.0,
target.to_glib_none().0,
templ.to_glib_none().0,
)).map(|o| Downcast::downcast_unchecked(o))
}
}
}

View file

@ -24,7 +24,10 @@ impl Iterator {
pub fn next(&mut self) -> Result<Value, IteratorResult> {
unsafe {
let mut value = Value::uninitialized();
let res = from_glib(ffi::gst_iterator_next(self.to_glib_none_mut().0, value.to_glib_none_mut().0));
let res = from_glib(ffi::gst_iterator_next(
self.to_glib_none_mut().0,
value.to_glib_none_mut().0,
));
if res == IteratorResult::Ok {
Ok(value)
} else {

View file

@ -6,7 +6,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![recursion_limit="256"]
#![recursion_limit = "256"]
#[macro_use]
extern crate bitflags;
extern crate libc;
@ -46,7 +46,7 @@ pub use glib::{Cast, Continue, Error, IsA, StaticType, ToValue, Type, TypedValue
mod auto;
pub use auto::*;
pub use auto::traits::*;
pub use auto::functions::{parse_launch, parse_bin_from_description};
pub use auto::functions::{parse_bin_from_description, parse_launch};
pub use auto::traits::ObjectExt as GstObjectExt;
pub mod miniobject;
@ -60,7 +60,8 @@ pub use caps::{Caps, CapsRef};
pub mod tags;
pub use tags::*;
pub mod buffer;
pub use buffer::{Buffer, BufferRef, ReadBufferMap, ReadWriteBufferMap, ReadMappedBuffer, ReadWriteMappedBuffer};
pub use buffer::{Buffer, BufferRef, ReadBufferMap, ReadMappedBuffer, ReadWriteBufferMap,
ReadWriteMappedBuffer};
pub mod sample;
pub use sample::{Sample, SampleRef};
pub mod bufferlist;
@ -82,7 +83,7 @@ mod tag_setter;
mod iterator;
pub use element::ElementExtManual;
pub use bin::BinExtManual;
pub use pad::{PadExtManual, PadProbeId, PadProbeInfo, PadProbeData, PAD_PROBE_ID_INVALID};
pub use pad::{PadExtManual, PadProbeData, PadProbeId, PadProbeInfo, PAD_PROBE_ID_INVALID};
pub use gobject::GObjectExtManualGst;
pub use child_proxy::ChildProxyExtManual;
pub use tag_setter::TagSetterExtManual;

View file

@ -19,7 +19,7 @@ use std::ffi::CStr;
use glib;
use glib::Cast;
use glib::IsA;
use glib::translate::{from_glib, from_glib_none, from_glib_full, mut_override, ToGlibPtr, ToGlib};
use glib::translate::{from_glib, from_glib_full, from_glib_none, mut_override, ToGlib, ToGlibPtr};
#[repr(C)]
pub struct MessageRef(ffi::GstMessage);
@ -167,7 +167,7 @@ impl Message {
flush: bool,
intermediate: bool,
duration: u64,
eos: bool
eos: bool,
) -> StepDoneBuilder {
StepDoneBuilder::new(format, amount, rate, flush, intermediate, duration, eos)
}
@ -184,7 +184,11 @@ impl Message {
NewClockBuilder::new(clock)
}
pub fn new_structure_change(type_: ::StructureChangeType, owner: &::Element, busy: bool) -> StructureChangeBuilder {
pub fn new_structure_change(
type_: ::StructureChangeType,
owner: &::Element,
busy: bool,
) -> StructureChangeBuilder {
StructureChangeBuilder::new(type_, owner, busy)
}
@ -224,7 +228,8 @@ impl Message {
AsyncDoneBuilder::new(running_time)
}
pub fn new_step_start(active: bool,
pub fn new_step_start(
active: bool,
format: ::Format,
amount: u64,
rate: f64,
@ -234,12 +239,13 @@ impl Message {
StepStartBuilder::new(active, format, amount, rate, flush, intermediate)
}
pub fn new_qos_builder(live: bool,
pub fn new_qos_builder(
live: bool,
running_time: u64,
stream_time: u64,
timestamp: u64,
duration: u64,
) -> QosBuilder {
) -> QosBuilder {
QosBuilder::new(live, running_time, stream_time, timestamp, duration)
}
@ -272,7 +278,10 @@ impl Message {
}
#[cfg(feature = "v1_10")]
pub fn new_property_notify<'a>(property_name: &'a str, value: &'a glib::Value) -> PropertyNotifyBuilder<'a> {
pub fn new_property_notify<'a>(
property_name: &'a str,
value: &'a glib::Value,
) -> PropertyNotifyBuilder<'a> {
PropertyNotifyBuilder::new(property_name, value)
}
@ -287,7 +296,8 @@ impl Message {
}
#[cfg(feature = "v1_10")]
pub fn new_redirect<'a>(location: &'a str,
pub fn new_redirect<'a>(
location: &'a str,
tag_list: Option<&'a TagList>,
entry_struct: Option<Structure>,
) -> RedirectBuilder<'a> {

View file

@ -6,15 +6,15 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::{fmt, ops, borrow};
use std::{borrow, fmt, ops};
use std::mem;
use std::marker::PhantomData;
use ffi;
use glib_ffi::gpointer;
use gobject_ffi;
use glib::translate::{from_glib, from_glib_none, Stash, StashMut, ToGlibPtr, ToGlibPtrMut,
FromGlibPtrNone, FromGlibPtrFull, FromGlibPtrBorrow};
use glib::translate::{from_glib, from_glib_none, FromGlibPtrBorrow, FromGlibPtrFull,
FromGlibPtrNone, Stash, StashMut, ToGlibPtr, ToGlibPtrMut};
use glib;
#[derive(Hash, Debug, PartialEq, Eq, PartialOrd, Ord)]
@ -63,9 +63,10 @@ impl<T: MiniObject> GstRc<T> {
return &mut *self.obj;
}
self.obj = T::from_mut_ptr(ffi::gst_mini_object_make_writable(
self.as_mut_ptr() as *mut ffi::GstMiniObject,
) as *mut T::GstType);
self.obj = T::from_mut_ptr(
ffi::gst_mini_object_make_writable(self.as_mut_ptr() as *mut ffi::GstMiniObject) as
*mut T::GstType,
);
assert!(self.is_writable());
&mut *self.obj
@ -82,9 +83,10 @@ impl<T: MiniObject> GstRc<T> {
pub fn copy(&self) -> Self {
unsafe {
GstRc::from_glib_full(ffi::gst_mini_object_copy(
self.as_ptr() as *const ffi::GstMiniObject,
) as *const T::GstType)
GstRc::from_glib_full(
ffi::gst_mini_object_copy(self.as_ptr() as *const ffi::GstMiniObject) as
*const T::GstType,
)
}
}
@ -263,7 +265,8 @@ impl<T: MiniObject + glib::StaticType> glib::StaticType for GstRc<T> {
}
}
impl<'a, T: MiniObject + glib::StaticType + 'static> glib::value::FromValueOptional<'a> for GstRc<T> {
impl<'a, T: MiniObject + glib::StaticType + 'static> glib::value::FromValueOptional<'a>
for GstRc<T> {
unsafe fn from_value_optional(v: &'a glib::Value) -> Option<Self> {
let ptr = gobject_ffi::g_value_get_boxed(v.to_glib_none().0);
from_glib_none(ptr as *const T::GstType)

View file

@ -22,7 +22,7 @@ use std::mem::transmute;
use std::ptr;
use glib::{IsA, StaticType};
use glib::translate::{ToGlib, ToGlibPtr, FromGlib, from_glib, from_glib_none, from_glib_full};
use glib::translate::{from_glib, from_glib_full, from_glib_none, FromGlib, ToGlib, ToGlibPtr};
use glib::source::CallbackGuard;
use glib_ffi::gpointer;
use glib::Object;
@ -79,7 +79,11 @@ pub trait PadExtManual {
fn peer_query(&self, query: &mut QueryRef) -> bool;
fn query(&self, query: &mut QueryRef) -> bool;
fn query_default<'a, P: IsA<Object> + 'a, Q: Into<Option<&'a P>>>(&self, parent: Q, query: &mut QueryRef) -> bool;
fn query_default<'a, P: IsA<Object> + 'a, Q: Into<Option<&'a P>>>(
&self,
parent: Q,
query: &mut QueryRef,
) -> bool;
fn proxy_query_caps(&self, query: &mut QueryRef) -> bool;
fn proxy_query_accept_caps(&self, query: &mut QueryRef) -> bool;
}
@ -152,33 +156,53 @@ impl<O: IsA<Pad>> PadExtManual for O {
fn query(&self, query: &mut QueryRef) -> bool {
unsafe {
from_glib(ffi::gst_pad_query(self.to_glib_none().0, query.as_mut_ptr()))
from_glib(ffi::gst_pad_query(
self.to_glib_none().0,
query.as_mut_ptr(),
))
}
}
fn peer_query(&self, query: &mut QueryRef) -> bool {
unsafe {
from_glib(ffi::gst_pad_peer_query(self.to_glib_none().0, query.as_mut_ptr()))
from_glib(ffi::gst_pad_peer_query(
self.to_glib_none().0,
query.as_mut_ptr(),
))
}
}
fn query_default<'a, P: IsA<Object> + 'a, Q: Into<Option<&'a P>>>(&self, parent: Q, query: &mut QueryRef) -> bool {
fn query_default<'a, P: IsA<Object> + 'a, Q: Into<Option<&'a P>>>(
&self,
parent: Q,
query: &mut QueryRef,
) -> bool {
let parent = parent.into();
let parent = parent.to_glib_none();
unsafe {
from_glib(ffi::gst_pad_query_default(self.to_glib_none().0, parent.0 as *mut _, query.as_mut_ptr()))
from_glib(ffi::gst_pad_query_default(
self.to_glib_none().0,
parent.0 as *mut _,
query.as_mut_ptr(),
))
}
}
fn proxy_query_accept_caps(&self, query: &mut QueryRef) -> bool {
unsafe {
from_glib(ffi::gst_pad_proxy_query_accept_caps(self.to_glib_none().0, query.as_mut_ptr()))
from_glib(ffi::gst_pad_proxy_query_accept_caps(
self.to_glib_none().0,
query.as_mut_ptr(),
))
}
}
fn proxy_query_caps(&self, query: &mut QueryRef) -> bool {
unsafe {
from_glib(ffi::gst_pad_proxy_query_accept_caps(self.to_glib_none().0, query.as_mut_ptr()))
from_glib(ffi::gst_pad_proxy_query_accept_caps(
self.to_glib_none().0,
query.as_mut_ptr(),
))
}
}
}

View file

@ -14,25 +14,44 @@ use FlowReturn;
use Buffer;
use glib::IsA;
use glib::translate::{ToGlibPtr, from_glib, from_glib_full};
use glib::translate::{from_glib, from_glib_full, ToGlibPtr};
use ffi;
impl ProxyPad {
pub fn chain_default<'a, P: IsA<Pad>, Q: IsA<Object> + 'a, R: Into<Option<&'a Q>>>(pad: &P, parent: R, buffer: Buffer) -> FlowReturn {
pub fn chain_default<'a, P: IsA<Pad>, Q: IsA<Object> + 'a, R: Into<Option<&'a Q>>>(
pad: &P,
parent: R,
buffer: Buffer,
) -> FlowReturn {
skip_assert_initialized!();
let parent = parent.into();
let parent = parent.to_glib_none();
unsafe {
from_glib(ffi::gst_proxy_pad_chain_default(pad.to_glib_none().0, parent.0, buffer.into_ptr()))
from_glib(ffi::gst_proxy_pad_chain_default(
pad.to_glib_none().0,
parent.0,
buffer.into_ptr(),
))
}
}
pub fn getrange_default<P: IsA<Pad>, Q: IsA<Object>>(pad: &P, parent: &Q, offset: u64, size: u32) -> Result<Buffer, FlowReturn> {
pub fn getrange_default<P: IsA<Pad>, Q: IsA<Object>>(
pad: &P,
parent: &Q,
offset: u64,
size: u32,
) -> Result<Buffer, FlowReturn> {
skip_assert_initialized!();
unsafe {
let mut buffer = ptr::null_mut();
let ret = from_glib(ffi::gst_proxy_pad_getrange_default(pad.to_glib_none().0, parent.to_glib_none().0, offset, size, &mut buffer));
let ret = from_glib(ffi::gst_proxy_pad_getrange_default(
pad.to_glib_none().0,
parent.to_glib_none().0,
offset,
size,
&mut buffer,
));
if ret == FlowReturn::Ok {
Ok(from_glib_full(buffer))
} else {

View file

@ -15,7 +15,7 @@ use std::mem;
use std::ops::Deref;
use glib;
use glib::translate::{from_glib, from_glib_full, ToGlibPtr, ToGlib};
use glib::translate::{from_glib, from_glib_full, ToGlib, ToGlibPtr};
#[repr(C)]
pub struct QueryRef(ffi::GstQuery);
@ -28,87 +28,70 @@ unsafe impl MiniObject for QueryRef {
impl Query {
pub fn new_position(fmt: ::Format) -> Self {
unsafe {
from_glib_full(ffi::gst_query_new_position(fmt.to_glib()))
}
unsafe { from_glib_full(ffi::gst_query_new_position(fmt.to_glib())) }
}
pub fn new_duration(fmt: ::Format) -> Self {
unsafe {
from_glib_full(ffi::gst_query_new_duration(fmt.to_glib()))
}
unsafe { from_glib_full(ffi::gst_query_new_duration(fmt.to_glib())) }
}
pub fn new_latency() -> Self {
unsafe {
from_glib_full(ffi::gst_query_new_latency())
}
unsafe { from_glib_full(ffi::gst_query_new_latency()) }
}
pub fn new_seeking(fmt: ::Format) -> Self {
unsafe {
from_glib_full(ffi::gst_query_new_seeking(fmt.to_glib()))
}
unsafe { from_glib_full(ffi::gst_query_new_seeking(fmt.to_glib())) }
}
pub fn new_segment(fmt: ::Format) -> Self {
unsafe {
from_glib_full(ffi::gst_query_new_segment(fmt.to_glib()))
}
unsafe { from_glib_full(ffi::gst_query_new_segment(fmt.to_glib())) }
}
pub fn new_convert(src_fmt: ::Format, value: i64, dest_fmt: ::Format) -> Self {
unsafe {
from_glib_full(ffi::gst_query_new_convert(src_fmt.to_glib(), value, dest_fmt.to_glib()))
from_glib_full(ffi::gst_query_new_convert(
src_fmt.to_glib(),
value,
dest_fmt.to_glib(),
))
}
}
pub fn new_formats() -> Self {
unsafe {
from_glib_full(ffi::gst_query_new_formats())
}
unsafe { from_glib_full(ffi::gst_query_new_formats()) }
}
pub fn new_buffering(fmt: ::Format) -> Self {
unsafe {
from_glib_full(ffi::gst_query_new_buffering(fmt.to_glib()))
}
unsafe { from_glib_full(ffi::gst_query_new_buffering(fmt.to_glib())) }
}
pub fn new_custom(structure: ::Structure) -> Self {
unsafe {
from_glib_full(ffi::gst_query_new_custom(ffi::GST_QUERY_CUSTOM, structure.into_ptr()))
from_glib_full(ffi::gst_query_new_custom(
ffi::GST_QUERY_CUSTOM,
structure.into_ptr(),
))
}
}
pub fn new_uri() -> Self {
unsafe {
from_glib_full(ffi::gst_query_new_uri())
}
unsafe { from_glib_full(ffi::gst_query_new_uri()) }
}
pub fn new_scheduling() -> Self {
unsafe {
from_glib_full(ffi::gst_query_new_scheduling())
}
unsafe { from_glib_full(ffi::gst_query_new_scheduling()) }
}
pub fn new_accept_caps(caps: &::Caps) -> Self {
unsafe {
from_glib_full(ffi::gst_query_new_accept_caps(caps.as_mut_ptr()))
}
unsafe { from_glib_full(ffi::gst_query_new_accept_caps(caps.as_mut_ptr())) }
}
pub fn new_caps(filter: &::Caps) -> Self {
unsafe {
from_glib_full(ffi::gst_query_new_caps(filter.as_mut_ptr()))
}
unsafe { from_glib_full(ffi::gst_query_new_caps(filter.as_mut_ptr())) }
}
pub fn new_drain() -> Self {
unsafe {
from_glib_full(ffi::gst_query_new_drain())
}
unsafe { from_glib_full(ffi::gst_query_new_drain()) }
}
}
@ -128,21 +111,15 @@ impl QueryRef {
}
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 {
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 {
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> {
@ -190,9 +167,7 @@ impl QueryRef {
}
pub fn view_mut(&mut self) -> QueryView<&mut Self> {
unsafe {
mem::transmute(self.view())
}
unsafe { mem::transmute(self.view()) }
}
}
@ -350,7 +325,13 @@ impl<'a> Seeking<&'a QueryRef> {
let mut seekable = mem::uninitialized();
let mut start = mem::uninitialized();
let mut end = mem::uninitialized();
ffi::gst_query_parse_seeking(self.0.as_mut_ptr(), &mut fmt, &mut seekable, &mut start, &mut end);
ffi::gst_query_parse_seeking(
self.0.as_mut_ptr(),
&mut fmt,
&mut seekable,
&mut start,
&mut end,
);
(from_glib(fmt), from_glib(seekable), start, end)
}
@ -364,7 +345,13 @@ impl<'a> Seeking<&'a QueryRef> {
impl<'a> Seeking<&'a mut QueryRef> {
pub fn set(&mut self, fmt: ::Format, seekable: bool, start: i64, end: i64) {
unsafe {
ffi::gst_query_set_seeking(self.0.as_mut_ptr(), fmt.to_glib(), seekable.to_glib(), start, end);
ffi::gst_query_set_seeking(
self.0.as_mut_ptr(),
fmt.to_glib(),
seekable.to_glib(),
start,
end,
);
}
}
@ -382,7 +369,13 @@ impl<'a> Segment<&'a QueryRef> {
let mut start = mem::uninitialized();
let mut stop = mem::uninitialized();
ffi::gst_query_parse_segment(self.0.as_mut_ptr(), &mut rate, &mut fmt, &mut start, &mut stop);
ffi::gst_query_parse_segment(
self.0.as_mut_ptr(),
&mut rate,
&mut fmt,
&mut start,
&mut stop,
);
(rate, from_glib(fmt), start, stop)
}
}
@ -413,7 +406,13 @@ impl<'a> Convert<&'a QueryRef> {
let mut dest_fmt = mem::uninitialized();
let mut dest = mem::uninitialized();
ffi::gst_query_parse_convert(self.0.as_mut_ptr(), &mut src_fmt, &mut src, &mut dest_fmt, &mut dest);
ffi::gst_query_parse_convert(
self.0.as_mut_ptr(),
&mut src_fmt,
&mut src,
&mut dest_fmt,
&mut dest,
);
(from_glib(src_fmt), src, from_glib(dest_fmt), dest)
}
}
@ -426,7 +425,13 @@ impl<'a> Convert<&'a QueryRef> {
impl<'a> Convert<&'a mut QueryRef> {
pub fn set(&mut self, src_fmt: ::Format, src: i64, dest_fmt: ::Format, dest: i64) {
unsafe {
ffi::gst_query_set_convert(self.0.as_mut_ptr(), src_fmt.to_glib(), src, dest_fmt.to_glib(), dest);
ffi::gst_query_set_convert(
self.0.as_mut_ptr(),
src_fmt.to_glib(),
src,
dest_fmt.to_glib(),
dest,
);
}
}
@ -491,7 +496,13 @@ impl<'a> Buffering<&'a QueryRef> {
let mut stop = mem::uninitialized();
let mut estimated_total = mem::uninitialized();
ffi::gst_query_parse_buffering_range(self.0.as_mut_ptr(), &mut fmt, &mut start, &mut stop, &mut estimated_total);
ffi::gst_query_parse_buffering_range(
self.0.as_mut_ptr(),
&mut fmt,
&mut start,
&mut stop,
&mut estimated_total,
);
(from_glib(fmt), start, stop, estimated_total)
}
}
@ -503,7 +514,13 @@ impl<'a> Buffering<&'a QueryRef> {
let mut avg_out = mem::uninitialized();
let mut buffering_left = mem::uninitialized();
ffi::gst_query_parse_buffering_stats(self.0.as_mut_ptr(), &mut mode, &mut avg_in, &mut avg_out, &mut buffering_left);
ffi::gst_query_parse_buffering_stats(
self.0.as_mut_ptr(),
&mut mode,
&mut avg_in,
&mut avg_out,
&mut buffering_left,
);
(from_glib(mode), avg_in, avg_out, buffering_left)
}
@ -516,7 +533,12 @@ impl<'a> Buffering<&'a QueryRef> {
for i in 0..n {
let mut start = mem::uninitialized();
let mut stop = mem::uninitialized();
let s: bool = from_glib(ffi::gst_query_parse_nth_buffering_range(self.0.as_mut_ptr(), i, &mut start, &mut stop));
let s: bool = from_glib(ffi::gst_query_parse_nth_buffering_range(
self.0.as_mut_ptr(),
i,
&mut start,
&mut stop,
));
if s {
res.push((start, stop));
}
@ -540,13 +562,31 @@ impl<'a> Buffering<&'a mut QueryRef> {
pub fn set_range(&mut self, fmt: ::Format, start: i64, stop: i64, estimated_total: i64) {
unsafe {
ffi::gst_query_set_buffering_range(self.0.as_mut_ptr(), fmt.to_glib(), start, stop, estimated_total);
ffi::gst_query_set_buffering_range(
self.0.as_mut_ptr(),
fmt.to_glib(),
start,
stop,
estimated_total,
);
}
}
pub fn set_stats(&mut self, mode: ::BufferingMode, avg_in: i32, avg_out: i32, buffering_left: i64) {
pub fn set_stats(
&mut self,
mode: ::BufferingMode,
avg_in: i32,
avg_out: i32,
buffering_left: i64,
) {
unsafe {
ffi::gst_query_set_buffering_stats(self.0.as_mut_ptr(), mode.to_glib(), avg_in, avg_out, buffering_left);
ffi::gst_query_set_buffering_stats(
self.0.as_mut_ptr(),
mode.to_glib(),
avg_in,
avg_out,
buffering_left,
);
}
}
@ -641,13 +681,24 @@ pub struct Scheduling<T>(T);
impl<'a> Scheduling<&'a QueryRef> {
pub fn has_scheduling_mode(&self, mode: ::PadMode) -> bool {
unsafe {
from_glib(ffi::gst_query_has_scheduling_mode(self.0.as_mut_ptr(), mode.to_glib()))
from_glib(ffi::gst_query_has_scheduling_mode(
self.0.as_mut_ptr(),
mode.to_glib(),
))
}
}
pub fn has_scheduling_mode_with_flags(&self, mode: ::PadMode, flags: ::SchedulingFlags) -> bool {
pub fn has_scheduling_mode_with_flags(
&self,
mode: ::PadMode,
flags: ::SchedulingFlags,
) -> bool {
unsafe {
from_glib(ffi::gst_query_has_scheduling_mode_with_flags(self.0.as_mut_ptr(), mode.to_glib(), flags.to_glib()))
from_glib(ffi::gst_query_has_scheduling_mode_with_flags(
self.0.as_mut_ptr(),
mode.to_glib(),
flags.to_glib(),
))
}
}
@ -656,7 +707,10 @@ impl<'a> Scheduling<&'a QueryRef> {
let n = ffi::gst_query_get_n_scheduling_modes(self.0.as_mut_ptr());
let mut res = Vec::with_capacity(n as usize);
for i in 0..n {
res.push(from_glib(ffi::gst_query_parse_nth_scheduling_mode(self.0.as_mut_ptr(), i)));
res.push(from_glib(ffi::gst_query_parse_nth_scheduling_mode(
self.0.as_mut_ptr(),
i,
)));
}
res
@ -670,7 +724,13 @@ impl<'a> Scheduling<&'a QueryRef> {
let mut maxsize = mem::uninitialized();
let mut align = mem::uninitialized();
ffi::gst_query_parse_scheduling(self.0.as_mut_ptr(), &mut flags, &mut minsize, &mut maxsize, &mut align);
ffi::gst_query_parse_scheduling(
self.0.as_mut_ptr(),
&mut flags,
&mut minsize,
&mut maxsize,
&mut align,
);
(from_glib(flags), minsize, maxsize, align)
}
@ -692,7 +752,13 @@ impl<'a> Scheduling<&'a mut QueryRef> {
pub fn set(&mut self, flags: ::SchedulingFlags, minsize: i32, maxsize: i32, align: i32) {
unsafe {
ffi::gst_query_set_scheduling(self.0.as_mut_ptr(), flags.to_glib(), minsize, maxsize, align);
ffi::gst_query_set_scheduling(
self.0.as_mut_ptr(),
flags.to_glib(),
minsize,
maxsize,
align,
);
}
}
@ -860,7 +926,7 @@ mod tests {
let (fmt, pos) = p.get();
assert_eq!(fmt, ::Format::Time);
assert_eq!(pos, -1);
},
}
_ => (),
}
@ -870,7 +936,7 @@ mod tests {
assert_eq!(fmt, ::Format::Time);
assert_eq!(pos, -1);
p.set(::Format::Time, 2);
},
}
_ => (),
}
@ -879,7 +945,7 @@ mod tests {
let (fmt, pos) = p.get();
assert_eq!(fmt, ::Format::Time);
assert_eq!(pos, 2);
},
}
_ => (),
}
}

View file

@ -12,7 +12,7 @@ use ffi;
use glib;
use glib::StaticType;
use glib::translate::{mut_override, from_glib, from_glib_none, from_glib_full, ToGlibPtr};
use glib::translate::{from_glib, from_glib_full, from_glib_none, mut_override, ToGlibPtr};
use miniobject::*;
use Buffer;
@ -28,35 +28,39 @@ unsafe impl MiniObject for SampleRef {
}
impl GstRc<SampleRef> {
pub fn new(buffer: Option<Buffer>, caps: Option<Caps>, segment: Option<&Segment>, info: Option<&StructureRef>) -> Self {
pub fn new(
buffer: Option<Buffer>,
caps: Option<Caps>,
segment: Option<&Segment>,
info: Option<&StructureRef>,
) -> Self {
assert_initialized_main_thread!();
unsafe {
let info = info.map(|i| i.as_ptr()).unwrap_or(ptr::null());
from_glib_full(ffi::gst_sample_new(buffer.to_glib_none().0, caps.to_glib_none().0, mut_override(segment.to_glib_none().0), mut_override(info)))
from_glib_full(ffi::gst_sample_new(
buffer.to_glib_none().0,
caps.to_glib_none().0,
mut_override(segment.to_glib_none().0),
mut_override(info),
))
}
}
}
impl SampleRef {
pub fn get_buffer(&self) -> Option<Buffer> {
unsafe {
from_glib_none(ffi::gst_sample_get_buffer(self.as_mut_ptr()))
}
unsafe { from_glib_none(ffi::gst_sample_get_buffer(self.as_mut_ptr())) }
}
// TODO: bufferlist
pub fn get_caps(&self) -> Option<Caps> {
unsafe {
from_glib_none(ffi::gst_sample_get_caps(self.as_mut_ptr()))
}
unsafe { from_glib_none(ffi::gst_sample_get_caps(self.as_mut_ptr())) }
}
pub fn get_segment(&self) -> Option<Segment> {
unsafe {
from_glib_none(ffi::gst_sample_get_segment(self.as_mut_ptr()))
}
unsafe { from_glib_none(ffi::gst_sample_get_segment(self.as_mut_ptr())) }
}
pub fn get_structure(&self) -> Option<&StructureRef> {
@ -73,9 +77,7 @@ impl SampleRef {
impl StaticType for SampleRef {
fn static_type() -> glib::Type {
unsafe {
from_glib(ffi::gst_sample_get_type())
}
unsafe { from_glib(ffi::gst_sample_get_type()) }
}
}
@ -89,4 +91,3 @@ impl ToOwned for SampleRef {
unsafe impl Sync for SampleRef {}
unsafe impl Send for SampleRef {}

View file

@ -22,17 +22,26 @@ pub struct Segment(ffi::GstSegment);
impl Segment {
pub fn new() -> Segment {
assert_initialized_main_thread!();
unsafe {
Self::uninitialized()
}
unsafe { Self::uninitialized() }
}
pub fn clip(&self, format: Format, start: u64, stop: u64) -> Option<(u64, u64)> {
unsafe {
let mut clip_start = mem::uninitialized();
let mut clip_stop = mem::uninitialized();
let ret = from_glib(ffi::gst_segment_clip(self.to_glib_none().0, format.to_glib(), start, stop, &mut clip_start, &mut clip_stop));
if ret { Some((clip_start, clip_stop)) } else { None }
let ret = from_glib(ffi::gst_segment_clip(
self.to_glib_none().0,
format.to_glib(),
start,
stop,
&mut clip_start,
&mut clip_stop,
));
if ret {
Some((clip_start, clip_stop))
} else {
None
}
}
}
@ -42,11 +51,34 @@ impl Segment {
}
}
pub fn do_seek(&mut self, rate: f64, format: Format, flags: SeekFlags, start_type: SeekType, start: u64, stop_type: SeekType, stop: u64) -> Option<bool> {
pub fn do_seek(
&mut self,
rate: f64,
format: Format,
flags: SeekFlags,
start_type: SeekType,
start: u64,
stop_type: SeekType,
stop: u64,
) -> Option<bool> {
unsafe {
let mut update = mem::uninitialized();
let ret = from_glib(ffi::gst_segment_do_seek(self.to_glib_none_mut().0, rate, format.to_glib(), flags.to_glib(), start_type.to_glib(), start, stop_type.to_glib(), stop, &mut update));
if ret { Some(from_glib(update)) } else { None }
let ret = from_glib(ffi::gst_segment_do_seek(
self.to_glib_none_mut().0,
rate,
format.to_glib(),
flags.to_glib(),
start_type.to_glib(),
start,
stop_type.to_glib(),
stop,
&mut update,
));
if ret {
Some(from_glib(update))
} else {
None
}
}
}
@ -58,47 +90,76 @@ impl Segment {
fn is_equal(&self, s1: &Segment) -> bool {
unsafe {
from_glib(ffi::gst_segment_is_equal(self.to_glib_none().0, s1.to_glib_none().0))
from_glib(ffi::gst_segment_is_equal(
self.to_glib_none().0,
s1.to_glib_none().0,
))
}
}
pub fn offset_running_time(&mut self, format: Format, offset: i64) -> bool {
unsafe {
from_glib(ffi::gst_segment_offset_running_time(self.to_glib_none_mut().0, format.to_glib(), offset))
from_glib(ffi::gst_segment_offset_running_time(
self.to_glib_none_mut().0,
format.to_glib(),
offset,
))
}
}
pub fn position_from_running_time(&self, format: Format, running_time: u64) -> u64 {
unsafe {
ffi::gst_segment_position_from_running_time(self.to_glib_none().0, format.to_glib(), running_time)
ffi::gst_segment_position_from_running_time(
self.to_glib_none().0,
format.to_glib(),
running_time,
)
}
}
pub fn position_from_running_time_full(&self, format: Format, running_time: u64) -> (i32, u64) {
unsafe {
let mut position = mem::uninitialized();
let ret = ffi::gst_segment_position_from_running_time_full(self.to_glib_none().0, format.to_glib(), running_time, &mut position);
let ret = ffi::gst_segment_position_from_running_time_full(
self.to_glib_none().0,
format.to_glib(),
running_time,
&mut position,
);
(ret, position)
}
}
pub fn position_from_stream_time(&self, format: Format, stream_time: u64) -> u64 {
unsafe {
ffi::gst_segment_position_from_stream_time(self.to_glib_none().0, format.to_glib(), stream_time)
ffi::gst_segment_position_from_stream_time(
self.to_glib_none().0,
format.to_glib(),
stream_time,
)
}
}
pub fn position_from_stream_time_full(&self, format: Format, stream_time: u64) -> (i32, u64) {
unsafe {
let mut position = mem::uninitialized();
let ret = ffi::gst_segment_position_from_stream_time_full(self.to_glib_none().0, format.to_glib(), stream_time, &mut position);
let ret = ffi::gst_segment_position_from_stream_time_full(
self.to_glib_none().0,
format.to_glib(),
stream_time,
&mut position,
);
(ret, position)
}
}
pub fn set_running_time(&mut self, format: Format, running_time: u64) -> bool {
unsafe {
from_glib(ffi::gst_segment_set_running_time(self.to_glib_none_mut().0, format.to_glib(), running_time))
from_glib(ffi::gst_segment_set_running_time(
self.to_glib_none_mut().0,
format.to_glib(),
running_time,
))
}
}
@ -117,7 +178,12 @@ impl Segment {
pub fn to_running_time_full(&self, format: Format, position: u64) -> (i32, u64) {
unsafe {
let mut running_time = mem::uninitialized();
let ret = ffi::gst_segment_to_running_time_full(self.to_glib_none().0, format.to_glib(), position, &mut running_time);
let ret = ffi::gst_segment_to_running_time_full(
self.to_glib_none().0,
format.to_glib(),
position,
&mut running_time,
);
(ret, running_time)
}
}
@ -131,7 +197,12 @@ impl Segment {
pub fn to_stream_time_full(&self, format: Format, position: u64) -> (i32, u64) {
unsafe {
let mut stream_time = mem::uninitialized();
let ret = ffi::gst_segment_to_stream_time_full(self.to_glib_none().0, format.to_glib(), position, &mut stream_time);
let ret = ffi::gst_segment_to_stream_time_full(
self.to_glib_none().0,
format.to_glib(),
position,
&mut stream_time,
);
(ret, stream_time)
}
}
@ -150,9 +221,7 @@ unsafe impl Send for Segment {}
impl Clone for Segment {
fn clone(&self) -> Self {
unsafe {
Segment(ptr::read(&self.0))
}
unsafe { Segment(ptr::read(&self.0)) }
}
}
@ -165,21 +234,30 @@ impl glib::types::StaticType for Segment {
#[doc(hidden)]
impl<'a> glib::value::FromValueOptional<'a> for Segment {
unsafe fn from_value_optional(value: &glib::Value) -> Option<Self> {
Option::<Segment>::from_glib_full(gobject_ffi::g_value_get_boxed(value.to_glib_none().0) as *mut ffi::GstSegment)
Option::<Segment>::from_glib_full(gobject_ffi::g_value_get_boxed(value.to_glib_none().0) as
*mut ffi::GstSegment)
}
}
#[doc(hidden)]
impl glib::value::SetValue for Segment {
unsafe fn set_value(value: &mut glib::Value, this: &Self) {
gobject_ffi::g_value_set_boxed(value.to_glib_none_mut().0, glib::translate::ToGlibPtr::<*const ffi::GstSegment>::to_glib_none(this).0 as glib_ffi::gpointer)
gobject_ffi::g_value_set_boxed(
value.to_glib_none_mut().0,
glib::translate::ToGlibPtr::<*const ffi::GstSegment>::to_glib_none(this).0 as
glib_ffi::gpointer,
)
}
}
#[doc(hidden)]
impl glib::value::SetValueOptional for Segment {
unsafe fn set_value_optional(value: &mut glib::Value, this: Option<&Self>) {
gobject_ffi::g_value_set_boxed(value.to_glib_none_mut().0, glib::translate::ToGlibPtr::<*const ffi::GstSegment>::to_glib_none(&this).0 as glib_ffi::gpointer)
gobject_ffi::g_value_set_boxed(
value.to_glib_none_mut().0,
glib::translate::ToGlibPtr::<*const ffi::GstSegment>::to_glib_none(&this).0 as
glib_ffi::gpointer,
)
}
}

View file

@ -12,15 +12,15 @@ use std::mem;
use std::str;
use std::ffi::CStr;
use std::ops::{Deref, DerefMut};
use std::borrow::{Borrow, ToOwned, BorrowMut};
use std::borrow::{Borrow, BorrowMut, ToOwned};
use std::marker::PhantomData;
use Fraction;
use glib;
use glib::translate::{from_glib, from_glib_full, Stash, StashMut, ToGlib, ToGlibPtr, ToGlibPtrMut,
FromGlibPtrNone, FromGlibPtrFull};
use glib::value::{Value, ToValue, FromValueOptional};
use glib::translate::{from_glib, from_glib_full, FromGlibPtrFull, FromGlibPtrNone, Stash,
StashMut, ToGlib, ToGlibPtr, ToGlibPtrMut};
use glib::value::{FromValueOptional, ToValue, Value};
use ffi;
pub struct Structure(*mut StructureRef, PhantomData<StructureRef>);
@ -587,14 +587,7 @@ mod tests {
assert_eq!(v[2].0, "f3");
assert_eq!(v[2].1.get::<i32>().unwrap(), 123i32);
let s2 = Structure::new(
"test",
&[
("f1", &"abc"),
("f2", &"bcd"),
("f3", &123i32),
],
);
let s2 = Structure::new("test", &[("f1", &"abc"), ("f2", &"bcd"), ("f3", &123i32)]);
assert_eq!(s, s2);
}
}

View file

@ -11,14 +11,13 @@ use TagSetter;
use TagMergeMode;
use glib::object::IsA;
use glib::translate::*;
use glib::value::{ToValue};
use glib::value::ToValue;
use tags::*;
pub trait TagSetterExtManual {
fn add<'a, T: Tag<'a>>(&mut self, value: T::TagType, mode: TagMergeMode)
where
T::TagType: ToValue;
}
impl<O: IsA<TagSetter>> TagSetterExtManual for O {

View file

@ -14,8 +14,8 @@ use std::ffi::CStr;
use ffi;
use glib;
use glib::StaticType;
use glib::value::{Value, TypedValue, FromValueOptional, SetValue, ToValue};
use glib::translate::{from_glib, from_glib_none, from_glib_full, ToGlib, ToGlibPtr, ToGlibPtrMut};
use glib::value::{FromValueOptional, SetValue, ToValue, TypedValue, Value};
use glib::translate::{from_glib, from_glib_full, from_glib_none, ToGlib, ToGlibPtr, ToGlibPtrMut};
use miniobject::*;
@ -105,10 +105,26 @@ impl_tag!(GeoLocationElevation, f64, *TAG_GEO_LOCATION_ELEVATION);
impl_tag!(GeoLocationCity, &'a str, *TAG_GEO_LOCATION_CITY);
impl_tag!(GeoLocationCountry, &'a str, *TAG_GEO_LOCATION_COUNTRY);
impl_tag!(GeoLocationSublocation, &'a str, *TAG_GEO_LOCATION_SUBLOCATION);
impl_tag!(GeoLocationHorizontalError, f64, *TAG_GEO_LOCATION_HORIZONTAL_ERROR);
impl_tag!(GeoLocationMovementDirection, f64, *TAG_GEO_LOCATION_MOVEMENT_DIRECTION);
impl_tag!(GeoLocationMovementSpeed, f64, *TAG_GEO_LOCATION_MOVEMENT_SPEED);
impl_tag!(GeoLocationCaptureDirection, f64, *TAG_GEO_LOCATION_CAPTURE_DIRECTION);
impl_tag!(
GeoLocationHorizontalError,
f64,
*TAG_GEO_LOCATION_HORIZONTAL_ERROR
);
impl_tag!(
GeoLocationMovementDirection,
f64,
*TAG_GEO_LOCATION_MOVEMENT_DIRECTION
);
impl_tag!(
GeoLocationMovementSpeed,
f64,
*TAG_GEO_LOCATION_MOVEMENT_SPEED
);
impl_tag!(
GeoLocationCaptureDirection,
f64,
*TAG_GEO_LOCATION_CAPTURE_DIRECTION
);
impl_tag!(ShowName, &'a str, *TAG_SHOW_NAME);
impl_tag!(ShowSortname, &'a str, *TAG_SHOW_SORTNAME);
impl_tag!(ShowEpisodeNumber, u32, *TAG_SHOW_EPISODE_NUMBER);
@ -317,9 +333,7 @@ impl ToOwned for TagListRef {
impl StaticType for TagListRef {
fn static_type() -> glib::Type {
unsafe {
from_glib(ffi::gst_tag_list_get_type())
}
unsafe { from_glib(ffi::gst_tag_list_get_type()) }
}
}

View file

@ -9,12 +9,13 @@
use num_rational::Rational32;
use std::fmt;
use std::ops;
use std::borrow::{Cow, Borrow};
use std::borrow::{Borrow, Cow};
use std::slice;
use glib;
use glib::value::{Value, FromValue, FromValueOptional, SetValue, ToValue};
use glib::translate::{from_glib, from_glib_full, ToGlibPtr, ToGlibPtrMut, FromGlib, ToGlib, Uninitialized};
use glib::value::{FromValue, FromValueOptional, SetValue, ToValue, Value};
use glib::translate::{from_glib, from_glib_full, FromGlib, ToGlib, ToGlibPtr, ToGlibPtrMut,
Uninitialized};
use ffi;
use glib_ffi;
@ -355,10 +356,7 @@ impl FractionRange {
assert!(min <= max);
FractionRange {
min: min,
max: max,
}
FractionRange { min: min, max: max }
}
pub fn min(&self) -> Fraction {
@ -404,7 +402,13 @@ impl<'a> FromValueOptional<'a> for FractionRange {
impl SetValue for FractionRange {
unsafe fn set_value(v: &mut Value, r: &Self) {
ffi::gst_value_set_fraction_range_full(v.to_glib_none_mut().0, *r.min().numer(), *r.min().denom(), *r.max().numer(), *r.max().denom());
ffi::gst_value_set_fraction_range_full(
v.to_glib_none_mut().0,
*r.min().numer(),
*r.min().denom(),
*r.max().numer(),
*r.max().denom(),
);
}
}
@ -443,7 +447,10 @@ impl<'a> FromValue<'a> for Array<'a> {
if arr.is_null() {
Array(Cow::Borrowed(&[]))
} else {
Array(Cow::Borrowed(slice::from_raw_parts((*arr).data as *const glib::Value, (*arr).len as usize)))
Array(Cow::Borrowed(slice::from_raw_parts(
(*arr).data as *const glib::Value,
(*arr).len as usize,
)))
}
}
}
@ -503,7 +510,10 @@ impl<'a> FromValue<'a> for List<'a> {
if arr.is_null() {
List(Cow::Borrowed(&[]))
} else {
List(Cow::Borrowed(slice::from_raw_parts((*arr).data as *const glib::Value, (*arr).len as usize)))
List(Cow::Borrowed(slice::from_raw_parts(
(*arr).data as *const glib::Value,
(*arr).len as usize,
)))
}
}
}
@ -579,26 +589,39 @@ pub trait GstValueExt: Sized {
impl GstValueExt for glib::Value {
fn can_compare(&self, other: &Self) -> bool {
unsafe {
from_glib(ffi::gst_value_can_compare(self.to_glib_none().0, other.to_glib_none().0))
from_glib(ffi::gst_value_can_compare(
self.to_glib_none().0,
other.to_glib_none().0,
))
}
}
fn compare(&self, other: &Self) -> ValueOrder {
unsafe {
from_glib(ffi::gst_value_compare(self.to_glib_none().0, other.to_glib_none().0))
from_glib(ffi::gst_value_compare(
self.to_glib_none().0,
other.to_glib_none().0,
))
}
}
fn can_intersect(&self, other: &Self) -> bool {
unsafe {
from_glib(ffi::gst_value_can_intersect(self.to_glib_none().0, other.to_glib_none().0))
from_glib(ffi::gst_value_can_intersect(
self.to_glib_none().0,
other.to_glib_none().0,
))
}
}
fn intersect(&self, other: &Self) -> Option<Self> {
unsafe {
let mut value = glib::Value::uninitialized();
let ret: bool = from_glib(ffi::gst_value_intersect(value.to_glib_none_mut().0, self.to_glib_none().0, other.to_glib_none().0));
let ret: bool = from_glib(ffi::gst_value_intersect(
value.to_glib_none_mut().0,
self.to_glib_none().0,
other.to_glib_none().0,
));
if ret {
Some(value)
} else {
@ -609,14 +632,21 @@ impl GstValueExt for glib::Value {
fn can_subtract(&self, other: &Self) -> bool {
unsafe {
from_glib(ffi::gst_value_can_subtract(self.to_glib_none().0, other.to_glib_none().0))
from_glib(ffi::gst_value_can_subtract(
self.to_glib_none().0,
other.to_glib_none().0,
))
}
}
fn subtract(&self, other: &Self) -> Option<Self> {
unsafe {
let mut value = glib::Value::uninitialized();
let ret: bool = from_glib(ffi::gst_value_subtract(value.to_glib_none_mut().0, self.to_glib_none().0, other.to_glib_none().0));
let ret: bool = from_glib(ffi::gst_value_subtract(
value.to_glib_none_mut().0,
self.to_glib_none().0,
other.to_glib_none().0,
));
if ret {
Some(value)
} else {
@ -627,14 +657,21 @@ impl GstValueExt for glib::Value {
fn can_union(&self, other: &Self) -> bool {
unsafe {
from_glib(ffi::gst_value_can_union(self.to_glib_none().0, other.to_glib_none().0))
from_glib(ffi::gst_value_can_union(
self.to_glib_none().0,
other.to_glib_none().0,
))
}
}
fn union(&self, other: &Self) -> Option<Self> {
unsafe {
let mut value = glib::Value::uninitialized();
let ret: bool = from_glib(ffi::gst_value_union(value.to_glib_none_mut().0, self.to_glib_none().0, other.to_glib_none().0));
let ret: bool = from_glib(ffi::gst_value_union(
value.to_glib_none_mut().0,
self.to_glib_none().0,
other.to_glib_none().0,
));
if ret {
Some(value)
} else {
@ -646,7 +683,10 @@ impl GstValueExt for glib::Value {
fn fixate(&self) -> Option<Self> {
unsafe {
let mut value = glib::Value::uninitialized();
let ret: bool = from_glib(ffi::gst_value_fixate(value.to_glib_none_mut().0, self.to_glib_none().0));
let ret: bool = from_glib(ffi::gst_value_fixate(
value.to_glib_none_mut().0,
self.to_glib_none().0,
));
if ret {
Some(value)
} else {
@ -656,21 +696,20 @@ impl GstValueExt for glib::Value {
}
fn is_fixed(&self) -> bool {
unsafe {
from_glib(ffi::gst_value_is_fixed(self.to_glib_none().0))
}
unsafe { from_glib(ffi::gst_value_is_fixed(self.to_glib_none().0)) }
}
fn is_subset(&self, superset: &Self) -> bool {
unsafe {
from_glib(ffi::gst_value_is_subset(self.to_glib_none().0, superset.to_glib_none().0))
from_glib(ffi::gst_value_is_subset(
self.to_glib_none().0,
superset.to_glib_none().0,
))
}
}
fn serialize(&self) -> Option<String> {
unsafe {
from_glib_full(ffi::gst_value_serialize(self.to_glib_none().0))
}
unsafe { from_glib_full(ffi::gst_value_serialize(self.to_glib_none().0)) }
}
fn deserialize<'a, T: Into<&'a str>>(s: T) -> Option<glib::Value> {
@ -678,7 +717,10 @@ impl GstValueExt for glib::Value {
unsafe {
let mut value = glib::Value::uninitialized();
let ret: bool = from_glib(ffi::gst_value_deserialize(value.to_glib_none_mut().0, s.to_glib_none().0));
let ret: bool = from_glib(ffi::gst_value_deserialize(
value.to_glib_none_mut().0,
s.to_glib_none().0,
));
if ret {
Some(value)
} else {