mirror of
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
synced 2025-01-02 07:18:43 +00:00
threadshare: Use appsink callbacks instead of signals in the tests
This commit is contained in:
parent
1ec1352c88
commit
94f75c29a1
5 changed files with 130 additions and 95 deletions
|
@ -77,7 +77,9 @@ fn jb_pipeline() {
|
||||||
|
|
||||||
let appsink = sink.dynamic_cast::<gst_app::AppSink>().unwrap();
|
let appsink = sink.dynamic_cast::<gst_app::AppSink>().unwrap();
|
||||||
let (sender, receiver) = mpsc::channel();
|
let (sender, receiver) = mpsc::channel();
|
||||||
appsink.connect_new_sample(move |appsink| {
|
appsink.set_callbacks(
|
||||||
|
gst_app::AppSinkCallbacks::builder()
|
||||||
|
.new_sample(move |appsink| {
|
||||||
let _sample = appsink
|
let _sample = appsink
|
||||||
.emit_by_name("pull-sample", &[])
|
.emit_by_name("pull-sample", &[])
|
||||||
.unwrap()
|
.unwrap()
|
||||||
|
@ -87,7 +89,9 @@ fn jb_pipeline() {
|
||||||
|
|
||||||
sender.send(()).unwrap();
|
sender.send(()).unwrap();
|
||||||
Ok(gst::FlowSuccess::Ok)
|
Ok(gst::FlowSuccess::Ok)
|
||||||
});
|
})
|
||||||
|
.build(),
|
||||||
|
);
|
||||||
|
|
||||||
pipeline.set_state(gst::State::Playing).unwrap();
|
pipeline.set_state(gst::State::Playing).unwrap();
|
||||||
|
|
||||||
|
@ -143,7 +147,9 @@ fn jb_ts_pipeline() {
|
||||||
|
|
||||||
let appsink = sink.dynamic_cast::<gst_app::AppSink>().unwrap();
|
let appsink = sink.dynamic_cast::<gst_app::AppSink>().unwrap();
|
||||||
let (sender, receiver) = mpsc::channel();
|
let (sender, receiver) = mpsc::channel();
|
||||||
appsink.connect_new_sample(move |appsink| {
|
appsink.set_callbacks(
|
||||||
|
gst_app::AppSinkCallbacks::builder()
|
||||||
|
.new_sample(move |appsink| {
|
||||||
let _sample = appsink
|
let _sample = appsink
|
||||||
.emit_by_name("pull-sample", &[])
|
.emit_by_name("pull-sample", &[])
|
||||||
.unwrap()
|
.unwrap()
|
||||||
|
@ -153,7 +159,9 @@ fn jb_ts_pipeline() {
|
||||||
|
|
||||||
sender.send(()).unwrap();
|
sender.send(()).unwrap();
|
||||||
Ok(gst::FlowSuccess::Ok)
|
Ok(gst::FlowSuccess::Ok)
|
||||||
});
|
})
|
||||||
|
.build(),
|
||||||
|
);
|
||||||
|
|
||||||
pipeline.set_state(gst::State::Playing).unwrap();
|
pipeline.set_state(gst::State::Playing).unwrap();
|
||||||
|
|
||||||
|
|
|
@ -86,7 +86,9 @@ fn multiple_contexts_queue() {
|
||||||
|
|
||||||
let appsink = sink.dynamic_cast::<gst_app::AppSink>().unwrap();
|
let appsink = sink.dynamic_cast::<gst_app::AppSink>().unwrap();
|
||||||
let sender_clone = sender.clone();
|
let sender_clone = sender.clone();
|
||||||
appsink.connect_new_sample(move |appsink| {
|
appsink.set_callbacks(
|
||||||
|
gst_app::AppSinkCallbacks::builder()
|
||||||
|
.new_sample(move |appsink| {
|
||||||
let _sample = appsink
|
let _sample = appsink
|
||||||
.emit_by_name("pull-sample", &[])
|
.emit_by_name("pull-sample", &[])
|
||||||
.unwrap()
|
.unwrap()
|
||||||
|
@ -96,7 +98,9 @@ fn multiple_contexts_queue() {
|
||||||
|
|
||||||
sender_clone.send(()).unwrap();
|
sender_clone.send(()).unwrap();
|
||||||
Ok(gst::FlowSuccess::Ok)
|
Ok(gst::FlowSuccess::Ok)
|
||||||
});
|
})
|
||||||
|
.build(),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
let pipeline_clone = pipeline.clone();
|
let pipeline_clone = pipeline.clone();
|
||||||
|
@ -244,7 +248,9 @@ fn multiple_contexts_proxy() {
|
||||||
|
|
||||||
let appsink = sink.dynamic_cast::<gst_app::AppSink>().unwrap();
|
let appsink = sink.dynamic_cast::<gst_app::AppSink>().unwrap();
|
||||||
let sender_clone = sender.clone();
|
let sender_clone = sender.clone();
|
||||||
appsink.connect_new_sample(move |appsink| {
|
appsink.set_callbacks(
|
||||||
|
gst_app::AppSinkCallbacks::builder()
|
||||||
|
.new_sample(move |appsink| {
|
||||||
let _sample = appsink
|
let _sample = appsink
|
||||||
.emit_by_name("pull-sample", &[])
|
.emit_by_name("pull-sample", &[])
|
||||||
.unwrap()
|
.unwrap()
|
||||||
|
@ -254,7 +260,9 @@ fn multiple_contexts_proxy() {
|
||||||
|
|
||||||
sender_clone.send(()).unwrap();
|
sender_clone.send(()).unwrap();
|
||||||
Ok(gst::FlowSuccess::Ok)
|
Ok(gst::FlowSuccess::Ok)
|
||||||
});
|
})
|
||||||
|
.build(),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
let pipeline_clone = pipeline.clone();
|
let pipeline_clone = pipeline.clone();
|
||||||
|
@ -361,7 +369,9 @@ fn eos() {
|
||||||
let (sample_notifier, sample_notif_rcv) = mpsc::channel();
|
let (sample_notifier, sample_notif_rcv) = mpsc::channel();
|
||||||
let (eos_notifier, eos_notif_rcv) = mpsc::channel();
|
let (eos_notifier, eos_notif_rcv) = mpsc::channel();
|
||||||
let appsink = appsink.dynamic_cast::<gst_app::AppSink>().unwrap();
|
let appsink = appsink.dynamic_cast::<gst_app::AppSink>().unwrap();
|
||||||
appsink.connect_new_sample(move |appsink| {
|
appsink.set_callbacks(
|
||||||
|
gst_app::AppSinkCallbacks::builder()
|
||||||
|
.new_sample(move |appsink| {
|
||||||
gst_debug!(CAT, obj: appsink, "eos: pulling sample");
|
gst_debug!(CAT, obj: appsink, "eos: pulling sample");
|
||||||
let _ = appsink
|
let _ = appsink
|
||||||
.emit_by_name("pull-sample", &[])
|
.emit_by_name("pull-sample", &[])
|
||||||
|
@ -373,9 +383,10 @@ fn eos() {
|
||||||
sample_notifier.send(()).unwrap();
|
sample_notifier.send(()).unwrap();
|
||||||
|
|
||||||
Ok(gst::FlowSuccess::Ok)
|
Ok(gst::FlowSuccess::Ok)
|
||||||
});
|
})
|
||||||
|
.eos(move |_appsink| eos_notifier.send(()).unwrap())
|
||||||
appsink.connect_eos(move |_appsink| eos_notifier.send(()).unwrap());
|
.build(),
|
||||||
|
);
|
||||||
|
|
||||||
fn push_buffer(src: &gst::Element) -> bool {
|
fn push_buffer(src: &gst::Element) -> bool {
|
||||||
gst_debug!(CAT, obj: src, "eos: pushing buffer");
|
gst_debug!(CAT, obj: src, "eos: pushing buffer");
|
||||||
|
@ -504,7 +515,9 @@ fn premature_shutdown() {
|
||||||
let (appsink_sender, appsink_receiver) = mpsc::channel();
|
let (appsink_sender, appsink_receiver) = mpsc::channel();
|
||||||
|
|
||||||
let appsink = appsink.dynamic_cast::<gst_app::AppSink>().unwrap();
|
let appsink = appsink.dynamic_cast::<gst_app::AppSink>().unwrap();
|
||||||
appsink.connect_new_sample(move |appsink| {
|
appsink.set_callbacks(
|
||||||
|
gst_app::AppSinkCallbacks::builder()
|
||||||
|
.new_sample(move |appsink| {
|
||||||
gst_debug!(CAT, obj: appsink, "premature_shutdown: pulling sample");
|
gst_debug!(CAT, obj: appsink, "premature_shutdown: pulling sample");
|
||||||
let _sample = appsink
|
let _sample = appsink
|
||||||
.emit_by_name("pull-sample", &[])
|
.emit_by_name("pull-sample", &[])
|
||||||
|
@ -516,7 +529,9 @@ fn premature_shutdown() {
|
||||||
appsink_sender.send(()).unwrap();
|
appsink_sender.send(()).unwrap();
|
||||||
|
|
||||||
Ok(gst::FlowSuccess::Ok)
|
Ok(gst::FlowSuccess::Ok)
|
||||||
});
|
})
|
||||||
|
.build(),
|
||||||
|
);
|
||||||
|
|
||||||
fn push_buffer(src: &gst::Element, intent: &str) -> bool {
|
fn push_buffer(src: &gst::Element, intent: &str) -> bool {
|
||||||
gst_debug!(
|
gst_debug!(
|
||||||
|
|
|
@ -56,7 +56,9 @@ fn test_push() {
|
||||||
|
|
||||||
let appsink = appsink.dynamic_cast::<gst_app::AppSink>().unwrap();
|
let appsink = appsink.dynamic_cast::<gst_app::AppSink>().unwrap();
|
||||||
let samples_clone = samples.clone();
|
let samples_clone = samples.clone();
|
||||||
appsink.connect_new_sample(move |appsink| {
|
appsink.set_callbacks(
|
||||||
|
gst_app::AppSinkCallbacks::builder()
|
||||||
|
.new_sample(move |appsink| {
|
||||||
let sample = appsink
|
let sample = appsink
|
||||||
.emit_by_name("pull-sample", &[])
|
.emit_by_name("pull-sample", &[])
|
||||||
.unwrap()
|
.unwrap()
|
||||||
|
@ -67,7 +69,9 @@ fn test_push() {
|
||||||
samples_clone.lock().unwrap().push(sample);
|
samples_clone.lock().unwrap().push(sample);
|
||||||
|
|
||||||
Ok(gst::FlowSuccess::Ok)
|
Ok(gst::FlowSuccess::Ok)
|
||||||
});
|
})
|
||||||
|
.build(),
|
||||||
|
);
|
||||||
|
|
||||||
pipeline.set_state(gst::State::Playing).unwrap();
|
pipeline.set_state(gst::State::Playing).unwrap();
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,9 @@ fn test_push() {
|
||||||
|
|
||||||
let appsink = appsink.dynamic_cast::<gst_app::AppSink>().unwrap();
|
let appsink = appsink.dynamic_cast::<gst_app::AppSink>().unwrap();
|
||||||
let samples_clone = samples.clone();
|
let samples_clone = samples.clone();
|
||||||
appsink.connect_new_sample(move |appsink| {
|
appsink.set_callbacks(
|
||||||
|
gst_app::AppSinkCallbacks::builder()
|
||||||
|
.new_sample(move |appsink| {
|
||||||
let sample = appsink
|
let sample = appsink
|
||||||
.emit_by_name("pull-sample", &[])
|
.emit_by_name("pull-sample", &[])
|
||||||
.unwrap()
|
.unwrap()
|
||||||
|
@ -62,7 +64,9 @@ fn test_push() {
|
||||||
samples_clone.lock().unwrap().push(sample);
|
samples_clone.lock().unwrap().push(sample);
|
||||||
|
|
||||||
Ok(gst::FlowSuccess::Ok)
|
Ok(gst::FlowSuccess::Ok)
|
||||||
});
|
})
|
||||||
|
.build(),
|
||||||
|
);
|
||||||
|
|
||||||
pipeline.set_state(gst::State::Playing).unwrap();
|
pipeline.set_state(gst::State::Playing).unwrap();
|
||||||
|
|
||||||
|
|
|
@ -73,7 +73,9 @@ fn test_push() {
|
||||||
|
|
||||||
let appsink = appsink.dynamic_cast::<gst_app::AppSink>().unwrap();
|
let appsink = appsink.dynamic_cast::<gst_app::AppSink>().unwrap();
|
||||||
let samples_clone = samples.clone();
|
let samples_clone = samples.clone();
|
||||||
appsink.connect_new_sample(move |appsink| {
|
appsink.set_callbacks(
|
||||||
|
gst_app::AppSinkCallbacks::builder()
|
||||||
|
.new_sample(move |appsink| {
|
||||||
let sample = appsink
|
let sample = appsink
|
||||||
.emit_by_name("pull-sample", &[])
|
.emit_by_name("pull-sample", &[])
|
||||||
.unwrap()
|
.unwrap()
|
||||||
|
@ -84,7 +86,9 @@ fn test_push() {
|
||||||
let mut samples = samples_clone.lock().unwrap();
|
let mut samples = samples_clone.lock().unwrap();
|
||||||
samples.push(sample);
|
samples.push(sample);
|
||||||
Ok(gst::FlowSuccess::Ok)
|
Ok(gst::FlowSuccess::Ok)
|
||||||
});
|
})
|
||||||
|
.build(),
|
||||||
|
);
|
||||||
|
|
||||||
// Wait for the server to listen
|
// Wait for the server to listen
|
||||||
listening_rx.recv().unwrap();
|
listening_rx.recv().unwrap();
|
||||||
|
|
Loading…
Reference in a new issue