diff --git a/src/lib.rs b/src/lib.rs index f4e59908..d13ea851 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -20,7 +20,7 @@ use rssink::Sink; use rsfilesink::FileSink; use std::os::raw::c_void; -use libc::{c_char}; +use libc::c_char; use std::ffi::CString; extern "C" { diff --git a/src/rsfilesrc.rs b/src/rsfilesrc.rs index 01766f91..2e06bea4 100644 --- a/src/rsfilesrc.rs +++ b/src/rsfilesrc.rs @@ -67,10 +67,10 @@ impl Source for FileSrc { } fn get_uri(&self) -> Option { - match self.location { - None => None, - Some(ref location) => Url::from_file_path(&location).map(|u| u.into_string()).ok() - } + self.location.as_ref() + .map(|l| Url::from_file_path(l).ok()) + .and_then(|i| i) // join() + .map(|u| u.into_string()) } fn is_seekable(&self) -> bool { @@ -78,12 +78,11 @@ impl Source for FileSrc { } fn get_size(&self) -> u64 { - match self.file { - None => return u64::MAX, - Some(ref f) => { - return f.metadata().map(|m| m.len()).unwrap_or(u64::MAX); - }, - } + self.file.as_ref() + .map(|f| f.metadata().ok()) + .and_then(|i| i) // join() + .map(|m| m.len()) + .unwrap_or(u64::MAX) } fn start(&mut self) -> bool { diff --git a/src/rshttpsrc.rs b/src/rshttpsrc.rs index 332ef76b..8629c7be 100644 --- a/src/rshttpsrc.rs +++ b/src/rshttpsrc.rs @@ -142,7 +142,7 @@ impl Source for HttpSrc { } fn get_uri(&self) -> Option { - self.url.clone().map(|u| u.into_string()) + self.url.as_ref().map(|u| String::from(u.as_str())) } fn is_seekable(&self) -> bool { diff --git a/src/rssource.c b/src/rssource.c index bbc63aa1..16b8ff40 100644 --- a/src/rssource.c +++ b/src/rssource.c @@ -4,7 +4,6 @@ #include typedef struct { - gchar *name; gchar *long_name; gchar *description; gchar *classification; @@ -305,7 +304,6 @@ gst_rs_source_register (GstPlugin * plugin, const gchar *name, const gchar * lon ElementData *data; data = g_new0 (ElementData, 1); - data->name = g_strdup (name); data->long_name = g_strdup (long_name); data->description = g_strdup (description); data->classification = g_strdup (classification);