Commit 33a6aab6 authored by Sebastian Dröge's avatar Sebastian Dröge 🍵

Run everything through latest rustfmt

parent 8f9c0a72
......@@ -27,7 +27,12 @@ mod examples_common;
struct MissingElement(&'static str);
#[derive(Debug, Fail)]
#[fail(display = "Received error from {}: {} (debug: {:?})", src, error, debug)]
#[fail(
display = "Received error from {}: {} (debug: {:?})",
src,
error,
debug
)]
struct ErrorMessage {
src: String,
error: String,
......@@ -138,7 +143,8 @@ fn main_loop(pipeline: gst::Pipeline) -> Result<(), Error> {
MessageView::Error(err) => {
pipeline.set_state(gst::State::Null).into_result()?;
Err(ErrorMessage {
src: err.get_src()
src: err
.get_src()
.map(|s| s.get_path_string())
.unwrap_or_else(|| String::from("None")),
error: err.get_error().description().into(),
......
......@@ -21,7 +21,12 @@ mod examples_common;
struct MissingElement(&'static str);
#[derive(Debug, Fail)]
#[fail(display = "Received error from {}: {} (debug: {:?})", src, error, debug)]
#[fail(
display = "Received error from {}: {} (debug: {:?})",
src,
error,
debug
)]
struct ErrorMessage {
src: String,
error: String,
......@@ -122,7 +127,8 @@ fn main_loop(pipeline: gst::Pipeline) -> Result<(), Error> {
MessageView::Error(err) => {
pipeline.set_state(gst::State::Null).into_result()?;
Err(ErrorMessage {
src: err.get_src()
src: err
.get_src()
.map(|s| s.get_path_string())
.unwrap_or_else(|| String::from("None")),
error: err.get_error().description().into(),
......
......@@ -23,7 +23,12 @@ mod examples_common;
struct MissingElement(&'static str);
#[derive(Debug, Fail)]
#[fail(display = "Received error from {}: {} (debug: {:?})", src, error, debug)]
#[fail(
display = "Received error from {}: {} (debug: {:?})",
src,
error,
debug
)]
struct ErrorMessage {
src: String,
error: String,
......@@ -177,7 +182,8 @@ fn example_main() -> Result<(), Error> {
.map(Result::Err)
.expect("error-details message without actual error"),
_ => Err(ErrorMessage {
src: err.get_src()
src: err
.get_src()
.map(|s| s.get_path_string())
.unwrap_or_else(|| String::from("None")),
error: err.get_error().description().into(),
......@@ -189,7 +195,8 @@ fn example_main() -> Result<(), Error> {
#[cfg(not(feature = "v1_10"))]
{
Err(ErrorMessage {
src: err.get_src()
src: err
.get_src()
.map(|s| s.get_path_string())
.unwrap_or_else(|| String::from("None")),
error: err.get_error().description().into(),
......
......@@ -51,13 +51,17 @@ fn print_stream_info(stream: &DiscovererStreamInfo) {
}
fn print_discoverer_info(info: &DiscovererInfo) -> Result<(), Error> {
let uri = info.get_uri()
let uri = info
.get_uri()
.ok_or(DiscovererError("URI should not be null"))?;
println!("URI: {}", uri);
println!("Duration: {}", info.get_duration());
print_tags(info);
print_stream_info(&info.get_stream_info()
.ok_or(DiscovererError("Error while obtaining stream info"))?);
print_stream_info(
&info
.get_stream_info()
.ok_or(DiscovererError("Error while obtaining stream info"))?,
);
let children = info.get_stream_list();
println!("Children streams:");
......
......@@ -9,8 +9,8 @@ use gio::prelude::*;
extern crate gtk;
use gtk::prelude::*;
use std::env;
use std::cell::RefCell;
use std::env;
fn create_ui(app: &gtk::Application) {
let pipeline = gst::Pipeline::new(None);
......
......@@ -46,7 +46,8 @@ fn create_ui(app: &gtk::Application) {
let video_window = gtk::DrawingArea::new();
video_window.set_size_request(320, 240);
let video_overlay = sink.clone()
let video_overlay = sink
.clone()
.dynamic_cast::<gst_video::VideoOverlay>()
.unwrap()
.downgrade();
......
......@@ -17,13 +17,9 @@ fn example_main() {
"audiotestsrc name=src ! audio/x-raw,format={},channels=1 ! fakesink",
gst_audio::AUDIO_FORMAT_S16.to_string()
)).unwrap();
let pipeline = pipeline
.dynamic_cast::<gst::Pipeline>()
.unwrap();
let pipeline = pipeline.dynamic_cast::<gst::Pipeline>().unwrap();
let src = pipeline
.get_by_name("src")
.unwrap();
let src = pipeline.get_by_name("src").unwrap();
let src_pad = src.get_static_pad("src").unwrap();
src_pad.add_probe(gst::PadProbeType::BUFFER, |_, probe_info| {
if let Some(gst::PadProbeData::Buffer(ref buffer)) = probe_info.data {
......
......@@ -33,7 +33,12 @@ struct UnknownPT(u32);
struct UsageError(String);
#[derive(Debug, Fail)]
#[fail(display = "Received error from {}: {} (debug: {:?})", src, error, debug)]
#[fail(
display = "Received error from {}: {} (debug: {:?})",
src,
error,
debug
)]
struct ErrorMessage {
src: String,
error: String,
......@@ -254,7 +259,8 @@ fn example_main() -> Result<(), Error> {
assert_ne!(ret, gst::StateChangeReturn::Failure);
return Err(ErrorMessage {
src: msg.get_src()
src: msg
.get_src()
.map(|s| s.get_path_string())
.unwrap_or_else(|| String::from("None")),
error: err.get_error().description().into(),
......
......@@ -30,7 +30,12 @@ struct NoSuchPad(&'static str, String);
struct UsageError(String);
#[derive(Debug, Fail)]
#[fail(display = "Received error from {}: {} (debug: {:?})", src, error, debug)]
#[fail(
display = "Received error from {}: {} (debug: {:?})",
src,
error,
debug
)]
struct ErrorMessage {
src: String,
error: String,
......@@ -187,7 +192,8 @@ fn example_main() -> Result<(), Error> {
assert_ne!(ret, gst::StateChangeReturn::Failure);
return Err(ErrorMessage {
src: msg.get_src()
src: msg
.get_src()
.map(|s| s.get_path_string())
.unwrap_or_else(|| String::from("None")),
error: err.get_error().description().into(),
......
......@@ -19,7 +19,12 @@ mod examples_common;
struct MissingElement(String);
#[derive(Debug, Fail)]
#[fail(display = "Received error from {}: {} (debug: {:?})", src, error, debug)]
#[fail(
display = "Received error from {}: {} (debug: {:?})",
src,
error,
debug
)]
struct ErrorMessage {
src: String,
error: String,
......@@ -72,7 +77,8 @@ fn example_main() -> Result<(), Error> {
MessageView::Eos(..) => break,
MessageView::Error(err) => {
Err(ErrorMessage {
src: err.get_src()
src: err
.get_src()
.map(|s| s.get_path_string())
.unwrap_or_else(|| String::from("None")),
error: err.get_error().description().into(),
......
......@@ -11,8 +11,9 @@ use glib_ffi;
use gobject_ffi;
use glib;
use glib::translate::{from_glib, from_glib_full, from_glib_none, FromGlibPtrNone, ToGlib,
ToGlibPtr, ToGlibPtrMut};
use glib::translate::{
from_glib, from_glib_full, from_glib_none, FromGlibPtrNone, ToGlib, ToGlibPtr, ToGlibPtrMut,
};
use gst;
use gst::prelude::*;
......@@ -312,7 +313,9 @@ impl glib::types::StaticType for AudioInfo {
#[doc(hidden)]
impl<'a> glib::value::FromValueOptional<'a> for AudioInfo {
unsafe fn from_value_optional(value: &glib::Value) -> Option<Self> {
Option::<AudioInfo>::from_glib_none(gobject_ffi::g_value_get_boxed(value.to_glib_none().0) as *mut ffi::GstAudioInfo)
Option::<AudioInfo>::from_glib_none(
gobject_ffi::g_value_get_boxed(value.to_glib_none().0) as *mut ffi::GstAudioInfo
)
}
}
......
......@@ -29,7 +29,10 @@ pub fn type_find_helper_for_data<
let data = data.as_ref();
let (ptr, len) = (data.as_ptr(), data.len());
let ret = from_glib_full(ffi::gst_type_find_helper_for_data(
obj.0, mut_override(ptr), len, &mut prob,
obj.0,
mut_override(ptr),
len,
&mut prob,
));
(ret, from_glib(prob))
}
......
......@@ -9,12 +9,16 @@
use ffi;
use NetTimeProvider;
use glib::IsA;
use glib::translate::*;
use glib::IsA;
use gst;
impl NetTimeProvider {
pub fn new<'a, P: IsA<gst::Clock>, Q: Into<Option<&'a str>>>(clock: &P, address: Q, port: i32) -> NetTimeProvider {
pub fn new<'a, P: IsA<gst::Clock>, Q: Into<Option<&'a str>>>(
clock: &P,
address: Q,
port: i32,
) -> NetTimeProvider {
assert_initialized_main_thread!();
let address = address.into();
let address = address.to_glib_none();
......@@ -22,12 +26,20 @@ impl NetTimeProvider {
let (major, minor, _, _) = gst::version();
if (major, minor) > (1, 12) {
unsafe {
from_glib_full(ffi::gst_net_time_provider_new(clock.to_glib_none().0, address.0, port))
from_glib_full(ffi::gst_net_time_provider_new(
clock.to_glib_none().0,
address.0,
port,
))
}
} else {
// Workaround for bad floating reference handling in 1.12. This issue was fixed for 1.13
unsafe {
from_glib_none(ffi::gst_net_time_provider_new(clock.to_glib_none().0, address.0, port))
from_glib_none(ffi::gst_net_time_provider_new(
clock.to_glib_none().0,
address.0,
port,
))
}
}
}
......
......@@ -13,11 +13,7 @@ pub struct MIKEYMapSRTP(ffi::GstMIKEYMapSRTP);
impl MIKEYMapSRTP {
pub fn new(policy: u8, ssrc: u32, roc: u32) -> MIKEYMapSRTP {
MIKEYMapSRTP(ffi::GstMIKEYMapSRTP {
policy,
ssrc,
roc,
})
MIKEYMapSRTP(ffi::GstMIKEYMapSRTP { policy, ssrc, roc })
}
pub fn policy(&self) -> u8 {
......
......@@ -104,10 +104,7 @@ impl<'a> DownstreamForceKeyUnitEventBuilder<'a> {
}
pub fn timestamp(self, timestamp: gst::ClockTime) -> Self {
Self {
timestamp,
..self
}
Self { timestamp, ..self }
}
pub fn stream_time(self, stream_time: gst::ClockTime) -> Self {
......@@ -132,10 +129,7 @@ impl<'a> DownstreamForceKeyUnitEventBuilder<'a> {
}
pub fn count(self, count: u32) -> Self {
Self {
count,
..self
}
Self { count, ..self }
}
event_builder_generic_impl!(
......@@ -231,10 +225,7 @@ impl<'a> UpstreamForceKeyUnitEventBuilder<'a> {
}
pub fn count(self, count: u32) -> Self {
Self {
count,
..self
}
Self { count, ..self }
}
event_builder_generic_impl!(
......
......@@ -238,7 +238,8 @@ impl VideoFrame<Writable> {
&mut frame,
info.to_glib_none().0 as *mut _,
buffer.to_glib_none().0,
ffi::GST_VIDEO_FRAME_MAP_FLAG_NO_REF | gst_ffi::GST_MAP_READ
ffi::GST_VIDEO_FRAME_MAP_FLAG_NO_REF
| gst_ffi::GST_MAP_READ
| gst_ffi::GST_MAP_WRITE,
));
......@@ -265,7 +266,8 @@ impl VideoFrame<Writable> {
info.to_glib_none().0 as *mut _,
buffer.to_glib_none().0,
id,
ffi::GST_VIDEO_FRAME_MAP_FLAG_NO_REF | gst_ffi::GST_MAP_READ
ffi::GST_VIDEO_FRAME_MAP_FLAG_NO_REF
| gst_ffi::GST_MAP_READ
| gst_ffi::GST_MAP_WRITE,
));
......@@ -512,7 +514,8 @@ impl<'a> VideoFrameRef<&'a mut gst::BufferRef> {
&mut frame,
info.to_glib_none().0 as *mut _,
buffer.as_mut_ptr(),
ffi::GST_VIDEO_FRAME_MAP_FLAG_NO_REF | gst_ffi::GST_MAP_READ
ffi::GST_VIDEO_FRAME_MAP_FLAG_NO_REF
| gst_ffi::GST_MAP_READ
| gst_ffi::GST_MAP_WRITE,
));
......@@ -539,7 +542,8 @@ impl<'a> VideoFrameRef<&'a mut gst::BufferRef> {
info.to_glib_none().0 as *mut _,
buffer.as_mut_ptr(),
id,
ffi::GST_VIDEO_FRAME_MAP_FLAG_NO_REF | gst_ffi::GST_MAP_READ
ffi::GST_VIDEO_FRAME_MAP_FLAG_NO_REF
| gst_ffi::GST_MAP_READ
| gst_ffi::GST_MAP_WRITE,
));
......@@ -591,7 +595,10 @@ impl<'a> ops::Deref for VideoFrameRef<&'a mut gst::BufferRef> {
type Target = VideoFrameRef<&'a gst::BufferRef>;
fn deref(&self) -> &Self::Target {
unsafe { &*(self as *const VideoFrameRef<&'a mut gst::BufferRef> as *const VideoFrameRef<&'a gst::BufferRef>) }
unsafe {
&*(self as *const VideoFrameRef<&'a mut gst::BufferRef>
as *const VideoFrameRef<&'a gst::BufferRef>)
}
}
}
......
......@@ -11,8 +11,10 @@ use glib_ffi;
use gobject_ffi;
use glib;
use glib::translate::{from_glib, from_glib_full, from_glib_none, FromGlib, FromGlibPtrNone,
ToGlib, ToGlibPtr, ToGlibPtrMut};
use glib::translate::{
from_glib, from_glib_full, from_glib_none, FromGlib, FromGlibPtrNone, ToGlib, ToGlibPtr,
ToGlibPtrMut,
};
use gst;
use gst::prelude::*;
......@@ -666,7 +668,9 @@ impl glib::types::StaticType for VideoInfo {
#[doc(hidden)]
impl<'a> glib::value::FromValueOptional<'a> for VideoInfo {
unsafe fn from_value_optional(value: &glib::Value) -> Option<Self> {
Option::<VideoInfo>::from_glib_none(gobject_ffi::g_value_get_boxed(value.to_glib_none().0) as *mut ffi::GstVideoInfo)
Option::<VideoInfo>::from_glib_none(
gobject_ffi::g_value_get_boxed(value.to_glib_none().0) as *mut ffi::GstVideoInfo
)
}
}
......
......@@ -113,7 +113,8 @@ mod tests {
bin.add(&::ElementFactory::make("identity", "identity1").unwrap())
.unwrap();
let mut child_names = bin.get_children()
let mut child_names = bin
.get_children()
.iter()
.map(|c| c.get_name())
.collect::<Vec<String>>();
......
......@@ -389,7 +389,7 @@ impl ToOwned for BufferRef {
impl fmt::Debug for BufferRef {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_struct("Buffer")
.field("ptr", unsafe { &self.as_ptr() } )
.field("ptr", unsafe { &self.as_ptr() })
.field("pts", &self.get_pts().to_string())
.field("dts", &self.get_dts().to_string())
.field("duration", &self.get_duration().to_string())
......
......@@ -198,7 +198,8 @@ impl BufferPoolAcquireParams {
impl PartialEq for BufferPoolAcquireParams {
fn eq(&self, other: &Self) -> bool {
self.format() == other.format() && self.start() == other.start()
self.format() == other.format()
&& self.start() == other.start()
&& self.stop() == other.stop()
}
}
......@@ -210,14 +211,10 @@ impl BufferPool {
assert_initialized_main_thread!();
let (major, minor, _, _) = ::version();
if (major, minor) > (1, 12) {
unsafe {
from_glib_full(ffi::gst_buffer_pool_new())
}
unsafe { from_glib_full(ffi::gst_buffer_pool_new()) }
} else {
// Work-around for 1.14 switching from transfer-floating to transfer-full
unsafe {
from_glib_none(ffi::gst_buffer_pool_new())
}
unsafe { from_glib_none(ffi::gst_buffer_pool_new()) }
}
}
}
......
......@@ -106,19 +106,22 @@ impl ToOwned for BufferListRef {
fn to_owned(&self) -> GstRc<BufferListRef> {
#[cfg_attr(feature = "cargo-clippy", allow(cast_ptr_alignment))]
unsafe { from_glib_full(ffi::gst_mini_object_copy(self.as_ptr() as *const _) as *mut _) }
unsafe {
from_glib_full(ffi::gst_mini_object_copy(self.as_ptr() as *const _) as *mut _)
}
}
}
impl fmt::Debug for BufferListRef {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let size = self.iter().map(|b| b.get_size()).sum::<usize>();
let (pts, dts) = self.get(0)
let (pts, dts) = self
.get(0)
.map(|b| (b.get_pts(), b.get_dts()))
.unwrap_or((::ClockTime::none(), ::ClockTime::none()));
f.debug_struct("BufferList")
.field("ptr", unsafe { &self.as_ptr() } )
.field("ptr", unsafe { &self.as_ptr() })
.field("buffers", &self.len())
.field("pts", &pts.to_string())
.field("dts", &dts.to_string())
......
......@@ -252,7 +252,12 @@ impl CapsRef {
pub fn subtract(&self, other: &Self) -> Caps {
skip_assert_initialized!();
unsafe { from_glib_full(ffi::gst_caps_subtract(self.as_mut_ptr(), other.as_mut_ptr())) }
unsafe {
from_glib_full(ffi::gst_caps_subtract(
self.as_mut_ptr(),
other.as_mut_ptr(),
))
}
}
}
......
......@@ -91,7 +91,9 @@ impl ToOwned for ContextRef {
fn to_owned(&self) -> GstRc<ContextRef> {
#[cfg_attr(feature = "cargo-clippy", allow(cast_ptr_alignment))]
unsafe { from_glib_full(ffi::gst_mini_object_copy(self.as_ptr() as *const _) as *mut _) }
unsafe {
from_glib_full(ffi::gst_mini_object_copy(self.as_ptr() as *const _) as *mut _)
}
}
}
......
......@@ -6,23 +6,19 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use DeviceMonitor;
use ffi;
use glib::translate::*;
use DeviceMonitor;
impl DeviceMonitor {
pub fn new() -> DeviceMonitor {
assert_initialized_main_thread!();
let (major, minor, _, _) = ::version();
if (major, minor) > (1, 12) {
unsafe {
from_glib_full(ffi::gst_device_monitor_new())
}
unsafe { from_glib_full(ffi::gst_device_monitor_new()) }
} else {
// Work-around for 1.14 switching from transfer-floating to transfer-full
unsafe {
from_glib_none(ffi::gst_device_monitor_new())
}
unsafe { from_glib_none(ffi::gst_device_monitor_new()) }
}
}
}
......
......@@ -13,8 +13,9 @@ use glib;
use glib::object::Downcast;
#[cfg(any(feature = "v1_10", feature = "dox"))]
use glib::translate::FromGlibPtrBorrow;
use glib::translate::{from_glib, from_glib_full, from_glib_none, FromGlib, FromGlibPtrContainer,
ToGlib, ToGlibPtr};
use glib::translate::{
from_glib, from_glib_full, from_glib_none, FromGlib, FromGlibPtrContainer, ToGlib, ToGlibPtr,
};
use glib::IsA;
use miniobject::MiniObject;
use Event;
......
......@@ -440,7 +440,7 @@ impl glib::types::StaticType for EventRef {
impl fmt::Debug for EventRef {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_struct("Event")
.field("ptr", unsafe { &self.as_ptr() } )
.field("ptr", unsafe { &self.as_ptr() })
.field("type", &unsafe {
let type_ = ffi::gst_event_type_get_name((*self.as_ptr()).type_);
CStr::from_ptr(type_).to_str().unwrap()
......@@ -902,7 +902,8 @@ impl<'a> EventBuilder<'a> {
fn other_fields(self, other_fields: &[(&'a str, &'a ToSendValue)]) -> Self {
Self {
other_fields: self.other_fields
other_fields: self
.other_fields
.iter()
.cloned()
.chain(other_fields.iter().cloned())
......
......@@ -317,10 +317,7 @@ where
for<'a> T: StaticType + ToValue + FromValueOptional<'a> + Clone + Send + 'static,
{
fn new(items: Vec<T>) -> Self {
Self {
pos: 0,
items,
}
Self { pos: 0, items }
}
}
......
......@@ -74,7 +74,9 @@ pub use caps::{Caps, CapsRef};
pub mod tags;
pub use tags::{Tag, TagList, TagListRef};
pub mod buffer;
pub use buffer::{Buffer, BufferMap, BufferRef, MappedBuffer, BUFFER_COPY_ALL, BUFFER_COPY_METADATA};
pub use buffer::{
Buffer, BufferMap, BufferRef, MappedBuffer, BUFFER_COPY_ALL, BUFFER_COPY_METADATA,
};
pub mod sample;
pub use sample::{Sample, SampleRef};
pub mod bufferlist;
......@@ -129,8 +131,10 @@ mod proxy_pad;
mod tag_setter;
pub use bin::BinExtManual;
pub use element::{ElementExtManual, ElementMessageType, NotifyWatchId};
pub use element::{ELEMENT_METADATA_AUTHOR, ELEMENT_METADATA_DESCRIPTION, ELEMENT_METADATA_DOC_URI,
ELEMENT_METADATA_ICON_NAME, ELEMENT_METADATA_KLASS, ELEMENT_METADATA_LONGNAME};
pub use element::{
ELEMENT_METADATA_AUTHOR, ELEMENT_METADATA_DESCRIPTION, ELEMENT_METADATA_DOC_URI,
ELEMENT_METADATA_ICON_NAME, ELEMENT_METADATA_KLASS, ELEMENT_METADATA_LONGNAME,
};
pub use object::GstObjectExtManual;
// OS dependent Bus extensions (also import the other plateform trait for doc)
......@@ -153,8 +157,10 @@ pub use bus::BusStream;
pub use child_proxy::ChildProxyExtManual;
pub use clock_time::ClockTime;
pub use device_provider::DeviceProviderExtManual;
pub use enums::{ClockError, ClockSuccess, FlowError, FlowSuccess, PadLinkError, PadLinkSuccess,
StateChangeError, StateChangeSuccess, TagError};
pub use enums::{
ClockError, ClockSuccess, FlowError, FlowSuccess, PadLinkError, PadLinkSuccess,
StateChangeError, StateChangeSuccess, TagError,
};
pub use gobject::GObjectExtManualGst;
pub use pad::{PadExtManual, PadProbeData, PadProbeId, PadProbeInfo};
pub use parse_context::ParseContext;
......@@ -162,9 +168,9 @@ pub use tag_setter::TagSetterExtManual;
mod plugin;
#[cfg(any(feature = "v1_10", feature = "dox"))]
pub mod stream_collection;
#[cfg(any(feature = "v1_10", feature = "dox"))]
mod stream;
#[cfg(any(feature = "v1_10", feature = "dox"))]
pub mod stream_collection;
mod typefind;
pub use typefind::*;
......
......@@ -17,7 +17,6 @@ use gobject_ffi;
use glib::translate::{from_glib, ToGlib, ToGlibPtr};
use glib::IsA;
#[derive(PartialEq, Eq, Clone, Copy)]
pub struct DebugCategory(ptr::NonNull<ffi::GstDebugCategory>);
......@@ -78,11 +77,7 @@ impl DebugCategory {
}
pub fn get_color(&self) -> ::DebugColorFlags {
unsafe {
from_glib(
ffi::gst_debug_category_get_color(self.0.as_ptr()),
)
}
unsafe { from_glib(ffi::gst_debug_category_get_color(self.0.as_ptr())) }
}
pub fn get_name(&self) -> &str {
......
......@@ -357,7 +357,7 @@ impl glib::types::StaticType for MessageRef {
impl fmt::Debug for MessageRef {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_struct("Message")
.field("ptr", unsafe { &self.as_ptr() } )
.field("ptr", unsafe { &self.as_ptr() })