mirror of
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
synced 2025-01-24 01:48:11 +00:00
reqwesthttpsrc: add is-live property
This commit is contained in:
parent
1e71767b40
commit
923f6e3a5c
1 changed files with 21 additions and 2 deletions
|
@ -37,6 +37,7 @@ const DEFAULT_USER_AGENT: &str = concat!(
|
|||
"-",
|
||||
env!("COMMIT_ID")
|
||||
);
|
||||
const DEFAULT_IS_LIVE: bool = false;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
struct Settings {
|
||||
|
@ -53,7 +54,7 @@ impl Default for Settings {
|
|||
}
|
||||
}
|
||||
|
||||
static PROPERTIES: [subclass::Property; 2] = [
|
||||
static PROPERTIES: [subclass::Property; 3] = [
|
||||
subclass::Property("location", |name| {
|
||||
glib::ParamSpec::string(
|
||||
name,
|
||||
|
@ -72,6 +73,15 @@ static PROPERTIES: [subclass::Property; 2] = [
|
|||
glib::ParamFlags::READWRITE,
|
||||
)
|
||||
}),
|
||||
subclass::Property("is-live", |name| {
|
||||
glib::ParamSpec::boolean(
|
||||
name,
|
||||
"Is Live",
|
||||
"Act like a live source",
|
||||
DEFAULT_IS_LIVE,
|
||||
glib::ParamFlags::READWRITE,
|
||||
)
|
||||
}),
|
||||
];
|
||||
|
||||
#[derive(Debug)]
|
||||
|
@ -314,11 +324,16 @@ impl ObjectImpl for ReqwestHttpSrc {
|
|||
let user_agent = value.get().unwrap();
|
||||
settings.user_agent = user_agent;
|
||||
}
|
||||
subclass::Property("is-live", ..) => {
|
||||
let element = obj.downcast_ref::<gst_base::BaseSrc>().unwrap();
|
||||
let is_live = value.get().unwrap();
|
||||
element.set_live(is_live);
|
||||
}
|
||||
_ => unimplemented!(),
|
||||
};
|
||||
}
|
||||
|
||||
fn get_property(&self, _obj: &glib::Object, id: usize) -> Result<glib::Value, ()> {
|
||||
fn get_property(&self, obj: &glib::Object, id: usize) -> Result<glib::Value, ()> {
|
||||
let prop = &PROPERTIES[id];
|
||||
match *prop {
|
||||
subclass::Property("location", ..) => {
|
||||
|
@ -331,6 +346,10 @@ impl ObjectImpl for ReqwestHttpSrc {
|
|||
let settings = self.settings.lock().unwrap();
|
||||
Ok(settings.user_agent.to_value())
|
||||
}
|
||||
subclass::Property("is-live", ..) => {
|
||||
let element = obj.downcast_ref::<gst_base::BaseSrc>().unwrap();
|
||||
Ok(element.is_live().to_value())
|
||||
}
|
||||
_ => unimplemented!(),
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue