Commit 396dae66 authored by Sebastian Dröge's avatar Sebastian Dröge 🍵
Browse files

Make appsink/appsrc callbacks builder more consistent with other code

Move the constructor of the builder to the main type
parent 7dc2e43d
......@@ -61,7 +61,7 @@ fn create_pipeline() -> Result<gst::Pipeline, Error> {
));
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,
......
......@@ -22,14 +22,8 @@ pub struct AppSinkCallbacks {
callbacks: ffi::GstAppSinkCallbacks,
}
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 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<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 {
Self {
eos: Some(Box::new(eos)),
......
......@@ -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<Box<Fn(&AppSrc, u32) + Send + Sync + 'static>>,
enough_data: Option<Box<Fn(&AppSrc) + Send + Sync + 'static>>,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment