mirror of
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
synced 2024-11-27 14:01:04 +00:00
Update URIHander::set_uri based on gstreamer-rs API changes
Went from Option<String> to &str.
This commit is contained in:
parent
857800b7b6
commit
e70937a8d7
4 changed files with 28 additions and 54 deletions
|
@ -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 {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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,8 +110,7 @@ impl S3Src {
|
|||
|
||||
let mut url = self.url.lock().unwrap();
|
||||
|
||||
match url_str {
|
||||
Some(s) => match parse_s3_url(&s) {
|
||||
match parse_s3_url(&url_str) {
|
||||
Ok(s3url) => {
|
||||
*url = Some(s3url);
|
||||
Ok(())
|
||||
|
@ -124,11 +119,6 @@ impl S3Src {
|
|||
gst::URIError::BadUri,
|
||||
"Could not parse URI",
|
||||
)),
|
||||
},
|
||||
None => {
|
||||
*url = None;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue