Commit 243f4420 authored by Sebastian Dröge's avatar Sebastian Dröge 🍵

Run everything through rustfmt

parent 27cbaee3
......@@ -163,7 +163,8 @@ impl AudioEcho {
) {
let delay_frames = (settings.delay as usize)
* (state.info.channels() as usize)
* (state.info.rate() as usize) / (gst::SECOND_VAL as usize);
* (state.info.rate() as usize)
/ (gst::SECOND_VAL as usize);
for (i, (o, e)) in data.iter_mut().zip(state.buffer.iter(delay_frames)) {
let inp = (*i).to_f64().unwrap();
......
......@@ -619,7 +619,8 @@ impl FlvDemux {
}
}
if !streaming_state.got_all_streams && streaming_state.audio != None
if !streaming_state.got_all_streams
&& streaming_state.audio != None
&& (streaming_state.expect_video && streaming_state.video != None
|| !streaming_state.expect_video)
{
......@@ -795,7 +796,8 @@ impl FlvDemux {
}
}
if !streaming_state.got_all_streams && streaming_state.video != None
if !streaming_state.got_all_streams
&& streaming_state.video != None
&& (streaming_state.expect_audio && streaming_state.audio != None
|| !streaming_state.expect_audio)
{
......
......@@ -231,12 +231,16 @@ impl Demuxer {
let event = gst::Event::new_eos().build();
match index {
Some(index) => if let Some(pad) = srcpads.get(&index) {
pad.push_event(event);
},
None => for (_, pad) in srcpads.iter().by_ref() {
pad.push_event(event.clone());
},
Some(index) => {
if let Some(pad) = srcpads.get(&index) {
pad.push_event(event);
}
}
None => {
for (_, pad) in srcpads.iter().by_ref() {
pad.push_event(event.clone());
}
}
};
}
......@@ -416,9 +420,11 @@ impl Demuxer {
HandleBufferResult::StreamChanged(stream) => {
demuxer.stream_format_changed(element, stream.index, stream.caps);
}
HandleBufferResult::StreamsChanged(streams) => for stream in streams {
demuxer.stream_format_changed(element, stream.index, stream.caps);
},
HandleBufferResult::StreamsChanged(streams) => {
for stream in streams {
demuxer.stream_format_changed(element, stream.index, stream.caps);
}
}
HandleBufferResult::BufferForStream(index, buffer) => {
let flow_ret = demuxer.stream_push_buffer(element, index, buffer);
......
......@@ -124,7 +124,8 @@ impl Sink {
Err(err) => Err(UriError::new(
gst::URIError::BadUri,
format!("Failed to parse URI '{}': {}", uri_str, err),
).into()),
)
.into()),
}
} else {
Ok(())
......
......@@ -143,7 +143,8 @@ impl Source {
Err(err) => Err(UriError::new(
gst::URIError::BadUri,
format!("Failed to parse URI '{}': {}", uri_str, err),
).into()),
)
.into()),
}
} else {
Ok(())
......
......@@ -139,7 +139,8 @@ fn create_pipeline() -> (
&video_queue1,
&video_convert1,
&video_sink,
]).unwrap();
])
.unwrap();
gst::Element::link_many(&[
&video_tee,
......@@ -147,7 +148,8 @@ fn create_pipeline() -> (
&video_convert2,
&video_enc,
&video_parse,
]).unwrap();
])
.unwrap();
video_parse.link_pads("src", &togglerecord, "sink").unwrap();
togglerecord.link_pads("src", &mux_queue1, "sink").unwrap();
......@@ -159,7 +161,8 @@ fn create_pipeline() -> (
&audio_queue1,
&audio_convert1,
&audio_sink,
]).unwrap();
])
.unwrap();
gst::Element::link_many(&[
&audio_tee,
......@@ -167,7 +170,8 @@ fn create_pipeline() -> (
&audio_convert2,
&audio_enc,
&audio_parse,
]).unwrap();
])
.unwrap();
audio_parse
.link_pads("src", &togglerecord, "sink_0")
......
......@@ -585,7 +585,8 @@ impl ToggleRecord {
while (main_state.current_running_time == gst::CLOCK_TIME_NONE
|| main_state.current_running_time < current_running_time)
&& !main_state.eos && !stream.state.lock().unwrap().flushing
&& !main_state.eos
&& !stream.state.lock().unwrap().flushing
{
gst_log!(
self.cat,
......@@ -1138,36 +1139,40 @@ impl ToggleRecord {
return true;
}
// Position and duration is always the current recording position
QueryView::Position(ref mut q) => if q.get_format() == gst::Format::Time {
let state = stream.state.lock().unwrap();
let rec_state = self.state.lock().unwrap();
let mut recording_duration = rec_state.recording_duration;
if rec_state.recording_state == RecordingState::Recording
|| rec_state.recording_state == RecordingState::Stopping
{
recording_duration +=
state.current_running_time - rec_state.last_recording_start;
QueryView::Position(ref mut q) => {
if q.get_format() == gst::Format::Time {
let state = stream.state.lock().unwrap();
let rec_state = self.state.lock().unwrap();
let mut recording_duration = rec_state.recording_duration;
if rec_state.recording_state == RecordingState::Recording
|| rec_state.recording_state == RecordingState::Stopping
{
recording_duration +=
state.current_running_time - rec_state.last_recording_start;
}
q.set(recording_duration);
return true;
} else {
return false;
}
q.set(recording_duration);
return true;
} else {
return false;
},
QueryView::Duration(ref mut q) => if q.get_format() == gst::Format::Time {
let state = stream.state.lock().unwrap();
let rec_state = self.state.lock().unwrap();
let mut recording_duration = rec_state.recording_duration;
if rec_state.recording_state == RecordingState::Recording
|| rec_state.recording_state == RecordingState::Stopping
{
recording_duration +=
state.current_running_time - rec_state.last_recording_start;
}
QueryView::Duration(ref mut q) => {
if q.get_format() == gst::Format::Time {
let state = stream.state.lock().unwrap();
let rec_state = self.state.lock().unwrap();
let mut recording_duration = rec_state.recording_duration;
if rec_state.recording_state == RecordingState::Recording
|| rec_state.recording_state == RecordingState::Stopping
{
recording_duration +=
state.current_running_time - rec_state.last_recording_start;
}
q.set(recording_duration);
return true;
} else {
return false;
}
q.set(recording_duration);
return true;
} else {
return false;
},
}
_ => (),
};
......
......@@ -148,37 +148,43 @@ fn setup_sender_receiver(
SendData::Eos => {
break;
}
SendData::Buffers(n) => for _ in 0..n {
let mut buffer = gst::Buffer::new();
buffer
.get_mut()
.unwrap()
.set_pts(offset + i * 20 * gst::MSECOND);
buffer.get_mut().unwrap().set_duration(20 * gst::MSECOND);
let _ = sinkpad.chain(buffer);
i += 1;
},
SendData::BuffersDelta(n) => for _ in 0..n {
let mut buffer = gst::Buffer::new();
buffer
.get_mut()
.unwrap()
.set_pts(offset + i * 20 * gst::MSECOND);
buffer.get_mut().unwrap().set_duration(20 * gst::MSECOND);
buffer
.get_mut()
.unwrap()
.set_flags(gst::BufferFlags::DELTA_UNIT);
let _ = sinkpad.chain(buffer);
i += 1;
},
SendData::Gaps(n) => for _ in 0..n {
let event =
gst::Event::new_gap(offset + i * 20 * gst::MSECOND, 20 * gst::MSECOND)
.build();
let _ = sinkpad.send_event(event);
i += 1;
},
SendData::Buffers(n) => {
for _ in 0..n {
let mut buffer = gst::Buffer::new();
buffer
.get_mut()
.unwrap()
.set_pts(offset + i * 20 * gst::MSECOND);
buffer.get_mut().unwrap().set_duration(20 * gst::MSECOND);
let _ = sinkpad.chain(buffer);
i += 1;
}
}
SendData::BuffersDelta(n) => {
for _ in 0..n {
let mut buffer = gst::Buffer::new();
buffer
.get_mut()
.unwrap()
.set_pts(offset + i * 20 * gst::MSECOND);
buffer.get_mut().unwrap().set_duration(20 * gst::MSECOND);
buffer
.get_mut()
.unwrap()
.set_flags(gst::BufferFlags::DELTA_UNIT);
let _ = sinkpad.chain(buffer);
i += 1;
}
}
SendData::Gaps(n) => {
for _ in 0..n {
let event =
gst::Event::new_gap(offset + i * 20 * gst::MSECOND, 20 * gst::MSECOND)
.build();
let _ = sinkpad.send_event(event);
i += 1;
}
}
}
let _ = sender_input_done.send(());
......
......@@ -540,7 +540,8 @@ where
panic_to_error!(&wrap, &aggregator.panicked(), gst::FlowReturn::Error, {
imp.flush(&wrap)
}).to_glib()
})
.to_glib()
}
unsafe extern "C" fn aggregator_clip<T: AggregatorBase>(
......@@ -583,7 +584,8 @@ where
panic_to_error!(&wrap, &aggregator.panicked(), gst::FlowReturn::Error, {
imp.finish_buffer(&wrap, from_glib_full(buffer))
}).to_glib()
})
.to_glib()
}
unsafe extern "C" fn aggregator_sink_event<T: AggregatorBase>(
......@@ -606,7 +608,8 @@ where
&from_glib_borrow(aggregator_pad),
from_glib_full(event),
)
}).to_glib()
})
.to_glib()
}
unsafe extern "C" fn aggregator_sink_query<T: AggregatorBase>(
......@@ -629,7 +632,8 @@ where
&from_glib_borrow(aggregator_pad),
gst::QueryRef::from_mut_ptr(query),
)
}).to_glib()
})
.to_glib()
}
unsafe extern "C" fn aggregator_src_event<T: AggregatorBase>(
......@@ -647,7 +651,8 @@ where
panic_to_error!(&wrap, &aggregator.panicked(), false, {
imp.src_event(&wrap, from_glib_full(event))
}).to_glib()
})
.to_glib()
}
unsafe extern "C" fn aggregator_src_query<T: AggregatorBase>(
......@@ -665,7 +670,8 @@ where
panic_to_error!(&wrap, &aggregator.panicked(), false, {
imp.src_query(&wrap, gst::QueryRef::from_mut_ptr(query))
}).to_glib()
})
.to_glib()
}
unsafe extern "C" fn aggregator_src_activate<T: AggregatorBase>(
......@@ -684,7 +690,8 @@ where
panic_to_error!(&wrap, &aggregator.panicked(), false, {
imp.src_activate(&wrap, from_glib(mode), from_glib(active))
}).to_glib()
})
.to_glib()
}
unsafe extern "C" fn aggregator_aggregate<T: AggregatorBase>(
......@@ -702,7 +709,8 @@ where
panic_to_error!(&wrap, &aggregator.panicked(), gst::FlowReturn::Error, {
imp.aggregate(&wrap, from_glib(timeout))
}).to_glib()
})
.to_glib()
}
unsafe extern "C" fn aggregator_start<T: AggregatorBase>(
......@@ -749,7 +757,8 @@ where
panic_to_error!(&wrap, &aggregator.panicked(), gst::CLOCK_TIME_NONE, {
imp.get_next_time(&wrap)
}).to_glib()
})
.to_glib()
}
unsafe extern "C" fn aggregator_create_new_pad<T: AggregatorBase>(
......@@ -790,7 +799,8 @@ where
Some(gst::CapsRef::from_ptr(caps))
},
)
}).to_glib_full()
})
.to_glib_full()
}
unsafe extern "C" fn aggregator_update_src_caps<T: AggregatorBase>(
......@@ -817,7 +827,8 @@ where
}
Err(err) => err,
}
}).to_glib()
})
.to_glib()
}
unsafe extern "C" fn aggregator_fixate_src_caps<T: AggregatorBase>(
......@@ -835,7 +846,8 @@ where
panic_to_error!(&wrap, &aggregator.panicked(), gst::Caps::new_empty(), {
imp.fixate_src_caps(&wrap, from_glib_full(caps))
}).into_ptr()
})
.into_ptr()
}
unsafe extern "C" fn aggregator_negotiated_src_caps<T: AggregatorBase>(
......@@ -853,5 +865,6 @@ where
panic_to_error!(&wrap, &aggregator.panicked(), false, {
imp.negotiated_src_caps(&wrap, gst::CapsRef::from_ptr(caps))
}).to_glib()
})
.to_glib()
}
......@@ -11,8 +11,8 @@ use std::ptr;
use glib_ffi;
use gobject_ffi;
use gst_ffi;
use gst_base_ffi;
use gst_ffi;
use glib;
use glib::translate::*;
......@@ -32,14 +32,21 @@ pub trait AggregatorPadImpl<T: AggregatorPadBase>:
aggregator_pad.parent_flush(aggregator)
}
fn skip_buffer(&self, aggregator_pad: &T, aggregator: &gst_base::Aggregator, buffer: &gst::BufferRef) -> bool {
fn skip_buffer(
&self,
aggregator_pad: &T,
aggregator: &gst_base::Aggregator,
buffer: &gst::BufferRef,
) -> bool {
aggregator_pad.parent_skip_buffer(aggregator, buffer)
}
}
any_impl!(AggregatorPadBase, AggregatorPadImpl);
pub unsafe trait AggregatorPadBase: IsA<gst_base::AggregatorPad> + IsA<gst::Pad> + ObjectType {
pub unsafe trait AggregatorPadBase:
IsA<gst_base::AggregatorPad> + IsA<gst::Pad> + ObjectType
{
fn parent_flush(&self, aggregator: &gst_base::Aggregator) -> gst::FlowReturn {
unsafe {
let klass = self.get_class();
......@@ -52,14 +59,24 @@ pub unsafe trait AggregatorPadBase: IsA<gst_base::AggregatorPad> + IsA<gst::Pad>
}
}
fn parent_skip_buffer(&self, aggregator: &gst_base::Aggregator, buffer: &gst::BufferRef) -> bool {
fn parent_skip_buffer(
&self,
aggregator: &gst_base::Aggregator,
buffer: &gst::BufferRef,
) -> bool {
unsafe {
let klass = self.get_class();
let parent_klass =
(*klass).get_parent_class() as *const gst_base_ffi::GstAggregatorPadClass;
(*parent_klass)
.skip_buffer
.map(|f| from_glib(f(self.to_glib_none().0, aggregator.to_glib_none().0, buffer.as_mut_ptr())))
.map(|f| {
from_glib(f(
self.to_glib_none().0,
aggregator.to_glib_none().0,
buffer.as_mut_ptr(),
))
})
.unwrap_or(false)
}
}
......@@ -163,5 +180,10 @@ where
let wrap: T = from_glib_borrow(ptr as *mut T::InstanceStructType);
let imp = aggregator_pad.get_impl();
imp.skip_buffer(&wrap, &from_glib_borrow(aggregator), gst::BufferRef::from_ptr(buffer)).to_glib()
imp.skip_buffer(
&wrap,
&from_glib_borrow(aggregator),
gst::BufferRef::from_ptr(buffer),
)
.to_glib()
}
......@@ -350,7 +350,8 @@ where
panic_to_error!(&wrap, &element.panicked(), gst::FlowReturn::Error, {
imp.render(&wrap, buffer)
}).to_glib()
})
.to_glib()
}
unsafe extern "C" fn base_sink_prepare<T: BaseSinkBase>(
......@@ -369,7 +370,8 @@ where
panic_to_error!(&wrap, &element.panicked(), gst::FlowReturn::Error, {
imp.prepare(&wrap, buffer)
}).to_glib()
})
.to_glib()
}
unsafe extern "C" fn base_sink_render_list<T: BaseSinkBase>(
......@@ -388,7 +390,8 @@ where
panic_to_error!(&wrap, &element.panicked(), gst::FlowReturn::Error, {
imp.render_list(&wrap, list)
}).to_glib()
})
.to_glib()
}
unsafe extern "C" fn base_sink_prepare_list<T: BaseSinkBase>(
......@@ -407,7 +410,8 @@ where
panic_to_error!(&wrap, &element.panicked(), gst::FlowReturn::Error, {
imp.prepare_list(&wrap, list)
}).to_glib()
})
.to_glib()
}
unsafe extern "C" fn base_sink_query<T: BaseSinkBase>(
......@@ -426,7 +430,8 @@ where
panic_to_error!(&wrap, &element.panicked(), false, {
BaseSinkImpl::query(imp, &wrap, query)
}).to_glib()
})
.to_glib()
}
unsafe extern "C" fn base_sink_event<T: BaseSinkBase>(
......@@ -444,7 +449,8 @@ where
panic_to_error!(&wrap, &element.panicked(), false, {
imp.event(&wrap, from_glib_full(event_ptr))
}).to_glib()
})
.to_glib()
}
unsafe extern "C" fn base_sink_get_caps<T: BaseSinkBase>(
......@@ -467,8 +473,9 @@ where
panic_to_error!(&wrap, &element.panicked(), None, {
imp.get_caps(&wrap, filter)
}).map(|caps| caps.into_ptr())
.unwrap_or(ptr::null_mut())
})
.map(|caps| caps.into_ptr())
.unwrap_or(ptr::null_mut())
}
unsafe extern "C" fn base_sink_set_caps<T: BaseSinkBase>(
......@@ -487,7 +494,8 @@ where
panic_to_error!(&wrap, &element.panicked(), false, {
imp.set_caps(&wrap, caps)
}).to_glib()
})
.to_glib()
}
unsafe extern "C" fn base_sink_fixate<T: BaseSinkBase>(
......@@ -506,7 +514,8 @@ where
panic_to_error!(&wrap, &element.panicked(), gst::Caps::new_empty(), {
imp.fixate(&wrap, caps)
}).into_ptr()
})
.into_ptr()
}
unsafe extern "C" fn base_sink_unlock<T: BaseSinkBase>(
......@@ -538,5 +547,6 @@ where
panic_to_error!(&wrap, &element.panicked(), false, {
imp.unlock_stop(&wrap)
}).to_glib()
})
.to_glib()
}
......@@ -420,7 +420,8 @@ where
panic_to_error!(&wrap, &element.panicked(), false, {
imp.is_seekable(&wrap)
}).to_glib()
})
.to_glib()
}
unsafe extern "C" fn base_src_get_size<T: BaseSrcBase>(
......@@ -444,7 +445,8 @@ where
}
None => false,
}
}).to_glib()
})
.to_glib()
}
unsafe extern "C" fn base_src_fill<T: BaseSrcBase>(
......@@ -465,7 +467,8 @@ where
panic_to_error!(&wrap, &element.panicked(), gst::FlowReturn::Error, {
imp.fill(&wrap, offset, length, buffer)
}).to_glib()
})
.to_glib()
}
unsafe extern "C" fn base_src_create<T: BaseSrcBase>(
......@@ -494,7 +497,8 @@ where
}
Err(err) => err,
}
}).to_glib()
})
.to_glib()
}