diff --git a/examples/src/bin/appsink.rs b/examples/src/bin/appsink.rs index fc999b375..468468e6e 100644 --- a/examples/src/bin/appsink.rs +++ b/examples/src/bin/appsink.rs @@ -61,7 +61,7 @@ fn create_pipeline() -> Result { )); appsink.set_callbacks( - gst_app::AppSinkCallbacksBuilder::new() + gst_app::AppSinkCallbacks::new() .new_sample(|appsink| { let sample = match appsink.pull_sample() { None => return gst::FlowReturn::Eos, diff --git a/gstreamer-app/src/app_sink.rs b/gstreamer-app/src/app_sink.rs index b4396d310..374524017 100644 --- a/gstreamer-app/src/app_sink.rs +++ b/gstreamer-app/src/app_sink.rs @@ -22,14 +22,8 @@ pub struct AppSinkCallbacks { callbacks: ffi::GstAppSinkCallbacks, } -pub struct AppSinkCallbacksBuilder { - eos: Option>, - new_preroll: Option gst::FlowReturn + Send + Sync + 'static>>, - new_sample: Option gst::FlowReturn + Send + Sync + 'static>>, -} - -impl AppSinkCallbacksBuilder { - pub fn new() -> Self { +impl AppSinkCallbacks { + pub fn new() -> AppSinkCallbacksBuilder { skip_assert_initialized!(); AppSinkCallbacksBuilder { eos: None, @@ -37,7 +31,15 @@ impl AppSinkCallbacksBuilder { new_sample: None, } } +} +pub struct AppSinkCallbacksBuilder { + eos: Option>, + new_preroll: Option gst::FlowReturn + Send + Sync + 'static>>, + new_sample: Option gst::FlowReturn + Send + Sync + 'static>>, +} + +impl AppSinkCallbacksBuilder { pub fn eos(self, eos: F) -> Self { Self { eos: Some(Box::new(eos)), diff --git a/gstreamer-app/src/app_src.rs b/gstreamer-app/src/app_src.rs index a32785a51..2a590c3e0 100644 --- a/gstreamer-app/src/app_src.rs +++ b/gstreamer-app/src/app_src.rs @@ -21,6 +21,18 @@ pub struct AppSrcCallbacks { 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 { need_data: Option>, enough_data: Option>,