forked from mirrors/gstreamer-rs
Make appsink/appsrc callbacks builder more consistent with other code
Move the constructor of the builder to the main type
This commit is contained in:
parent
7dc2e43db3
commit
396dae666f
3 changed files with 23 additions and 9 deletions
|
@ -61,7 +61,7 @@ fn create_pipeline() -> Result<gst::Pipeline, Error> {
|
||||||
));
|
));
|
||||||
|
|
||||||
appsink.set_callbacks(
|
appsink.set_callbacks(
|
||||||
gst_app::AppSinkCallbacksBuilder::new()
|
gst_app::AppSinkCallbacks::new()
|
||||||
.new_sample(|appsink| {
|
.new_sample(|appsink| {
|
||||||
let sample = match appsink.pull_sample() {
|
let sample = match appsink.pull_sample() {
|
||||||
None => return gst::FlowReturn::Eos,
|
None => return gst::FlowReturn::Eos,
|
||||||
|
|
|
@ -22,14 +22,8 @@ pub struct AppSinkCallbacks {
|
||||||
callbacks: ffi::GstAppSinkCallbacks,
|
callbacks: ffi::GstAppSinkCallbacks,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct AppSinkCallbacksBuilder {
|
impl AppSinkCallbacks {
|
||||||
eos: Option<Box<Fn(&AppSink) + Send + Sync + 'static>>,
|
pub fn new() -> AppSinkCallbacksBuilder {
|
||||||
new_preroll: Option<Box<Fn(&AppSink) -> gst::FlowReturn + Send + Sync + 'static>>,
|
|
||||||
new_sample: Option<Box<Fn(&AppSink) -> gst::FlowReturn + Send + Sync + 'static>>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl AppSinkCallbacksBuilder {
|
|
||||||
pub fn new() -> Self {
|
|
||||||
skip_assert_initialized!();
|
skip_assert_initialized!();
|
||||||
AppSinkCallbacksBuilder {
|
AppSinkCallbacksBuilder {
|
||||||
eos: None,
|
eos: None,
|
||||||
|
@ -37,7 +31,15 @@ impl AppSinkCallbacksBuilder {
|
||||||
new_sample: None,
|
new_sample: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct AppSinkCallbacksBuilder {
|
||||||
|
eos: Option<Box<Fn(&AppSink) + Send + Sync + 'static>>,
|
||||||
|
new_preroll: Option<Box<Fn(&AppSink) -> gst::FlowReturn + Send + Sync + 'static>>,
|
||||||
|
new_sample: Option<Box<Fn(&AppSink) -> gst::FlowReturn + Send + Sync + 'static>>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl AppSinkCallbacksBuilder {
|
||||||
pub fn eos<F: Fn(&AppSink) + Send + Sync + 'static>(self, eos: F) -> Self {
|
pub fn eos<F: Fn(&AppSink) + Send + Sync + 'static>(self, eos: F) -> Self {
|
||||||
Self {
|
Self {
|
||||||
eos: Some(Box::new(eos)),
|
eos: Some(Box::new(eos)),
|
||||||
|
|
|
@ -21,6 +21,18 @@ pub struct AppSrcCallbacks {
|
||||||
callbacks: ffi::GstAppSrcCallbacks,
|
callbacks: ffi::GstAppSrcCallbacks,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl AppSrcCallbacks {
|
||||||
|
pub fn new() -> AppSrcCallbacksBuilder {
|
||||||
|
skip_assert_initialized!();
|
||||||
|
|
||||||
|
AppSrcCallbacksBuilder {
|
||||||
|
need_data: None,
|
||||||
|
enough_data: None,
|
||||||
|
seek_data: None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub struct AppSrcCallbacksBuilder {
|
pub struct AppSrcCallbacksBuilder {
|
||||||
need_data: Option<Box<Fn(&AppSrc, u32) + Send + Sync + 'static>>,
|
need_data: Option<Box<Fn(&AppSrc, u32) + Send + Sync + 'static>>,
|
||||||
enough_data: Option<Box<Fn(&AppSrc) + Send + Sync + 'static>>,
|
enough_data: Option<Box<Fn(&AppSrc) + Send + Sync + 'static>>,
|
||||||
|
|
Loading…
Reference in a new issue