mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2024-11-25 19:11:06 +00:00
Update to new clone macro syntax
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1463>
This commit is contained in:
parent
0be8b364f8
commit
5ea912d702
5 changed files with 172 additions and 149 deletions
26
Cargo.lock
generated
26
Cargo.lock
generated
|
@ -169,7 +169,7 @@ checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9"
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cairo-rs"
|
name = "cairo-rs"
|
||||||
version = "0.20.0"
|
version = "0.20.0"
|
||||||
source = "git+https://github.com/gtk-rs/gtk-rs-core?branch=master#d88a7c473e2af36a4718a648406b7894d288ec1b"
|
source = "git+https://github.com/gtk-rs/gtk-rs-core?branch=master#dc97710becdf432e5a97e0b7c22d4d1daa8cfec6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 2.5.0",
|
"bitflags 2.5.0",
|
||||||
"cairo-sys-rs",
|
"cairo-sys-rs",
|
||||||
|
@ -181,7 +181,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cairo-sys-rs"
|
name = "cairo-sys-rs"
|
||||||
version = "0.20.0"
|
version = "0.20.0"
|
||||||
source = "git+https://github.com/gtk-rs/gtk-rs-core?branch=master#d88a7c473e2af36a4718a648406b7894d288ec1b"
|
source = "git+https://github.com/gtk-rs/gtk-rs-core?branch=master#dc97710becdf432e5a97e0b7c22d4d1daa8cfec6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"glib-sys",
|
"glib-sys",
|
||||||
"libc",
|
"libc",
|
||||||
|
@ -678,7 +678,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "gio"
|
name = "gio"
|
||||||
version = "0.20.0"
|
version = "0.20.0"
|
||||||
source = "git+https://github.com/gtk-rs/gtk-rs-core?branch=master#d88a7c473e2af36a4718a648406b7894d288ec1b"
|
source = "git+https://github.com/gtk-rs/gtk-rs-core?branch=master#dc97710becdf432e5a97e0b7c22d4d1daa8cfec6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"futures-channel",
|
"futures-channel",
|
||||||
"futures-core",
|
"futures-core",
|
||||||
|
@ -695,7 +695,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "gio-sys"
|
name = "gio-sys"
|
||||||
version = "0.20.0"
|
version = "0.20.0"
|
||||||
source = "git+https://github.com/gtk-rs/gtk-rs-core?branch=master#d88a7c473e2af36a4718a648406b7894d288ec1b"
|
source = "git+https://github.com/gtk-rs/gtk-rs-core?branch=master#dc97710becdf432e5a97e0b7c22d4d1daa8cfec6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"glib-sys",
|
"glib-sys",
|
||||||
"gobject-sys",
|
"gobject-sys",
|
||||||
|
@ -724,7 +724,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "glib"
|
name = "glib"
|
||||||
version = "0.20.0"
|
version = "0.20.0"
|
||||||
source = "git+https://github.com/gtk-rs/gtk-rs-core?branch=master#d88a7c473e2af36a4718a648406b7894d288ec1b"
|
source = "git+https://github.com/gtk-rs/gtk-rs-core?branch=master#dc97710becdf432e5a97e0b7c22d4d1daa8cfec6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 2.5.0",
|
"bitflags 2.5.0",
|
||||||
"futures-channel",
|
"futures-channel",
|
||||||
|
@ -745,7 +745,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "glib-macros"
|
name = "glib-macros"
|
||||||
version = "0.20.0"
|
version = "0.20.0"
|
||||||
source = "git+https://github.com/gtk-rs/gtk-rs-core?branch=master#d88a7c473e2af36a4718a648406b7894d288ec1b"
|
source = "git+https://github.com/gtk-rs/gtk-rs-core?branch=master#dc97710becdf432e5a97e0b7c22d4d1daa8cfec6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"heck",
|
"heck",
|
||||||
"proc-macro-crate",
|
"proc-macro-crate",
|
||||||
|
@ -757,7 +757,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "glib-sys"
|
name = "glib-sys"
|
||||||
version = "0.20.0"
|
version = "0.20.0"
|
||||||
source = "git+https://github.com/gtk-rs/gtk-rs-core?branch=master#d88a7c473e2af36a4718a648406b7894d288ec1b"
|
source = "git+https://github.com/gtk-rs/gtk-rs-core?branch=master#dc97710becdf432e5a97e0b7c22d4d1daa8cfec6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
"system-deps",
|
"system-deps",
|
||||||
|
@ -820,7 +820,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "gobject-sys"
|
name = "gobject-sys"
|
||||||
version = "0.20.0"
|
version = "0.20.0"
|
||||||
source = "git+https://github.com/gtk-rs/gtk-rs-core?branch=master#d88a7c473e2af36a4718a648406b7894d288ec1b"
|
source = "git+https://github.com/gtk-rs/gtk-rs-core?branch=master#dc97710becdf432e5a97e0b7c22d4d1daa8cfec6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"glib-sys",
|
"glib-sys",
|
||||||
"libc",
|
"libc",
|
||||||
|
@ -1679,7 +1679,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "0c2a198fb6b0eada2a8df47933734e6d35d350665a33a3593d7164fa52c75c19"
|
checksum = "0c2a198fb6b0eada2a8df47933734e6d35d350665a33a3593d7164fa52c75c19"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"windows-targets 0.52.5",
|
"windows-targets 0.48.5",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -1898,7 +1898,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pango"
|
name = "pango"
|
||||||
version = "0.20.0"
|
version = "0.20.0"
|
||||||
source = "git+https://github.com/gtk-rs/gtk-rs-core?branch=master#d88a7c473e2af36a4718a648406b7894d288ec1b"
|
source = "git+https://github.com/gtk-rs/gtk-rs-core?branch=master#dc97710becdf432e5a97e0b7c22d4d1daa8cfec6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"gio",
|
"gio",
|
||||||
"glib",
|
"glib",
|
||||||
|
@ -1909,7 +1909,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pango-sys"
|
name = "pango-sys"
|
||||||
version = "0.20.0"
|
version = "0.20.0"
|
||||||
source = "git+https://github.com/gtk-rs/gtk-rs-core?branch=master#d88a7c473e2af36a4718a648406b7894d288ec1b"
|
source = "git+https://github.com/gtk-rs/gtk-rs-core?branch=master#dc97710becdf432e5a97e0b7c22d4d1daa8cfec6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"glib-sys",
|
"glib-sys",
|
||||||
"gobject-sys",
|
"gobject-sys",
|
||||||
|
@ -1920,7 +1920,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pangocairo"
|
name = "pangocairo"
|
||||||
version = "0.20.0"
|
version = "0.20.0"
|
||||||
source = "git+https://github.com/gtk-rs/gtk-rs-core?branch=master#d88a7c473e2af36a4718a648406b7894d288ec1b"
|
source = "git+https://github.com/gtk-rs/gtk-rs-core?branch=master#dc97710becdf432e5a97e0b7c22d4d1daa8cfec6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cairo-rs",
|
"cairo-rs",
|
||||||
"glib",
|
"glib",
|
||||||
|
@ -1932,7 +1932,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pangocairo-sys"
|
name = "pangocairo-sys"
|
||||||
version = "0.20.0"
|
version = "0.20.0"
|
||||||
source = "git+https://github.com/gtk-rs/gtk-rs-core?branch=master#d88a7c473e2af36a4718a648406b7894d288ec1b"
|
source = "git+https://github.com/gtk-rs/gtk-rs-core?branch=master#dc97710becdf432e5a97e0b7c22d4d1daa8cfec6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cairo-sys-rs",
|
"cairo-sys-rs",
|
||||||
"glib-sys",
|
"glib-sys",
|
||||||
|
|
|
@ -132,8 +132,10 @@ fn create_pipeline() -> Result<gst::Pipeline, Error> {
|
||||||
overlay.connect_closure(
|
overlay.connect_closure(
|
||||||
"draw",
|
"draw",
|
||||||
false,
|
false,
|
||||||
glib::closure!(@strong drawer => move |_overlay: &gst::Element,
|
glib::closure!(
|
||||||
sample: &gst::Sample| {
|
#[strong]
|
||||||
|
drawer,
|
||||||
|
move |_overlay: &gst::Element, sample: &gst::Sample| {
|
||||||
use std::f64::consts::PI;
|
use std::f64::consts::PI;
|
||||||
|
|
||||||
let drawer = drawer.lock().unwrap();
|
let drawer = drawer.lock().unwrap();
|
||||||
|
@ -146,7 +148,8 @@ fn create_pipeline() -> Result<gst::Pipeline, Error> {
|
||||||
let bitmap = drawer.bitmap.as_ref().unwrap();
|
let bitmap = drawer.bitmap.as_ref().unwrap();
|
||||||
let render_target = drawer.render_target.as_ref().unwrap();
|
let render_target = drawer.render_target.as_ref().unwrap();
|
||||||
|
|
||||||
let global_angle = 360. * (timestamp % (10 * gst::ClockTime::SECOND)).nseconds() as f64
|
let global_angle = 360.
|
||||||
|
* (timestamp % (10 * gst::ClockTime::SECOND)).nseconds() as f64
|
||||||
/ (10.0 * gst::ClockTime::SECOND.nseconds() as f64);
|
/ (10.0 * gst::ClockTime::SECOND.nseconds() as f64);
|
||||||
let center_x = (info.width() / 2) as f32;
|
let center_x = (info.width() / 2) as f32;
|
||||||
let center_y = (info.height() / 2) as f32;
|
let center_y = (info.height() / 2) as f32;
|
||||||
|
@ -184,7 +187,10 @@ fn create_pipeline() -> Result<gst::Pipeline, Error> {
|
||||||
let matrix = Matrix3x2::rotation(angle, center_x, center_y);
|
let matrix = Matrix3x2::rotation(angle, center_x, center_y);
|
||||||
render_target.SetTransform(&matrix);
|
render_target.SetTransform(&matrix);
|
||||||
render_target.DrawTextLayout(
|
render_target.DrawTextLayout(
|
||||||
D2D_POINT_2F { x: 0f32, y: top_margin },
|
D2D_POINT_2F {
|
||||||
|
x: 0f32,
|
||||||
|
y: top_margin,
|
||||||
|
},
|
||||||
text_layout,
|
text_layout,
|
||||||
&text_brush,
|
&text_brush,
|
||||||
D2D1_DRAW_TEXT_OPTIONS_NONE,
|
D2D1_DRAW_TEXT_OPTIONS_NONE,
|
||||||
|
@ -200,7 +206,8 @@ fn create_pipeline() -> Result<gst::Pipeline, Error> {
|
||||||
let _ = render_target.Flush(None::<*mut u64>, None::<*mut u64>);
|
let _ = render_target.Flush(None::<*mut u64>, None::<*mut u64>);
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut buffer = gst::Buffer::with_size((info.width() * info.height() * 4) as usize).unwrap();
|
let mut buffer =
|
||||||
|
gst::Buffer::with_size((info.width() * info.height() * 4) as usize).unwrap();
|
||||||
{
|
{
|
||||||
let buffer_mut = buffer.get_mut().unwrap();
|
let buffer_mut = buffer.get_mut().unwrap();
|
||||||
let mut map = buffer_mut.map_writable().unwrap();
|
let mut map = buffer_mut.map_writable().unwrap();
|
||||||
|
@ -209,7 +216,9 @@ fn create_pipeline() -> Result<gst::Pipeline, Error> {
|
||||||
unsafe {
|
unsafe {
|
||||||
// Bitmap size is equal to the background image size.
|
// Bitmap size is equal to the background image size.
|
||||||
// Copy entire memory
|
// Copy entire memory
|
||||||
bitmap.CopyPixels(std::ptr::null(), info.width() * 4, dst).unwrap();
|
bitmap
|
||||||
|
.CopyPixels(std::ptr::null(), info.width() * 4, dst)
|
||||||
|
.unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -239,9 +248,9 @@ fn create_pipeline() -> Result<gst::Pipeline, Error> {
|
||||||
gst_video::VideoOverlayFormatFlags::PREMULTIPLIED_ALPHA,
|
gst_video::VideoOverlayFormatFlags::PREMULTIPLIED_ALPHA,
|
||||||
);
|
);
|
||||||
|
|
||||||
gst_video::VideoOverlayComposition::new(Some(&rect))
|
gst_video::VideoOverlayComposition::new(Some(&rect)).unwrap()
|
||||||
.unwrap()
|
}
|
||||||
}),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
// Add a signal handler to the overlay's "caps-changed" signal. This could e.g.
|
// Add a signal handler to the overlay's "caps-changed" signal. This could e.g.
|
||||||
|
|
|
@ -119,8 +119,9 @@ fn create_pipeline() -> Result<gst::Pipeline, Error> {
|
||||||
overlay.connect_closure(
|
overlay.connect_closure(
|
||||||
"draw",
|
"draw",
|
||||||
false,
|
false,
|
||||||
glib::closure!(@strong drawer => move |_overlay: &gst::Element,
|
glib::closure!(
|
||||||
sample: &gst::Sample| {
|
#[strong] drawer,
|
||||||
|
move |_overlay: &gst::Element, sample: &gst::Sample| {
|
||||||
use std::f64::consts::PI;
|
use std::f64::consts::PI;
|
||||||
|
|
||||||
let drawer = drawer.lock().unwrap();
|
let drawer = drawer.lock().unwrap();
|
||||||
|
|
|
@ -195,7 +195,11 @@ impl StreamProducer {
|
||||||
let fku_probe_id = srcpad
|
let fku_probe_id = srcpad
|
||||||
.add_probe(
|
.add_probe(
|
||||||
gst::PadProbeType::EVENT_UPSTREAM,
|
gst::PadProbeType::EVENT_UPSTREAM,
|
||||||
glib::clone!(@weak appsink, @weak consumer => @default-panic, move |_pad, info| {
|
glib::clone!(
|
||||||
|
#[weak]
|
||||||
|
appsink,
|
||||||
|
#[upgrade_or_panic]
|
||||||
|
move |_pad, info| {
|
||||||
let Some(event) = info.event() else {
|
let Some(event) = info.event() else {
|
||||||
return gst::PadProbeReturn::Ok;
|
return gst::PadProbeReturn::Ok;
|
||||||
};
|
};
|
||||||
|
@ -208,7 +212,8 @@ impl StreamProducer {
|
||||||
}
|
}
|
||||||
|
|
||||||
gst::PadProbeReturn::Ok
|
gst::PadProbeReturn::Ok
|
||||||
}),
|
}
|
||||||
|
),
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
@ -410,7 +415,7 @@ impl<'a> From<&'a gst_app::AppSink> for StreamProducer {
|
||||||
|
|
||||||
appsink.set_callbacks(
|
appsink.set_callbacks(
|
||||||
gst_app::AppSinkCallbacks::builder()
|
gst_app::AppSinkCallbacks::builder()
|
||||||
.new_sample(glib::clone!(@strong consumers => move |appsink| {
|
.new_sample(glib::clone!(#[strong] consumers, move |appsink| {
|
||||||
let mut consumers = consumers.lock().unwrap();
|
let mut consumers = consumers.lock().unwrap();
|
||||||
|
|
||||||
let sample = match appsink.pull_sample() {
|
let sample = match appsink.pull_sample() {
|
||||||
|
@ -429,7 +434,7 @@ impl<'a> From<&'a gst_app::AppSink> for StreamProducer {
|
||||||
|
|
||||||
StreamProducer::process_sample(sample, appsink, consumers)
|
StreamProducer::process_sample(sample, appsink, consumers)
|
||||||
}))
|
}))
|
||||||
.new_preroll(glib::clone!(@strong consumers => move |appsink| {
|
.new_preroll(glib::clone!(#[strong] consumers, move |appsink| {
|
||||||
let mut consumers = consumers.lock().unwrap();
|
let mut consumers = consumers.lock().unwrap();
|
||||||
|
|
||||||
let sample = match appsink.pull_preroll() {
|
let sample = match appsink.pull_preroll() {
|
||||||
|
@ -448,7 +453,7 @@ impl<'a> From<&'a gst_app::AppSink> for StreamProducer {
|
||||||
Ok(gst::FlowSuccess::Ok)
|
Ok(gst::FlowSuccess::Ok)
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
.new_event(glib::clone!(@strong consumers => move |appsink| {
|
.new_event(glib::clone!(#[strong] consumers, move |appsink| {
|
||||||
match appsink.pull_object().map(|obj| obj.downcast::<gst::Event>()) {
|
match appsink.pull_object().map(|obj| obj.downcast::<gst::Event>()) {
|
||||||
Ok(Ok(event)) => {
|
Ok(Ok(event)) => {
|
||||||
let (events_to_forward, appsrcs) = {
|
let (events_to_forward, appsrcs) = {
|
||||||
|
@ -472,7 +477,7 @@ impl<'a> From<&'a gst_app::AppSink> for StreamProducer {
|
||||||
|
|
||||||
false
|
false
|
||||||
}))
|
}))
|
||||||
.eos(glib::clone!(@strong consumers => move |appsink| {
|
.eos(glib::clone!(#[strong] consumers, move |appsink| {
|
||||||
let stream_consumers = consumers
|
let stream_consumers = consumers
|
||||||
.lock()
|
.lock()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
@ -499,7 +504,10 @@ impl<'a> From<&'a gst_app::AppSink> for StreamProducer {
|
||||||
let sinkpad = appsink.static_pad("sink").unwrap();
|
let sinkpad = appsink.static_pad("sink").unwrap();
|
||||||
sinkpad.add_probe(
|
sinkpad.add_probe(
|
||||||
gst::PadProbeType::EVENT_UPSTREAM,
|
gst::PadProbeType::EVENT_UPSTREAM,
|
||||||
glib::clone!(@strong consumers => move |_pad, info| {
|
glib::clone!(
|
||||||
|
#[strong]
|
||||||
|
consumers,
|
||||||
|
move |_pad, info| {
|
||||||
let Some(event) = info.event() else {
|
let Some(event) = info.event() else {
|
||||||
return gst::PadProbeReturn::Ok;
|
return gst::PadProbeReturn::Ok;
|
||||||
};
|
};
|
||||||
|
@ -513,7 +521,8 @@ impl<'a> From<&'a gst_app::AppSink> for StreamProducer {
|
||||||
consumers.current_latency = Some(latency);
|
consumers.current_latency = Some(latency);
|
||||||
|
|
||||||
gst::PadProbeReturn::Ok
|
gst::PadProbeReturn::Ok
|
||||||
}),
|
}
|
||||||
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
StreamProducer {
|
StreamProducer {
|
||||||
|
|
|
@ -387,11 +387,15 @@ mod tests {
|
||||||
let called = Arc::new(Mutex::new(false));
|
let called = Arc::new(Mutex::new(false));
|
||||||
let succeeding_action_type = crate::ActionTypeBuilder::new(
|
let succeeding_action_type = crate::ActionTypeBuilder::new(
|
||||||
"succeeds",
|
"succeeds",
|
||||||
glib::clone!(@strong called => move |_, _action| {
|
glib::clone!(
|
||||||
|
#[strong]
|
||||||
|
called,
|
||||||
|
move |_, _action| {
|
||||||
*called.lock().unwrap() = true;
|
*called.lock().unwrap() = true;
|
||||||
|
|
||||||
Ok(crate::ActionSuccess::Ok)
|
Ok(crate::ActionSuccess::Ok)
|
||||||
}),
|
}
|
||||||
|
),
|
||||||
)
|
)
|
||||||
.parameter(
|
.parameter(
|
||||||
crate::ActionParameterBuilder::new("always", "Does the action always succeeds")
|
crate::ActionParameterBuilder::new("always", "Does the action always succeeds")
|
||||||
|
|
Loading…
Reference in a new issue