Fix various needless-borrow clippy warnings and others

This commit is contained in:
Sebastian Dröge 2021-07-30 13:53:35 +03:00
parent 67f566dd28
commit 052365ba1a
36 changed files with 81 additions and 84 deletions

View file

@ -1622,7 +1622,7 @@ impl AudioLoudNorm {
let mut state = self.state.borrow_mut(); let mut state = self.state.borrow_mut();
let mut outbuf = None; let mut outbuf = None;
if let Some(ref mut state) = &mut *state { if let Some(ref mut state) = &mut *state {
outbuf = match state.drain(&element) { outbuf = match state.drain(element) {
Ok(outbuf) => Some(outbuf), Ok(outbuf) => Some(outbuf),
Err(gst::FlowError::Eos) => None, Err(gst::FlowError::Eos) => None,
Err(_) => return false, Err(_) => return false,
@ -1644,7 +1644,7 @@ impl AudioLoudNorm {
let mut state = self.state.borrow_mut(); let mut state = self.state.borrow_mut();
let mut outbuf = None; let mut outbuf = None;
if let Some(ref mut state) = &mut *state { if let Some(ref mut state) = &mut *state {
outbuf = match state.drain(&element) { outbuf = match state.drain(element) {
Ok(outbuf) => Some(outbuf), Ok(outbuf) => Some(outbuf),
Err(gst::FlowError::Eos) => None, Err(gst::FlowError::Eos) => None,
Err(_) => return false, Err(_) => return false,

View file

@ -436,7 +436,7 @@ impl BaseTransformImpl for EbuR128Level {
let mut timestamp = buf.pts(); let mut timestamp = buf.pts();
let segment = element.segment().downcast::<gst::ClockTime>().ok(); let segment = element.segment().downcast::<gst::ClockTime>().ok();
let buf = gst_audio::AudioBufferRef::from_buffer_ref_readable(&buf, &state.info).map_err( let buf = gst_audio::AudioBufferRef::from_buffer_ref_readable(buf, &state.info).map_err(
|_| { |_| {
gst::element_error!(element, gst::ResourceError::Read, ["Failed to map buffer"]); gst::element_error!(element, gst::ResourceError::Read, ["Failed to map buffer"]);
gst::FlowError::Error gst::FlowError::Error

View file

@ -313,7 +313,7 @@ impl URIHandlerImpl for FileSink {
if uri != "file://" { if uri != "file://" {
let file_location = FileLocation::try_from_uri_str(uri)?; let file_location = FileLocation::try_from_uri_str(uri)?;
self.set_location(&element, Some(file_location)) self.set_location(element, Some(file_location))
} else { } else {
Ok(()) Ok(())
} }

View file

@ -366,7 +366,7 @@ impl URIHandlerImpl for FileSrc {
if uri != "file://" { if uri != "file://" {
let file_location = FileLocation::try_from_uri_str(uri)?; let file_location = FileLocation::try_from_uri_str(uri)?;
self.set_location(&element, Some(file_location)) self.set_location(element, Some(file_location))
} else { } else {
Ok(()) Ok(())
} }

View file

@ -58,7 +58,7 @@ impl State {
let sender_key = props let sender_key = props
.sender_key .sender_key
.as_ref() .as_ref()
.and_then(|k| box_::PublicKey::from_slice(&k)) .and_then(|k| box_::PublicKey::from_slice(k))
.ok_or_else(|| { .ok_or_else(|| {
gst::error_msg!( gst::error_msg!(
gst::ResourceError::NotFound, gst::ResourceError::NotFound,
@ -73,7 +73,7 @@ impl State {
let receiver_key = props let receiver_key = props
.receiver_key .receiver_key
.as_ref() .as_ref()
.and_then(|k| box_::SecretKey::from_slice(&k)) .and_then(|k| box_::SecretKey::from_slice(k))
.ok_or_else(|| { .ok_or_else(|| {
gst::error_msg!( gst::error_msg!(
gst::ResourceError::NotFound, gst::ResourceError::NotFound,
@ -121,16 +121,15 @@ impl State {
let block_size = self.block_size.expect("Block size wasn't set") as usize + box_::MACBYTES; let block_size = self.block_size.expect("Block size wasn't set") as usize + box_::MACBYTES;
for subbuffer in map.chunks(block_size) { for subbuffer in map.chunks(block_size) {
let plain = box_::open_precomputed(&subbuffer, &nonce, &self.precomputed_key).map_err( let plain =
|_| { box_::open_precomputed(subbuffer, &nonce, &self.precomputed_key).map_err(|_| {
gst::element_error!( gst::element_error!(
element, element,
gst::StreamError::Format, gst::StreamError::Format,
["Failed to decrypt buffer"] ["Failed to decrypt buffer"]
); );
gst::FlowError::Error gst::FlowError::Error
}, })?;
)?;
// assumes little endian // assumes little endian
nonce.increment_le_inplace(); nonce.increment_le_inplace();
self.adapter.push(gst::Buffer::from_mut_slice(plain)); self.adapter.push(gst::Buffer::from_mut_slice(plain));

View file

@ -73,7 +73,7 @@ impl State {
let sender_key = props let sender_key = props
.sender_key .sender_key
.as_ref() .as_ref()
.and_then(|k| box_::SecretKey::from_slice(&k)) .and_then(|k| box_::SecretKey::from_slice(k))
.ok_or_else(|| { .ok_or_else(|| {
gst::error_msg!( gst::error_msg!(
gst::ResourceError::NotFound, gst::ResourceError::NotFound,
@ -88,7 +88,7 @@ impl State {
let receiver_key = props let receiver_key = props
.receiver_key .receiver_key
.as_ref() .as_ref()
.and_then(|k| box_::PublicKey::from_slice(&k)) .and_then(|k| box_::PublicKey::from_slice(k))
.ok_or_else(|| { .ok_or_else(|| {
gst::error_msg!( gst::error_msg!(
gst::ResourceError::NotFound, gst::ResourceError::NotFound,

View file

@ -134,7 +134,7 @@ impl AppSrcPadHandler {
pad.push_event(stream_start_evt).await; pad.push_event(stream_start_evt).await;
if let Some(ref caps) = state.caps { if let Some(ref caps) = state.caps {
pad.push_event(gst::event::Caps::new(&caps)).await; pad.push_event(gst::event::Caps::new(caps)).await;
*self.0.configured_caps.lock().unwrap() = Some(caps.clone()); *self.0.configured_caps.lock().unwrap() = Some(caps.clone());
} }

View file

@ -110,7 +110,7 @@ impl InputSelectorPadSinkHandler {
if let Some(segment) = &inner.segment { if let Some(segment) = &inner.segment {
if let Some(segment) = segment.downcast_ref::<gst::format::Time>() { if let Some(segment) = segment.downcast_ref::<gst::format::Time>() {
let rtime = segment.to_running_time(buffer.pts()); let rtime = segment.to_running_time(buffer.pts());
let (sync_fut, abort_handle) = abortable(self.sync(&element, rtime)); let (sync_fut, abort_handle) = abortable(self.sync(element, rtime));
inner.abort_handle = Some(abort_handle); inner.abort_handle = Some(abort_handle);
sync_future = Some(sync_fut.map_err(|_| gst::FlowError::Flushing)); sync_future = Some(sync_fut.map_err(|_| gst::FlowError::Flushing));
} }
@ -479,7 +479,7 @@ impl ObjectImpl for InputSelector {
let pads = self.pads.lock().unwrap(); let pads = self.pads.lock().unwrap();
let mut old_pad = None; let mut old_pad = None;
if let Some(ref pad) = pad { if let Some(ref pad) = pad {
if pads.sink_pads.get(&pad).is_some() { if pads.sink_pads.get(pad).is_some() {
old_pad = state.active_sinkpad.clone(); old_pad = state.active_sinkpad.clone();
state.active_sinkpad = Some(pad.clone()); state.active_sinkpad = Some(pad.clone());
state.switched_pad = true; state.switched_pad = true;
@ -607,7 +607,7 @@ impl ElementImpl for InputSelector {
let mut state = self.state.lock().unwrap(); let mut state = self.state.lock().unwrap();
let mut pads = self.pads.lock().unwrap(); let mut pads = self.pads.lock().unwrap();
let sink_pad = let sink_pad =
gst::Pad::from_template(&templ, Some(format!("sink_{}", pads.pad_serial).as_str())); gst::Pad::from_template(templ, Some(format!("sink_{}", pads.pad_serial).as_str()));
pads.pad_serial += 1; pads.pad_serial += 1;
sink_pad.set_active(true).unwrap(); sink_pad.set_active(true).unwrap();
element.add_pad(&sink_pad).unwrap(); element.add_pad(&sink_pad).unwrap();

View file

@ -525,7 +525,7 @@ impl SinkHandler {
// Reschedule if needed // Reschedule if needed
let (_, next_wakeup) = let (_, next_wakeup) =
jb.src_pad_handler jb.src_pad_handler
.next_wakeup(&element, &state, latency, context_wait); .next_wakeup(element, &state, latency, context_wait);
if let Some((next_wakeup, _)) = next_wakeup { if let Some((next_wakeup, _)) = next_wakeup {
if let Some((previous_next_wakeup, ref abort_handle)) = state.wait_handle { if let Some((previous_next_wakeup, ref abort_handle)) = state.wait_handle {
if previous_next_wakeup.is_none() if previous_next_wakeup.is_none()

View file

@ -902,7 +902,7 @@ impl TaskImpl for ProxySrcTask {
let pad = self.src_pad.upgrade().expect("PadSrc no longer exists"); let pad = self.src_pad.upgrade().expect("PadSrc no longer exists");
let proxysrc = ProxySrc::from_instance(&self.element); let proxysrc = ProxySrc::from_instance(&self.element);
let res = ProxySrcPadHandler::push_item(&pad, &proxysrc, item).await; let res = ProxySrcPadHandler::push_item(&pad, proxysrc, item).await;
match res { match res {
Ok(()) => { Ok(()) => {
gst_log!(SRC_CAT, obj: &self.element, "Successfully pushed item"); gst_log!(SRC_CAT, obj: &self.element, "Successfully pushed item");

View file

@ -368,7 +368,7 @@ impl TaskImpl for QueueTask {
let pad = self.src_pad.upgrade().expect("PadSrc no longer exists"); let pad = self.src_pad.upgrade().expect("PadSrc no longer exists");
let queue = Queue::from_instance(&self.element); let queue = Queue::from_instance(&self.element);
let res = QueuePadSrcHandler::push_item(&pad, &queue, item).await; let res = QueuePadSrcHandler::push_item(&pad, queue, item).await;
match res { match res {
Ok(()) => { Ok(()) => {
gst_log!(CAT, obj: &self.element, "Successfully pushed item"); gst_log!(CAT, obj: &self.element, "Successfully pushed item");
@ -558,7 +558,7 @@ impl Queue {
let mut pending_queue = self.pending_queue.lock().unwrap(); let mut pending_queue = self.pending_queue.lock().unwrap();
if let Err(item) = self.queue_until_full(&dataqueue, &mut pending_queue, item) { if let Err(item) = self.queue_until_full(dataqueue, &mut pending_queue, item) {
if pending_queue if pending_queue
.as_ref() .as_ref()
.map(|pq| !pq.scheduled) .map(|pq| !pq.scheduled)

View file

@ -1027,7 +1027,7 @@ impl StateMachine {
task_inner: &Arc<Mutex<TaskInner>>, task_inner: &Arc<Mutex<TaskInner>>,
context: &Context, context: &Context,
) -> Self { ) -> Self {
let task_inner_clone = Arc::clone(&task_inner); let task_inner_clone = Arc::clone(task_inner);
let loop_fut = async move { let loop_fut = async move {
let mut res = self.task_impl.start().await; let mut res = self.task_impl.start().await;
if res.is_ok() { if res.is_ok() {

View file

@ -148,7 +148,7 @@ impl TcpClientSrcPadHandler {
pad.push_event(stream_start_evt).await; pad.push_event(stream_start_evt).await;
if let Some(ref caps) = state.caps { if let Some(ref caps) = state.caps {
pad.push_event(gst::event::Caps::new(&caps)).await; pad.push_event(gst::event::Caps::new(caps)).await;
*self.0.configured_caps.lock().unwrap() = Some(caps.clone()); *self.0.configured_caps.lock().unwrap() = Some(caps.clone());
} }

View file

@ -441,7 +441,7 @@ impl UdpSinkPadHandler {
if !clients_to_configure.is_empty() { if !clients_to_configure.is_empty() {
for client in &clients_to_configure { for client in &clients_to_configure {
self.configure_client(&settings, &mut socket, &mut socket_v6, &client) self.configure_client(&settings, &mut socket, &mut socket_v6, client)
.map_err(|err| { .map_err(|err| {
element_error!( element_error!(
element, element,
@ -456,7 +456,7 @@ impl UdpSinkPadHandler {
if !clients_to_unconfigure.is_empty() { if !clients_to_unconfigure.is_empty() {
for client in &clients_to_unconfigure { for client in &clients_to_unconfigure {
self.unconfigure_client(&settings, &mut socket, &mut socket_v6, &client) self.unconfigure_client(&settings, &mut socket, &mut socket_v6, client)
.map_err(|err| { .map_err(|err| {
element_error!( element_error!(
element, element,
@ -470,7 +470,7 @@ impl UdpSinkPadHandler {
} }
if do_sync { if do_sync {
self.sync(&element, rtime).await; self.sync(element, rtime).await;
} }
let data = buffer.map_readable().map_err(|_| { let data = buffer.map_readable().map_err(|_| {
@ -876,7 +876,7 @@ impl UdpSink {
self.prepare_socket(SocketFamily::Ipv6, &context, element)?; self.prepare_socket(SocketFamily::Ipv6, &context, element)?;
self.task self.task
.prepare(UdpSinkTask::new(&element, &self.sink_pad_handler), context) .prepare(UdpSinkTask::new(element, &self.sink_pad_handler), context)
.map_err(|err| { .map_err(|err| {
error_msg!( error_msg!(
gst::ResourceError::OpenRead, gst::ResourceError::OpenRead,
@ -916,17 +916,17 @@ impl UdpSink {
impl UdpSink { impl UdpSink {
fn clear_clients(&self, clients_to_add: impl Iterator<Item = SocketAddr>) { fn clear_clients(&self, clients_to_add: impl Iterator<Item = SocketAddr>) {
self.sink_pad_handler self.sink_pad_handler
.clear_clients(&self.sink_pad.gst_pad(), clients_to_add); .clear_clients(self.sink_pad.gst_pad(), clients_to_add);
} }
fn remove_client(&self, addr: SocketAddr) { fn remove_client(&self, addr: SocketAddr) {
self.sink_pad_handler self.sink_pad_handler
.remove_client(&self.sink_pad.gst_pad(), addr); .remove_client(self.sink_pad.gst_pad(), addr);
} }
fn add_client(&self, addr: SocketAddr) { fn add_client(&self, addr: SocketAddr) {
self.sink_pad_handler self.sink_pad_handler
.add_client(&self.sink_pad.gst_pad(), addr); .add_client(self.sink_pad.gst_pad(), addr);
} }
} }
@ -1249,7 +1249,7 @@ impl ObjectImpl for UdpSink {
.map_err(|err| { .map_err(|err| {
gst_error!(CAT, obj: obj, "Invalid port {}: {}", rsplit[0], err); gst_error!(CAT, obj: obj, "Invalid port {}: {}", rsplit[0], err);
}) })
.and_then(|port| try_into_socket_addr(&obj, rsplit[1], port)) .and_then(|port| try_into_socket_addr(obj, rsplit[1], port))
.ok() .ok()
} else { } else {
None None

View file

@ -165,7 +165,7 @@ impl UdpSrcPadHandler {
pad.push_event(stream_start_evt).await; pad.push_event(stream_start_evt).await;
if let Some(ref caps) = state.caps { if let Some(ref caps) = state.caps {
pad.push_event(gst::event::Caps::new(&caps)).await; pad.push_event(gst::event::Caps::new(caps)).await;
*self.0.configured_caps.lock().unwrap() = Some(caps.clone()); *self.0.configured_caps.lock().unwrap() = Some(caps.clone());
} }

View file

@ -524,7 +524,7 @@ mod imp_sink {
match event.view() { match event.view() {
EventView::FlushStart(..) => { EventView::FlushStart(..) => {
elem_sink_test.stop(&element.downcast_ref::<super::ElementSinkTest>().unwrap()); elem_sink_test.stop(element.downcast_ref::<super::ElementSinkTest>().unwrap());
true true
} }
_ => false, _ => false,
@ -953,9 +953,9 @@ fn nominal_scenario(
fn src_sink_nominal() { fn src_sink_nominal() {
let name = "src_sink_nominal"; let name = "src_sink_nominal";
let (pipeline, src_element, _sink_element, receiver) = setup(&name, None, None); let (pipeline, src_element, _sink_element, receiver) = setup(name, None, None);
nominal_scenario(&name, pipeline, src_element, receiver); nominal_scenario(name, pipeline, src_element, receiver);
} }
#[test] #[test]
@ -974,7 +974,7 @@ fn src_tsqueue_sink_nominal() {
let (pipeline, src_element, _sink_element, receiver) = setup(name, Some(ts_queue), None); let (pipeline, src_element, _sink_element, receiver) = setup(name, Some(ts_queue), None);
nominal_scenario(&name, pipeline, src_element, receiver); nominal_scenario(name, pipeline, src_element, receiver);
} }
#[test] #[test]
@ -986,7 +986,7 @@ fn src_queue_sink_nominal() {
let queue = gst::ElementFactory::make("queue", Some("queue")).unwrap(); let queue = gst::ElementFactory::make("queue", Some("queue")).unwrap();
let (pipeline, src_element, _sink_element, receiver) = setup(name, Some(queue), None); let (pipeline, src_element, _sink_element, receiver) = setup(name, Some(queue), None);
nominal_scenario(&name, pipeline, src_element, receiver); nominal_scenario(name, pipeline, src_element, receiver);
} }
#[test] #[test]
@ -1014,7 +1014,7 @@ fn src_tsproxy_sink_nominal() {
let (pipeline, src_element, _sink_element, receiver) = let (pipeline, src_element, _sink_element, receiver) =
setup(name, Some(ts_proxy_sink), Some(ts_proxy_src)); setup(name, Some(ts_proxy_sink), Some(ts_proxy_src));
nominal_scenario(&name, pipeline, src_element, receiver); nominal_scenario(name, pipeline, src_element, receiver);
} }
#[test] #[test]
@ -1023,7 +1023,7 @@ fn start_pause_start() {
let scenario_name = "start_pause_start"; let scenario_name = "start_pause_start";
let (pipeline, src_element, _sink_element, mut receiver) = setup(&scenario_name, None, None); let (pipeline, src_element, _sink_element, mut receiver) = setup(scenario_name, None, None);
let elem_src_test = imp_src::ElementSrcTest::from_instance(&src_element); let elem_src_test = imp_src::ElementSrcTest::from_instance(&src_element);
@ -1101,7 +1101,7 @@ fn start_stop_start() {
let scenario_name = "start_stop_start"; let scenario_name = "start_stop_start";
let (pipeline, src_element, _sink_element, mut receiver) = setup(&scenario_name, None, None); let (pipeline, src_element, _sink_element, mut receiver) = setup(scenario_name, None, None);
let elem_src_test = imp_src::ElementSrcTest::from_instance(&src_element); let elem_src_test = imp_src::ElementSrcTest::from_instance(&src_element);
@ -1214,7 +1214,7 @@ fn start_flush() {
let scenario_name = "start_flush"; let scenario_name = "start_flush";
let (pipeline, src_element, sink_element, mut receiver) = setup(&scenario_name, None, None); let (pipeline, src_element, sink_element, mut receiver) = setup(scenario_name, None, None);
let elem_src_test = imp_src::ElementSrcTest::from_instance(&src_element); let elem_src_test = imp_src::ElementSrcTest::from_instance(&src_element);

View file

@ -122,7 +122,7 @@ fn test_chain() {
init(); init();
let mut h = gst_check::Harness::new("ts-udpsink"); let mut h = gst_check::Harness::new("ts-udpsink");
h.set_src_caps_str(&"foo/bar"); h.set_src_caps_str("foo/bar");
{ {
let udpsink = h.element().unwrap(); let udpsink = h.element().unwrap();
udpsink.set_property("clients", &"127.0.0.1:5005").unwrap(); udpsink.set_property("clients", &"127.0.0.1:5005").unwrap();

View file

@ -1274,7 +1274,7 @@ impl URIHandlerImpl for ReqwestHttpSrc {
} }
fn set_uri(&self, element: &Self::Type, uri: &str) -> Result<(), glib::Error> { fn set_uri(&self, element: &Self::Type, uri: &str) -> Result<(), glib::Error> {
self.set_location(&element, Some(uri)) self.set_location(element, Some(uri))
} }
} }

View file

@ -486,7 +486,7 @@ impl Transcriber {
if packet_is_exception(&pkt) { if packet_is_exception(&pkt) {
let message: ExceptionMessage = let message: ExceptionMessage =
serde_json::from_str(&payload).map_err(|err| { serde_json::from_str(payload).map_err(|err| {
gst_error!( gst_error!(
CAT, CAT,
obj: element, obj: element,
@ -512,7 +512,7 @@ impl Transcriber {
)); ));
} }
let transcript: Transcript = serde_json::from_str(&payload).map_err(|err| { let transcript: Transcript = serde_json::from_str(payload).map_err(|err| {
error_msg!( error_msg!(
gst::StreamError::Failed, gst::StreamError::Failed,
["Unexpected binary message: {} ({})", payload, err] ["Unexpected binary message: {} ({})", payload, err]
@ -802,7 +802,7 @@ impl Transcriber {
self.ensure_connection(element).map_err(|err| { self.ensure_connection(element).map_err(|err| {
element_error!( element_error!(
&element, element,
gst::StreamError::Failed, gst::StreamError::Failed,
["Streaming failed: {}", err] ["Streaming failed: {}", err]
); );

View file

@ -130,7 +130,7 @@ impl State {
} }
}; };
let line: Line = serde_json::from_slice(&line).map_err(|err| (line, err))?; let line: Line = serde_json::from_slice(line).map_err(|err| (line, err))?;
Ok(Some(line)) Ok(Some(line))
} }
@ -181,7 +181,7 @@ impl State {
self.need_segment = false; self.need_segment = false;
} }
events.extend(self.pending_events.drain(..)); events.append(&mut self.pending_events);
events events
} }
@ -501,7 +501,7 @@ impl JsonGstParse {
pts, pts,
duration, duration,
data: _data, data: _data,
}) = serde_json::from_slice(&line) }) = serde_json::from_slice(line)
{ {
last_pts = pts.zip(duration).map(|(pts, duration)| pts + duration); last_pts = pts.zip(duration).map(|(pts, duration)| pts + duration);
} }

View file

@ -88,8 +88,8 @@ fn test_parse() {
match ev.view() { match ev.view() {
EventView::Caps(ev) => { EventView::Caps(ev) => {
assert!(ev.caps().is_strictly_equal(&gst::Caps::new_simple( assert!(ev.caps().is_strictly_equal(&gst::Caps::new_simple(
&"application/x-json", "application/x-json",
&[(&"format", &"test")] &[("format", &"test")]
))); )));
} }
_ => (), _ => (),

View file

@ -259,7 +259,7 @@ impl ObjectImpl for RegEx {
Operation::ReplaceAll(ref replacement) => { Operation::ReplaceAll(ref replacement) => {
commands.push( commands.push(
gst::Structure::new( gst::Structure::new(
&"replace-all", "replace-all",
&[("pattern", &command.pattern), ("replacement", &replacement)], &[("pattern", &command.pattern), ("replacement", &replacement)],
) )
.to_send_value(), .to_send_value(),

View file

@ -36,7 +36,7 @@ fn create_pipeline() -> (gst::Pipeline, gst::Pad, gst::Element, gtk::Widget) {
let video_src = gst::parse_bin_from_description(MAIN_PIPELINE, true) let video_src = gst::parse_bin_from_description(MAIN_PIPELINE, true)
.unwrap() .unwrap()
.upcast(); .upcast();
let fallback_video_src = gst::parse_bin_from_description(&FALLBACK_PIPELINE, true) let fallback_video_src = gst::parse_bin_from_description(FALLBACK_PIPELINE, true)
.unwrap() .unwrap()
.upcast(); .upcast();

View file

@ -162,7 +162,7 @@ impl BinImpl for CustomSource {
// TODO: Drop stream collection message for now, we only create a simple custom // TODO: Drop stream collection message for now, we only create a simple custom
// one here so that fallbacksrc can know about our streams. It is never // one here so that fallbacksrc can know about our streams. It is never
// forwarded. // forwarded.
self.handle_source_no_more_pads(&bin); self.handle_source_no_more_pads(bin);
} }
_ => self.parent_handle_message(bin, msg), _ => self.parent_handle_message(bin, msg),
} }
@ -198,14 +198,14 @@ impl CustomSource {
// Handle all source pads that already exist // Handle all source pads that already exist
for pad in source.src_pads() { for pad in source.src_pads() {
if let Err(msg) = self.handle_source_pad_added(&element, &pad) { if let Err(msg) = self.handle_source_pad_added(element, &pad) {
element.post_error_message(msg); element.post_error_message(msg);
return Err(gst::StateChangeError); return Err(gst::StateChangeError);
} }
} }
if !has_sometimes_pads { if !has_sometimes_pads {
self.handle_source_no_more_pads(&element); self.handle_source_no_more_pads(element);
} else { } else {
gst_debug!(CAT, obj: element, "Found sometimes pads"); gst_debug!(CAT, obj: element, "Found sometimes pads");

View file

@ -361,7 +361,7 @@ impl FallbackSwitch {
// Drop all older buffers from the fallback sinkpad // Drop all older buffers from the fallback sinkpad
if let Some(backup_pad) = backup_pad { if let Some(backup_pad) = backup_pad {
self.drain_pad_to_time(state, &backup_pad, state.last_output_time)?; self.drain_pad_to_time(state, backup_pad, state.last_output_time)?;
} }
Ok(Some((buffer, active_caps, pad_change))) Ok(Some((buffer, active_caps, pad_change)))
@ -607,7 +607,7 @@ impl FallbackSwitch {
"No primary buffer, but can't autoswitch - draining backup pad" "No primary buffer, but can't autoswitch - draining backup pad"
); );
if let Some(backup_pad) = &backup_pad { if let Some(backup_pad) = &backup_pad {
if let Err(e) = self.drain_pad_to_time(&mut *state, &backup_pad, cur_running_time) { if let Err(e) = self.drain_pad_to_time(&mut *state, backup_pad, cur_running_time) {
return ( return (
Err(e), Err(e),
state.check_health_changes( state.check_health_changes(
@ -917,10 +917,8 @@ impl ElementImpl for FallbackSwitch {
return None; return None;
} }
let sinkpad = gst::PadBuilder::<gst_base::AggregatorPad>::from_template( let sinkpad =
&templ, gst::PadBuilder::<gst_base::AggregatorPad>::from_template(templ, Some("fallback_sink"))
Some("fallback_sink"),
)
.build(); .build();
*fallback_sinkpad = Some(sinkpad.clone()); *fallback_sinkpad = Some(sinkpad.clone());

View file

@ -399,7 +399,7 @@ fn setup_pipeline(with_live_fallback: Option<bool>) -> Pipeline {
let queue = gst::ElementFactory::make("queue", None).unwrap(); let queue = gst::ElementFactory::make("queue", None).unwrap();
pipeline pipeline
.add_many(&[src.upcast_ref(), &switch, &queue, &sink.upcast_ref()]) .add_many(&[src.upcast_ref(), &switch, &queue, sink.upcast_ref()])
.unwrap(); .unwrap();
src.link_pads(Some("src"), &switch, Some("sink")).unwrap(); src.link_pads(Some("src"), &switch, Some("sink")).unwrap();
switch.link_pads(Some("src"), &queue, Some("sink")).unwrap(); switch.link_pads(Some("src"), &queue, Some("sink")).unwrap();

View file

@ -135,7 +135,7 @@ impl VideoDecoderImpl for CdgDec {
})?; })?;
let data = map.as_slice(); let data = map.as_slice();
cdg::decode_subchannel_cmd(&data) cdg::decode_subchannel_cmd(data)
}; };
let cmd = match cmd { let cmd = match cmd {

View file

@ -131,7 +131,7 @@ impl Cea608Overlay {
context.set_base_dir(pango::Direction::Ltr); context.set_base_dir(pango::Direction::Ltr);
let layout = pango::Layout::new(&context); let layout = pango::Layout::new(&context);
layout.set_alignment(pango::Alignment::Left); layout.set_alignment(pango::Alignment::Left);
let mut font_desc = pango::FontDescription::from_string(&"monospace"); let mut font_desc = pango::FontDescription::from_string("monospace");
let mut font_size = 1; let mut font_size = 1;
let mut left_alignment = 0; let mut left_alignment = 0;
@ -139,7 +139,7 @@ impl Cea608Overlay {
font_desc.set_size(font_size * pango::SCALE); font_desc.set_size(font_size * pango::SCALE);
layout.set_font_description(Some(&font_desc)); layout.set_font_description(Some(&font_desc));
layout.set_text( layout.set_text(
&"12345678901234567890123456789012\n2\n3\n4\n5\n6\n7\n8\n9\n0\n1\n2\n3\n4\n5", "12345678901234567890123456789012\n2\n3\n4\n5\n6\n7\n8\n9\n0\n1\n2\n3\n4\n5",
); );
let (_ink_rect, logical_rect) = layout.extents(); let (_ink_rect, logical_rect) = layout.extents();
if logical_rect.width > video_info.width() as i32 * pango::SCALE if logical_rect.width > video_info.width() as i32 * pango::SCALE
@ -222,7 +222,7 @@ impl Cea608Overlay {
cr.set_source_rgba(0.0, 0.0, 0.0, 1.0); cr.set_source_rgba(0.0, 0.0, 0.0, 1.0);
pangocairo::functions::layout_path(&cr, &layout); pangocairo::functions::layout_path(&cr, layout);
cr.stroke().ok()?; cr.stroke().ok()?;
cr.restore().ok()?; cr.restore().ok()?;
@ -230,7 +230,7 @@ impl Cea608Overlay {
cr.save().ok()?; cr.save().ok()?;
cr.set_source_rgba(255.0, 255.0, 255.0, 1.0); cr.set_source_rgba(255.0, 255.0, 255.0, 1.0);
pangocairo::functions::show_layout(&cr, &layout); pangocairo::functions::show_layout(&cr, layout);
cr.restore().ok()?; cr.restore().ok()?;
drop(cr); drop(cr);
@ -496,7 +496,7 @@ impl Cea608Overlay {
if let Some(composition) = &state.composition { if let Some(composition) = &state.composition {
let buffer = buffer.make_mut(); let buffer = buffer.make_mut();
if state.attach { if state.attach {
gst_video::VideoOverlayCompositionMeta::add(buffer, &composition); gst_video::VideoOverlayCompositionMeta::add(buffer, composition);
} else { } else {
let mut frame = gst_video::VideoFrameRef::from_buffer_ref_writable( let mut frame = gst_video::VideoFrameRef::from_buffer_ref_writable(
buffer, buffer,

View file

@ -262,9 +262,9 @@ impl State {
framerate: gst::Fraction, framerate: gst::Fraction,
) { ) {
let buffer = buffer.get_mut().unwrap(); let buffer = buffer.get_mut().unwrap();
gst_video::VideoTimeCodeMeta::add(buffer, &timecode); gst_video::VideoTimeCodeMeta::add(buffer, timecode);
self.update_timestamp(element, &timecode); self.update_timestamp(element, timecode);
buffer.set_pts(self.last_position); buffer.set_pts(self.last_position);
@ -336,7 +336,7 @@ impl State {
self.need_segment = false; self.need_segment = false;
} }
events.extend(self.pending_events.drain(..)); events.append(&mut self.pending_events);
events events
} }
} }

View file

@ -159,7 +159,7 @@ impl State {
framerate: gst::Fraction, framerate: gst::Fraction,
element: &super::SccParse, element: &super::SccParse,
) -> Result<gst_video::ValidVideoTimeCode, gst::FlowError> { ) -> Result<gst_video::ValidVideoTimeCode, gst::FlowError> {
match parse_timecode(framerate, &tc) { match parse_timecode(framerate, tc) {
Ok(timecode) => Ok(timecode), Ok(timecode) => Ok(timecode),
Err(err) => { Err(err) => {
let last_timecode = let last_timecode =
@ -222,7 +222,7 @@ impl State {
element: &super::SccParse, element: &super::SccParse,
) { ) {
let buffer = buffer.get_mut().unwrap(); let buffer = buffer.get_mut().unwrap();
gst_video::VideoTimeCodeMeta::add(buffer, &timecode); gst_video::VideoTimeCodeMeta::add(buffer, timecode);
self.update_timestamp(timecode, element); self.update_timestamp(timecode, element);
@ -284,7 +284,7 @@ impl State {
self.need_segment = false; self.need_segment = false;
} }
events.extend(self.pending_events.drain(..)); events.append(&mut self.pending_events);
events events
} }
} }

View file

@ -721,7 +721,7 @@ impl ObjectImpl for TranscriberBin {
} }
"transcriber" => { "transcriber" => {
let state = self.state.lock().unwrap(); let state = self.state.lock().unwrap();
if let Some(ref state) = state.as_ref() { if let Some(state) = state.as_ref() {
state.transcriber.to_value() state.transcriber.to_value()
} else { } else {
let ret: Option<gst::Element> = None; let ret: Option<gst::Element> = None;

View file

@ -253,14 +253,14 @@ impl Dav1dDec {
pic: &dav1d::Picture, pic: &dav1d::Picture,
format: gst_video::VideoFormat, format: gst_video::VideoFormat,
) -> Result<gst::FlowSuccess, gst::FlowError> { ) -> Result<gst::FlowSuccess, gst::FlowError> {
self.handle_resolution_change(element, &pic, format)?; self.handle_resolution_change(element, pic, format)?;
let output_state = element let output_state = element
.output_state() .output_state()
.expect("Output state not set. Shouldn't happen!"); .expect("Output state not set. Shouldn't happen!");
let offset = pic.offset() as i32; let offset = pic.offset() as i32;
if let Some(mut frame) = element.frame(offset) { if let Some(mut frame) = element.frame(offset) {
let output_buffer = self.decoded_picture_as_buffer(&pic, output_state)?; let output_buffer = self.decoded_picture_as_buffer(pic, output_state)?;
frame.set_output_buffer(output_buffer); frame.set_output_buffer(output_buffer);
element.finish_frame(frame)?; element.finish_frame(frame)?;
} else { } else {

View file

@ -661,7 +661,7 @@ impl FlvDemux {
let full_stream_id = srcpad.create_stream_id(element, Some(name)); let full_stream_id = srcpad.create_stream_id(element, Some(name));
// FIXME group id // FIXME group id
srcpad.push_event(gst::event::StreamStart::new(&full_stream_id)); srcpad.push_event(gst::event::StreamStart::new(&full_stream_id));
srcpad.push_event(gst::event::Caps::new(&caps)); srcpad.push_event(gst::event::Caps::new(caps));
// FIXME proper segment handling // FIXME proper segment handling
let segment = gst::FormattedSegment::<gst::ClockTime>::default(); let segment = gst::FormattedSegment::<gst::ClockTime>::default();
@ -940,7 +940,7 @@ impl StreamingState {
// AAC special case // AAC special case
if data_header.sound_format == flavors::SoundFormat::AAC if data_header.sound_format == flavors::SoundFormat::AAC
&& self.handle_aac_audio_packet_header(element, &tag_header, adapter)? && self.handle_aac_audio_packet_header(element, tag_header, adapter)?
{ {
return Ok(events); return Ok(events);
} }

View file

@ -49,7 +49,7 @@ fn test_encode(video_info: &gst_video::VideoInfo) {
buffer.set_pts(gst::ClockTime::from_seconds(pts)); buffer.set_pts(gst::ClockTime::from_seconds(pts));
} }
let mut vframe = let mut vframe =
gst_video::VideoFrame::from_buffer_writable(buffer, &video_info).unwrap(); gst_video::VideoFrame::from_buffer_writable(buffer, video_info).unwrap();
for v in vframe.plane_data_mut(0).unwrap() { for v in vframe.plane_data_mut(0).unwrap() {
*v = 128; *v = 128;
} }

View file

@ -128,7 +128,7 @@ fn test_encode(video_info: &gst_video::VideoInfo) {
let buffer = { let buffer = {
let buffer = gst::Buffer::with_size(video_info.size()).unwrap(); let buffer = gst::Buffer::with_size(video_info.size()).unwrap();
let mut vframe = gst_video::VideoFrame::from_buffer_writable(buffer, &video_info).unwrap(); let mut vframe = gst_video::VideoFrame::from_buffer_writable(buffer, video_info).unwrap();
for v in vframe.plane_data_mut(0).unwrap() { for v in vframe.plane_data_mut(0).unwrap() {
*v = 0; *v = 0;

View file

@ -73,7 +73,7 @@ fn test_png_encode(video_info: &gst_video::VideoInfo) {
buffer.set_pts(gst::ClockTime::from_seconds(pts)); buffer.set_pts(gst::ClockTime::from_seconds(pts));
} }
let mut vframe = let mut vframe =
gst_video::VideoFrame::from_buffer_writable(buffer, &video_info).unwrap(); gst_video::VideoFrame::from_buffer_writable(buffer, video_info).unwrap();
for v in vframe.plane_data_mut(0).unwrap() { for v in vframe.plane_data_mut(0).unwrap() {
*v = 128; *v = 128;
} }