Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArun Raghavan <arun@arunraghavan.net>2019-05-25 20:23:55 +0300
committerArun Raghavan <arun@arunraghavan.net>2019-05-27 17:41:58 +0300
commite70937a8d73ef1c466dbd283c8f07af0ce17cf31 (patch)
treed94bd86e4b90c5bbe65e8749ed92610da55816b3
parent857800b7b683fd390f8b0161375543109a190b45 (diff)
Update URIHander::set_uri based on gstreamer-rs API changes
Went from Option<String> to &str.
-rw-r--r--gst-plugin-file/src/filesink.rs15
-rw-r--r--gst-plugin-file/src/filesrc.rs15
-rw-r--r--gst-plugin-http/src/httpsrc.rs20
-rw-r--r--gst-plugin-s3/src/s3src.rs32
4 files changed, 28 insertions, 54 deletions
diff --git a/gst-plugin-file/src/filesink.rs b/gst-plugin-file/src/filesink.rs
index e4a3a2ce1..f84629a83 100644
--- a/gst-plugin-file/src/filesink.rs
+++ b/gst-plugin-file/src/filesink.rs
@@ -303,19 +303,18 @@ impl URIHandlerImpl for FileSink {
})
}
- fn set_uri(&self, element: &gst::URIHandler, uri: Option<String>) -> Result<(), glib::Error> {
+ fn set_uri(&self, element: &gst::URIHandler, uri: &str) -> Result<(), glib::Error> {
let element = element.dynamic_cast_ref::<gst_base::BaseSink>().unwrap();
// Special case for "file://" as this is used by some applications to test
// with `gst_element_make_from_uri` if there's an element that supports the URI protocol
- let uri = uri.filter(|uri| uri != "file://");
- let file_location = match uri {
- Some(uri) => Some(FileLocation::try_from_uri_str(&uri)?),
- None => None,
- };
-
- self.set_location(&element, file_location)
+ if uri != "file://" {
+ let file_location = FileLocation::try_from_uri_str(uri)?;
+ self.set_location(&element, Some(file_location))
+ } else {
+ Ok(())
+ }
}
fn get_uri_type() -> gst::URIType {
diff --git a/gst-plugin-file/src/filesrc.rs b/gst-plugin-file/src/filesrc.rs
index bc4dd1c6e..a817f9bc0 100644
--- a/gst-plugin-file/src/filesrc.rs
+++ b/gst-plugin-file/src/filesrc.rs
@@ -357,19 +357,18 @@ impl URIHandlerImpl for FileSrc {
})
}
- fn set_uri(&self, element: &gst::URIHandler, uri: Option<String>) -> Result<(), glib::Error> {
+ fn set_uri(&self, element: &gst::URIHandler, uri: &str) -> Result<(), glib::Error> {
let element = element.dynamic_cast_ref::<gst_base::BaseSrc>().unwrap();
// Special case for "file://" as this is used by some applications to test
// with `gst_element_make_from_uri` if there's an element that supports the URI protocol
- let uri = uri.filter(|uri| uri != "file://");
- let file_location = match uri {
- Some(uri) => Some(FileLocation::try_from_uri_str(&uri)?),
- None => None,
- };
-
- self.set_location(&element, file_location)
+ if uri != "file://" {
+ let file_location = FileLocation::try_from_uri_str(uri)?;
+ self.set_location(&element, Some(file_location))
+ } else {
+ Ok(())
+ }
}
fn get_uri_type() -> gst::URIType {
diff --git a/gst-plugin-http/src/httpsrc.rs b/gst-plugin-http/src/httpsrc.rs
index 2533b45b1..785996930 100644
--- a/gst-plugin-http/src/httpsrc.rs
+++ b/gst-plugin-http/src/httpsrc.rs
@@ -80,11 +80,7 @@ pub struct HttpSrc {
}
impl HttpSrc {
- fn set_location(
- &self,
- _element: &gst_base::BaseSrc,
- uri: Option<String>,
- ) -> Result<(), glib::Error> {
+ fn set_location(&self, _element: &gst_base::BaseSrc, uri: &str) -> Result<(), glib::Error> {
let state = self.state.lock().unwrap();
if let State::Started { .. } = *state {
return Err(glib::Error::new(
@@ -95,15 +91,7 @@ impl HttpSrc {
let mut settings = self.settings.lock().unwrap();
- let uri = match uri {
- Some(uri) => uri,
- None => {
- settings.location = None;
- return Ok(());
- }
- };
-
- let uri = Url::parse(uri.as_str()).map_err(|err| {
+ let uri = Url::parse(uri).map_err(|err| {
glib::Error::new(
gst::URIError::BadUri,
format!("Failed to parse URI '{}': {:?}", uri, err,).as_str(),
@@ -216,7 +204,7 @@ impl ObjectImpl for HttpSrc {
subclass::Property("location", ..) => {
let element = obj.downcast_ref::<gst_base::BaseSrc>().unwrap();
- let location = value.get::<String>();
+ let location = value.get::<&str>().unwrap();
let res = self.set_location(element, location);
if let Err(err) = res {
@@ -408,7 +396,7 @@ impl URIHandlerImpl for HttpSrc {
settings.location.as_ref().map(Url::to_string)
}
- fn set_uri(&self, element: &gst::URIHandler, uri: Option<String>) -> Result<(), glib::Error> {
+ fn set_uri(&self, element: &gst::URIHandler, uri: &str) -> Result<(), glib::Error> {
let element = element.dynamic_cast_ref::<gst_base::BaseSrc>().unwrap();
self.set_location(&element, uri)
diff --git a/gst-plugin-s3/src/s3src.rs b/gst-plugin-s3/src/s3src.rs
index d7a243cd9..26f49d361 100644
--- a/gst-plugin-s3/src/s3src.rs
+++ b/gst-plugin-s3/src/s3src.rs
@@ -98,11 +98,7 @@ impl S3Src {
Ok(S3Client::new(url.region.clone()))
}
- fn set_uri(
- self: &S3Src,
- _: &gst_base::BaseSrc,
- url_str: Option<String>,
- ) -> Result<(), glib::Error> {
+ fn set_uri(self: &S3Src, _: &gst_base::BaseSrc, url_str: &str) -> Result<(), glib::Error> {
let state = self.state.lock().unwrap();
if let StreamingState::Started { .. } = *state {
@@ -114,21 +110,15 @@ impl S3Src {
let mut url = self.url.lock().unwrap();
- match url_str {
- Some(s) => match parse_s3_url(&s) {
- Ok(s3url) => {
- *url = Some(s3url);
- Ok(())
- }
- Err(_) => Err(gst::Error::new(
- gst::URIError::BadUri,
- "Could not parse URI",
- )),
- },
- None => {
- *url = None;
+ match parse_s3_url(&url_str) {
+ Ok(s3url) => {
+ *url = Some(s3url);
Ok(())
}
+ Err(_) => Err(gst::Error::new(
+ gst::URIError::BadUri,
+ "Could not parse URI",
+ )),
}
}
@@ -302,9 +292,7 @@ impl ObjectImpl for S3Src {
match *prop {
subclass::Property("uri", ..) => {
- self.set_uri(basesrc, value.get()).unwrap_or_else(|err| {
- gst_error!(self.cat, obj: basesrc, "Could not set URI: {}", err);
- });
+ let _ = self.set_uri(basesrc, value.get().unwrap());
}
_ => unimplemented!(),
}
@@ -345,7 +333,7 @@ impl URIHandlerImpl for S3Src {
self.url.lock().unwrap().as_ref().map(|s| s.to_string())
}
- fn set_uri(&self, element: &gst::URIHandler, uri: Option<String>) -> Result<(), glib::Error> {
+ fn set_uri(&self, element: &gst::URIHandler, uri: &str) -> Result<(), glib::Error> {
let basesrc = element.dynamic_cast_ref::<gst_base::BaseSrc>().unwrap();
self.set_uri(basesrc, uri)
}