On Thu, 2021-04-08 at 21:54 -0500, kakakong wrote:
fn sink_event(&self, element: &Self::Type, event: gst::Event) -> bool {
match event.view() {
let state = self.state.lock().unwrap();
EventView::StreamStart(_) => {
state.inspect_timer
.schedule_repeating(chrono::Duration::seconds(1), move ||
unsafe {
// how to get self and element instance
})
.ignore();
}
_ => (),
}
}
i need get element state and element instance's real-time data.
i attempt to use raw pointer, but it not work;
In the code above you have `element` which is the element instance, and `self` which should be the private/implementation state of it.
If you want to pass that to the closure, you could do something like
let element_clone = element.clone();
state.inspect_timer.schedule_repeating(chrono::Duration::seconds(1), move || {
let imp = YourElementType::from_instance(&element_clone); // This is the same as `self` outside the closure
[...]
})
.ignore();
Note that this keeps the element alive until the closure is dropped.
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel