reqwesthttpsrc: add is-live property

This commit is contained in:
ahamedsajeer.15 2019-08-07 00:43:18 +05:30 committed by Sebastian Dröge
parent 1e71767b40
commit 923f6e3a5c

View file

@ -37,6 +37,7 @@ const DEFAULT_USER_AGENT: &str = concat!(
"-", "-",
env!("COMMIT_ID") env!("COMMIT_ID")
); );
const DEFAULT_IS_LIVE: bool = false;
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
struct Settings { struct Settings {
@ -53,7 +54,7 @@ impl Default for Settings {
} }
} }
static PROPERTIES: [subclass::Property; 2] = [ static PROPERTIES: [subclass::Property; 3] = [
subclass::Property("location", |name| { subclass::Property("location", |name| {
glib::ParamSpec::string( glib::ParamSpec::string(
name, name,
@ -72,6 +73,15 @@ static PROPERTIES: [subclass::Property; 2] = [
glib::ParamFlags::READWRITE, 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)] #[derive(Debug)]
@ -314,11 +324,16 @@ impl ObjectImpl for ReqwestHttpSrc {
let user_agent = value.get().unwrap(); let user_agent = value.get().unwrap();
settings.user_agent = user_agent; 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!(), _ => 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]; let prop = &PROPERTIES[id];
match *prop { match *prop {
subclass::Property("location", ..) => { subclass::Property("location", ..) => {
@ -331,6 +346,10 @@ impl ObjectImpl for ReqwestHttpSrc {
let settings = self.settings.lock().unwrap(); let settings = self.settings.lock().unwrap();
Ok(settings.user_agent.to_value()) 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!(), _ => unimplemented!(),
} }
} }